smart-home-engine 1.18.1 → 1.19.0

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-D8qyUbwO.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-Dt8a9eeo.js";import{t as I}from"./index-xdnNresq.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,10 +172,10 @@
172
172
  }
173
173
  })();
174
174
  </script>
175
- <script type="module" crossorigin src="/assets/index-D8qyUbwO.js"></script>
175
+ <script type="module" crossorigin src="/assets/index-xdnNresq.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
- <link rel="stylesheet" crossorigin href="/assets/index-BvKmwc2a.css">
178
+ <link rel="stylesheet" crossorigin href="/assets/index-nf1nG74s.css">
179
179
  </head>
180
180
  <body>
181
181
  <div id="app"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "1.18.1",
3
+ "version": "1.19.0",
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/index.js CHANGED
@@ -328,6 +328,23 @@ let _mqttMsgCount = 0;
328
328
  let _mqttMsgTs = Date.now();
329
329
  let _prevCpuUsage = process.cpuUsage();
330
330
 
331
+ // perf_hooks — event loop utilization + delay histogram (always-on, minimal overhead)
332
+ const { PerformanceObserver, monitorEventLoopDelay, performance } = require('perf_hooks');
333
+ let _prevElu = performance.eventLoopUtilization();
334
+ const _elHisto = monitorEventLoopDelay({ resolution: 20 });
335
+ _elHisto.enable();
336
+
337
+ // GC observer — log only significant GC pauses (>=50ms); never spams on normal minor GCs
338
+ const _gcKinds = { 1: 'minor', 2: 'major', 4: 'incremental', 8: 'weaken' };
339
+ new PerformanceObserver((list) => {
340
+ for (const entry of list.getEntries()) {
341
+ if (entry.duration >= 50) {
342
+ const kind = _gcKinds[entry.detail?.kind] ?? 'gc';
343
+ log.warn(`GC ${kind} pause ${Math.round(entry.duration)}ms`);
344
+ }
345
+ }
346
+ }).observe({ type: 'gc', buffered: false });
347
+
331
348
  // Register runtime stats provider for GET /she/status
332
349
  require('./web/server').setStatsProvider(() => {
333
350
  let topics = 0;
@@ -341,6 +358,11 @@ require('./web/server').setStatsProvider(() => {
341
358
  const cpuDelta = process.cpuUsage(_prevCpuUsage);
342
359
  _prevCpuUsage = process.cpuUsage();
343
360
  const cpuPercent = elapsed > 0 ? Math.round(((cpuDelta.user + cpuDelta.system) / 1000 / (elapsed * 1000)) * 1000) / 10 : 0;
361
+ const eluDelta = performance.eventLoopUtilization(_prevElu);
362
+ _prevElu = performance.eventLoopUtilization();
363
+ const elMeanMs = Math.round(_elHisto.mean / 1e6);
364
+ const elP99Ms = Math.round(_elHisto.percentile(99) / 1e6);
365
+ _elHisto.reset();
344
366
  const mem = process.memoryUsage();
345
367
  const memMb = Math.round(mem.rss / 1048576);
346
368
  const core = shedb.getCore();
@@ -378,6 +400,9 @@ require('./web/server').setStatsProvider(() => {
378
400
  handlers: subscriptions.length + varSubscriptions.length + mqttEventCallbacks.length,
379
401
  memMb,
380
402
  cpuPercent,
403
+ eluPercent: Math.round(eluDelta.utilization * 100),
404
+ elMeanMs,
405
+ elP99Ms,
381
406
  };
382
407
  });
383
408
 
@@ -1005,12 +1030,14 @@ function runScript(script, name, _origin) {
1005
1030
 
1006
1031
  const Sandbox = {
1007
1032
  setTimeout: (fn, delay, ...args) => {
1008
- const id = setTimeout(fn, delay, ...args);
1033
+ const wrapped = args.length ? () => fn(...args) : fn;
1034
+ const id = setTimeout(() => _dispatch(name, wrapped), delay);
1009
1035
  _myTimers.add(id);
1010
1036
  return id;
1011
1037
  },
1012
1038
  setInterval: (fn, delay, ...args) => {
1013
- const id = setInterval(fn, delay, ...args);
1039
+ const wrapped = args.length ? () => fn(...args) : fn;
1040
+ const id = setInterval(() => _dispatch(name, wrapped), delay);
1014
1041
  _myTimers.add(id);
1015
1042
  return id;
1016
1043
  },
@@ -1084,7 +1111,8 @@ function runScript(script, name, _origin) {
1084
1111
  // she.setTimeout / she.clearTimeout — tracked versions for use by stdlib and
1085
1112
  // sandbox modules that don't have direct access to the Sandbox context.
1086
1113
  she.setTimeout = (fn, delay, ...args) => {
1087
- const id = setTimeout(fn, delay, ...args);
1114
+ const wrapped = args.length ? () => fn(...args) : fn;
1115
+ const id = setTimeout(() => _dispatch(name, wrapped), delay);
1088
1116
  _myTimers.add(id);
1089
1117
  return id;
1090
1118
  };