homebridge 2.0.0-beta.3 → 2.0.0-beta.31

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 (169) hide show
  1. package/README.md +16 -17
  2. package/bin/homebridge.js +22 -0
  3. package/config-sample.json +3 -3
  4. package/dist/api.d.ts +457 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +221 -0
  7. package/dist/api.js.map +1 -0
  8. package/{lib → dist}/bridgeService.d.ts +19 -10
  9. package/dist/bridgeService.d.ts.map +1 -0
  10. package/{lib → dist}/bridgeService.js +85 -117
  11. package/dist/bridgeService.js.map +1 -0
  12. package/dist/childBridgeFork.d.ts +65 -0
  13. package/dist/childBridgeFork.d.ts.map +1 -0
  14. package/dist/childBridgeFork.js +531 -0
  15. package/dist/childBridgeFork.js.map +1 -0
  16. package/{lib → dist}/childBridgeService.d.ts +30 -7
  17. package/dist/childBridgeService.d.ts.map +1 -0
  18. package/{lib → dist}/childBridgeService.js +127 -69
  19. package/dist/childBridgeService.js.map +1 -0
  20. package/dist/cli.d.ts +3 -0
  21. package/dist/cli.d.ts.map +1 -0
  22. package/dist/cli.js +90 -0
  23. package/dist/cli.js.map +1 -0
  24. package/dist/externalPortService.d.ts +54 -0
  25. package/dist/externalPortService.d.ts.map +1 -0
  26. package/dist/externalPortService.js +125 -0
  27. package/dist/externalPortService.js.map +1 -0
  28. package/dist/index.d.ts +122 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +34 -0
  31. package/dist/index.js.map +1 -0
  32. package/{lib → dist}/ipcService.d.ts +22 -5
  33. package/dist/ipcService.d.ts.map +1 -0
  34. package/{lib → dist}/ipcService.js +12 -12
  35. package/dist/ipcService.js.map +1 -0
  36. package/{lib → dist}/logger.d.ts +12 -6
  37. package/dist/logger.d.ts.map +1 -0
  38. package/{lib → dist}/logger.js +27 -28
  39. package/dist/logger.js.map +1 -0
  40. package/dist/matter/index.d.ts +123 -0
  41. package/dist/matter/index.d.ts.map +1 -0
  42. package/dist/matter/index.js +19 -0
  43. package/dist/matter/index.js.map +1 -0
  44. package/dist/matter/matterAccessoryCache.d.ts +96 -0
  45. package/dist/matter/matterAccessoryCache.d.ts.map +1 -0
  46. package/dist/matter/matterAccessoryCache.js +192 -0
  47. package/dist/matter/matterAccessoryCache.js.map +1 -0
  48. package/dist/matter/matterBehaviors.d.ts +194 -0
  49. package/dist/matter/matterBehaviors.d.ts.map +1 -0
  50. package/dist/matter/matterBehaviors.js +665 -0
  51. package/dist/matter/matterBehaviors.js.map +1 -0
  52. package/dist/matter/matterConfigValidator.d.ts +81 -0
  53. package/dist/matter/matterConfigValidator.d.ts.map +1 -0
  54. package/dist/matter/matterConfigValidator.js +240 -0
  55. package/dist/matter/matterConfigValidator.js.map +1 -0
  56. package/dist/matter/matterErrorHandler.d.ts +106 -0
  57. package/dist/matter/matterErrorHandler.d.ts.map +1 -0
  58. package/dist/matter/matterErrorHandler.js +495 -0
  59. package/dist/matter/matterErrorHandler.js.map +1 -0
  60. package/dist/matter/matterLogFormatter.d.ts +19 -0
  61. package/dist/matter/matterLogFormatter.d.ts.map +1 -0
  62. package/dist/matter/matterLogFormatter.js +144 -0
  63. package/dist/matter/matterLogFormatter.js.map +1 -0
  64. package/dist/matter/matterNetworkMonitor.d.ts +68 -0
  65. package/dist/matter/matterNetworkMonitor.d.ts.map +1 -0
  66. package/dist/matter/matterNetworkMonitor.js +249 -0
  67. package/dist/matter/matterNetworkMonitor.js.map +1 -0
  68. package/dist/matter/matterServer.d.ts +656 -0
  69. package/dist/matter/matterServer.d.ts.map +1 -0
  70. package/dist/matter/matterServer.js +1690 -0
  71. package/dist/matter/matterServer.js.map +1 -0
  72. package/dist/matter/matterServerHelpers.d.ts +81 -0
  73. package/dist/matter/matterServerHelpers.d.ts.map +1 -0
  74. package/dist/matter/matterServerHelpers.js +323 -0
  75. package/dist/matter/matterServerHelpers.js.map +1 -0
  76. package/dist/matter/matterSharedTypes.d.ts +170 -0
  77. package/dist/matter/matterSharedTypes.d.ts.map +1 -0
  78. package/dist/matter/matterSharedTypes.js +52 -0
  79. package/dist/matter/matterSharedTypes.js.map +1 -0
  80. package/dist/matter/matterStorage.d.ts +128 -0
  81. package/dist/matter/matterStorage.d.ts.map +1 -0
  82. package/dist/matter/matterStorage.js +415 -0
  83. package/dist/matter/matterStorage.js.map +1 -0
  84. package/dist/matter/matterTypes.d.ts +745 -0
  85. package/dist/matter/matterTypes.d.ts.map +1 -0
  86. package/dist/matter/matterTypes.js +174 -0
  87. package/dist/matter/matterTypes.js.map +1 -0
  88. package/{lib → dist}/platformAccessory.d.ts +8 -6
  89. package/dist/platformAccessory.d.ts.map +1 -0
  90. package/{lib → dist}/platformAccessory.js +19 -16
  91. package/dist/platformAccessory.js.map +1 -0
  92. package/{lib → dist}/plugin.d.ts +2 -3
  93. package/dist/plugin.d.ts.map +1 -0
  94. package/{lib → dist}/plugin.js +39 -51
  95. package/dist/plugin.js.map +1 -0
  96. package/{lib → dist}/pluginManager.d.ts +3 -3
  97. package/dist/pluginManager.d.ts.map +1 -0
  98. package/{lib → dist}/pluginManager.js +76 -81
  99. package/dist/pluginManager.js.map +1 -0
  100. package/{lib → dist}/server.d.ts +23 -1
  101. package/dist/server.d.ts.map +1 -0
  102. package/dist/server.js +811 -0
  103. package/dist/server.js.map +1 -0
  104. package/{lib → dist}/storageService.d.ts.map +1 -1
  105. package/dist/storageService.js +41 -0
  106. package/dist/storageService.js.map +1 -0
  107. package/{lib → dist}/user.d.ts +1 -0
  108. package/dist/user.d.ts.map +1 -0
  109. package/dist/user.js +32 -0
  110. package/dist/user.js.map +1 -0
  111. package/{lib → dist}/util/mac.d.ts +1 -0
  112. package/dist/util/mac.d.ts.map +1 -0
  113. package/dist/util/mac.js +14 -0
  114. package/dist/util/mac.js.map +1 -0
  115. package/dist/version.d.ts.map +1 -0
  116. package/dist/version.js +16 -0
  117. package/dist/version.js.map +1 -0
  118. package/package.json +48 -49
  119. package/bin/homebridge +0 -17
  120. package/lib/api.d.ts +0 -210
  121. package/lib/api.d.ts.map +0 -1
  122. package/lib/api.js +0 -155
  123. package/lib/api.js.map +0 -1
  124. package/lib/bridgeService.d.ts.map +0 -1
  125. package/lib/bridgeService.js.map +0 -1
  126. package/lib/childBridgeFork.d.ts +0 -37
  127. package/lib/childBridgeFork.d.ts.map +0 -1
  128. package/lib/childBridgeFork.js +0 -244
  129. package/lib/childBridgeFork.js.map +0 -1
  130. package/lib/childBridgeService.d.ts.map +0 -1
  131. package/lib/childBridgeService.js.map +0 -1
  132. package/lib/cli.d.ts +0 -4
  133. package/lib/cli.d.ts.map +0 -1
  134. package/lib/cli.js +0 -111
  135. package/lib/cli.js.map +0 -1
  136. package/lib/externalPortService.d.ts +0 -33
  137. package/lib/externalPortService.d.ts.map +0 -1
  138. package/lib/externalPortService.js +0 -64
  139. package/lib/externalPortService.js.map +0 -1
  140. package/lib/index.d.ts +0 -76
  141. package/lib/index.d.ts.map +0 -1
  142. package/lib/index.js +0 -72
  143. package/lib/index.js.map +0 -1
  144. package/lib/ipcService.d.ts.map +0 -1
  145. package/lib/ipcService.js.map +0 -1
  146. package/lib/logger.d.ts.map +0 -1
  147. package/lib/logger.js.map +0 -1
  148. package/lib/platformAccessory.d.ts.map +0 -1
  149. package/lib/platformAccessory.js.map +0 -1
  150. package/lib/plugin.d.ts.map +0 -1
  151. package/lib/plugin.js.map +0 -1
  152. package/lib/pluginManager.d.ts.map +0 -1
  153. package/lib/pluginManager.js.map +0 -1
  154. package/lib/server.d.ts.map +0 -1
  155. package/lib/server.js +0 -457
  156. package/lib/server.js.map +0 -1
  157. package/lib/storageService.js +0 -70
  158. package/lib/storageService.js.map +0 -1
  159. package/lib/user.d.ts.map +0 -1
  160. package/lib/user.js +0 -36
  161. package/lib/user.js.map +0 -1
  162. package/lib/util/mac.d.ts.map +0 -1
  163. package/lib/util/mac.js +0 -20
  164. package/lib/util/mac.js.map +0 -1
  165. package/lib/version.d.ts.map +0 -1
  166. package/lib/version.js +0 -21
  167. package/lib/version.js.map +0 -1
  168. /package/{lib → dist}/storageService.d.ts +0 -0
  169. /package/{lib → dist}/version.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterTypes.d.ts","sourceRoot":"","sources":["../../src/matter/matterTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG1D,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAG/C,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAE1H;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAA;CACjD;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,gGAAgG;IAChG,EAAE,EAAE,MAAM,CAAA;IAEV,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,uCAAuC;IACvC,UAAU,EAAE,YAAY,CAAA;IAExB;;;OAGG;IACH,QAAQ,EAAE;QACR,CAAC,WAAW,EAAE,MAAM,GAAG;YACrB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAA;SACjC,CAAA;KACF,CAAA;IAED;;;OAGG;IACH,QAAQ,CAAC,EAAE;QACT,CAAC,W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Of;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,IAAI,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,KAAK,uBAAuB,CAAA;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE;QACb,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAA;QAC/B,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAChC,CAAA;IACD,+BAA+B,CAAC,EAAE,MAAM,CAAA;IACxC,gCAAgC,CAAC,EAAE,MAAM,CAAA;IACzC,+BAA+B,CAAC,EAAE,MAAM,CAAA;IACxC,gCAAgC,CAAC,EAAE,MAAM,CAAA;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,eAAe,GACzB,qBAAqB,GAAG,SAAS,CAEnC"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Matter Types for Homebridge Plugin API
3
+ *
4
+ * This module provides types and interfaces for plugin developers
5
+ * to create Matter-compatible accessories.
6
+ */
7
+ // Import Matter.js clusters and device types
8
+ import * as clusters from '@matter/main/clusters';
9
+ import * as devices from '@matter/main/devices';
10
+ /**
11
+ * Matter error type enum (for error handler categorization)
12
+ */
13
+ export var MatterErrorType;
14
+ (function (MatterErrorType) {
15
+ MatterErrorType["INITIALIZATION"] = "INITIALIZATION";
16
+ MatterErrorType["NETWORK"] = "NETWORK";
17
+ MatterErrorType["COMMISSIONING"] = "COMMISSIONING";
18
+ MatterErrorType["DEVICE_SYNC"] = "DEVICE_SYNC";
19
+ MatterErrorType["SERVER"] = "SERVER";
20
+ MatterErrorType["STORAGE"] = "STORAGE";
21
+ MatterErrorType["CONFIGURATION"] = "CONFIGURATION";
22
+ MatterErrorType["DEVICE_ERROR"] = "DEVICE_ERROR";
23
+ MatterErrorType["UNKNOWN"] = "UNKNOWN";
24
+ })(MatterErrorType || (MatterErrorType = {}));
25
+ /**
26
+ * Matter error types
27
+ */
28
+ export class MatterError extends Error {
29
+ code;
30
+ details;
31
+ type;
32
+ timestamp;
33
+ recoverable;
34
+ constructor(message, code, details) {
35
+ super(message);
36
+ this.code = code;
37
+ this.details = details;
38
+ this.name = 'MatterError';
39
+ this.type = details?.type ?? MatterErrorType.UNKNOWN;
40
+ this.timestamp = new Date();
41
+ this.recoverable = details?.recoverable ?? true;
42
+ }
43
+ }
44
+ export class MatterCommissioningError extends MatterError {
45
+ constructor(message, details) {
46
+ super(message, 'COMMISSIONING_ERROR', { ...details, type: MatterErrorType.COMMISSIONING });
47
+ this.name = 'MatterCommissioningError';
48
+ }
49
+ }
50
+ export class MatterStorageError extends MatterError {
51
+ constructor(message, details) {
52
+ super(message, 'STORAGE_ERROR', { ...details, type: MatterErrorType.STORAGE });
53
+ this.name = 'MatterStorageError';
54
+ }
55
+ }
56
+ export class MatterDeviceError extends MatterError {
57
+ constructor(message, details) {
58
+ super(message, 'DEVICE_ERROR', { ...details, type: MatterErrorType.DEVICE_ERROR });
59
+ this.name = 'MatterDeviceError';
60
+ }
61
+ }
62
+ export class MatterNetworkError extends MatterError {
63
+ constructor(message, details) {
64
+ super(message, 'NETWORK_ERROR', { ...details, type: MatterErrorType.NETWORK });
65
+ this.name = 'MatterNetworkError';
66
+ }
67
+ }
68
+ // Export Matter.js clusters for direct access
69
+ export { clusters };
70
+ // Export raw devices namespace (for advanced use)
71
+ export { devices };
72
+ /**
73
+ * Friendly device type names for the Plugin API
74
+ * Maps simplified names to actual Matter.js device types
75
+ */
76
+ export const deviceTypes = {
77
+ // Lighting
78
+ OnOffLight: devices.OnOffLightDevice,
79
+ DimmableLight: devices.DimmableLightDevice,
80
+ ColorTemperatureLight: devices.ColorTemperatureLightDevice,
81
+ ExtendedColorLight: devices.ExtendedColorLightDevice,
82
+ // Switches & Outlets
83
+ OnOffSwitch: devices.OnOffLightSwitchDevice,
84
+ OnOffOutlet: devices.OnOffPlugInUnitDevice,
85
+ DimmableOutlet: devices.DimmablePlugInUnitDevice,
86
+ // Sensors
87
+ TemperatureSensor: devices.TemperatureSensorDevice,
88
+ HumiditySensor: devices.HumiditySensorDevice,
89
+ LightSensor: devices.LightSensorDevice,
90
+ MotionSensor: devices.OccupancySensorDevice,
91
+ ContactSensor: devices.ContactSensorDevice,
92
+ LeakSensor: devices.WaterLeakDetectorDevice,
93
+ SmokeSensor: devices.SmokeCoAlarmDevice,
94
+ // HVAC
95
+ Thermostat: devices.ThermostatDevice.with(devices.ThermostatRequirements.ThermostatServer.with('Heating', 'Cooling')),
96
+ Fan: devices.FanDevice,
97
+ // Security
98
+ DoorLock: devices.DoorLockDevice,
99
+ // Window Coverings (features will be auto-detected based on accessory attributes)
100
+ WindowCovering: devices.WindowCoveringDevice,
101
+ // Appliances
102
+ // RVC optional clusters (RvcCleanMode, ServiceArea) are added dynamically in matterServer
103
+ // based on whether they're defined in the accessory configuration
104
+ RoboticVacuumCleaner: devices.RoboticVacuumCleanerDevice,
105
+ // Other
106
+ GenericSwitch: devices.GenericSwitchDevice,
107
+ Pump: devices.PumpDevice,
108
+ RoomAirConditioner: devices.RoomAirConditionerDevice,
109
+ };
110
+ /**
111
+ * Matter Cluster Names
112
+ * Commonly used cluster names for type safety and autocomplete
113
+ * Use these with api.updateMatterAccessoryState() and api.getAccessoryState()
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * // With autocomplete and type safety:
118
+ * api.updateMatterAccessoryState(uuid, api.matterClusterNames.OnOff, { onOff: true })
119
+ * api.getAccessoryState(uuid, api.matterClusterNames.LevelControl)
120
+ * ```
121
+ */
122
+ export const clusterNames = {
123
+ // Control Clusters
124
+ OnOff: 'onOff',
125
+ LevelControl: 'levelControl',
126
+ ColorControl: 'colorControl',
127
+ DoorLock: 'doorLock',
128
+ WindowCovering: 'windowCovering',
129
+ Thermostat: 'thermostat',
130
+ FanControl: 'fanControl',
131
+ // Sensor Clusters
132
+ TemperatureMeasurement: 'temperatureMeasurement',
133
+ RelativeHumidityMeasurement: 'relativeHumidityMeasurement',
134
+ IlluminanceMeasurement: 'illuminanceMeasurement',
135
+ OccupancySensing: 'occupancySensing',
136
+ BooleanState: 'booleanState',
137
+ SmokeCoAlarm: 'smokeCoAlarm',
138
+ // Robotic Vacuum Cleaner Clusters
139
+ RvcRunMode: 'rvcRunMode',
140
+ RvcOperationalState: 'rvcOperationalState',
141
+ RvcCleanMode: 'rvcCleanMode',
142
+ ServiceArea: 'serviceArea',
143
+ // Pump & Other
144
+ PumpConfigurationAndControl: 'pumpConfigurationAndControl',
145
+ // Identification
146
+ Identify: 'identify',
147
+ // Device Information (read-only, set during registration)
148
+ BasicInformation: 'basicInformation',
149
+ BridgedDeviceBasicInformation: 'bridgedDeviceBasicInformation',
150
+ };
151
+ /**
152
+ * Check if endpoint has state property (runtime check)
153
+ */
154
+ export function hasEndpointState(endpoint) {
155
+ return 'state' in endpoint && typeof endpoint.state === 'object';
156
+ }
157
+ /**
158
+ * Safely update endpoint state
159
+ * Uses the Endpoint's set method to update cluster attributes
160
+ */
161
+ export async function updateEndpointState(endpoint, cluster, attributes) {
162
+ if (!hasEndpointState(endpoint)) {
163
+ throw new Error('Endpoint does not support state updates');
164
+ }
165
+ const updateObject = { [cluster]: attributes };
166
+ await endpoint.set(updateObject);
167
+ }
168
+ /**
169
+ * Type-safe cluster access for WindowCovering
170
+ */
171
+ export function getWindowCoveringCluster(accessory) {
172
+ return accessory.clusters?.windowCovering;
173
+ }
174
+ //# sourceMappingURL=matterTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterTypes.js","sourceRoot":"","sources":["../../src/matter/matterTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,6CAA6C;AAC7C,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACjD,O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D,iBAAiB;IACjB,QAAQ,EAAE,UAAU;IAEpB,0DAA0D;IAC1D,gBAAgB,EAAE,kBAAkB;IACpC,6BAA6B,EAAE,+BAA+B;CACtD,CAAA;AAaV;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAkB;IACjD,OAAO,OAAO,IAAI,QAAQ,IAAI,OAAQ,QAAgB,CAAC,KAAK,KAAK,QAAQ,CAAA;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAkB,EAClB,OAAe,EACf,UAAmC;IAEnC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAC5D,CAAC;IAED,MAAM,YAAY,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IAC9C,MAAO,QAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAC3C,CAAC;AA2BD;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAA0B;IAE1B,OAAO,SAAS,CAAC,QAAQ,EAAE,cAAmD,CAAA;AAChF,CAAC"}
@@ -1,7 +1,8 @@
1
- import { EventEmitter } from "events";
2
- import { Accessory, Categories, Controller, ControllerConstructor, SerializedAccessory, Service, WithUUID } from "hap-nodejs";
3
- import { ConstructorArgs } from "hap-nodejs/dist/types";
4
- import { PlatformName, PluginIdentifier, PluginName } from "./api";
1
+ import type { Controller, ControllerConstructor, SerializedAccessory, Service, WithUUID } from 'hap-nodejs';
2
+ import type { ConstructorArgs } from 'hap-nodejs/dist/types.js';
3
+ import type { PlatformName, PluginIdentifier, PluginName } from './api.js';
4
+ import { EventEmitter } from 'node:events';
5
+ import { Accessory, Categories } from 'hap-nodejs';
5
6
  export type UnknownContext = Record<string, any>;
6
7
  export interface SerializedPlatformAccessory<T extends UnknownContext = UnknownContext> extends SerializedAccessory {
7
8
  plugin: PluginName;
@@ -12,8 +13,8 @@ export declare const enum PlatformAccessoryEvent {
12
13
  IDENTIFY = "identify"
13
14
  }
14
15
  export declare interface PlatformAccessory {
15
- on(event: "identify", listener: () => void): this;
16
- emit(event: "identify"): boolean;
16
+ on: (event: 'identify', listener: () => void) => this;
17
+ emit: (event: 'identify') => boolean;
17
18
  }
18
19
  export declare class PlatformAccessory<T extends UnknownContext = UnknownContext> extends EventEmitter {
19
20
  private static injectedAccessory?;
@@ -29,6 +30,7 @@ export declare class PlatformAccessory<T extends UnknownContext = UnknownContext
29
30
  */
30
31
  context: T;
31
32
  constructor(displayName: string, uuid: string, category?: Categories);
33
+ updateDisplayName(name: string): void;
32
34
  addService(service: Service): Service;
33
35
  addService<S extends typeof Service>(serviceConstructor: S, ...constructorArgs: ConstructorArgs<S>): Service;
34
36
  removeService(service: Service): void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAccessory.d.ts","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,OAAO,EAEP,QAAQ,EACT,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAuB,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEhD,MAAM,WAAW,2BAA2B,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CAAE,SAAQ,mBAAmB;IACjH,MAAM,EAAE,UAAU,CAAA;IAClB,QAAQ,EAAE,YAAY,CAAA;IACtB,OAAO,EAAE,CAAC,CAAA;CACX;AAGD,0BAA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EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIjH;;;;;OAKG;IACI,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,qBAAqB,GAAG,IAAI;IAIhF;;;;;OAKG;IACI,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAKrD,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,iBAAiB,GAAG,2BAA2B;IAU3E,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,2BAA2B,GAAG,iBAAiB;CAczE"}
@@ -1,13 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlatformAccessory = exports.PlatformAccessoryEvent = void 0;
4
- const events_1 = require("events");
5
- const hap_nodejs_1 = require("hap-nodejs");
6
- var PlatformAccessoryEvent;
1
+ import { EventEmitter } from 'node:events';
2
+ import { Accessory } from 'hap-nodejs';
3
+ // eslint-disable-next-line no-restricted-syntax
4
+ export var PlatformAccessoryEvent;
7
5
  (function (PlatformAccessoryEvent) {
8
6
  PlatformAccessoryEvent["IDENTIFY"] = "identify";
9
- })(PlatformAccessoryEvent || (exports.PlatformAccessoryEvent = PlatformAccessoryEvent = {}));
10
- class PlatformAccessory extends events_1.EventEmitter {
7
+ })(PlatformAccessoryEvent || (PlatformAccessoryEvent = {}));
8
+ // eslint-disable-next-line ts/no-unsafe-declaration-merging
9
+ export class PlatformAccessory extends EventEmitter {
11
10
  // somewhat ugly way to inject custom Accessory object, while not changing the publicly exposed constructor signature
12
11
  static injectedAccessory;
13
12
  _associatedPlugin; // present as soon as it is registered
@@ -27,7 +26,7 @@ class PlatformAccessory extends events_1.EventEmitter {
27
26
  super();
28
27
  this._associatedHAPAccessory = PlatformAccessory.injectedAccessory
29
28
  ? PlatformAccessory.injectedAccessory
30
- : new hap_nodejs_1.Accessory(displayName, uuid);
29
+ : new Accessory(displayName, uuid);
31
30
  if (category) {
32
31
  this._associatedHAPAccessory.category = category;
33
32
  }
@@ -37,13 +36,17 @@ class PlatformAccessory extends events_1.EventEmitter {
37
36
  this.services = this._associatedHAPAccessory.services;
38
37
  // forward identify event
39
38
  this._associatedHAPAccessory.on("identify" /* AccessoryEventTypes.IDENTIFY */, (paired, callback) => {
40
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
- // @ts-ignore
42
- // eslint-disable-next-line @typescript-eslint/no-empty-function
43
- this.emit("identify" /* PlatformAccessoryEvent.IDENTIFY */, paired, () => { }); // empty callback for backwards compatibility
39
+ // @ts-expect-error: empty callback for backwards compatibility
40
+ this.emit("identify" /* PlatformAccessoryEvent.IDENTIFY */, paired, () => { });
44
41
  callback();
45
42
  });
46
43
  }
44
+ updateDisplayName(name) {
45
+ if (name) {
46
+ this.displayName = name;
47
+ this._associatedHAPAccessory.displayName = name;
48
+ }
49
+ }
47
50
  addService(service, ...constructorArgs) {
48
51
  // @ts-expect-error: while the HAP-NodeJS interface was refined, the underlying implementation
49
52
  // still only operates on an any[] array. Therefore, do not require any additional checks here
@@ -79,15 +82,16 @@ class PlatformAccessory extends events_1.EventEmitter {
79
82
  }
80
83
  // private
81
84
  static serialize(accessory) {
85
+ accessory._associatedHAPAccessory.displayName = accessory.displayName;
82
86
  return {
83
87
  plugin: accessory._associatedPlugin,
84
88
  platform: accessory._associatedPlatform,
85
89
  context: accessory.context,
86
- ...hap_nodejs_1.Accessory.serialize(accessory._associatedHAPAccessory),
90
+ ...Accessory.serialize(accessory._associatedHAPAccessory),
87
91
  };
88
92
  }
89
93
  static deserialize(json) {
90
- const accessory = hap_nodejs_1.Accessory.deserialize(json);
94
+ const accessory = Accessory.deserialize(json);
91
95
  PlatformAccessory.injectedAccessory = accessory;
92
96
  const platformAccessory = new PlatformAccessory(accessory.displayName, accessory.UUID);
93
97
  PlatformAccessory.injectedAccessory = undefined;
@@ -98,5 +102,4 @@ class PlatformAccessory extends events_1.EventEmitter {
98
102
  return platformAccessory;
99
103
  }
100
104
  }
101
- exports.PlatformAccessory = PlatformAccessory;
102
105
  //# sourceMappingURL=platformAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAmC,MAAM,YAAY,CAAA;AAUvE,gDAAgD;AAChD,MAAM,CAAN,IAAkB,sBAEjB;AAFD,WAAkB,sBAAsB;IACtC,+CAAqB,CAAA;AACvB,CAAC,EAFiB,sBAAsB,KAAtB,sBAAsB,QAEvC;AAQD,4DAA4D;AAC5D,MAAM,OAAO,iBAA6D,SAAQ,YAAY;IAC5F,qHAAqH;IAC7G,MAAM,CAAC,iBAAiB,CAAY;IAE5C,iBAAiB,CAAmB,CAAC,sCAAsC;IAC3E,mBAAmB,CAAe,CAAC,uCAAuC;IAC1E,uBAAuB,CAAW;IAElC,yDAAyD;IACzD,WAAW,CAAQ;IACnB,IAAI,CAAQ;IACZ,QAAQ,CAAY;IACpB,QAAQ,GAAc,EAAE,CAAA;IACxB,yDAAyD;IAEzD;;OAEG;IACI,OAAO,GAAM,EAAO,CAAA,CAAC,+BAA+B;IAE3D,YAAY,WAAmB,EAAE,IAAY,EAAE,QAAqB;QAClE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,uBAAuB,GAAG,iBAAiB,CAAC,iBAAiB;YAChE,CAAC,CAAC,iBAAiB,CAAC,iBAAiB;YACrC,CAAC,CAAC,IAAI,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;QAEpC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,uBAAuB,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAClD,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAA;QAC3D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAA;QAC7C,IAAI,CAAC,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B;QAC5C,IAAI,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAC3D,CAAC;IAED,UAAU;IACV,MAAM,CAAC,SAAS,CAAC,SAA4B;QAC3C,SAAS,CAAC,uBAAuB,CAAC,WAAW,GAAG,SAAS,CAAC,WAAW,CAAA;QACrE,OAAO;YACL,MAAM,EAAE,SAAS,CAAC,iBAAkB;YACpC,QAAQ,EAAE,SAAS,CAAC,mBAAoB;YACxC,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,GAAG,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,uBAAuB,CAAC;SAC1D,CAAA;IACH,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAiC;QAClD,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;QAE7C,iBAAiB,CAAC,iBAAiB,GAAG,SAAS,CAAA;QAC/C,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QACtF,iBAAiB,CAAC,iBAAiB,GAAG,SAAS,CAAA;QAE/C,iBAAiB,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAA;QACjD,iBAAiB,CAAC,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAA;QACrD,iBAAiB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QACxC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAE1C,OAAO,iBAAiB,CAAA;IAC1B,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
- import { AccessoryIdentifier, AccessoryName, AccessoryPluginConstructor, API, PlatformIdentifier, PlatformName, DynamicPlatformPlugin, PlatformPluginConstructor, PluginIdentifier, PluginName } from "./api";
2
- import { PackageJSON } from "./pluginManager";
1
+ import type { AccessoryIdentifier, AccessoryName, AccessoryPluginConstructor, API, DynamicPlatformPlugin, PlatformIdentifier, PlatformName, PlatformPluginConstructor, PluginIdentifier, PluginName } from './api.js';
2
+ import type { PackageJSON } from './pluginManager.js';
3
3
  /**
4
4
  * Represents a loaded Homebridge plugin.
5
5
  */
@@ -7,7 +7,6 @@ export declare class Plugin {
7
7
  private readonly pluginName;
8
8
  private readonly scope?;
9
9
  private readonly pluginPath;
10
- private readonly isESM;
11
10
  disabled: boolean;
12
11
  readonly version: string;
13
12
  private readonly main;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,0BAA0B,EAC1B,GAAG,EACH,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACZ,yBAAyB,EACzB,gBAAgB,EAEhB,UAAU,EACX,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAerD;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAC5B,QAAQ,UAAQ;IAGvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO,CAAC,WAAW,CAAC,CAGnB;IAGD,OAAO,CAAC,iBAAiB,CAAC,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA4D;IAClG,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA0D;IAC9F,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAwD;gBAEnF,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,MAAM;IA+C7E,mBAAmB,IAAI,gBAAgB;IAIvC,aAAa,IAAI,MAAM;IAIvB,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,0BAA0B,GAAG,IAAI;IAYrF,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,yBAAyB,GAAG,IAAI;IAYlF,uBAAuB,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,aAAa,GAAG,0BAA0B;IAW7G,sBAAsB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,YAAY,GAAG,yBAAyB;IAiBxG,qBAAqB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,YAAY,EAAE,cAAc,EAAE,qBAAqB,GAAG,IAAI;IAczH,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,qBAAqB,GAAG,SAAS;IAMjF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkD3B,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAOlD"}
@@ -1,27 +1,19 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Plugin = void 0;
7
- const assert_1 = __importDefault(require("assert"));
8
- const path_1 = __importDefault(require("path"));
9
- const url_1 = require("url");
10
- const semver_1 = require("semver");
11
- const logger_1 = require("./logger");
12
- const pluginManager_1 = require("./pluginManager");
13
- const version_1 = __importDefault(require("./version"));
14
- const log = logger_1.Logger.internal;
15
- // Workaround for https://github.com/microsoft/TypeScript/issues/43329
16
- const _importDynamic = new Function("modulePath", "return import(modulePath)");
1
+ import assert from 'node:assert';
2
+ import { join } from 'node:path';
3
+ import process from 'node:process';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { satisfies } from 'semver';
6
+ import { Logger } from './logger.js';
7
+ import { PluginManager } from './pluginManager.js';
8
+ import getVersion from './version.js';
9
+ const log = Logger.internal;
17
10
  /**
18
11
  * Represents a loaded Homebridge plugin.
19
12
  */
20
- class Plugin {
13
+ export class Plugin {
21
14
  pluginName;
22
15
  scope; // npm package scope
23
16
  pluginPath; // like "/usr/local/lib/node_modules/homebridge-lockitron"
24
- isESM;
25
17
  disabled = false; // mark the plugin as disabled
26
18
  // ------------------ package.json content ------------------
27
19
  version;
@@ -36,20 +28,20 @@ class Plugin {
36
28
  this.pluginName = name;
37
29
  this.scope = scope;
38
30
  this.pluginPath = path;
39
- this.version = packageJSON.version || "0.0.0";
40
- this.main = "";
31
+ this.version = packageJSON.version || '0.0.0';
32
+ this.main = '';
41
33
  // figure out the main module
42
34
  // exports is available - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_package_entry_points
43
35
  if (packageJSON.exports) {
44
36
  // main entrypoint - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_main_entry_point_export
45
- if (typeof packageJSON.exports === "string") {
37
+ if (typeof packageJSON.exports === 'string') {
46
38
  this.main = packageJSON.exports;
47
39
  }
48
40
  else { // subpath export - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_subpath_exports
49
41
  // conditional exports - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_conditional_exports
50
- const exports = packageJSON.exports.import || packageJSON.exports.require || packageJSON.exports.node || packageJSON.exports.default || packageJSON.exports["."];
42
+ const exports = packageJSON.exports.import || packageJSON.exports.require || packageJSON.exports.node || packageJSON.exports.default || packageJSON.exports['.'];
51
43
  // check if conditional export is nested
52
- if (typeof exports !== "string") {
44
+ if (typeof exports !== 'string') {
53
45
  if (exports.import) {
54
46
  this.main = exports.import;
55
47
  }
@@ -64,10 +56,8 @@ class Plugin {
64
56
  }
65
57
  // exports search was not successful, fallback to package.main, using index.js as fallback
66
58
  if (!this.main) {
67
- this.main = packageJSON.main || "./index.js";
59
+ this.main = packageJSON.main || './index.js';
68
60
  }
69
- // check if it is an ESM module
70
- this.isESM = this.main.endsWith(".mjs") || (this.main.endsWith(".js") && packageJSON.type === "module");
71
61
  // very temporary fix for first wave of plugins
72
62
  if (packageJSON.peerDependencies && (!packageJSON.engines || !packageJSON.engines.homebridge)) {
73
63
  packageJSON.engines = packageJSON.engines || {};
@@ -79,7 +69,7 @@ class Plugin {
79
69
  };
80
70
  }
81
71
  getPluginIdentifier() {
82
- return (this.scope ? this.scope + "/" : "") + this.pluginName;
72
+ return (this.scope ? `${this.scope}/` : '') + this.pluginName;
83
73
  }
84
74
  getPluginPath() {
85
75
  return this.pluginPath;
@@ -89,7 +79,7 @@ class Plugin {
89
79
  throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register an accessory '${name}' which has already been registered!`);
90
80
  }
91
81
  if (!this.disabled) {
92
- log.info("Registering accessory '%s'", this.getPluginIdentifier() + "." + name);
82
+ log.info('Registering accessory \'%s\'', `${this.getPluginIdentifier()}.${name}`);
93
83
  }
94
84
  this.registeredAccessories.set(name, constructor);
95
85
  }
@@ -98,12 +88,12 @@ class Plugin {
98
88
  throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register a platform '${name}' which has already been registered!`);
99
89
  }
100
90
  if (!this.disabled) {
101
- log.info("Registering platform '%s'", this.getPluginIdentifier() + "." + name);
91
+ log.info('Registering platform \'%s\'', `${this.getPluginIdentifier()}.${name}`);
102
92
  }
103
93
  this.registeredPlatforms.set(name, constructor);
104
94
  }
105
95
  getAccessoryConstructor(accessoryIdentifier) {
106
- const name = pluginManager_1.PluginManager.getAccessoryName(accessoryIdentifier);
96
+ const name = PluginManager.getAccessoryName(accessoryIdentifier);
107
97
  const constructor = this.registeredAccessories.get(name);
108
98
  if (!constructor) {
109
99
  throw new Error(`The requested accessory '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`);
@@ -111,20 +101,20 @@ class Plugin {
111
101
  return constructor;
112
102
  }
113
103
  getPlatformConstructor(platformIdentifier) {
114
- const name = pluginManager_1.PluginManager.getPlatformName(platformIdentifier);
104
+ const name = PluginManager.getPlatformName(platformIdentifier);
115
105
  const constructor = this.registeredPlatforms.get(name);
116
106
  if (!constructor) {
117
107
  throw new Error(`The requested platform '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`);
118
108
  }
119
109
  // If it's a dynamic platform plugin, ensure it's not enabled multiple times.
120
110
  if (this.activeDynamicPlatforms.has(name)) {
121
- throw new Error("The dynamic platform " + name + " from the plugin " + this.getPluginIdentifier() + " is configured " +
122
- "times in your config.json.");
111
+ throw new Error(`The dynamic platform ${name} from the plugin ${this.getPluginIdentifier()} is configured `
112
+ + 'times in your config.json.');
123
113
  }
124
114
  return constructor;
125
115
  }
126
116
  assignDynamicPlatform(platformIdentifier, platformPlugin) {
127
- const name = pluginManager_1.PluginManager.getPlatformName(platformIdentifier);
117
+ const name = PluginManager.getPlatformName(platformIdentifier);
128
118
  let platforms = this.activeDynamicPlatforms.get(name);
129
119
  if (!platforms) {
130
120
  platforms = [];
@@ -141,42 +131,41 @@ class Plugin {
141
131
  }
142
132
  async load() {
143
133
  const context = this.loadContext;
144
- (0, assert_1.default)(context, "Reached illegal state. Plugin state is undefined!");
134
+ assert(context, 'Reached illegal state. Plugin state is undefined!');
145
135
  this.loadContext = undefined; // free up memory
146
- // pluck out the HomeBridge version requirement
136
+ // pluck out the Homebridge version requirement
147
137
  if (!context.engines || !context.engines.homebridge) {
148
138
  throw new Error(`Plugin ${this.pluginPath} does not contain the 'homebridge' package in 'engines'.`);
149
139
  }
150
140
  const versionRequired = context.engines.homebridge;
151
141
  const nodeVersionRequired = context.engines.node;
152
- // make sure the version is satisfied by the currently running version of HomeBridge
153
- if (!(0, semver_1.satisfies)((0, version_1.default)(), versionRequired, { includePrerelease: true })) {
142
+ // make sure the version is satisfied by the currently running version of Homebridge
143
+ if (!satisfies(getVersion(), versionRequired, { includePrerelease: true })) {
154
144
  // TODO - change this back to an error
155
- log.error(`The plugin "${this.pluginName}" requires a Homebridge version of ${versionRequired} which does \
156
- not satisfy the current Homebridge version of ${(0, version_1.default)()}. You may need to update this plugin (or Homebridge) to a newer version. \
145
+ log.warn(`The plugin "${this.pluginName}" requires a Homebridge version of ${versionRequired} which does \
146
+ not satisfy the current Homebridge version of v${getVersion()}. You may need to update this plugin (or Homebridge) to a newer version. \
157
147
  You may face unexpected issues or stability problems running this plugin.`);
158
148
  }
159
149
  // make sure the version is satisfied by the currently running version of Node
160
- if (nodeVersionRequired && !(0, semver_1.satisfies)(process.version, nodeVersionRequired)) {
161
- log.warn(`The plugin "${this.pluginName}" requires Node.js version of ${nodeVersionRequired} which does \
150
+ if (nodeVersionRequired && !satisfies(process.version, nodeVersionRequired)) {
151
+ log.warn(`The plugin "${this.pluginName}" requires a Node.js version of ${nodeVersionRequired} which does \
162
152
  not satisfy the current Node.js version of ${process.version}. You may need to upgrade your installation of Node.js - see https://homebridge.io/w/JTKEF`);
163
153
  }
164
154
  const dependencies = context.dependencies || {};
165
- if (dependencies.homebridge || dependencies["hap-nodejs"]) {
155
+ if (dependencies.homebridge || dependencies['hap-nodejs']) {
166
156
  log.error(`The plugin "${this.pluginName}" defines 'homebridge' and/or 'hap-nodejs' in their 'dependencies' section, \
167
157
  meaning they carry an additional copy of homebridge and hap-nodejs. This not only wastes disk space, but also can cause \
168
158
  major incompatibility issues and thus is considered bad practice. Please inform the developer to update their plugin!`);
169
159
  }
170
- const mainPath = path_1.default.join(this.pluginPath, this.main);
171
- // try to require() it and grab the exported initialization hook
172
- // eslint-disable-next-line @typescript-eslint/no-var-requires
160
+ const mainPath = join(this.pluginPath, this.main);
161
+ // try to import it and grab the exported initialization hook
173
162
  // pathToFileURL(specifier).href to turn a path into a "file url"
174
163
  // see https://github.com/nodejs/node/issues/31710
175
- const pluginModules = this.isESM ? await _importDynamic((0, url_1.pathToFileURL)(mainPath).href) : require(mainPath);
176
- if (typeof pluginModules === "function") {
164
+ const pluginModules = (await import(pathToFileURL(mainPath).href)).default;
165
+ if (typeof pluginModules === 'function') {
177
166
  this.pluginInitializer = pluginModules;
178
167
  }
179
- else if (pluginModules && typeof pluginModules.default === "function") {
168
+ else if (pluginModules && typeof pluginModules.default === 'function') {
180
169
  this.pluginInitializer = pluginModules.default;
181
170
  }
182
171
  else {
@@ -185,10 +174,9 @@ major incompatibility issues and thus is considered bad practice. Please inform
185
174
  }
186
175
  initialize(api) {
187
176
  if (!this.pluginInitializer) {
188
- throw new Error("Tried to initialize a plugin which hasn't been loaded yet!");
177
+ throw new Error('Tried to initialize a plugin which hasn\'t been loaded yet!');
189
178
  }
190
179
  return this.pluginInitializer(api);
191
180
  }
192
181
  }
193
- exports.Plugin = Plugin;
194
182
  //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAeA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,UAAU,MAAM,cAAc,CAAA;AAErC,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAA;AAE3B;;GAEG;AACH,MAAM,OAAO,MAAM;IACA,UAAU,CAAY;IACtB,KAAK,CAAS,CAAC,oBAAoB;IACnC,UAAU,CAAQ,CAAC,0DAA0D;IACvF,QAAQ,GAAG,KAAK,CAAA,CAAC,8BAA8B;IAEtD,6DAA6D;IACpD,OAAO,CAAQ;IACP,IAAI,CAAQ;IACrB,WAAW,CAGlB;IACD,6DAA6D;IAErD,iBAAiB,CAAoB,CAAC,gEAAgE;IAC7F,qBAAqB,GAAmD,IAAI,GAAG,EAAE,CAAA;IACjF,mBAAmB,GAAiD,IAAI,GAAG,EAAE,CAAA;I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AC,OAAO,KAAK,UAAU,EAAE,CAAC;YACxE,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,OAAO,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,UAAU,oDAAoD,CAAC,CAAA;QAChG,CAAC;IACH,CAAC;IAEM,UAAU,CAAC,GAAQ;QACxB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;QAChF,CAAC;QAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
- import { AccessoryIdentifier, AccessoryName, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, PluginName } from "./api";
2
- import { Plugin } from "./plugin";
1
+ import type { AccessoryIdentifier, AccessoryName, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, PluginName } from './api.js';
2
+ import { Plugin } from './plugin.js';
3
3
  export interface PackageJSON {
4
4
  name: string;
5
5
  version: string;
@@ -10,7 +10,7 @@ export interface PackageJSON {
10
10
  * When set as module, it marks .js file to be treated as ESM.
11
11
  * See https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_enabling
12
12
  */
13
- type?: "module" | "commonjs";
13
+ type?: 'module' | 'commonjs';
14
14
  engines?: Record<string, string>;
15
15
  dependencies?: Record<string, string>;
16
16
  devDependencies?: Record<string, string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginManager.d.ts","sourceRoot":"","sources":["../src/pluginManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAEb,aAAa,EACb,kBAAkB,EAClB,YAAY,EAEZ,gBAAgB,EAChB,UAAU,EACX,MAAM,UAAU,CAAA;AAUjB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMpC,MAAM,WA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