@crvouga/mockingbird-service-aws-iot 0.9.7 → 0.9.8

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/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Changelog — @crvouga/mockingbird-service-aws-iot
2
2
 
3
- ## 0.9.7 (2026-11-03)
3
+ ## 0.9.8 (2026-11-03)
4
+
5
+ ### Fixes and improvements
6
+
7
+ - list migrations applied in the same second in run order ([f8c0591](https://github.com/crvouga/mockingbird/commit/f8c059146a65bfaf7fe99b4d3b6e812e82602bb9))
8
+ - reassemble packets and WebSocket frames in linear time ([42b8ab7](https://github.com/crvouga/mockingbird/commit/42b8ab7ccf31f128a3be600ed4a3722c81bf1bea))
9
+
10
+ ## 0.9.7 (2026-11-02)
4
11
 
5
12
  ### Fixes and improvements
6
13
 
@@ -16,10 +23,6 @@
16
23
  - reserve the manual admin view id ([3d4da92](https://github.com/crvouga/mockingbird/commit/3d4da926182ce609fba44e0fd58abcbb253eee2c))
17
24
  - cap a reassembled WebSocket message and close with 1009 past it ([ae04b19](https://github.com/crvouga/mockingbird/commit/ae04b19cad284380e376cff5222d6e1af14d6d45))
18
25
 
19
- ### Dependencies
20
-
21
- - `@crvouga/mockingbird-service-sqlite`
22
-
23
26
  ## 0.9.6 (2026-11-02)
24
27
 
25
28
  ### Fixes and improvements
@@ -5558,7 +5558,7 @@ var stateAdminRoutes = (routes) => {
5558
5558
  };
5559
5559
 
5560
5560
  // ../core/dist/version.js
5561
- var PACKAGE_VERSION = true ? "0.9.7" : UNRELEASED_VERSION;
5561
+ var PACKAGE_VERSION = true ? "0.9.8" : UNRELEASED_VERSION;
5562
5562
 
5563
5563
  // ../core/dist/webhooks.js
5564
5564
  var json4 = (status, body) => new Response(JSON.stringify(body), {
@@ -7393,7 +7393,11 @@ var packetLength = (buffer) => {
7393
7393
  };
7394
7394
  var PacketReader = class {
7395
7395
  maxPacketSize;
7396
- buffer = new Uint8Array(0);
7396
+ chunks = [];
7397
+ /** Bytes of `chunks[0]` already consumed. */
7398
+ head = 0;
7399
+ /** Bytes held and not yet consumed. */
7400
+ buffered = 0;
7397
7401
  /** `maxPacketSize` is the Maximum Packet Size this endpoint advertised (3.2.2.3.6). */
7398
7402
  constructor(maxPacketSize = MAX_VARIABLE_BYTE_INTEGER + 5) {
7399
7403
  this.maxPacketSize = maxPacketSize;
@@ -7403,32 +7407,69 @@ var PacketReader = class {
7403
7407
  * decoded stops the stream: its error is returned after the packets before it.
7404
7408
  */
7405
7409
  push(chunk) {
7406
- const joined = new Uint8Array(this.buffer.length + chunk.length);
7407
- joined.set(this.buffer);
7408
- joined.set(chunk, this.buffer.length);
7409
- this.buffer = joined;
7410
+ if (chunk.length > 0) {
7411
+ this.chunks.push(chunk);
7412
+ this.buffered += chunk.length;
7413
+ }
7410
7414
  const packets = [];
7411
7415
  try {
7412
7416
  for (; ; ) {
7413
- const length = packetLength(this.buffer);
7417
+ const length = packetLength(this.peek(5));
7414
7418
  if (length === void 0)
7415
7419
  break;
7416
7420
  if (length > this.maxPacketSize) {
7417
7421
  throw new MqttProtocolError(ReasonCode.PacketTooLarge, `packet of ${length} bytes`);
7418
7422
  }
7419
- if (this.buffer.length < length)
7423
+ if (this.buffered < length)
7420
7424
  break;
7421
- packets.push(decodePacket(this.buffer.subarray(0, length)));
7422
- this.buffer = this.buffer.slice(length);
7425
+ packets.push(decodePacket(this.take(length)));
7423
7426
  }
7424
7427
  } catch (error) {
7425
- this.buffer = new Uint8Array(0);
7428
+ this.chunks = [];
7429
+ this.head = 0;
7430
+ this.buffered = 0;
7426
7431
  if (error instanceof MqttProtocolError)
7427
7432
  return { packets, error };
7428
7433
  throw error;
7429
7434
  }
7430
7435
  return { packets };
7431
7436
  }
7437
+ /** Up to the first `count` held bytes, without consuming them. */
7438
+ peek(count2) {
7439
+ const bytes = [];
7440
+ let skip = this.head;
7441
+ for (const chunk of this.chunks) {
7442
+ for (let index = skip; index < chunk.length && bytes.length < count2; index++) {
7443
+ bytes.push(chunk[index] ?? 0);
7444
+ }
7445
+ if (bytes.length === count2)
7446
+ break;
7447
+ skip = 0;
7448
+ }
7449
+ return Uint8Array.from(bytes);
7450
+ }
7451
+ /** Consume the first `length` held bytes into a fresh array (decoded packets keep views of it). */
7452
+ take(length) {
7453
+ const out = new Uint8Array(length);
7454
+ let filled = 0;
7455
+ let used = 0;
7456
+ while (filled < length) {
7457
+ const chunk = this.chunks[used];
7458
+ if (!chunk)
7459
+ break;
7460
+ const count2 = Math.min(chunk.length - this.head, length - filled);
7461
+ out.set(chunk.subarray(this.head, this.head + count2), filled);
7462
+ filled += count2;
7463
+ this.head += count2;
7464
+ if (this.head === chunk.length) {
7465
+ used += 1;
7466
+ this.head = 0;
7467
+ }
7468
+ }
7469
+ this.chunks.splice(0, used);
7470
+ this.buffered -= length;
7471
+ return out;
7472
+ }
7432
7473
  };
7433
7474
 
7434
7475
  // ../../mqtt/broker/dist/topics.js
@@ -9138,4 +9179,4 @@ export {
9138
9179
  splitUsername,
9139
9180
  AwsIotAPI
9140
9181
  };
9141
- //# sourceMappingURL=chunk-BVRCGL7Y.js.map
9182
+ //# sourceMappingURL=chunk-RSCOKDEF.js.map