opcjs-base 0.1.26-alpha → 0.1.29-alpha
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/dist/index.cjs +43 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -23
- package/dist/index.d.ts +20 -23
- package/dist/index.js +43 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
var fastXmlParser = require('fast-xml-parser');
|
|
4
4
|
|
|
5
|
+
// src/types/expandedNodeId.ts
|
|
6
|
+
var ExpandedNodeId = class {
|
|
7
|
+
/** The wrapped NodeId. */
|
|
8
|
+
nodeId;
|
|
9
|
+
/** The server index (optional, for cross-server references). */
|
|
10
|
+
serverIndex;
|
|
11
|
+
/** The namespace URI (optional, alternative to the namespace index on nodeId). */
|
|
12
|
+
namespaceUri;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new ExpandedNodeId.
|
|
15
|
+
*
|
|
16
|
+
* @param nodeId - The wrapped NodeId
|
|
17
|
+
* @param namespaceUri - Optional namespace URI
|
|
18
|
+
* @param serverIndex - Optional server index
|
|
19
|
+
*/
|
|
20
|
+
constructor(nodeId, namespaceUri, serverIndex) {
|
|
21
|
+
this.nodeId = nodeId;
|
|
22
|
+
this.namespaceUri = namespaceUri;
|
|
23
|
+
this.serverIndex = serverIndex;
|
|
24
|
+
}
|
|
25
|
+
/** Convert ExpandedNodeId to string representation. */
|
|
26
|
+
toString() {
|
|
27
|
+
let result = "";
|
|
28
|
+
if (this.serverIndex !== void 0) {
|
|
29
|
+
result += `svr=${this.serverIndex};`;
|
|
30
|
+
}
|
|
31
|
+
if (this.namespaceUri !== void 0) {
|
|
32
|
+
result += `nsu=${this.namespaceUri};`;
|
|
33
|
+
}
|
|
34
|
+
result += this.nodeId.toString();
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
5
39
|
// src/types/nodeId.ts
|
|
6
40
|
var NodeIdType = /* @__PURE__ */ ((NodeIdType2) => {
|
|
7
41
|
NodeIdType2[NodeIdType2["Numeric"] = 0] = "Numeric";
|
|
@@ -172,47 +206,6 @@ var NodeId = class _NodeId {
|
|
|
172
206
|
}
|
|
173
207
|
};
|
|
174
208
|
|
|
175
|
-
// src/types/expandedNodeId.ts
|
|
176
|
-
var ExpandedNodeId = class extends NodeId {
|
|
177
|
-
/**
|
|
178
|
-
* The server index (optional, for cross-server references)
|
|
179
|
-
*/
|
|
180
|
-
serverIndex;
|
|
181
|
-
/**
|
|
182
|
-
* The namespace URI (optional, alternative to namespace index)
|
|
183
|
-
*/
|
|
184
|
-
namespaceUri;
|
|
185
|
-
/**
|
|
186
|
-
* Create a new ExpandedNodeId
|
|
187
|
-
*
|
|
188
|
-
* @param namespace - The namespace index
|
|
189
|
-
* @param identifier - The identifier
|
|
190
|
-
* @param namespaceUri - Optional namespace URI
|
|
191
|
-
* @param serverIndex - Optional server index
|
|
192
|
-
*/
|
|
193
|
-
constructor(namespace = 0, identifier = 0, namespaceUri, serverIndex) {
|
|
194
|
-
super(namespace, identifier);
|
|
195
|
-
this.namespaceUri = namespaceUri;
|
|
196
|
-
this.serverIndex = serverIndex;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Convert ExpandedNodeId to string representation
|
|
200
|
-
*
|
|
201
|
-
* @returns String representation of the ExpandedNodeId
|
|
202
|
-
*/
|
|
203
|
-
toString() {
|
|
204
|
-
let result = "";
|
|
205
|
-
if (this.serverIndex !== void 0) {
|
|
206
|
-
result += `svr=${this.serverIndex};`;
|
|
207
|
-
}
|
|
208
|
-
if (this.namespaceUri !== void 0) {
|
|
209
|
-
result += `nsu=${this.namespaceUri};`;
|
|
210
|
-
}
|
|
211
|
-
result += super.toString();
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
209
|
// src/codecs/encoder.ts
|
|
217
210
|
var Encoder = class {
|
|
218
211
|
encoders = /* @__PURE__ */ new Map();
|
|
@@ -230,7 +223,7 @@ var Encoder = class {
|
|
|
230
223
|
}
|
|
231
224
|
const writer = writerFactory();
|
|
232
225
|
const encodingId = value.getBinaryEncodingId();
|
|
233
|
-
const eid = new ExpandedNodeId(0, encodingId);
|
|
226
|
+
const eid = new ExpandedNodeId(new NodeId(0, encodingId));
|
|
234
227
|
writer.writeExpandedNodeId(eid);
|
|
235
228
|
const typeId = value.getTypeId();
|
|
236
229
|
const encodingFunction = this.encoders.get(typeId);
|
|
@@ -277,7 +270,7 @@ var Decoder = class {
|
|
|
277
270
|
}
|
|
278
271
|
const reader = readerFactory(data);
|
|
279
272
|
const eid = reader.readExpandedNodeId();
|
|
280
|
-
return this.decodeWithEncodingId(eid.identifier, reader);
|
|
273
|
+
return this.decodeWithEncodingId(eid.nodeId.identifier, reader);
|
|
281
274
|
}
|
|
282
275
|
decodeWithEncodingId(encodingId, reader) {
|
|
283
276
|
const decodingInfo = this.encodingIdMap.get(encodingId);
|
|
@@ -493,7 +486,7 @@ function decodeExpandedNodeId(reader) {
|
|
|
493
486
|
if (hasServerIndex) {
|
|
494
487
|
serverIndex = reader.readUInt32();
|
|
495
488
|
}
|
|
496
|
-
return new ExpandedNodeId(nodeId
|
|
489
|
+
return new ExpandedNodeId(nodeId, namespaceUri, serverIndex);
|
|
497
490
|
}
|
|
498
491
|
function encodeExpandedNodeId(writer, value) {
|
|
499
492
|
let extraFlags = 0;
|
|
@@ -504,9 +497,9 @@ function encodeExpandedNodeId(writer, value) {
|
|
|
504
497
|
extraFlags |= ExpandedNodeIdMask.ServerIndexFlag;
|
|
505
498
|
}
|
|
506
499
|
if (extraFlags === 0) {
|
|
507
|
-
encodeNodeId(writer, value);
|
|
500
|
+
encodeNodeId(writer, value.nodeId);
|
|
508
501
|
} else {
|
|
509
|
-
encodeNodeIdWithExtraFlags(writer, value, extraFlags);
|
|
502
|
+
encodeNodeIdWithExtraFlags(writer, value.nodeId, extraFlags);
|
|
510
503
|
}
|
|
511
504
|
if (value.namespaceUri !== void 0) {
|
|
512
505
|
writer.writeString(value.namespaceUri);
|
|
@@ -727,7 +720,7 @@ function encodeLocalizedText(writer, value) {
|
|
|
727
720
|
// src/types/extensionObject.ts
|
|
728
721
|
var ExtensionObject = class _ExtensionObject {
|
|
729
722
|
/**
|
|
730
|
-
* The NodeId that identifies the type of structure encoded in the body.
|
|
723
|
+
* The NodeId (or ExpandedNodeId) that identifies the type of structure encoded in the body.
|
|
731
724
|
*/
|
|
732
725
|
typeId;
|
|
733
726
|
/**
|
|
@@ -1056,7 +1049,7 @@ function decodeExtensionObject(reader, decoder) {
|
|
|
1056
1049
|
}
|
|
1057
1050
|
function encodeExtensionObject(writer, value, encoder) {
|
|
1058
1051
|
const typeId = value.typeId;
|
|
1059
|
-
if (
|
|
1052
|
+
if (typeId instanceof ExpandedNodeId) {
|
|
1060
1053
|
encodeExpandedNodeId(writer, typeId);
|
|
1061
1054
|
} else {
|
|
1062
1055
|
encodeNodeId(writer, typeId);
|
|
@@ -1372,7 +1365,7 @@ function StatusCodeToString(statusCode) {
|
|
|
1372
1365
|
if (statusCode === void 0) {
|
|
1373
1366
|
return "Unknown";
|
|
1374
1367
|
}
|
|
1375
|
-
const baseCode = statusCode & 4294901760;
|
|
1368
|
+
const baseCode = (statusCode & 4294901760) >>> 0;
|
|
1376
1369
|
const name = Object.entries(StatusCode).find(([, v]) => v === baseCode)?.[0];
|
|
1377
1370
|
return name ?? `0x${baseCode.toString(16).toUpperCase().padStart(8, "0")}`;
|
|
1378
1371
|
}
|
|
@@ -1395,7 +1388,7 @@ function StatusCodeGetFlagBits(statusCode) {
|
|
|
1395
1388
|
};
|
|
1396
1389
|
}
|
|
1397
1390
|
function StatusCodeIs(statusCode, expected) {
|
|
1398
|
-
return (statusCode & 4294901760) === expected;
|
|
1391
|
+
return (statusCode & 4294901760) >>> 0 === expected;
|
|
1399
1392
|
}
|
|
1400
1393
|
|
|
1401
1394
|
// src/types/dataValue.ts
|