@homebridge/hap-nodejs 2.3.1-beta.1 → 2.3.1-beta.3
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/README.md +13 -4
- package/dist/accessories/types.d.ts +0 -1
- package/dist/hap.d.ts +1 -1
- package/dist/hap.js +6 -4
- package/dist/hap.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +6 -7
- package/dist/internal-types.js +1 -5
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +53 -25
- package/dist/lib/Accessory.js +289 -171
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +37 -18
- package/dist/lib/Advertiser.js +143 -62
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +1 -2
- package/dist/lib/Bridge.js +1 -1
- package/dist/lib/Characteristic.d.ts +19 -20
- package/dist/lib/Characteristic.js +187 -153
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +19 -13
- package/dist/lib/HAPServer.js +266 -220
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +11 -11
- package/dist/lib/Service.js +54 -37
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +5 -5
- package/dist/lib/camera/RTPProxy.js +48 -23
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +18 -13
- package/dist/lib/camera/RTPStreamManagement.js +247 -216
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +13 -13
- package/dist/lib/camera/RecordingManagement.js +115 -110
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.d.ts +0 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +41 -36
- package/dist/lib/controller/AdaptiveLightingController.js +126 -113
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +17 -17
- package/dist/lib/controller/CameraController.js +30 -26
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +15 -12
- package/dist/lib/controller/Controller.js +0 -1
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +6 -6
- package/dist/lib/controller/DoorbellController.js +10 -3
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +46 -27
- package/dist/lib/controller/RemoteController.js +268 -178
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.d.ts +0 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts +6 -6
- package/dist/lib/datastream/DataStreamManagement.js +30 -26
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +25 -8
- package/dist/lib/datastream/DataStreamParser.js +124 -105
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +47 -23
- package/dist/lib/datastream/DataStreamServer.js +285 -143
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.d.ts +0 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +0 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +578 -578
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +0 -1
- package/dist/lib/definitions/index.d.ts +0 -1
- package/dist/lib/gen/HomeKit.d.ts +0 -1
- package/dist/lib/model/AccessoryInfo.d.ts +5 -6
- package/dist/lib/model/AccessoryInfo.js +23 -19
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +11 -5
- package/dist/lib/model/ControllerStorage.js +34 -8
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPFileStorage.d.ts +20 -2
- package/dist/lib/model/HAPFileStorage.js +59 -10
- package/dist/lib/model/HAPFileStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.d.ts +0 -1
- package/dist/lib/model/HAPStorage.js +6 -3
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +2 -3
- package/dist/lib/model/IdentifierCache.js +26 -13
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +6 -7
- package/dist/lib/tv/AccessControlManagement.js +13 -19
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +1 -2
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/clone.d.ts +0 -1
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts +1 -2
- package/dist/lib/util/color-utils.js +1 -1
- package/dist/lib/util/errors.d.ts +4 -0
- package/dist/lib/util/errors.js +15 -0
- package/dist/lib/util/errors.js.map +1 -0
- package/dist/lib/util/eventedhttp.d.ts +63 -19
- package/dist/lib/util/eventedhttp.js +170 -48
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +1 -2
- package/dist/lib/util/hapCrypto.js +6 -7
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.d.ts +0 -1
- package/dist/lib/util/hapStatusError.js +1 -1
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.d.ts +1 -2
- package/dist/lib/util/net-utils.js +6 -7
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.d.ts +0 -1
- package/dist/lib/util/promise-utils.d.ts +1 -2
- package/dist/lib/util/promise-utils.js +2 -1
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +4 -4
- package/dist/lib/util/request-util.js +29 -28
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +1 -2
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +4 -4
- package/dist/lib/util/tlv.js +16 -5
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +5 -2
- package/dist/lib/util/uuid.js +6 -0
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +20 -17
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -14
- package/dist/accessories/AirConditioner_accessory.d.ts +0 -2
- package/dist/accessories/AirConditioner_accessory.d.ts.map +0 -1
- package/dist/accessories/AirConditioner_accessory.js +0 -126
- package/dist/accessories/AirConditioner_accessory.js.map +0 -1
- package/dist/accessories/AppleTVRemote_accessory.d.ts +0 -2
- package/dist/accessories/AppleTVRemote_accessory.d.ts.map +0 -1
- package/dist/accessories/AppleTVRemote_accessory.js +0 -146
- package/dist/accessories/AppleTVRemote_accessory.js.map +0 -1
- package/dist/accessories/Camera_accessory.d.ts +0 -2
- package/dist/accessories/Camera_accessory.d.ts.map +0 -1
- package/dist/accessories/Camera_accessory.js +0 -562
- package/dist/accessories/Camera_accessory.js.map +0 -1
- package/dist/accessories/Fan_accessory.d.ts +0 -2
- package/dist/accessories/Fan_accessory.d.ts.map +0 -1
- package/dist/accessories/Fan_accessory.js +0 -71
- package/dist/accessories/Fan_accessory.js.map +0 -1
- package/dist/accessories/GarageDoorOpener_accessory.d.ts +0 -2
- package/dist/accessories/GarageDoorOpener_accessory.d.ts.map +0 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +0 -76
- package/dist/accessories/GarageDoorOpener_accessory.js.map +0 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +0 -2
- package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +0 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +0 -103
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +0 -1
- package/dist/accessories/Light_accessory.d.ts +0 -2
- package/dist/accessories/Light_accessory.d.ts.map +0 -1
- package/dist/accessories/Light_accessory.js +0 -143
- package/dist/accessories/Light_accessory.js.map +0 -1
- package/dist/accessories/Lock_accessory.d.ts +0 -2
- package/dist/accessories/Lock_accessory.d.ts.map +0 -1
- package/dist/accessories/Lock_accessory.js +0 -74
- package/dist/accessories/Lock_accessory.js.map +0 -1
- package/dist/accessories/MotionSensor_accessory.d.ts +0 -2
- package/dist/accessories/MotionSensor_accessory.d.ts.map +0 -1
- package/dist/accessories/MotionSensor_accessory.js +0 -43
- package/dist/accessories/MotionSensor_accessory.js.map +0 -1
- package/dist/accessories/Outlet_accessory.d.ts +0 -2
- package/dist/accessories/Outlet_accessory.d.ts.map +0 -1
- package/dist/accessories/Outlet_accessory.js +0 -77
- package/dist/accessories/Outlet_accessory.js.map +0 -1
- package/dist/accessories/SmartSpeaker_accessory.d.ts +0 -2
- package/dist/accessories/SmartSpeaker_accessory.d.ts.map +0 -1
- package/dist/accessories/SmartSpeaker_accessory.js +0 -42
- package/dist/accessories/SmartSpeaker_accessory.js.map +0 -1
- package/dist/accessories/Sprinkler_accessory.d.ts +0 -2
- package/dist/accessories/Sprinkler_accessory.d.ts.map +0 -1
- package/dist/accessories/Sprinkler_accessory.js +0 -126
- package/dist/accessories/Sprinkler_accessory.js.map +0 -1
- package/dist/accessories/TV_accessory.d.ts +0 -2
- package/dist/accessories/TV_accessory.d.ts.map +0 -1
- package/dist/accessories/TV_accessory.js +0 -99
- package/dist/accessories/TV_accessory.js.map +0 -1
- package/dist/accessories/TemperatureSensor_accessory.d.ts +0 -2
- package/dist/accessories/TemperatureSensor_accessory.d.ts.map +0 -1
- package/dist/accessories/TemperatureSensor_accessory.js +0 -42
- package/dist/accessories/TemperatureSensor_accessory.js.map +0 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts +0 -3
- package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +0 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +0 -14
- package/dist/accessories/Wi-FiRouter_accessory.js.map +0 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts +0 -3
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +0 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +0 -16
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +0 -1
- package/dist/accessories/gstreamer-audioProducer.d.ts +0 -25
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +0 -1
- package/dist/accessories/gstreamer-audioProducer.js +0 -145
- package/dist/accessories/gstreamer-audioProducer.js.map +0 -1
- package/dist/accessories/types.d.ts.map +0 -1
- package/dist/hap.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal-types.d.ts.map +0 -1
- package/dist/lib/Accessory.d.ts.map +0 -1
- package/dist/lib/Advertiser.d.ts.map +0 -1
- package/dist/lib/Bridge.d.ts.map +0 -1
- package/dist/lib/Characteristic.d.ts.map +0 -1
- package/dist/lib/HAPServer.d.ts.map +0 -1
- package/dist/lib/Service.d.ts.map +0 -1
- package/dist/lib/camera/RTPProxy.d.ts.map +0 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +0 -1
- package/dist/lib/camera/RecordingManagement.d.ts.map +0 -1
- package/dist/lib/camera/index.d.ts.map +0 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +0 -1
- package/dist/lib/controller/CameraController.d.ts.map +0 -1
- package/dist/lib/controller/Controller.d.ts.map +0 -1
- package/dist/lib/controller/DoorbellController.d.ts.map +0 -1
- package/dist/lib/controller/RemoteController.d.ts.map +0 -1
- package/dist/lib/controller/index.d.ts.map +0 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts.map +0 -1
- package/dist/lib/datastream/DataStreamParser.d.ts.map +0 -1
- package/dist/lib/datastream/DataStreamServer.d.ts.map +0 -1
- package/dist/lib/datastream/index.d.ts.map +0 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +0 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +0 -1
- package/dist/lib/definitions/generate-definitions.d.ts +0 -34
- package/dist/lib/definitions/generate-definitions.d.ts.map +0 -1
- package/dist/lib/definitions/generate-definitions.js +0 -624
- package/dist/lib/definitions/generate-definitions.js.map +0 -1
- package/dist/lib/definitions/generator-configuration.d.ts +0 -22
- package/dist/lib/definitions/generator-configuration.d.ts.map +0 -1
- package/dist/lib/definitions/generator-configuration.js +0 -674
- package/dist/lib/definitions/generator-configuration.js.map +0 -1
- package/dist/lib/definitions/index.d.ts.map +0 -1
- package/dist/lib/gen/HomeKit.d.ts.map +0 -1
- package/dist/lib/model/AccessoryInfo.d.ts.map +0 -1
- package/dist/lib/model/ControllerStorage.d.ts.map +0 -1
- package/dist/lib/model/HAPFileStorage.d.ts.map +0 -1
- package/dist/lib/model/HAPStorage.d.ts.map +0 -1
- package/dist/lib/model/IdentifierCache.d.ts.map +0 -1
- package/dist/lib/tv/AccessControlManagement.d.ts.map +0 -1
- package/dist/lib/util/checkName.d.ts.map +0 -1
- package/dist/lib/util/clone.d.ts.map +0 -1
- package/dist/lib/util/color-utils.d.ts.map +0 -1
- package/dist/lib/util/eventedhttp.d.ts.map +0 -1
- package/dist/lib/util/hapCrypto.d.ts.map +0 -1
- package/dist/lib/util/hapStatusError.d.ts.map +0 -1
- package/dist/lib/util/net-utils.d.ts.map +0 -1
- package/dist/lib/util/once.d.ts.map +0 -1
- package/dist/lib/util/promise-utils.d.ts.map +0 -1
- package/dist/lib/util/request-util.d.ts.map +0 -1
- package/dist/lib/util/time.d.ts.map +0 -1
- package/dist/lib/util/tlv.d.ts.map +0 -1
- package/dist/lib/util/uuid.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -4,7 +4,7 @@ import createDebug from 'debug';
|
|
|
4
4
|
import * as hapCrypto from '../util/hapCrypto.js';
|
|
5
5
|
import * as uuid from '../util/uuid.js';
|
|
6
6
|
// welcome to hell :)
|
|
7
|
-
// in this file lies madness and frustration. and
|
|
7
|
+
// in this file lies madness and frustration. and it's not only about HDS. Also, JavaScript is hell
|
|
8
8
|
const debug = createDebug('HAP-NodeJS:DataStream:Parser');
|
|
9
9
|
class Magics {
|
|
10
10
|
static TERMINATOR = { type: 'terminator' };
|
|
@@ -68,7 +68,6 @@ export class UUID extends ValueWrapper {
|
|
|
68
68
|
/**
|
|
69
69
|
* @group HomeKit Data Streams (HDS)
|
|
70
70
|
*/
|
|
71
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
72
71
|
export var DataFormatTags;
|
|
73
72
|
(function (DataFormatTags) {
|
|
74
73
|
DataFormatTags[DataFormatTags["INVALID"] = 0] = "INVALID";
|
|
@@ -80,7 +79,7 @@ export var DataFormatTags;
|
|
|
80
79
|
DataFormatTags[DataFormatTags["DATE"] = 6] = "DATE";
|
|
81
80
|
DataFormatTags[DataFormatTags["INTEGER_MINUS_ONE"] = 7] = "INTEGER_MINUS_ONE";
|
|
82
81
|
DataFormatTags[DataFormatTags["INTEGER_RANGE_START_0"] = 8] = "INTEGER_RANGE_START_0";
|
|
83
|
-
DataFormatTags[DataFormatTags["INTEGER_RANGE_STOP_39"] =
|
|
82
|
+
DataFormatTags[DataFormatTags["INTEGER_RANGE_STOP_39"] = 47] = "INTEGER_RANGE_STOP_39";
|
|
84
83
|
DataFormatTags[DataFormatTags["INT8"] = 48] = "INT8";
|
|
85
84
|
DataFormatTags[DataFormatTags["INT16LE"] = 49] = "INT16LE";
|
|
86
85
|
DataFormatTags[DataFormatTags["INT32LE"] = 50] = "INT32LE";
|
|
@@ -114,133 +113,160 @@ export var DataFormatTags;
|
|
|
114
113
|
* @group HomeKit Data Streams (HDS)
|
|
115
114
|
*/
|
|
116
115
|
export class DataStreamParser {
|
|
116
|
+
/**
|
|
117
|
+
* How many arrays and dictionaries may be nested into each other. A real message is only a few levels deep,
|
|
118
|
+
* while a message made of nothing but array tags would otherwise use up the call stack.
|
|
119
|
+
*/
|
|
120
|
+
static MAX_NESTING_DEPTH = 32;
|
|
117
121
|
static decode(buffer) {
|
|
122
|
+
return this.decodeValue(buffer, 0);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Decodes the next value, which must not be a terminator.
|
|
126
|
+
* @param buffer - The reader to take the value from.
|
|
127
|
+
* @param depth - The number of arrays and dictionaries around this value.
|
|
128
|
+
*/
|
|
129
|
+
static decodeValue(buffer, depth) {
|
|
130
|
+
const value = this.decodeNext(buffer, depth);
|
|
131
|
+
// a terminator only has a meaning where an array or a dictionary without a length looks for its end
|
|
132
|
+
if (value === Magics.TERMINATOR) {
|
|
133
|
+
throw new Error(`HDSDecoder: unexpected terminator tag on index ${buffer.readerIndex - 1}`);
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Decodes the next value. Unlike {@link decodeValue} it returns the terminator marker for a terminator tag.
|
|
139
|
+
*/
|
|
140
|
+
static decodeNext(buffer, depth) {
|
|
118
141
|
const tag = buffer.readTag();
|
|
119
|
-
if (tag
|
|
142
|
+
if (tag >= DataFormatTags.ARRAY_LENGTH_START && tag <= DataFormatTags.DICTIONARY_TERMINATED && depth >= this.MAX_NESTING_DEPTH) {
|
|
143
|
+
throw new Error(`HDSDecoder: arrays and dictionaries are nested more than ${this.MAX_NESTING_DEPTH} levels deep on index ${buffer.readerIndex - 1}`);
|
|
144
|
+
}
|
|
145
|
+
if (tag === DataFormatTags.INVALID) {
|
|
120
146
|
throw new Error(`HDSDecoder: zero tag detected on index ${buffer.readerIndex}`);
|
|
121
147
|
}
|
|
122
|
-
else if (tag ===
|
|
148
|
+
else if (tag === DataFormatTags.TRUE) {
|
|
123
149
|
return buffer.readTrue();
|
|
124
150
|
}
|
|
125
|
-
else if (tag ===
|
|
151
|
+
else if (tag === DataFormatTags.FALSE) {
|
|
126
152
|
return buffer.readFalse();
|
|
127
153
|
}
|
|
128
|
-
else if (tag ===
|
|
154
|
+
else if (tag === DataFormatTags.TERMINATOR) {
|
|
129
155
|
return Magics.TERMINATOR;
|
|
130
156
|
}
|
|
131
|
-
else if (tag ===
|
|
157
|
+
else if (tag === DataFormatTags.NULL) {
|
|
132
158
|
return null;
|
|
133
159
|
}
|
|
134
|
-
else if (tag ===
|
|
160
|
+
else if (tag === DataFormatTags.UUID) {
|
|
135
161
|
return buffer.readUUID();
|
|
136
162
|
}
|
|
137
|
-
else if (tag ===
|
|
163
|
+
else if (tag === DataFormatTags.DATE) {
|
|
138
164
|
return buffer.readSecondsSince2001_01_01();
|
|
139
165
|
}
|
|
140
|
-
else if (tag ===
|
|
166
|
+
else if (tag === DataFormatTags.INTEGER_MINUS_ONE) {
|
|
141
167
|
return buffer.readNegOne();
|
|
142
168
|
}
|
|
143
|
-
else if (tag >=
|
|
169
|
+
else if (tag >= DataFormatTags.INTEGER_RANGE_START_0 && tag <= DataFormatTags.INTEGER_RANGE_STOP_39) {
|
|
144
170
|
return buffer.readIntRange(tag); // integer values from 0-39
|
|
145
171
|
}
|
|
146
|
-
else if (tag ===
|
|
172
|
+
else if (tag === DataFormatTags.INT8) {
|
|
147
173
|
return buffer.readInt8();
|
|
148
174
|
}
|
|
149
|
-
else if (tag ===
|
|
175
|
+
else if (tag === DataFormatTags.INT16LE) {
|
|
150
176
|
return buffer.readInt16LE();
|
|
151
177
|
}
|
|
152
|
-
else if (tag ===
|
|
178
|
+
else if (tag === DataFormatTags.INT32LE) {
|
|
153
179
|
return buffer.readInt32LE();
|
|
154
180
|
}
|
|
155
|
-
else if (tag ===
|
|
181
|
+
else if (tag === DataFormatTags.INT64LE) {
|
|
156
182
|
return buffer.readInt64LE();
|
|
157
183
|
}
|
|
158
|
-
else if (tag ===
|
|
184
|
+
else if (tag === DataFormatTags.FLOAT32LE) {
|
|
159
185
|
return buffer.readFloat32LE();
|
|
160
186
|
}
|
|
161
|
-
else if (tag ===
|
|
187
|
+
else if (tag === DataFormatTags.FLOAT64LE) {
|
|
162
188
|
return buffer.readFloat64LE();
|
|
163
189
|
}
|
|
164
|
-
else if (tag >=
|
|
165
|
-
const length = tag -
|
|
190
|
+
else if (tag >= DataFormatTags.UTF8_LENGTH_START && tag <= DataFormatTags.UTF8_LENGTH_STOP) {
|
|
191
|
+
const length = tag - DataFormatTags.UTF8_LENGTH_START;
|
|
166
192
|
if (length === 0) {
|
|
167
193
|
return ''; // a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
|
|
168
194
|
}
|
|
169
195
|
return buffer.readUTF8(length);
|
|
170
196
|
}
|
|
171
|
-
else if (tag ===
|
|
197
|
+
else if (tag === DataFormatTags.UTF8_LENGTH8) {
|
|
172
198
|
return buffer.readUTF8_Length8();
|
|
173
199
|
}
|
|
174
|
-
else if (tag ===
|
|
200
|
+
else if (tag === DataFormatTags.UTF8_LENGTH16LE) {
|
|
175
201
|
return buffer.readUTF8_Length16LE();
|
|
176
202
|
}
|
|
177
|
-
else if (tag ===
|
|
203
|
+
else if (tag === DataFormatTags.UTF8_LENGTH32LE) {
|
|
178
204
|
return buffer.readUTF8_Length32LE();
|
|
179
205
|
}
|
|
180
|
-
else if (tag ===
|
|
206
|
+
else if (tag === DataFormatTags.UTF8_LENGTH64LE) {
|
|
181
207
|
return buffer.readUTF8_Length64LE();
|
|
182
208
|
}
|
|
183
|
-
else if (tag ===
|
|
209
|
+
else if (tag === DataFormatTags.UTF8_NULL_TERMINATED) {
|
|
184
210
|
return buffer.readUTF8_NULL_terminated();
|
|
185
211
|
}
|
|
186
|
-
else if (tag >=
|
|
187
|
-
const length = tag -
|
|
212
|
+
else if (tag >= DataFormatTags.DATA_LENGTH_START && tag <= DataFormatTags.DATA_LENGTH_STOP) {
|
|
213
|
+
const length = tag - DataFormatTags.DATA_LENGTH_START;
|
|
188
214
|
if (length === 0) {
|
|
189
215
|
return Buffer.alloc(0); // a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
|
|
190
216
|
}
|
|
191
217
|
return buffer.readData(length);
|
|
192
218
|
}
|
|
193
|
-
else if (tag ===
|
|
219
|
+
else if (tag === DataFormatTags.DATA_LENGTH8) {
|
|
194
220
|
return buffer.readData_Length8();
|
|
195
221
|
}
|
|
196
|
-
else if (tag ===
|
|
222
|
+
else if (tag === DataFormatTags.DATA_LENGTH16LE) {
|
|
197
223
|
return buffer.readData_Length16LE();
|
|
198
224
|
}
|
|
199
|
-
else if (tag ===
|
|
225
|
+
else if (tag === DataFormatTags.DATA_LENGTH32LE) {
|
|
200
226
|
return buffer.readData_Length32LE();
|
|
201
227
|
}
|
|
202
|
-
else if (tag ===
|
|
228
|
+
else if (tag === DataFormatTags.DATA_LENGTH64LE) {
|
|
203
229
|
return buffer.readData_Length64LE();
|
|
204
230
|
}
|
|
205
|
-
else if (tag ===
|
|
231
|
+
else if (tag === DataFormatTags.DATA_TERMINATED) {
|
|
206
232
|
return buffer.readData_terminated();
|
|
207
233
|
}
|
|
208
|
-
else if (tag >=
|
|
209
|
-
const index = tag -
|
|
234
|
+
else if (tag >= DataFormatTags.COMPRESSION_START && tag <= DataFormatTags.COMPRESSION_STOP) {
|
|
235
|
+
const index = tag - DataFormatTags.COMPRESSION_START;
|
|
210
236
|
return buffer.decompressData(index);
|
|
211
237
|
}
|
|
212
|
-
else if (tag >=
|
|
213
|
-
const length = tag -
|
|
238
|
+
else if (tag >= DataFormatTags.ARRAY_LENGTH_START && tag <= DataFormatTags.ARRAY_LENGTH_STOP) {
|
|
239
|
+
const length = tag - DataFormatTags.ARRAY_LENGTH_START;
|
|
214
240
|
const array = [];
|
|
215
241
|
for (let i = 0; i < length; i++) {
|
|
216
|
-
array.push(this.
|
|
242
|
+
array.push(this.decodeValue(buffer, depth + 1));
|
|
217
243
|
}
|
|
218
244
|
return array;
|
|
219
245
|
}
|
|
220
|
-
else if (tag ===
|
|
246
|
+
else if (tag === DataFormatTags.ARRAY_TERMINATED) {
|
|
221
247
|
const array = [];
|
|
222
248
|
let element;
|
|
223
249
|
// eslint-disable-next-line no-cond-assign
|
|
224
|
-
while ((element = this.
|
|
250
|
+
while ((element = this.decodeNext(buffer, depth + 1)) !== Magics.TERMINATOR) {
|
|
225
251
|
array.push(element);
|
|
226
252
|
}
|
|
227
253
|
return array;
|
|
228
254
|
}
|
|
229
|
-
else if (tag >=
|
|
230
|
-
const length = tag -
|
|
255
|
+
else if (tag >= DataFormatTags.DICTIONARY_LENGTH_START && tag <= DataFormatTags.DICTIONARY_LENGTH_STOP) {
|
|
256
|
+
const length = tag - DataFormatTags.DICTIONARY_LENGTH_START;
|
|
231
257
|
const dictionary = {};
|
|
232
258
|
for (let i = 0; i < length; i++) {
|
|
233
|
-
const key = this.
|
|
234
|
-
dictionary
|
|
259
|
+
const key = this.decodeValue(buffer, depth + 1);
|
|
260
|
+
this.setDictionaryEntry(dictionary, key, this.decodeValue(buffer, depth + 1));
|
|
235
261
|
}
|
|
236
262
|
return dictionary;
|
|
237
263
|
}
|
|
238
|
-
else if (tag ===
|
|
264
|
+
else if (tag === DataFormatTags.DICTIONARY_TERMINATED) {
|
|
239
265
|
const dictionary = {};
|
|
240
266
|
let key;
|
|
241
267
|
// eslint-disable-next-line no-cond-assign
|
|
242
|
-
while ((key = this.
|
|
243
|
-
dictionary
|
|
268
|
+
while ((key = this.decodeNext(buffer, depth + 1)) !== Magics.TERMINATOR) {
|
|
269
|
+
this.setDictionaryEntry(dictionary, key, this.decodeValue(buffer, depth + 1));
|
|
244
270
|
}
|
|
245
271
|
return dictionary;
|
|
246
272
|
}
|
|
@@ -248,13 +274,25 @@ export class DataStreamParser {
|
|
|
248
274
|
throw new Error(`HDSDecoder: encountered unknown tag on index ${buffer.readerIndex}: ${tag.toString(16)}`);
|
|
249
275
|
}
|
|
250
276
|
}
|
|
251
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Stores a decoded entry as an own property of the dictionary.
|
|
279
|
+
* A key is a string on the wire, as the writer only writes strings; anything else is named by its string form.
|
|
280
|
+
*/
|
|
281
|
+
static setDictionaryEntry(dictionary, key, value) {
|
|
282
|
+
// a plain assignment to the key `__proto__` would replace the prototype of the dictionary instead of storing the value
|
|
283
|
+
Object.defineProperty(dictionary, String(key), {
|
|
284
|
+
value,
|
|
285
|
+
writable: true,
|
|
286
|
+
enumerable: true,
|
|
287
|
+
configurable: true,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
252
290
|
static encode(data, buffer) {
|
|
253
291
|
if (data === undefined) {
|
|
254
292
|
throw new Error('HDSEncoder: cannot encode undefined');
|
|
255
293
|
}
|
|
256
294
|
if (data === null) {
|
|
257
|
-
buffer.writeTag(
|
|
295
|
+
buffer.writeTag(DataFormatTags.NULL);
|
|
258
296
|
return;
|
|
259
297
|
}
|
|
260
298
|
switch (typeof data) {
|
|
@@ -281,16 +319,16 @@ export class DataStreamParser {
|
|
|
281
319
|
if (Array.isArray(data)) {
|
|
282
320
|
const length = data.length;
|
|
283
321
|
if (length <= 12) {
|
|
284
|
-
buffer.writeTag(
|
|
322
|
+
buffer.writeTag(DataFormatTags.ARRAY_LENGTH_START + length);
|
|
285
323
|
}
|
|
286
324
|
else {
|
|
287
|
-
buffer.writeTag(
|
|
325
|
+
buffer.writeTag(DataFormatTags.ARRAY_TERMINATED);
|
|
288
326
|
}
|
|
289
327
|
data.forEach((element) => {
|
|
290
328
|
this.encode(element, buffer);
|
|
291
329
|
});
|
|
292
330
|
if (length > 12) {
|
|
293
|
-
buffer.writeTag(
|
|
331
|
+
buffer.writeTag(DataFormatTags.TERMINATOR);
|
|
294
332
|
}
|
|
295
333
|
}
|
|
296
334
|
else if (data instanceof ValueWrapper) {
|
|
@@ -329,17 +367,17 @@ export class DataStreamParser {
|
|
|
329
367
|
const entries = Object.entries(data)
|
|
330
368
|
.filter(entry => entry[1] !== undefined); // explicitly setting undefined will result in an entry here
|
|
331
369
|
if (entries.length <= 14) {
|
|
332
|
-
buffer.writeTag(
|
|
370
|
+
buffer.writeTag(DataFormatTags.DICTIONARY_LENGTH_START + entries.length);
|
|
333
371
|
}
|
|
334
372
|
else {
|
|
335
|
-
buffer.writeTag(
|
|
373
|
+
buffer.writeTag(DataFormatTags.DICTIONARY_TERMINATED);
|
|
336
374
|
}
|
|
337
375
|
entries.forEach((entry) => {
|
|
338
376
|
this.encode(entry[0], buffer); // encode key
|
|
339
377
|
this.encode(entry[1], buffer); // encode value
|
|
340
378
|
});
|
|
341
379
|
if (entries.length > 14) {
|
|
342
|
-
buffer.writeTag(
|
|
380
|
+
buffer.writeTag(DataFormatTags.TERMINATOR);
|
|
343
381
|
}
|
|
344
382
|
}
|
|
345
383
|
break;
|
|
@@ -362,7 +400,7 @@ export class DataStreamReader {
|
|
|
362
400
|
finished() {
|
|
363
401
|
if (this.readerIndex < this.data.length) {
|
|
364
402
|
const remainingHex = this.data.subarray(this.readerIndex, this.data.length).toString('hex');
|
|
365
|
-
debug('WARNING Finished reading HDS stream, but there are still %d bytes remaining
|
|
403
|
+
debug('WARNING Finished reading HDS stream, but there are still %d bytes remaining: %s', this.data.length - this.readerIndex, remainingHex);
|
|
366
404
|
}
|
|
367
405
|
}
|
|
368
406
|
decompressData(index) {
|
|
@@ -405,7 +443,7 @@ export class DataStreamReader {
|
|
|
405
443
|
return -1;
|
|
406
444
|
}
|
|
407
445
|
readIntRange(tag) {
|
|
408
|
-
return tag -
|
|
446
|
+
return tag - DataFormatTags.INTEGER_RANGE_START_0; // integer values from 0-39
|
|
409
447
|
}
|
|
410
448
|
readInt8() {
|
|
411
449
|
this.ensureLength(1);
|
|
@@ -539,7 +577,7 @@ export class DataStreamReader {
|
|
|
539
577
|
if (nextByte === undefined) {
|
|
540
578
|
throw new Error('HDSDecoder: Reached end of data stream while reading terminated data!');
|
|
541
579
|
}
|
|
542
|
-
else if (nextByte ===
|
|
580
|
+
else if (nextByte === DataFormatTags.TERMINATOR) {
|
|
543
581
|
break;
|
|
544
582
|
}
|
|
545
583
|
else {
|
|
@@ -625,7 +663,7 @@ export class DataStreamWriter {
|
|
|
625
663
|
}
|
|
626
664
|
else if (index <= DataStreamWriter.maxDirectReferenceIndex) {
|
|
627
665
|
// data was already written and the index is in the applicable range => shorten the payload
|
|
628
|
-
this.writeTag(
|
|
666
|
+
this.writeTag(DataFormatTags.COMPRESSION_START + index);
|
|
629
667
|
return true;
|
|
630
668
|
}
|
|
631
669
|
return false;
|
|
@@ -635,17 +673,17 @@ export class DataStreamWriter {
|
|
|
635
673
|
this.data.writeUInt8(tag, this.writerIndex++);
|
|
636
674
|
}
|
|
637
675
|
writeTrue() {
|
|
638
|
-
this.writeTag(
|
|
676
|
+
this.writeTag(DataFormatTags.TRUE);
|
|
639
677
|
}
|
|
640
678
|
writeFalse() {
|
|
641
|
-
this.writeTag(
|
|
679
|
+
this.writeTag(DataFormatTags.FALSE);
|
|
642
680
|
}
|
|
643
681
|
writeNumber(number) {
|
|
644
682
|
if (number === -1) {
|
|
645
|
-
this.writeTag(
|
|
683
|
+
this.writeTag(DataFormatTags.INTEGER_MINUS_ONE);
|
|
646
684
|
}
|
|
647
685
|
else if (number >= 0 && number <= 39) {
|
|
648
|
-
this.writeTag(
|
|
686
|
+
this.writeTag(DataFormatTags.INTEGER_RANGE_START_0 + number);
|
|
649
687
|
}
|
|
650
688
|
else if (number >= -128 && number <= 127) {
|
|
651
689
|
this.writeInt8(new Int8(number));
|
|
@@ -656,7 +694,7 @@ export class DataStreamWriter {
|
|
|
656
694
|
else if (number >= -2147483648 && number <= 2147483647) {
|
|
657
695
|
this.writeInt32LE(new Int32(number));
|
|
658
696
|
}
|
|
659
|
-
else if (number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER) { //
|
|
697
|
+
else if (number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER) { // a number can't hold a larger integer exactly
|
|
660
698
|
this.writeInt64LE(new Int64(number));
|
|
661
699
|
}
|
|
662
700
|
else {
|
|
@@ -668,7 +706,7 @@ export class DataStreamWriter {
|
|
|
668
706
|
return;
|
|
669
707
|
}
|
|
670
708
|
this.ensureLength(2);
|
|
671
|
-
this.writeTag(
|
|
709
|
+
this.writeTag(DataFormatTags.INT8);
|
|
672
710
|
this.data.writeInt8(int8.value, this.writerIndex++);
|
|
673
711
|
}
|
|
674
712
|
writeInt16LE(int16) {
|
|
@@ -676,7 +714,7 @@ export class DataStreamWriter {
|
|
|
676
714
|
return;
|
|
677
715
|
}
|
|
678
716
|
this.ensureLength(3);
|
|
679
|
-
this.writeTag(
|
|
717
|
+
this.writeTag(DataFormatTags.INT16LE);
|
|
680
718
|
this.data.writeInt16LE(int16.value, this.writerIndex);
|
|
681
719
|
this.writerIndex += 2;
|
|
682
720
|
}
|
|
@@ -685,7 +723,7 @@ export class DataStreamWriter {
|
|
|
685
723
|
return;
|
|
686
724
|
}
|
|
687
725
|
this.ensureLength(5);
|
|
688
|
-
this.writeTag(
|
|
726
|
+
this.writeTag(DataFormatTags.INT32LE);
|
|
689
727
|
this.data.writeInt32LE(int32.value, this.writerIndex);
|
|
690
728
|
this.writerIndex += 4;
|
|
691
729
|
}
|
|
@@ -694,9 +732,8 @@ export class DataStreamWriter {
|
|
|
694
732
|
return;
|
|
695
733
|
}
|
|
696
734
|
this.ensureLength(9);
|
|
697
|
-
this.writeTag(
|
|
698
|
-
this.data.
|
|
699
|
-
this.data.writeUInt32LE(0, this.writerIndex + 4);
|
|
735
|
+
this.writeTag(DataFormatTags.INT64LE);
|
|
736
|
+
this.data.writeBigInt64LE(BigInt(Math.trunc(int64.value)), this.writerIndex);
|
|
700
737
|
this.writerIndex += 8;
|
|
701
738
|
}
|
|
702
739
|
writeFloat32LE(float32) {
|
|
@@ -704,7 +741,7 @@ export class DataStreamWriter {
|
|
|
704
741
|
return;
|
|
705
742
|
}
|
|
706
743
|
this.ensureLength(5);
|
|
707
|
-
this.writeTag(
|
|
744
|
+
this.writeTag(DataFormatTags.FLOAT32LE);
|
|
708
745
|
this.data.writeFloatLE(float32.value, this.writerIndex);
|
|
709
746
|
this.writerIndex += 4;
|
|
710
747
|
}
|
|
@@ -713,7 +750,7 @@ export class DataStreamWriter {
|
|
|
713
750
|
return;
|
|
714
751
|
}
|
|
715
752
|
this.ensureLength(9);
|
|
716
|
-
this.writeTag(
|
|
753
|
+
this.writeTag(DataFormatTags.FLOAT64LE);
|
|
717
754
|
this.data.writeDoubleLE(float64.value, this.writerIndex);
|
|
718
755
|
this.writerIndex += 8;
|
|
719
756
|
}
|
|
@@ -739,7 +776,7 @@ export class DataStreamWriter {
|
|
|
739
776
|
writeUTF8(utf8) {
|
|
740
777
|
if (utf8.length === 0) {
|
|
741
778
|
// a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
|
|
742
|
-
this.writeTag(
|
|
779
|
+
this.writeTag(DataFormatTags.UTF8_LENGTH_START);
|
|
743
780
|
return;
|
|
744
781
|
}
|
|
745
782
|
if (this.compressDataIfPossible(utf8)) {
|
|
@@ -748,7 +785,7 @@ export class DataStreamWriter {
|
|
|
748
785
|
const length = Buffer.byteLength(utf8);
|
|
749
786
|
if (length <= 32) {
|
|
750
787
|
this.ensureLength(1 + length);
|
|
751
|
-
this.writeTag(
|
|
788
|
+
this.writeTag(DataFormatTags.UTF8_LENGTH_START + length);
|
|
752
789
|
this._writeUTF8(utf8);
|
|
753
790
|
}
|
|
754
791
|
else if (length <= 255) {
|
|
@@ -760,12 +797,9 @@ export class DataStreamWriter {
|
|
|
760
797
|
else if (length <= 4294967295) {
|
|
761
798
|
this.writeUTF8_Length32LE(utf8);
|
|
762
799
|
}
|
|
763
|
-
else
|
|
800
|
+
else { // a string can never be longer than a number can count
|
|
764
801
|
this.writeUTF8_Length64LE(utf8);
|
|
765
802
|
}
|
|
766
|
-
else {
|
|
767
|
-
this.writeUTF8_NULL_terminated(utf8);
|
|
768
|
-
}
|
|
769
803
|
}
|
|
770
804
|
_writeUTF8(utf8) {
|
|
771
805
|
const byteLength = Buffer.byteLength(utf8);
|
|
@@ -776,48 +810,42 @@ export class DataStreamWriter {
|
|
|
776
810
|
writeUTF8_Length8(utf8) {
|
|
777
811
|
const length = Buffer.byteLength(utf8);
|
|
778
812
|
this.ensureLength(2 + length);
|
|
779
|
-
this.writeTag(
|
|
813
|
+
this.writeTag(DataFormatTags.UTF8_LENGTH8);
|
|
780
814
|
this.writeLength8(length);
|
|
781
815
|
this._writeUTF8(utf8);
|
|
782
816
|
}
|
|
783
817
|
writeUTF8_Length16LE(utf8) {
|
|
784
818
|
const length = Buffer.byteLength(utf8);
|
|
785
819
|
this.ensureLength(3 + length);
|
|
786
|
-
this.writeTag(
|
|
820
|
+
this.writeTag(DataFormatTags.UTF8_LENGTH16LE);
|
|
787
821
|
this.writeLength16LE(length);
|
|
788
822
|
this._writeUTF8(utf8);
|
|
789
823
|
}
|
|
790
824
|
writeUTF8_Length32LE(utf8) {
|
|
791
825
|
const length = Buffer.byteLength(utf8);
|
|
792
826
|
this.ensureLength(5 + length);
|
|
793
|
-
this.writeTag(
|
|
827
|
+
this.writeTag(DataFormatTags.UTF8_LENGTH32LE);
|
|
794
828
|
this.writeLength32LE(length);
|
|
795
829
|
this._writeUTF8(utf8);
|
|
796
830
|
}
|
|
797
831
|
writeUTF8_Length64LE(utf8) {
|
|
798
832
|
const length = Buffer.byteLength(utf8);
|
|
799
833
|
this.ensureLength(9 + length);
|
|
800
|
-
this.writeTag(
|
|
834
|
+
this.writeTag(DataFormatTags.UTF8_LENGTH64LE);
|
|
801
835
|
this.writeLength64LE(length);
|
|
802
836
|
this._writeUTF8(utf8);
|
|
803
837
|
}
|
|
804
|
-
writeUTF8_NULL_terminated(utf8) {
|
|
805
|
-
this.ensureLength(1 + Buffer.byteLength(utf8) + 1);
|
|
806
|
-
this.writeTag(111 /* DataFormatTags.UTF8_NULL_TERMINATED */);
|
|
807
|
-
this._writeUTF8(utf8);
|
|
808
|
-
this.data.writeUInt8(0, this.writerIndex++);
|
|
809
|
-
}
|
|
810
838
|
writeData(data) {
|
|
811
839
|
if (data.length === 0) {
|
|
812
840
|
// a one-byte value, which is never tracked for back-references (see DataStreamReader.trackData)
|
|
813
|
-
this.writeTag(
|
|
841
|
+
this.writeTag(DataFormatTags.DATA_LENGTH_START);
|
|
814
842
|
return;
|
|
815
843
|
}
|
|
816
844
|
if (this.compressDataIfPossible(data)) {
|
|
817
845
|
return;
|
|
818
846
|
}
|
|
819
847
|
if (data.length <= 32) {
|
|
820
|
-
this.writeTag(
|
|
848
|
+
this.writeTag(DataFormatTags.DATA_LENGTH_START + data.length);
|
|
821
849
|
this._writeData(data);
|
|
822
850
|
}
|
|
823
851
|
else if (data.length <= 255) {
|
|
@@ -829,12 +857,9 @@ export class DataStreamWriter {
|
|
|
829
857
|
else if (data.length <= 4294967295) {
|
|
830
858
|
this.writeData_Length32LE(data);
|
|
831
859
|
}
|
|
832
|
-
else
|
|
860
|
+
else { // a buffer can never be longer than a number can count
|
|
833
861
|
this.writeData_Length64LE(data);
|
|
834
862
|
}
|
|
835
|
-
else {
|
|
836
|
-
this.writeData_terminated(data);
|
|
837
|
-
}
|
|
838
863
|
}
|
|
839
864
|
_writeData(data) {
|
|
840
865
|
this.ensureLength(data.length);
|
|
@@ -844,40 +869,34 @@ export class DataStreamWriter {
|
|
|
844
869
|
}
|
|
845
870
|
writeData_Length8(data) {
|
|
846
871
|
this.ensureLength(2 + data.length);
|
|
847
|
-
this.writeTag(
|
|
872
|
+
this.writeTag(DataFormatTags.DATA_LENGTH8);
|
|
848
873
|
this.writeLength8(data.length);
|
|
849
874
|
this._writeData(data);
|
|
850
875
|
}
|
|
851
876
|
writeData_Length16LE(data) {
|
|
852
877
|
this.ensureLength(3 + data.length);
|
|
853
|
-
this.writeTag(
|
|
878
|
+
this.writeTag(DataFormatTags.DATA_LENGTH16LE);
|
|
854
879
|
this.writeLength16LE(data.length);
|
|
855
880
|
this._writeData(data);
|
|
856
881
|
}
|
|
857
882
|
writeData_Length32LE(data) {
|
|
858
883
|
this.ensureLength(5 + data.length);
|
|
859
|
-
this.writeTag(
|
|
884
|
+
this.writeTag(DataFormatTags.DATA_LENGTH32LE);
|
|
860
885
|
this.writeLength32LE(data.length);
|
|
861
886
|
this._writeData(data);
|
|
862
887
|
}
|
|
863
888
|
writeData_Length64LE(data) {
|
|
864
889
|
this.ensureLength(9 + data.length);
|
|
865
|
-
this.writeTag(
|
|
890
|
+
this.writeTag(DataFormatTags.DATA_LENGTH64LE);
|
|
866
891
|
this.writeLength64LE(data.length);
|
|
867
892
|
this._writeData(data);
|
|
868
893
|
}
|
|
869
|
-
writeData_terminated(data) {
|
|
870
|
-
this.ensureLength(1 + data.length + 1);
|
|
871
|
-
this.writeTag(159 /* DataFormatTags.DATA_TERMINATED */);
|
|
872
|
-
this._writeData(data);
|
|
873
|
-
this.writeTag(3 /* DataFormatTags.TERMINATOR */);
|
|
874
|
-
}
|
|
875
894
|
writeSecondsSince2001_01_01(seconds) {
|
|
876
895
|
if (this.compressDataIfPossible(seconds)) {
|
|
877
896
|
return;
|
|
878
897
|
}
|
|
879
898
|
this.ensureLength(9);
|
|
880
|
-
this.writeTag(
|
|
899
|
+
this.writeTag(DataFormatTags.DATE);
|
|
881
900
|
this.data.writeDoubleLE(seconds.value, this.writerIndex);
|
|
882
901
|
this.writerIndex += 8;
|
|
883
902
|
}
|
|
@@ -887,7 +906,7 @@ export class DataStreamWriter {
|
|
|
887
906
|
return;
|
|
888
907
|
}
|
|
889
908
|
this.ensureLength(17);
|
|
890
|
-
this.writeTag(
|
|
909
|
+
this.writeTag(DataFormatTags.UUID);
|
|
891
910
|
uuid.write(uuid_string, this.data, this.writerIndex);
|
|
892
911
|
this.writerIndex += 16;
|
|
893
912
|
}
|