iobroker.javascript 9.3.0 → 9.3.1
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 +3 -4
- package/admin/assets/{AiChatPanel-BvND3KNP.js → AiChatPanel-C3bIw_D5.js} +1 -1
- package/admin/assets/{ScriptEditor-1BwI9a_X.js → ScriptEditor-8UU88tT5.js} +1 -1
- package/admin/assets/{ScriptEditorVanillaMonaco-BPK75VNu.js → ScriptEditorVanillaMonaco-Bn8xJ3LV.js} +2 -2
- package/admin/assets/index-C0ZnUCQf.js +990 -0
- package/admin/assets/{index-CxRhXAwi.js → index-CO9RA-Wq.js} +4 -4
- package/admin/assets/{index-fS-54-pB.js → index-CRGWWpGb.js} +1 -1
- package/admin/assets/{index-DUMiVB6k.js → index-CsyuIWlD.js} +1 -1
- package/admin/assets/localSharedImportMap-Db5DxDmY.js +1 -0
- package/admin/assets/{stateHoverProvider-dvzAyUDH.js → stateHoverProvider-C82xsI7Q.js} +1 -1
- package/admin/assets/{virtual_mf-REMOTE_ENTRY_ID_iobroker_javascript__remoteEntry_js-Dus28I2g.js → virtual_mf-REMOTE_ENTRY_ID_iobroker_javascript__remoteEntry_js-Bw22wl4W.js} +2 -2
- package/admin/custom/assets/index-CMsuyEZj.js +964 -0
- package/admin/custom/assets/{index-C8_qJ4Y6.js → index-CuAhFQ4L.js} +1 -1
- package/admin/custom/assets/{index-BVOepGI5.js → index-mkhHeJ3Q.js} +1 -1
- package/admin/custom/assets/localSharedImportMap-BsMINYMr.js +1 -0
- package/admin/custom/assets/{virtual_mf-REMOTE_ENTRY_ID_ConfigCustomJavascriptSet__customComponents_js-CO2hfDx_.js → virtual_mf-REMOTE_ENTRY_ID_ConfigCustomJavascriptSet__customComponents_js-BzLNCazi.js} +2 -2
- package/admin/custom/customComponents.js +1 -1
- package/admin/mf-manifest.json +1 -1
- package/admin/remoteEntry.js +1 -1
- package/admin/tab.html +2 -2
- package/build/lib/sandbox.js +20 -12
- package/build/lib/sandbox.js.map +1 -1
- package/build/main.js +34 -25
- package/build/main.js.map +1 -1
- package/build/types.d.ts +4 -4
- package/io-package.json +14 -14
- package/package.json +3 -3
- package/admin/assets/index-Be9Zg6aF.js +0 -990
- package/admin/assets/localSharedImportMap-Cs4ibnCv.js +0 -1
- package/admin/custom/assets/index-DSGXVHGh.js +0 -964
- package/admin/custom/assets/localSharedImportMap-C-8wOKN2.js +0 -1
package/build/main.js
CHANGED
|
@@ -335,6 +335,7 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
335
335
|
executeCounter = 0;
|
|
336
336
|
// compiler instance for typescript
|
|
337
337
|
tsServer;
|
|
338
|
+
logCollectors = [];
|
|
338
339
|
ignoreObjectChange = new Set();
|
|
339
340
|
debugState = {
|
|
340
341
|
scriptName: '',
|
|
@@ -1461,6 +1462,14 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
1461
1462
|
}
|
|
1462
1463
|
}
|
|
1463
1464
|
}
|
|
1465
|
+
// Special case if some script is executed now with "execute" command, and we see "script.js.__execute_X:" at the beginning
|
|
1466
|
+
if (this.logCollectors.length) {
|
|
1467
|
+
for (const logCollector of this.logCollectors) {
|
|
1468
|
+
if (msg.message.includes(`${logCollector.name}:`)) {
|
|
1469
|
+
logCollector.collector(msg.severity, msg.message);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1464
1473
|
}
|
|
1465
1474
|
logError(scriptName, msg, e, offs) {
|
|
1466
1475
|
const stack = e.stack ? e.stack.toString().split('\n') : e ? e.toString() : '';
|
|
@@ -2370,19 +2379,7 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
2370
2379
|
expire: 1000,
|
|
2371
2380
|
});
|
|
2372
2381
|
}
|
|
2373
|
-
const sandbox = (0, sandbox_1.sandBox)(script, name, verbose, debug, this.context);
|
|
2374
|
-
// Redirect every log line into the collector. As `console.*`, the global `log()` and all
|
|
2375
|
-
// `sandbox.verbose && sandbox.log(...)` calls go through `sandbox.log`, this captures the
|
|
2376
|
-
// full picture for the caller while keeping the adapter log clean.
|
|
2377
|
-
if (logCollector) {
|
|
2378
|
-
sandbox.log = (msg, severity) => {
|
|
2379
|
-
let text = msg;
|
|
2380
|
-
if (text && typeof text !== 'string') {
|
|
2381
|
-
text = util.format(text);
|
|
2382
|
-
}
|
|
2383
|
-
logCollector(severity || 'info', text);
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2382
|
+
const sandbox = (0, sandbox_1.sandBox)(script, name, verbose, debug, this.context, logCollector);
|
|
2386
2383
|
try {
|
|
2387
2384
|
script.script.runInNewContext(sandbox, {
|
|
2388
2385
|
filename: name,
|
|
@@ -2488,6 +2485,8 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
2488
2485
|
}
|
|
2489
2486
|
logs.push({ ts: Date.now(), severity, message: msg });
|
|
2490
2487
|
};
|
|
2488
|
+
this.logCollectors.push({ name, collector });
|
|
2489
|
+
this.updateLogSubscriptions();
|
|
2491
2490
|
this.scripts[name] = createdScript;
|
|
2492
2491
|
this.execute(createdScript, name, engineType, verbose, false, collector);
|
|
2493
2492
|
// Let asynchronous output (timeouts, awaited code, triggered subscriptions) accumulate
|
|
@@ -2496,6 +2495,11 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
2496
2495
|
}
|
|
2497
2496
|
// Stop and clean up the ephemeral script (timers, subscriptions, schedules, …)
|
|
2498
2497
|
await this.stopScript(name, true);
|
|
2498
|
+
const pos = this.logCollectors.findIndex(it => it.name === name);
|
|
2499
|
+
if (pos !== -1) {
|
|
2500
|
+
this.logCollectors.splice(pos, 1);
|
|
2501
|
+
}
|
|
2502
|
+
this.updateLogSubscriptions();
|
|
2499
2503
|
const minIdx = LEVELS.indexOf(minLevel);
|
|
2500
2504
|
const filtered = logs.filter(entry => {
|
|
2501
2505
|
const idx = LEVELS.indexOf(entry.severity);
|
|
@@ -2584,26 +2588,31 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
2584
2588
|
}
|
|
2585
2589
|
// Analyze if logs are still required or not
|
|
2586
2590
|
updateLogSubscriptions() {
|
|
2587
|
-
let found =
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2591
|
+
let found = '';
|
|
2592
|
+
if (this.logCollectors.length) {
|
|
2593
|
+
found = this.logCollectors[0].name;
|
|
2594
|
+
}
|
|
2595
|
+
else {
|
|
2596
|
+
// go through all scripts and check if some script still requires logs
|
|
2597
|
+
Object.keys(this.logSubscriptions).forEach(scriptName => {
|
|
2598
|
+
if (!this.logSubscriptions?.[scriptName] || !this.logSubscriptions[scriptName].length) {
|
|
2599
|
+
delete this.logSubscriptions[scriptName];
|
|
2600
|
+
}
|
|
2601
|
+
else {
|
|
2602
|
+
found = scriptName;
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2597
2606
|
if (this.requireLog) {
|
|
2598
2607
|
if (found && !this.logSubscribed) {
|
|
2599
2608
|
this.logSubscribed = true;
|
|
2600
2609
|
void this.requireLog(this.logSubscribed);
|
|
2601
|
-
this.log.info(`Subscribed to log messages (found
|
|
2610
|
+
this.log.info(`Subscribed to log messages (at least because of ${found})`);
|
|
2602
2611
|
}
|
|
2603
2612
|
else if (!found && this.logSubscribed) {
|
|
2604
2613
|
this.logSubscribed = false;
|
|
2605
2614
|
void this.requireLog(this.logSubscribed);
|
|
2606
|
-
this.log.info(`Unsubscribed from log messages (not found
|
|
2615
|
+
this.log.info(`Unsubscribed from log messages (not found any subscribers)`);
|
|
2607
2616
|
}
|
|
2608
2617
|
}
|
|
2609
2618
|
}
|