hap-nodejs 0.12.3-beta.2 → 0.12.3-beta.21

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.
Files changed (175) hide show
  1. package/README.md +1 -0
  2. package/dist/accessories/AirConditioner_accessory.js +24 -24
  3. package/dist/accessories/AirConditioner_accessory.js.map +1 -1
  4. package/dist/accessories/AppleTVRemote_accessory.js +23 -23
  5. package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
  6. package/dist/accessories/Camera_accessory.js +292 -373
  7. package/dist/accessories/Camera_accessory.js.map +1 -1
  8. package/dist/accessories/Fan_accessory.js +15 -21
  9. package/dist/accessories/Fan_accessory.js.map +1 -1
  10. package/dist/accessories/GarageDoorOpener_accessory.js +12 -12
  11. package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
  12. package/dist/accessories/Light-AdaptiveLighting_accessory.js +31 -21
  13. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
  14. package/dist/accessories/Light_accessory.js +45 -48
  15. package/dist/accessories/Light_accessory.js.map +1 -1
  16. package/dist/accessories/Lock_accessory.js +11 -11
  17. package/dist/accessories/Lock_accessory.js.map +1 -1
  18. package/dist/accessories/MotionSensor_accessory.js +8 -8
  19. package/dist/accessories/MotionSensor_accessory.js.map +1 -1
  20. package/dist/accessories/Outlet_accessory.js +10 -10
  21. package/dist/accessories/Outlet_accessory.js.map +1 -1
  22. package/dist/accessories/SmartSpeaker_accessory.js +11 -11
  23. package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
  24. package/dist/accessories/Sprinkler_accessory.js +19 -19
  25. package/dist/accessories/Sprinkler_accessory.js.map +1 -1
  26. package/dist/accessories/TV_accessory.js +17 -17
  27. package/dist/accessories/TV_accessory.js.map +1 -1
  28. package/dist/accessories/TemperatureSensor_accessory.js +6 -6
  29. package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
  30. package/dist/accessories/Wi-FiRouter_accessory.js +3 -3
  31. package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
  32. package/dist/accessories/Wi-FiSatellite_accessory.js +4 -4
  33. package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
  34. package/dist/accessories/gstreamer-audioProducer.js +36 -47
  35. package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
  36. package/dist/accessories/types.js +2 -2
  37. package/dist/accessories/types.js.map +1 -1
  38. package/dist/index.d.ts +0 -14
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +5 -28
  41. package/dist/index.js.map +1 -1
  42. package/dist/lib/Accessory.d.ts +1 -58
  43. package/dist/lib/Accessory.d.ts.map +1 -1
  44. package/dist/lib/Accessory.js +747 -1149
  45. package/dist/lib/Accessory.js.map +1 -1
  46. package/dist/lib/Advertiser.d.ts +1 -2
  47. package/dist/lib/Advertiser.d.ts.map +1 -1
  48. package/dist/lib/Advertiser.js +392 -524
  49. package/dist/lib/Advertiser.js.map +1 -1
  50. package/dist/lib/Bridge.js +6 -10
  51. package/dist/lib/Bridge.js.map +1 -1
  52. package/dist/lib/Characteristic.d.ts +2 -133
  53. package/dist/lib/Characteristic.d.ts.map +1 -1
  54. package/dist/lib/Characteristic.js +1467 -669
  55. package/dist/lib/Characteristic.js.map +1 -1
  56. package/dist/lib/HAPServer.d.ts +0 -10
  57. package/dist/lib/HAPServer.d.ts.map +1 -1
  58. package/dist/lib/HAPServer.js +216 -280
  59. package/dist/lib/HAPServer.js.map +1 -1
  60. package/dist/lib/Service.d.ts +1 -51
  61. package/dist/lib/Service.d.ts.map +1 -1
  62. package/dist/lib/Service.js +474 -322
  63. package/dist/lib/Service.js.map +1 -1
  64. package/dist/lib/camera/RTPProxy.js +112 -104
  65. package/dist/lib/camera/RTPProxy.js.map +1 -1
  66. package/dist/lib/camera/RTPStreamManagement.d.ts +0 -65
  67. package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
  68. package/dist/lib/camera/RTPStreamManagement.js +255 -278
  69. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  70. package/dist/lib/camera/RecordingManagement.js +318 -381
  71. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  72. package/dist/lib/camera/index.d.ts +0 -1
  73. package/dist/lib/camera/index.d.ts.map +1 -1
  74. package/dist/lib/camera/index.js +1 -2
  75. package/dist/lib/camera/index.js.map +1 -1
  76. package/dist/lib/controller/AdaptiveLightingController.d.ts +19 -3
  77. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
  78. package/dist/lib/controller/AdaptiveLightingController.js +217 -218
  79. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  80. package/dist/lib/controller/CameraController.d.ts +0 -4
  81. package/dist/lib/controller/CameraController.d.ts.map +1 -1
  82. package/dist/lib/controller/CameraController.js +189 -256
  83. package/dist/lib/controller/CameraController.js.map +1 -1
  84. package/dist/lib/controller/DoorbellController.js +38 -39
  85. package/dist/lib/controller/DoorbellController.js.map +1 -1
  86. package/dist/lib/controller/RemoteController.d.ts +0 -14
  87. package/dist/lib/controller/RemoteController.d.ts.map +1 -1
  88. package/dist/lib/controller/RemoteController.js +340 -415
  89. package/dist/lib/controller/RemoteController.js.map +1 -1
  90. package/dist/lib/controller/index.js +1 -1
  91. package/dist/lib/datastream/DataStreamManagement.js +56 -57
  92. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  93. package/dist/lib/datastream/DataStreamParser.js +259 -304
  94. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  95. package/dist/lib/datastream/DataStreamServer.d.ts +0 -5
  96. package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
  97. package/dist/lib/datastream/DataStreamServer.js +252 -269
  98. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  99. package/dist/lib/datastream/index.js +1 -1
  100. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +1 -106
  101. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
  102. package/dist/lib/definitions/CharacteristicDefinitions.js +2000 -2995
  103. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  104. package/dist/lib/definitions/ServiceDefinitions.d.ts +0 -32
  105. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
  106. package/dist/lib/definitions/ServiceDefinitions.js +820 -1147
  107. package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
  108. package/dist/lib/definitions/generate-definitions.js +383 -679
  109. package/dist/lib/definitions/generate-definitions.js.map +1 -1
  110. package/dist/lib/definitions/generator-configuration.js +29 -29
  111. package/dist/lib/definitions/generator-configuration.js.map +1 -1
  112. package/dist/lib/definitions/index.js +1 -1
  113. package/dist/lib/model/AccessoryInfo.js +101 -136
  114. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  115. package/dist/lib/model/ControllerStorage.js +86 -89
  116. package/dist/lib/model/ControllerStorage.js.map +1 -1
  117. package/dist/lib/model/HAPStorage.js +15 -16
  118. package/dist/lib/model/HAPStorage.js.map +1 -1
  119. package/dist/lib/model/IdentifierCache.js +49 -49
  120. package/dist/lib/model/IdentifierCache.js.map +1 -1
  121. package/dist/lib/tv/AccessControlManagement.js +40 -44
  122. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  123. package/dist/lib/util/checkName.d.ts +2 -1
  124. package/dist/lib/util/checkName.d.ts.map +1 -1
  125. package/dist/lib/util/checkName.js +7 -11
  126. package/dist/lib/util/checkName.js.map +1 -1
  127. package/dist/lib/util/clone.js +5 -27
  128. package/dist/lib/util/clone.js.map +1 -1
  129. package/dist/lib/util/color-utils.js +8 -12
  130. package/dist/lib/util/color-utils.js.map +1 -1
  131. package/dist/lib/util/eventedhttp.d.ts.map +1 -1
  132. package/dist/lib/util/eventedhttp.js +301 -409
  133. package/dist/lib/util/eventedhttp.js.map +1 -1
  134. package/dist/lib/util/hapCrypto.js +31 -32
  135. package/dist/lib/util/hapCrypto.js.map +1 -1
  136. package/dist/lib/util/hapStatusError.js +9 -12
  137. package/dist/lib/util/hapStatusError.js.map +1 -1
  138. package/dist/lib/util/net-utils.js +32 -53
  139. package/dist/lib/util/net-utils.js.map +1 -1
  140. package/dist/lib/util/once.js +3 -8
  141. package/dist/lib/util/once.js.map +1 -1
  142. package/dist/lib/util/promise-utils.js +8 -13
  143. package/dist/lib/util/promise-utils.js.map +1 -1
  144. package/dist/lib/util/request-util.js +2 -3
  145. package/dist/lib/util/request-util.js.map +1 -1
  146. package/dist/lib/util/time.js +5 -5
  147. package/dist/lib/util/time.js.map +1 -1
  148. package/dist/lib/util/tlv.d.ts +0 -27
  149. package/dist/lib/util/tlv.d.ts.map +1 -1
  150. package/dist/lib/util/tlv.js +71 -113
  151. package/dist/lib/util/tlv.js.map +1 -1
  152. package/dist/lib/util/uuid.d.ts +0 -9
  153. package/dist/lib/util/uuid.d.ts.map +1 -1
  154. package/dist/lib/util/uuid.js +15 -33
  155. package/dist/lib/util/uuid.js.map +1 -1
  156. package/dist/types.d.ts +0 -35
  157. package/dist/types.d.ts.map +1 -1
  158. package/dist/types.js.map +1 -1
  159. package/package.json +10 -10
  160. package/dist/BridgedCore.d.ts +0 -2
  161. package/dist/BridgedCore.d.ts.map +0 -1
  162. package/dist/BridgedCore.js +0 -43
  163. package/dist/BridgedCore.js.map +0 -1
  164. package/dist/Core.d.ts +0 -2
  165. package/dist/Core.d.ts.map +0 -1
  166. package/dist/Core.js +0 -52
  167. package/dist/Core.js.map +0 -1
  168. package/dist/lib/AccessoryLoader.d.ts +0 -28
  169. package/dist/lib/AccessoryLoader.d.ts.map +0 -1
  170. package/dist/lib/AccessoryLoader.js +0 -166
  171. package/dist/lib/AccessoryLoader.js.map +0 -1
  172. package/dist/lib/camera/Camera.d.ts +0 -43
  173. package/dist/lib/camera/Camera.d.ts.map +0 -1
  174. package/dist/lib/camera/Camera.js +0 -36
  175. package/dist/lib/camera/Camera.js.map +0 -1
@@ -1,121 +1,81 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataStreamWriter = exports.DataStreamReader = exports.DataStreamParser = exports.DataFormatTags = exports.UUID = exports.SecondsSince2001 = exports.Float64 = exports.Float32 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.ValueWrapper = void 0;
4
- var tslib_1 = require("tslib");
5
- var uuid = tslib_1.__importStar(require("../util/uuid"));
6
- var hapCrypto = tslib_1.__importStar(require("../util/hapCrypto"));
7
- var assert_1 = tslib_1.__importDefault(require("assert"));
8
- var debug_1 = tslib_1.__importDefault(require("debug"));
4
+ const tslib_1 = require("tslib");
5
+ const uuid = tslib_1.__importStar(require("../util/uuid"));
6
+ const hapCrypto = tslib_1.__importStar(require("../util/hapCrypto"));
7
+ const assert_1 = tslib_1.__importDefault(require("assert"));
8
+ const debug_1 = tslib_1.__importDefault(require("debug"));
9
9
  // welcome to hell :)
10
10
  // in this file lies madness and frustration. and It's not only about HDS. Also, JavaScript is hell
11
- var debug = (0, debug_1.default)("HAP-NodeJS:DataStream:Parser");
12
- var Magics = /** @class */ (function () {
13
- function Magics() {
14
- }
15
- Magics.TERMINATOR = { type: "terminator" };
16
- return Magics;
17
- }());
11
+ const debug = (0, debug_1.default)("HAP-NodeJS:DataStream:Parser");
12
+ class Magics {
13
+ static TERMINATOR = { type: "terminator" };
14
+ }
18
15
  /**
19
16
  * @group HomeKit Data Streams (HDS)
20
17
  */
21
- var ValueWrapper = /** @class */ (function () {
22
- function ValueWrapper(value) {
18
+ class ValueWrapper {
19
+ value;
20
+ constructor(value) {
23
21
  this.value = value;
24
22
  }
25
- ValueWrapper.prototype.equals = function (obj) {
23
+ equals(obj) {
26
24
  return this.constructor.name === obj.constructor.name && obj.value === this.value;
27
- };
28
- return ValueWrapper;
29
- }());
25
+ }
26
+ }
30
27
  exports.ValueWrapper = ValueWrapper;
31
28
  /**
32
29
  * @group HomeKit Data Streams (HDS)
33
30
  */
34
- var Int8 = /** @class */ (function (_super) {
35
- tslib_1.__extends(Int8, _super);
36
- function Int8() {
37
- return _super !== null && _super.apply(this, arguments) || this;
38
- }
39
- return Int8;
40
- }(ValueWrapper));
31
+ class Int8 extends ValueWrapper {
32
+ }
41
33
  exports.Int8 = Int8;
42
34
  /**
43
35
  * @group HomeKit Data Streams (HDS)
44
36
  */
45
- var Int16 = /** @class */ (function (_super) {
46
- tslib_1.__extends(Int16, _super);
47
- function Int16() {
48
- return _super !== null && _super.apply(this, arguments) || this;
49
- }
50
- return Int16;
51
- }(ValueWrapper));
37
+ class Int16 extends ValueWrapper {
38
+ }
52
39
  exports.Int16 = Int16;
53
40
  /**
54
41
  * @group HomeKit Data Streams (HDS)
55
42
  */
56
- var Int32 = /** @class */ (function (_super) {
57
- tslib_1.__extends(Int32, _super);
58
- function Int32() {
59
- return _super !== null && _super.apply(this, arguments) || this;
60
- }
61
- return Int32;
62
- }(ValueWrapper));
43
+ class Int32 extends ValueWrapper {
44
+ }
63
45
  exports.Int32 = Int32;
64
46
  /**
65
47
  * @group HomeKit Data Streams (HDS)
66
48
  */
67
- var Int64 = /** @class */ (function (_super) {
68
- tslib_1.__extends(Int64, _super);
69
- function Int64() {
70
- return _super !== null && _super.apply(this, arguments) || this;
71
- }
72
- return Int64;
73
- }(ValueWrapper));
49
+ class Int64 extends ValueWrapper {
50
+ }
74
51
  exports.Int64 = Int64;
75
52
  /**
76
53
  * @group HomeKit Data Streams (HDS)
77
54
  */
78
- var Float32 = /** @class */ (function (_super) {
79
- tslib_1.__extends(Float32, _super);
80
- function Float32() {
81
- return _super !== null && _super.apply(this, arguments) || this;
82
- }
83
- return Float32;
84
- }(ValueWrapper));
55
+ class Float32 extends ValueWrapper {
56
+ }
85
57
  exports.Float32 = Float32;
86
58
  /**
87
59
  * @group HomeKit Data Streams (HDS)
88
60
  */
89
- var Float64 = /** @class */ (function (_super) {
90
- tslib_1.__extends(Float64, _super);
91
- function Float64() {
92
- return _super !== null && _super.apply(this, arguments) || this;
93
- }
94
- return Float64;
95
- }(ValueWrapper));
61
+ class Float64 extends ValueWrapper {
62
+ }
96
63
  exports.Float64 = Float64;
97
64
  /**
98
65
  * @group HomeKit Data Streams (HDS)
99
66
  */
100
- var SecondsSince2001 = /** @class */ (function (_super) {
101
- tslib_1.__extends(SecondsSince2001, _super);
102
- function SecondsSince2001() {
103
- return _super !== null && _super.apply(this, arguments) || this;
104
- }
105
- return SecondsSince2001;
106
- }(ValueWrapper));
67
+ class SecondsSince2001 extends ValueWrapper {
68
+ }
107
69
  exports.SecondsSince2001 = SecondsSince2001;
108
70
  /**
109
71
  * @group HomeKit Data Streams (HDS)
110
72
  */
111
- var UUID = /** @class */ (function (_super) {
112
- tslib_1.__extends(UUID, _super);
113
- function UUID(value) {
73
+ class UUID extends ValueWrapper {
74
+ constructor(value) {
114
75
  (0, assert_1.default)(uuid.isValid(value), "invalid uuid format");
115
- return _super.call(this, value) || this;
76
+ super(value);
116
77
  }
117
- return UUID;
118
- }(ValueWrapper));
78
+ }
119
79
  exports.UUID = UUID;
120
80
  /**
121
81
  * @group HomeKit Data Streams (HDS)
@@ -164,12 +124,10 @@ var DataFormatTags;
164
124
  /**
165
125
  * @group HomeKit Data Streams (HDS)
166
126
  */
167
- var DataStreamParser = /** @class */ (function () {
168
- function DataStreamParser() {
169
- }
127
+ class DataStreamParser {
170
128
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
- DataStreamParser.decode = function (buffer) {
172
- var tag = buffer.readTag();
129
+ static decode(buffer) {
130
+ const tag = buffer.readTag();
173
131
  if (tag === 0 /* DataFormatTags.INVALID */) {
174
132
  throw new Error("HDSDecoder: zero tag detected on index " + buffer.readerIndex);
175
133
  }
@@ -216,7 +174,7 @@ var DataStreamParser = /** @class */ (function () {
216
174
  return buffer.readFloat64LE();
217
175
  }
218
176
  else if (tag >= 64 /* DataFormatTags.UTF8_LENGTH_START */ && tag <= 96 /* DataFormatTags.UTF8_LENGTH_STOP */) {
219
- var length = tag - 64 /* DataFormatTags.UTF8_LENGTH_START */;
177
+ const length = tag - 64 /* DataFormatTags.UTF8_LENGTH_START */;
220
178
  return buffer.readUTF8(length);
221
179
  }
222
180
  else if (tag === 97 /* DataFormatTags.UTF8_LENGTH8 */) {
@@ -235,7 +193,7 @@ var DataStreamParser = /** @class */ (function () {
235
193
  return buffer.readUTF8_NULL_terminated();
236
194
  }
237
195
  else if (tag >= 112 /* DataFormatTags.DATA_LENGTH_START */ && tag <= 144 /* DataFormatTags.DATA_LENGTH_STOP */) {
238
- var length = tag - 112 /* DataFormatTags.DATA_LENGTH_START */;
196
+ const length = tag - 112 /* DataFormatTags.DATA_LENGTH_START */;
239
197
  buffer.readData(length);
240
198
  }
241
199
  else if (tag === 145 /* DataFormatTags.DATA_LENGTH8 */) {
@@ -254,39 +212,39 @@ var DataStreamParser = /** @class */ (function () {
254
212
  return buffer.readData_terminated();
255
213
  }
256
214
  else if (tag >= 160 /* DataFormatTags.COMPRESSION_START */ && tag <= 207 /* DataFormatTags.COMPRESSION_STOP */) {
257
- var index = tag - 160 /* DataFormatTags.COMPRESSION_START */;
215
+ const index = tag - 160 /* DataFormatTags.COMPRESSION_START */;
258
216
  return buffer.decompressData(index);
259
217
  }
260
218
  else if (tag >= 208 /* DataFormatTags.ARRAY_LENGTH_START */ && tag <= 222 /* DataFormatTags.ARRAY_LENGTH_STOP */) {
261
- var length = tag - 208 /* DataFormatTags.ARRAY_LENGTH_START */;
262
- var array = [];
263
- for (var i = 0; i < length; i++) {
219
+ const length = tag - 208 /* DataFormatTags.ARRAY_LENGTH_START */;
220
+ const array = [];
221
+ for (let i = 0; i < length; i++) {
264
222
  array.push(this.decode(buffer));
265
223
  }
266
224
  return array;
267
225
  }
268
226
  else if (tag === 223 /* DataFormatTags.ARRAY_TERMINATED */) {
269
- var array = [];
270
- var element = void 0;
227
+ const array = [];
228
+ let element;
271
229
  while ((element = this.decode(buffer)) !== Magics.TERMINATOR) {
272
230
  array.push(element);
273
231
  }
274
232
  return array;
275
233
  }
276
234
  else if (tag >= 224 /* DataFormatTags.DICTIONARY_LENGTH_START */ && tag <= 238 /* DataFormatTags.DICTIONARY_LENGTH_STOP */) {
277
- var length = tag - 224 /* DataFormatTags.DICTIONARY_LENGTH_START */;
235
+ const length = tag - 224 /* DataFormatTags.DICTIONARY_LENGTH_START */;
278
236
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
- var dictionary = {};
280
- for (var i = 0; i < length; i++) {
281
- var key = this.decode(buffer);
237
+ const dictionary = {};
238
+ for (let i = 0; i < length; i++) {
239
+ const key = this.decode(buffer);
282
240
  dictionary[key] = this.decode(buffer);
283
241
  }
284
242
  return dictionary;
285
243
  }
286
244
  else if (tag === 239 /* DataFormatTags.DICTIONARY_TERMINATED */) {
287
245
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
288
- var dictionary = {};
289
- var key = void 0;
246
+ const dictionary = {};
247
+ let key;
290
248
  while ((key = this.decode(buffer)) !== Magics.TERMINATOR) {
291
249
  dictionary[key] = this.decode(buffer); // decode value
292
250
  }
@@ -295,10 +253,9 @@ var DataStreamParser = /** @class */ (function () {
295
253
  else {
296
254
  throw new Error("HDSDecoder: encountered unknown tag on index " + buffer.readerIndex + ": " + tag.toString(16));
297
255
  }
298
- };
256
+ }
299
257
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any
300
- DataStreamParser.encode = function (data, buffer) {
301
- var _this = this;
258
+ static encode(data, buffer) {
302
259
  if (data === undefined) {
303
260
  throw new Error("HDSEncoder: cannot encode undefined");
304
261
  }
@@ -328,15 +285,15 @@ var DataStreamParser = /** @class */ (function () {
328
285
  break;
329
286
  case "object":
330
287
  if (Array.isArray(data)) {
331
- var length = data.length;
288
+ const length = data.length;
332
289
  if (length <= 12) {
333
290
  buffer.writeTag(208 /* DataFormatTags.ARRAY_LENGTH_START */ + length);
334
291
  }
335
292
  else {
336
293
  buffer.writeTag(223 /* DataFormatTags.ARRAY_TERMINATED */);
337
294
  }
338
- data.forEach(function (element) {
339
- _this.encode(element, buffer);
295
+ data.forEach(element => {
296
+ this.encode(element, buffer);
340
297
  });
341
298
  if (length > 12) {
342
299
  buffer.writeTag(3 /* DataFormatTags.TERMINATOR */);
@@ -375,17 +332,17 @@ var DataStreamParser = /** @class */ (function () {
375
332
  buffer.writeData(data);
376
333
  }
377
334
  else { // object is treated as dictionary
378
- var entries = Object.entries(data)
379
- .filter(function (entry) { return entry[1] !== undefined; }); // explicitly setting undefined will result in an entry here
335
+ const entries = Object.entries(data)
336
+ .filter(entry => entry[1] !== undefined); // explicitly setting undefined will result in an entry here
380
337
  if (entries.length <= 14) {
381
338
  buffer.writeTag(224 /* DataFormatTags.DICTIONARY_LENGTH_START */ + entries.length);
382
339
  }
383
340
  else {
384
341
  buffer.writeTag(239 /* DataFormatTags.DICTIONARY_TERMINATED */);
385
342
  }
386
- entries.forEach(function (entry) {
387
- _this.encode(entry[0], buffer); // encode key
388
- _this.encode(entry[1], buffer); // encode value
343
+ entries.forEach(entry => {
344
+ this.encode(entry[0], buffer); // encode key
345
+ this.encode(entry[1], buffer); // encode value
389
346
  });
390
347
  if (entries.length > 14) {
391
348
  buffer.writeTag(3 /* DataFormatTags.TERMINATOR */);
@@ -395,145 +352,146 @@ var DataStreamParser = /** @class */ (function () {
395
352
  default:
396
353
  throw new Error("HDSEncoder: no idea how to encode value of type '" + (typeof data) + "': " + data);
397
354
  }
398
- };
399
- return DataStreamParser;
400
- }());
355
+ }
356
+ }
401
357
  exports.DataStreamParser = DataStreamParser;
402
358
  /**
403
359
  * @group HomeKit Data Streams (HDS)
404
360
  */
405
- var DataStreamReader = /** @class */ (function () {
406
- function DataStreamReader(data) {
407
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
408
- this.trackedCompressedData = [];
361
+ class DataStreamReader {
362
+ data;
363
+ readerIndex;
364
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
365
+ trackedCompressedData = [];
366
+ constructor(data) {
409
367
  this.data = data;
410
368
  this.readerIndex = 0;
411
369
  }
412
- DataStreamReader.prototype.finished = function () {
370
+ finished() {
413
371
  if (this.readerIndex < this.data.length) {
414
- var remainingHex = this.data.slice(this.readerIndex, this.data.length).toString("hex");
372
+ const remainingHex = this.data.slice(this.readerIndex, this.data.length).toString("hex");
415
373
  debug("WARNING Finished reading HDS stream, but there are still %d bytes remaining () %s", this.data.length - this.readerIndex, remainingHex);
416
374
  }
417
- };
375
+ }
418
376
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
419
- DataStreamReader.prototype.decompressData = function (index) {
377
+ decompressData(index) {
420
378
  if (index >= this.trackedCompressedData.length) {
421
379
  throw new Error("HDSDecoder: Tried decompression of data for an index out of range (index " + index +
422
380
  " and got " + this.trackedCompressedData.length + " elements)");
423
381
  }
424
382
  return this.trackedCompressedData[index];
425
- };
426
- DataStreamReader.prototype.trackData = function (data) {
383
+ }
384
+ trackData(data) {
427
385
  this.trackedCompressedData.push(data);
428
386
  return data;
429
- };
430
- DataStreamReader.prototype.ensureLength = function (bytes) {
387
+ }
388
+ ensureLength(bytes) {
431
389
  if (this.readerIndex + bytes > this.data.length) {
432
- var remaining = this.data.length - this.readerIndex;
390
+ const remaining = this.data.length - this.readerIndex;
433
391
  throw new Error("HDSDecoder: End of data stream. Tried reading " + bytes + " bytes however got only " + remaining + " remaining!");
434
392
  }
435
- };
436
- DataStreamReader.prototype.readTag = function () {
393
+ }
394
+ readTag() {
437
395
  this.ensureLength(1);
438
396
  return this.data.readUInt8(this.readerIndex++);
439
- };
440
- DataStreamReader.prototype.readTrue = function () {
397
+ }
398
+ readTrue() {
441
399
  return this.trackData(true); // do those tag encoded values get cached?
442
- };
443
- DataStreamReader.prototype.readFalse = function () {
400
+ }
401
+ readFalse() {
444
402
  return this.trackData(false);
445
- };
446
- DataStreamReader.prototype.readNegOne = function () {
403
+ }
404
+ readNegOne() {
447
405
  return this.trackData(-1);
448
- };
449
- DataStreamReader.prototype.readIntRange = function (tag) {
406
+ }
407
+ readIntRange(tag) {
450
408
  return this.trackData(tag - 8 /* DataFormatTags.INTEGER_RANGE_START_0 */); // integer values from 0-39
451
- };
452
- DataStreamReader.prototype.readInt8 = function () {
409
+ }
410
+ readInt8() {
453
411
  this.ensureLength(1);
454
412
  return this.trackData(this.data.readInt8(this.readerIndex++));
455
- };
456
- DataStreamReader.prototype.readInt16LE = function () {
413
+ }
414
+ readInt16LE() {
457
415
  this.ensureLength(2);
458
- var value = this.data.readInt16LE(this.readerIndex);
416
+ const value = this.data.readInt16LE(this.readerIndex);
459
417
  this.readerIndex += 2;
460
418
  return this.trackData(value);
461
- };
462
- DataStreamReader.prototype.readInt32LE = function () {
419
+ }
420
+ readInt32LE() {
463
421
  this.ensureLength(4);
464
- var value = this.data.readInt32LE(this.readerIndex);
422
+ const value = this.data.readInt32LE(this.readerIndex);
465
423
  this.readerIndex += 4;
466
424
  return this.trackData(value);
467
- };
468
- DataStreamReader.prototype.readInt64LE = function () {
425
+ }
426
+ readInt64LE() {
469
427
  this.ensureLength(8);
470
- var low = this.data.readInt32LE(this.readerIndex);
471
- var value = this.data.readInt32LE(this.readerIndex + 4) * 0x100000000 + low;
428
+ const low = this.data.readInt32LE(this.readerIndex);
429
+ let value = this.data.readInt32LE(this.readerIndex + 4) * 0x100000000 + low;
472
430
  if (low < 0) {
473
431
  value += 0x100000000;
474
432
  }
475
433
  this.readerIndex += 8;
476
434
  return this.trackData(value);
477
- };
478
- DataStreamReader.prototype.readFloat32LE = function () {
435
+ }
436
+ readFloat32LE() {
479
437
  this.ensureLength(4);
480
- var value = this.data.readFloatLE(this.readerIndex);
438
+ const value = this.data.readFloatLE(this.readerIndex);
481
439
  this.readerIndex += 4;
482
440
  return this.trackData(value);
483
- };
484
- DataStreamReader.prototype.readFloat64LE = function () {
441
+ }
442
+ readFloat64LE() {
485
443
  this.ensureLength(8);
486
- var value = this.data.readDoubleLE(this.readerIndex);
444
+ const value = this.data.readDoubleLE(this.readerIndex);
487
445
  return this.trackData(value);
488
- };
489
- DataStreamReader.prototype.readLength8 = function () {
446
+ }
447
+ readLength8() {
490
448
  this.ensureLength(1);
491
449
  return this.data.readUInt8(this.readerIndex++);
492
- };
493
- DataStreamReader.prototype.readLength16LE = function () {
450
+ }
451
+ readLength16LE() {
494
452
  this.ensureLength(2);
495
- var value = this.data.readUInt16LE(this.readerIndex);
453
+ const value = this.data.readUInt16LE(this.readerIndex);
496
454
  this.readerIndex += 2;
497
455
  return value;
498
- };
499
- DataStreamReader.prototype.readLength32LE = function () {
456
+ }
457
+ readLength32LE() {
500
458
  this.ensureLength(4);
501
- var value = this.data.readUInt32LE(this.readerIndex);
459
+ const value = this.data.readUInt32LE(this.readerIndex);
502
460
  this.readerIndex += 4;
503
461
  return value;
504
- };
505
- DataStreamReader.prototype.readLength64LE = function () {
462
+ }
463
+ readLength64LE() {
506
464
  this.ensureLength(8);
507
- var low = this.data.readUInt32LE(this.readerIndex);
508
- var value = this.data.readUInt32LE(this.readerIndex + 4) * 0x100000000 + low;
465
+ const low = this.data.readUInt32LE(this.readerIndex);
466
+ const value = this.data.readUInt32LE(this.readerIndex + 4) * 0x100000000 + low;
509
467
  this.readerIndex += 8;
510
468
  return value;
511
- };
512
- DataStreamReader.prototype.readUTF8 = function (length) {
469
+ }
470
+ readUTF8(length) {
513
471
  this.ensureLength(length);
514
- var value = this.data.toString("utf8", this.readerIndex, this.readerIndex + length);
472
+ const value = this.data.toString("utf8", this.readerIndex, this.readerIndex + length);
515
473
  this.readerIndex += length;
516
474
  return this.trackData(value);
517
- };
518
- DataStreamReader.prototype.readUTF8_Length8 = function () {
519
- var length = this.readLength8();
475
+ }
476
+ readUTF8_Length8() {
477
+ const length = this.readLength8();
520
478
  return this.readUTF8(length);
521
- };
522
- DataStreamReader.prototype.readUTF8_Length16LE = function () {
523
- var length = this.readLength16LE();
479
+ }
480
+ readUTF8_Length16LE() {
481
+ const length = this.readLength16LE();
524
482
  return this.readUTF8(length);
525
- };
526
- DataStreamReader.prototype.readUTF8_Length32LE = function () {
527
- var length = this.readLength32LE();
483
+ }
484
+ readUTF8_Length32LE() {
485
+ const length = this.readLength32LE();
528
486
  return this.readUTF8(length);
529
- };
530
- DataStreamReader.prototype.readUTF8_Length64LE = function () {
531
- var length = this.readLength64LE();
487
+ }
488
+ readUTF8_Length64LE() {
489
+ const length = this.readLength64LE();
532
490
  return this.readUTF8(length);
533
- };
534
- DataStreamReader.prototype.readUTF8_NULL_terminated = function () {
535
- var offset = this.readerIndex;
536
- var nextByte;
491
+ }
492
+ readUTF8_NULL_terminated() {
493
+ let offset = this.readerIndex;
494
+ let nextByte;
537
495
  for (;;) {
538
496
  nextByte = this.data[offset];
539
497
  if (nextByte === undefined) {
@@ -546,35 +504,35 @@ var DataStreamReader = /** @class */ (function () {
546
504
  offset++;
547
505
  }
548
506
  }
549
- var value = this.data.toString("utf8", this.readerIndex, offset);
507
+ const value = this.data.toString("utf8", this.readerIndex, offset);
550
508
  this.readerIndex = offset + 1;
551
509
  return this.trackData(value);
552
- };
553
- DataStreamReader.prototype.readData = function (length) {
510
+ }
511
+ readData(length) {
554
512
  this.ensureLength(length);
555
- var value = this.data.slice(this.readerIndex, this.readerIndex + length);
513
+ const value = this.data.slice(this.readerIndex, this.readerIndex + length);
556
514
  this.readerIndex += length;
557
515
  return this.trackData(value);
558
- };
559
- DataStreamReader.prototype.readData_Length8 = function () {
560
- var length = this.readLength8();
516
+ }
517
+ readData_Length8() {
518
+ const length = this.readLength8();
561
519
  return this.readData(length);
562
- };
563
- DataStreamReader.prototype.readData_Length16LE = function () {
564
- var length = this.readLength16LE();
520
+ }
521
+ readData_Length16LE() {
522
+ const length = this.readLength16LE();
565
523
  return this.readData(length);
566
- };
567
- DataStreamReader.prototype.readData_Length32LE = function () {
568
- var length = this.readLength32LE();
524
+ }
525
+ readData_Length32LE() {
526
+ const length = this.readLength32LE();
569
527
  return this.readData(length);
570
- };
571
- DataStreamReader.prototype.readData_Length64LE = function () {
572
- var length = this.readLength64LE();
528
+ }
529
+ readData_Length64LE() {
530
+ const length = this.readLength64LE();
573
531
  return this.readData(length);
574
- };
575
- DataStreamReader.prototype.readData_terminated = function () {
576
- var offset = this.readerIndex;
577
- var nextByte;
532
+ }
533
+ readData_terminated() {
534
+ let offset = this.readerIndex;
535
+ let nextByte;
578
536
  for (;;) {
579
537
  nextByte = this.data[offset];
580
538
  if (nextByte === undefined) {
@@ -587,34 +545,31 @@ var DataStreamReader = /** @class */ (function () {
587
545
  offset++;
588
546
  }
589
547
  }
590
- var value = this.data.slice(this.readerIndex, offset);
548
+ const value = this.data.slice(this.readerIndex, offset);
591
549
  this.readerIndex = offset + 1;
592
550
  return this.trackData(value);
593
- };
594
- DataStreamReader.prototype.readSecondsSince2001_01_01 = function () {
551
+ }
552
+ readSecondsSince2001_01_01() {
595
553
  // second since 2001-01-01 00:00:00
596
554
  return this.readFloat64LE();
597
- };
598
- DataStreamReader.prototype.readUUID = function () {
555
+ }
556
+ readUUID() {
599
557
  this.ensureLength(16);
600
- var value = uuid.unparse(this.data, this.readerIndex);
558
+ const value = uuid.unparse(this.data, this.readerIndex);
601
559
  this.readerIndex += 16;
602
560
  return this.trackData(value);
603
- };
604
- return DataStreamReader;
605
- }());
606
- exports.DataStreamReader = DataStreamReader;
607
- var WrittenDataList = /** @class */ (function () {
608
- function WrittenDataList() {
609
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
610
- this.writtenData = [];
611
561
  }
612
- WrittenDataList.prototype.push = function (data) {
562
+ }
563
+ exports.DataStreamReader = DataStreamReader;
564
+ class WrittenDataList {
565
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
566
+ writtenData = [];
567
+ push(data) {
613
568
  this.writtenData.push(data);
614
- };
615
- WrittenDataList.prototype.indexOf = function (data) {
616
- for (var i = 0; i < this.writtenData.length; i++) {
617
- var data0 = this.writtenData[i];
569
+ }
570
+ indexOf(data) {
571
+ for (let i = 0; i < this.writtenData.length; i++) {
572
+ const data0 = this.writtenData[i];
618
573
  if (data === data0) {
619
574
  return i;
620
575
  }
@@ -625,35 +580,37 @@ var WrittenDataList = /** @class */ (function () {
625
580
  }
626
581
  }
627
582
  return -1;
628
- };
629
- return WrittenDataList;
630
- }());
583
+ }
584
+ }
631
585
  /**
632
586
  * @group HomeKit Data Streams (HDS)
633
587
  */
634
- var DataStreamWriter = /** @class */ (function () {
635
- function DataStreamWriter() {
636
- this.writtenData = new WrittenDataList();
588
+ class DataStreamWriter {
589
+ static chunkSize = 128; // seems to be a good default
590
+ data;
591
+ writerIndex;
592
+ writtenData = new WrittenDataList();
593
+ constructor() {
637
594
  this.data = Buffer.alloc(DataStreamWriter.chunkSize);
638
595
  this.writerIndex = 0;
639
596
  }
640
- DataStreamWriter.prototype.length = function () {
597
+ length() {
641
598
  return this.writerIndex; // since writerIndex points to the next FREE index it also represents the length
642
- };
643
- DataStreamWriter.prototype.getData = function () {
599
+ }
600
+ getData() {
644
601
  return this.data.slice(0, this.writerIndex);
645
- };
646
- DataStreamWriter.prototype.ensureLength = function (bytes) {
647
- var neededBytes = (this.writerIndex + bytes) - this.data.length;
602
+ }
603
+ ensureLength(bytes) {
604
+ const neededBytes = (this.writerIndex + bytes) - this.data.length;
648
605
  if (neededBytes > 0) {
649
- var chunks = Math.ceil(neededBytes / DataStreamWriter.chunkSize);
606
+ const chunks = Math.ceil(neededBytes / DataStreamWriter.chunkSize);
650
607
  // don't know if it's best for performance to immediately concatenate the buffers. That way it's
651
608
  // the easiest way to handle writing though.
652
609
  this.data = Buffer.concat([this.data, Buffer.alloc(chunks * DataStreamWriter.chunkSize)]);
653
610
  }
654
- };
655
- DataStreamWriter.prototype.compressDataIfPossible = function (data) {
656
- var index = this.writtenData.indexOf(data);
611
+ }
612
+ compressDataIfPossible(data) {
613
+ const index = this.writtenData.indexOf(data);
657
614
  if (index < 0) {
658
615
  // data is not present yet
659
616
  this.writtenData.push(data);
@@ -665,18 +622,18 @@ var DataStreamWriter = /** @class */ (function () {
665
622
  return true;
666
623
  }
667
624
  return false;
668
- };
669
- DataStreamWriter.prototype.writeTag = function (tag) {
625
+ }
626
+ writeTag(tag) {
670
627
  this.ensureLength(1);
671
628
  this.data.writeUInt8(tag, this.writerIndex++);
672
- };
673
- DataStreamWriter.prototype.writeTrue = function () {
629
+ }
630
+ writeTrue() {
674
631
  this.writeTag(1 /* DataFormatTags.TRUE */);
675
- };
676
- DataStreamWriter.prototype.writeFalse = function () {
632
+ }
633
+ writeFalse() {
677
634
  this.writeTag(2 /* DataFormatTags.FALSE */);
678
- };
679
- DataStreamWriter.prototype.writeNumber = function (number) {
635
+ }
636
+ writeNumber(number) {
680
637
  if (number === -1) {
681
638
  this.writeTag(7 /* DataFormatTags.INTEGER_MINUS_ONE */);
682
639
  }
@@ -698,16 +655,16 @@ var DataStreamWriter = /** @class */ (function () {
698
655
  else {
699
656
  throw new Error("Tried writing unrepresentable number (" + number + ")");
700
657
  }
701
- };
702
- DataStreamWriter.prototype.writeInt8 = function (int8) {
658
+ }
659
+ writeInt8(int8) {
703
660
  if (this.compressDataIfPossible(int8)) {
704
661
  return;
705
662
  }
706
663
  this.ensureLength(2);
707
664
  this.writeTag(48 /* DataFormatTags.INT8 */);
708
665
  this.data.writeInt8(int8.value, this.writerIndex++);
709
- };
710
- DataStreamWriter.prototype.writeInt16LE = function (int16) {
666
+ }
667
+ writeInt16LE(int16) {
711
668
  if (this.compressDataIfPossible(int16)) {
712
669
  return;
713
670
  }
@@ -715,8 +672,8 @@ var DataStreamWriter = /** @class */ (function () {
715
672
  this.writeTag(49 /* DataFormatTags.INT16LE */);
716
673
  this.data.writeInt16LE(int16.value, this.writerIndex);
717
674
  this.writerIndex += 2;
718
- };
719
- DataStreamWriter.prototype.writeInt32LE = function (int32) {
675
+ }
676
+ writeInt32LE(int32) {
720
677
  if (this.compressDataIfPossible(int32)) {
721
678
  return;
722
679
  }
@@ -724,8 +681,8 @@ var DataStreamWriter = /** @class */ (function () {
724
681
  this.writeTag(50 /* DataFormatTags.INT32LE */);
725
682
  this.data.writeInt32LE(int32.value, this.writerIndex);
726
683
  this.writerIndex += 4;
727
- };
728
- DataStreamWriter.prototype.writeInt64LE = function (int64) {
684
+ }
685
+ writeInt64LE(int64) {
729
686
  if (this.compressDataIfPossible(int64)) {
730
687
  return;
731
688
  }
@@ -734,8 +691,8 @@ var DataStreamWriter = /** @class */ (function () {
734
691
  this.data.writeUInt32LE(int64.value, this.writerIndex); // TODO correctly implement int64; currently it's basically an int32
735
692
  this.data.writeUInt32LE(0, this.writerIndex + 4);
736
693
  this.writerIndex += 8;
737
- };
738
- DataStreamWriter.prototype.writeFloat32LE = function (float32) {
694
+ }
695
+ writeFloat32LE(float32) {
739
696
  if (this.compressDataIfPossible(float32)) {
740
697
  return;
741
698
  }
@@ -743,8 +700,8 @@ var DataStreamWriter = /** @class */ (function () {
743
700
  this.writeTag(53 /* DataFormatTags.FLOAT32LE */);
744
701
  this.data.writeFloatLE(float32.value, this.writerIndex);
745
702
  this.writerIndex += 4;
746
- };
747
- DataStreamWriter.prototype.writeFloat64LE = function (float64) {
703
+ }
704
+ writeFloat64LE(float64) {
748
705
  if (this.compressDataIfPossible(float64)) {
749
706
  return;
750
707
  }
@@ -752,31 +709,31 @@ var DataStreamWriter = /** @class */ (function () {
752
709
  this.writeTag(54 /* DataFormatTags.FLOAT64LE */);
753
710
  this.data.writeDoubleLE(float64.value, this.writerIndex);
754
711
  this.writerIndex += 8;
755
- };
756
- DataStreamWriter.prototype.writeLength8 = function (length) {
712
+ }
713
+ writeLength8(length) {
757
714
  this.ensureLength(1);
758
715
  this.data.writeUInt8(length, this.writerIndex++);
759
- };
760
- DataStreamWriter.prototype.writeLength16LE = function (length) {
716
+ }
717
+ writeLength16LE(length) {
761
718
  this.ensureLength(2);
762
719
  this.data.writeUInt16LE(length, this.writerIndex);
763
720
  this.writerIndex += 2;
764
- };
765
- DataStreamWriter.prototype.writeLength32LE = function (length) {
721
+ }
722
+ writeLength32LE(length) {
766
723
  this.ensureLength(4);
767
724
  this.data.writeUInt32LE(length, this.writerIndex);
768
725
  this.writerIndex += 4;
769
- };
770
- DataStreamWriter.prototype.writeLength64LE = function (length) {
726
+ }
727
+ writeLength64LE(length) {
771
728
  this.ensureLength(8);
772
729
  hapCrypto.writeUInt64LE(length, this.data, this.writerIndex);
773
730
  this.writerIndex += 8;
774
- };
775
- DataStreamWriter.prototype.writeUTF8 = function (utf8) {
731
+ }
732
+ writeUTF8(utf8) {
776
733
  if (this.compressDataIfPossible(utf8)) {
777
734
  return;
778
735
  }
779
- var length = Buffer.byteLength(utf8);
736
+ const length = Buffer.byteLength(utf8);
780
737
  if (length <= 32) {
781
738
  this.ensureLength(1 + length);
782
739
  this.writeTag(64 /* DataFormatTags.UTF8_LENGTH_START */ + utf8.length);
@@ -797,48 +754,48 @@ var DataStreamWriter = /** @class */ (function () {
797
754
  else {
798
755
  this.writeUTF8_NULL_terminated(utf8);
799
756
  }
800
- };
801
- DataStreamWriter.prototype._writeUTF8 = function (utf8) {
802
- var byteLength = Buffer.byteLength(utf8);
757
+ }
758
+ _writeUTF8(utf8) {
759
+ const byteLength = Buffer.byteLength(utf8);
803
760
  this.ensureLength(byteLength);
804
761
  this.data.write(utf8, this.writerIndex, byteLength, "utf8");
805
762
  this.writerIndex += byteLength;
806
- };
807
- DataStreamWriter.prototype.writeUTF8_Length8 = function (utf8) {
808
- var length = Buffer.byteLength(utf8);
763
+ }
764
+ writeUTF8_Length8(utf8) {
765
+ const length = Buffer.byteLength(utf8);
809
766
  this.ensureLength(2 + length);
810
767
  this.writeTag(97 /* DataFormatTags.UTF8_LENGTH8 */);
811
768
  this.writeLength8(length);
812
769
  this._writeUTF8(utf8);
813
- };
814
- DataStreamWriter.prototype.writeUTF8_Length16LE = function (utf8) {
815
- var length = Buffer.byteLength(utf8);
770
+ }
771
+ writeUTF8_Length16LE(utf8) {
772
+ const length = Buffer.byteLength(utf8);
816
773
  this.ensureLength(3 + length);
817
774
  this.writeTag(98 /* DataFormatTags.UTF8_LENGTH16LE */);
818
775
  this.writeLength16LE(length);
819
776
  this._writeUTF8(utf8);
820
- };
821
- DataStreamWriter.prototype.writeUTF8_Length32LE = function (utf8) {
822
- var length = Buffer.byteLength(utf8);
777
+ }
778
+ writeUTF8_Length32LE(utf8) {
779
+ const length = Buffer.byteLength(utf8);
823
780
  this.ensureLength(5 + length);
824
781
  this.writeTag(99 /* DataFormatTags.UTF8_LENGTH32LE */);
825
782
  this.writeLength32LE(length);
826
783
  this._writeUTF8(utf8);
827
- };
828
- DataStreamWriter.prototype.writeUTF8_Length64LE = function (utf8) {
829
- var length = Buffer.byteLength(utf8);
784
+ }
785
+ writeUTF8_Length64LE(utf8) {
786
+ const length = Buffer.byteLength(utf8);
830
787
  this.ensureLength(9 + length);
831
788
  this.writeTag(100 /* DataFormatTags.UTF8_LENGTH64LE */);
832
789
  this.writeLength64LE(length);
833
790
  this._writeUTF8(utf8);
834
- };
835
- DataStreamWriter.prototype.writeUTF8_NULL_terminated = function (utf8) {
791
+ }
792
+ writeUTF8_NULL_terminated(utf8) {
836
793
  this.ensureLength(1 + Buffer.byteLength(utf8) + 1);
837
794
  this.writeTag(111 /* DataFormatTags.UTF8_NULL_TERMINATED */);
838
795
  this._writeUTF8(utf8);
839
796
  this.data.writeUInt8(0, this.writerIndex++);
840
- };
841
- DataStreamWriter.prototype.writeData = function (data) {
797
+ }
798
+ writeData(data) {
842
799
  if (this.compressDataIfPossible(data)) {
843
800
  return;
844
801
  }
@@ -861,44 +818,44 @@ var DataStreamWriter = /** @class */ (function () {
861
818
  else {
862
819
  this.writeData_terminated(data);
863
820
  }
864
- };
865
- DataStreamWriter.prototype._writeData = function (data) {
821
+ }
822
+ _writeData(data) {
866
823
  this.ensureLength(data.length);
867
- for (var i = 0; i < data.length; i++) {
824
+ for (let i = 0; i < data.length; i++) {
868
825
  this.data[this.writerIndex++] = data[i];
869
826
  }
870
- };
871
- DataStreamWriter.prototype.writeData_Length8 = function (data) {
827
+ }
828
+ writeData_Length8(data) {
872
829
  this.ensureLength(2 + data.length);
873
830
  this.writeTag(145 /* DataFormatTags.DATA_LENGTH8 */);
874
831
  this.writeLength8(data.length);
875
832
  this._writeData(data);
876
- };
877
- DataStreamWriter.prototype.writeData_Length16LE = function (data) {
833
+ }
834
+ writeData_Length16LE(data) {
878
835
  this.ensureLength(3 + data.length);
879
836
  this.writeTag(146 /* DataFormatTags.DATA_LENGTH16LE */);
880
837
  this.writeLength16LE(data.length);
881
838
  this._writeData(data);
882
- };
883
- DataStreamWriter.prototype.writeData_Length32LE = function (data) {
839
+ }
840
+ writeData_Length32LE(data) {
884
841
  this.ensureLength(5 + data.length);
885
842
  this.writeTag(147 /* DataFormatTags.DATA_LENGTH32LE */);
886
843
  this.writeLength32LE(data.length);
887
844
  this._writeData(data);
888
- };
889
- DataStreamWriter.prototype.writeData_Length64LE = function (data) {
845
+ }
846
+ writeData_Length64LE(data) {
890
847
  this.ensureLength(9 + data.length);
891
848
  this.writeTag(148 /* DataFormatTags.DATA_LENGTH64LE */);
892
849
  this.writeLength64LE(data.length);
893
850
  this._writeData(data);
894
- };
895
- DataStreamWriter.prototype.writeData_terminated = function (data) {
851
+ }
852
+ writeData_terminated(data) {
896
853
  this.ensureLength(1 + data.length + 1);
897
854
  this.writeTag(159 /* DataFormatTags.DATA_TERMINATED */);
898
855
  this._writeData(data);
899
856
  this.writeTag(3 /* DataFormatTags.TERMINATOR */);
900
- };
901
- DataStreamWriter.prototype.writeSecondsSince2001_01_01 = function (seconds) {
857
+ }
858
+ writeSecondsSince2001_01_01(seconds) {
902
859
  if (this.compressDataIfPossible(seconds)) {
903
860
  return;
904
861
  }
@@ -906,8 +863,8 @@ var DataStreamWriter = /** @class */ (function () {
906
863
  this.writeTag(6 /* DataFormatTags.DATE */);
907
864
  this.data.writeDoubleLE(seconds.value, this.writerIndex);
908
865
  this.writerIndex += 8;
909
- };
910
- DataStreamWriter.prototype.writeUUID = function (uuid_string) {
866
+ }
867
+ writeUUID(uuid_string) {
911
868
  (0, assert_1.default)(uuid.isValid(uuid_string), "supplied uuid is invalid");
912
869
  if (this.compressDataIfPossible(new UUID(uuid_string))) {
913
870
  return;
@@ -916,9 +873,7 @@ var DataStreamWriter = /** @class */ (function () {
916
873
  this.writeTag(5 /* DataFormatTags.UUID */);
917
874
  uuid.write(uuid_string, this.data, this.writerIndex);
918
875
  this.writerIndex += 16;
919
- };
920
- DataStreamWriter.chunkSize = 128; // seems to be a good default
921
- return DataStreamWriter;
922
- }());
876
+ }
877
+ }
923
878
  exports.DataStreamWriter = DataStreamWriter;
924
879
  //# sourceMappingURL=DataStreamParser.js.map