smart-home-engine 1.51.0 → 1.51.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 +72 -75
- package/dist/web/assets/{index-d3XMhJaq.js → index-CSKTxEh5.js} +98 -98
- package/dist/web/assets/{tsMode-DYoVxMI5.js → tsMode-4A8DZYIU.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/service/she-servicectl +1 -1
- package/src/index.js +4 -8
- package/src/lib/script-timers.js +26 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as O}from"./monaco-langs-DKJI_o9J.js";import{t as I}from"./index-
|
|
1
|
+
import{m as O}from"./monaco-langs-DKJI_o9J.js";import{t as I}from"./index-CSKTxEh5.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
package/dist/web/index.html
CHANGED
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
}
|
|
176
176
|
})();
|
|
177
177
|
</script>
|
|
178
|
-
<script type="module" crossorigin src="/assets/index-
|
|
178
|
+
<script type="module" crossorigin src="/assets/index-CSKTxEh5.js"></script>
|
|
179
179
|
<link rel="modulepreload" crossorigin href="/assets/monaco-langs-DKJI_o9J.js">
|
|
180
180
|
<link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
|
|
181
181
|
<link rel="stylesheet" crossorigin href="/assets/index-DPDW78ru.css">
|
package/package.json
CHANGED
package/service/she-servicectl
CHANGED
|
@@ -719,7 +719,7 @@ fetch_n() {
|
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
cmd_node() {
|
|
722
|
-
[ $# -ge 1 ] || die "usage: node update [--lts|--stable]"
|
|
722
|
+
[ $# -ge 1 ] || die "usage: node update [--lts|--stable|--latest|--version X.Y.Z]"
|
|
723
723
|
action=$1
|
|
724
724
|
shift
|
|
725
725
|
[ "$action" = update ] || die "unknown node action: $action"
|
package/src/index.js
CHANGED
|
@@ -259,6 +259,7 @@ const { domain, vm, fs, path, suncalc } = modules;
|
|
|
259
259
|
const scheduler = modules['node-schedule'];
|
|
260
260
|
|
|
261
261
|
const StateStore = require('./lib/state-store');
|
|
262
|
+
const { trackTimeout } = require('./lib/script-timers');
|
|
262
263
|
const sandboxModules = [];
|
|
263
264
|
const store = new StateStore();
|
|
264
265
|
if (typeof config.port !== 'undefined') require('./web/broker-api').setStore(store);
|
|
@@ -1061,8 +1062,7 @@ function runScript(script, name, _origin) {
|
|
|
1061
1062
|
scheduler.scheduleJob(pattern, () => {
|
|
1062
1063
|
// Track the random-delay timer so it is cancelled on unload
|
|
1063
1064
|
// if the job fires in the same tick as the script is reloaded.
|
|
1064
|
-
|
|
1065
|
-
_myTimers.add(id);
|
|
1065
|
+
trackTimeout(_myTimers, () => _dispatch(name, scriptDomain.bind(callback)), (parseFloat(options.random) || 0) * 1000 * Math.random());
|
|
1066
1066
|
}),
|
|
1067
1067
|
);
|
|
1068
1068
|
} else {
|
|
@@ -1211,9 +1211,7 @@ function runScript(script, name, _origin) {
|
|
|
1211
1211
|
const Sandbox = {
|
|
1212
1212
|
setTimeout: (fn, delay, ...args) => {
|
|
1213
1213
|
const wrapped = args.length ? () => fn(...args) : fn;
|
|
1214
|
-
|
|
1215
|
-
_myTimers.add(id);
|
|
1216
|
-
return id;
|
|
1214
|
+
return trackTimeout(_myTimers, () => _dispatch(name, wrapped), delay);
|
|
1217
1215
|
},
|
|
1218
1216
|
setInterval: (fn, delay, ...args) => {
|
|
1219
1217
|
const wrapped = args.length ? () => fn(...args) : fn;
|
|
@@ -1296,9 +1294,7 @@ function runScript(script, name, _origin) {
|
|
|
1296
1294
|
// sandbox modules that don't have direct access to the Sandbox context.
|
|
1297
1295
|
she.setTimeout = (fn, delay, ...args) => {
|
|
1298
1296
|
const wrapped = args.length ? () => fn(...args) : fn;
|
|
1299
|
-
|
|
1300
|
-
_myTimers.add(id);
|
|
1301
|
-
return id;
|
|
1297
|
+
return trackTimeout(_myTimers, () => _dispatch(name, wrapped), delay);
|
|
1302
1298
|
};
|
|
1303
1299
|
she.clearTimeout = (id) => {
|
|
1304
1300
|
_myTimers.delete(id);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* One-shot timers a script started, tracked in the script's set so that unloading the script can
|
|
4
|
+
* clear the ones still pending (roadmap B9).
|
|
5
|
+
*
|
|
6
|
+
* The id leaves the set when the timer fires. Before, only an explicit clearTimeout removed it, so
|
|
7
|
+
* every timeout that ran normally stayed in the set for the life of the daemon — with its callback
|
|
8
|
+
* and everything the callback captured. A script that starts a "switch off after N minutes" timer
|
|
9
|
+
* per event leaked hundreds of them an hour, and the heap ran full after about twelve days.
|
|
10
|
+
*
|
|
11
|
+
* @param {Set} timers the script's timer set
|
|
12
|
+
* @param {Function} fn called when the timer fires
|
|
13
|
+
* @param {number} delay ms
|
|
14
|
+
* @param {Function} [setTimeoutFn] for tests
|
|
15
|
+
* @returns the timer id (what clearTimeout takes)
|
|
16
|
+
*/
|
|
17
|
+
function trackTimeout(timers, fn, delay, setTimeoutFn = setTimeout) {
|
|
18
|
+
const id = setTimeoutFn(() => {
|
|
19
|
+
timers.delete(id);
|
|
20
|
+
fn();
|
|
21
|
+
}, delay);
|
|
22
|
+
timers.add(id);
|
|
23
|
+
return id;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = { trackTimeout };
|