@mega-yfue/eufy-sdk 0.5.0-beta.34 → 0.5.0-beta.36
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/dist/index.js +14 -10
- package/dist/index.js.map +2 -2
- package/dist/transport/p2p/p2p-session.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6160,7 +6160,8 @@ var LIGHT_SWITCH_INT_STRING_TYPES = /* @__PURE__ */ new Set([
|
|
|
6160
6160
|
DeviceType.CAMERA2_PRO,
|
|
6161
6161
|
DeviceType.CAMERA2C_PRO,
|
|
6162
6162
|
DeviceType.CAMERA3,
|
|
6163
|
-
DeviceType.CAMERA3C
|
|
6163
|
+
DeviceType.CAMERA3C,
|
|
6164
|
+
DeviceType.PROFESSIONAL_247
|
|
6164
6165
|
]);
|
|
6165
6166
|
function switchCommand(on, ctx) {
|
|
6166
6167
|
switch (lightSwitchWire(ctx)) {
|
|
@@ -17119,32 +17120,35 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
17119
17120
|
* Frames are packed back to back, so a frame header can itself be cut by a datagram boundary. The start
|
|
17120
17121
|
* of a header left at the end of a datagram is carried into the next one rather than discarded; dropping
|
|
17121
17122
|
* it would lose that frame and every frame after it until a datagram happened to begin on a header.
|
|
17123
|
+
* Payload fragments retain their original slices and are copied once, when the complete frame is delivered.
|
|
17122
17124
|
*/
|
|
17123
17125
|
reassemble(dataType, datagramBody) {
|
|
17124
17126
|
const pending = this.pendingByDataType.get(dataType);
|
|
17125
|
-
let body = pending ? Buffer.concat([pending.buf, datagramBody]) : datagramBody;
|
|
17126
|
-
const carryHeader = pending?.header;
|
|
17127
17127
|
this.pendingByDataType.delete(dataType);
|
|
17128
|
-
|
|
17129
|
-
|
|
17130
|
-
|
|
17128
|
+
let body = pending && !pending.header ? Buffer.concat([...pending.chunks, datagramBody]) : datagramBody;
|
|
17129
|
+
if (pending?.header) {
|
|
17130
|
+
const taken = Math.min(pending.header.bytesToRead - pending.byteLength, body.length);
|
|
17131
|
+
pending.chunks.push(body.subarray(0, taken));
|
|
17132
|
+
pending.byteLength += taken;
|
|
17133
|
+
body = body.subarray(taken);
|
|
17134
|
+
if (pending.byteLength < pending.header.bytesToRead) {
|
|
17135
|
+
this.pendingByDataType.set(dataType, pending);
|
|
17131
17136
|
return;
|
|
17132
17137
|
}
|
|
17133
|
-
this.handleFrame(
|
|
17134
|
-
body = body.subarray(carryHeader.bytesToRead);
|
|
17138
|
+
this.handleFrame(pending.header, Buffer.concat(pending.chunks, pending.byteLength), dataType);
|
|
17135
17139
|
}
|
|
17136
17140
|
while (body.length >= P2P_DATA_HEADER_BYTES && body.subarray(0, 4).toString() === MAGIC_WORD) {
|
|
17137
17141
|
const header = parseDataFrameHeader(body);
|
|
17138
17142
|
const payload = body.subarray(P2P_DATA_HEADER_BYTES);
|
|
17139
17143
|
if (payload.length < header.bytesToRead) {
|
|
17140
|
-
this.pendingByDataType.set(dataType, { header,
|
|
17144
|
+
this.pendingByDataType.set(dataType, { header, chunks: [payload], byteLength: payload.length });
|
|
17141
17145
|
return;
|
|
17142
17146
|
}
|
|
17143
17147
|
this.handleFrame(header, payload.subarray(0, header.bytesToRead), dataType);
|
|
17144
17148
|
body = body.subarray(P2P_DATA_HEADER_BYTES + header.bytesToRead);
|
|
17145
17149
|
}
|
|
17146
17150
|
if (body.length > 0 && body.length < P2P_DATA_HEADER_BYTES && MAGIC_WORD.startsWith(body.subarray(0, 4).toString())) {
|
|
17147
|
-
this.pendingByDataType.set(dataType, {
|
|
17151
|
+
this.pendingByDataType.set(dataType, { chunks: [body], byteLength: body.length });
|
|
17148
17152
|
}
|
|
17149
17153
|
}
|
|
17150
17154
|
/**
|