@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.
Files changed (132) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +7 -0
  3. package/bld/exports/mobx.d.ts +1 -0
  4. package/bld/exports/mobx.js +2 -0
  5. package/bld/exports/mobx.js.map +1 -0
  6. package/bld/library/@lifecycle.d.ts +4 -0
  7. package/bld/library/@lifecycle.js +23 -0
  8. package/bld/library/@lifecycle.js.map +1 -0
  9. package/bld/library/atomics/index.d.ts +1 -0
  10. package/bld/library/atomics/index.js +2 -0
  11. package/bld/library/atomics/index.js.map +1 -0
  12. package/bld/library/atomics/temperature.d.ts +13 -0
  13. package/bld/library/atomics/temperature.js +53 -0
  14. package/bld/library/atomics/temperature.js.map +1 -0
  15. package/bld/library/command.d.ts +12 -0
  16. package/bld/library/command.js +21 -0
  17. package/bld/library/command.js.map +1 -0
  18. package/bld/library/device/index.d.ts +1 -0
  19. package/bld/library/device/index.js +2 -0
  20. package/bld/library/device/index.js.map +1 -0
  21. package/bld/library/device/sensor.d.ts +8 -0
  22. package/bld/library/device/sensor.js +2 -0
  23. package/bld/library/device/sensor.js.map +1 -0
  24. package/bld/library/device-namespace.d.ts +11 -0
  25. package/bld/library/device-namespace.js +9 -0
  26. package/bld/library/device-namespace.js.map +1 -0
  27. package/bld/library/device.d.ts +23 -0
  28. package/bld/library/device.js +92 -0
  29. package/bld/library/device.js.map +1 -0
  30. package/bld/library/devices/air-conditioner.d.ts +72 -0
  31. package/bld/library/devices/air-conditioner.js +246 -0
  32. package/bld/library/devices/air-conditioner.js.map +1 -0
  33. package/bld/library/devices/dehumidifier.d.ts +62 -0
  34. package/bld/library/devices/dehumidifier.js +211 -0
  35. package/bld/library/devices/dehumidifier.js.map +1 -0
  36. package/bld/library/devices/fan.d.ts +70 -0
  37. package/bld/library/devices/fan.js +229 -0
  38. package/bld/library/devices/fan.js.map +1 -0
  39. package/bld/library/devices/index.d.ts +4 -0
  40. package/bld/library/devices/index.js +5 -0
  41. package/bld/library/devices/index.js.map +1 -0
  42. package/bld/library/devices/light.d.ts +59 -0
  43. package/bld/library/devices/light.js +197 -0
  44. package/bld/library/devices/light.js.map +1 -0
  45. package/bld/library/endpoint.d.ts +100 -0
  46. package/bld/library/endpoint.js +431 -0
  47. package/bld/library/endpoint.js.map +1 -0
  48. package/bld/library/home.d.ts +4 -0
  49. package/bld/library/home.js +11 -0
  50. package/bld/library/home.js.map +1 -0
  51. package/bld/library/index.d.ts +16 -0
  52. package/bld/library/index.js +17 -0
  53. package/bld/library/index.js.map +1 -0
  54. package/bld/library/log.d.ts +43 -0
  55. package/bld/library/log.js +78 -0
  56. package/bld/library/log.js.map +1 -0
  57. package/bld/library/provider.d.ts +26 -0
  58. package/bld/library/provider.js +18 -0
  59. package/bld/library/provider.js.map +1 -0
  60. package/bld/library/registry.d.ts +19 -0
  61. package/bld/library/registry.js +65 -0
  62. package/bld/library/registry.js.map +1 -0
  63. package/bld/library/runtime/@binding-creation.d.ts +4 -0
  64. package/bld/library/runtime/@binding-creation.js +19 -0
  65. package/bld/library/runtime/@binding-creation.js.map +1 -0
  66. package/bld/library/runtime/binding.d.ts +50 -0
  67. package/bld/library/runtime/binding.js +108 -0
  68. package/bld/library/runtime/binding.js.map +1 -0
  69. package/bld/library/runtime/bootstrap-frontend.d.ts +48 -0
  70. package/bld/library/runtime/bootstrap-frontend.js +96 -0
  71. package/bld/library/runtime/bootstrap-frontend.js.map +1 -0
  72. package/bld/library/runtime/bootstrap.d.ts +9 -0
  73. package/bld/library/runtime/bootstrap.js +165 -0
  74. package/bld/library/runtime/bootstrap.js.map +1 -0
  75. package/bld/library/runtime/environment.d.ts +1 -0
  76. package/bld/library/runtime/environment.js +7 -0
  77. package/bld/library/runtime/environment.js.map +1 -0
  78. package/bld/library/runtime/index.d.ts +4 -0
  79. package/bld/library/runtime/index.js +5 -0
  80. package/bld/library/runtime/index.js.map +1 -0
  81. package/bld/library/scope.d.ts +41 -0
  82. package/bld/library/scope.js +132 -0
  83. package/bld/library/scope.js.map +1 -0
  84. package/bld/library/types.d.ts +17 -0
  85. package/bld/library/types.js +8 -0
  86. package/bld/library/types.js.map +1 -0
  87. package/bld/library/utils/backoff.d.ts +10 -0
  88. package/bld/library/utils/backoff.js +63 -0
  89. package/bld/library/utils/backoff.js.map +1 -0
  90. package/bld/library/utils/constructor.d.ts +21 -0
  91. package/bld/library/utils/constructor.js +30 -0
  92. package/bld/library/utils/constructor.js.map +1 -0
  93. package/bld/library/utils/index.d.ts +2 -0
  94. package/bld/library/utils/index.js +3 -0
  95. package/bld/library/utils/index.js.map +1 -0
  96. package/bld/library/x-data-medium.d.ts +12 -0
  97. package/bld/library/x-data-medium.js +3 -0
  98. package/bld/library/x-data-medium.js.map +1 -0
  99. package/package.json +27 -0
  100. package/src/exports/mobx.ts +1 -0
  101. package/src/library/@lifecycle.ts +30 -0
  102. package/src/library/atomics/index.ts +1 -0
  103. package/src/library/atomics/temperature.ts +60 -0
  104. package/src/library/command.ts +25 -0
  105. package/src/library/device/index.ts +1 -0
  106. package/src/library/device/sensor.ts +10 -0
  107. package/src/library/device-namespace.ts +21 -0
  108. package/src/library/device.ts +91 -0
  109. package/src/library/devices/air-conditioner.ts +234 -0
  110. package/src/library/devices/dehumidifier.ts +200 -0
  111. package/src/library/devices/fan.ts +204 -0
  112. package/src/library/devices/index.ts +4 -0
  113. package/src/library/devices/light.ts +177 -0
  114. package/src/library/endpoint.ts +610 -0
  115. package/src/library/home.ts +11 -0
  116. package/src/library/index.ts +16 -0
  117. package/src/library/log.ts +163 -0
  118. package/src/library/provider.ts +66 -0
  119. package/src/library/registry.ts +129 -0
  120. package/src/library/runtime/@binding-creation.ts +48 -0
  121. package/src/library/runtime/binding.ts +165 -0
  122. package/src/library/runtime/bootstrap-frontend.ts +243 -0
  123. package/src/library/runtime/bootstrap.ts +286 -0
  124. package/src/library/runtime/environment.ts +6 -0
  125. package/src/library/runtime/index.ts +4 -0
  126. package/src/library/scope.ts +193 -0
  127. package/src/library/types/global.d.ts +8 -0
  128. package/src/library/types.ts +26 -0
  129. package/src/library/utils/backoff.ts +65 -0
  130. package/src/library/utils/constructor.ts +89 -0
  131. package/src/library/utils/index.ts +2 -0
  132. package/src/library/x-data-medium.ts +16 -0
@@ -0,0 +1,431 @@
1
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate, __runInitializers } from "tslib";
2
+ import { action, comparer, computed, observable, reaction } from 'mobx';
3
+ import { CommandError, StatefulCommand } from './command.js';
4
+ import { hasEndpointLogTarget, logEndpointCommand, logEndpointError, logEndpointState, } from './log.js';
5
+ import { ExponentialBackoff } from './utils/index.js';
6
+ let Endpoint = (() => {
7
+ var _a, _Endpoint_connection__accessor_storage;
8
+ var _b;
9
+ let _instanceExtraInitializers = [];
10
+ let _connection__decorators;
11
+ let _connection__initializers = [];
12
+ let _connection__extraInitializers = [];
13
+ let _get_ready_decorators;
14
+ let _bindConnection_decorators;
15
+ let _unbindConnection_decorators;
16
+ return _a = class Endpoint {
17
+ get connection_() { return __classPrivateFieldGet(this, _Endpoint_connection__accessor_storage, "f"); }
18
+ set connection_(value) { __classPrivateFieldSet(this, _Endpoint_connection__accessor_storage, value, "f"); }
19
+ constructor(name = '') {
20
+ Object.defineProperty(this, "name", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: (__runInitializers(this, _instanceExtraInitializers), name)
25
+ });
26
+ _Endpoint_connection__accessor_storage.set(this, __runInitializers(this, _connection__initializers, void 0));
27
+ Object.defineProperty(this, "pendingCommands", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: (__runInitializers(this, _connection__extraInitializers), [])
32
+ });
33
+ Object.defineProperty(this, "processingCommands", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: false
38
+ });
39
+ Object.defineProperty(this, "connectionErrorBackoff", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: new ExponentialBackoff(100, 10000)
44
+ });
45
+ Object.defineProperty(this, "connectionReactionDisposer", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: void 0
50
+ });
51
+ Object.defineProperty(this, "logStateReactionDisposer", {
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true,
55
+ value: void 0
56
+ });
57
+ Object.defineProperty(this, "acknowledgedCommands", {
58
+ enumerable: true,
59
+ configurable: true,
60
+ writable: true,
61
+ value: []
62
+ });
63
+ Object.defineProperty(this, "commandsWithUncertainEffects", {
64
+ enumerable: true,
65
+ configurable: true,
66
+ writable: true,
67
+ value: []
68
+ });
69
+ Object.defineProperty(this, "connectionStateGeneration", {
70
+ enumerable: true,
71
+ configurable: true,
72
+ writable: true,
73
+ value: 0
74
+ });
75
+ }
76
+ get ready() {
77
+ var _b, _c;
78
+ return (_c = (_b = this.connection) === null || _b === void 0 ? void 0 : _b.ready) !== null && _c !== void 0 ? _c : false;
79
+ }
80
+ get connection() {
81
+ return this.connection_;
82
+ }
83
+ get logState() {
84
+ return { ready: this.ready };
85
+ }
86
+ bindConnection(connection) {
87
+ var _b, _c;
88
+ if (this.connection_ === connection) {
89
+ return;
90
+ }
91
+ (_b = this.connectionReactionDisposer) === null || _b === void 0 ? void 0 : _b.call(this);
92
+ (_c = this.logStateReactionDisposer) === null || _c === void 0 ? void 0 : _c.call(this);
93
+ this.clearCommandEffectState();
94
+ this.connection_ = connection;
95
+ this.connectionStateGeneration++;
96
+ this.connectionErrorBackoff.reset();
97
+ this.logStateReactionDisposer =
98
+ connection !== undefined && hasEndpointLogTarget(this)
99
+ ? reaction(() => this.logState, (state, previousState) => {
100
+ logEndpointState(this, connection, state, previousState);
101
+ }, { equals: comparer.structural, fireImmediately: true })
102
+ : undefined;
103
+ this.connectionReactionDisposer = connection
104
+ ? reaction(() => ({
105
+ ready: connection.ready,
106
+ stateRevision: connection.stateRevision,
107
+ }), (state, previousState) => {
108
+ const { ready } = state;
109
+ if (ready) {
110
+ if (previousState !== undefined &&
111
+ state.stateRevision !== previousState.stateRevision) {
112
+ this.reconcileCommandEffects();
113
+ }
114
+ void this.processPendingCommands().catch(logEndpointError);
115
+ }
116
+ else {
117
+ this.connectionStateGeneration++;
118
+ this.clearCommandEffectState();
119
+ }
120
+ }, { equals: comparer.structural, fireImmediately: true })
121
+ : undefined;
122
+ }
123
+ unbindConnection(connection) {
124
+ if (this.connection_ === connection) {
125
+ this.bindConnection(undefined);
126
+ }
127
+ }
128
+ enqueueCommand(command) {
129
+ this.pendingCommands = this.pendingCommands.filter(pendingCommand => !command.supersedes(pendingCommand));
130
+ this.pendingCommands.push(command);
131
+ void this.processPendingCommands().catch(logEndpointError);
132
+ return this;
133
+ }
134
+ async processPendingCommands() {
135
+ var _b;
136
+ if (this.processingCommands) {
137
+ return;
138
+ }
139
+ this.processingCommands = true;
140
+ try {
141
+ while (this.connection &&
142
+ this.connection.ready &&
143
+ this.pendingCommands.length > 0) {
144
+ const command = this.pendingCommands[0];
145
+ const connection = this.connection;
146
+ let executionStarted = false;
147
+ let executionEffect;
148
+ let executionEffectObservationRevision;
149
+ let executionStateGeneration;
150
+ try {
151
+ const execution = connection.prepareCommand(command);
152
+ executionEffect = execution.effect;
153
+ if (this.isStatefulCommandSatisfied(command, execution.effect)) {
154
+ logEndpointCommand(this, connection, command, 'skip', execution);
155
+ consumeCommand(this.pendingCommands, command);
156
+ this.connectionErrorBackoff.reset();
157
+ continue;
158
+ }
159
+ executionEffectObservationRevision =
160
+ (_b = execution.effect) === null || _b === void 0 ? void 0 : _b.observationRevision;
161
+ executionStateGeneration = this.connectionStateGeneration;
162
+ logEndpointCommand(this, connection, command, 'execute', execution);
163
+ executionStarted = true;
164
+ await execution.execute();
165
+ if (command instanceof StatefulCommand) {
166
+ this.removeAcknowledgedCommandsSupersededBy(command);
167
+ this.removeUncertainEffectsSupersededBy(command);
168
+ }
169
+ if (command instanceof StatefulCommand &&
170
+ execution.effect !== undefined &&
171
+ this.connection === connection &&
172
+ connection.ready) {
173
+ this.acknowledgeCommand(command, execution.effect, connection, executionEffectObservationRevision, executionStateGeneration);
174
+ }
175
+ else if (command instanceof StatefulCommand &&
176
+ execution.effect === undefined) {
177
+ this.markCommandEffectUncertain(command, undefined, connection, undefined, executionStateGeneration);
178
+ }
179
+ }
180
+ catch (error) {
181
+ if (error instanceof EndpointConnectionError) {
182
+ await this.connectionErrorBackoff;
183
+ continue;
184
+ }
185
+ if (executionStarted &&
186
+ command instanceof StatefulCommand &&
187
+ !(error instanceof CommandError)) {
188
+ this.removeAcknowledgedCommandsSupersededBy(command);
189
+ this.removeUncertainEffectsSupersededBy(command);
190
+ this.markCommandEffectUncertain(command, executionEffect, connection, executionEffectObservationRevision, executionStateGeneration);
191
+ }
192
+ logEndpointError(error);
193
+ }
194
+ consumeCommand(this.pendingCommands, command);
195
+ this.connectionErrorBackoff.reset();
196
+ }
197
+ }
198
+ finally {
199
+ this.processingCommands = false;
200
+ }
201
+ function consumeCommand(pendingCommands, command) {
202
+ if (pendingCommands.length > 0 && pendingCommands[0] === command) {
203
+ pendingCommands.shift();
204
+ }
205
+ }
206
+ }
207
+ isStatefulCommandSatisfied(command, preparedEffect) {
208
+ if (!(command instanceof StatefulCommand) || preparedEffect === undefined) {
209
+ return false;
210
+ }
211
+ if (this.commandsWithUncertainEffects.some(uncertainEffect => command.supersedes(uncertainEffect.command))) {
212
+ return false;
213
+ }
214
+ let supersededAcknowledgedCommand = false;
215
+ for (const acknowledgedCommand of this.acknowledgedCommands) {
216
+ if (command.supersedes(acknowledgedCommand.command)) {
217
+ supersededAcknowledgedCommand = true;
218
+ if (acknowledgedCommand.effect.equals(preparedEffect)) {
219
+ return true;
220
+ }
221
+ }
222
+ }
223
+ if (supersededAcknowledgedCommand) {
224
+ return false;
225
+ }
226
+ return this.commandEffectMatches(preparedEffect);
227
+ }
228
+ acknowledgeCommand(command, effect, connection, observationRevision, connectionStateGeneration) {
229
+ if (observationRevision === undefined ||
230
+ connectionStateGeneration === undefined ||
231
+ !this.isCurrentConnectionState(connection, connectionStateGeneration)) {
232
+ return;
233
+ }
234
+ const currentObservationRevision = effect.observationRevision;
235
+ if (currentObservationRevision !== observationRevision) {
236
+ if (this.commandEffectMatches(effect)) {
237
+ this.acknowledgedCommands.push({
238
+ command,
239
+ effect,
240
+ observationRevision: currentObservationRevision,
241
+ });
242
+ }
243
+ else {
244
+ this.commandsWithUncertainEffects.push({
245
+ command,
246
+ effect,
247
+ observationRevision: currentObservationRevision,
248
+ });
249
+ }
250
+ return;
251
+ }
252
+ this.acknowledgedCommands.push({
253
+ command,
254
+ effect,
255
+ observationRevision: currentObservationRevision,
256
+ });
257
+ }
258
+ removeAcknowledgedCommandsSupersededBy(command) {
259
+ for (const acknowledgedCommand of [...this.acknowledgedCommands]) {
260
+ if (command.supersedes(acknowledgedCommand.command)) {
261
+ this.removeAcknowledgedCommand(acknowledgedCommand);
262
+ }
263
+ }
264
+ }
265
+ removeUncertainEffectsSupersededBy(command) {
266
+ this.commandsWithUncertainEffects =
267
+ this.commandsWithUncertainEffects.filter(uncertainEffect => !command.supersedes(uncertainEffect.command));
268
+ }
269
+ markCommandEffectUncertain(command, effect, connection, observationRevision, connectionStateGeneration) {
270
+ if (connectionStateGeneration === undefined ||
271
+ !this.isCurrentConnectionState(connection, connectionStateGeneration)) {
272
+ return;
273
+ }
274
+ if (effect === undefined) {
275
+ this.commandsWithUncertainEffects.push({ command, effect });
276
+ return;
277
+ }
278
+ if (observationRevision === undefined) {
279
+ return;
280
+ }
281
+ const currentObservationRevision = effect.observationRevision;
282
+ if (currentObservationRevision !== observationRevision) {
283
+ if (this.commandEffectMatches(effect)) {
284
+ this.acknowledgedCommands.push({
285
+ command,
286
+ effect,
287
+ observationRevision: currentObservationRevision,
288
+ });
289
+ }
290
+ else {
291
+ this.commandsWithUncertainEffects.push({
292
+ command,
293
+ effect,
294
+ observationRevision: currentObservationRevision,
295
+ });
296
+ }
297
+ return;
298
+ }
299
+ this.commandsWithUncertainEffects.push({
300
+ command,
301
+ effect,
302
+ observationRevision,
303
+ });
304
+ }
305
+ removeAcknowledgedCommand(acknowledgedCommand) {
306
+ const index = this.acknowledgedCommands.indexOf(acknowledgedCommand);
307
+ if (index === -1) {
308
+ return;
309
+ }
310
+ this.acknowledgedCommands.splice(index, 1);
311
+ }
312
+ reconcileCommandEffects() {
313
+ for (const acknowledgedCommand of [...this.acknowledgedCommands]) {
314
+ const observationRevision = acknowledgedCommand.effect.observationRevision;
315
+ if (observationRevision === acknowledgedCommand.observationRevision) {
316
+ continue;
317
+ }
318
+ if (this.commandEffectMatches(acknowledgedCommand.effect)) {
319
+ acknowledgedCommand.observationRevision = observationRevision;
320
+ }
321
+ else {
322
+ this.removeAcknowledgedCommand(acknowledgedCommand);
323
+ }
324
+ }
325
+ for (const uncertainEffect of [...this.commandsWithUncertainEffects]) {
326
+ if (uncertainEffect.effect === undefined ||
327
+ uncertainEffect.observationRevision === undefined) {
328
+ continue;
329
+ }
330
+ const observationRevision = uncertainEffect.effect.observationRevision;
331
+ if (observationRevision === uncertainEffect.observationRevision) {
332
+ continue;
333
+ }
334
+ this.removeUncertainCommandEffect(uncertainEffect);
335
+ if (this.commandEffectMatches(uncertainEffect.effect)) {
336
+ this.acknowledgedCommands.push({
337
+ command: uncertainEffect.command,
338
+ effect: uncertainEffect.effect,
339
+ observationRevision,
340
+ });
341
+ }
342
+ }
343
+ }
344
+ removeUncertainCommandEffect(uncertainEffect) {
345
+ const index = this.commandsWithUncertainEffects.indexOf(uncertainEffect);
346
+ if (index !== -1) {
347
+ this.commandsWithUncertainEffects.splice(index, 1);
348
+ }
349
+ }
350
+ commandEffectMatches(effect) {
351
+ try {
352
+ return effect.matches(this);
353
+ }
354
+ catch (error) {
355
+ logEndpointError(error);
356
+ return false;
357
+ }
358
+ }
359
+ isCurrentConnectionState(connection, connectionStateGeneration) {
360
+ return (this.connection === connection &&
361
+ connection.ready &&
362
+ this.connectionStateGeneration === connectionStateGeneration);
363
+ }
364
+ clearCommandEffectState() {
365
+ this.acknowledgedCommands = [];
366
+ this.commandsWithUncertainEffects = [];
367
+ }
368
+ },
369
+ _Endpoint_connection__accessor_storage = new WeakMap(),
370
+ (() => {
371
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
372
+ _connection__decorators = [(_b = observable).ref.bind(_b)];
373
+ _get_ready_decorators = [computed];
374
+ _bindConnection_decorators = [action];
375
+ _unbindConnection_decorators = [action];
376
+ __esDecorate(_a, null, _connection__decorators, { kind: "accessor", name: "connection_", static: false, private: false, access: { has: obj => "connection_" in obj, get: obj => obj.connection_, set: (obj, value) => { obj.connection_ = value; } }, metadata: _metadata }, _connection__initializers, _connection__extraInitializers);
377
+ __esDecorate(_a, null, _get_ready_decorators, { kind: "getter", name: "ready", static: false, private: false, access: { has: obj => "ready" in obj, get: obj => obj.ready }, metadata: _metadata }, null, _instanceExtraInitializers);
378
+ __esDecorate(_a, null, _bindConnection_decorators, { kind: "method", name: "bindConnection", static: false, private: false, access: { has: obj => "bindConnection" in obj, get: obj => obj.bindConnection }, metadata: _metadata }, null, _instanceExtraInitializers);
379
+ __esDecorate(_a, null, _unbindConnection_decorators, { kind: "method", name: "unbindConnection", static: false, private: false, access: { has: obj => "unbindConnection" in obj, get: obj => obj.unbindConnection }, metadata: _metadata }, null, _instanceExtraInitializers);
380
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
381
+ })(),
382
+ _a;
383
+ })();
384
+ export { Endpoint };
385
+ export function createEndpointConnectionBinding(endpoint, connection, disposeConnection = () => undefined) {
386
+ let bound = false;
387
+ let disposePromise;
388
+ return {
389
+ bind() {
390
+ if (disposePromise !== undefined) {
391
+ throw new Error('Cannot bind a disposed endpoint connection.');
392
+ }
393
+ bound = true;
394
+ endpoint.bindConnection(connection);
395
+ },
396
+ dispose() {
397
+ disposePromise !== null && disposePromise !== void 0 ? disposePromise : (disposePromise = (async () => {
398
+ const errors = [];
399
+ if (bound) {
400
+ bound = false;
401
+ try {
402
+ endpoint.unbindConnection(connection);
403
+ }
404
+ catch (error) {
405
+ errors.push(error);
406
+ }
407
+ }
408
+ try {
409
+ await disposeConnection();
410
+ }
411
+ catch (error) {
412
+ errors.push(error);
413
+ }
414
+ if (errors.length === 1) {
415
+ throw errors[0];
416
+ }
417
+ else if (errors.length > 1) {
418
+ throw new AggregateError(errors, 'Failed to dispose endpoint connection binding.');
419
+ }
420
+ })());
421
+ return disposePromise;
422
+ },
423
+ };
424
+ }
425
+ export class EndpointConnectionError extends Error {
426
+ constructor(message) {
427
+ super(message);
428
+ this.name = new.target.name;
429
+ }
430
+ }
431
+ //# sourceMappingURL=endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/library/endpoint.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,MAAM,CAAC;AAEtE,OAAO,EAAe,YAAY,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;IAE9B,QAAQ;;;;;;;;;;sBAAR,QAAQ;YAKZ,IAAiB,WAAW,wFAA0B;YAAtD,IAAiB,WAAW,6FAA0B;YAkBtE,YAAqB,OAAO,EAAE;gBAAlB;;;;4BAvBQ,mDAAQ,EAuBP,IAAI;mBAAK;gBAlBG,6GAAqC;gBAE9D;;;;qFAA8B,EAAE;mBAAC;gBAEjC;;;;2BAAqB,KAAK;mBAAC;gBAElB;;;;2BAAyB,IAAI,kBAAkB,CAAC,GAAG,EAAE,KAAM,CAAC;mBAAC;gBAEtE;;;;;mBAAqD;gBAErD;;;;;mBA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AM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { Scope } from './scope.js';
2
+ export declare class Home extends Scope {
3
+ }
4
+ export declare const $home: import("./utils/constructor.js").ExtendedConstructorWithNameParameter<[parent?: Scope | undefined], Home>;
@@ -0,0 +1,11 @@
1
+ import { registerRootScope } from './registry.js';
2
+ import { Scope } from './scope.js';
3
+ import { $constructor, uniqueName } from './utils/index.js';
4
+ export class Home extends Scope {
5
+ }
6
+ export const $home = $constructor(Home)
7
+ .build(uniqueName('home'))
8
+ .build(home => {
9
+ registerRootScope(home);
10
+ });
11
+ //# sourceMappingURL=home.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home.js","sourceRoot":"","sources":["../../src/library/home.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE1D,MAAM,OAAO,IAAK,SAAQ,KAAK;CAAG;AAElC,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC;KACpC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;KACzB,KAAK,CAAC,IAAI,CAAC,EAAE;IACZ,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export * from './atomics/index.js';
2
+ export * from './command.js';
3
+ export * from './device.js';
4
+ export * from './device/index.js';
5
+ export * from './device-namespace.js';
6
+ export * from './devices/index.js';
7
+ export * from './endpoint.js';
8
+ export * from './home.js';
9
+ export * from './log.js';
10
+ export * from './provider.js';
11
+ export * from './registry.js';
12
+ export * from './runtime/index.js';
13
+ export * from './scope.js';
14
+ export * from './types.js';
15
+ export * from './utils/index.js';
16
+ export * from './x-data-medium.js';
@@ -0,0 +1,17 @@
1
+ export * from './atomics/index.js';
2
+ export * from './command.js';
3
+ export * from './device.js';
4
+ export * from './device/index.js';
5
+ export * from './device-namespace.js';
6
+ export * from './devices/index.js';
7
+ export * from './endpoint.js';
8
+ export * from './home.js';
9
+ export * from './log.js';
10
+ export * from './provider.js';
11
+ export * from './registry.js';
12
+ export * from './runtime/index.js';
13
+ export * from './scope.js';
14
+ export * from './types.js';
15
+ export * from './utils/index.js';
16
+ export * from './x-data-medium.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/library/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { Command } from './command.js';
2
+ import type { EndpointLogState } from './endpoint.js';
3
+ export type EndpointLogTarget = {
4
+ readonly scopePath: readonly string[];
5
+ readonly deviceName: string;
6
+ readonly endpointName: string;
7
+ };
8
+ export type LogEvent = EndpointCommandLogEvent | EndpointStateLogEvent | ErrorLogEvent;
9
+ export type EndpointCommandLogEvent = {
10
+ readonly type: 'endpoint-command';
11
+ /** Unix timestamp in milliseconds. */
12
+ readonly timestamp: number;
13
+ /** The execution decision made by Core. */
14
+ readonly action: 'execute' | 'skip';
15
+ readonly target: EndpointLogTarget;
16
+ readonly connectionDescription: string | undefined;
17
+ readonly commandDescription: string;
18
+ };
19
+ export type EndpointStateLogEvent = {
20
+ readonly type: 'endpoint-state';
21
+ /** Unix timestamp in milliseconds. */
22
+ readonly timestamp: number;
23
+ readonly target: EndpointLogTarget;
24
+ readonly connectionDescription: string | undefined;
25
+ readonly state: EndpointLogState;
26
+ readonly previousState: EndpointLogState | undefined;
27
+ };
28
+ export type ErrorLogEvent = {
29
+ readonly type: 'error';
30
+ /** Unix timestamp in milliseconds. */
31
+ readonly timestamp: number;
32
+ readonly error: unknown;
33
+ };
34
+ export type LogListener = (event: LogEvent) => void;
35
+ export declare function addLogListener(listener: LogListener): () => void;
36
+ export declare function setEndpointLogTarget(endpoint: object, target: EndpointLogTarget): void;
37
+ export declare function hasEndpointLogTarget(endpoint: object): boolean;
38
+ export declare function logEndpointCommand(endpoint: object, connection: Loggable, command: Command, action: EndpointCommandLogEvent['action'], execution?: Loggable | undefined): void;
39
+ export declare function logEndpointState(endpoint: object, connection: Loggable, state: EndpointLogState, previousState: EndpointLogState | undefined): void;
40
+ export declare function logEndpointError(error: unknown): void;
41
+ export type Loggable = {
42
+ readonly toLogString?: () => string;
43
+ };
@@ -0,0 +1,78 @@
1
+ const endpointLogTargetMap = new WeakMap();
2
+ const logListenerSet = new Set();
3
+ export function addLogListener(listener) {
4
+ logListenerSet.add(listener);
5
+ return () => {
6
+ logListenerSet.delete(listener);
7
+ };
8
+ }
9
+ export function setEndpointLogTarget(endpoint, target) {
10
+ endpointLogTargetMap.set(endpoint, target);
11
+ }
12
+ export function hasEndpointLogTarget(endpoint) {
13
+ return endpointLogTargetMap.has(endpoint);
14
+ }
15
+ export function logEndpointCommand(endpoint, connection, command, action, execution = undefined) {
16
+ var _a, _b;
17
+ try {
18
+ const target = endpointLogTargetMap.get(endpoint);
19
+ if (target !== undefined) {
20
+ emitLogEvent({
21
+ type: 'endpoint-command',
22
+ action,
23
+ target,
24
+ connectionDescription: safeLogString(connection, connection.constructor.name),
25
+ commandDescription: (_b = (_a = safeLogString(execution)) !== null && _a !== void 0 ? _a : safeLogString(command)) !== null && _b !== void 0 ? _b : command.constructor.name,
26
+ });
27
+ }
28
+ }
29
+ catch (_c) {
30
+ // Logging must never affect command processing.
31
+ }
32
+ }
33
+ export function logEndpointState(endpoint, connection, state, previousState) {
34
+ try {
35
+ const target = endpointLogTargetMap.get(endpoint);
36
+ if (target !== undefined) {
37
+ emitLogEvent({
38
+ type: 'endpoint-state',
39
+ target,
40
+ connectionDescription: safeLogString(connection, connection.constructor.name),
41
+ state,
42
+ previousState,
43
+ });
44
+ }
45
+ }
46
+ catch (_a) {
47
+ // Logging must never affect state propagation.
48
+ }
49
+ }
50
+ export function logEndpointError(error) {
51
+ emitLogEvent({ type: 'error', error });
52
+ }
53
+ function emitLogEvent(event) {
54
+ const timestampedEvent = { ...event, timestamp: Date.now() };
55
+ for (const listener of logListenerSet) {
56
+ try {
57
+ listener(timestampedEvent);
58
+ }
59
+ catch (_a) {
60
+ // A log listener must never affect another listener or homelib itself.
61
+ }
62
+ }
63
+ }
64
+ function safeLogString(value, errorFallback = undefined) {
65
+ if (value === undefined) {
66
+ return undefined;
67
+ }
68
+ try {
69
+ const { toLogString } = value;
70
+ return typeof toLogString === 'function'
71
+ ? String(toLogString.call(value))
72
+ : undefined;
73
+ }
74
+ catch (_a) {
75
+ return errorFallback;
76
+ }
77
+ }
78
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/library/log.ts"],"names":[],"mappings":"AAGA,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAA6B,CAAC;AACtE,MAAM,cAAc,GAAG,IAAI,GAAG,EAAe,CAAC;AAyC9C,MAAM,UAAU,cAAc,CAAC,QAAqB;IAClD,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE7B,OAAO,GAAG,EAAE;QACV,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAA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