@mega-yfue/eufy-sdk 0.4.0-beta.12 → 0.4.0-beta.14
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
CHANGED
|
@@ -5743,7 +5743,7 @@ var SIREN_CMD = {
|
|
|
5743
5743
|
ALARM_TEST: 1826,
|
|
5744
5744
|
/** Manually stop a sounding alarm (app `APP_CMD_SIREN_SENSOR_MANUAL_STOP_ALARM`). */
|
|
5745
5745
|
MANUAL_STOP: 1871,
|
|
5746
|
-
/** Station-family HomeBase duration alarm, verified live on T8010 (app `SET_TONE_FILE`). */
|
|
5746
|
+
/** Station-family HomeBase duration alarm, verified live on T8010 and T8030 (app `SET_TONE_FILE`). */
|
|
5747
5747
|
HOMEBASE_TONE: 1201,
|
|
5748
5748
|
/** HomeBase alarm volume percentage (app `CMD_SET_HUB_SPK_VOLUME`). */
|
|
5749
5749
|
HUB_SPK_VOLUME: 1235,
|
|
@@ -5758,7 +5758,7 @@ var SirenAlarmDuration = { Min1: 60, Min5: 300, Min10: 600, Min15: 900 };
|
|
|
5758
5758
|
var HubAlarmTone = { Tone1: 1, Tone2: 2 };
|
|
5759
5759
|
var HUB_ALARM_EVIDENCE = [SIREN_CMD.HUB_ALARM_TONE, 1282];
|
|
5760
5760
|
function isStationAlarmOutput(ctx) {
|
|
5761
|
-
return ctx.deviceType === DeviceType.STATION;
|
|
5761
|
+
return ctx.deviceType === DeviceType.STATION || ctx.deviceType === DeviceType.HB3;
|
|
5762
5762
|
}
|
|
5763
5763
|
function isEvidencedStationAlarm(ctx) {
|
|
5764
5764
|
return isStationAlarmOutput(ctx) && HUB_ALARM_EVIDENCE.some((param) => ctx.paramIds.has(param));
|
|
@@ -24364,6 +24364,7 @@ var MEDIA_FAILURE_REASONS = [
|
|
|
24364
24364
|
// dist/transport/stored-image-cache.js
|
|
24365
24365
|
var MAX_JPEG_BYTES = 10 * 1024 * 1024;
|
|
24366
24366
|
var MAX_REMEMBERED_URLS = 64;
|
|
24367
|
+
var NOT_YET_PUBLISHED_RETRY_MS = [2e3, 4e3];
|
|
24367
24368
|
var DIAGNOSTIC_INTERVAL_MS = 6e4;
|
|
24368
24369
|
var StoredImageCache = class {
|
|
24369
24370
|
downloader;
|
|
@@ -24401,6 +24402,8 @@ var StoredImageCache = class {
|
|
|
24401
24402
|
if (state.seenUrls.has(url))
|
|
24402
24403
|
return;
|
|
24403
24404
|
state.seenUrls.add(url);
|
|
24405
|
+
clearTimeout(state.retrying);
|
|
24406
|
+
state.retrying = void 0;
|
|
24404
24407
|
while (state.seenUrls.size > MAX_REMEMBERED_URLS) {
|
|
24405
24408
|
const oldest = state.seenUrls.values().next();
|
|
24406
24409
|
if (oldest.done)
|
|
@@ -24412,14 +24415,15 @@ var StoredImageCache = class {
|
|
|
24412
24415
|
url,
|
|
24413
24416
|
sequence: ++state.nextSequence,
|
|
24414
24417
|
observedAt: this.clock(),
|
|
24415
|
-
generation: this.generation
|
|
24418
|
+
generation: this.generation,
|
|
24419
|
+
retries: 0
|
|
24416
24420
|
};
|
|
24417
24421
|
this.pump();
|
|
24418
24422
|
}
|
|
24419
24423
|
/** Return retained bytes without starting or awaiting network work. */
|
|
24420
24424
|
snapshotStored(deviceKey) {
|
|
24421
24425
|
const state = this.devices.get(deviceKey);
|
|
24422
|
-
const reason = state?.queued || state?.inFlight ? "pending" : state?.reason ?? "not-observed";
|
|
24426
|
+
const reason = state?.queued || state?.inFlight || state?.retrying ? "pending" : state?.reason ?? "not-observed";
|
|
24423
24427
|
if (reason !== "pending" && state?.lifecycleError)
|
|
24424
24428
|
return Promise.reject(state.lifecycleError);
|
|
24425
24429
|
if (state?.retained)
|
|
@@ -24453,6 +24457,8 @@ var StoredImageCache = class {
|
|
|
24453
24457
|
if (error !== void 0 && this.isLifecycleError(error)) {
|
|
24454
24458
|
state.lifecycleError = error;
|
|
24455
24459
|
state.reason = void 0;
|
|
24460
|
+
} else if (image === void 0 && this.retryLater(state, candidate, error)) {
|
|
24461
|
+
state.lifecycleError = void 0;
|
|
24456
24462
|
} else if (image === void 0) {
|
|
24457
24463
|
state.lifecycleError = void 0;
|
|
24458
24464
|
state.reason = "download-failed";
|
|
@@ -24469,6 +24475,21 @@ var StoredImageCache = class {
|
|
|
24469
24475
|
}
|
|
24470
24476
|
this.pump();
|
|
24471
24477
|
}
|
|
24478
|
+
/** Schedule the next attempt after a 404; answers whether one was scheduled. */
|
|
24479
|
+
retryLater(state, candidate, error) {
|
|
24480
|
+
const delay = NOT_YET_PUBLISHED_RETRY_MS[candidate.retries];
|
|
24481
|
+
const tag2 = mediaFailureTag(error);
|
|
24482
|
+
if (delay === void 0 || tag2.cause !== "http-status" || tag2.status !== 404 || state.queued)
|
|
24483
|
+
return false;
|
|
24484
|
+
const timer = setTimeout(() => {
|
|
24485
|
+
state.retrying = void 0;
|
|
24486
|
+
state.queued = { ...candidate, retries: candidate.retries + 1 };
|
|
24487
|
+
this.pump();
|
|
24488
|
+
}, delay);
|
|
24489
|
+
timer.unref?.();
|
|
24490
|
+
state.retrying = timer;
|
|
24491
|
+
return true;
|
|
24492
|
+
}
|
|
24472
24493
|
isValidJpeg(image) {
|
|
24473
24494
|
return Buffer.isBuffer(image) && image.length > 0 && image.length <= MAX_JPEG_BYTES && image.length >= 5 && image[0] === 255 && image[1] === 216 && image[2] === 255 && image[image.length - 2] === 255 && image[image.length - 1] === 217;
|
|
24474
24495
|
}
|