dredless 1.5.1 → 1.5.2
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.
|
@@ -147,7 +147,11 @@
|
|
|
147
147
|
];
|
|
148
148
|
COMMAND_DEFAULT_FORMATS = {
|
|
149
149
|
type: "positive-fixint",
|
|
150
|
-
|
|
150
|
+
// The official client counts commands in a u32 and writes the smallest
|
|
151
|
+
// unsigned format (fixint, then uint8, uint16, uint32). A fixed uint16
|
|
152
|
+
// wrapped the 65,536th command to 0, and the server drops a connection
|
|
153
|
+
// whose command number goes backwards (ProtocolError).
|
|
154
|
+
n: "uint",
|
|
151
155
|
x: "float32",
|
|
152
156
|
y: "float32",
|
|
153
157
|
mx: "float32",
|
|
@@ -3863,6 +3867,12 @@
|
|
|
3863
3867
|
if (typeof value === "number") {
|
|
3864
3868
|
const schemaFormat = COMMAND_DEFAULT_FORMATS[key];
|
|
3865
3869
|
let format = schemaFormat && schemaFormat !== "nil" ? schemaFormat : null;
|
|
3870
|
+
if (format === "uint") {
|
|
3871
|
+
if (!Number.isInteger(value) || value < 0 || value > 4294967295) {
|
|
3872
|
+
throw new RangeError(`Command field ${key} must be an integer from 0 to 4294967295, got ${value}`);
|
|
3873
|
+
}
|
|
3874
|
+
format = value <= 127 ? "positive-fixint" : value <= 255 ? "uint8" : value <= 65535 ? "uint16" : "uint32";
|
|
3875
|
+
}
|
|
3866
3876
|
if (!format) {
|
|
3867
3877
|
if (!Number.isInteger(value)) format = "float32";
|
|
3868
3878
|
else if (value >= 0) {
|