@homebridge/plugin-ui-utils 1.0.3 → 1.0.4-beta.0
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/CHANGELOG.md +4 -0
- package/DEVELOPMENT.md +10 -11
- package/README.md +128 -127
- package/eslint.config.js +27 -0
- package/package.json +27 -26
- package/tsconfig.ui.json +2 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/server.d.ts +0 -96
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -184
- package/dist/server.js.map +0 -1
- package/dist/ui.d.ts +0 -62
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.interface.d.ts +0 -307
- package/dist/ui.interface.d.ts.map +0 -1
- package/dist/ui.interface.js +0 -3
- package/dist/ui.interface.js.map +0 -1
- package/dist/ui.js +0 -299
- package/dist/ui.js.map +0 -1
- package/dist/ui.mock.d.ts +0 -37
- package/dist/ui.mock.d.ts.map +0 -1
- package/dist/ui.mock.js +0 -101
- package/dist/ui.mock.js.map +0 -1
package/dist/ui.interface.d.ts
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface Window {
|
|
3
|
-
homebridge: IHomebridgePluginUi;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
export interface PluginSchema extends Record<string, unknown> {
|
|
7
|
-
pluginAlias: string;
|
|
8
|
-
pluginType: string;
|
|
9
|
-
singular?: boolean;
|
|
10
|
-
customUi?: boolean;
|
|
11
|
-
headerDisplay?: string;
|
|
12
|
-
footerDisplay?: string;
|
|
13
|
-
schema?: Record<string, any>;
|
|
14
|
-
layout?: Record<string, any>[];
|
|
15
|
-
form?: Record<string, any>[];
|
|
16
|
-
}
|
|
17
|
-
export interface PluginFormSchema {
|
|
18
|
-
schema: Record<string, any>;
|
|
19
|
-
layout?: Record<string, any>[] | null;
|
|
20
|
-
form?: Record<string, any>[] | null;
|
|
21
|
-
}
|
|
22
|
-
export interface PluginMetadata {
|
|
23
|
-
name: string;
|
|
24
|
-
displayName?: string;
|
|
25
|
-
description: string;
|
|
26
|
-
verifiedPlugin: boolean;
|
|
27
|
-
installedVersion: string;
|
|
28
|
-
latestVersion: string | null;
|
|
29
|
-
updateAvailable: boolean;
|
|
30
|
-
publicPackage: boolean;
|
|
31
|
-
globalInstall: boolean;
|
|
32
|
-
settingsSchema: boolean;
|
|
33
|
-
installPath: string;
|
|
34
|
-
links: Record<string, string>[];
|
|
35
|
-
funding?: Record<string, string>[];
|
|
36
|
-
}
|
|
37
|
-
export interface ServerEnvMetadata {
|
|
38
|
-
theme: string;
|
|
39
|
-
serverTimestamp: string;
|
|
40
|
-
formAuth: boolean | 'none';
|
|
41
|
-
env: {
|
|
42
|
-
ableToConfigureSelf: boolean;
|
|
43
|
-
dockerOfflineUpdate: boolean;
|
|
44
|
-
enableAccessories: boolean;
|
|
45
|
-
enableTerminalAccess: boolean;
|
|
46
|
-
homebridgeInstanceName: string;
|
|
47
|
-
nodeVersion: string;
|
|
48
|
-
packageName: string;
|
|
49
|
-
packageVersion: string;
|
|
50
|
-
platform: string;
|
|
51
|
-
runningInDocker: boolean;
|
|
52
|
-
runningInLinux: boolean;
|
|
53
|
-
serviceMode: boolean;
|
|
54
|
-
temperatureUnits: string;
|
|
55
|
-
lang: string | null;
|
|
56
|
-
instanceId: string;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export interface CachedAccessory {
|
|
60
|
-
plugin: string;
|
|
61
|
-
platform: string;
|
|
62
|
-
context: Record<string, any>;
|
|
63
|
-
displayName: string;
|
|
64
|
-
UUID: string;
|
|
65
|
-
category: string;
|
|
66
|
-
services: any[];
|
|
67
|
-
}
|
|
68
|
-
export declare type PluginConfig = Record<string, any>;
|
|
69
|
-
export declare class IHomebridgePluginUi extends EventTarget {
|
|
70
|
-
/**
|
|
71
|
-
* Send a popup toast notification to the UI.
|
|
72
|
-
*/
|
|
73
|
-
toast: IHomebridgeUiToastHelper;
|
|
74
|
-
/**
|
|
75
|
-
* An object containing information about the current plugin.
|
|
76
|
-
*/
|
|
77
|
-
plugin: PluginMetadata;
|
|
78
|
-
/**
|
|
79
|
-
* An object containing information about the server.
|
|
80
|
-
*/
|
|
81
|
-
serverEnv: ServerEnvMetadata;
|
|
82
|
-
/**
|
|
83
|
-
* Tell the UI to adjust the height of the iframe container to the same as your document body
|
|
84
|
-
*/
|
|
85
|
-
fixScrollHeight(): any;
|
|
86
|
-
/**
|
|
87
|
-
* Close the Plugin Settings modal.
|
|
88
|
-
* This action does not save any config changes.
|
|
89
|
-
*/
|
|
90
|
-
closeSettings(): void;
|
|
91
|
-
/**
|
|
92
|
-
* Show a loading spinner overlay.
|
|
93
|
-
* Prevents user input until cleared with `homebridge.hideSpinner();`
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* homebridge.showSpinner();
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
showSpinner(): void;
|
|
101
|
-
/**
|
|
102
|
-
* Hide the loading spinner overlay.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* homebridge.hideSpinner();
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
hideSpinner(): void;
|
|
110
|
-
/**
|
|
111
|
-
* Show the schema-generated form below the custom UI.
|
|
112
|
-
* This only works for platform plugins that have set `singular` = `true` in their config.schema.json file.
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* homebridge.showSchemaForm();
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
showSchemaForm(): void;
|
|
120
|
-
/**
|
|
121
|
-
* Hides the schema-generated form.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```ts
|
|
125
|
-
* this.hideSchemaForm();
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
hideSchemaForm(): void;
|
|
129
|
-
/**
|
|
130
|
-
* Create a standalone form using a generic schema.
|
|
131
|
-
* This is not linked to the main config schema model, and you must listen for changes yourself.
|
|
132
|
-
*
|
|
133
|
-
* @param schema the schema used to generate the standalone form. See [schema guide](https://developers.homebridge.io/#/config-schema).
|
|
134
|
-
* @param data the initial form data
|
|
135
|
-
*
|
|
136
|
-
* @param submitButton
|
|
137
|
-
* @param cancelButton
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* const myForm = homebridge.createForm(
|
|
141
|
-
* {
|
|
142
|
-
* schema: {
|
|
143
|
-
* type: 'object',
|
|
144
|
-
* properties: {
|
|
145
|
-
* name: {
|
|
146
|
-
* title: 'Name',
|
|
147
|
-
* type: string,
|
|
148
|
-
* required: true,
|
|
149
|
-
* }
|
|
150
|
-
* }
|
|
151
|
-
* },
|
|
152
|
-
* layout: null,
|
|
153
|
-
* form: null,
|
|
154
|
-
* },
|
|
155
|
-
* {
|
|
156
|
-
* name: 'initial name value'
|
|
157
|
-
* }
|
|
158
|
-
* );
|
|
159
|
-
*
|
|
160
|
-
* // listen for input changes
|
|
161
|
-
* myForm.onChange((change) => {
|
|
162
|
-
* console.log(change);
|
|
163
|
-
* });
|
|
164
|
-
*
|
|
165
|
-
* // stop listening / hide the form
|
|
166
|
-
* myForm.end();
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
createForm(schema: PluginFormSchema, data: any, submitButton?: string, cancelButton?: string): IHomebridgeUiFormHelper;
|
|
170
|
-
/**
|
|
171
|
-
* Removes the form.
|
|
172
|
-
*/
|
|
173
|
-
endForm(): void;
|
|
174
|
-
/**
|
|
175
|
-
* Get the current config for the plugin.
|
|
176
|
-
* @returns an array of platforms or accessory config blocks.
|
|
177
|
-
* @returns an empty array if the plugin has no current config.
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* const pluginConfigBlocks = await homebridge.getPluginConfig();
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
getPluginConfig(): Promise<PluginConfig[]>;
|
|
185
|
-
/**
|
|
186
|
-
* Update the plugin config.
|
|
187
|
-
* This should be called whenever a change to the config is made.
|
|
188
|
-
* This method does not save the changes to the config.json file.
|
|
189
|
-
* Existing blocks not included will be removed.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* await homebridge.updatePluginConfig(
|
|
194
|
-
* [
|
|
195
|
-
* {
|
|
196
|
-
* "name": "my light",
|
|
197
|
-
* "platform": "example_platform"
|
|
198
|
-
* }
|
|
199
|
-
* ]
|
|
200
|
-
* );
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
updatePluginConfig(pluginConfig: PluginConfig[]): Promise<PluginConfig[]>;
|
|
204
|
-
/**
|
|
205
|
-
* Save the plugin config.
|
|
206
|
-
* You must call `homebridge.updatePluginConfig` first.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```ts
|
|
210
|
-
* await homebridge.savePluginConfig();
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
savePluginConfig(): Promise<void>;
|
|
214
|
-
/**
|
|
215
|
-
* Returns the plugin's config.schema.json
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```ts
|
|
219
|
-
* const schema = await homebridge.getPluginConfigSchema();
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
getPluginConfigSchema(): Promise<PluginSchema>;
|
|
223
|
-
/**
|
|
224
|
-
* Return an array of cached accessories for your plugin.
|
|
225
|
-
*/
|
|
226
|
-
getCachedAccessories(): Promise<CachedAccessory[]>;
|
|
227
|
-
/**
|
|
228
|
-
* Make a request to the plugins server side script
|
|
229
|
-
* @param path - the path handler on the server that the request should be sent to
|
|
230
|
-
* @param body - an optional payload
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```ts
|
|
234
|
-
*
|
|
235
|
-
* const response = await homebridge.request('/hello', { who: 'world' });
|
|
236
|
-
* console.log(response); // the response from the server
|
|
237
|
-
* ```
|
|
238
|
-
*
|
|
239
|
-
* The server side component would handle this using `this.onRequest`.
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* ```ts
|
|
243
|
-
* this.onRequest('/hello', async (payload) => {
|
|
244
|
-
* return {hello: 'user'};
|
|
245
|
-
* });
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
request(path: string, body?: any): Promise<any>;
|
|
249
|
-
/**
|
|
250
|
-
* Return the current language the user interface is displayed in.
|
|
251
|
-
* Returns the i18n country code.
|
|
252
|
-
*/
|
|
253
|
-
i18nCurrentLang(): Promise<string>;
|
|
254
|
-
/**
|
|
255
|
-
* Returns the full translation object for the current language.
|
|
256
|
-
*/
|
|
257
|
-
i18nGetTranslation(): Promise<Record<string, string>>;
|
|
258
|
-
}
|
|
259
|
-
export declare class IHomebridgeUiToastHelper {
|
|
260
|
-
/**
|
|
261
|
-
* Trigger a success toast notification in the UI
|
|
262
|
-
* @param message
|
|
263
|
-
* @param title - optional title
|
|
264
|
-
*/
|
|
265
|
-
success(message: string, title?: string): any;
|
|
266
|
-
/**
|
|
267
|
-
* Trigger an error toast notification in the UI
|
|
268
|
-
* @param message
|
|
269
|
-
* @param title - optional title
|
|
270
|
-
*/
|
|
271
|
-
error(message: string, title?: string): any;
|
|
272
|
-
/**
|
|
273
|
-
* Trigger a warning toast notification in the UI
|
|
274
|
-
* @param message
|
|
275
|
-
* @param title - optional title
|
|
276
|
-
*/
|
|
277
|
-
warning(message: string, title?: string): any;
|
|
278
|
-
/**
|
|
279
|
-
* Trigger an info toast notification in the UI
|
|
280
|
-
* @param message
|
|
281
|
-
* @param title - optional title
|
|
282
|
-
*/
|
|
283
|
-
info(message: string, title?: string): any;
|
|
284
|
-
}
|
|
285
|
-
export declare class IHomebridgeUiFormHelper {
|
|
286
|
-
constructor(parent: IHomebridgePluginUi, schema: PluginFormSchema, data: any, submitButton: string, cancelButton: string);
|
|
287
|
-
/**
|
|
288
|
-
* Hide the form and stop listening to events
|
|
289
|
-
*/
|
|
290
|
-
end(): void;
|
|
291
|
-
/**
|
|
292
|
-
* Listen to input / change events emitted by the standalone form
|
|
293
|
-
* @param fn
|
|
294
|
-
*/
|
|
295
|
-
onChange(fn: (change: Record<string, any>) => any): void;
|
|
296
|
-
/**
|
|
297
|
-
* Listen submit button form events
|
|
298
|
-
* @param fn
|
|
299
|
-
*/
|
|
300
|
-
onSubmit(fn: (change: Record<string, any>) => any): void;
|
|
301
|
-
/**
|
|
302
|
-
* Listen cancel button form events
|
|
303
|
-
* @param fn
|
|
304
|
-
*/
|
|
305
|
-
onCancel(fn: (change: Record<string, any>) => any): void;
|
|
306
|
-
}
|
|
307
|
-
//# sourceMappingURL=ui.interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.interface.d.ts","sourceRoot":"","sources":["../src/ui.interface.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE,mBAAmB,CAAC;KACjC;CACF;AAED,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;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OAGG;IACI,QAAQ,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,GAAG,IAAI;IAE/D;;;OAGG;IACI,QAAQ,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,GAAG,IAAI;IAE/D;;;OAGG;IACI,QAAQ,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,GAAG,IAAI;CAChE"}
|
package/dist/ui.interface.js
DELETED
package/dist/ui.interface.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.interface.js","sourceRoot":"","sources":["../src/ui.interface.ts"],"names":[],"mappings":""}
|
package/dist/ui.js
DELETED
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This script is injected into a plugins custom settings ui by the Homebridge UI
|
|
4
|
-
* You should not include it in your own code, however you can use it for type information if desired.
|
|
5
|
-
* It provides the interface to interact with the Homebridge UI service.
|
|
6
|
-
*/
|
|
7
|
-
let EventTargetConstructor = window.EventTarget;
|
|
8
|
-
/**
|
|
9
|
-
* Polyfill for older browsers that do not support EventTarget as a constructor.
|
|
10
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
|
|
11
|
-
*/
|
|
12
|
-
if (!Object.prototype.hasOwnProperty.call(window.EventTarget, 'caller')) {
|
|
13
|
-
EventTargetConstructor = function () {
|
|
14
|
-
this['listeners'] = {};
|
|
15
|
-
};
|
|
16
|
-
EventTargetConstructor.prototype['listeners'] = null;
|
|
17
|
-
EventTargetConstructor.prototype.addEventListener = function (type, callback) {
|
|
18
|
-
if (!(type in this['listeners'])) {
|
|
19
|
-
this['listeners'][type] = [];
|
|
20
|
-
}
|
|
21
|
-
this['listeners'][type].push(callback);
|
|
22
|
-
};
|
|
23
|
-
EventTargetConstructor.prototype.removeEventListener = function (type, callback) {
|
|
24
|
-
if (!(type in this['listeners'])) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const stack = this['listeners'][type];
|
|
28
|
-
for (let i = 0, l = stack.length; i < l; i++) {
|
|
29
|
-
if (stack[i] === callback) {
|
|
30
|
-
stack.splice(i, 1);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
EventTargetConstructor.prototype.dispatchEvent = function (event) {
|
|
36
|
-
if (!(event.type in this['listeners'])) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
const stack = this['listeners'][event.type].slice();
|
|
40
|
-
for (let i = 0, l = stack.length; i < l; i++) {
|
|
41
|
-
stack[i].call(this, event);
|
|
42
|
-
}
|
|
43
|
-
return !event.defaultPrevented;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
class HomebridgePluginUi extends EventTargetConstructor {
|
|
47
|
-
origin = '';
|
|
48
|
-
lastBodyHeight = 0;
|
|
49
|
-
linkRequests = [];
|
|
50
|
-
toast = new HomebridgeUiToastHelper();
|
|
51
|
-
plugin = window['_homebridge'].plugin;
|
|
52
|
-
serverEnv = window['_homebridge'].serverEnv;
|
|
53
|
-
constructor() {
|
|
54
|
-
super();
|
|
55
|
-
window.addEventListener('message', this._handleIncomingMessage.bind(this), false);
|
|
56
|
-
}
|
|
57
|
-
async _handleIncomingMessage(e) {
|
|
58
|
-
switch (e.data.action) {
|
|
59
|
-
case 'ready': {
|
|
60
|
-
await Promise.all(this.linkRequests);
|
|
61
|
-
this.origin = e.origin;
|
|
62
|
-
document.body.style.display = 'block';
|
|
63
|
-
this.dispatchEvent(new Event('ready'));
|
|
64
|
-
this.fixScrollHeight();
|
|
65
|
-
this._monitorFrameHeight();
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
case 'response': {
|
|
69
|
-
this.dispatchEvent(new MessageEvent(e.data.requestId, {
|
|
70
|
-
data: e.data,
|
|
71
|
-
}));
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
case 'stream': {
|
|
75
|
-
this.dispatchEvent(new MessageEvent(e.data.event, {
|
|
76
|
-
data: e.data.data,
|
|
77
|
-
}));
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case 'body-class': {
|
|
81
|
-
this._setBodyClass(e);
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case 'inline-style': {
|
|
85
|
-
this._setInlineStyle(e);
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
case 'link-element': {
|
|
89
|
-
this._setLinkElement(e);
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
default:
|
|
93
|
-
console.log(e.data);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
_postMessage(message) {
|
|
97
|
-
window.parent.postMessage(message, this.origin || '*');
|
|
98
|
-
}
|
|
99
|
-
_setBodyClass(e) {
|
|
100
|
-
document.body.classList.add(e.data.class);
|
|
101
|
-
}
|
|
102
|
-
_setInlineStyle(e) {
|
|
103
|
-
const styleElement = document.createElement('style');
|
|
104
|
-
styleElement.innerHTML = e.data.style;
|
|
105
|
-
document.head.appendChild(styleElement);
|
|
106
|
-
}
|
|
107
|
-
_setLinkElement(e) {
|
|
108
|
-
const request = new Promise(resolve => {
|
|
109
|
-
const linkElement = document.createElement('link');
|
|
110
|
-
linkElement.setAttribute('href', e.data.href);
|
|
111
|
-
linkElement.setAttribute('rel', e.data.rel);
|
|
112
|
-
linkElement.onload = resolve;
|
|
113
|
-
linkElement.onerror = resolve;
|
|
114
|
-
document.head.appendChild(linkElement);
|
|
115
|
-
});
|
|
116
|
-
this.linkRequests.push(request);
|
|
117
|
-
}
|
|
118
|
-
_monitorFrameHeight() {
|
|
119
|
-
if (window['ResizeObserver']) {
|
|
120
|
-
// use ResizeObserver if available
|
|
121
|
-
const resizeObserver = new window['ResizeObserver'](() => {
|
|
122
|
-
this.fixScrollHeight();
|
|
123
|
-
});
|
|
124
|
-
resizeObserver.observe(document.body);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
// fall back to polling
|
|
128
|
-
setInterval(() => {
|
|
129
|
-
if (document.body.scrollHeight !== this.lastBodyHeight) {
|
|
130
|
-
this.lastBodyHeight = document.body.scrollHeight;
|
|
131
|
-
this.fixScrollHeight();
|
|
132
|
-
}
|
|
133
|
-
}, 250);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async _requestResponse(payload) {
|
|
137
|
-
// generate a random request id, so we can link the response
|
|
138
|
-
const requestId = Math.random().toString(36).substring(2);
|
|
139
|
-
payload.requestId = requestId;
|
|
140
|
-
// post message to parent
|
|
141
|
-
this._postMessage(payload);
|
|
142
|
-
// wait for response
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
const responseHandler = (event) => {
|
|
145
|
-
this.removeEventListener(requestId, responseHandler);
|
|
146
|
-
if (event.data.success) {
|
|
147
|
-
resolve(event.data.data);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
reject(event.data.data);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
this.addEventListener(requestId, responseHandler);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
fixScrollHeight() {
|
|
157
|
-
this._postMessage({ action: 'scrollHeight', scrollHeight: document.body.scrollHeight });
|
|
158
|
-
}
|
|
159
|
-
closeSettings() {
|
|
160
|
-
this._postMessage({ action: 'close' });
|
|
161
|
-
}
|
|
162
|
-
showSpinner() {
|
|
163
|
-
this._postMessage({ action: 'spinner.show' });
|
|
164
|
-
}
|
|
165
|
-
hideSpinner() {
|
|
166
|
-
this._postMessage({ action: 'spinner.hide' });
|
|
167
|
-
}
|
|
168
|
-
showSchemaForm() {
|
|
169
|
-
this._postMessage({ action: 'schema.show' });
|
|
170
|
-
}
|
|
171
|
-
hideSchemaForm() {
|
|
172
|
-
this._postMessage({ action: 'schema.hide' });
|
|
173
|
-
}
|
|
174
|
-
createForm(schema, data, submitButton, cancelButton) {
|
|
175
|
-
return new HomebridgeUiFormHelper(this, schema, data, submitButton, cancelButton);
|
|
176
|
-
}
|
|
177
|
-
endForm() {
|
|
178
|
-
this._postMessage({ action: 'form.end' });
|
|
179
|
-
}
|
|
180
|
-
async getPluginConfig() {
|
|
181
|
-
return await this._requestResponse({ action: 'config.get' });
|
|
182
|
-
}
|
|
183
|
-
async updatePluginConfig(pluginConfig) {
|
|
184
|
-
return await this._requestResponse({ action: 'config.update', pluginConfig: pluginConfig });
|
|
185
|
-
}
|
|
186
|
-
async savePluginConfig() {
|
|
187
|
-
return await this._requestResponse({ action: 'config.save' });
|
|
188
|
-
}
|
|
189
|
-
async getPluginConfigSchema() {
|
|
190
|
-
return await this._requestResponse({ action: 'config.schema' });
|
|
191
|
-
}
|
|
192
|
-
async getCachedAccessories() {
|
|
193
|
-
return await this._requestResponse({ action: 'cachedAccessories.get' });
|
|
194
|
-
}
|
|
195
|
-
async request(path, body) {
|
|
196
|
-
return await this._requestResponse({ action: 'request', path: path, body: body });
|
|
197
|
-
}
|
|
198
|
-
async i18nCurrentLang() {
|
|
199
|
-
return await this._requestResponse({ action: 'i18n.lang' });
|
|
200
|
-
}
|
|
201
|
-
async i18nGetTranslation() {
|
|
202
|
-
return await this._requestResponse({ action: 'i18n.translations' });
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
class HomebridgeUiToastHelper {
|
|
206
|
-
_postMessage(type, message, title) {
|
|
207
|
-
window.parent.postMessage({ action: 'toast.' + type, message: message, title: title }, '*');
|
|
208
|
-
}
|
|
209
|
-
success(message, title) {
|
|
210
|
-
this._postMessage('success', message, title);
|
|
211
|
-
}
|
|
212
|
-
error(message, title) {
|
|
213
|
-
this._postMessage('error', message, title);
|
|
214
|
-
}
|
|
215
|
-
warning(message, title) {
|
|
216
|
-
this._postMessage('warning', message, title);
|
|
217
|
-
}
|
|
218
|
-
info(message, title) {
|
|
219
|
-
this._postMessage('info', message, title);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
class HomebridgeUiFormHelper {
|
|
223
|
-
parent;
|
|
224
|
-
formId = Math.random().toString(36).substring(2);
|
|
225
|
-
_changeHandle;
|
|
226
|
-
_submitHandle;
|
|
227
|
-
_cancelHandle;
|
|
228
|
-
end;
|
|
229
|
-
constructor(parent, schema, data, submitButton, cancelButton) {
|
|
230
|
-
this.parent = parent;
|
|
231
|
-
this.parent._postMessage({ action: 'form.create', formId: this.formId, schema, data, submitButton, cancelButton });
|
|
232
|
-
const handle = this._eventHandle.bind(this);
|
|
233
|
-
this.parent.addEventListener(this.formId, handle);
|
|
234
|
-
this.end = () => {
|
|
235
|
-
this.parent.removeEventListener(this.formId, handle);
|
|
236
|
-
this.parent._postMessage({ action: 'form.end', formId: this.formId, schema: schema, data: data });
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
_eventHandle(event) {
|
|
240
|
-
switch (event.data.formEvent) {
|
|
241
|
-
case 'change': {
|
|
242
|
-
// general change events
|
|
243
|
-
if (this._changeHandle && typeof this._changeHandle === 'function') {
|
|
244
|
-
this._changeHandle(event.data.formData);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
console.info('Homebridge Custom Plugin UI: Missing form onChange handler.');
|
|
248
|
-
}
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
case 'submit': {
|
|
252
|
-
// submit form events
|
|
253
|
-
if (this._submitHandle && typeof this._submitHandle === 'function') {
|
|
254
|
-
this._submitHandle(event.data.formData);
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
console.info('Homebridge Custom Plugin UI: Missing form onSubmit handler.');
|
|
258
|
-
}
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
case 'cancel': {
|
|
262
|
-
// cancel form events
|
|
263
|
-
if (this._cancelHandle && typeof this._cancelHandle === 'function') {
|
|
264
|
-
this._cancelHandle(event.data.formData);
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
console.info('Homebridge Custom Plugin UI: Missing form onCancel handler.');
|
|
268
|
-
}
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
default: {
|
|
272
|
-
console.info('Unknown form event type:', event.data);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
onChange(fn) {
|
|
277
|
-
if (typeof fn !== 'function') {
|
|
278
|
-
console.error('Homebridge Custom Plugin UI: Form onChange handler must be a function.');
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
this._changeHandle = fn;
|
|
282
|
-
}
|
|
283
|
-
onSubmit(fn) {
|
|
284
|
-
if (typeof fn !== 'function') {
|
|
285
|
-
console.error('Homebridge Custom Plugin UI: Form onSubmit handler must be a function.');
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
this._submitHandle = fn;
|
|
289
|
-
}
|
|
290
|
-
onCancel(fn) {
|
|
291
|
-
if (typeof fn !== 'function') {
|
|
292
|
-
console.error('Homebridge Custom Plugin UI: Form onCancel handler must be a function.');
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
this._cancelHandle = fn;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
window['homebridge'] = new HomebridgePluginUi();
|
|
299
|
-
//# sourceMappingURL=ui.js.map
|
package/dist/ui.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,IAAI,sBAAsB,GAAG,MAAM,CAAC,WAAW,CAAC;AAEhD;;;GAGG;AACH,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC;IACxE,sBAAsB,GAAG;QACvB,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;IACzB,CAA8D,CAAC;IAE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,EAAE,CAAC;IAC1B,CAAC;IAEM,QAAQ,CAAC,EAAE;QAChB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAC;YACxF,OAAO;QACT,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;IAC1B,CAAC;CACF;AAED,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
package/dist/ui.mock.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { IHomebridgePluginUi, IHomebridgeUiToastHelper, PluginConfig, PluginFormSchema, PluginMetadata, PluginSchema, ServerEnvMetadata } from './ui.interface';
|
|
2
|
-
export declare class MockHomebridgePluginUi extends EventTarget implements IHomebridgePluginUi {
|
|
3
|
-
mockPluginConfig: PluginConfig[];
|
|
4
|
-
mockPluginSchema: PluginSchema;
|
|
5
|
-
plugin: PluginMetadata;
|
|
6
|
-
serverEnv: ServerEnvMetadata;
|
|
7
|
-
constructor();
|
|
8
|
-
toast: MockHomebridgeUiToastHelper;
|
|
9
|
-
fixScrollHeight(): void;
|
|
10
|
-
closeSettings(): void;
|
|
11
|
-
showSpinner(): void;
|
|
12
|
-
hideSpinner(): void;
|
|
13
|
-
showSchemaForm(): void;
|
|
14
|
-
hideSchemaForm(): void;
|
|
15
|
-
endForm(): void;
|
|
16
|
-
createForm(schema: any, data: any): any;
|
|
17
|
-
getPluginConfig(): Promise<PluginConfig[]>;
|
|
18
|
-
updatePluginConfig(pluginConfig: PluginConfig[]): Promise<PluginConfig[]>;
|
|
19
|
-
savePluginConfig(): Promise<void>;
|
|
20
|
-
getPluginConfigSchema(): Promise<PluginSchema>;
|
|
21
|
-
request(path: string, body: string): Promise<{}>;
|
|
22
|
-
i18nCurrentLang(): Promise<string>;
|
|
23
|
-
i18nGetTranslation(): Promise<{}>;
|
|
24
|
-
getCachedAccessories(): Promise<never[]>;
|
|
25
|
-
}
|
|
26
|
-
export declare class MockHomebridgeUiToastHelper implements IHomebridgeUiToastHelper {
|
|
27
|
-
success(message: string, title: string): void;
|
|
28
|
-
error(message: string, title: string): void;
|
|
29
|
-
warning(message: string, title: string): void;
|
|
30
|
-
info(message: string, title: string): void;
|
|
31
|
-
}
|
|
32
|
-
export declare class MockHomebridgeUiFormHelper {
|
|
33
|
-
constructor(parent: IHomebridgePluginUi, schema: PluginFormSchema, data: any);
|
|
34
|
-
end(): void;
|
|
35
|
-
onChange(fn: any): void;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=ui.mock.d.ts.map
|
package/dist/ui.mock.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.mock.d.ts","sourceRoot":"","sources":["../src/ui.mock.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAExB,qBAAa,sBAAuB,SAAQ,WAAY,YAAW,mBAAmB;IAC7E,gBAAgB,EAAE,YAAY,EAAE,CAAM;IAEtC,gBAAgB,EAAE,YAAY,CAGnC;IAEK,MAAM,EAAE,cAAc,CAa3B;IAEK,SAAS,EAAE,iBAAiB,CAqBjC;;IAOK,KAAK,8BAAqC;IAE1C,eAAe;IACf,aAAa;IACb,WAAW;IACX,WAAW;IACX,cAAc;IACd,cAAc;IACd,OAAO;IAEP,UAAU,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA;IAIjB,eAAe;IAIf,kBAAkB,CAAC,YAAY,EAAE,YAAY,EAAE;IAK/C,gBAAgB;IAEhB,qBAAqB;IAIrB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIlC,eAAe;IAIf,kBAAkB;IAIlB,oBAAoB;CAGlC;AAED,qBAAa,2BAA4B,YAAW,wBAAwB;IAC1E,OAAO,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