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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dredless",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "A fully-featured and from-scratch headless drednot.io client implementation written in pure js.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/certainhuman/dredless#readme",
|
package/src/constants.js
CHANGED
|
@@ -44,7 +44,11 @@ export const COMMAND_FIELDS = [
|
|
|
44
44
|
|
|
45
45
|
export const COMMAND_DEFAULT_FORMATS = {
|
|
46
46
|
type: "positive-fixint",
|
|
47
|
-
|
|
47
|
+
// The official client counts commands in a u32 and writes the smallest
|
|
48
|
+
// unsigned format (fixint, then uint8, uint16, uint32). A fixed uint16
|
|
49
|
+
// wrapped the 65,536th command to 0, and the server drops a connection
|
|
50
|
+
// whose command number goes backwards (ProtocolError).
|
|
51
|
+
n: "uint",
|
|
48
52
|
x: "float32",
|
|
49
53
|
y: "float32",
|
|
50
54
|
mx: "float32",
|
|
@@ -90,6 +90,13 @@ function encodeValue(key, value, entry) {
|
|
|
90
90
|
if (typeof value === "number") {
|
|
91
91
|
const schemaFormat = COMMAND_DEFAULT_FORMATS[key];
|
|
92
92
|
let format = schemaFormat && schemaFormat !== "nil" ? schemaFormat : null;
|
|
93
|
+
if (format === "uint") {
|
|
94
|
+
// A narrower format would silently wrap the value.
|
|
95
|
+
if (!Number.isInteger(value) || value < 0 || value > 0xffffffff) {
|
|
96
|
+
throw new RangeError(`Command field ${key} must be an integer from 0 to 4294967295, got ${value}`);
|
|
97
|
+
}
|
|
98
|
+
format = value <= 0x7f ? "positive-fixint" : value <= 0xff ? "uint8" : value <= 0xffff ? "uint16" : "uint32";
|
|
99
|
+
}
|
|
93
100
|
if (!format) {
|
|
94
101
|
if (!Number.isInteger(value)) format = "float32";
|
|
95
102
|
else if (value >= 0) {
|