iobroker.javascript 9.2.3 → 9.2.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.
- package/README.md +6 -14
- package/admin/assets/{AiChatPanel-C4zUsNmN.js → AiChatPanel-B4vPXgLz.js} +1 -1
- package/admin/assets/{ScriptEditor-C6W68ya0.js → ScriptEditor-CmEeMfC2.js} +1 -1
- package/admin/assets/{ScriptEditorVanillaMonaco-DYTcDqp_.js → ScriptEditorVanillaMonaco-C22Gpet7.js} +2 -2
- package/admin/assets/{index-crBQrXKG.js → index-7mrTpzQy.js} +1 -1
- package/admin/assets/{index-CUau9-il.js → index-BTQOdA7v.js} +28 -28
- package/admin/assets/{index-BXfqctma.js → index-Dggem6AX.js} +1 -1
- package/admin/assets/{stateHoverProvider-BYBqzJuX.js → stateHoverProvider-DxTNxyYN.js} +1 -1
- package/admin/custom/assets/{Components-jfkoGyES.js → Components-CGiJE5Zh.js} +1 -1
- package/admin/custom/assets/{index-CS_GBN2m.js → index-B6NrrORQ.js} +1 -1
- package/admin/custom/assets/index-CT5PwRfY.js +964 -0
- package/admin/custom/assets/{index-ChQotUCl.js → index-DTbSiEk2.js} +1 -1
- package/admin/custom/assets/{localSharedImportMap-BeObsVNc.js → localSharedImportMap-ChjFDKsq.js} +1 -1
- package/admin/custom/assets/{virtualExposes-wYe_Np-4.js → virtualExposes-D402kVGY.js} +1 -1
- package/admin/custom/assets/{virtual_mf-REMOTE_ENTRY_ID_ConfigCustomJavascriptSet__customComponents_js-BcRVut8U.js → virtual_mf-REMOTE_ENTRY_ID_ConfigCustomJavascriptSet__customComponents_js-ClQrb2n1.js} +2 -2
- package/admin/custom/customComponents.js +1 -1
- package/admin/i18n/es.json +77 -77
- package/admin/tab.html +1 -1
- package/build/lib/debugger.js +1 -1
- package/build/lib/debugger.js.map +1 -1
- package/build/lib/eventObj.js +10 -2
- package/build/lib/eventObj.js.map +1 -1
- package/build/lib/inspect.js +3 -3
- package/build/lib/inspect.js.map +1 -1
- package/build/lib/sandbox.js +169 -62
- package/build/lib/sandbox.js.map +1 -1
- package/build/main.js +63 -19
- package/build/main.js.map +1 -1
- package/build/types.d.ts +4 -0
- package/io-package.json +14 -14
- package/package.json +11 -11
- package/admin/custom/assets/index-qs6J40Tp.js +0 -964
package/build/main.js
CHANGED
|
@@ -273,6 +273,16 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
273
273
|
/** Fast O(1) lookup set – always kept in sync with stateIds */
|
|
274
274
|
stateIdSet = new Set();
|
|
275
275
|
subscriptions = [];
|
|
276
|
+
/**
|
|
277
|
+
* O(1) dispatch map for subscriptions with exact (non-wildcard) string IDs.
|
|
278
|
+
* Always kept in sync with `subscriptions`.
|
|
279
|
+
*/
|
|
280
|
+
subscriptionsMap = new Map();
|
|
281
|
+
/**
|
|
282
|
+
* Subscriptions whose pattern.id is a RegExp, contains wildcards (*,?), or is undefined.
|
|
283
|
+
* These must still be checked linearly on every state change.
|
|
284
|
+
*/
|
|
285
|
+
subscriptionsWildcard = [];
|
|
276
286
|
subscriptionsFile = [];
|
|
277
287
|
subscriptionsObject = [];
|
|
278
288
|
/** O(1) dispatch map for subscriptionsObject – pattern → subscribers */
|
|
@@ -418,6 +428,8 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
418
428
|
stateIds: this.stateIds,
|
|
419
429
|
errorLogFunction: this.errorLogFunction,
|
|
420
430
|
subscriptions: this.subscriptions,
|
|
431
|
+
subscriptionsMap: this.subscriptionsMap,
|
|
432
|
+
subscriptionsWildcard: this.subscriptionsWildcard,
|
|
421
433
|
subscriptionsFile: this.subscriptionsFile,
|
|
422
434
|
subscriptionsObject: this.subscriptionsObject,
|
|
423
435
|
subscriptionsObjectMap: this.subscriptionsObjectMap,
|
|
@@ -684,13 +696,42 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
684
696
|
this.stateIdSet.delete(id);
|
|
685
697
|
}
|
|
686
698
|
}
|
|
687
|
-
|
|
699
|
+
// Collect matching subscriptions:
|
|
700
|
+
// 1. O(1) exact-id map lookup – only buckets for this specific state id
|
|
701
|
+
// 2. Linear scan over wildcard/regex subscriptions (unavoidable)
|
|
702
|
+
// EventObj is created lazily – only when at least one subscription must be dispatched.
|
|
703
|
+
const exactSubs = this.subscriptionsMap.get(id);
|
|
704
|
+
const wildcardSubs = this.subscriptionsWildcard;
|
|
705
|
+
const hasWork = (exactSubs && exactSubs.length > 0) || wildcardSubs.length > 0;
|
|
706
|
+
if (!hasWork) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
let _eventObj = null;
|
|
710
|
+
const getEvent = () => {
|
|
711
|
+
if (!_eventObj) {
|
|
712
|
+
_eventObj = (0, eventObj_1.createEventObject)(this.context, id, this.convertBackStringifiedValues(id, state), this.convertBackStringifiedValues(id, oldState));
|
|
713
|
+
}
|
|
714
|
+
return _eventObj;
|
|
715
|
+
};
|
|
716
|
+
if (exactSubs) {
|
|
717
|
+
for (let i = 0, l = exactSubs.length; i < l; i++) {
|
|
718
|
+
const sub = exactSubs[i];
|
|
719
|
+
if (sub?.patternCompareFunctions && patternMatching(getEvent(), sub.patternCompareFunctions)) {
|
|
720
|
+
try {
|
|
721
|
+
sub.callback(getEvent());
|
|
722
|
+
}
|
|
723
|
+
catch (err) {
|
|
724
|
+
this.log.error(`Error in callback: ${err.toString()}`);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
688
729
|
// if this state matches any subscriptions
|
|
689
|
-
for (let i = 0, l =
|
|
690
|
-
const sub =
|
|
691
|
-
if (sub?.patternCompareFunctions && patternMatching(
|
|
730
|
+
for (let i = 0, l = wildcardSubs.length; i < l; i++) {
|
|
731
|
+
const sub = wildcardSubs[i];
|
|
732
|
+
if (sub?.patternCompareFunctions && patternMatching(getEvent(), sub.patternCompareFunctions)) {
|
|
692
733
|
try {
|
|
693
|
-
sub.callback(
|
|
734
|
+
sub.callback(getEvent());
|
|
694
735
|
}
|
|
695
736
|
catch (err) {
|
|
696
737
|
this.log.error(`Error in callback: ${err.toString()}`);
|
|
@@ -1263,7 +1304,7 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
1263
1304
|
}
|
|
1264
1305
|
}
|
|
1265
1306
|
onLog(msg) {
|
|
1266
|
-
for (const name
|
|
1307
|
+
for (const name of Object.keys(this.logSubscriptions)) {
|
|
1267
1308
|
for (const handler of this.logSubscriptions[name]) {
|
|
1268
1309
|
if (typeof handler.cb === 'function' &&
|
|
1269
1310
|
(handler.severity === '*' || handler.severity === msg.severity)) {
|
|
@@ -1524,9 +1565,9 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
1524
1565
|
}
|
|
1525
1566
|
}
|
|
1526
1567
|
}
|
|
1527
|
-
//
|
|
1568
|
+
// Check setState counter per minute and stop a script if too high
|
|
1528
1569
|
this.setStateCountCheckInterval = setInterval(() => {
|
|
1529
|
-
for (const id
|
|
1570
|
+
for (const id of Object.keys(this.scripts)) {
|
|
1530
1571
|
if (!this.scripts[id]) {
|
|
1531
1572
|
continue;
|
|
1532
1573
|
}
|
|
@@ -1547,7 +1588,7 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
1547
1588
|
this.log.debug(`Script ${id} has NOT reached the maximum of ${this.config.maxSetStatePerMinute} setState calls per minute. Decrease problem counter to ${this.scripts[id].setStatePerMinuteProblemCounter}`);
|
|
1548
1589
|
}
|
|
1549
1590
|
}
|
|
1550
|
-
},
|
|
1591
|
+
}, 60_000).unref();
|
|
1551
1592
|
}
|
|
1552
1593
|
loadTypeScriptDeclarations() {
|
|
1553
1594
|
// try to load the typings on disk for all 3rd party modules
|
|
@@ -2328,6 +2369,11 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
2328
2369
|
for (let i = this.subscriptions.length - 1; i >= 0; i--) {
|
|
2329
2370
|
if (this.subscriptions[i].name === name) {
|
|
2330
2371
|
const sub = this.subscriptions.splice(i, 1)[0];
|
|
2372
|
+
// Also remove from the O(1) dispatch structures – shared helper to keep the
|
|
2373
|
+
// exact-id classification identical to the subscribe side in sandbox.ts
|
|
2374
|
+
if (sub) {
|
|
2375
|
+
(0, sandbox_1.removeFromDispatchIndex)(this.context, sub);
|
|
2376
|
+
}
|
|
2331
2377
|
if (sub?.pattern.id) {
|
|
2332
2378
|
this.unsubscribe(sub.pattern.id);
|
|
2333
2379
|
}
|
|
@@ -3045,20 +3091,18 @@ class JavaScript extends adapter_core_1.Adapter {
|
|
|
3045
3091
|
}
|
|
3046
3092
|
}
|
|
3047
3093
|
function patternMatching(event, patternFunctions) {
|
|
3048
|
-
|
|
3049
|
-
const logic = patternFunctions.logic;
|
|
3094
|
+
const logic = patternFunctions.logic ?? 'and';
|
|
3050
3095
|
for (let i = 0, len = patternFunctions.length; i < len; i++) {
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
}
|
|
3055
|
-
matched = true;
|
|
3096
|
+
const result = patternFunctions[i](event);
|
|
3097
|
+
if (logic === 'and' && !result) {
|
|
3098
|
+
return false; // short-circuit AND – one false is enough
|
|
3056
3099
|
}
|
|
3057
|
-
|
|
3058
|
-
return
|
|
3100
|
+
if (logic === 'or' && result) {
|
|
3101
|
+
return true; // short-circuit OR – one true is enough
|
|
3059
3102
|
}
|
|
3060
3103
|
}
|
|
3061
|
-
|
|
3104
|
+
// AND: all passed → true; OR: none matched → false
|
|
3105
|
+
return logic === 'and';
|
|
3062
3106
|
}
|
|
3063
3107
|
// If started as allInOne mode => return function to create an instance
|
|
3064
3108
|
if (require.main !== module) {
|