@mega-yfue/eufy-sdk 0.6.0-beta.39 → 0.6.0-beta.40

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.
@@ -63,6 +63,11 @@ export declare class EufyMega extends EventEmitter {
63
63
  /** Device list/record/capability resolution + the frame→caps cache. */
64
64
  private readonly registry;
65
65
  private pushClient?;
66
+ /**
67
+ * Second FCM deliveries of one detection. Only pulse events (no {@link STATE_EVENT_FIELDS} entry) are
68
+ * held back on a repeat; state-carrying events are already edge-triggered by {@link noteState}.
69
+ */
70
+ private readonly pushRepeats;
66
71
  /** Push-fed passive image store; absent when the caller disables acquisition. */
67
72
  private readonly storedImages?;
68
73
  /** Account whose retained images are currently held. */
@@ -0,0 +1,10 @@
1
+ import type { PushEvent } from "../transport/push/types.js";
2
+ /**
3
+ * A push repeats an earlier one with the same device, `event_type` and `unique_id` within the window,
4
+ * and a push missing any of the three never does.
5
+ */
6
+ export declare class PushRepeats {
7
+ private readonly seen;
8
+ /** Record this push, answering `true` when it repeats one already recorded. */
9
+ repeat(event: PushEvent): boolean;
10
+ }
package/dist/index.js CHANGED
@@ -29761,6 +29761,27 @@ var DeviceRegistry = class {
29761
29761
  }
29762
29762
  };
29763
29763
 
29764
+ // dist/client/push-repeats.js
29765
+ var WINDOW_MS = 3e4;
29766
+ var PushRepeats = class {
29767
+ seen = /* @__PURE__ */ new Map();
29768
+ /** Record this push, answering `true` when it repeats one already recorded. */
29769
+ repeat(event) {
29770
+ const uniqueId = event.payload.unique_id;
29771
+ if (!event.deviceSn || event.eventType == null || typeof uniqueId !== "string" || !uniqueId)
29772
+ return false;
29773
+ const at = Date.now();
29774
+ for (const [key2, seenAt] of this.seen)
29775
+ if (at - seenAt > WINDOW_MS)
29776
+ this.seen.delete(key2);
29777
+ const key = `${event.deviceSn}:${event.eventType}:${uniqueId}`;
29778
+ if (this.seen.has(key))
29779
+ return true;
29780
+ this.seen.set(key, at);
29781
+ return false;
29782
+ }
29783
+ };
29784
+
29764
29785
  // dist/client/eufy-mega.js
29765
29786
  function recordString(raw, key) {
29766
29787
  const nested = raw.deviceParams?.[key];
@@ -29827,6 +29848,11 @@ var EufyMega = class _EufyMega extends EventEmitter14 {
29827
29848
  /** Device list/record/capability resolution + the frame→caps cache. */
29828
29849
  registry;
29829
29850
  pushClient;
29851
+ /**
29852
+ * Second FCM deliveries of one detection. Only pulse events (no {@link STATE_EVENT_FIELDS} entry) are
29853
+ * held back on a repeat; state-carrying events are already edge-triggered by {@link noteState}.
29854
+ */
29855
+ pushRepeats = new PushRepeats();
29830
29856
  /** Push-fed passive image store; absent when the caller disables acquisition. */
29831
29857
  storedImages;
29832
29858
  /** Account whose retained images are currently held. */
@@ -31995,8 +32021,10 @@ var EufyMega = class _EufyMega extends EventEmitter14 {
31995
32021
  payload: ev.payload
31996
32022
  };
31997
32023
  const caps = this.capsForEvent(ev.deviceSn);
31998
- const decoded = decodeEvent(signal2, caps);
31999
- this.opts.logger?.debug(`[push] in: eventType=${ev.eventType} device=${caps ? "known" : ev.deviceSn ? "unknown" : "none"} events=${decoded.length}`);
32024
+ const all = decodeEvent(signal2, caps);
32025
+ const repeat = all.some((out) => !STATE_EVENT_FIELDS[out.event]) && this.pushRepeats.repeat(ev);
32026
+ const decoded = repeat ? all.filter((out) => STATE_EVENT_FIELDS[out.event]) : all;
32027
+ this.opts.logger?.debug(`[push] in: eventType=${ev.eventType} device=${caps ? "known" : ev.deviceSn ? "unknown" : "none"} events=${decoded.length}${repeat ? " (repeat)" : ""}`);
32000
32028
  for (const out of decoded) {
32001
32029
  this.emitSemantic(out.event, out.payload, { edge: true, refresh: out.refresh });
32002
32030
  const dsn = out.payload.deviceSn ?? ev.deviceSn;