smart-home-engine 0.24.2 → 0.24.3

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-BW2J83t5.js";import{t as I}from"./index-7iwVdvJ3.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-CH348YBf.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -155,7 +155,7 @@
155
155
  }
156
156
  })();
157
157
  </script>
158
- <script type="module" crossorigin src="/assets/index-7iwVdvJ3.js"></script>
158
+ <script type="module" crossorigin src="/assets/index-CH348YBf.js"></script>
159
159
  <link rel="modulepreload" crossorigin href="/assets/monaco-langs-BW2J83t5.js">
160
160
  <link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
161
161
  <link rel="stylesheet" crossorigin href="/assets/index-OfBaeGiK.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "0.24.2",
3
+ "version": "0.24.3",
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
@@ -1329,12 +1329,21 @@ function loadDir(dir) {
1329
1329
  return;
1330
1330
  }
1331
1331
 
1332
- // .shelib marker changes - warn only, manual restart required
1332
+ // .shelib marker changes - unload or reload scripts in the affected directory
1333
1333
  if (basename === '.shelib') {
1334
+ const affectedDir = path.dirname(filePath);
1334
1335
  if (event === 'add') {
1335
- log.warn(makeLabel(filePath), 'library marker added - .js files in this directory will no longer load as scripts after daemon restart');
1336
+ log.info(makeLabel(filePath), 'library marker added - unloading scripts in this directory');
1337
+ Object.keys(scripts).forEach((scriptFile) => {
1338
+ const absScript = path.resolve(scriptFile);
1339
+ const absDir = path.resolve(affectedDir);
1340
+ if (absScript.startsWith(absDir + path.sep) || path.dirname(absScript) === absDir) {
1341
+ unloadScript(scriptFile);
1342
+ }
1343
+ });
1336
1344
  } else if (event === 'unlink') {
1337
- log.warn(makeLabel(filePath), 'library marker removed - .js files in this directory will load as scripts after daemon restart');
1345
+ log.info(makeLabel(filePath), 'library marker removed - loading scripts in this directory');
1346
+ loadDirRecursive(affectedDir, path.resolve(dir));
1338
1347
  }
1339
1348
  return;
1340
1349
  }
@@ -63,7 +63,7 @@ function walk(dir, base, parentIsLib) {
63
63
  * Nested tree of all files and subdirectories.
64
64
  * Each node: { type:'file'|'dir', name, path, lib, size?, mtime?, children? }
65
65
  */
66
- function buildTree(dir, base, parentIsLib) {
66
+ function buildTree(dir, base, parentIsLib, parentIsDisabled = false) {
67
67
  let entries;
68
68
  try {
69
69
  entries = fs.readdirSync(dir, { withFileTypes: true });
@@ -81,13 +81,15 @@ function buildTree(dir, base, parentIsLib) {
81
81
  const abs = path.join(dir, entry.name);
82
82
  if (entry.isDirectory()) {
83
83
  const childIsLib = lib || hasShelibMarker(abs);
84
- const disabled = hasShedisableMarker(abs);
85
- const children = buildTree(abs, rel, childIsLib);
86
- result.push({ type: 'dir', name: entry.name, path: rel, lib: childIsLib, disabled, children });
84
+ const selfDisabled = hasShedisableMarker(abs);
85
+ const effectiveDisabled = parentIsDisabled || selfDisabled;
86
+ const children = buildTree(abs, rel, childIsLib, effectiveDisabled);
87
+ result.push({ type: 'dir', name: entry.name, path: rel, lib: childIsLib, disabled: selfDisabled, children });
87
88
  } else {
88
89
  const stat = fs.statSync(abs);
89
90
  const isJs = entry.name.endsWith('.js');
90
- const disabled = isJs ? hasShedisableMarker(abs) : false;
91
+ const selfDisabled = isJs ? hasShedisableMarker(abs) : false;
92
+ const disabled = parentIsDisabled || selfDisabled;
91
93
  result.push({ type: 'file', name: entry.name, path: rel, lib, size: stat.size, mtime: stat.mtimeMs, ...(isJs ? { disabled } : {}) });
92
94
  }
93
95
  }