@homebridge/plugin-ui-utils 1.0.4-beta.0 → 1.0.4-beta.2
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 +26 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +96 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +181 -0
- package/dist/server.js.map +1 -0
- package/dist/ui.d.ts +64 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.interface.d.ts +325 -0
- package/dist/ui.interface.d.ts.map +1 -0
- package/dist/ui.interface.js +2 -0
- package/dist/ui.interface.js.map +1 -0
- package/dist/ui.js +318 -0
- package/dist/ui.js.map +1 -0
- package/dist/ui.mock.d.ts +41 -0
- package/dist/ui.mock.d.ts.map +1 -0
- package/dist/ui.mock.js +98 -0
- package/dist/ui.mock.js.map +1 -0
- package/package.json +6 -1
- package/CHANGELOG.md +0 -37
- package/DEVELOPMENT.md +0 -132
- package/eslint.config.js +0 -27
- package/tsconfig.ui.json +0 -13
package/README.md
CHANGED
|
@@ -303,6 +303,26 @@ Hide the spinner / loading overlay.
|
|
|
303
303
|
homebridge.hideSpinner()
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
+
#### `homebridge.disableSaveButton`
|
|
307
|
+
|
|
308
|
+
> `homebridge.disableSaveButton(): void`
|
|
309
|
+
|
|
310
|
+
Disables the save button in the settings modal.
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
homebridge.disableSaveButton()
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
#### `homebridge.enableSaveButton`
|
|
317
|
+
|
|
318
|
+
> `homebridge.enableSaveButton(): void`
|
|
319
|
+
|
|
320
|
+
Enables the save button in the settings modal.
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
homebridge.enableSaveButton()
|
|
324
|
+
```
|
|
325
|
+
|
|
306
326
|
### Forms
|
|
307
327
|
|
|
308
328
|
The custom user interface allows you to create two types of forms:
|
|
@@ -494,19 +514,19 @@ Note:
|
|
|
494
514
|
Example `server.js`:
|
|
495
515
|
|
|
496
516
|
```js
|
|
497
|
-
|
|
517
|
+
import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils'
|
|
498
518
|
|
|
499
519
|
// your class MUST extend the HomebridgePluginUiServer
|
|
500
520
|
class UiServer extends HomebridgePluginUiServer {
|
|
501
521
|
constructor () {
|
|
502
522
|
// super must be called first
|
|
503
|
-
super()
|
|
523
|
+
super()
|
|
504
524
|
|
|
505
525
|
// Example: create api endpoint request handlers (example only)
|
|
506
|
-
this.onRequest('/hello', this.handleHelloRequest.bind(this))
|
|
526
|
+
this.onRequest('/hello', this.handleHelloRequest.bind(this))
|
|
507
527
|
|
|
508
528
|
// this.ready() must be called to let the UI know you are ready to accept api calls
|
|
509
|
-
this.ready()
|
|
529
|
+
this.ready()
|
|
510
530
|
}
|
|
511
531
|
|
|
512
532
|
/**
|
|
@@ -514,7 +534,7 @@ class UiServer extends HomebridgePluginUiServer {
|
|
|
514
534
|
* Handle requests made from the UI to the `/hello` endpoint.
|
|
515
535
|
*/
|
|
516
536
|
async handleHelloRequest(payload) {
|
|
517
|
-
return { hello: 'world'
|
|
537
|
+
return { hello: 'world' }
|
|
518
538
|
}
|
|
519
539
|
}
|
|
520
540
|
|
|
@@ -575,7 +595,7 @@ Example:
|
|
|
575
595
|
|
|
576
596
|
```ts
|
|
577
597
|
// server side code
|
|
578
|
-
|
|
598
|
+
import { RequestError } from '@homebridge/plugin-ui-utils'
|
|
579
599
|
|
|
580
600
|
this.onRequest('/hello', async (payload) => {
|
|
581
601
|
// something went wrong, throw a RequestError:
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Homebridge Custom Plugin UI Base Class
|
|
3
|
+
* This provides the api to facilitate two-way communication between a plugin
|
|
4
|
+
* custom UI HTML code and the server.
|
|
5
|
+
*
|
|
6
|
+
* This is a base class and is intended to be extended.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* class MyPluginUiServer extends HomebridgePluginUiServer {
|
|
11
|
+
* constructor() {
|
|
12
|
+
* // this MUST be called first
|
|
13
|
+
* super();
|
|
14
|
+
*
|
|
15
|
+
* // this MUST be called to let the UI know your script is ready for requests
|
|
16
|
+
* this.ready();
|
|
17
|
+
*
|
|
18
|
+
* // example handling requests
|
|
19
|
+
* this.onRequest('/hello', (payload) => {
|
|
20
|
+
* return { hello: 'world' };
|
|
21
|
+
* });
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* // start the class
|
|
26
|
+
* (() => {
|
|
27
|
+
* return new MyPluginUiServer();
|
|
28
|
+
* })();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class HomebridgePluginUiServer {
|
|
32
|
+
private handlers;
|
|
33
|
+
constructor();
|
|
34
|
+
get homebridgeStoragePath(): string | undefined;
|
|
35
|
+
get homebridgeConfigPath(): string | undefined;
|
|
36
|
+
get homebridgeUiVersion(): string | undefined;
|
|
37
|
+
private sendResponse;
|
|
38
|
+
private processRequest;
|
|
39
|
+
/**
|
|
40
|
+
* Let the server and UI know you are ready to receive requests.
|
|
41
|
+
* This method must be called when you are ready to process requests!
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* this.ready();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
ready(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Register a new request handler for a given route.
|
|
50
|
+
* @param path the request route name
|
|
51
|
+
* @param fn the function to handle the request and provide a response
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* this.onRequest('/hello', async (payload) => {
|
|
56
|
+
* return {hello: 'user'};
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* You can then make requests to this endpoint from the client / ui using `homebridge.request`:
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* homebridge.request('/hello', {some: 'payload data'});
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
onRequest(path: string, fn: RequestHandler): void;
|
|
68
|
+
/**
|
|
69
|
+
* Push an event or stream data to the UI.
|
|
70
|
+
* @param event the event name, the plugin UI can listen for this event
|
|
71
|
+
* @param data the data to send
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* this.pushEvent('my-event', {some: 'data'});
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* In the client / ui, you would then listen to this event using `homebridge.addEventListener`:
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* homebridge.addEventListener('my-event', (event) => {
|
|
83
|
+
* // do something with the event
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
pushEvent(event: string, data: any): void;
|
|
88
|
+
}
|
|
89
|
+
export declare class RequestError extends Error {
|
|
90
|
+
requestError: any;
|
|
91
|
+
constructor(message: string, requestError: any);
|
|
92
|
+
}
|
|
93
|
+
type RequestResponse = string | number | Record<any, any> | Array<any>;
|
|
94
|
+
type RequestHandler = (arg: any) => Promise<RequestResponse> | RequestResponse;
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAqC;;IAiBrD,IAAI,qBAAqB,uBAExB;IAED,IAAI,oBAAoB,uBAEvB;IAED,IAAI,mBAAmB,uBAEtB;IAED,OAAO,CAAC,YAAY;YAeN,cAAc;IAqB5B;;;;;;;OAOG;IACI,KAAK,IAAI,IAAI;IAapB;;;;;;;;;;;;;;;;;;OAkBG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc;IAIjD;;;;;;;;;;;;;;;;;;OAkBG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;CAa1C;AAED,qBAAa,YAAa,SAAQ,KAAK;IAC9B,YAAY,EAAE,GAAG,CAAA;gBAEZ,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG;CAM/C;AAED,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;AACtE,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
/**
|
|
3
|
+
* Homebridge Custom Plugin UI Base Class
|
|
4
|
+
* This provides the api to facilitate two-way communication between a plugin
|
|
5
|
+
* custom UI HTML code and the server.
|
|
6
|
+
*
|
|
7
|
+
* This is a base class and is intended to be extended.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* class MyPluginUiServer extends HomebridgePluginUiServer {
|
|
12
|
+
* constructor() {
|
|
13
|
+
* // this MUST be called first
|
|
14
|
+
* super();
|
|
15
|
+
*
|
|
16
|
+
* // this MUST be called to let the UI know your script is ready for requests
|
|
17
|
+
* this.ready();
|
|
18
|
+
*
|
|
19
|
+
* // example handling requests
|
|
20
|
+
* this.onRequest('/hello', (payload) => {
|
|
21
|
+
* return { hello: 'world' };
|
|
22
|
+
* });
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // start the class
|
|
27
|
+
* (() => {
|
|
28
|
+
* return new MyPluginUiServer();
|
|
29
|
+
* })();
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class HomebridgePluginUiServer {
|
|
33
|
+
handlers = {};
|
|
34
|
+
constructor() {
|
|
35
|
+
if (!process.send) {
|
|
36
|
+
console.error('This script can only run as a child process.');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
process.addListener('message', (request) => {
|
|
40
|
+
switch (request.action) {
|
|
41
|
+
case 'request': {
|
|
42
|
+
this.processRequest(request);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
get homebridgeStoragePath() {
|
|
48
|
+
return process.env.HOMEBRIDGE_STORAGE_PATH;
|
|
49
|
+
}
|
|
50
|
+
get homebridgeConfigPath() {
|
|
51
|
+
return process.env.HOMEBRIDGE_CONFIG_PATH;
|
|
52
|
+
}
|
|
53
|
+
get homebridgeUiVersion() {
|
|
54
|
+
return process.env.HOMEBRIDGE_UI_VERSION;
|
|
55
|
+
}
|
|
56
|
+
sendResponse(request, data, success = true) {
|
|
57
|
+
if (!process.send) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
process.send({
|
|
61
|
+
action: 'response',
|
|
62
|
+
payload: {
|
|
63
|
+
requestId: request.requestId,
|
|
64
|
+
success,
|
|
65
|
+
data,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async processRequest(request) {
|
|
70
|
+
if (this.handlers[request.path]) {
|
|
71
|
+
try {
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log('Incoming Request:', request.path);
|
|
74
|
+
const resp = await this.handlers[request.path](request.body || {});
|
|
75
|
+
return this.sendResponse(request, resp, true);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (e instanceof RequestError) {
|
|
79
|
+
return this.sendResponse(request, { message: e.message, error: e.requestError }, false);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.error(e);
|
|
83
|
+
return this.sendResponse(request, { message: e.message }, false);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.error('No Registered Handler:', request.path);
|
|
89
|
+
return this.sendResponse(request, { message: 'Not Found', path: request.path }, false);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Let the server and UI know you are ready to receive requests.
|
|
94
|
+
* This method must be called when you are ready to process requests!
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* this.ready();
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
ready() {
|
|
101
|
+
if (!process.send) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
process.send({
|
|
105
|
+
action: 'ready',
|
|
106
|
+
payload: {
|
|
107
|
+
server: true,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Register a new request handler for a given route.
|
|
113
|
+
* @param path the request route name
|
|
114
|
+
* @param fn the function to handle the request and provide a response
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* this.onRequest('/hello', async (payload) => {
|
|
119
|
+
* return {hello: 'user'};
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* You can then make requests to this endpoint from the client / ui using `homebridge.request`:
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* homebridge.request('/hello', {some: 'payload data'});
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
onRequest(path, fn) {
|
|
131
|
+
this.handlers[path] = fn;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Push an event or stream data to the UI.
|
|
135
|
+
* @param event the event name, the plugin UI can listen for this event
|
|
136
|
+
* @param data the data to send
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* this.pushEvent('my-event', {some: 'data'});
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* In the client / ui, you would then listen to this event using `homebridge.addEventListener`:
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* homebridge.addEventListener('my-event', (event) => {
|
|
148
|
+
* // do something with the event
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
pushEvent(event, data) {
|
|
153
|
+
if (!process.send) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
process.send({
|
|
157
|
+
action: 'stream',
|
|
158
|
+
payload: {
|
|
159
|
+
event,
|
|
160
|
+
data,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export class RequestError extends Error {
|
|
166
|
+
requestError;
|
|
167
|
+
constructor(message, requestError) {
|
|
168
|
+
super(message);
|
|
169
|
+
Object.setPrototypeOf(this, RequestError.prototype);
|
|
170
|
+
this.requestError = requestError;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
setInterval(() => {
|
|
174
|
+
if (!process.connected) {
|
|
175
|
+
process.kill(process.pid, 'SIGTERM');
|
|
176
|
+
}
|
|
177
|
+
}, 10000);
|
|
178
|
+
process.on('disconnect', () => {
|
|
179
|
+
process.kill(process.pid, 'SIGTERM');
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,wBAAwB;IAC3B,QAAQ,GAAmC,EAAE,CAAA;IAErD;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAA;YAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QAED,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,OAAY,EAAE,EAAE;YAC9C,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;gBACvB,KAAK,SAAS,CAAC,CAAC,CAAC;oBACf,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAA;IAC5C,CAAC;IAED,IAAI,oBAAoB;QACtB,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAA;IAC3C,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAA;IAC1C,CAAC;IAEO,YAAY,CAAC,OAAY,EAAE,IAAS,EAAE,OAAO,GAAG,IAAI;QAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAClB,OAAM;QACR,CAAC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE;gBACP,SAAS,EAAE,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|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This script is injected into a plugins custom settings ui by the Homebridge UI
|
|
3
|
+
* You should not include it in your own code, however you can use it for type information if desired.
|
|
4
|
+
* It provides the interface to interact with the Homebridge UI service.
|
|
5
|
+
*/
|
|
6
|
+
declare let EventTargetConstructor: {
|
|
7
|
+
new (): EventTarget;
|
|
8
|
+
prototype: EventTarget;
|
|
9
|
+
};
|
|
10
|
+
declare class HomebridgePluginUi extends EventTargetConstructor {
|
|
11
|
+
private origin;
|
|
12
|
+
private lastBodyHeight;
|
|
13
|
+
private linkRequests;
|
|
14
|
+
toast: HomebridgeUiToastHelper;
|
|
15
|
+
plugin: any;
|
|
16
|
+
serverEnv: any;
|
|
17
|
+
constructor();
|
|
18
|
+
private _handleIncomingMessage;
|
|
19
|
+
_postMessage(message: any): void;
|
|
20
|
+
private _setBodyClass;
|
|
21
|
+
private _setInlineStyle;
|
|
22
|
+
private _setLinkElement;
|
|
23
|
+
private _monitorFrameHeight;
|
|
24
|
+
private _requestResponse;
|
|
25
|
+
fixScrollHeight(): void;
|
|
26
|
+
closeSettings(): void;
|
|
27
|
+
showSpinner(): void;
|
|
28
|
+
hideSpinner(): void;
|
|
29
|
+
disableSaveButton(): void;
|
|
30
|
+
enableSaveButton(): void;
|
|
31
|
+
showSchemaForm(): void;
|
|
32
|
+
hideSchemaForm(): void;
|
|
33
|
+
createForm(schema: any, data: any, submitButton?: string, cancelButton?: string): HomebridgeUiFormHelper;
|
|
34
|
+
endForm(): void;
|
|
35
|
+
getPluginConfig(): Promise<any>;
|
|
36
|
+
updatePluginConfig(pluginConfig: any): Promise<any>;
|
|
37
|
+
savePluginConfig(): Promise<any>;
|
|
38
|
+
getPluginConfigSchema(): Promise<any>;
|
|
39
|
+
getCachedAccessories(): Promise<Record<string, string>>;
|
|
40
|
+
request(path: string, body?: any): Promise<any>;
|
|
41
|
+
i18nCurrentLang(): Promise<string>;
|
|
42
|
+
i18nGetTranslation(): Promise<Record<string, string>>;
|
|
43
|
+
}
|
|
44
|
+
declare class HomebridgeUiToastHelper {
|
|
45
|
+
private _postMessage;
|
|
46
|
+
success(message: string, title?: string): void;
|
|
47
|
+
error(message: string, title?: string): void;
|
|
48
|
+
warning(message: string, title?: string): void;
|
|
49
|
+
info(message: string, title?: string): void;
|
|
50
|
+
}
|
|
51
|
+
declare class HomebridgeUiFormHelper {
|
|
52
|
+
private parent;
|
|
53
|
+
private formId;
|
|
54
|
+
private _changeHandle?;
|
|
55
|
+
private _submitHandle?;
|
|
56
|
+
private _cancelHandle?;
|
|
57
|
+
end: () => void;
|
|
58
|
+
constructor(parent: HomebridgePluginUi, schema: Record<string, any>, data: Record<string, any>, submitButton?: string, cancelButton?: string);
|
|
59
|
+
private _eventHandle;
|
|
60
|
+
onChange(fn: any): void;
|
|
61
|
+
onSubmit(fn: any): void;
|
|
62
|
+
onCancel(fn: any): void;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,QAAA,IAAI,sBAAsB;;;CAAqB,CAAA;AAyD/C,cAAM,kBAAmB,SAAQ,sBAAsB;IACrD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,YAAY,CAAyB;IAEtC,KAAK,0BAAgC;IAErC,MAAM,MAA4B;IAGlC,SAAS,MAA+B;;YAOjC,sBAAsB;IAwC7B,YAAY,CAAC,OAAO,KAAA;IAI3B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,mBAAmB;YAkBb,gBAAgB;IAuBvB,eAAe;IAIf,aAAa,IAAI,IAAI;IAIrB,W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