dredless 1.1.0 → 1.1.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.1.0",
3
+ "version": "1.1.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",
@@ -45,19 +45,13 @@ export const TWO_FIELD_SPEC = {
45
45
 
46
46
  export const LABEL_STATE_SPEC = {
47
47
  name: "label_state",
48
- read(reader, record, mask) {
49
- if (mask & 1) record.blob20 = reader.readBlob();
50
- if (mask & 2) {
51
- if (mask & 1) record.blob24 = reader.readBlob();
52
- else record.q20 = (record.q20 || 0) + reader.readFieldDelta();
53
- }
54
- if (mask & 4) record.q28 = (record.q28 || 0) + reader.readFieldDelta();
55
- if (mask & 8) {
56
- if (mask & 1) record.q32 = (record.q32 || 0) + reader.readFieldDelta();
57
- else record.blob28 = reader.readBlob();
58
- }
59
- if (mask & 16) record.q36 = (record.q36 || 0) + reader.readFieldDelta();
60
- }
48
+ // Packed flag first, two independent text blobs,
49
+ // then two numeric deltas. Field types never depend on another mask bit.
50
+ // Keep the existing summary keys for the strings and colors.
51
+ packedBeforeValues: true,
52
+ packedBits: [{bit: 16, offset: 36}],
53
+ blobs: [{bit: 1, offset: 20}, {bit: 2, offset: 24}],
54
+ fields: numericFields({4: 28, 8: 32})
61
55
  };
62
56
 
63
57
  export const SIMPLE_LABEL_STATE_SPEC = {
@@ -34,7 +34,8 @@ export class ModelReader {
34
34
 
35
35
  readFieldDelta() {
36
36
  const raw = this.readUnsigned();
37
- return (raw & 1) === 0 ? raw / 2 : -(raw >> 1);
37
+ const magnitude = Math.floor(raw / 2);
38
+ return raw % 2 === 0 ? magnitude : -magnitude;
38
39
  }
39
40
 
40
41
  readBlob() {