homebridge 2.0.0-alpha.3 → 2.0.0-alpha.5
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/{lib → dist}/api.d.ts +23 -40
- package/dist/api.d.ts.map +1 -0
- package/{lib → dist}/api.js +38 -64
- package/dist/api.js.map +1 -0
- package/{lib → dist}/bridgeService.d.ts +10 -9
- package/dist/bridgeService.d.ts.map +1 -0
- package/{lib → dist}/bridgeService.js +79 -121
- package/dist/bridgeService.js.map +1 -0
- package/{lib → dist}/childBridgeFork.d.ts +4 -3
- package/dist/childBridgeFork.d.ts.map +1 -0
- package/{lib → dist}/childBridgeFork.js +38 -41
- package/dist/childBridgeFork.js.map +1 -0
- package/{lib → dist}/childBridgeService.d.ts +8 -7
- package/dist/childBridgeService.d.ts.map +1 -0
- package/{lib → dist}/childBridgeService.js +54 -55
- package/dist/childBridgeService.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +89 -0
- package/dist/cli.js.map +1 -0
- package/{lib → dist}/externalPortService.d.ts +2 -2
- package/{lib → dist}/externalPortService.d.ts.map +1 -1
- package/{lib → dist}/externalPortService.js +4 -9
- package/dist/externalPortService.js.map +1 -0
- package/{lib → dist}/index.d.ts +29 -29
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/{lib → dist}/ipcService.d.ts +2 -5
- package/dist/ipcService.d.ts.map +1 -0
- package/{lib → dist}/ipcService.js +12 -12
- package/dist/ipcService.js.map +1 -0
- package/{lib → dist}/logger.d.ts +6 -6
- package/dist/logger.d.ts.map +1 -0
- package/{lib → dist}/logger.js +19 -28
- package/dist/logger.js.map +1 -0
- package/{lib → dist}/platformAccessory.d.ts +7 -6
- package/dist/platformAccessory.d.ts.map +1 -0
- package/{lib → dist}/platformAccessory.js +12 -16
- package/dist/platformAccessory.js.map +1 -0
- package/{lib → dist}/plugin.d.ts +2 -2
- package/dist/plugin.d.ts.map +1 -0
- package/{lib → dist}/plugin.js +36 -45
- package/dist/plugin.js.map +1 -0
- package/{lib → dist}/pluginManager.d.ts +3 -3
- package/dist/pluginManager.d.ts.map +1 -0
- package/{lib → dist}/pluginManager.js +72 -78
- package/dist/pluginManager.js.map +1 -0
- package/dist/server.d.ts.map +1 -0
- package/{lib → dist}/server.js +89 -116
- package/dist/server.js.map +1 -0
- package/{lib → dist}/storageService.d.ts.map +1 -1
- package/dist/storageService.js +41 -0
- package/dist/storageService.js.map +1 -0
- package/{lib → dist}/user.d.ts.map +1 -1
- package/dist/user.js +29 -0
- package/dist/user.js.map +1 -0
- package/{lib → dist}/util/mac.d.ts +1 -0
- package/dist/util/mac.d.ts.map +1 -0
- package/dist/util/mac.js +14 -0
- package/dist/util/mac.js.map +1 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +16 -0
- package/dist/version.js.map +1 -0
- package/package.json +42 -42
- package/lib/api.d.ts.map +0 -1
- package/lib/api.js.map +0 -1
- package/lib/bridgeService.d.ts.map +0 -1
- package/lib/bridgeService.js.map +0 -1
- package/lib/childBridgeFork.d.ts.map +0 -1
- package/lib/childBridgeFork.js.map +0 -1
- package/lib/childBridgeService.d.ts.map +0 -1
- 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.js.map +0 -1
- 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.map +0 -1
- package/lib/ipcService.js.map +0 -1
- package/lib/logger.d.ts.map +0 -1
- package/lib/logger.js.map +0 -1
- package/lib/platformAccessory.d.ts.map +0 -1
- package/lib/platformAccessory.js.map +0 -1
- package/lib/plugin.d.ts.map +0 -1
- package/lib/plugin.js.map +0 -1
- package/lib/pluginManager.d.ts.map +0 -1
- package/lib/pluginManager.js.map +0 -1
- package/lib/server.d.ts.map +0 -1
- package/lib/server.js.map +0 -1
- package/lib/storageService.js +0 -70
- package/lib/storageService.js.map +0 -1
- package/lib/user.js +0 -36
- package/lib/user.js.map +0 -1
- 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.map +0 -1
- package/lib/version.js +0 -21
- package/lib/version.js.map +0 -1
- /package/{lib → dist}/server.d.ts +0 -0
- /package/{lib → dist}/storageService.d.ts +0 -0
- /package/{lib → dist}/user.d.ts +0 -0
- /package/{lib → dist}/version.d.ts +0 -0
package/{lib → dist}/plugin.js
RENAMED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const semver_1 = require("semver");
|
|
11
|
-
const logger_1 = require("./logger");
|
|
12
|
-
const pluginManager_1 = require("./pluginManager");
|
|
13
|
-
const version_1 = __importDefault(require("./version"));
|
|
14
|
-
const log = logger_1.Logger.internal;
|
|
15
|
-
// Workaround for https://github.com/microsoft/TypeScript/issues/43329
|
|
16
|
-
const _importDynamic = new Function("modulePath", "return import(modulePath)");
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { satisfies } from 'semver';
|
|
6
|
+
import { Logger } from './logger.js';
|
|
7
|
+
import { PluginManager } from './pluginManager.js';
|
|
8
|
+
import getVersion from './version.js';
|
|
9
|
+
const log = Logger.internal;
|
|
17
10
|
/**
|
|
18
11
|
* Represents a loaded Homebridge plugin.
|
|
19
12
|
*/
|
|
20
|
-
class Plugin {
|
|
13
|
+
export class Plugin {
|
|
21
14
|
pluginName;
|
|
22
15
|
scope; // npm package scope
|
|
23
16
|
pluginPath; // like "/usr/local/lib/node_modules/homebridge-lockitron"
|
|
@@ -36,20 +29,20 @@ class Plugin {
|
|
|
36
29
|
this.pluginName = name;
|
|
37
30
|
this.scope = scope;
|
|
38
31
|
this.pluginPath = path;
|
|
39
|
-
this.version = packageJSON.version ||
|
|
40
|
-
this.main =
|
|
32
|
+
this.version = packageJSON.version || '0.0.0';
|
|
33
|
+
this.main = '';
|
|
41
34
|
// figure out the main module
|
|
42
35
|
// exports is available - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_package_entry_points
|
|
43
36
|
if (packageJSON.exports) {
|
|
44
37
|
// main entrypoint - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_main_entry_point_export
|
|
45
|
-
if (typeof packageJSON.exports ===
|
|
38
|
+
if (typeof packageJSON.exports === 'string') {
|
|
46
39
|
this.main = packageJSON.exports;
|
|
47
40
|
}
|
|
48
41
|
else { // subpath export - https://nodejs.org/dist/latest-v14.x/docs/api/packages.html#packages_subpath_exports
|
|
49
42
|
// 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[
|
|
43
|
+
const exports = packageJSON.exports.import || packageJSON.exports.require || packageJSON.exports.node || packageJSON.exports.default || packageJSON.exports['.'];
|
|
51
44
|
// check if conditional export is nested
|
|
52
|
-
if (typeof exports !==
|
|
45
|
+
if (typeof exports !== 'string') {
|
|
53
46
|
if (exports.import) {
|
|
54
47
|
this.main = exports.import;
|
|
55
48
|
}
|
|
@@ -64,10 +57,10 @@ class Plugin {
|
|
|
64
57
|
}
|
|
65
58
|
// exports search was not successful, fallback to package.main, using index.js as fallback
|
|
66
59
|
if (!this.main) {
|
|
67
|
-
this.main = packageJSON.main ||
|
|
60
|
+
this.main = packageJSON.main || './index.js';
|
|
68
61
|
}
|
|
69
62
|
// check if it is an ESM module
|
|
70
|
-
this.isESM = this.main.endsWith(
|
|
63
|
+
this.isESM = this.main.endsWith('.mjs') || (this.main.endsWith('.js') && packageJSON.type === 'module');
|
|
71
64
|
// very temporary fix for first wave of plugins
|
|
72
65
|
if (packageJSON.peerDependencies && (!packageJSON.engines || !packageJSON.engines.homebridge)) {
|
|
73
66
|
packageJSON.engines = packageJSON.engines || {};
|
|
@@ -79,7 +72,7 @@ class Plugin {
|
|
|
79
72
|
};
|
|
80
73
|
}
|
|
81
74
|
getPluginIdentifier() {
|
|
82
|
-
return (this.scope ? this.scope
|
|
75
|
+
return (this.scope ? `${this.scope}/` : '') + this.pluginName;
|
|
83
76
|
}
|
|
84
77
|
getPluginPath() {
|
|
85
78
|
return this.pluginPath;
|
|
@@ -89,7 +82,7 @@ class Plugin {
|
|
|
89
82
|
throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register an accessory '${name}' which has already been registered!`);
|
|
90
83
|
}
|
|
91
84
|
if (!this.disabled) {
|
|
92
|
-
log.info(
|
|
85
|
+
log.info('Registering accessory \'%s\'', `${this.getPluginIdentifier()}.${name}`);
|
|
93
86
|
}
|
|
94
87
|
this.registeredAccessories.set(name, constructor);
|
|
95
88
|
}
|
|
@@ -98,12 +91,12 @@ class Plugin {
|
|
|
98
91
|
throw new Error(`Plugin '${this.getPluginIdentifier()}' tried to register a platform '${name}' which has already been registered!`);
|
|
99
92
|
}
|
|
100
93
|
if (!this.disabled) {
|
|
101
|
-
log.info(
|
|
94
|
+
log.info('Registering platform \'%s\'', `${this.getPluginIdentifier()}.${name}`);
|
|
102
95
|
}
|
|
103
96
|
this.registeredPlatforms.set(name, constructor);
|
|
104
97
|
}
|
|
105
98
|
getAccessoryConstructor(accessoryIdentifier) {
|
|
106
|
-
const name =
|
|
99
|
+
const name = PluginManager.getAccessoryName(accessoryIdentifier);
|
|
107
100
|
const constructor = this.registeredAccessories.get(name);
|
|
108
101
|
if (!constructor) {
|
|
109
102
|
throw new Error(`The requested accessory '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`);
|
|
@@ -111,20 +104,20 @@ class Plugin {
|
|
|
111
104
|
return constructor;
|
|
112
105
|
}
|
|
113
106
|
getPlatformConstructor(platformIdentifier) {
|
|
114
|
-
const name =
|
|
107
|
+
const name = PluginManager.getPlatformName(platformIdentifier);
|
|
115
108
|
const constructor = this.registeredPlatforms.get(name);
|
|
116
109
|
if (!constructor) {
|
|
117
110
|
throw new Error(`The requested platform '${name}' was not registered by the plugin '${this.getPluginIdentifier()}'.`);
|
|
118
111
|
}
|
|
119
112
|
// If it's a dynamic platform plugin, ensure it's not enabled multiple times.
|
|
120
113
|
if (this.activeDynamicPlatforms.has(name)) {
|
|
121
|
-
throw new Error(
|
|
122
|
-
|
|
114
|
+
throw new Error(`The dynamic platform ${name} from the plugin ${this.getPluginIdentifier()} is configured `
|
|
115
|
+
+ `times in your config.json.`);
|
|
123
116
|
}
|
|
124
117
|
return constructor;
|
|
125
118
|
}
|
|
126
119
|
assignDynamicPlatform(platformIdentifier, platformPlugin) {
|
|
127
|
-
const name =
|
|
120
|
+
const name = PluginManager.getPlatformName(platformIdentifier);
|
|
128
121
|
let platforms = this.activeDynamicPlatforms.get(name);
|
|
129
122
|
if (!platforms) {
|
|
130
123
|
platforms = [];
|
|
@@ -141,7 +134,7 @@ class Plugin {
|
|
|
141
134
|
}
|
|
142
135
|
async load() {
|
|
143
136
|
const context = this.loadContext;
|
|
144
|
-
(
|
|
137
|
+
assert(context, 'Reached illegal state. Plugin state is undefined!');
|
|
145
138
|
this.loadContext = undefined; // free up memory
|
|
146
139
|
// pluck out the HomeBridge version requirement
|
|
147
140
|
if (!context.engines || !context.engines.homebridge) {
|
|
@@ -150,33 +143,32 @@ class Plugin {
|
|
|
150
143
|
const versionRequired = context.engines.homebridge;
|
|
151
144
|
const nodeVersionRequired = context.engines.node;
|
|
152
145
|
// make sure the version is satisfied by the currently running version of HomeBridge
|
|
153
|
-
if (!
|
|
146
|
+
if (!satisfies(getVersion(), versionRequired, { includePrerelease: true })) {
|
|
154
147
|
// TODO - change this back to an error
|
|
155
148
|
log.error(`The plugin "${this.pluginName}" requires a Homebridge version of ${versionRequired} which does \
|
|
156
|
-
not satisfy the current Homebridge version of ${(
|
|
149
|
+
not satisfy the current Homebridge version of ${getVersion()}. You may need to update this plugin (or Homebridge) to a newer version. \
|
|
157
150
|
You may face unexpected issues or stability problems running this plugin.`);
|
|
158
151
|
}
|
|
159
152
|
// make sure the version is satisfied by the currently running version of Node
|
|
160
|
-
if (nodeVersionRequired && !
|
|
153
|
+
if (nodeVersionRequired && !satisfies(process.version, nodeVersionRequired)) {
|
|
161
154
|
log.warn(`The plugin "${this.pluginName}" requires Node.js version of ${nodeVersionRequired} which does \
|
|
162
155
|
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
156
|
}
|
|
164
157
|
const dependencies = context.dependencies || {};
|
|
165
|
-
if (dependencies.homebridge || dependencies[
|
|
158
|
+
if (dependencies.homebridge || dependencies['hap-nodejs']) {
|
|
166
159
|
log.error(`The plugin "${this.pluginName}" defines 'homebridge' and/or 'hap-nodejs' in their 'dependencies' section, \
|
|
167
160
|
meaning they carry an additional copy of homebridge and hap-nodejs. This not only wastes disk space, but also can cause \
|
|
168
161
|
major incompatibility issues and thus is considered bad practice. Please inform the developer to update their plugin!`);
|
|
169
162
|
}
|
|
170
|
-
const mainPath =
|
|
171
|
-
// try to
|
|
172
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
163
|
+
const mainPath = path.join(this.pluginPath, this.main);
|
|
164
|
+
// try to import it and grab the exported initialization hook
|
|
173
165
|
// pathToFileURL(specifier).href to turn a path into a "file url"
|
|
174
166
|
// see https://github.com/nodejs/node/issues/31710
|
|
175
|
-
const pluginModules =
|
|
176
|
-
if (typeof pluginModules ===
|
|
167
|
+
const pluginModules = await import(pathToFileURL(mainPath).href);
|
|
168
|
+
if (typeof pluginModules === 'function') {
|
|
177
169
|
this.pluginInitializer = pluginModules;
|
|
178
170
|
}
|
|
179
|
-
else if (pluginModules && typeof pluginModules.default ===
|
|
171
|
+
else if (pluginModules && typeof pluginModules.default === 'function') {
|
|
180
172
|
this.pluginInitializer = pluginModules.default;
|
|
181
173
|
}
|
|
182
174
|
else {
|
|
@@ -185,10 +177,9 @@ major incompatibility issues and thus is considered bad practice. Please inform
|
|
|
185
177
|
}
|
|
186
178
|
initialize(api) {
|
|
187
179
|
if (!this.pluginInitializer) {
|
|
188
|
-
throw new Error(
|
|
180
|
+
throw new Error('Tried to initialize a plugin which hasn\'t been loaded yet!');
|
|
189
181
|
}
|
|
190
182
|
return this.pluginInitializer(api);
|
|
191
183
|
}
|
|
192
184
|
}
|
|
193
|
-
exports.Plugin = Plugin;
|
|
194
185
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAeA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,UAAU,MAAM,cAAc,CAAA;AAErC,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAA;AAE3B;;GAEG;AACH,MAAM,OAAO,MAAM;IACA,UAAU,CAAY;IACtB,KAAK,CAAS,CAAC,oBAAoB;IACnC,UAAU,CAAQ,CAAC,0DAA0D;IAC7E,KAAK,CAAS;IAExB,QAAQ,GAAG,KAAK,CAAA,CAAC,8BAA8B;IAEtD,6DAA6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A;QACnH,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QAEtD,6DAA6D;QAC7D,iEAAiE;QACjE,kDAAkD;QAElD,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;QAEhE,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE,CAAC;YACxC,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAA;QACxC,CAAC;aAAM,IAAI,aAAa,IAAI,OAAO,aAAa,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACxE,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC,OAAO,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,UAAU,oDAAoD,CAAC,CAAA;QAChG,CAAC;IACH,CAAC;IAEM,UAAU,CAAC,GAAQ;QACxB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;QAChF,CAAC;QAED,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AccessoryIdentifier, AccessoryName, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, PluginName } from
|
|
2
|
-
import { Plugin } from
|
|
1
|
+
import type { AccessoryIdentifier, AccessoryName, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, PluginName } from './api.js';
|
|
2
|
+
import { Plugin } from './plugin.js';
|
|
3
3
|
export interface PackageJSON {
|
|
4
4
|
name: string;
|
|
5
5
|
version: string;
|
|
@@ -10,7 +10,7 @@ export interface PackageJSON {
|
|
|
10
10
|
* When set as module, it marks .js file to be treated as ESM.
|
|
11
11
|
* See https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_enabling
|
|
12
12
|
*/
|
|
13
|
-
type?:
|
|
13
|
+
type?: 'module' | 'commonjs';
|
|
14
14
|
engines?: Record<string, string>;
|
|
15
15
|
dependencies?: Record<string, string>;
|
|
16
16
|
devDependencies?: Record<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginManager.d.ts","sourceRoot":"","sources":["../src/pluginManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAEb,aAAa,EACb,kBAAkB,EAClB,YAAY,EAEZ,gBAAgB,EAChB,UAAU,EACX,MAAM,UAAU,CAAA;AAYjB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMpC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IAGnB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAClE,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAE5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAA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AAC,uBAAuB;IAoB/B,OAAO,CAAC,sBAAsB;IAoBvB,qBAAqB,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,aAAa,GAAG,MAAM;IAgCvF,oBAAoB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,YAAY,GAAG,MAAM;IAgCnF,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO;IAIhE,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS;IAcjE,gCAAgC,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS;IAcvF;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAoErB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAiB/C,OAAO,CAAC,MAAM,CAAC,eAAe;IA0B9B,OAAO,CAAC,gBAAgB;IAqCxB,OAAO,CAAC,yBAAyB;CAYlC"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const plugin_1 = require("./plugin");
|
|
12
|
-
const log = logger_1.Logger.internal;
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import { Logger } from './logger.js';
|
|
7
|
+
import { Plugin } from './plugin.js';
|
|
8
|
+
const log = Logger.internal;
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const paths = require.resolve.paths('');
|
|
13
11
|
/**
|
|
14
12
|
* Utility which exposes methods to search for installed Homebridge plugins
|
|
15
13
|
*/
|
|
16
|
-
class PluginManager {
|
|
14
|
+
export class PluginManager {
|
|
17
15
|
// name must be prefixed with 'homebridge-' or '@scope/homebridge-'
|
|
18
16
|
static PLUGIN_IDENTIFIER_PATTERN = /^((@[\w-]*)\/)?(homebridge-[\w-]*)$/;
|
|
19
17
|
api;
|
|
@@ -31,7 +29,7 @@ class PluginManager {
|
|
|
31
29
|
this.api = api;
|
|
32
30
|
if (options) {
|
|
33
31
|
if (options.customPluginPath) {
|
|
34
|
-
this.searchPaths.add(
|
|
32
|
+
this.searchPaths.add(path.resolve(process.cwd(), options.customPluginPath));
|
|
35
33
|
}
|
|
36
34
|
this.strictPluginResolution = options.strictPluginResolution || false;
|
|
37
35
|
this.activePlugins = options.activePlugins;
|
|
@@ -50,32 +48,32 @@ class PluginManager {
|
|
|
50
48
|
return name.match(PluginManager.PLUGIN_IDENTIFIER_PATTERN)[2];
|
|
51
49
|
}
|
|
52
50
|
static getAccessoryName(identifier) {
|
|
53
|
-
if (identifier.
|
|
51
|
+
if (!identifier.includes('.')) {
|
|
54
52
|
return identifier;
|
|
55
53
|
}
|
|
56
|
-
return identifier.split(
|
|
54
|
+
return identifier.split('.')[1];
|
|
57
55
|
}
|
|
58
56
|
static getPlatformName(identifier) {
|
|
59
|
-
if (identifier.
|
|
57
|
+
if (!identifier.includes('.')) {
|
|
60
58
|
return identifier;
|
|
61
59
|
}
|
|
62
|
-
return identifier.split(
|
|
60
|
+
return identifier.split('.')[1];
|
|
63
61
|
}
|
|
64
62
|
static getPluginIdentifier(identifier) {
|
|
65
|
-
return identifier.split(
|
|
63
|
+
return identifier.split('.')[0];
|
|
66
64
|
}
|
|
67
65
|
async initializeInstalledPlugins() {
|
|
68
|
-
log.info(
|
|
66
|
+
log.info('---');
|
|
69
67
|
this.loadInstalledPlugins();
|
|
70
68
|
for (const [identifier, plugin] of this.plugins) {
|
|
71
69
|
try {
|
|
72
70
|
await plugin.load();
|
|
73
71
|
}
|
|
74
72
|
catch (error) {
|
|
75
|
-
log.error(
|
|
73
|
+
log.error('====================');
|
|
76
74
|
log.error(`ERROR LOADING PLUGIN ${identifier}:`);
|
|
77
75
|
log.error(error.stack);
|
|
78
|
-
log.error(
|
|
76
|
+
log.error('====================');
|
|
79
77
|
this.plugins.delete(identifier);
|
|
80
78
|
continue;
|
|
81
79
|
}
|
|
@@ -89,7 +87,7 @@ class PluginManager {
|
|
|
89
87
|
log.info(`Loaded plugin: ${identifier}@${plugin.version}`);
|
|
90
88
|
}
|
|
91
89
|
await this.initializePlugin(plugin, identifier);
|
|
92
|
-
log.info(
|
|
90
|
+
log.info('---');
|
|
93
91
|
}
|
|
94
92
|
this.currentInitializingPlugin = undefined;
|
|
95
93
|
}
|
|
@@ -99,17 +97,16 @@ class PluginManager {
|
|
|
99
97
|
await plugin.initialize(this.api); // call the plugin's initializer and pass it our API instance
|
|
100
98
|
}
|
|
101
99
|
catch (error) {
|
|
102
|
-
log.error(
|
|
100
|
+
log.error('====================');
|
|
103
101
|
log.error(`ERROR INITIALIZING PLUGIN ${identifier}:`);
|
|
104
102
|
log.error(error.stack);
|
|
105
|
-
log.error(
|
|
103
|
+
log.error('====================');
|
|
106
104
|
this.plugins.delete(identifier);
|
|
107
|
-
return;
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
handleRegisterAccessory(name, constructor, pluginIdentifier) {
|
|
111
108
|
if (!this.currentInitializingPlugin) {
|
|
112
|
-
throw new Error(`Unexpected accessory registration. Plugin ${pluginIdentifier ? `'${pluginIdentifier}' ` :
|
|
109
|
+
throw new Error(`Unexpected accessory registration. Plugin ${pluginIdentifier ? `'${pluginIdentifier}' ` : ''}tried to register outside the initializer function!`);
|
|
113
110
|
}
|
|
114
111
|
if (pluginIdentifier && pluginIdentifier !== this.currentInitializingPlugin.getPluginIdentifier()) {
|
|
115
112
|
log.info(`Plugin '${this.currentInitializingPlugin.getPluginIdentifier()}' tried to register with an incorrect plugin identifier: '${pluginIdentifier}'. Please report this to the developer!`);
|
|
@@ -125,7 +122,7 @@ class PluginManager {
|
|
|
125
122
|
}
|
|
126
123
|
handleRegisterPlatform(name, constructor, pluginIdentifier) {
|
|
127
124
|
if (!this.currentInitializingPlugin) {
|
|
128
|
-
throw new Error(`Unexpected platform registration. Plugin ${pluginIdentifier ? `'${pluginIdentifier}' ` :
|
|
125
|
+
throw new Error(`Unexpected platform registration. Plugin ${pluginIdentifier ? `'${pluginIdentifier}' ` : ''}tried to register outside the initializer function!`);
|
|
129
126
|
}
|
|
130
127
|
if (pluginIdentifier && pluginIdentifier !== this.currentInitializingPlugin.getPluginIdentifier()) {
|
|
131
128
|
log.debug(`Plugin '${this.currentInitializingPlugin.getPluginIdentifier()}' tried to register with an incorrect plugin identifier: '${pluginIdentifier}'. Please report this to the developer!`);
|
|
@@ -141,13 +138,13 @@ class PluginManager {
|
|
|
141
138
|
}
|
|
142
139
|
getPluginForAccessory(accessoryIdentifier) {
|
|
143
140
|
let plugin;
|
|
144
|
-
if (accessoryIdentifier.
|
|
141
|
+
if (!accessoryIdentifier.includes('.')) { // see if it matches exactly one accessory
|
|
145
142
|
let found = this.accessoryToPluginMap.get(accessoryIdentifier);
|
|
146
143
|
if (!found) {
|
|
147
144
|
throw new Error(`No plugin was found for the accessory "${accessoryIdentifier}" in your config.json. Please make sure the corresponding plugin is installed correctly.`);
|
|
148
145
|
}
|
|
149
146
|
if (found.length > 1) {
|
|
150
|
-
const options = found.map(plugin => plugin.getPluginIdentifier()
|
|
147
|
+
const options = found.map(plugin => `${plugin.getPluginIdentifier()}.${accessoryIdentifier}`).join(', ');
|
|
151
148
|
// check if only one of the multiple platforms is not disabled
|
|
152
149
|
found = found.filter(plugin => !plugin.disabled);
|
|
153
150
|
if (found.length !== 1) {
|
|
@@ -155,7 +152,7 @@ class PluginManager {
|
|
|
155
152
|
}
|
|
156
153
|
}
|
|
157
154
|
plugin = found[0];
|
|
158
|
-
accessoryIdentifier = plugin.getPluginIdentifier()
|
|
155
|
+
accessoryIdentifier = `${plugin.getPluginIdentifier()}.${accessoryIdentifier}`;
|
|
159
156
|
}
|
|
160
157
|
else {
|
|
161
158
|
const pluginIdentifier = PluginManager.getPluginIdentifier(accessoryIdentifier);
|
|
@@ -168,13 +165,13 @@ class PluginManager {
|
|
|
168
165
|
}
|
|
169
166
|
getPluginForPlatform(platformIdentifier) {
|
|
170
167
|
let plugin;
|
|
171
|
-
if (platformIdentifier.
|
|
168
|
+
if (!platformIdentifier.includes('.')) { // see if it matches exactly one platform
|
|
172
169
|
let found = this.platformToPluginMap.get(platformIdentifier);
|
|
173
170
|
if (!found) {
|
|
174
171
|
throw new Error(`No plugin was found for the platform "${platformIdentifier}" in your config.json. Please make sure the corresponding plugin is installed correctly.`);
|
|
175
172
|
}
|
|
176
173
|
if (found.length > 1) {
|
|
177
|
-
const options = found.map(plugin => plugin.getPluginIdentifier()
|
|
174
|
+
const options = found.map(plugin => `${plugin.getPluginIdentifier()}.${platformIdentifier}`).join(', ');
|
|
178
175
|
// check if only one of the multiple platforms is not disabled
|
|
179
176
|
found = found.filter(plugin => !plugin.disabled);
|
|
180
177
|
if (found.length !== 1) {
|
|
@@ -182,7 +179,7 @@ class PluginManager {
|
|
|
182
179
|
}
|
|
183
180
|
}
|
|
184
181
|
plugin = found[0];
|
|
185
|
-
platformIdentifier = plugin.getPluginIdentifier()
|
|
182
|
+
platformIdentifier = `${plugin.getPluginIdentifier()}.${platformIdentifier}`;
|
|
186
183
|
}
|
|
187
184
|
else {
|
|
188
185
|
const pluginIdentifier = PluginManager.getPluginIdentifier(platformIdentifier);
|
|
@@ -216,7 +213,7 @@ class PluginManager {
|
|
|
216
213
|
return undefined;
|
|
217
214
|
}
|
|
218
215
|
else if (found.length > 1) {
|
|
219
|
-
const plugins = found.map(plugin => plugin.getPluginIdentifier()).join(
|
|
216
|
+
const plugins = found.map(plugin => plugin.getPluginIdentifier()).join(', ');
|
|
220
217
|
throw new Error(`'${platformName}' is an ambiguous platform name. It was registered by multiple plugins: ${plugins}`);
|
|
221
218
|
}
|
|
222
219
|
else {
|
|
@@ -228,70 +225,68 @@ class PluginManager {
|
|
|
228
225
|
*/
|
|
229
226
|
loadInstalledPlugins() {
|
|
230
227
|
this.loadDefaultPaths();
|
|
231
|
-
this.searchPaths.forEach(searchPath => {
|
|
232
|
-
if (!
|
|
228
|
+
this.searchPaths.forEach((searchPath) => {
|
|
229
|
+
if (!fs.existsSync(searchPath)) { // just because this path is in require.main.paths doesn't mean it necessarily exists!
|
|
233
230
|
return;
|
|
234
231
|
}
|
|
235
|
-
if (
|
|
232
|
+
if (fs.existsSync(path.join(searchPath, 'package.json'))) { // does this path point inside a single plugin and not a directory containing plugins?
|
|
236
233
|
try {
|
|
237
234
|
this.loadPlugin(searchPath);
|
|
238
235
|
}
|
|
239
236
|
catch (error) {
|
|
240
237
|
log.warn(error.message);
|
|
241
|
-
return;
|
|
242
238
|
}
|
|
243
239
|
}
|
|
244
240
|
else { // read through each directory in this node_modules folder
|
|
245
|
-
const relativePluginPaths =
|
|
246
|
-
.filter(relativePath => {
|
|
241
|
+
const relativePluginPaths = fs.readdirSync(searchPath) // search for directories only
|
|
242
|
+
.filter((relativePath) => {
|
|
247
243
|
try {
|
|
248
|
-
return
|
|
244
|
+
return fs.statSync(path.resolve(searchPath, relativePath)).isDirectory();
|
|
249
245
|
}
|
|
250
|
-
catch (
|
|
251
|
-
log.debug(`Ignoring path ${
|
|
246
|
+
catch (error) {
|
|
247
|
+
log.debug(`Ignoring path ${path.resolve(searchPath, relativePath)} - ${error.message}`);
|
|
252
248
|
return false;
|
|
253
249
|
}
|
|
254
250
|
});
|
|
255
251
|
// expand out @scoped plugins
|
|
256
252
|
relativePluginPaths.slice()
|
|
257
|
-
.filter(path => path.charAt(0) ===
|
|
258
|
-
.forEach(scopeDirectory => {
|
|
253
|
+
.filter(path => path.charAt(0) === '@') // is it a scope directory?
|
|
254
|
+
.forEach((scopeDirectory) => {
|
|
259
255
|
// remove scopeDirectory from the path list
|
|
260
256
|
const index = relativePluginPaths.indexOf(scopeDirectory);
|
|
261
257
|
relativePluginPaths.splice(index, 1);
|
|
262
|
-
const absolutePath =
|
|
263
|
-
|
|
258
|
+
const absolutePath = path.join(searchPath, scopeDirectory);
|
|
259
|
+
fs.readdirSync(absolutePath)
|
|
264
260
|
.filter(name => PluginManager.isQualifiedPluginIdentifier(name))
|
|
265
|
-
.filter(name => {
|
|
261
|
+
.filter((name) => {
|
|
266
262
|
try {
|
|
267
|
-
return
|
|
263
|
+
return fs.statSync(path.resolve(absolutePath, name)).isDirectory();
|
|
268
264
|
}
|
|
269
|
-
catch (
|
|
270
|
-
log.debug(`Ignoring path ${
|
|
265
|
+
catch (error) {
|
|
266
|
+
log.debug(`Ignoring path ${path.resolve(absolutePath, name)} - ${error.message}`);
|
|
271
267
|
return false;
|
|
272
268
|
}
|
|
273
269
|
})
|
|
274
|
-
.forEach(name => relativePluginPaths.push(scopeDirectory
|
|
270
|
+
.forEach(name => relativePluginPaths.push(`${scopeDirectory}/${name}`));
|
|
275
271
|
});
|
|
276
272
|
relativePluginPaths
|
|
277
|
-
.filter(pluginIdentifier => {
|
|
273
|
+
.filter((pluginIdentifier) => {
|
|
278
274
|
return PluginManager.isQualifiedPluginIdentifier(pluginIdentifier) // needs to be a valid homebridge plugin name
|
|
279
275
|
&& (!this.activePlugins || this.activePlugins.includes(pluginIdentifier)); // check if activePlugins is restricted and if so is the plugin is contained
|
|
280
276
|
})
|
|
281
|
-
.forEach(pluginIdentifier => {
|
|
277
|
+
.forEach((pluginIdentifier) => {
|
|
282
278
|
try {
|
|
283
|
-
const absolutePath =
|
|
279
|
+
const absolutePath = path.resolve(searchPath, pluginIdentifier);
|
|
284
280
|
this.loadPlugin(absolutePath);
|
|
285
281
|
}
|
|
286
282
|
catch (error) {
|
|
287
283
|
log.warn(error.message);
|
|
288
|
-
return;
|
|
289
284
|
}
|
|
290
285
|
});
|
|
291
286
|
}
|
|
292
287
|
});
|
|
293
288
|
if (this.plugins.size === 0) {
|
|
294
|
-
log.warn(
|
|
289
|
+
log.warn('No plugins found.');
|
|
295
290
|
}
|
|
296
291
|
}
|
|
297
292
|
loadPlugin(absolutePath) {
|
|
@@ -303,27 +298,27 @@ class PluginManager {
|
|
|
303
298
|
if (alreadyInstalled) {
|
|
304
299
|
throw new Error(`Warning: skipping plugin found at '${absolutePath}' since we already loaded the same plugin from '${alreadyInstalled.getPluginPath()}'.`);
|
|
305
300
|
}
|
|
306
|
-
const plugin = new
|
|
301
|
+
const plugin = new Plugin(name, absolutePath, packageJson, scope);
|
|
307
302
|
this.plugins.set(identifier, plugin);
|
|
308
303
|
return plugin;
|
|
309
304
|
}
|
|
310
305
|
static loadPackageJSON(pluginPath) {
|
|
311
|
-
const packageJsonPath =
|
|
306
|
+
const packageJsonPath = path.join(pluginPath, 'package.json');
|
|
312
307
|
let packageJson;
|
|
313
|
-
if (!
|
|
308
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
314
309
|
throw new Error(`Plugin ${pluginPath} does not contain a package.json.`);
|
|
315
310
|
}
|
|
316
311
|
try {
|
|
317
|
-
packageJson = JSON.parse(
|
|
312
|
+
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf8' })); // attempt to parse package.json
|
|
318
313
|
}
|
|
319
|
-
catch (
|
|
320
|
-
throw new Error(`Plugin ${pluginPath} contains an invalid package.json. Error: ${
|
|
314
|
+
catch (error) {
|
|
315
|
+
throw new Error(`Plugin ${pluginPath} contains an invalid package.json. Error: ${error}`);
|
|
321
316
|
}
|
|
322
317
|
if (!packageJson.name || !PluginManager.isQualifiedPluginIdentifier(packageJson.name)) {
|
|
323
318
|
throw new Error(`Plugin ${pluginPath} does not have a package name that begins with 'homebridge-' or '@scope/homebridge-.`);
|
|
324
319
|
}
|
|
325
320
|
// verify that it's tagged with the correct keyword
|
|
326
|
-
if (!packageJson.keywords || !packageJson.keywords.includes(
|
|
321
|
+
if (!packageJson.keywords || !packageJson.keywords.includes('homebridge-plugin')) {
|
|
327
322
|
throw new Error(`Plugin ${pluginPath} package.json does not contain the keyword 'homebridge-plugin'.`);
|
|
328
323
|
}
|
|
329
324
|
return packageJson;
|
|
@@ -338,9 +333,9 @@ class PluginManager {
|
|
|
338
333
|
}
|
|
339
334
|
return;
|
|
340
335
|
}
|
|
341
|
-
if (
|
|
336
|
+
if (paths) {
|
|
342
337
|
// add the paths used by require()
|
|
343
|
-
|
|
338
|
+
paths.forEach(path => this.searchPaths.add(path));
|
|
344
339
|
}
|
|
345
340
|
// THIS SECTION FROM: https://github.com/yeoman/environment/blob/master/lib/resolver.js
|
|
346
341
|
// Adding global npm directories
|
|
@@ -349,32 +344,31 @@ class PluginManager {
|
|
|
349
344
|
// performance issues. So, we go with our best bet for now.
|
|
350
345
|
if (process.env.NODE_PATH) {
|
|
351
346
|
process.env.NODE_PATH
|
|
352
|
-
.split(
|
|
347
|
+
.split(path.delimiter)
|
|
353
348
|
.filter(path => !!path) // trim out empty values
|
|
354
349
|
.forEach(path => this.searchPaths.add(path));
|
|
355
350
|
}
|
|
356
351
|
else {
|
|
357
352
|
// Default paths for non-windows systems
|
|
358
|
-
if (process.platform !==
|
|
359
|
-
this.searchPaths.add(
|
|
360
|
-
this.searchPaths.add(
|
|
353
|
+
if (process.platform !== 'win32') {
|
|
354
|
+
this.searchPaths.add('/usr/local/lib/node_modules');
|
|
355
|
+
this.searchPaths.add('/usr/lib/node_modules');
|
|
361
356
|
}
|
|
362
357
|
this.addNpmPrefixToSearchPaths();
|
|
363
358
|
}
|
|
364
359
|
}
|
|
365
360
|
addNpmPrefixToSearchPaths() {
|
|
366
|
-
if (process.platform ===
|
|
367
|
-
this.searchPaths.add(
|
|
361
|
+
if (process.platform === 'win32') {
|
|
362
|
+
this.searchPaths.add(path.join(process.env.APPDATA, 'npm/node_modules'));
|
|
368
363
|
}
|
|
369
364
|
else {
|
|
370
|
-
this.searchPaths.add(
|
|
365
|
+
this.searchPaths.add(execSync('/bin/echo -n "$(npm -g prefix)/lib/node_modules"', {
|
|
371
366
|
env: Object.assign({
|
|
372
|
-
npm_config_loglevel:
|
|
373
|
-
npm_update_notifier:
|
|
367
|
+
npm_config_loglevel: 'silent',
|
|
368
|
+
npm_update_notifier: 'false',
|
|
374
369
|
}, process.env),
|
|
375
|
-
}).toString(
|
|
370
|
+
}).toString('utf8'));
|
|
376
371
|
}
|
|
377
372
|
}
|
|
378
373
|
}
|
|
379
|
-
exports.PluginManager = PluginManager;
|
|
380
374
|
//# sourceMappingURL=pluginManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginManager.js","sourceRoot":"","sources":["../src/pluginManager.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,OAAO,MAAM,cAAc,CAAA;AAKlC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAA;AAC3B,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AA0CvC;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB,mEAAmE;IAC3D,MAAM,CAAU,yBAAyB,GAAG,qCAAqC,CAAA;IAExE,GAAG,CAAe;IAElB,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAA,CAAC,uEAAuE;IAC5G,sBAAsB,GAAY,KAAK,CAAA;IACvC,aAAa,CAAqB;IAClC,eAAe,CAAqB;IAEpC,OAAO,GAAkC,IAAI,GAAG,EAAE,CAAA;IACnE,qIAAqI;IACpH,2BAA2B,GAA4C,IAAI,GAAG,EAAE,CAAA;IAChF,oBAAoB,GAAiC,IAAI,GAAG,EAAE,CAAA;IAC9D,mBAAmB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