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.
- package/README.md +16 -17
- package/bin/homebridge +8 -6
- package/config-sample.json +3 -3
- package/dist/childBridgeFork.js +2 -0
- package/dist/childBridgeFork.js.map +7 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.d.ts +1099 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/package.json +50 -47
- package/lib/api.d.ts +0 -210
- package/lib/api.d.ts.map +0 -1
- package/lib/api.js +0 -155
- package/lib/api.js.map +0 -1
- package/lib/bridgeService.d.ts +0 -105
- package/lib/bridgeService.d.ts.map +0 -1
- package/lib/bridgeService.js +0 -428
- package/lib/bridgeService.js.map +0 -1
- package/lib/childBridgeFork.d.ts +0 -37
- package/lib/childBridgeFork.d.ts.map +0 -1
- package/lib/childBridgeFork.js +0 -244
- package/lib/childBridgeFork.js.map +0 -1
- package/lib/childBridgeService.d.ts +0 -199
- package/lib/childBridgeService.d.ts.map +0 -1
- package/lib/childBridgeService.js +0 -428
- package/lib/childBridgeService.js.map +0 -1
- package/lib/cli.d.ts +0 -4
- package/lib/cli.d.ts.map +0 -1
- package/lib/cli.js +0 -115
- package/lib/cli.js.map +0 -1
- package/lib/externalPortService.d.ts +0 -33
- package/lib/externalPortService.d.ts.map +0 -1
- package/lib/externalPortService.js +0 -64
- package/lib/externalPortService.js.map +0 -1
- package/lib/index.d.ts +0 -76
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -72
- package/lib/index.js.map +0 -1
- package/lib/ipcService.d.ts +0 -33
- package/lib/ipcService.d.ts.map +0 -1
- package/lib/ipcService.js +0 -49
- package/lib/ipcService.js.map +0 -1
- package/lib/logger.d.ts +0 -78
- package/lib/logger.d.ts.map +0 -1
- package/lib/logger.js +0 -147
- package/lib/logger.js.map +0 -1
- package/lib/platformAccessory.d.ts +0 -54
- package/lib/platformAccessory.d.ts.map +0 -1
- package/lib/platformAccessory.js +0 -102
- package/lib/platformAccessory.js.map +0 -1
- package/lib/plugin.d.ts +0 -31
- package/lib/plugin.d.ts.map +0 -1
- package/lib/plugin.js +0 -194
- package/lib/plugin.js.map +0 -1
- package/lib/pluginManager.d.ts +0 -77
- package/lib/pluginManager.d.ts.map +0 -1
- package/lib/pluginManager.js +0 -380
- package/lib/pluginManager.js.map +0 -1
- package/lib/server.d.ts +0 -58
- package/lib/server.d.ts.map +0 -1
- package/lib/server.js +0 -457
- package/lib/server.js.map +0 -1
- package/lib/storageService.d.ts +0 -13
- package/lib/storageService.d.ts.map +0 -1
- package/lib/storageService.js +0 -70
- package/lib/storageService.js.map +0 -1
- package/lib/user.d.ts +0 -13
- package/lib/user.d.ts.map +0 -1
- package/lib/user.js +0 -36
- package/lib/user.js.map +0 -1
- package/lib/util/mac.d.ts +0 -4
- package/lib/util/mac.d.ts.map +0 -1
- package/lib/util/mac.js +0 -20
- package/lib/util/mac.js.map +0 -1
- package/lib/version.d.ts +0 -3
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js +0 -21
- package/lib/version.js.map +0 -1
package/lib/platformAccessory.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
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;
|
|
7
|
-
(function (PlatformAccessoryEvent) {
|
|
8
|
-
PlatformAccessoryEvent["IDENTIFY"] = "identify";
|
|
9
|
-
})(PlatformAccessoryEvent || (exports.PlatformAccessoryEvent = PlatformAccessoryEvent = {}));
|
|
10
|
-
class PlatformAccessory extends events_1.EventEmitter {
|
|
11
|
-
// somewhat ugly way to inject custom Accessory object, while not changing the publicly exposed constructor signature
|
|
12
|
-
static injectedAccessory;
|
|
13
|
-
_associatedPlugin; // present as soon as it is registered
|
|
14
|
-
_associatedPlatform; // not present for external accessories
|
|
15
|
-
_associatedHAPAccessory;
|
|
16
|
-
// ---------------- HAP Accessory mirror ----------------
|
|
17
|
-
displayName;
|
|
18
|
-
UUID;
|
|
19
|
-
category;
|
|
20
|
-
services = [];
|
|
21
|
-
// ------------------------------------------------------
|
|
22
|
-
/**
|
|
23
|
-
* This is a way for Plugin developers to store custom data with their accessory
|
|
24
|
-
*/
|
|
25
|
-
context = {}; // providing something to store
|
|
26
|
-
constructor(displayName, uuid, category) {
|
|
27
|
-
super();
|
|
28
|
-
this._associatedHAPAccessory = PlatformAccessory.injectedAccessory
|
|
29
|
-
? PlatformAccessory.injectedAccessory
|
|
30
|
-
: new hap_nodejs_1.Accessory(displayName, uuid);
|
|
31
|
-
if (category) {
|
|
32
|
-
this._associatedHAPAccessory.category = category;
|
|
33
|
-
}
|
|
34
|
-
this.displayName = this._associatedHAPAccessory.displayName;
|
|
35
|
-
this.UUID = this._associatedHAPAccessory.UUID;
|
|
36
|
-
this.category = category || 1 /* Categories.OTHER */;
|
|
37
|
-
this.services = this._associatedHAPAccessory.services;
|
|
38
|
-
// forward identify event
|
|
39
|
-
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
|
|
44
|
-
callback();
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
addService(service, ...constructorArgs) {
|
|
48
|
-
// @ts-expect-error: while the HAP-NodeJS interface was refined, the underlying implementation
|
|
49
|
-
// still only operates on an any[] array. Therefore, do not require any additional checks here
|
|
50
|
-
// we force the parameter unpack with expecting a ts-error.
|
|
51
|
-
return this._associatedHAPAccessory.addService(service, ...constructorArgs);
|
|
52
|
-
}
|
|
53
|
-
removeService(service) {
|
|
54
|
-
this._associatedHAPAccessory.removeService(service);
|
|
55
|
-
}
|
|
56
|
-
getService(name) {
|
|
57
|
-
return this._associatedHAPAccessory.getService(name);
|
|
58
|
-
}
|
|
59
|
-
getServiceById(uuid, subType) {
|
|
60
|
-
return this._associatedHAPAccessory.getServiceById(uuid, subType);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Configures a new controller for the given accessory.
|
|
64
|
-
* See {@link https://developers.homebridge.io/HAP-NodeJS/classes/accessory.html#configurecontroller | Accessory.configureController}.
|
|
65
|
-
*
|
|
66
|
-
* @param controller
|
|
67
|
-
*/
|
|
68
|
-
configureController(controller) {
|
|
69
|
-
this._associatedHAPAccessory.configureController(controller);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Removes a configured controller from the given accessory.
|
|
73
|
-
* See {@link https://developers.homebridge.io/HAP-NodeJS/classes/accessory.html#removecontroller | Accessory.removeController}.
|
|
74
|
-
*
|
|
75
|
-
* @param controller
|
|
76
|
-
*/
|
|
77
|
-
removeController(controller) {
|
|
78
|
-
this._associatedHAPAccessory.removeController(controller);
|
|
79
|
-
}
|
|
80
|
-
// private
|
|
81
|
-
static serialize(accessory) {
|
|
82
|
-
return {
|
|
83
|
-
plugin: accessory._associatedPlugin,
|
|
84
|
-
platform: accessory._associatedPlatform,
|
|
85
|
-
context: accessory.context,
|
|
86
|
-
...hap_nodejs_1.Accessory.serialize(accessory._associatedHAPAccessory),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
static deserialize(json) {
|
|
90
|
-
const accessory = hap_nodejs_1.Accessory.deserialize(json);
|
|
91
|
-
PlatformAccessory.injectedAccessory = accessory;
|
|
92
|
-
const platformAccessory = new PlatformAccessory(accessory.displayName, accessory.UUID);
|
|
93
|
-
PlatformAccessory.injectedAccessory = undefined;
|
|
94
|
-
platformAccessory._associatedPlugin = json.plugin;
|
|
95
|
-
platformAccessory._associatedPlatform = json.platform;
|
|
96
|
-
platformAccessory.context = json.context;
|
|
97
|
-
platformAccessory.category = json.category;
|
|
98
|
-
return platformAccessory;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.PlatformAccessory = PlatformAccessory;
|
|
102
|
-
//# sourceMappingURL=platformAccessory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,2CAUoB;AAepB,IAAkB,sBAEjB;AAFD,WAAkB,sBAAsB;IACtC,+CAAqB,CAAA;AACvB,CAAC,EAFiB,sBAAsB,sCAAtB,sBAAsB,QAEvC;AAWD,MAAa,iBAA8D,SAAQ,qBAAY;IAE7F,qHAAqH;IAC7G,MAAM,CAAC,iBAAiB,CAAa;IAE7C,iBAAiB,CAAoB,CAAC,sCAAsC;IAC5E,mBAAmB,CAAgB,CAAC,uCAAuC;IAE3E,uBAAuB,CAAY;IAEnC,yDAAyD;IACzD,WAAW,CAAS;IACpB,IAAI,CAAS;IACb,QAAQ,CAAa;IACrB,QAAQ,GAAc,EAAE,CAAC;IACzB,yDAAyD;IAEzD;;OAEG;IACI,OAAO,GAAM,EAAO,CAAC,CAAC,+BAA+B;IAE5D,YAAY,WAAmB,EAAE,IAAY,EAAE,QAAqB;QAClE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,uBAAuB,GAAG,iBAAiB,CAAC,iBAAiB;YAChE,CAAC,CAAC,iBAAiB,CAAC,iBAAiB;YACrC,CAAC,CAAC,IAAI,sBAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAErC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,uBAAuB,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACnD,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,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AAI,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED,UAAU;IACV,MAAM,CAAC,SAAS,CAAC,SAA4B;QAC3C,OAAO;YACL,MAAM,EAAE,SAAS,CAAC,iBAAkB;YACpC,QAAQ,EAAE,SAAS,CAAC,mBAAoB;YACxC,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,GAAG,sBAAS,CAAC,SAAS,CAAC,SAAS,CAAC,uBAAuB,CAAC;SAC1D,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAiC;QAClD,MAAM,SAAS,GAAG,sBAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAE9C,iBAAiB,CAAC,iBAAiB,GAAG,SAAS,CAAC;QAChD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACvF,iBAAiB,CAAC,iBAAiB,GAAG,SAAS,CAAC;QAEhD,iBAAiB,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;QAClD,iBAAiB,CAAC,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC;QACtD,iBAAiB,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QACzC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE3C,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CAEF;AAjHD,8CAiHC"}
|
package/lib/plugin.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AccessoryIdentifier, AccessoryName, AccessoryPluginConstructor, API, PlatformIdentifier, PlatformName, DynamicPlatformPlugin, PlatformPluginConstructor, PluginIdentifier, PluginName } from "./api";
|
|
2
|
-
import { PackageJSON } from "./pluginManager";
|
|
3
|
-
/**
|
|
4
|
-
* Represents a loaded Homebridge plugin.
|
|
5
|
-
*/
|
|
6
|
-
export declare class Plugin {
|
|
7
|
-
private readonly pluginName;
|
|
8
|
-
private readonly scope?;
|
|
9
|
-
private readonly pluginPath;
|
|
10
|
-
private readonly isESM;
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
readonly version: string;
|
|
13
|
-
private readonly main;
|
|
14
|
-
private loadContext?;
|
|
15
|
-
private pluginInitializer?;
|
|
16
|
-
private readonly registeredAccessories;
|
|
17
|
-
private readonly registeredPlatforms;
|
|
18
|
-
private readonly activeDynamicPlatforms;
|
|
19
|
-
constructor(name: PluginName, path: string, packageJSON: PackageJSON, scope?: string);
|
|
20
|
-
getPluginIdentifier(): PluginIdentifier;
|
|
21
|
-
getPluginPath(): string;
|
|
22
|
-
registerAccessory(name: AccessoryName, constructor: AccessoryPluginConstructor): void;
|
|
23
|
-
registerPlatform(name: PlatformName, constructor: PlatformPluginConstructor): void;
|
|
24
|
-
getAccessoryConstructor(accessoryIdentifier: AccessoryIdentifier | AccessoryName): AccessoryPluginConstructor;
|
|
25
|
-
getPlatformConstructor(platformIdentifier: PlatformIdentifier | PlatformName): PlatformPluginConstructor;
|
|
26
|
-
assignDynamicPlatform(platformIdentifier: PlatformIdentifier | PlatformName, platformPlugin: DynamicPlatformPlugin): void;
|
|
27
|
-
getActiveDynamicPlatform(platformName: PlatformName): DynamicPlatformPlugin | undefined;
|
|
28
|
-
load(): Promise<void>;
|
|
29
|
-
initialize(api: API): void | Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=plugin.d.ts.map
|
package/lib/plugin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,0BAA0B,EAC1B,GAAG,EACH,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAEhB,UAAU,EACX,MAAM,OAAO,CAAC;AAEf,OAAO,E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C,IAAI,CAAC;IAqD3B,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CASlD"}
|
package/lib/plugin.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
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)");
|
|
17
|
-
/**
|
|
18
|
-
* Represents a loaded Homebridge plugin.
|
|
19
|
-
*/
|
|
20
|
-
class Plugin {
|
|
21
|
-
pluginName;
|
|
22
|
-
scope; // npm package scope
|
|
23
|
-
pluginPath; // like "/usr/local/lib/node_modules/homebridge-lockitron"
|
|
24
|
-
isESM;
|
|
25
|
-
disabled = false; // mark the plugin as disabled
|
|
26
|
-
// ------------------ package.json content ------------------
|
|
27
|
-
version;
|
|
28
|
-
main;
|
|
29
|
-
loadContext;
|
|
30
|
-
// ----------------------------------------------------------
|
|
31
|
-
pluginInitializer; // default exported function from the plugin that initializes it
|
|
32
|
-
registeredAccessories = new Map();
|
|
33
|
-
registeredPlatforms = new Map();
|
|
34
|
-
activeDynamicPlatforms = new Map();
|
|
35
|
-
constructor(name, path, packageJSON, scope) {
|
|
36
|
-
this.pluginName = name;
|
|
37
|
-
this.scope = scope;
|
|
38
|
-
this.pluginPath = path;
|
|
39
|
-
this.version = packageJSON.version || "0.0.0";
|
|
40
|
-
this.main = "";
|
|
41
|
-
// figure out the main module
|
|
42
|
-
// exports is available - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_package_entry_points
|
|
43
|
-
if (packageJSON.exports) {
|
|
44
|
-
// main entrypoint - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_main_entry_point_export
|
|
45
|
-
if (typeof packageJSON.exports === "string") {
|
|
46
|
-
this.main = packageJSON.exports;
|
|
47
|
-
}
|
|
48
|
-
else { // subpath export - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_subpath_exports
|
|
49
|
-
// 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["."];
|
|
51
|
-
// check if conditional export is nested
|
|
52
|
-
if (typeof exports !== "string") {
|
|
53
|
-
if (exports.import) {
|
|
54
|
-
this.main = exports.import;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.main = exports.require || exports.node || exports.default;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.main = exports;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// exports search was not successful, fallback to package.main, using index.js as fallback
|
|
66
|
-
if (!this.main) {
|
|
67
|
-
this.main = packageJSON.main || "./index.js";
|
|
68
|
-
}
|
|
69
|
-
// check if it is an ESM module
|
|
70
|
-
this.isESM = this.main.endsWith(".mjs") || (this.main.endsWith(".js") && packageJSON.type === "module");
|
|
71
|
-
// very temporary fix for first wave of plugins
|
|
72
|
-
if (packageJSON.peerDependencies && (!packageJSON.engines || !packageJSON.engines.homebridge)) {
|
|
73
|
-
packageJSON.engines = packageJSON.engines || {};
|
|
74
|
-
packageJSON.engines.homebridge = packageJSON.peerDependencies.homebridge;
|
|
75
|
-
}
|
|
76
|
-
this.loadContext = {
|
|
77
|
-
engines: packageJSON.engines,
|
|
78
|
-
dependencies: packageJSON.dependencies,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
getPluginIdentifier() {
|
|
82
|
-
return (this.scope ? this.scope + "/" : "") + this.pluginName;
|
|
83
|
-
}
|
|
84
|
-
getPluginPath() {
|
|
85
|
-
return this.pluginPath;
|
|
86
|
-
}
|
|
87
|
-
registerAccessory(name, constructor) {
|
|
88
|
-
if (this.registeredAccessories.has(name)) {
|
|
89
|
-
throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register an accessory '${name}' which has already been registered!`);
|
|
90
|
-
}
|
|
91
|
-
if (!this.disabled) {
|
|
92
|
-
log.info("Registering accessory '%s'", this.getPluginIdentifier() + "." + name);
|
|
93
|
-
}
|
|
94
|
-
this.registeredAccessories.set(name, constructor);
|
|
95
|
-
}
|
|
96
|
-
registerPlatform(name, constructor) {
|
|
97
|
-
if (this.registeredPlatforms.has(name)) {
|
|
98
|
-
throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register a platform '${name}' which has already been registered!`);
|
|
99
|
-
}
|
|
100
|
-
if (!this.disabled) {
|
|
101
|
-
log.info("Registering platform '%s'", this.getPluginIdentifier() + "." + name);
|
|
102
|
-
}
|
|
103
|
-
this.registeredPlatforms.set(name, constructor);
|
|
104
|
-
}
|
|
105
|
-
getAccessoryConstructor(accessoryIdentifier) {
|
|
106
|
-
const name = pluginManager_1.PluginManager.getAccessoryName(accessoryIdentifier);
|
|
107
|
-
const constructor = this.registeredAccessories.get(name);
|
|
108
|
-
if (!constructor) {
|
|
109
|
-
throw new Error(`The requested accessory '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`);
|
|
110
|
-
}
|
|
111
|
-
return constructor;
|
|
112
|
-
}
|
|
113
|
-
getPlatformConstructor(platformIdentifier) {
|
|
114
|
-
const name = pluginManager_1.PluginManager.getPlatformName(platformIdentifier);
|
|
115
|
-
const constructor = this.registeredPlatforms.get(name);
|
|
116
|
-
if (!constructor) {
|
|
117
|
-
throw new Error(`The requested platform '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`);
|
|
118
|
-
}
|
|
119
|
-
// If it's a dynamic platform plugin, ensure it's not enabled multiple times.
|
|
120
|
-
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.");
|
|
123
|
-
}
|
|
124
|
-
return constructor;
|
|
125
|
-
}
|
|
126
|
-
assignDynamicPlatform(platformIdentifier, platformPlugin) {
|
|
127
|
-
const name = pluginManager_1.PluginManager.getPlatformName(platformIdentifier);
|
|
128
|
-
let platforms = this.activeDynamicPlatforms.get(name);
|
|
129
|
-
if (!platforms) {
|
|
130
|
-
platforms = [];
|
|
131
|
-
this.activeDynamicPlatforms.set(name, platforms);
|
|
132
|
-
}
|
|
133
|
-
// the last platform published should be at the first position for easy access
|
|
134
|
-
// we just try to mimic pre 1.0.0 behavior
|
|
135
|
-
platforms.unshift(platformPlugin);
|
|
136
|
-
}
|
|
137
|
-
getActiveDynamicPlatform(platformName) {
|
|
138
|
-
const platforms = this.activeDynamicPlatforms.get(platformName);
|
|
139
|
-
// we always use the last registered
|
|
140
|
-
return platforms && platforms[0];
|
|
141
|
-
}
|
|
142
|
-
async load() {
|
|
143
|
-
const context = this.loadContext;
|
|
144
|
-
(0, assert_1.default)(context, "Reached illegal state. Plugin state is undefined!");
|
|
145
|
-
this.loadContext = undefined; // free up memory
|
|
146
|
-
// pluck out the HomeBridge version requirement
|
|
147
|
-
if (!context.engines || !context.engines.homebridge) {
|
|
148
|
-
throw new Error(`Plugin ${this.pluginPath} does not contain the 'homebridge' package in 'engines'.`);
|
|
149
|
-
}
|
|
150
|
-
const versionRequired = context.engines.homebridge;
|
|
151
|
-
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 })) {
|
|
154
|
-
// 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. \
|
|
157
|
-
You may face unexpected issues or stability problems running this plugin.`);
|
|
158
|
-
}
|
|
159
|
-
// 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 \
|
|
162
|
-
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
|
-
}
|
|
164
|
-
const dependencies = context.dependencies || {};
|
|
165
|
-
if (dependencies.homebridge || dependencies["hap-nodejs"]) {
|
|
166
|
-
log.error(`The plugin "${this.pluginName}" defines 'homebridge' and/or 'hap-nodejs' in their 'dependencies' section, \
|
|
167
|
-
meaning they carry an additional copy of homebridge and hap-nodejs. This not only wastes disk space, but also can cause \
|
|
168
|
-
major incompatibility issues and thus is considered bad practice. Please inform the developer to update their plugin!`);
|
|
169
|
-
}
|
|
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
|
|
173
|
-
// pathToFileURL(specifier).href to turn a path into a "file url"
|
|
174
|
-
// 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") {
|
|
177
|
-
this.pluginInitializer = pluginModules;
|
|
178
|
-
}
|
|
179
|
-
else if (pluginModules && typeof pluginModules.default === "function") {
|
|
180
|
-
this.pluginInitializer = pluginModules.default;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
throw new Error(`Plugin ${this.pluginPath} does not export a initializer function from main.`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
initialize(api) {
|
|
187
|
-
if (!this.pluginInitializer) {
|
|
188
|
-
throw new Error("Tried to initialize a plugin which hasn't been loaded yet!");
|
|
189
|
-
}
|
|
190
|
-
return this.pluginInitializer(api);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
exports.Plugin = Plugin;
|
|
194
|
-
//# sourceMappingURL=plugin.js.map
|
package/lib/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,gDAAwB;AACxB,6BAAoC;AACpC,mCAAmC;AAcnC,qCAAkC;AAClC,mDAA6D;AAC7D,wDAAmC;AAEnC,MAAM,GAAG,GAAG,eAAM,CAAC,QAAQ,CAAC;AAE5B,sEAAsE;AACtE,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAa,MAAM;IAEA,UAAU,CAAa;IACvB,KAAK,CAAU,CAAC,oBAAoB;IACpC,UAAU,CAAS,CAAC,0DAA0D;IAC9E,KAAK,CAAU;IAEzB,QAAQ,GAAG,KAAK,CAAC,CAAC,8BAA8B;IAEvD,6DAA6D;IACpD,OAAO,CAAS;IACR,IAAI,CAAS;IACtB,WAAW,CAGjB;IACF,6DAA6D;IAErD,iBAAiB,CAAqB,CAAC,gEAAgE;IAE9F,qBAAqB,GAAmD,IAAI,GAAG,EAAE,CAAC;IAClF,mBAAmB,GAAiD,IAAI,GAAG,EAAE,CAAC;IAE9E,sBAAsB,GAA+C,IAAI,GAAG,EAAE,CAAC;IAEhG,YAA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G,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,cAAc,CAAC,IAAA,mBAAa,EAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE1G,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;YACxC,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC;QACzC,CAAC;aAAM,IAAI,aAAa,IAAI,OAAO,aAAa,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACxE,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,OAAO,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,UAAU,oDAAoD,CAAC,CAAC;QACjG,CAAC;IACH,CAAC;IAEM,UAAU,CAAC,GAAQ;QACxB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;CAGF;AA1ND,wBA0NC"}
|
package/lib/pluginManager.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { AccessoryIdentifier, AccessoryName, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, PluginName } from "./api";
|
|
2
|
-
import { Plugin } from "./plugin";
|
|
3
|
-
export interface PackageJSON {
|
|
4
|
-
name: string;
|
|
5
|
-
version: string;
|
|
6
|
-
keywords?: string[];
|
|
7
|
-
exports?: string | Record<string, string | Record<string, string>>;
|
|
8
|
-
main?: string;
|
|
9
|
-
/**
|
|
10
|
-
* When set as module, it marks .js file to be treated as ESM.
|
|
11
|
-
* See https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_enabling
|
|
12
|
-
*/
|
|
13
|
-
type?: "module" | "commonjs";
|
|
14
|
-
engines?: Record<string, string>;
|
|
15
|
-
dependencies?: Record<string, string>;
|
|
16
|
-
devDependencies?: Record<string, string>;
|
|
17
|
-
peerDependencies?: Record<string, string>;
|
|
18
|
-
}
|
|
19
|
-
export interface PluginManagerOptions {
|
|
20
|
-
/**
|
|
21
|
-
* Additional path to search for plugins in. Specified relative to the current working directory.
|
|
22
|
-
*/
|
|
23
|
-
customPluginPath?: string;
|
|
24
|
-
/**
|
|
25
|
-
* If set, only load plugins from the customPluginPath, if set, otherwise only from the primary global node_modules.
|
|
26
|
-
*/
|
|
27
|
-
strictPluginResolution?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* When defined, only plugins specified here will be initialized.
|
|
30
|
-
*/
|
|
31
|
-
activePlugins?: PluginIdentifier[];
|
|
32
|
-
/**
|
|
33
|
-
* Plugins that are marked as disabled and whose corresponding config blocks should be ignored
|
|
34
|
-
*/
|
|
35
|
-
disabledPlugins?: PluginIdentifier[];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Utility which exposes methods to search for installed Homebridge plugins
|
|
39
|
-
*/
|
|
40
|
-
export declare class PluginManager {
|
|
41
|
-
private static readonly PLUGIN_IDENTIFIER_PATTERN;
|
|
42
|
-
private readonly api;
|
|
43
|
-
private readonly searchPaths;
|
|
44
|
-
private readonly strictPluginResolution;
|
|
45
|
-
private readonly activePlugins?;
|
|
46
|
-
private readonly disabledPlugins?;
|
|
47
|
-
private readonly plugins;
|
|
48
|
-
private readonly pluginIdentifierTranslation;
|
|
49
|
-
private readonly accessoryToPluginMap;
|
|
50
|
-
private readonly platformToPluginMap;
|
|
51
|
-
private currentInitializingPlugin?;
|
|
52
|
-
constructor(api: HomebridgeAPI, options?: PluginManagerOptions);
|
|
53
|
-
static isQualifiedPluginIdentifier(identifier: string): boolean;
|
|
54
|
-
static extractPluginName(name: string): PluginName;
|
|
55
|
-
static extractPluginScope(name: string): string;
|
|
56
|
-
static getAccessoryName(identifier: AccessoryIdentifier): AccessoryName;
|
|
57
|
-
static getPlatformName(identifier: PlatformIdentifier): PlatformIdentifier;
|
|
58
|
-
static getPluginIdentifier(identifier: AccessoryIdentifier | PlatformIdentifier): PluginIdentifier;
|
|
59
|
-
initializeInstalledPlugins(): Promise<void>;
|
|
60
|
-
initializePlugin(plugin: Plugin, identifier: string): Promise<void>;
|
|
61
|
-
private handleRegisterAccessory;
|
|
62
|
-
private handleRegisterPlatform;
|
|
63
|
-
getPluginForAccessory(accessoryIdentifier: AccessoryIdentifier | AccessoryName): Plugin;
|
|
64
|
-
getPluginForPlatform(platformIdentifier: PlatformIdentifier | PlatformName): Plugin;
|
|
65
|
-
hasPluginRegistered(pluginIdentifier: PluginIdentifier): boolean;
|
|
66
|
-
getPlugin(pluginIdentifier: PluginIdentifier): Plugin | undefined;
|
|
67
|
-
getPluginByActiveDynamicPlatform(platformName: PlatformName): Plugin | undefined;
|
|
68
|
-
/**
|
|
69
|
-
* Gets all plugins installed on the local system
|
|
70
|
-
*/
|
|
71
|
-
private loadInstalledPlugins;
|
|
72
|
-
loadPlugin(absolutePath: string): Plugin;
|
|
73
|
-
private static loadPackageJSON;
|
|
74
|
-
private loadDefaultPaths;
|
|
75
|
-
private addNpmPrefixToSearchPaths;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=pluginManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pluginManager.d.ts","sourceRoot":"","sources":["../src/pluginManager.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,aAAa,EAEb,aAAa,EAEb,kBAAkB,EAClB,YAAY,EAEZ,gBAAgB,EAChB,UAAU,EACX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpB,OAAO,CAA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