node-red-contrib-uos-nats 1.3.71 → 1.3.72
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/lib/payloads.js +15 -12
- package/nodes/datahub-input.js +11 -3
- package/package.json +1 -1
package/lib/payloads.js
CHANGED
|
@@ -222,6 +222,13 @@ export function decodeVariableList(list, whitelistIds = null) {
|
|
|
222
222
|
if (!list)
|
|
223
223
|
return [];
|
|
224
224
|
const result = [];
|
|
225
|
+
|
|
226
|
+
// Optimization: Reuse holders to reduce GC pressure
|
|
227
|
+
const holderInt64 = new VariableValueInt64();
|
|
228
|
+
const holderFloat64 = new VariableValueFloat64();
|
|
229
|
+
const holderBoolean = new VariableValueBoolean();
|
|
230
|
+
const holderString = new VariableValueString();
|
|
231
|
+
|
|
225
232
|
for (let i = 0; i < list.itemsLength(); i += 1) {
|
|
226
233
|
const item = list.items(i);
|
|
227
234
|
if (!item)
|
|
@@ -236,27 +243,23 @@ export function decodeVariableList(list, whitelistIds = null) {
|
|
|
236
243
|
let decoded;
|
|
237
244
|
switch (item.valueType()) {
|
|
238
245
|
case VariableValue.Int64: {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
decoded = Number(holder.value());
|
|
246
|
+
item.value(holderInt64);
|
|
247
|
+
decoded = Number(holderInt64.value());
|
|
242
248
|
break;
|
|
243
249
|
}
|
|
244
250
|
case VariableValue.Float64: {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
decoded = holder.value();
|
|
251
|
+
item.value(holderFloat64);
|
|
252
|
+
decoded = holderFloat64.value();
|
|
248
253
|
break;
|
|
249
254
|
}
|
|
250
255
|
case VariableValue.Boolean: {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
decoded = holder.value();
|
|
256
|
+
item.value(holderBoolean);
|
|
257
|
+
decoded = holderBoolean.value();
|
|
254
258
|
break;
|
|
255
259
|
}
|
|
256
260
|
case VariableValue.String: {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
decoded = holder.value();
|
|
261
|
+
item.value(holderString);
|
|
262
|
+
decoded = holderString.value();
|
|
260
263
|
break;
|
|
261
264
|
}
|
|
262
265
|
default:
|
package/nodes/datahub-input.js
CHANGED
|
@@ -74,12 +74,14 @@ module.exports = function (RED) {
|
|
|
74
74
|
// Pre-populate raw map with manual definitions
|
|
75
75
|
this.manualDefs.forEach(d => defMap.set(d.id, { ...d, type: 'MANUAL', dataType: 'UNKNOWN', access: 'READ_ONLY' }));
|
|
76
76
|
|
|
77
|
+
// Optimization: Use Set for O(1) lookups
|
|
78
|
+
const variableSet = new Set(this.variables.map(v => normalizeKey(v)));
|
|
79
|
+
|
|
77
80
|
const shouldInclude = (key) => {
|
|
78
|
-
if (
|
|
81
|
+
if (variableSet.size === 0) {
|
|
79
82
|
return true;
|
|
80
83
|
}
|
|
81
|
-
|
|
82
|
-
return this.variables.includes(needle);
|
|
84
|
+
return variableSet.has(normalizeKey(key));
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
const processStates = (states) => {
|
|
@@ -101,6 +103,12 @@ module.exports = function (RED) {
|
|
|
101
103
|
this.warnOnce('Filtering active but Variable Definitions failed to load (API Error). Names cannot be resolved. Try using "Name:ID" format to manually map variables.');
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
// Optimization: redundant check removed if whitelist is active, but keeping as safeguard
|
|
107
|
+
// If we used a whitelist, we know we only have relevant IDs.
|
|
108
|
+
// However, keeping strict check is safer for "Name-based" consistency.
|
|
109
|
+
// But we can optimize: if mapped.length is same as whitelist size, we are good?
|
|
110
|
+
// Actually, let's keep it simple: Filter-on-Decode handles the heavy lifting (byte level).
|
|
111
|
+
// This JS filter is now cheap (O(1) lookup). We'll keep it for correctness in case of aliasing/manual IDs.
|
|
104
112
|
return mapped.filter((state) => shouldInclude(state.key));
|
|
105
113
|
};
|
|
106
114
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-uos-nats",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.72",
|
|
4
4
|
"description": "Node-RED nodes for Weidmüller u-OS Data Hub. Read, write, and provide variables via NATS protocol with OAuth2 authentication. Features: Variable Key resolution, custom icons, example flows, and provider definition caching.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "IoTUeli",
|