smart-home-engine 1.14.3 → 1.14.4

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.
@@ -1,4 +1,4 @@
1
- import{m as O}from"./monaco-langs-Dt8a9eeo.js";import{t as I}from"./index-BwN-1kYF.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-Dt8a9eeo.js";import{t as I}from"./index-BPKYEBmN.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -172,7 +172,7 @@
172
172
  }
173
173
  })();
174
174
  </script>
175
- <script type="module" crossorigin src="/assets/index-BwN-1kYF.js"></script>
175
+ <script type="module" crossorigin src="/assets/index-BPKYEBmN.js"></script>
176
176
  <link rel="modulepreload" crossorigin href="/assets/monaco-langs-Dt8a9eeo.js">
177
177
  <link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
178
178
  <link rel="stylesheet" crossorigin href="/assets/index-BXB4YlVH.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "1.14.3",
3
+ "version": "1.14.4",
4
4
  "description": "Node.js based script runner for use in MQTT based Smart Home environments",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/web/shedb.js CHANGED
@@ -82,6 +82,22 @@ function init({ dbPath, dbPublish, dbRetain, dbPrefix, mqttName, mqtt, log, broa
82
82
  }
83
83
  });
84
84
 
85
+ // When a view definition is saved, immediately publish the existing cached
86
+ // result if mqttpub is enabled. This covers the case where the user enables
87
+ // mqttpub on an already-computed view: the worker re-runs and finds an
88
+ // identical result, so the 'view' event is suppressed by the deepEqual
89
+ // check — without this handler nothing would be published until the next
90
+ // document change triggers a view recomputation.
91
+ _core.on('query', (id) => {
92
+ const query = _core.queries[id];
93
+ if (query && query.mqttpub && _mqtt) {
94
+ const view = _core.views[id];
95
+ if (view && !view.error) {
96
+ _mqtt.publish(_dbPrefix + 'view/' + id, JSON.stringify(view.result ?? []), { retain: query.retain === true });
97
+ }
98
+ }
99
+ });
100
+
85
101
  return _core;
86
102
  }
87
103