opcjs-base 0.1.40-alpha → 0.1.41-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 +17 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -19
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.cts
CHANGED
|
@@ -1655,7 +1655,7 @@ interface IWriter {
|
|
|
1655
1655
|
* Binary: Int32 length prefix + bytes
|
|
1656
1656
|
* @param value The byte array; null or undefined is encoded as length -1 (OPC UA null)
|
|
1657
1657
|
*/
|
|
1658
|
-
writeByteString(value:
|
|
1658
|
+
writeByteString(value: Uint8Array | null | undefined): void;
|
|
1659
1659
|
/**
|
|
1660
1660
|
* Encode an XmlElement value.
|
|
1661
1661
|
* Binary: Int32 length prefix + UTF-8 encoded XML
|
package/dist/index.d.ts
CHANGED
|
@@ -1655,7 +1655,7 @@ interface IWriter {
|
|
|
1655
1655
|
* Binary: Int32 length prefix + bytes
|
|
1656
1656
|
* @param value The byte array; null or undefined is encoded as length -1 (OPC UA null)
|
|
1657
1657
|
*/
|
|
1658
|
-
writeByteString(value:
|
|
1658
|
+
writeByteString(value: Uint8Array | null | undefined): void;
|
|
1659
1659
|
/**
|
|
1660
1660
|
* Encode an XmlElement value.
|
|
1661
1661
|
* Binary: Int32 length prefix + UTF-8 encoded XML
|
package/dist/index.js
CHANGED
|
@@ -84,9 +84,7 @@ var NodeId = class _NodeId {
|
|
|
84
84
|
break;
|
|
85
85
|
case 3 /* ByteString */:
|
|
86
86
|
prefix = "b";
|
|
87
|
-
|
|
88
|
-
value = Buffer.from(this.identifier).toString("base64");
|
|
89
|
-
} else {
|
|
87
|
+
{
|
|
90
88
|
const bytes = this.identifier;
|
|
91
89
|
let binary = "";
|
|
92
90
|
for (let i = 0; i < bytes.length; i++) {
|
|
@@ -146,17 +144,14 @@ var NodeId = class _NodeId {
|
|
|
146
144
|
case "g":
|
|
147
145
|
return new _NodeId(namespace, value);
|
|
148
146
|
// GUID as string
|
|
149
|
-
case "b":
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const bytes = new Uint8Array(binary.length);
|
|
155
|
-
for (let i = 0; i < binary.length; i++) {
|
|
156
|
-
bytes[i] = binary.charCodeAt(i);
|
|
157
|
-
}
|
|
158
|
-
return new _NodeId(namespace, bytes);
|
|
147
|
+
case "b": {
|
|
148
|
+
const binary = atob(value);
|
|
149
|
+
const bytes = new Uint8Array(binary.length);
|
|
150
|
+
for (let i = 0; i < binary.length; i++) {
|
|
151
|
+
bytes[i] = binary.charCodeAt(i);
|
|
159
152
|
}
|
|
153
|
+
return new _NodeId(namespace, bytes);
|
|
154
|
+
}
|
|
160
155
|
default:
|
|
161
156
|
throw new Error(`Unknown NodeId type: ${type}`);
|
|
162
157
|
}
|
|
@@ -316,9 +311,7 @@ var CodecError = class _CodecError extends Error {
|
|
|
316
311
|
this.suggestedAction = options?.suggestedAction;
|
|
317
312
|
this.typeName = options?.typeName;
|
|
318
313
|
this.cause = options?.cause;
|
|
319
|
-
|
|
320
|
-
Error.captureStackTrace(this, _CodecError);
|
|
321
|
-
}
|
|
314
|
+
Error.captureStackTrace?.(this, _CodecError);
|
|
322
315
|
}
|
|
323
316
|
/**
|
|
324
317
|
* Returns a detailed error message including all context.
|
|
@@ -901,7 +894,10 @@ var XmlReader = class {
|
|
|
901
894
|
const text = this.getTextContent();
|
|
902
895
|
if (text === "") return null;
|
|
903
896
|
try {
|
|
904
|
-
|
|
897
|
+
const binary = atob(text);
|
|
898
|
+
const bytes = new Uint8Array(binary.length);
|
|
899
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
900
|
+
return bytes;
|
|
905
901
|
} catch {
|
|
906
902
|
throw new CodecError(`Invalid Base64 ByteString: ${text}`);
|
|
907
903
|
}
|
|
@@ -16601,10 +16597,12 @@ var UserTokenTypeEnum = /* @__PURE__ */ ((UserTokenTypeEnum2) => {
|
|
|
16601
16597
|
|
|
16602
16598
|
// src/utils/logger/consoleSink.ts
|
|
16603
16599
|
function isNodeLike() {
|
|
16604
|
-
|
|
16600
|
+
const g = globalThis;
|
|
16601
|
+
return typeof g.process !== "undefined" && typeof g.process?.versions !== "undefined" && typeof g.process?.versions?.node !== "undefined";
|
|
16605
16602
|
}
|
|
16606
16603
|
function supportsAnsiColors() {
|
|
16607
|
-
|
|
16604
|
+
const g = globalThis;
|
|
16605
|
+
return isNodeLike() && !!g.process?.stdout?.isTTY;
|
|
16608
16606
|
}
|
|
16609
16607
|
function pad2(n) {
|
|
16610
16608
|
return n < 10 ? `0${n}` : `${n}`;
|