@homelib/core 0.0.0-wip.ba4eafa051eb
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/LICENSE +19 -0
- package/README.md +7 -0
- package/bld/exports/mobx.d.ts +1 -0
- package/bld/exports/mobx.js +2 -0
- package/bld/exports/mobx.js.map +1 -0
- package/bld/library/@lifecycle.d.ts +4 -0
- package/bld/library/@lifecycle.js +23 -0
- package/bld/library/@lifecycle.js.map +1 -0
- package/bld/library/atomics/index.d.ts +1 -0
- package/bld/library/atomics/index.js +2 -0
- package/bld/library/atomics/index.js.map +1 -0
- package/bld/library/atomics/temperature.d.ts +13 -0
- package/bld/library/atomics/temperature.js +53 -0
- package/bld/library/atomics/temperature.js.map +1 -0
- package/bld/library/command.d.ts +12 -0
- package/bld/library/command.js +21 -0
- package/bld/library/command.js.map +1 -0
- package/bld/library/device/index.d.ts +1 -0
- package/bld/library/device/index.js +2 -0
- package/bld/library/device/index.js.map +1 -0
- package/bld/library/device/sensor.d.ts +8 -0
- package/bld/library/device/sensor.js +2 -0
- package/bld/library/device/sensor.js.map +1 -0
- package/bld/library/device-namespace.d.ts +11 -0
- package/bld/library/device-namespace.js +9 -0
- package/bld/library/device-namespace.js.map +1 -0
- package/bld/library/device.d.ts +23 -0
- package/bld/library/device.js +92 -0
- package/bld/library/device.js.map +1 -0
- package/bld/library/devices/air-conditioner.d.ts +72 -0
- package/bld/library/devices/air-conditioner.js +246 -0
- package/bld/library/devices/air-conditioner.js.map +1 -0
- package/bld/library/devices/dehumidifier.d.ts +62 -0
- package/bld/library/devices/dehumidifier.js +211 -0
- package/bld/library/devices/dehumidifier.js.map +1 -0
- package/bld/library/devices/fan.d.ts +70 -0
- package/bld/library/devices/fan.js +229 -0
- package/bld/library/devices/fan.js.map +1 -0
- package/bld/library/devices/index.d.ts +4 -0
- package/bld/library/devices/index.js +5 -0
- package/bld/library/devices/index.js.map +1 -0
- package/bld/library/devices/light.d.ts +59 -0
- package/bld/library/devices/light.js +197 -0
- package/bld/library/devices/light.js.map +1 -0
- package/bld/library/endpoint.d.ts +100 -0
- package/bld/library/endpoint.js +431 -0
- package/bld/library/endpoint.js.map +1 -0
- package/bld/library/home.d.ts +4 -0
- package/bld/library/home.js +11 -0
- package/bld/library/home.js.map +1 -0
- package/bld/library/index.d.ts +16 -0
- package/bld/library/index.js +17 -0
- package/bld/library/index.js.map +1 -0
- package/bld/library/log.d.ts +43 -0
- package/bld/library/log.js +78 -0
- package/bld/library/log.js.map +1 -0
- package/bld/library/provider.d.ts +26 -0
- package/bld/library/provider.js +18 -0
- package/bld/library/provider.js.map +1 -0
- package/bld/library/registry.d.ts +19 -0
- package/bld/library/registry.js +65 -0
- package/bld/library/registry.js.map +1 -0
- package/bld/library/runtime/@binding-creation.d.ts +4 -0
- package/bld/library/runtime/@binding-creation.js +19 -0
- package/bld/library/runtime/@binding-creation.js.map +1 -0
- package/bld/library/runtime/binding.d.ts +50 -0
- package/bld/library/runtime/binding.js +108 -0
- package/bld/library/runtime/binding.js.map +1 -0
- package/bld/library/runtime/bootstrap-frontend.d.ts +48 -0
- package/bld/library/runtime/bootstrap-frontend.js +96 -0
- package/bld/library/runtime/bootstrap-frontend.js.map +1 -0
- package/bld/library/runtime/bootstrap.d.ts +9 -0
- package/bld/library/runtime/bootstrap.js +165 -0
- package/bld/library/runtime/bootstrap.js.map +1 -0
- package/bld/library/runtime/environment.d.ts +1 -0
- package/bld/library/runtime/environment.js +7 -0
- package/bld/library/runtime/environment.js.map +1 -0
- package/bld/library/runtime/index.d.ts +4 -0
- package/bld/library/runtime/index.js +5 -0
- package/bld/library/runtime/index.js.map +1 -0
- package/bld/library/scope.d.ts +41 -0
- package/bld/library/scope.js +132 -0
- package/bld/library/scope.js.map +1 -0
- package/bld/library/types.d.ts +17 -0
- package/bld/library/types.js +8 -0
- package/bld/library/types.js.map +1 -0
- package/bld/library/utils/backoff.d.ts +10 -0
- package/bld/library/utils/backoff.js +63 -0
- package/bld/library/utils/backoff.js.map +1 -0
- package/bld/library/utils/constructor.d.ts +21 -0
- package/bld/library/utils/constructor.js +30 -0
- package/bld/library/utils/constructor.js.map +1 -0
- package/bld/library/utils/index.d.ts +2 -0
- package/bld/library/utils/index.js +3 -0
- package/bld/library/utils/index.js.map +1 -0
- package/bld/library/x-data-medium.d.ts +12 -0
- package/bld/library/x-data-medium.js +3 -0
- package/bld/library/x-data-medium.js.map +1 -0
- package/package.json +27 -0
- package/src/exports/mobx.ts +1 -0
- package/src/library/@lifecycle.ts +30 -0
- package/src/library/atomics/index.ts +1 -0
- package/src/library/atomics/temperature.ts +60 -0
- package/src/library/command.ts +25 -0
- package/src/library/device/index.ts +1 -0
- package/src/library/device/sensor.ts +10 -0
- package/src/library/device-namespace.ts +21 -0
- package/src/library/device.ts +91 -0
- package/src/library/devices/air-conditioner.ts +234 -0
- package/src/library/devices/dehumidifier.ts +200 -0
- package/src/library/devices/fan.ts +204 -0
- package/src/library/devices/index.ts +4 -0
- package/src/library/devices/light.ts +177 -0
- package/src/library/endpoint.ts +610 -0
- package/src/library/home.ts +11 -0
- package/src/library/index.ts +16 -0
- package/src/library/log.ts +163 -0
- package/src/library/provider.ts +66 -0
- package/src/library/registry.ts +129 -0
- package/src/library/runtime/@binding-creation.ts +48 -0
- package/src/library/runtime/binding.ts +165 -0
- package/src/library/runtime/bootstrap-frontend.ts +243 -0
- package/src/library/runtime/bootstrap.ts +286 -0
- package/src/library/runtime/environment.ts +6 -0
- package/src/library/runtime/index.ts +4 -0
- package/src/library/scope.ts +193 -0
- package/src/library/types/global.d.ts +8 -0
- package/src/library/types.ts +26 -0
- package/src/library/utils/backoff.ts +65 -0
- package/src/library/utils/constructor.ts +89 -0
- package/src/library/utils/index.ts +2 -0
- package/src/library/x-data-medium.ts +16 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { computed } from 'mobx';
|
|
3
|
+
import { StatefulCommand } from '../command.js';
|
|
4
|
+
import { Device } from '../device.js';
|
|
5
|
+
import { Endpoint, } from '../endpoint.js';
|
|
6
|
+
let Fan = (() => {
|
|
7
|
+
var _a;
|
|
8
|
+
let _classSuper = Device;
|
|
9
|
+
let _instanceExtraInitializers = [];
|
|
10
|
+
let _get_on_decorators;
|
|
11
|
+
let _get_mode_decorators;
|
|
12
|
+
let _get_speed_decorators;
|
|
13
|
+
let _get_horizontalSwing_decorators;
|
|
14
|
+
return _a = class Fan extends _classSuper {
|
|
15
|
+
get on() {
|
|
16
|
+
return this.endpoint.on;
|
|
17
|
+
}
|
|
18
|
+
get mode() {
|
|
19
|
+
return this.endpoint.mode;
|
|
20
|
+
}
|
|
21
|
+
/** Fan speed as a normalized ratio from 0 to 1. */
|
|
22
|
+
get speed() {
|
|
23
|
+
return this.endpoint.speed;
|
|
24
|
+
}
|
|
25
|
+
get horizontalSwing() {
|
|
26
|
+
return this.endpoint.horizontalSwing;
|
|
27
|
+
}
|
|
28
|
+
constructor(entry) {
|
|
29
|
+
super(entry);
|
|
30
|
+
Object.defineProperty(this, "endpoint", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: __runInitializers(this, _instanceExtraInitializers)
|
|
35
|
+
});
|
|
36
|
+
this.endpoint = this.getOrCreateEndpoint(FanEndpoint);
|
|
37
|
+
}
|
|
38
|
+
turnOn() {
|
|
39
|
+
this.endpoint.turnOn();
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
turnOff() {
|
|
43
|
+
this.endpoint.turnOff();
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
setMode(value) {
|
|
47
|
+
this.endpoint.setMode(value);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sets fan speed using a normalized ratio from 0 to 1.
|
|
52
|
+
* A value of 0 turns the fan off.
|
|
53
|
+
*/
|
|
54
|
+
setSpeed(value) {
|
|
55
|
+
if (value === 0) {
|
|
56
|
+
return this.turnOff();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.endpoint.setSpeed(value);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
setHorizontalSwing(value) {
|
|
64
|
+
this.endpoint.setHorizontalSwing(value);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
(() => {
|
|
69
|
+
var _b;
|
|
70
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
71
|
+
_get_on_decorators = [computed];
|
|
72
|
+
_get_mode_decorators = [computed];
|
|
73
|
+
_get_speed_decorators = [computed];
|
|
74
|
+
_get_horizontalSwing_decorators = [computed];
|
|
75
|
+
__esDecorate(_a, null, _get_on_decorators, { kind: "getter", name: "on", static: false, private: false, access: { has: obj => "on" in obj, get: obj => obj.on }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
76
|
+
__esDecorate(_a, null, _get_mode_decorators, { kind: "getter", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
77
|
+
__esDecorate(_a, null, _get_speed_decorators, { kind: "getter", name: "speed", static: false, private: false, access: { has: obj => "speed" in obj, get: obj => obj.speed }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
78
|
+
__esDecorate(_a, null, _get_horizontalSwing_decorators, { kind: "getter", name: "horizontalSwing", static: false, private: false, access: { has: obj => "horizontalSwing" in obj, get: obj => obj.horizontalSwing }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
79
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
80
|
+
})(),
|
|
81
|
+
_a;
|
|
82
|
+
})();
|
|
83
|
+
export { Fan };
|
|
84
|
+
let FanEndpoint = (() => {
|
|
85
|
+
var _a;
|
|
86
|
+
let _classSuper = Endpoint;
|
|
87
|
+
let _instanceExtraInitializers = [];
|
|
88
|
+
let _get_on_decorators;
|
|
89
|
+
let _get_mode_decorators;
|
|
90
|
+
let _get_speed_decorators;
|
|
91
|
+
let _get_horizontalSwing_decorators;
|
|
92
|
+
return _a = class FanEndpoint extends _classSuper {
|
|
93
|
+
get on() {
|
|
94
|
+
var _b, _c;
|
|
95
|
+
return (_c = (_b = this.connection) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false;
|
|
96
|
+
}
|
|
97
|
+
get mode() {
|
|
98
|
+
var _b;
|
|
99
|
+
return (_b = this.connection) === null || _b === void 0 ? void 0 : _b.mode;
|
|
100
|
+
}
|
|
101
|
+
/** Fan speed as a normalized ratio from 0 to 1. */
|
|
102
|
+
get speed() {
|
|
103
|
+
var _b;
|
|
104
|
+
return (_b = this.connection) === null || _b === void 0 ? void 0 : _b.speed;
|
|
105
|
+
}
|
|
106
|
+
get horizontalSwing() {
|
|
107
|
+
var _b;
|
|
108
|
+
return (_b = this.connection) === null || _b === void 0 ? void 0 : _b.horizontalSwing;
|
|
109
|
+
}
|
|
110
|
+
get logState() {
|
|
111
|
+
if (!this.ready) {
|
|
112
|
+
return { ready: false };
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
ready: true,
|
|
116
|
+
on: this.on,
|
|
117
|
+
mode: this.mode,
|
|
118
|
+
speed: this.speed,
|
|
119
|
+
horizontalSwing: this.horizontalSwing,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
turnOn() {
|
|
123
|
+
return this.enqueueCommand(new SetFanOnCommand(true));
|
|
124
|
+
}
|
|
125
|
+
turnOff() {
|
|
126
|
+
return this.enqueueCommand(new SetFanOnCommand(false));
|
|
127
|
+
}
|
|
128
|
+
setMode(value) {
|
|
129
|
+
return this.enqueueCommand(new SetFanModeCommand(value));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Sets fan speed using a normalized ratio from 0 to 1.
|
|
133
|
+
* A value of 0 turns the fan off.
|
|
134
|
+
*/
|
|
135
|
+
setSpeed(value) {
|
|
136
|
+
if (value === 0) {
|
|
137
|
+
return this.turnOff();
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return this.enqueueCommand(new SetFanSpeedCommand(value));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
setHorizontalSwing(value) {
|
|
144
|
+
return this.enqueueCommand(new SetFanHorizontalSwingCommand(value));
|
|
145
|
+
}
|
|
146
|
+
constructor() {
|
|
147
|
+
super(...arguments);
|
|
148
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
(() => {
|
|
152
|
+
var _b;
|
|
153
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
154
|
+
_get_on_decorators = [computed];
|
|
155
|
+
_get_mode_decorators = [computed];
|
|
156
|
+
_get_speed_decorators = [computed];
|
|
157
|
+
_get_horizontalSwing_decorators = [computed];
|
|
158
|
+
__esDecorate(_a, null, _get_on_decorators, { kind: "getter", name: "on", static: false, private: false, access: { has: obj => "on" in obj, get: obj => obj.on }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
159
|
+
__esDecorate(_a, null, _get_mode_decorators, { kind: "getter", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
160
|
+
__esDecorate(_a, null, _get_speed_decorators, { kind: "getter", name: "speed", static: false, private: false, access: { has: obj => "speed" in obj, get: obj => obj.speed }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
161
|
+
__esDecorate(_a, null, _get_horizontalSwing_decorators, { kind: "getter", name: "horizontalSwing", static: false, private: false, access: { has: obj => "horizontalSwing" in obj, get: obj => obj.horizontalSwing }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
162
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
163
|
+
})(),
|
|
164
|
+
_a;
|
|
165
|
+
})();
|
|
166
|
+
export { FanEndpoint };
|
|
167
|
+
export class FanCommand extends StatefulCommand {
|
|
168
|
+
}
|
|
169
|
+
export class SetFanOnCommand extends FanCommand {
|
|
170
|
+
constructor(value) {
|
|
171
|
+
super();
|
|
172
|
+
Object.defineProperty(this, "value", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
configurable: true,
|
|
175
|
+
writable: true,
|
|
176
|
+
value: value
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
toLogString() {
|
|
180
|
+
return `set on=${this.value}`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export class SetFanModeCommand extends FanCommand {
|
|
184
|
+
constructor(value) {
|
|
185
|
+
super();
|
|
186
|
+
Object.defineProperty(this, "value", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
configurable: true,
|
|
189
|
+
writable: true,
|
|
190
|
+
value: value
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
toLogString() {
|
|
194
|
+
return `set mode=${this.value}`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export class SetFanSpeedCommand extends FanCommand {
|
|
198
|
+
/** `value` is a normalized fan-speed ratio greater than 0 and at most 1. */
|
|
199
|
+
constructor(value) {
|
|
200
|
+
super();
|
|
201
|
+
Object.defineProperty(this, "value", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
configurable: true,
|
|
204
|
+
writable: true,
|
|
205
|
+
value: value
|
|
206
|
+
});
|
|
207
|
+
if (!Number.isFinite(value) || value <= 0 || value > 1) {
|
|
208
|
+
throw new RangeError('Fan speed must be a finite number greater than 0 and at most 1.');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
toLogString() {
|
|
212
|
+
return `set speed=${this.value}`;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
export class SetFanHorizontalSwingCommand extends FanCommand {
|
|
216
|
+
constructor(value) {
|
|
217
|
+
super();
|
|
218
|
+
Object.defineProperty(this, "value", {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
configurable: true,
|
|
221
|
+
writable: true,
|
|
222
|
+
value: value
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
toLogString() {
|
|
226
|
+
return `set horizontalSwing=${this.value}`;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=fan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fan.js","sourceRoot":"","sources":["../../../src/library/devices/fan.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAmB,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,QAAQ,GAGT,MAAM,gBAAgB,CAAC;IAIX,GAAG;;sBAAS,MAAM;;;;;;sBAAlB,GAAI,SAAQ,WAAM;YAI7B,IAAI,EAAE;gBACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,CAAC;YAGD,IAAI,IAAI;gBACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC5B,CAAC;YAED,mDAAmD;YAEnD,IAAI,KAAK;gBACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC7B,CAAC;YAGD,IAAI,eAAe;gBACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;YACvC,CAAC;YAED,YAAY,KAAkB;gBAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;gBAxBI;;;;2BADR,mDAAG;mBAC2B;gBAyBvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,CA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"file":"index.js","sourceRoot":"","sources":["../../../src/library/devices/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { StatefulCommand } from '../command.js';
|
|
2
|
+
import { Device, type DeviceEntry } from '../device.js';
|
|
3
|
+
import { Endpoint, type EndpointConnection, type EndpointLogState } from '../endpoint.js';
|
|
4
|
+
export declare class Light extends Device {
|
|
5
|
+
protected readonly endpoint: LightEndpoint;
|
|
6
|
+
get on(): boolean;
|
|
7
|
+
/** Brightness as a normalized ratio from 0 to 1. */
|
|
8
|
+
get brightness(): number | undefined;
|
|
9
|
+
get colorTemperature(): number | undefined;
|
|
10
|
+
constructor(entry: DeviceEntry);
|
|
11
|
+
turnOn(): this;
|
|
12
|
+
turnOff(): this;
|
|
13
|
+
/**
|
|
14
|
+
* Sets brightness using a normalized ratio from 0 to 1.
|
|
15
|
+
* A value of 0 turns the light off.
|
|
16
|
+
*/
|
|
17
|
+
setBrightness(value: number): this;
|
|
18
|
+
setColorTemperature(value: number): this;
|
|
19
|
+
}
|
|
20
|
+
export declare class LightEndpoint<TConnection extends LightEndpointConnection = LightEndpointConnection> extends Endpoint<LightEndpointCommand, TConnection> {
|
|
21
|
+
get on(): boolean;
|
|
22
|
+
/** Brightness as a normalized ratio from 0 to 1. */
|
|
23
|
+
get brightness(): number | undefined;
|
|
24
|
+
get colorTemperature(): number | undefined;
|
|
25
|
+
protected get logState(): EndpointLogState;
|
|
26
|
+
turnOn(): this;
|
|
27
|
+
turnOff(): this;
|
|
28
|
+
/**
|
|
29
|
+
* Sets brightness using a normalized ratio from 0 to 1.
|
|
30
|
+
* A value of 0 turns the light off.
|
|
31
|
+
*/
|
|
32
|
+
setBrightness(value: number): this;
|
|
33
|
+
setColorTemperature(value: number): this;
|
|
34
|
+
}
|
|
35
|
+
export type LightEndpointConnection = EndpointConnection<LightEndpointCommand> & {
|
|
36
|
+
readonly on: boolean;
|
|
37
|
+
/** Brightness as a normalized ratio from 0 to 1. */
|
|
38
|
+
readonly brightness: number | undefined;
|
|
39
|
+
readonly colorTemperature: number | undefined;
|
|
40
|
+
};
|
|
41
|
+
export declare abstract class LightCommand extends StatefulCommand {
|
|
42
|
+
}
|
|
43
|
+
export declare class SetLightOnCommand extends LightCommand {
|
|
44
|
+
readonly value: boolean;
|
|
45
|
+
constructor(value: boolean);
|
|
46
|
+
toLogString(): string;
|
|
47
|
+
}
|
|
48
|
+
export declare class SetLightBrightnessCommand extends LightCommand {
|
|
49
|
+
readonly value: number;
|
|
50
|
+
/** `value` is a normalized brightness ratio greater than 0 and at most 1. */
|
|
51
|
+
constructor(value: number);
|
|
52
|
+
toLogString(): string;
|
|
53
|
+
}
|
|
54
|
+
export declare class SetLightColorTemperatureCommand extends LightCommand {
|
|
55
|
+
readonly value: number;
|
|
56
|
+
constructor(value: number);
|
|
57
|
+
toLogString(): string;
|
|
58
|
+
}
|
|
59
|
+
export type LightEndpointCommand = SetLightOnCommand | SetLightBrightnessCommand | SetLightColorTemperatureCommand;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { computed } from 'mobx';
|
|
3
|
+
import { StatefulCommand } from '../command.js';
|
|
4
|
+
import { Device } from '../device.js';
|
|
5
|
+
import { Endpoint, } from '../endpoint.js';
|
|
6
|
+
let Light = (() => {
|
|
7
|
+
var _a;
|
|
8
|
+
let _classSuper = Device;
|
|
9
|
+
let _instanceExtraInitializers = [];
|
|
10
|
+
let _get_on_decorators;
|
|
11
|
+
let _get_brightness_decorators;
|
|
12
|
+
let _get_colorTemperature_decorators;
|
|
13
|
+
return _a = class Light extends _classSuper {
|
|
14
|
+
get on() {
|
|
15
|
+
return this.endpoint.on;
|
|
16
|
+
}
|
|
17
|
+
/** Brightness as a normalized ratio from 0 to 1. */
|
|
18
|
+
get brightness() {
|
|
19
|
+
return this.endpoint.brightness;
|
|
20
|
+
}
|
|
21
|
+
get colorTemperature() {
|
|
22
|
+
return this.endpoint.colorTemperature;
|
|
23
|
+
}
|
|
24
|
+
constructor(entry) {
|
|
25
|
+
super(entry);
|
|
26
|
+
Object.defineProperty(this, "endpoint", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: __runInitializers(this, _instanceExtraInitializers)
|
|
31
|
+
});
|
|
32
|
+
this.endpoint = this.getOrCreateEndpoint(LightEndpoint);
|
|
33
|
+
}
|
|
34
|
+
turnOn() {
|
|
35
|
+
this.endpoint.turnOn();
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
turnOff() {
|
|
39
|
+
this.endpoint.turnOff();
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Sets brightness using a normalized ratio from 0 to 1.
|
|
44
|
+
* A value of 0 turns the light off.
|
|
45
|
+
*/
|
|
46
|
+
setBrightness(value) {
|
|
47
|
+
if (value === 0) {
|
|
48
|
+
return this.turnOff();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.endpoint.setBrightness(value);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
setColorTemperature(value) {
|
|
56
|
+
this.endpoint.setColorTemperature(value);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
(() => {
|
|
61
|
+
var _b;
|
|
62
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
63
|
+
_get_on_decorators = [computed];
|
|
64
|
+
_get_brightness_decorators = [computed];
|
|
65
|
+
_get_colorTemperature_decorators = [computed];
|
|
66
|
+
__esDecorate(_a, null, _get_on_decorators, { kind: "getter", name: "on", static: false, private: false, access: { has: obj => "on" in obj, get: obj => obj.on }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
67
|
+
__esDecorate(_a, null, _get_brightness_decorators, { kind: "getter", name: "brightness", static: false, private: false, access: { has: obj => "brightness" in obj, get: obj => obj.brightness }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
68
|
+
__esDecorate(_a, null, _get_colorTemperature_decorators, { kind: "getter", name: "colorTemperature", static: false, private: false, access: { has: obj => "colorTemperature" in obj, get: obj => obj.colorTemperature }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
69
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
70
|
+
})(),
|
|
71
|
+
_a;
|
|
72
|
+
})();
|
|
73
|
+
export { Light };
|
|
74
|
+
let LightEndpoint = (() => {
|
|
75
|
+
var _a;
|
|
76
|
+
let _classSuper = Endpoint;
|
|
77
|
+
let _instanceExtraInitializers = [];
|
|
78
|
+
let _get_on_decorators;
|
|
79
|
+
let _get_brightness_decorators;
|
|
80
|
+
let _get_colorTemperature_decorators;
|
|
81
|
+
return _a = class LightEndpoint extends _classSuper {
|
|
82
|
+
get on() {
|
|
83
|
+
var _b, _c;
|
|
84
|
+
return (_c = (_b = this.connection) === null || _b === void 0 ? void 0 : _b.on) !== null && _c !== void 0 ? _c : false;
|
|
85
|
+
}
|
|
86
|
+
/** Brightness as a normalized ratio from 0 to 1. */
|
|
87
|
+
get brightness() {
|
|
88
|
+
var _b;
|
|
89
|
+
return (_b = this.connection) === null || _b === void 0 ? void 0 : _b.brightness;
|
|
90
|
+
}
|
|
91
|
+
get colorTemperature() {
|
|
92
|
+
var _b;
|
|
93
|
+
return (_b = this.connection) === null || _b === void 0 ? void 0 : _b.colorTemperature;
|
|
94
|
+
}
|
|
95
|
+
get logState() {
|
|
96
|
+
if (!this.ready) {
|
|
97
|
+
return { ready: false };
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
ready: true,
|
|
101
|
+
on: this.on,
|
|
102
|
+
brightness: this.brightness,
|
|
103
|
+
colorTemperature: this.colorTemperature,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
turnOn() {
|
|
107
|
+
return this.enqueueCommand(new SetLightOnCommand(true));
|
|
108
|
+
}
|
|
109
|
+
turnOff() {
|
|
110
|
+
return this.enqueueCommand(new SetLightOnCommand(false));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Sets brightness using a normalized ratio from 0 to 1.
|
|
114
|
+
* A value of 0 turns the light off.
|
|
115
|
+
*/
|
|
116
|
+
setBrightness(value) {
|
|
117
|
+
if (value === 0) {
|
|
118
|
+
return this.turnOff();
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return this.enqueueCommand(new SetLightBrightnessCommand(value));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
setColorTemperature(value) {
|
|
125
|
+
return this.enqueueCommand(new SetLightColorTemperatureCommand(value));
|
|
126
|
+
}
|
|
127
|
+
constructor() {
|
|
128
|
+
super(...arguments);
|
|
129
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
(() => {
|
|
133
|
+
var _b;
|
|
134
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
|
|
135
|
+
_get_on_decorators = [computed];
|
|
136
|
+
_get_brightness_decorators = [computed];
|
|
137
|
+
_get_colorTemperature_decorators = [computed];
|
|
138
|
+
__esDecorate(_a, null, _get_on_decorators, { kind: "getter", name: "on", static: false, private: false, access: { has: obj => "on" in obj, get: obj => obj.on }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
139
|
+
__esDecorate(_a, null, _get_brightness_decorators, { kind: "getter", name: "brightness", static: false, private: false, access: { has: obj => "brightness" in obj, get: obj => obj.brightness }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
140
|
+
__esDecorate(_a, null, _get_colorTemperature_decorators, { kind: "getter", name: "colorTemperature", static: false, private: false, access: { has: obj => "colorTemperature" in obj, get: obj => obj.colorTemperature }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
141
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
142
|
+
})(),
|
|
143
|
+
_a;
|
|
144
|
+
})();
|
|
145
|
+
export { LightEndpoint };
|
|
146
|
+
export class LightCommand extends StatefulCommand {
|
|
147
|
+
}
|
|
148
|
+
export class SetLightOnCommand extends LightCommand {
|
|
149
|
+
constructor(value) {
|
|
150
|
+
super();
|
|
151
|
+
Object.defineProperty(this, "value", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
configurable: true,
|
|
154
|
+
writable: true,
|
|
155
|
+
value: value
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
toLogString() {
|
|
159
|
+
return `set on=${this.value}`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export class SetLightBrightnessCommand extends LightCommand {
|
|
163
|
+
/** `value` is a normalized brightness ratio greater than 0 and at most 1. */
|
|
164
|
+
constructor(value) {
|
|
165
|
+
super();
|
|
166
|
+
Object.defineProperty(this, "value", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
configurable: true,
|
|
169
|
+
writable: true,
|
|
170
|
+
value: value
|
|
171
|
+
});
|
|
172
|
+
if (!Number.isFinite(value) || value <= 0 || value > 1) {
|
|
173
|
+
throw new RangeError('Brightness must be a finite number greater than 0 and at most 1.');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
toLogString() {
|
|
177
|
+
return `set brightness=${this.value}`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export class SetLightColorTemperatureCommand extends LightCommand {
|
|
181
|
+
constructor(value) {
|
|
182
|
+
super();
|
|
183
|
+
Object.defineProperty(this, "value", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
configurable: true,
|
|
186
|
+
writable: true,
|
|
187
|
+
value: value
|
|
188
|
+
});
|
|
189
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
190
|
+
throw new RangeError('Color temperature must be a finite number greater than 0.');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
toLogString() {
|
|
194
|
+
return `set colorTemperature=${this.value}`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=light.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.js","sourceRoot":"","sources":["../../../src/library/devices/light.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAmB,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,QAAQ,GAGT,MAAM,gBAAgB,CAAC;IAEX,KAAK;;sBAAS,MAAM;;;;;sBAApB,KAAM,SAAQ,WAAM;YAI/B,IAAI,EAAE;gBACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,CAAC;YAED,oDAAoD;YAEpD,IAAI,UAAU;gBACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAClC,CAAC;YAGD,IAAI,gBAAgB;gBAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YACxC,CAAC;YAED,YAAY,KAAkB;gBAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;gBAnBI;;;;2BADR,mDAAK;mBAC2B;gBAoBzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;YAC1D,CAAC;YAED,MAAM;gBACJ,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO;gBACL,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CA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AI,KAAK,GAAG,CAAC,EAAE,CAAC;YACvD,MAAM,IAAI,UAAU,CAClB,kEAAkE,CACnE,CAAC;QACJ,CAAC;IACH,CAAC;IAEQ,WAAW;QAClB,OAAO,kBAAkB,IAAI,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;CACF;AAED,MAAM,OAAO,+BAAgC,SAAQ,YAAY;IAC/D,YAAqB,KAAa;QAChC,KAAK,EAAE,CAAC;QADE;;;;mBAAS,KAAK;WAAQ;QAGhC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,UAAU,CAClB,2DAA2D,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;IAEQ,WAAW;QAClB,OAAO,wBAAwB,IAAI,CAAC,KAAK,EAAE,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type Command } from './command.js';
|
|
2
|
+
export declare abstract class Endpoint<TCommand extends Command, TConnection extends EndpointConnection<TCommand> = EndpointConnection<TCommand>> {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
private accessor connection_;
|
|
5
|
+
private pendingCommands;
|
|
6
|
+
private processingCommands;
|
|
7
|
+
private readonly connectionErrorBackoff;
|
|
8
|
+
private connectionReactionDisposer;
|
|
9
|
+
private logStateReactionDisposer;
|
|
10
|
+
private acknowledgedCommands;
|
|
11
|
+
private commandsWithUncertainEffects;
|
|
12
|
+
private connectionStateGeneration;
|
|
13
|
+
constructor(name?: string);
|
|
14
|
+
get ready(): boolean;
|
|
15
|
+
protected get connection(): TConnection | undefined;
|
|
16
|
+
protected get logState(): EndpointLogState;
|
|
17
|
+
bindConnection(connection: TConnection | undefined): void;
|
|
18
|
+
unbindConnection(connection: TConnection): void;
|
|
19
|
+
enqueueCommand(command: TCommand): this;
|
|
20
|
+
private processPendingCommands;
|
|
21
|
+
private isStatefulCommandSatisfied;
|
|
22
|
+
private acknowledgeCommand;
|
|
23
|
+
private removeAcknowledgedCommandsSupersededBy;
|
|
24
|
+
private removeUncertainEffectsSupersededBy;
|
|
25
|
+
private markCommandEffectUncertain;
|
|
26
|
+
private removeAcknowledgedCommand;
|
|
27
|
+
private reconcileCommandEffects;
|
|
28
|
+
private removeUncertainCommandEffect;
|
|
29
|
+
private commandEffectMatches;
|
|
30
|
+
private isCurrentConnectionState;
|
|
31
|
+
private clearCommandEffectState;
|
|
32
|
+
}
|
|
33
|
+
export type EndpointConnectionMetadata = {};
|
|
34
|
+
export type EndpointLogState = Readonly<Record<string, string | number | boolean | undefined>>;
|
|
35
|
+
export type EndpointReference = {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly ready: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type CommandEffect = {
|
|
40
|
+
/**
|
|
41
|
+
* Revision of the observations relevant to the result of {@link matches}.
|
|
42
|
+
*
|
|
43
|
+
* It must increase only after every value relevant to {@link matches} has
|
|
44
|
+
* been observed since its previous revision, including observations equal to
|
|
45
|
+
* the previous values. It must remain unchanged for partial or unrelated
|
|
46
|
+
* updates. Every change must accompany a change to the owning connection's
|
|
47
|
+
* `stateRevision`; equality deliberately ignores this lifecycle value.
|
|
48
|
+
*/
|
|
49
|
+
readonly observationRevision: number;
|
|
50
|
+
/**
|
|
51
|
+
* Whether this and `effect` describe the same desired state.
|
|
52
|
+
*
|
|
53
|
+
* Core only compares effects for stateful commands in the same effect slot,
|
|
54
|
+
* as determined by `StatefulCommand.supersedes`, and from the same bound
|
|
55
|
+
* endpoint connection lifecycle.
|
|
56
|
+
*/
|
|
57
|
+
equals(effect: CommandEffect): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the endpoint's latest complete state already reflects this effect.
|
|
60
|
+
*
|
|
61
|
+
* Core only calls this with the endpoint that owns the effect while its
|
|
62
|
+
* current connection is ready. Implementations need not repeat connection
|
|
63
|
+
* readiness or endpoint ownership checks.
|
|
64
|
+
*/
|
|
65
|
+
matches(endpoint: EndpointReference): boolean;
|
|
66
|
+
};
|
|
67
|
+
export type CommandExecution = {
|
|
68
|
+
/** The desired state effect, available before execution for noop detection. */
|
|
69
|
+
readonly effect?: CommandEffect;
|
|
70
|
+
/** Starts the externally observable command execution. */
|
|
71
|
+
readonly execute: () => PromiseLike<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Describes the prepared execution, reflecting any normalization the
|
|
74
|
+
* connection applied. Core prefers it over the command description when
|
|
75
|
+
* logging command actions.
|
|
76
|
+
*/
|
|
77
|
+
readonly toLogString?: () => string;
|
|
78
|
+
};
|
|
79
|
+
export type EndpointConnection<in TCommand extends Command> = {
|
|
80
|
+
readonly ready: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Monotonically increases after every complete or incremental state update,
|
|
83
|
+
* including updates whose values equal the previously observed state.
|
|
84
|
+
*/
|
|
85
|
+
readonly stateRevision: number;
|
|
86
|
+
/**
|
|
87
|
+
* Validates and prepares an inert execution plan. External execution must not
|
|
88
|
+
* begin until the returned `execute()` function is called.
|
|
89
|
+
*/
|
|
90
|
+
readonly prepareCommand: (command: TCommand) => CommandExecution;
|
|
91
|
+
readonly toLogString?: () => string;
|
|
92
|
+
};
|
|
93
|
+
export type EndpointConnectionBinding = {
|
|
94
|
+
bind(): void;
|
|
95
|
+
dispose(): PromiseLike<void>;
|
|
96
|
+
};
|
|
97
|
+
export declare function createEndpointConnectionBinding<TCommand extends Command, TConnection extends EndpointConnection<TCommand>>(endpoint: Endpoint<TCommand, TConnection>, connection: TConnection, disposeConnection?: () => void | PromiseLike<void>): EndpointConnectionBinding;
|
|
98
|
+
export declare class EndpointConnectionError extends Error {
|
|
99
|
+
constructor(message: string);
|
|
100
|
+
}
|