opcjs-base 0.1.9 → 0.1.13
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 +11 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1551,12 +1551,12 @@ var BinaryReader = class _BinaryReader {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
case 1 /* Binary */: {
|
|
1553
1553
|
const reader = new _BinaryReader(this.readByteString());
|
|
1554
|
-
data = decoder.
|
|
1554
|
+
data = decoder.decodeWithEncodingId(typeId.identifier, reader);
|
|
1555
1555
|
break;
|
|
1556
1556
|
}
|
|
1557
1557
|
case 2 /* Xml */: {
|
|
1558
1558
|
const reader = new XmlReader(this.readString());
|
|
1559
|
-
data = decoder.
|
|
1559
|
+
data = decoder.decodeWithEncodingId(typeId.identifier, reader);
|
|
1560
1560
|
break;
|
|
1561
1561
|
}
|
|
1562
1562
|
}
|
|
@@ -2015,22 +2015,11 @@ var BinaryWriter = class {
|
|
|
2015
2015
|
this.position += 8;
|
|
2016
2016
|
}
|
|
2017
2017
|
writeString(value) {
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
}
|
|
2022
|
-
const utf8Bytes = Buffer.from(value, "utf8");
|
|
2023
|
-
const length = utf8Bytes.length;
|
|
2024
|
-
if (length > 16777216) {
|
|
2025
|
-
throw new CodecError(
|
|
2026
|
-
`String length ${length} exceeds maximum allowed length of 16,777,216 bytes`,
|
|
2027
|
-
{ format: "Binary", suggestedAction: "Reduce string length" }
|
|
2028
|
-
);
|
|
2018
|
+
let encoded = void 0;
|
|
2019
|
+
if (value && value !== "") {
|
|
2020
|
+
encoded = new TextEncoder().encode(value);
|
|
2029
2021
|
}
|
|
2030
|
-
this.
|
|
2031
|
-
this.ensureCapacity(length);
|
|
2032
|
-
utf8Bytes.copy(this.buffer, this.position);
|
|
2033
|
-
this.position += length;
|
|
2022
|
+
this.writeByteString(encoded);
|
|
2034
2023
|
}
|
|
2035
2024
|
writeDateTime(value) {
|
|
2036
2025
|
const jsTimestamp = BigInt(value.getTime());
|
|
@@ -2056,7 +2045,7 @@ var BinaryWriter = class {
|
|
|
2056
2045
|
this.position += 16;
|
|
2057
2046
|
}
|
|
2058
2047
|
writeByteString(value) {
|
|
2059
|
-
if (value
|
|
2048
|
+
if (!value) {
|
|
2060
2049
|
this.writeInt32(-1);
|
|
2061
2050
|
return;
|
|
2062
2051
|
}
|
|
@@ -2067,14 +2056,8 @@ var BinaryWriter = class {
|
|
|
2067
2056
|
{ format: "Binary", suggestedAction: "Reduce ByteString length" }
|
|
2068
2057
|
);
|
|
2069
2058
|
}
|
|
2070
|
-
this.writeInt32(length);
|
|
2071
|
-
this.
|
|
2072
|
-
if (Buffer.isBuffer(value)) {
|
|
2073
|
-
value.copy(this.buffer, this.position);
|
|
2074
|
-
} else {
|
|
2075
|
-
this.buffer.set(value, this.position);
|
|
2076
|
-
}
|
|
2077
|
-
this.position += length;
|
|
2059
|
+
this.writeInt32(value.length);
|
|
2060
|
+
this.writeBytes(value);
|
|
2078
2061
|
}
|
|
2079
2062
|
writeXmlElement(value) {
|
|
2080
2063
|
this.writeString(value);
|
|
@@ -2142,8 +2125,7 @@ var BinaryWriter = class {
|
|
|
2142
2125
|
this.writeByte(5 /* ByteString */);
|
|
2143
2126
|
this.writeUInt16(value.namespace);
|
|
2144
2127
|
const ident = value.identifier;
|
|
2145
|
-
|
|
2146
|
-
this.writeByteString(buf);
|
|
2128
|
+
this.writeByteString(ident);
|
|
2147
2129
|
break;
|
|
2148
2130
|
}
|
|
2149
2131
|
default:
|
|
@@ -2455,7 +2437,7 @@ var BinaryWriter = class {
|
|
|
2455
2437
|
}
|
|
2456
2438
|
}
|
|
2457
2439
|
constructor(initialSize = 1024) {
|
|
2458
|
-
const data =
|
|
2440
|
+
const data = new Uint8Array(initialSize);
|
|
2459
2441
|
this.buffer = data;
|
|
2460
2442
|
this.view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
2461
2443
|
this.position = 0;
|