homebridge 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (79) hide show
  1. package/README.md +16 -17
  2. package/bin/homebridge +8 -6
  3. package/config-sample.json +3 -3
  4. package/dist/childBridgeFork.js +2 -0
  5. package/dist/childBridgeFork.js.map +7 -0
  6. package/dist/cli.js +2 -0
  7. package/dist/cli.js.map +7 -0
  8. package/dist/index.d.ts +1099 -0
  9. package/dist/index.js +2 -0
  10. package/dist/index.js.map +7 -0
  11. package/package.json +50 -47
  12. package/lib/api.d.ts +0 -210
  13. package/lib/api.d.ts.map +0 -1
  14. package/lib/api.js +0 -155
  15. package/lib/api.js.map +0 -1
  16. package/lib/bridgeService.d.ts +0 -105
  17. package/lib/bridgeService.d.ts.map +0 -1
  18. package/lib/bridgeService.js +0 -428
  19. package/lib/bridgeService.js.map +0 -1
  20. package/lib/childBridgeFork.d.ts +0 -37
  21. package/lib/childBridgeFork.d.ts.map +0 -1
  22. package/lib/childBridgeFork.js +0 -244
  23. package/lib/childBridgeFork.js.map +0 -1
  24. package/lib/childBridgeService.d.ts +0 -199
  25. package/lib/childBridgeService.d.ts.map +0 -1
  26. package/lib/childBridgeService.js +0 -428
  27. package/lib/childBridgeService.js.map +0 -1
  28. package/lib/cli.d.ts +0 -4
  29. package/lib/cli.d.ts.map +0 -1
  30. package/lib/cli.js +0 -115
  31. package/lib/cli.js.map +0 -1
  32. package/lib/externalPortService.d.ts +0 -33
  33. package/lib/externalPortService.d.ts.map +0 -1
  34. package/lib/externalPortService.js +0 -64
  35. package/lib/externalPortService.js.map +0 -1
  36. package/lib/index.d.ts +0 -76
  37. package/lib/index.d.ts.map +0 -1
  38. package/lib/index.js +0 -72
  39. package/lib/index.js.map +0 -1
  40. package/lib/ipcService.d.ts +0 -33
  41. package/lib/ipcService.d.ts.map +0 -1
  42. package/lib/ipcService.js +0 -49
  43. package/lib/ipcService.js.map +0 -1
  44. package/lib/logger.d.ts +0 -78
  45. package/lib/logger.d.ts.map +0 -1
  46. package/lib/logger.js +0 -147
  47. package/lib/logger.js.map +0 -1
  48. package/lib/platformAccessory.d.ts +0 -54
  49. package/lib/platformAccessory.d.ts.map +0 -1
  50. package/lib/platformAccessory.js +0 -102
  51. package/lib/platformAccessory.js.map +0 -1
  52. package/lib/plugin.d.ts +0 -31
  53. package/lib/plugin.d.ts.map +0 -1
  54. package/lib/plugin.js +0 -194
  55. package/lib/plugin.js.map +0 -1
  56. package/lib/pluginManager.d.ts +0 -77
  57. package/lib/pluginManager.d.ts.map +0 -1
  58. package/lib/pluginManager.js +0 -380
  59. package/lib/pluginManager.js.map +0 -1
  60. package/lib/server.d.ts +0 -58
  61. package/lib/server.d.ts.map +0 -1
  62. package/lib/server.js +0 -457
  63. package/lib/server.js.map +0 -1
  64. package/lib/storageService.d.ts +0 -13
  65. package/lib/storageService.d.ts.map +0 -1
  66. package/lib/storageService.js +0 -70
  67. package/lib/storageService.js.map +0 -1
  68. package/lib/user.d.ts +0 -13
  69. package/lib/user.d.ts.map +0 -1
  70. package/lib/user.js +0 -36
  71. package/lib/user.js.map +0 -1
  72. package/lib/util/mac.d.ts +0 -4
  73. package/lib/util/mac.d.ts.map +0 -1
  74. package/lib/util/mac.js +0 -20
  75. package/lib/util/mac.js.map +0 -1
  76. package/lib/version.d.ts +0 -3
  77. package/lib/version.d.ts.map +0 -1
  78. package/lib/version.js +0 -21
  79. package/lib/version.js.map +0 -1
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import ee from"hap-nodejs";import te from"semver";import d from"node:util";import a from"chalk";var l=(o=>(o.INFO="info",o.SUCCESS="success",o.WARN="warn",o.ERROR="error",o.DEBUG="debug",o))(l||{}),s=class n{static internal=new n;static loggerCache=new Map;static debugEnabled=!1;static timestampEnabled=!0;prefix;constructor(i){this.prefix=i}static withPrefix(i){let e=n.loggerCache.get(i);if(e)return e;{let r=new n(i),t=r.info.bind(r);t.info=r.info,t.success=r.success,t.warn=r.warn,t.error=r.error,t.debug=r.debug,t.log=r.log,t.prefix=r.prefix;let o=t;return n.loggerCache.set(i,o),o}}static setDebugEnabled(i=!0){n.debugEnabled=i}static setTimestampEnabled(i=!0){n.timestampEnabled=i}static forceColor(){a.level=1}info(i,...e){this.log("info",i,...e)}success(i,...e){this.log("success",i,...e)}warn(i,...e){this.log("warn",i,...e)}error(i,...e){this.log("error",i,...e)}debug(i,...e){this.log("debug",i,...e)}log(i,e,...r){if(i==="debug"&&!n.debugEnabled)return;e=d.format(e,...r);let t=console.log;switch(i){case"success":e=a.green(e);break;case"warn":e=a.yellow(e),t=console.error;break;case"error":e=a.red(e),t=console.error;break;case"debug":e=a.gray(e);break}if(this.prefix&&(e=`${m(this.prefix)} ${e}`),n.timestampEnabled){let o=new Date;e=a.white(`[${o.toLocaleString()}] `)+e}t(e)}};function m(n){return a.cyan(`[${n}]`)}import{Accessory as b,AccessoryEventTypes as R,Categories as T}from"hap-nodejs";var c=(i=>(i.IDENTIFY="identify",i))(c||{});import{createRequire as A}from"node:module";import{satisfies as O}from"semver";import{dirname as f,join as w}from"node:path";import{fileURLToPath as P}from"node:url";var p=P(import.meta.url),D=f(p);var U=s.internal;var V=s.internal,v=A(import.meta.url),W=v.resolve.paths("");var le=s.internal,g=(e=>(e.ACCESSORY="accessory",e.PLATFORM="platform",e))(g||{}),u=(e=>(e.DID_FINISH_LAUNCHING="didFinishLaunching",e.SHUTDOWN="shutdown",e))(u||{});import{Access as Pe,AccessControlEvent as pe,AccessLevel as he,AccessoryEventTypes as ye,AdaptiveLightingControllerEvents as Ae,AdaptiveLightingControllerMode as ve,AudioBitrate as Se,AudioCodecTypes as Ie,AudioRecordingCodecType as Ce,AudioRecordingSamplerate as Ee,AudioSamplerate as be,AudioStreamingCodecType as Re,AudioStreamingSamplerate as Te,ButtonState as Ne,ButtonType as xe,CameraControllerEvents as we,Categories as Le,ChangeReason as De,CharacteristicEventTypes as $e,DataFormatTags as Me,DataStreamConnectionEvent as Oe,DataStreamServerEvent as He,DataStreamStatus as _e,DefaultControllerType as je,EventTriggerOption as Ue,Formats as ze,H264Level as Fe,H264Profile as ke,HAPServerEventTypes as Ge,HAPStatus as qe,HDSProtocolSpecificErrorReason as Be,HDSStatus as Ve,MediaContainerType as We,PacketDataType as Ye,Perms as Qe,Protocols as Xe,RemoteControllerEvents as Ke,ResourceRequestReason as Ze,ServiceEventTypes as Je,SiriAudioSessionEvents as ei,SRTPCryptoSuites as ii,StreamRequestTypes as ti,TargetCategory as ri,TargetUpdates as ni,Topics as oi,Units as si}from"hap-nodejs";export{u as APIEvent,Pe as Access,pe as AccessControlEvent,he as AccessLevel,ye as AccessoryEventTypes,Ae as AdaptiveLightingControllerEvents,ve as AdaptiveLightingControllerMode,Se as AudioBitrate,Ie as AudioCodecTypes,Ce as AudioRecordingCodecType,Ee as AudioRecordingSamplerate,be as AudioSamplerate,Re as AudioStreamingCodecType,Te as AudioStreamingSamplerate,Ne as ButtonState,xe as ButtonType,we as CameraControllerEvents,Le as Categories,De as ChangeReason,$e as CharacteristicEventTypes,Me as DataFormatTags,Oe as DataStreamConnectionEvent,He as DataStreamServerEvent,_e as DataStreamStatus,je as DefaultControllerType,Ue as EventTriggerOption,ze as Formats,Fe as H264Level,ke as H264Profile,Ge as HAPServerEventTypes,qe as HAPStatus,Be as HDSProtocolSpecificErrorReason,Ve as HDSStatus,l as LogLevel,We as MediaContainerType,Ye as PacketDataType,Qe as Perms,c as PlatformAccessoryEvent,g as PluginType,Xe as Protocols,Ke as RemoteControllerEvents,Ze as ResourceRequestReason,ii as SRTPCryptoSuites,Je as ServiceEventTypes,ei as SiriAudioSessionEvents,ti as StreamRequestTypes,ri as TargetCategory,ni as TargetUpdates,oi as Topics,si as Units};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/api.ts", "../src/logger.ts", "../src/platformAccessory.ts", "../src/pluginManager.ts", "../src/plugin.ts", "../src/version.ts", "../src/index.ts"],
4
+ "sourcesContent": ["import type { Controller, Service } from 'hap-nodejs'\n\nimport type { AccessoryConfig, PlatformConfig } from './bridgeService.js'\nimport type { Logging } from './logger.js'\n\nimport { EventEmitter } from 'node:events'\n\nimport hapNodeJs from 'hap-nodejs'\nimport semver from 'semver'\n\nimport { Logger } from './logger.js'\nimport { PlatformAccessory } from './platformAccessory.js'\nimport { PluginManager } from './pluginManager.js'\nimport { User } from './user.js'\nimport getVersion from './version.js'\n\nconst log = Logger.internal\n\nexport type HAP = typeof hapNodeJs\nexport type HAPLegacyTypes = typeof hapNodeJs.LegacyTypes\n\nexport type PluginIdentifier = PluginName | ScopedPluginName\nexport type PluginName = string // plugin name like \"homebridge-dummy\"\nexport type ScopedPluginName = string // plugin name like \"@scope/homebridge-dummy\"\nexport type AccessoryName = string\nexport type PlatformName = string\n\nexport type AccessoryIdentifier = string // format: \"PluginIdentifier.AccessoryName\"\nexport type PlatformIdentifier = string // format: \"PluginIdentifier.PlatformName\"\n\n// eslint-disable-next-line no-restricted-syntax\nexport const enum PluginType {\n ACCESSORY = 'accessory',\n PLATFORM = 'platform',\n}\n\n/**\n * The {PluginInitializer} is a method which must be the default export for every homebridge plugin.\n * It is called once the plugin is loaded from disk.\n */\nexport interface PluginInitializer {\n\n /**\n * When the initializer is called the plugin must use the provided api instance and call the appropriate\n * register methods - {@link API.registerAccessory} or {@link API.registerPlatform} - in order to\n * correctly register for the following startup sequence.\n *\n * @param {API} api\n */\n (api: API): void | Promise<void>\n\n}\n\nexport interface AccessoryPluginConstructor {\n new(logger: Logging, config: AccessoryConfig, api: API): AccessoryPlugin\n}\n\nexport interface AccessoryPlugin {\n\n /**\n * Optional method which will be called if an 'identify' of an Accessory is requested by HomeKit.\n */\n identify?: () => void\n\n /**\n * This method will be called once on startup, to query all services to be exposed by the Accessory.\n * All event handlers for characteristics should be set up before the array is returned.\n *\n * @returns {Service[]} services - returned services will be added to the Accessory\n */\n getServices: () => Service[]\n\n /**\n * This method will be called once on startup, to query all controllers to be exposed by the Accessory.\n * It is optional to implement.\n *\n * This includes controllers like the RemoteController or the CameraController.\n * Any necessary controller specific setup should have been done when returning the array.\n * In most cases the plugin will only return an array of the size 1.\n *\n * In the case that the Plugin does not add any additional services (returned by {@link getServices}) the\n * method {@link getServices} must be defined in any way and should just return an empty array.\n *\n * @returns {Controller[]} controllers - returned controllers will be configured for the Accessory\n */\n getControllers?: () => Controller[]\n\n}\n\nexport interface PlatformPluginConstructor<Config extends PlatformConfig = PlatformConfig> {\n new(logger: Logging, config: Config, api: API): DynamicPlatformPlugin | StaticPlatformPlugin | IndependentPlatformPlugin\n}\n\nexport interface PlatformPlugin {} // not exported to the public in index.ts\n\n/**\n * Platform that is able to dynamically add or remove accessories.\n * All configured accessories are stored to disk and recreated on startup.\n * Accessories can be added or removed by using {@link API.registerPlatformAccessories} or {@link API.unregisterPlatformAccessories}.\n */\nexport interface DynamicPlatformPlugin extends PlatformPlugin {\n\n /**\n * This method is called for every PlatformAccessory, which is recreated from disk on startup.\n * It should be used to properly initialize the Accessory and setup all event handlers for\n * all services and their characteristics.\n *\n * @param {PlatformAccessory} accessory which needs to be configured\n */\n configureAccessory: (accessory: PlatformAccessory) => void\n\n}\n\n/**\n * Platform that exposes all available characteristics at the start of the plugin.\n * The set of accessories can not change at runtime.\n * The bridge waits for all callbacks to return before it is published and accessible by HomeKit controllers.\n */\nexport interface StaticPlatformPlugin extends PlatformPlugin {\n\n /**\n * This method is called once at startup. The Platform should pass all accessories which need to be created\n * to the callback in form of a {@link AccessoryPlugin}.\n * The Platform must respond in a timely manner as otherwise the startup of the bridge would be unnecessarily delayed.\n *\n * @param {(foundAccessories: AccessoryPlugin[]) => void} callback\n */\n accessories: (callback: (foundAccessories: AccessoryPlugin[]) => void) => void\n\n}\n\n/**\n * Platform that does not aim to add any accessories to the main bridge accessory.\n * This platform should be used if for example a plugin aims to only expose external accessories.\n * It should also be used when the platform doesn't intend to expose any accessories at all, like plugins\n * providing a UI for homebridge.\n */\nexport interface IndependentPlatformPlugin extends PlatformPlugin {\n // does not expose any methods\n}\n\n// eslint-disable-next-line no-restricted-syntax\nexport const enum APIEvent {\n /**\n * Event is fired once homebridge has finished with booting up and initializing all components and plugins.\n * When this event is fired it is possible that the Bridge accessory isn't published yet, if homebridge still needs\n * to wait for some {@see StaticPlatformPlugin | StaticPlatformPlugins} to finish accessory creation.\n */\n DID_FINISH_LAUNCHING = 'didFinishLaunching',\n /**\n * This event is fired when homebridge gets shutdown. This could be a regular shutdown or an unexpected crash.\n * At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!\n */\n SHUTDOWN = 'shutdown',\n}\n\n// eslint-disable-next-line no-restricted-syntax\nexport const enum InternalAPIEvent {\n REGISTER_ACCESSORY = 'registerAccessory',\n REGISTER_PLATFORM = 'registerPlatform',\n\n PUBLISH_EXTERNAL_ACCESSORIES = 'publishExternalAccessories',\n REGISTER_PLATFORM_ACCESSORIES = 'registerPlatformAccessories',\n UPDATE_PLATFORM_ACCESSORIES = 'updatePlatformAccessories',\n UNREGISTER_PLATFORM_ACCESSORIES = 'unregisterPlatformAccessories',\n}\n\nexport interface API {\n\n /**\n * The homebridge API version as a floating point number.\n */\n readonly version: number\n /**\n * The current homebridge semver version.\n */\n readonly serverVersion: string\n\n // ------------------ LEGACY EXPORTS FOR PRE TYPESCRIPT ------------------\n readonly user: typeof User\n readonly hap: HAP\n readonly hapLegacyTypes: HAPLegacyTypes // used for older accessories/platforms\n readonly platformAccessory: typeof PlatformAccessory\n // ------------------------------------------------------------------------\n\n /**\n * Returns true if the current running homebridge version is greater or equal to the\n * passed version string.\n *\n * Example:\n *\n * We assume the homebridge version 1.3.0-beta.12 ({@link serverVersion}) and the following example calls below\n * ```\n * versionGreaterOrEqual(\"1.2.0\"); // will return true\n * versionGreaterOrEqual(\"1.3.0\"); // will return false (the RELEASE version 1.3.0 is bigger than the BETA version 1.3.0-beta.12)\n * versionGreaterOrEqual(\"1.3.0-beta.8); // will return true\n * ```\n *\n * @param version\n */\n versionGreaterOrEqual: (version: string) => boolean\n\n registerAccessory: ((accessoryName: AccessoryName, constructor: AccessoryPluginConstructor) => void) & ((pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor) => void)\n\n registerPlatform: (<Config extends PlatformConfig>(platformName: PlatformName, constructor: PlatformPluginConstructor<Config>) => void) & (<Config extends PlatformConfig>(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor<Config>) => void)\n registerPlatformAccessories: (pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]) => void\n updatePlatformAccessories: (accessories: PlatformAccessory[]) => void\n unregisterPlatformAccessories: (pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]) => void\n\n publishExternalAccessories: (pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]) => void\n\n on: ((event: 'didFinishLaunching', listener: () => void) => this) & ((event: 'shutdown', listener: () => void) => this)\n\n}\n\n// eslint-disable-next-line ts/no-unsafe-declaration-merging\nexport declare interface HomebridgeAPI {\n\n on: ((event: 'didFinishLaunching', listener: () => void) => this) & ((event: 'shutdown', listener: () => void) => this) & ((event: InternalAPIEvent.REGISTER_ACCESSORY, listener: (accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier) => void) => this) & ((event: InternalAPIEvent.REGISTER_PLATFORM, listener: (platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier) => void) => this) & ((event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this) & ((event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this) & ((event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this) & ((event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this)\n\n emit: ((event: 'didFinishLaunching') => boolean) & ((event: 'shutdown') => boolean) & ((event: InternalAPIEvent.REGISTER_ACCESSORY, accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier) => boolean) & ((event: InternalAPIEvent.REGISTER_PLATFORM, platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier) => boolean) & ((event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, accessories: PlatformAccessory[]) => boolean) & ((event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]) => boolean) & ((event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]) => boolean) & ((event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]) => boolean)\n\n}\n\n// eslint-disable-next-line ts/no-unsafe-declaration-merging\nexport class HomebridgeAPI extends EventEmitter implements API {\n public readonly version = 2.7 // homebridge API version\n public readonly serverVersion = getVersion() // homebridge node module version\n\n // ------------------ LEGACY EXPORTS FOR PRE TYPESCRIPT ------------------\n readonly user = User\n readonly hap = hapNodeJs\n readonly hapLegacyTypes = hapNodeJs.LegacyTypes // used for older accessories/platforms\n readonly platformAccessory = PlatformAccessory\n // ------------------------------------------------------------------------\n\n constructor() {\n super()\n }\n\n public versionGreaterOrEqual(version: string): boolean {\n return semver.gte(this.serverVersion, version)\n }\n\n public static isDynamicPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is DynamicPlatformPlugin {\n return 'configureAccessory' in platformPlugin\n }\n\n public static isStaticPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is StaticPlatformPlugin {\n return 'accessories' in platformPlugin\n }\n\n signalFinished(): void {\n this.emit(APIEvent.DID_FINISH_LAUNCHING)\n }\n\n signalShutdown(): void {\n this.emit(APIEvent.SHUTDOWN)\n }\n\n registerAccessory(accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void\n registerAccessory(pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void\n\n registerAccessory(pluginIdentifier: PluginIdentifier | AccessoryName, accessoryName: AccessoryName | AccessoryPluginConstructor, constructor?: AccessoryPluginConstructor): void {\n if (typeof accessoryName === 'function') {\n constructor = accessoryName\n accessoryName = pluginIdentifier\n this.emit(InternalAPIEvent.REGISTER_ACCESSORY, accessoryName, constructor)\n } else {\n this.emit(InternalAPIEvent.REGISTER_ACCESSORY, accessoryName, constructor!, pluginIdentifier)\n }\n }\n\n registerPlatform(platformName: PlatformName, constructor: PlatformPluginConstructor): void\n registerPlatform(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor): void\n\n registerPlatform(pluginIdentifier: PluginIdentifier | PlatformName, platformName: PlatformName | PlatformPluginConstructor, constructor?: PlatformPluginConstructor): void {\n if (typeof platformName === 'function') {\n constructor = platformName\n platformName = pluginIdentifier\n this.emit(InternalAPIEvent.REGISTER_PLATFORM, platformName, constructor)\n } else {\n this.emit(InternalAPIEvent.REGISTER_PLATFORM, platformName, constructor!, pluginIdentifier)\n }\n }\n\n publishCameraAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void {\n this.publishExternalAccessories(pluginIdentifier, accessories)\n }\n\n publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void {\n if (!PluginManager.isQualifiedPluginIdentifier(pluginIdentifier)) {\n log.info(`One of your plugins incorrectly registered an external accessory using the platform name (${pluginIdentifier}) and not the plugin identifier. Please report this to the developer!`)\n }\n\n accessories.forEach((accessory) => {\n // noinspection SuspiciousTypeOfGuard\n if (!(accessory instanceof PlatformAccessory)) {\n throw new TypeError(`${pluginIdentifier} attempt to register an accessory that isn't PlatformAccessory!`)\n }\n\n accessory._associatedPlugin = pluginIdentifier\n })\n\n this.emit(InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, accessories)\n }\n\n registerPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void {\n accessories.forEach((accessory) => {\n // noinspection SuspiciousTypeOfGuard\n if (!(accessory instanceof PlatformAccessory)) {\n throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to register an accessory that isn't PlatformAccessory!`)\n }\n\n accessory._associatedPlugin = pluginIdentifier\n accessory._associatedPlatform = platformName\n })\n\n this.emit(InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, accessories)\n }\n\n updatePlatformAccessories(accessories: PlatformAccessory[]): void {\n this.emit(InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, accessories)\n }\n\n unregisterPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void {\n accessories.forEach((accessory) => {\n // noinspection SuspiciousTypeOfGuard\n if (!(accessory instanceof PlatformAccessory)) {\n throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to unregister an accessory that isn't PlatformAccessory!`)\n }\n })\n\n this.emit(InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, accessories)\n }\n}\n", "import util from 'node:util'\n\nimport chalk from 'chalk'\n\n/**\n * Log levels to indicate importance of the logged message.\n * Every level corresponds to a certain color.\n *\n * - INFO: no color\n * - SUCCESS: green\n * - WARN: yellow\n * - ERROR: red\n * - DEBUG: gray\n *\n * Messages with DEBUG level are only displayed if explicitly enabled.\n */\n// eslint-disable-next-line no-restricted-syntax\nexport const enum LogLevel {\n INFO = 'info',\n SUCCESS = 'success',\n WARN = 'warn',\n ERROR = 'error',\n DEBUG = 'debug',\n}\n\n/**\n * Represents a logging device which can be used directly as a function (for INFO logging)\n * but also has dedicated logging functions for respective logging levels.\n */\nexport interface Logging {\n\n prefix: string\n\n (message: string, ...parameters: any[]): void\n\n info: (message: string, ...parameters: any[]) => void\n success: (message: string, ...parameters: any[]) => void\n warn: (message: string, ...parameters: any[]) => void\n error: (message: string, ...parameters: any[]) => void\n debug: (message: string, ...parameters: any[]) => void\n log: (level: LogLevel, message: string, ...parameters: any[]) => void\n\n}\n\ninterface IntermediateLogging { // some auxiliary interface used to correctly type stuff happening in \"withPrefix\"\n\n prefix?: string\n\n (message: string, ...parameters: any[]): void\n\n info?: (message: string, ...parameters: any[]) => void\n success?: (message: string, ...parameters: any[]) => void\n warn?: (message: string, ...parameters: any[]) => void\n error?: (message: string, ...parameters: any[]) => void\n debug?: (message: string, ...parameters: any[]) => void\n log?: (level: LogLevel, message: string, ...parameters: any[]) => void\n\n}\n\n/**\n * Logger class\n */\nexport class Logger {\n public static readonly internal = new Logger()\n\n private static readonly loggerCache = new Map<string, Logging>() // global cache of logger instances by plugin name\n private static debugEnabled = false\n private static timestampEnabled = true\n\n readonly prefix?: string\n\n constructor(prefix?: string) {\n this.prefix = prefix\n }\n\n /**\n * Creates a new Logging device with a specified prefix.\n *\n * @param prefix {string} - the prefix of the logger\n */\n static withPrefix(prefix: string): Logging {\n const loggerStuff = Logger.loggerCache.get(prefix)\n\n if (loggerStuff) {\n return loggerStuff\n } else {\n const logger = new Logger(prefix)\n\n const log: IntermediateLogging = logger.info.bind(logger)\n log.info = logger.info\n log.success = logger.success\n log.warn = logger.warn\n log.error = logger.error\n log.debug = logger.debug\n log.log = logger.log\n\n log.prefix = logger.prefix\n\n // @ts-expect-error: I aimed to not use ts-ignore in this project, but this evil \"thing\" above is hell\n const logging: Logging = log\n Logger.loggerCache.set(prefix, logging)\n return logging\n }\n }\n\n /**\n * Turns on debug level logging. Off by default.\n *\n * @param enabled {boolean}\n */\n public static setDebugEnabled(enabled: boolean = true): void {\n Logger.debugEnabled = enabled\n }\n\n /**\n * Turns on inclusion of timestamps in log messages. On by default.\n *\n * @param enabled {boolean}\n */\n public static setTimestampEnabled(enabled: boolean = true): void {\n Logger.timestampEnabled = enabled\n }\n\n /**\n * Forces color in logging output, even if it seems like color is unsupported.\n */\n public static forceColor(): void {\n chalk.level = 1 // `1` - Basic 16 colors support.\n }\n\n public info(message: string, ...parameters: any[]): void {\n this.log(LogLevel.INFO, message, ...parameters)\n }\n\n public success(message: string, ...parameters: any[]): void {\n this.log(LogLevel.SUCCESS, message, ...parameters)\n }\n\n public warn(message: string, ...parameters: any[]): void {\n this.log(LogLevel.WARN, message, ...parameters)\n }\n\n public error(message: string, ...parameters: any[]): void {\n this.log(LogLevel.ERROR, message, ...parameters)\n }\n\n public debug(message: string, ...parameters: any[]): void {\n this.log(LogLevel.DEBUG, message, ...parameters)\n }\n\n public log(level: LogLevel, message: string, ...parameters: any[]): void {\n if (level === LogLevel.DEBUG && !Logger.debugEnabled) {\n return\n }\n\n message = util.format(message, ...parameters)\n\n let loggingFunction = console.log // eslint-disable-line no-console\n switch (level) {\n case LogLevel.SUCCESS:\n message = chalk.green(message)\n break\n case LogLevel.WARN:\n message = chalk.yellow(message)\n loggingFunction = console.error\n break\n case LogLevel.ERROR:\n message = chalk.red(message)\n loggingFunction = console.error\n break\n case LogLevel.DEBUG:\n message = chalk.gray(message)\n break\n }\n\n if (this.prefix) {\n message = `${getLogPrefix(this.prefix)} ${message}`\n }\n\n if (Logger.timestampEnabled) {\n const date = new Date()\n message = chalk.white(`[${date.toLocaleString()}] `) + message\n }\n\n loggingFunction(message)\n }\n}\n\n/**\n * Gets the prefix\n * @param prefix\n */\nexport function getLogPrefix(prefix: string): string {\n return chalk.cyan(`[${prefix}]`)\n}\n", "import type {\n Controller,\n ControllerConstructor,\n SerializedAccessory,\n Service,\n VoidCallback,\n WithUUID,\n} from 'hap-nodejs'\nimport type { ConstructorArgs } from 'hap-nodejs/dist/types.js'\n\nimport type { PlatformName, PluginIdentifier, PluginName } from './api.js'\n\nimport { EventEmitter } from 'node:events'\n\nimport {\n Accessory,\n AccessoryEventTypes,\n Categories,\n} from 'hap-nodejs'\n\nexport type UnknownContext = Record<string, any>\n\nexport interface SerializedPlatformAccessory<T extends UnknownContext = UnknownContext> extends SerializedAccessory {\n\n plugin: PluginName\n platform: PlatformName\n context: T\n\n}\n\n// eslint-disable-next-line no-restricted-syntax\nexport const enum PlatformAccessoryEvent {\n IDENTIFY = 'identify',\n}\n\n// eslint-disable-next-line ts/no-unsafe-declaration-merging\nexport declare interface PlatformAccessory {\n\n on: (event: 'identify', listener: () => void) => this\n\n emit: (event: 'identify') => boolean\n\n}\n\n// eslint-disable-next-line ts/no-unsafe-declaration-merging\nexport class PlatformAccessory<T extends UnknownContext = UnknownContext> extends EventEmitter {\n // somewhat ugly way to inject custom Accessory object, while not changing the publicly exposed constructor signature\n private static injectedAccessory?: Accessory\n\n _associatedPlugin?: PluginIdentifier // present as soon as it is registered\n _associatedPlatform?: PlatformName // not present for external accessories\n\n _associatedHAPAccessory: Accessory\n\n // ---------------- HAP Accessory mirror ----------------\n displayName: string\n UUID: string\n category: Categories\n services: Service[] = []\n // ------------------------------------------------------\n\n /**\n * This is a way for Plugin developers to store custom data with their accessory\n */\n public context: T = {} as T // providing something to store\n\n constructor(displayName: string, uuid: string, category?: Categories) { // category is only useful for external accessories\n super()\n this._associatedHAPAccessory = PlatformAccessory.injectedAccessory\n ? PlatformAccessory.injectedAccessory\n : new Accessory(displayName, uuid)\n\n if (category) {\n this._associatedHAPAccessory.category = category\n }\n\n this.displayName = this._associatedHAPAccessory.displayName\n this.UUID = this._associatedHAPAccessory.UUID\n this.category = category || Categories.OTHER\n this.services = this._associatedHAPAccessory.services\n\n // forward identify event\n this._associatedHAPAccessory.on(AccessoryEventTypes.IDENTIFY, (paired: boolean, callback: VoidCallback) => {\n // @ts-expect-error: empty callback for backwards compatibility\n this.emit(PlatformAccessoryEvent.IDENTIFY, paired, () => {})\n callback()\n })\n }\n\n public addService(service: Service): Service\n public addService<S extends typeof Service>(serviceConstructor: S, ...constructorArgs: ConstructorArgs<S>): Service\n public addService(service: Service | typeof Service, ...constructorArgs: any[]): Service {\n // @ts-expect-error: while the HAP-NodeJS interface was refined, the underlying implementation\n // still only operates on an any[] array. Therefore, do not require any additional checks here\n // we force the parameter unpack with expecting a ts-error.\n return this._associatedHAPAccessory.addService(service, ...constructorArgs)\n }\n\n public removeService(service: Service): void {\n this._associatedHAPAccessory.removeService(service)\n }\n\n public getService<T extends WithUUID<typeof Service>>(name: string | T): Service | undefined {\n return this._associatedHAPAccessory.getService(name)\n }\n\n public getServiceById<T extends WithUUID<typeof Service>>(uuid: string | T, subType: string): Service | undefined {\n return this._associatedHAPAccessory.getServiceById(uuid, subType)\n }\n\n /**\n * Configures a new controller for the given accessory.\n * See {@link https://developers.homebridge.io/HAP-NodeJS/classes/accessory.html#configurecontroller | Accessory.configureController}.\n *\n * @param controller\n */\n public configureController(controller: Controller | ControllerConstructor): void {\n this._associatedHAPAccessory.configureController(controller)\n }\n\n /**\n * Removes a configured controller from the given accessory.\n * See {@link https://developers.homebridge.io/HAP-NodeJS/classes/accessory.html#removecontroller | Accessory.removeController}.\n *\n * @param controller\n */\n public removeController(controller: Controller): void {\n this._associatedHAPAccessory.removeController(controller)\n }\n\n // private\n static serialize(accessory: PlatformAccessory): SerializedPlatformAccessory {\n return {\n plugin: accessory._associatedPlugin!,\n platform: accessory._associatedPlatform!,\n context: accessory.context,\n ...Accessory.serialize(accessory._associatedHAPAccessory),\n }\n }\n\n static deserialize(json: SerializedPlatformAccessory): PlatformAccessory {\n const accessory = Accessory.deserialize(json)\n\n PlatformAccessory.injectedAccessory = accessory\n const platformAccessory = new PlatformAccessory(accessory.displayName, accessory.UUID)\n PlatformAccessory.injectedAccessory = undefined\n\n platformAccessory._associatedPlugin = json.plugin\n platformAccessory._associatedPlatform = json.platform\n platformAccessory.context = json.context\n platformAccessory.category = json.category\n\n return platformAccessory\n }\n}\n", "import type {\n AccessoryIdentifier,\n AccessoryName,\n AccessoryPluginConstructor,\n HomebridgeAPI,\n PlatformIdentifier,\n PlatformName,\n PlatformPluginConstructor,\n PluginIdentifier,\n PluginName,\n} from './api.js'\n\nimport { execSync } from 'node:child_process'\nimport fs from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\nimport process from 'node:process'\n\nimport {\n InternalAPIEvent,\n} from './api.js'\nimport { Logger } from './logger.js'\nimport { Plugin } from './plugin.js'\n\nconst log = Logger.internal\nconst require = createRequire(import.meta.url)\nconst paths = require.resolve.paths('')\n\nexport interface PackageJSON { // incomplete type for package.json (just stuff we use here)\n name: string\n version: string\n keywords?: string[]\n\n // see https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_package_entry_points\n exports?: string | Record<string, string | Record<string, string>>\n main?: string\n\n /**\n * When set as module, it marks .js file to be treated as ESM.\n * See https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_enabling\n */\n type?: 'module' | 'commonjs'\n\n engines?: Record<string, string>\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n}\n\nexport interface PluginManagerOptions {\n /**\n * Additional path to search for plugins in. Specified relative to the current working directory.\n */\n customPluginPath?: string\n /**\n * If set, only load plugins from the customPluginPath, if set, otherwise only from the primary global node_modules.\n */\n strictPluginResolution?: boolean\n /**\n * When defined, only plugins specified here will be initialized.\n */\n activePlugins?: PluginIdentifier[]\n /**\n * Plugins that are marked as disabled and whose corresponding config blocks should be ignored\n */\n disabledPlugins?: PluginIdentifier[]\n}\n\n/**\n * Utility which exposes methods to search for installed Homebridge plugins\n */\nexport class PluginManager {\n // name must be prefixed with 'homebridge-' or '@scope/homebridge-'\n private static readonly PLUGIN_IDENTIFIER_PATTERN = /^((@[\\w-]*)\\/)?(homebridge-[\\w-]*)$/\n\n private readonly api: HomebridgeAPI\n\n private readonly searchPaths: Set<string> = new Set() // unique set of search paths we will use to discover installed plugins\n private readonly strictPluginResolution: boolean = false\n private readonly activePlugins?: PluginIdentifier[]\n private readonly disabledPlugins?: PluginIdentifier[]\n\n private readonly plugins: Map<PluginIdentifier, Plugin> = new Map()\n // we have some plugins which simply pass a wrong or misspelled plugin name to the api calls, this translation tries to mitigate this\n private readonly pluginIdentifierTranslation: Map<PluginIdentifier, PluginIdentifier> = new Map()\n private readonly accessoryToPluginMap: Map<AccessoryName, Plugin[]> = new Map()\n private readonly platformToPluginMap: Map<PlatformName, Plugin[]> = new Map()\n\n private currentInitializingPlugin?: Plugin // used to match registering plugins, see handleRegisterAccessory and handleRegisterPlatform\n\n constructor(api: HomebridgeAPI, options?: PluginManagerOptions) {\n this.api = api\n\n if (options) {\n if (options.customPluginPath) {\n this.searchPaths.add(path.resolve(process.cwd(), options.customPluginPath))\n }\n\n this.strictPluginResolution = options.strictPluginResolution || false\n\n this.activePlugins = options.activePlugins\n this.disabledPlugins = Array.isArray(options.disabledPlugins) ? options.disabledPlugins : undefined\n }\n\n this.api.on(InternalAPIEvent.REGISTER_ACCESSORY, this.handleRegisterAccessory.bind(this))\n this.api.on(InternalAPIEvent.REGISTER_PLATFORM, this.handleRegisterPlatform.bind(this))\n }\n\n public static isQualifiedPluginIdentifier(identifier: string): boolean {\n return PluginManager.PLUGIN_IDENTIFIER_PATTERN.test(identifier)\n }\n\n public static extractPluginName(name: string): PluginName { // extract plugin name without @scope/ prefix\n return name.match(PluginManager.PLUGIN_IDENTIFIER_PATTERN)![3]\n }\n\n public static extractPluginScope(name: string): string { // extract the \"@scope\" of a npm module name\n return name.match(PluginManager.PLUGIN_IDENTIFIER_PATTERN)![2]\n }\n\n public static getAccessoryName(identifier: AccessoryIdentifier): AccessoryName {\n if (!identifier.includes('.')) {\n return identifier\n }\n\n return identifier.split('.')[1]\n }\n\n public static getPlatformName(identifier: PlatformIdentifier): PlatformIdentifier {\n if (!identifier.includes('.')) {\n return identifier\n }\n\n return identifier.split('.')[1]\n }\n\n public static getPluginIdentifier(identifier: AccessoryIdentifier | PlatformIdentifier): PluginIdentifier {\n return identifier.split('.')[0]\n }\n\n public async initializeInstalledPlugins(): Promise<void> {\n log.info('---')\n\n this.loadInstalledPlugins()\n\n for (const [identifier, plugin] of this.plugins) {\n try {\n await plugin.load()\n } catch (error: any) {\n log.error('====================')\n log.error(`ERROR LOADING PLUGIN ${identifier}:`)\n log.error(error.stack)\n log.error('====================')\n\n this.plugins.delete(identifier)\n continue\n }\n\n if (this.disabledPlugins && this.disabledPlugins.includes(plugin.getPluginIdentifier())) {\n plugin.disabled = true\n }\n\n if (plugin.disabled) {\n log.warn(`Disabled plugin: ${identifier}@${plugin.version}`)\n } else {\n log.info(`Loaded plugin: ${identifier}@${plugin.version}`)\n }\n\n await this.initializePlugin(plugin, identifier)\n\n log.info('---')\n }\n\n this.currentInitializingPlugin = undefined\n }\n\n public async initializePlugin(plugin: Plugin, identifier: string): Promise<void> {\n try {\n this.currentInitializingPlugin = plugin\n await plugin.initialize(this.api) // call the plugin's initializer and pass it our API instance\n } catch (error: any) {\n log.error('====================')\n log.error(`ERROR INITIALIZING PLUGIN ${identifier}:`)\n log.error(error.stack)\n log.error('====================')\n\n this.plugins.delete(identifier)\n }\n }\n\n private handleRegisterAccessory(name: AccessoryName, constructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier): void {\n if (!this.currentInitializingPlugin) {\n throw new Error(`Unexpected accessory registration. Plugin ${pluginIdentifier ? `'${pluginIdentifier}' ` : ''}tried to register outside the initializer function!`)\n }\n\n if (pluginIdentifier && pluginIdentifier !== this.currentInitializingPlugin.getPluginIdentifier()) {\n log.info(`Plugin '${this.currentInitializingPlugin.getPluginIdentifier()}' tried to register with an incorrect plugin identifier: '${pluginIdentifier}'. Please report this to the developer!`)\n this.pluginIdentifierTranslation.set(pluginIdentifier, this.currentInitializingPlugin.getPluginIdentifier())\n }\n\n this.currentInitializingPlugin.registerAccessory(name, constructor)\n\n let plugins = this.accessoryToPluginMap.get(name)\n if (!plugins) {\n plugins = []\n this.accessoryToPluginMap.set(name, plugins)\n }\n plugins.push(this.currentInitializingPlugin)\n }\n\n private handleRegisterPlatform(name: PlatformName, constructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier): void {\n if (!this.currentInitializingPlugin) {\n throw new Error(`Unexpected platform registration. Plugin ${pluginIdentifier ? `'${pluginIdentifier}' ` : ''}tried to register outside the initializer function!`)\n }\n\n if (pluginIdentifier && pluginIdentifier !== this.currentInitializingPlugin.getPluginIdentifier()) {\n log.debug(`Plugin '${this.currentInitializingPlugin.getPluginIdentifier()}' tried to register with an incorrect plugin identifier: '${pluginIdentifier}'. Please report this to the developer!`)\n this.pluginIdentifierTranslation.set(pluginIdentifier, this.currentInitializingPlugin.getPluginIdentifier())\n }\n\n this.currentInitializingPlugin.registerPlatform(name, constructor)\n\n let plugins = this.platformToPluginMap.get(name)\n if (!plugins) {\n plugins = []\n this.platformToPluginMap.set(name, plugins)\n }\n plugins.push(this.currentInitializingPlugin)\n }\n\n public getPluginForAccessory(accessoryIdentifier: AccessoryIdentifier | AccessoryName): Plugin {\n let plugin: Plugin\n if (!accessoryIdentifier.includes('.')) { // see if it matches exactly one accessory\n let found = this.accessoryToPluginMap.get(accessoryIdentifier)\n\n if (!found) {\n throw new Error(`No plugin was found for the accessory \"${accessoryIdentifier}\" in your config.json. Please make sure the corresponding plugin is installed correctly.`)\n }\n\n if (found.length > 1) {\n const options = found.map(plugin => `${plugin.getPluginIdentifier()}.${accessoryIdentifier}`).join(', ')\n // check if only one of the multiple platforms is not disabled\n found = found.filter(plugin => !plugin.disabled)\n if (found.length !== 1) {\n throw new Error(`The requested accessory '${accessoryIdentifier}' has been registered multiple times. Please be more specific by writing one of: ${options}`)\n }\n }\n\n plugin = found[0]\n accessoryIdentifier = `${plugin.getPluginIdentifier()}.${accessoryIdentifier}`\n } else {\n const pluginIdentifier = PluginManager.getPluginIdentifier(accessoryIdentifier)\n if (!this.hasPluginRegistered(pluginIdentifier)) {\n throw new Error(`The requested plugin '${pluginIdentifier}' was not registered.`)\n }\n\n plugin = this.getPlugin(pluginIdentifier)!\n }\n\n return plugin\n }\n\n public getPluginForPlatform(platformIdentifier: PlatformIdentifier | PlatformName): Plugin {\n let plugin: Plugin\n if (!platformIdentifier.includes('.')) { // see if it matches exactly one platform\n let found = this.platformToPluginMap.get(platformIdentifier)\n\n if (!found) {\n throw new Error(`No plugin was found for the platform \"${platformIdentifier}\" in your config.json. Please make sure the corresponding plugin is installed correctly.`)\n }\n\n if (found.length > 1) {\n const options = found.map(plugin => `${plugin.getPluginIdentifier()}.${platformIdentifier}`).join(', ')\n // check if only one of the multiple platforms is not disabled\n found = found.filter(plugin => !plugin.disabled)\n if (found.length !== 1) {\n throw new Error(`The requested platform '${platformIdentifier}' has been registered multiple times. Please be more specific by writing one of: ${options}`)\n }\n }\n\n plugin = found[0]\n platformIdentifier = `${plugin.getPluginIdentifier()}.${platformIdentifier}`\n } else {\n const pluginIdentifier = PluginManager.getPluginIdentifier(platformIdentifier)\n if (!this.hasPluginRegistered(pluginIdentifier)) {\n throw new Error(`The requested plugin '${pluginIdentifier}' was not registered.`)\n }\n\n plugin = this.getPlugin(pluginIdentifier)!\n }\n\n return plugin\n }\n\n public hasPluginRegistered(pluginIdentifier: PluginIdentifier): boolean {\n return this.plugins.has(pluginIdentifier) || this.pluginIdentifierTranslation.has(pluginIdentifier)\n }\n\n public getPlugin(pluginIdentifier: PluginIdentifier): Plugin | undefined {\n const plugin = this.plugins.get(pluginIdentifier)\n if (plugin) {\n return plugin\n } else {\n const translation = this.pluginIdentifierTranslation.get(pluginIdentifier)\n if (translation) {\n return this.plugins.get(translation)\n }\n }\n\n return undefined\n }\n\n public getPluginByActiveDynamicPlatform(platformName: PlatformName): Plugin | undefined {\n const found = (this.platformToPluginMap.get(platformName) || [])\n .filter(plugin => !!plugin.getActiveDynamicPlatform(platformName))\n\n if (found.length === 0) {\n return undefined\n } else if (found.length > 1) {\n const plugins = found.map(plugin => plugin.getPluginIdentifier()).join(', ')\n throw new Error(`'${platformName}' is an ambiguous platform name. It was registered by multiple plugins: ${plugins}`)\n } else {\n return found[0]\n }\n }\n\n /**\n * Gets all plugins installed on the local system\n */\n private loadInstalledPlugins(): void {\n this.loadDefaultPaths()\n\n this.searchPaths.forEach((searchPath) => { // search for plugins among all known paths\n if (!fs.existsSync(searchPath)) { // just because this path is in require.main.paths doesn't mean it necessarily exists!\n return\n }\n\n if (fs.existsSync(path.join(searchPath, 'package.json'))) { // does this path point inside a single plugin and not a directory containing plugins?\n try {\n this.loadPlugin(searchPath)\n } catch (error: any) {\n log.warn(error.message)\n }\n } else { // read through each directory in this node_modules folder\n const relativePluginPaths = fs.readdirSync(searchPath) // search for directories only\n .filter((relativePath) => {\n try {\n return fs.statSync(path.resolve(searchPath, relativePath)).isDirectory()\n } catch (error: any) {\n log.debug(`Ignoring path ${path.resolve(searchPath, relativePath)} - ${error.message}`)\n return false\n }\n })\n\n // expand out @scoped plugins\n relativePluginPaths.slice()\n .filter(path => path.charAt(0) === '@') // is it a scope directory?\n .forEach((scopeDirectory) => {\n // remove scopeDirectory from the path list\n const index = relativePluginPaths.indexOf(scopeDirectory)\n relativePluginPaths.splice(index, 1)\n\n const absolutePath = path.join(searchPath, scopeDirectory)\n fs.readdirSync(absolutePath)\n .filter(name => PluginManager.isQualifiedPluginIdentifier(name))\n .filter((name) => {\n try {\n return fs.statSync(path.resolve(absolutePath, name)).isDirectory()\n } catch (error: any) {\n log.debug(`Ignoring path ${path.resolve(absolutePath, name)} - ${error.message}`)\n return false\n }\n })\n .forEach(name => relativePluginPaths.push(`${scopeDirectory}/${name}`))\n })\n\n relativePluginPaths\n .filter((pluginIdentifier) => {\n return PluginManager.isQualifiedPluginIdentifier(pluginIdentifier) // needs to be a valid homebridge plugin name\n && (!this.activePlugins || this.activePlugins.includes(pluginIdentifier)) // check if activePlugins is restricted and if so is the plugin is contained\n })\n .forEach((pluginIdentifier) => {\n try {\n const absolutePath = path.resolve(searchPath, pluginIdentifier)\n this.loadPlugin(absolutePath)\n } catch (error: any) {\n log.warn(error.message)\n }\n })\n }\n })\n\n if (this.plugins.size === 0) {\n log.warn('No plugins found.')\n }\n }\n\n public loadPlugin(absolutePath: string): Plugin {\n const packageJson: PackageJSON = PluginManager.loadPackageJSON(absolutePath)\n\n const identifier: PluginIdentifier = packageJson.name\n const name: PluginName = PluginManager.extractPluginName(identifier)\n const scope = PluginManager.extractPluginScope(identifier) // possibly undefined\n\n const alreadyInstalled = this.plugins.get(identifier) // check if there is already a plugin with the same Identifier\n if (alreadyInstalled) {\n throw new Error(`Warning: skipping plugin found at '${absolutePath}' since we already loaded the same plugin from '${alreadyInstalled.getPluginPath()}'.`)\n }\n\n const plugin = new Plugin(name, absolutePath, packageJson, scope)\n this.plugins.set(identifier, plugin)\n return plugin\n }\n\n private static loadPackageJSON(pluginPath: string): PackageJSON {\n const packageJsonPath = path.join(pluginPath, 'package.json')\n let packageJson: PackageJSON\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(`Plugin ${pluginPath} does not contain a package.json.`)\n }\n\n try {\n packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf8' })) // attempt to parse package.json\n } catch (error: any) {\n throw new Error(`Plugin ${pluginPath} contains an invalid package.json. Error: ${error}`)\n }\n\n if (!packageJson.name || !PluginManager.isQualifiedPluginIdentifier(packageJson.name)) {\n throw new Error(`Plugin ${pluginPath} does not have a package name that begins with 'homebridge-' or '@scope/homebridge-.`)\n }\n\n // verify that it's tagged with the correct keyword\n if (!packageJson.keywords || !packageJson.keywords.includes('homebridge-plugin')) {\n throw new Error(`Plugin ${pluginPath} package.json does not contain the keyword 'homebridge-plugin'.`)\n }\n\n return packageJson\n }\n\n private loadDefaultPaths(): void {\n if (this.strictPluginResolution) {\n // if strict plugin resolution is enabled:\n // * only use custom plugin path, if set;\n // * otherwise add the current npm global prefix (e.g. /usr/local/lib/node_modules)\n if (this.searchPaths.size === 0) {\n this.addNpmPrefixToSearchPaths()\n }\n return\n }\n\n if (paths) {\n // add the paths used by require()\n paths.forEach(path => this.searchPaths.add(path))\n }\n\n // THIS SECTION FROM: https://github.com/yeoman/environment/blob/master/lib/resolver.js\n\n // Adding global npm directories\n // We tried using npm to get the global modules path, but it hasn't work out\n // because of bugs in the parsable implementation of `ls` command and mostly\n // performance issues. So, we go with our best bet for now.\n if (process.env.NODE_PATH) {\n process.env.NODE_PATH\n .split(path.delimiter)\n .filter(path => !!path) // trim out empty values\n .forEach(path => this.searchPaths.add(path))\n } else {\n // Default paths for non-windows systems\n if (process.platform !== 'win32') {\n this.searchPaths.add('/usr/local/lib/node_modules')\n this.searchPaths.add('/usr/lib/node_modules')\n }\n this.addNpmPrefixToSearchPaths()\n }\n }\n\n private addNpmPrefixToSearchPaths(): void {\n if (process.platform === 'win32') {\n this.searchPaths.add(path.join(process.env.APPDATA!, 'npm/node_modules'))\n } else {\n this.searchPaths.add(execSync('/bin/echo -n \"$(npm -g prefix)/lib/node_modules\"', {\n env: Object.assign({\n npm_config_loglevel: 'silent',\n npm_update_notifier: 'false',\n }, process.env),\n }).toString('utf8'))\n }\n }\n}\n", "import type {\n AccessoryIdentifier,\n AccessoryName,\n AccessoryPluginConstructor,\n API,\n DynamicPlatformPlugin,\n PlatformIdentifier,\n PlatformName,\n PlatformPluginConstructor,\n PluginIdentifier,\n PluginInitializer,\n PluginName,\n} from './api.js'\nimport type { PackageJSON } from './pluginManager.js'\n\nimport assert from 'node:assert'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { pathToFileURL } from 'node:url'\n\nimport { satisfies } from 'semver'\n\nimport { Logger } from './logger.js'\nimport { PluginManager } from './pluginManager.js'\nimport getVersion from './version.js'\n\nconst log = Logger.internal\n\n/**\n * Represents a loaded Homebridge plugin.\n */\nexport class Plugin {\n private readonly pluginName: PluginName\n private readonly scope?: string // npm package scope\n private readonly pluginPath: string // like \"/usr/local/lib/node_modules/homebridge-lockitron\"\n private readonly isESM: boolean\n\n public disabled = false // mark the plugin as disabled\n\n // ------------------ package.json content ------------------\n readonly version: string\n private readonly main: string\n private loadContext?: { // used to store data for a limited time until the load method is called, will be reset afterward\n engines?: Record<string, string>\n dependencies?: Record<string, string>\n }\n // ----------------------------------------------------------\n\n private pluginInitializer?: PluginInitializer // default exported function from the plugin that initializes it\n\n private readonly registeredAccessories: Map<AccessoryName, AccessoryPluginConstructor> = new Map()\n private readonly registeredPlatforms: Map<PlatformName, PlatformPluginConstructor> = new Map()\n\n private readonly activeDynamicPlatforms: Map<PlatformName, DynamicPlatformPlugin[]> = new Map()\n\n constructor(name: PluginName, path: string, packageJSON: PackageJSON, scope?: string) {\n this.pluginName = name\n this.scope = scope\n this.pluginPath = path\n\n this.version = packageJSON.version || '0.0.0'\n this.main = ''\n\n // figure out the main module\n // exports is available - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_package_entry_points\n if (packageJSON.exports) {\n // main entrypoint - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_main_entry_point_export\n if (typeof packageJSON.exports === 'string') {\n this.main = packageJSON.exports\n } else { // subpath export - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_subpath_exports\n // conditional exports - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_conditional_exports\n const exports = packageJSON.exports.import || packageJSON.exports.require || packageJSON.exports.node || packageJSON.exports.default || packageJSON.exports['.']\n\n // check if conditional export is nested\n if (typeof exports !== 'string') {\n if (exports.import) {\n this.main = exports.import\n } else {\n this.main = exports.require || exports.node || exports.default\n }\n } else {\n this.main = exports\n }\n }\n }\n\n // exports search was not successful, fallback to package.main, using index.js as fallback\n if (!this.main) {\n this.main = packageJSON.main || './index.js'\n }\n\n // check if it is an ESM module\n this.isESM = this.main.endsWith('.mjs') || (this.main.endsWith('.js') && packageJSON.type === 'module')\n\n // very temporary fix for first wave of plugins\n if (packageJSON.peerDependencies && (!packageJSON.engines || !packageJSON.engines.homebridge)) {\n packageJSON.engines = packageJSON.engines || {}\n packageJSON.engines.homebridge = packageJSON.peerDependencies.homebridge\n }\n\n this.loadContext = {\n engines: packageJSON.engines,\n dependencies: packageJSON.dependencies,\n }\n }\n\n public getPluginIdentifier(): PluginIdentifier { // return full plugin name with scope prefix\n return (this.scope ? `${this.scope}/` : '') + this.pluginName\n }\n\n public getPluginPath(): string {\n return this.pluginPath\n }\n\n public registerAccessory(name: AccessoryName, constructor: AccessoryPluginConstructor): void {\n if (this.registeredAccessories.has(name)) {\n throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register an accessory '${name}' which has already been registered!`)\n }\n\n if (!this.disabled) {\n log.info('Registering accessory \\'%s\\'', `${this.getPluginIdentifier()}.${name}`)\n }\n\n this.registeredAccessories.set(name, constructor)\n }\n\n public registerPlatform(name: PlatformName, constructor: PlatformPluginConstructor): void {\n if (this.registeredPlatforms.has(name)) {\n throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register a platform '${name}' which has already been registered!`)\n }\n\n if (!this.disabled) {\n log.info('Registering platform \\'%s\\'', `${this.getPluginIdentifier()}.${name}`)\n }\n\n this.registeredPlatforms.set(name, constructor)\n }\n\n public getAccessoryConstructor(accessoryIdentifier: AccessoryIdentifier | AccessoryName): AccessoryPluginConstructor {\n const name: AccessoryName = PluginManager.getAccessoryName(accessoryIdentifier)\n\n const constructor = this.registeredAccessories.get(name)\n if (!constructor) {\n throw new Error(`The requested accessory '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`)\n }\n\n return constructor\n }\n\n public getPlatformConstructor(platformIdentifier: PlatformIdentifier | PlatformName): PlatformPluginConstructor {\n const name: PlatformName = PluginManager.getPlatformName(platformIdentifier)\n\n const constructor = this.registeredPlatforms.get(name)\n if (!constructor) {\n throw new Error(`The requested platform '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`)\n }\n\n // If it's a dynamic platform plugin, ensure it's not enabled multiple times.\n if (this.activeDynamicPlatforms.has(name)) {\n throw new Error(`The dynamic platform ${name} from the plugin ${this.getPluginIdentifier()} is configured `\n + `times in your config.json.`)\n }\n\n return constructor\n }\n\n public assignDynamicPlatform(platformIdentifier: PlatformIdentifier | PlatformName, platformPlugin: DynamicPlatformPlugin): void {\n const name: PlatformName = PluginManager.getPlatformName(platformIdentifier)\n\n let platforms = this.activeDynamicPlatforms.get(name)\n if (!platforms) {\n platforms = []\n this.activeDynamicPlatforms.set(name, platforms)\n }\n\n // the last platform published should be at the first position for easy access\n // we just try to mimic pre 1.0.0 behavior\n platforms.unshift(platformPlugin)\n }\n\n public getActiveDynamicPlatform(platformName: PlatformName): DynamicPlatformPlugin | undefined {\n const platforms = this.activeDynamicPlatforms.get(platformName)\n // we always use the last registered\n return platforms && platforms[0]\n }\n\n public async load(): Promise<void> {\n const context = this.loadContext!\n assert(context, 'Reached illegal state. Plugin state is undefined!')\n this.loadContext = undefined // free up memory\n\n // pluck out the HomeBridge version requirement\n if (!context.engines || !context.engines.homebridge) {\n throw new Error(`Plugin ${this.pluginPath} does not contain the 'homebridge' package in 'engines'.`)\n }\n\n const versionRequired = context.engines.homebridge\n const nodeVersionRequired = context.engines.node\n\n // make sure the version is satisfied by the currently running version of HomeBridge\n if (!satisfies(getVersion(), versionRequired, { includePrerelease: true })) {\n // TODO - change this back to an error\n log.error(`The plugin \"${this.pluginName}\" requires a Homebridge version of ${versionRequired} which does \\\nnot satisfy the current Homebridge version of ${getVersion()}. You may need to update this plugin (or Homebridge) to a newer version. \\\nYou may face unexpected issues or stability problems running this plugin.`)\n }\n\n // make sure the version is satisfied by the currently running version of Node\n if (nodeVersionRequired && !satisfies(process.version, nodeVersionRequired)) {\n log.warn(`The plugin \"${this.pluginName}\" requires Node.js version of ${nodeVersionRequired} which does \\\nnot 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`)\n }\n\n const dependencies = context.dependencies || {}\n if (dependencies.homebridge || dependencies['hap-nodejs']) {\n log.error(`The plugin \"${this.pluginName}\" defines 'homebridge' and/or 'hap-nodejs' in their 'dependencies' section, \\\nmeaning they carry an additional copy of homebridge and hap-nodejs. This not only wastes disk space, but also can cause \\\nmajor incompatibility issues and thus is considered bad practice. Please inform the developer to update their plugin!`)\n }\n\n const mainPath = path.join(this.pluginPath, this.main)\n\n // try to import it and grab the exported initialization hook\n // pathToFileURL(specifier).href to turn a path into a \"file url\"\n // see https://github.com/nodejs/node/issues/31710\n\n const pluginModules = await import(pathToFileURL(mainPath).href)\n\n if (typeof pluginModules === 'function') {\n this.pluginInitializer = pluginModules\n } else if (pluginModules && typeof pluginModules.default === 'function') {\n this.pluginInitializer = pluginModules.default\n } else {\n throw new Error(`Plugin ${this.pluginPath} does not export a initializer function from main.`)\n }\n }\n\n public initialize(api: API): void | Promise<void> {\n if (!this.pluginInitializer) {\n throw new Error('Tried to initialize a plugin which hasn\\'t been loaded yet!')\n }\n\n return this.pluginInitializer(api)\n }\n}\n", "import fs from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nfunction loadPackageJson(): any {\n const packageJSONPath = join(__dirname, '../package.json')\n return JSON.parse(fs.readFileSync(packageJSONPath, { encoding: 'utf8' }))\n}\n\nexport default function getVersion(): string {\n return loadPackageJson().version\n}\n\nexport function getRequiredNodeVersion(): string {\n return loadPackageJson().engines.node\n}\n", "/**\n * Export HAP\n */\nimport type { API } from './api.js'\n\n// noinspection JSUnusedGlobalSymbols\nexport type HAP = API['hap']\n\n/**\n * Export types for basically everything but the actual API implementation\n */\nexport type {\n AccessoryIdentifier,\n AccessoryName,\n AccessoryPlugin,\n AccessoryPluginConstructor,\n API,\n\n DynamicPlatformPlugin,\n IndependentPlatformPlugin,\n\n PlatformIdentifier,\n PlatformName,\n PlatformPluginConstructor,\n PluginIdentifier,\n PluginInitializer,\n PluginName,\n ScopedPluginName,\n\n StaticPlatformPlugin,\n} from './api.js'\n\n/**\n * Export API const enums\n */\nexport { APIEvent, PluginType } from './api.js'\n\n/**\n * Export bridge types\n */\nexport type {\n AccessoryConfig,\n BridgeConfiguration,\n HomebridgeConfig,\n PlatformConfig,\n} from './bridgeService.js'\n\n/**\n * Export port types\n */\nexport type {\n ExternalPortsConfiguration,\n} from './externalPortService.js'\n\n/**\n * Export Logger const enums\n */\nexport { LogLevel } from './logger.js'\n\n/**\n * Export Logger types\n */\nexport type { Logger, Logging } from './logger.js'\n\n/**\n * Export Platform Accessory const enums\n */\nexport { PlatformAccessoryEvent } from './platformAccessory.js'\n\n/**\n * Export Platform Accessory Types\n */\nexport type { PlatformAccessory, UnknownContext } from './platformAccessory.js'\n\n/**\n * Export server types\n */\nexport type { HomebridgeOptions } from './server.js'\n\n/**\n * Export User Types\n */\nexport type { User } from './user.js'\n\n/**\n * Export the CONST ENUMS from hap-nodejs\n * These get converted to their string value at compile time\n * and can be safely used directly.\n */\nexport {\n Access,\n AccessControlEvent,\n AccessLevel,\n AccessoryEventTypes,\n AdaptiveLightingControllerEvents,\n AdaptiveLightingControllerMode,\n AudioBitrate,\n AudioCodecTypes,\n AudioRecordingCodecType,\n AudioRecordingSamplerate,\n AudioSamplerate,\n AudioStreamingCodecType,\n AudioStreamingSamplerate,\n ButtonState,\n ButtonType,\n CameraControllerEvents,\n Categories,\n ChangeReason,\n CharacteristicEventTypes,\n DataFormatTags,\n DataStreamConnectionEvent,\n DataStreamServerEvent,\n DataStreamStatus,\n DefaultControllerType,\n EventTriggerOption,\n Formats,\n H264Level,\n H264Profile,\n HAPServerEventTypes,\n HAPStatus,\n HDSProtocolSpecificErrorReason,\n HDSStatus,\n MediaContainerType,\n PacketDataType,\n Perms,\n Protocols,\n RemoteControllerEvents,\n ResourceRequestReason,\n ServiceEventTypes,\n SiriAudioSessionEvents,\n SRTPCryptoSuites,\n StreamRequestTypes,\n TargetCategory,\n TargetUpdates,\n Topics,\n Units,\n} from 'hap-nodejs'\n\n/**\n * Export HAP-NodeJS namespaces as type only\n */\nexport type { DataStreamParser } from 'hap-nodejs'\n\n/**\n * Export HAP-NodeJS classes as type only\n */\nexport type {\n AccessControlManagement,\n AdaptiveLightingController,\n CameraController,\n Characteristic,\n ColorUtils,\n DataStreamConnection,\n DataStreamManagement,\n DataStreamReader,\n DataStreamServer,\n DataStreamWriter,\n DoorbellController,\n HAPServer,\n HapStatusError,\n HAPStorage,\n HDSProtocolError,\n RecordingManagement,\n RemoteController,\n RTPStreamManagement,\n Service,\n SiriAudioSession,\n} from 'hap-nodejs'\n\n/**\n * Export HAP-NodeJS interfaces as type only\n */\nexport type {\n ActiveAdaptiveLightingTransition,\n AdaptiveLightingOptions,\n AdaptiveLightingTransitionCurveEntry,\n BrightnessAdjustmentMultiplierRange,\n CameraControllerOptions,\n CameraRecordingConfiguration,\n CameraRecordingDelegate,\n CameraStreamingDelegate,\n CharacteristicOperationContext,\n CharacteristicProps,\n Controller,\n ControllerConstructor,\n ControllerContext,\n ControllerServiceMap,\n DataStreamProtocolHandler,\n DoorbellOptions,\n H264CodecParameters,\n MediaContainerConfiguration,\n ProxiedSourceResponse,\n PublishInfo,\n RecordingManagementState,\n RecordingPacket,\n RTPProxyOptions,\n RTPStreamManagementState,\n SelectedH264CodecParameters,\n SerializableController,\n ServiceConfigurationChange,\n SiriAudioStreamProducer,\n SiriAudioStreamProducerConstructor,\n SourceResponse,\n VideoRecordingOptions,\n} from 'hap-nodejs'\n\n/**\n * Export HAP-NodeJS type aliases as type only\n */\nexport type {\n AccessoriesCallback,\n AccessoryCharacteristicChange,\n AdditionalAuthorizationHandler,\n AddPairingCallback,\n AudioCodecConfiguration,\n AudioCodecParameters,\n AudioFrame,\n AudioInfo,\n AudioRecordingCodec,\n AudioRecordingOptions,\n AudioStreamingCodec,\n AudioStreamingOptions,\n ButtonConfiguration,\n CameraRecordingOptions,\n CameraStreamingOptions,\n CharacteristicChange,\n CharacteristicGetCallback,\n CharacteristicGetHandler,\n CharacteristicSetCallback,\n CharacteristicSetHandler,\n CharacteristicValue,\n ConstructorArgs,\n ControllerType,\n ErrorHandler,\n EventHandler,\n FrameHandler,\n GlobalEventHandler,\n GlobalRequestHandler,\n HAPHttpError,\n HAPPincode,\n IdentificationCallback,\n IdentifyCallback,\n InterfaceName,\n IPAddress,\n IPv4Address,\n IPv6Address,\n ListPairingsCallback,\n MacAddress,\n NodeCallback,\n Nullable,\n PairCallback,\n PairingsCallback,\n PartialAllowingNull,\n PreparedDataStreamSession,\n PrepareStreamCallback,\n PrepareStreamRequest,\n PrepareStreamResponse,\n PrimitiveTypes,\n ReadCharacteristicsCallback,\n ReconfiguredVideoInfo,\n ReconfigureStreamRequest,\n RemovePairingCallback,\n RequestHandler,\n Resolution,\n ResourceRequestCallback,\n ResponseHandler,\n RTPTime,\n SerializedServiceMap,\n ServiceCharacteristicChange,\n ServiceId,\n SessionIdentifier,\n SnapshotRequest,\n SnapshotRequestCallback,\n Source,\n StartStreamRequest,\n StateChangeDelegate,\n StopStreamRequest,\n StreamingRequest,\n StreamRequestCallback,\n StreamSessionIdentifier,\n SupportedButtonConfiguration,\n SupportedConfiguration,\n TargetConfiguration,\n TLVEncodable,\n VideoInfo,\n VideoStreamingOptions,\n VoidCallback,\n WithUUID,\n WriteCharacteristicsCallback,\n} from 'hap-nodejs'\n\n/**\n * Export HAP-NodeJS variables as type only\n */\nexport type {\n LegacyTypes,\n uuid,\n} from 'hap-nodejs'\n\n/**\n * Export HAP-NodeJS functions as type only\n */\nexport type {\n clone,\n decode,\n decodeList,\n decodeWithLists,\n encode,\n epochMillisFromMillisSince2001_01_01,\n epochMillisFromMillisSince2001_01_01Buffer,\n once,\n} from 'hap-nodejs'\n"],
5
+ "mappings": "AAOA,OAAOA,OAAe,aACtB,OAAOC,OAAY,SCRnB,OAAOC,MAAU,YAEjB,OAAOC,MAAW,QAeX,IAAWC,OAChBA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,KAAO,OACPA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QALQA,OAAA,IA6CLC,EAAN,MAAMC,CAAO,CAClB,OAAuB,SAAW,IAAIA,EAEtC,OAAwB,YAAc,IAAI,IAC1C,OAAe,aAAe,GAC9B,OAAe,iBAAmB,GAEzB,OAET,YAAYC,EAAiB,CAC3B,KAAK,OAASA,CAChB,CAOA,OAAO,WAAWA,EAAyB,CACzC,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,2BAAAC,GACA,4BAAAC,GACA,eAAAC,GACA,cAAAC,GACA,0BAAAC,GACA,cAAAC,GACA,gBAAAC,GACA,4BAAAC,GACA,kBAAAC,GACA,6BAAAC,GACA,yBAAAC,GACA,oBAAAC,GACA,yBAAAC,GACA,sBAAAC,GACA,WAAAC,GACA,aAAAC,GACA,eAAAC,GACA,uBAAAC,GACA,aAAAC,GACA,kCAAAC,GACA,aAAAC,GACA,sBAAAC,GACA,kBAAAC,GACA,SAAAC,GACA,aAAAC,GACA,0BAAAC,GACA,yBAAAC,GACA,qBAAAC,GACA,0BAAAC,GACA,oBAAAC,GACA,sBAAAC,GACA,kBAAAC,GACA,iBAAAC,GACA,UAAAC,GACA,SAAAC,OACK",
6
+ "names": ["hapNodeJs", "semver", "util", "chalk", "LogLevel", "Logger", "_Logger", "prefix", "loggerStuff", "logger", "log", "logging", "enabled", "message", "parameters", "level", "loggingFunction", "getLogPrefix", "date", "Accessory", "AccessoryEventTypes", "Categories", "PlatformAccessoryEvent", "createRequire", "satisfies", "dirname", "join", "fileURLToPath", "__filename", "__dirname", "log", "Logger", "log", "Logger", "require", "createRequire", "paths", "log", "Logger", "PluginType", "APIEvent", "Access", "AccessControlEvent", "AccessLevel", "AccessoryEventTypes", "AdaptiveLightingControllerEvents", "AdaptiveLightingControllerMode", "AudioBitrate", "AudioCodecTypes", "AudioRecordingCodecType", "AudioRecordingSamplerate", "AudioSamplerate", "AudioStreamingCodecType", "AudioStreamingSamplerate", "ButtonState", "ButtonType", "CameraControllerEvents", "Categories", "ChangeReason", "CharacteristicEventTypes", "DataFormatTags", "DataStreamConnectionEvent", "DataStreamServerEvent", "DataStreamStatus", "DefaultControllerType", "EventTriggerOption", "Formats", "H264Level", "H264Profile", "HAPServerEventTypes", "HAPStatus", "HDSProtocolSpecificErrorReason", "HDSStatus", "MediaContainerType", "PacketDataType", "Perms", "Protocols", "RemoteControllerEvents", "ResourceRequestReason", "ServiceEventTypes", "SiriAudioSessionEvents", "SRTPCryptoSuites", "StreamRequestTypes", "TargetCategory", "TargetUpdates", "Topics", "Units"]
7
+ }
package/package.json CHANGED
@@ -1,29 +1,10 @@
1
1
  {
2
2
  "name": "homebridge",
3
+ "type": "module",
4
+ "version": "2.0.0-alpha.4",
3
5
  "description": "HomeKit support for the impatient",
4
- "version": "2.0.0-alpha.2",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "license": "Apache-2.0",
8
6
  "author": "Nick Farina",
9
- "maintainers": [
10
- "oznu <dev@oz.nu>",
11
- "Andreas Bauer <mail@anderl-bauer.de>"
12
- ],
13
- "scripts": {
14
- "build": "npm run clean && tsc",
15
- "check": "npm install && npm outdated",
16
- "clean": "rimraf lib/",
17
- "dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true",
18
- "docs": "typedoc",
19
- "lint": "eslint 'src/**/*.{js,ts,json}'",
20
- "lint:fix": "npm run lint -- --fix",
21
- "prepublishOnly": "npm run build",
22
- "postpublish": "npm run clean",
23
- "test": "jest --forceExit --detectOpenHandles",
24
- "test-coverage": "jest --coverage --forceExit --detectOpenHandles",
25
- "watch": "nodemon"
26
- },
7
+ "license": "Apache-2.0",
27
8
  "repository": {
28
9
  "type": "git",
29
10
  "url": "git://github.com/homebridge/homebridge.git"
@@ -31,48 +12,70 @@
31
12
  "bugs": {
32
13
  "url": "https://github.com/homebridge/homebridge/issues"
33
14
  },
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "maintainers": [
23
+ "oznu <dev@oz.nu>",
24
+ "Andreas Bauer <mail@anderl-bauer.de>"
25
+ ],
34
26
  "bin": {
35
27
  "homebridge": "bin/homebridge"
36
28
  },
37
- "engines": {
38
- "node": "^18.15.0 || ^20.7.0"
39
- },
40
29
  "files": [
30
+ "LICENSE",
41
31
  "README.md",
32
+ "bin",
42
33
  "config-sample.json",
43
- "LICENSE",
44
- "lib",
45
- "bin"
34
+ "dist"
46
35
  ],
36
+ "engines": {
37
+ "node": "^18.15.0 || ^20.7.0 || ^22.0.0"
38
+ },
39
+ "scripts": {
40
+ "build": "npm run clean && node scripts/build.js",
41
+ "check": "npm install && npm outdated",
42
+ "clean": "rimraf dist/",
43
+ "dev": "DEBUG=* ./bin/homebridge -D -P example-plugins/ || true",
44
+ "docs": "typedoc",
45
+ "lint": "eslint .",
46
+ "lint:fix": "npm run lint -- --fix",
47
+ "prepublishOnly": "npm run build",
48
+ "postpublish": "npm run clean",
49
+ "test": "vitest run",
50
+ "test-coverage": "npm run test -- --coverage",
51
+ "watch": "npm run clean && nodemon"
52
+ },
47
53
  "preferGlobal": true,
48
54
  "dependencies": {
49
- "chalk": "4.1.2",
55
+ "chalk": "5.3.0",
50
56
  "commander": "12.1.0",
51
57
  "fs-extra": "11.2.0",
52
- "hap-nodejs": "1.0.0",
58
+ "hap-nodejs": "1.1.1-beta.1",
53
59
  "qrcode-terminal": "0.12.0",
54
- "semver": "7.6.2",
55
- "source-map-support": "0.5.21"
60
+ "semver": "7.6.3"
56
61
  },
57
62
  "devDependencies": {
63
+ "@antfu/eslint-config": "^2.27.1",
58
64
  "@types/debug": "^4.1.12",
59
65
  "@types/fs-extra": "^11.0.4",
60
- "@types/jest": "^29.5.12",
61
- "@types/node": "^20.14.10",
66
+ "@types/node": "^22.5.0",
62
67
  "@types/semver": "^7.5.8",
63
- "@types/source-map-support": "^0.5.10",
64
- "@typescript-eslint/eslint-plugin": "^7.16.0",
65
- "@typescript-eslint/parser": "^7.16.0",
66
- "eslint": "^8.57.0",
67
- "eslint-plugin-import": "^2.29.1",
68
- "eslint-plugin-import-newlines": "^1.4.0",
69
- "eslint-plugin-jest": "^28.6.0",
70
- "jest": "^29.7.0",
68
+ "@vitest/coverage-v8": "^2.0.5",
69
+ "esbuild": "^0.23.1",
70
+ "esbuild-node-externals": "^1.14.0",
71
+ "esbuild-plugin-tsc": "^0.4.0",
72
+ "eslint": "^9.9.1",
73
+ "eslint-plugin-format": "^0.1.2",
71
74
  "nodemon": "^3.1.4",
72
- "rimraf": "^5.0.9",
73
- "ts-jest": "^29.2.2",
74
- "ts-node": "^10.9.2",
75
- "typedoc": "^0.26.4",
76
- "typescript": "^5.5.3"
75
+ "npm-dts": "^1.3.13",
76
+ "rimraf": "^6.0.1",
77
+ "typedoc": "^0.26.6",
78
+ "typescript": "^5.5.4",
79
+ "vitest": "^2.0.5"
77
80
  }
78
81
  }
package/lib/api.d.ts DELETED
@@ -1,210 +0,0 @@
1
- import { EventEmitter } from "events";
2
- import * as hapNodeJs from "hap-nodejs";
3
- import { Controller, Service } from "hap-nodejs";
4
- import { AccessoryConfig, PlatformConfig } from "./bridgeService";
5
- import { Logging } from "./logger";
6
- import { PlatformAccessory } from "./platformAccessory";
7
- import { User } from "./user";
8
- export type HAP = typeof hapNodeJs;
9
- export type HAPLegacyTypes = typeof hapNodeJs.LegacyTypes;
10
- export type PluginIdentifier = PluginName | ScopedPluginName;
11
- export type PluginName = string;
12
- export type ScopedPluginName = string;
13
- export type AccessoryName = string;
14
- export type PlatformName = string;
15
- export type AccessoryIdentifier = string;
16
- export type PlatformIdentifier = string;
17
- export declare const enum PluginType {
18
- ACCESSORY = "accessory",
19
- PLATFORM = "platform"
20
- }
21
- /**
22
- * The {PluginInitializer} is a method which must be the default export for every homebridge plugin.
23
- * It is called once the plugin is loaded from disk.
24
- */
25
- export interface PluginInitializer {
26
- /**
27
- * When the initializer is called the plugin must use the provided api instance and call the appropriate
28
- * register methods - {@link API.registerAccessory} or {@link API.registerPlatform} - in order to
29
- * correctly register for the following startup sequence.
30
- *
31
- * @param {API} api
32
- */
33
- (api: API): void | Promise<void>;
34
- }
35
- export interface AccessoryPluginConstructor {
36
- new (logger: Logging, config: AccessoryConfig, api: API): AccessoryPlugin;
37
- }
38
- export interface AccessoryPlugin {
39
- /**
40
- * Optional method which will be called if a 'identify' of an Accessory is requested by HomeKit.
41
- */
42
- identify?(): void;
43
- /**
44
- * This method will be called once on startup, to query all services to be exposed by the Accessory.
45
- * All event handlers for characteristics should be set up before the array is returned.
46
- *
47
- * @returns {Service[]} services - returned services will be added to the Accessory
48
- */
49
- getServices(): Service[];
50
- /**
51
- * This method will be called once on startup, to query all controllers to be exposed by the Accessory.
52
- * It is optional to implement.
53
- *
54
- * This includes controllers like the RemoteController or the CameraController.
55
- * Any necessary controller specific setup should have been done when returning the array.
56
- * In most cases the plugin will only return an array of the size 1.
57
- *
58
- * In the case that the Plugin does not add any additional services (returned by {@link getServices}) the
59
- * method {@link getServices} must be defined in any way and should just return an empty array.
60
- *
61
- * @returns {Controller[]} controllers - returned controllers will be configured for the Accessory
62
- */
63
- getControllers?(): Controller[];
64
- }
65
- export interface PlatformPluginConstructor<Config extends PlatformConfig = PlatformConfig> {
66
- new (logger: Logging, config: Config, api: API): DynamicPlatformPlugin | StaticPlatformPlugin | IndependentPlatformPlugin;
67
- }
68
- export interface PlatformPlugin {
69
- }
70
- /**
71
- * Platform that is able to dynamically add or remove accessories.
72
- * All configured accessories are stored to disk and recreated on startup.
73
- * Accessories can be added or removed by using {@link API.registerPlatformAccessories} or {@link API.unregisterPlatformAccessories}.
74
- */
75
- export interface DynamicPlatformPlugin extends PlatformPlugin {
76
- /**
77
- * This method is called for every PlatformAccessory, which is recreated from disk on startup.
78
- * It should be used to properly initialize the Accessory and setup all event handlers for
79
- * all services and their characteristics.
80
- *
81
- * @param {PlatformAccessory} accessory which needs to be configured
82
- */
83
- configureAccessory(accessory: PlatformAccessory): void;
84
- }
85
- /**
86
- * Platform that exposes all available characteristics at the start of the plugin.
87
- * The set of accessories can not change at runtime.
88
- * The bridge waits for all callbacks to return before it is published and accessible by HomeKit controllers.
89
- */
90
- export interface StaticPlatformPlugin extends PlatformPlugin {
91
- /**
92
- * This method is called once at startup. The Platform should pass all accessories which need to be created
93
- * to the callback in form of a {@link AccessoryPlugin}.
94
- * The Platform must respond in a timely manner as otherwise the startup of the bridge would be unnecessarily delayed.
95
- *
96
- * @param {(foundAccessories: AccessoryPlugin[]) => void} callback
97
- */
98
- accessories(callback: (foundAccessories: AccessoryPlugin[]) => void): void;
99
- }
100
- /**
101
- * Platform that does not aim to add any accessories to the main bridge accessory.
102
- * This platform should be used if for example a plugin aims to only expose external accessories.
103
- * It should also be used when the platform doesn't intend to expose any accessories at all, like plugins
104
- * providing a UI for homebridge.
105
- */
106
- export interface IndependentPlatformPlugin extends PlatformPlugin {
107
- }
108
- export declare const enum APIEvent {
109
- /**
110
- * Event is fired once homebridge has finished with booting up and initializing all components and plugins.
111
- * When this event is fired it is possible that the Bridge accessory isn't published yet, if homebridge still needs
112
- * to wait for some {@see StaticPlatformPlugin | StaticPlatformPlugins} to finish accessory creation.
113
- */
114
- DID_FINISH_LAUNCHING = "didFinishLaunching",
115
- /**
116
- * This event is fired when homebridge gets shutdown. This could be a regular shutdown or an unexpected crash.
117
- * At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!
118
- */
119
- SHUTDOWN = "shutdown"
120
- }
121
- export declare const enum InternalAPIEvent {
122
- REGISTER_ACCESSORY = "registerAccessory",
123
- REGISTER_PLATFORM = "registerPlatform",
124
- PUBLISH_EXTERNAL_ACCESSORIES = "publishExternalAccessories",
125
- REGISTER_PLATFORM_ACCESSORIES = "registerPlatformAccessories",
126
- UPDATE_PLATFORM_ACCESSORIES = "updatePlatformAccessories",
127
- UNREGISTER_PLATFORM_ACCESSORIES = "unregisterPlatformAccessories"
128
- }
129
- export interface API {
130
- /**
131
- * The homebridge API version as a floating point number.
132
- */
133
- readonly version: number;
134
- /**
135
- * The current homebridge semver version.
136
- */
137
- readonly serverVersion: string;
138
- readonly user: typeof User;
139
- readonly hap: HAP;
140
- readonly hapLegacyTypes: HAPLegacyTypes;
141
- readonly platformAccessory: typeof PlatformAccessory;
142
- /**
143
- * Returns true if the current running homebridge version is greater or equal to the
144
- * passed version string.
145
- *
146
- * Example:
147
- *
148
- * We assume the homebridge version 1.3.0-beta.12 ({@link serverVersion}) and the following example calls below
149
- * ```
150
- * versionGreaterOrEqual("1.2.0"); // will return true
151
- * versionGreaterOrEqual("1.3.0"); // will return false (the RELEASE version 1.3.0 is bigger than the BETA version 1.3.0-beta.12)
152
- * versionGreaterOrEqual("1.3.0-beta.8); // will return true
153
- * ```
154
- *
155
- * @param version
156
- */
157
- versionGreaterOrEqual(version: string): boolean;
158
- registerAccessory(accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
159
- registerAccessory(pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
160
- registerPlatform<Config extends PlatformConfig>(platformName: PlatformName, constructor: PlatformPluginConstructor<Config>): void;
161
- registerPlatform<Config extends PlatformConfig>(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor<Config>): void;
162
- registerPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
163
- updatePlatformAccessories(accessories: PlatformAccessory[]): void;
164
- unregisterPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
165
- publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
166
- on(event: "didFinishLaunching", listener: () => void): this;
167
- on(event: "shutdown", listener: () => void): this;
168
- }
169
- export declare interface HomebridgeAPI {
170
- on(event: "didFinishLaunching", listener: () => void): this;
171
- on(event: "shutdown", listener: () => void): this;
172
- on(event: InternalAPIEvent.REGISTER_ACCESSORY, listener: (accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier) => void): this;
173
- on(event: InternalAPIEvent.REGISTER_PLATFORM, listener: (platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier) => void): this;
174
- on(event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
175
- on(event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
176
- on(event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
177
- on(event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
178
- emit(event: "didFinishLaunching"): boolean;
179
- emit(event: "shutdown"): boolean;
180
- emit(event: InternalAPIEvent.REGISTER_ACCESSORY, accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier): boolean;
181
- emit(event: InternalAPIEvent.REGISTER_PLATFORM, platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier): boolean;
182
- emit(event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
183
- emit(event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
184
- emit(event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
185
- emit(event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
186
- }
187
- export declare class HomebridgeAPI extends EventEmitter implements API {
188
- readonly version = 2.7;
189
- readonly serverVersion: string;
190
- readonly user: typeof User;
191
- readonly hap: typeof hapNodeJs;
192
- readonly hapLegacyTypes: typeof hapNodeJs.LegacyTypes;
193
- readonly platformAccessory: typeof PlatformAccessory;
194
- constructor();
195
- versionGreaterOrEqual(version: string): boolean;
196
- static isDynamicPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is DynamicPlatformPlugin;
197
- static isStaticPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is StaticPlatformPlugin;
198
- signalFinished(): void;
199
- signalShutdown(): void;
200
- registerAccessory(accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
201
- registerAccessory(pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
202
- registerPlatform(platformName: PlatformName, constructor: PlatformPluginConstructor): void;
203
- registerPlatform(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor): void;
204
- publishCameraAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
205
- publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
206
- registerPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
207
- updatePlatformAccessories(accessories: PlatformAccessory[]): void;
208
- unregisterPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
209
- }
210
- //# sourceMappingURL=api.d.ts.map
package/lib/api.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAU,OAAO,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAK9B,MAAM,MAAM,GAAG,GAAG,OAAO,SAAS,CAAC;AACnC,MAAM,MAAM,cAAc,GAAG,OAAO,SAAS,CAAC,WAAW,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,gBAAgB,CAAC;AAC7D,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,MAAM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