@homebridge-plugins/homebridge-noip
Version:
The No-IP plugin allows you to update your No-IP hostname(s) for your homebridge instance.
28 lines • 1.23 kB
JavaScript
/**
* Factory function that returns a proxy constructor which selects between the
* HAP and Matter platform implementations based on the plugin config and
* whether the Homebridge Matter API is available.
*
* @param HAPPlatform - The standard HAP platform class.
* @param MatterPlatform - The Matter platform class.
* @returns A constructor that instantiates the correct platform.
*/
export function createPlatformProxy(HAPPlatform, MatterPlatform) {
return class NoIPPlatformProxy {
/** The instantiated platform implementation (HAP or Matter) */
impl;
constructor(log, config, api) {
const preferMatter = config?.options?.preferMatter ?? true;
const enableMatter = config?.options?.enableMatter ?? true;
const matterAvailable = !!(api?.isMatterAvailable?.() && api?.isMatterEnabled?.());
if (enableMatter && preferMatter && MatterPlatform && matterAvailable) {
this.impl = new MatterPlatform(log, config, api);
return this.impl;
}
// Fallback to HAP
this.impl = new HAPPlatform(log, config, api);
return this.impl;
}
};
}
//# sourceMappingURL=utils.js.map