@mega-yfue/eufy-sdk 0.5.0-beta.49 → 0.5.0-beta.50

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
@@ -3334,6 +3334,7 @@ function propertiesOf(members, ctx) {
3334
3334
  raw: m.decode ? true : void 0,
3335
3335
  readAliases: aliases?.slice(promoted ? 1 : 0).map(({ paramType, invert }) => ({ paramType, invert })),
3336
3336
  writable: m.write !== void 0 || m.writtenElsewhere === true,
3337
+ reported: ctx?.paramIds ? wasReported(m, borrowedBy(m, members), { ...ctx, paramIds: ctx.paramIds }) : void 0,
3337
3338
  description: m.description
3338
3339
  }
3339
3340
  ];
@@ -3409,12 +3410,16 @@ function narrow(type, read, prop) {
3409
3410
  return readNum(read, prop);
3410
3411
  }
3411
3412
  function reads(m, ctx) {
3412
- if (m.realtime === true)
3413
- return true;
3413
+ return m.realtime === true || sent(m, ctx);
3414
+ }
3415
+ function sent(m, ctx) {
3414
3416
  if ((!m.readAvailable || m.readAvailable(ctx)) && m.param !== void 0 && ctx.paramIds.has(m.param))
3415
3417
  return true;
3416
3418
  return m.readAliases?.some((a) => (!a.available || a.available(ctx)) && ctx.paramIds.has(a.paramType)) === true;
3417
3419
  }
3420
+ function wasReported(m, from, ctx) {
3421
+ return sent(m, ctx) || from !== void 0 && ctx.paramIds.has(from.param);
3422
+ }
3418
3423
  function installs(m, ctx) {
3419
3424
  return reports(m.requires, ctx) && (!m.requiresRead || reads(m, ctx)) && (!m.available || m.available(ctx));
3420
3425
  }
@@ -3451,7 +3456,7 @@ function bindMembers(members, deps) {
3451
3456
  const from = borrowedBy(m, members);
3452
3457
  const borrowed = from?.property;
3453
3458
  const available = !m.available || m.available(ctx);
3454
- const reported = available && (reads(m, ctx) || from !== void 0 && ctx.paramIds.has(from.param));
3459
+ const reported = available && (m.realtime === true || wasReported(m, from, ctx));
3455
3460
  if (reported && !m.writeOnly && !m.unexposed) {
3456
3461
  const decode = m.decode;
3457
3462
  const raw = () => read(prop)?.value ?? (borrowed === void 0 ? void 0 : read(borrowed)?.value);
@@ -7888,22 +7893,22 @@ var ARMING_MEMBERS = {
7888
7893
  * not revert it; a write whose dispatch rejects is not built on.
7889
7894
  */
7890
7895
  setDeviceNotification: method(({ ctx, sink, read }) => {
7891
- const sent = /* @__PURE__ */ new Map();
7896
+ const sent2 = /* @__PURE__ */ new Map();
7892
7897
  return (mode, channel, on) => {
7893
- const last = sent.get(mode);
7898
+ const last = sent2.get(mode);
7894
7899
  const observed = read(`${mode}ActionTable`)?.ts ?? 0;
7895
7900
  const base = last && observed < last.at + ACTION_TABLE_LAG_MS ? last.table : actionTable(read, mode);
7896
7901
  const table = withDeviceNotification(base, channel, on);
7897
7902
  if (!table) {
7898
7903
  return Promise.reject(new Error(`arming: no ${mode} action table lists channel ${channel} [${describeDevice(ctx)}]`));
7899
7904
  }
7900
- sent.set(mode, { table, at: Date.now() });
7905
+ sent2.set(mode, { table, at: Date.now() });
7901
7906
  return sink.dispatch(setJsonRaw(ARMING_CMD.SET_ALL_ACTION, table, ctx, 0)).catch((err) => {
7902
- if (sent.get(mode)?.table === table) {
7907
+ if (sent2.get(mode)?.table === table) {
7903
7908
  if (last)
7904
- sent.set(mode, last);
7909
+ sent2.set(mode, last);
7905
7910
  else
7906
- sent.delete(mode);
7911
+ sent2.delete(mode);
7907
7912
  }
7908
7913
  throw err;
7909
7914
  });
@@ -13199,7 +13204,7 @@ function coerce(spec, raw, invert = false, logger = noopLogger) {
13199
13204
  function sameManifest(a, b) {
13200
13205
  if (a.length !== b.length)
13201
13206
  return false;
13202
- const sig = (p) => JSON.stringify([p.name, p.writable, p.enumValues ?? null]);
13207
+ const sig = (p) => JSON.stringify([p.name, p.writable, p.reported ?? null, p.enumValues ?? null]);
13203
13208
  const bSigs = new Set(b.map(sig));
13204
13209
  return a.every((p) => bSigs.has(sig(p)));
13205
13210
  }
@@ -22417,13 +22422,13 @@ var P2PCommandRouter = class _P2PCommandRouter {
22417
22422
  */
22418
22423
  async replayLevel2Send(sn, describe2, send, resolved) {
22419
22424
  resolved ??= await this.resolveSession(sn, { waitLevel2: true });
22420
- let sent = false;
22425
+ let sent2 = false;
22421
22426
  for (let i = 0; i < DIRECT_CMD_SENDS; i++) {
22422
22427
  if (send(resolved))
22423
- sent = true;
22428
+ sent2 = true;
22424
22429
  await sleep2(200);
22425
22430
  }
22426
- if (!sent) {
22431
+ if (!sent2) {
22427
22432
  throw new Error(`${describe2} for ${sn} was never sent (no level-2 key / session not connected)`);
22428
22433
  }
22429
22434
  }
@@ -22882,7 +22887,7 @@ var RtcLiveStream = class extends EventEmitter7 {
22882
22887
  session.on("commandData", this.onCommand);
22883
22888
  session.on("close", this.onClose);
22884
22889
  this.startSegment = seg.next();
22885
- const sent = session.sendCommand(buildPortalPacket({
22890
+ const sent2 = session.sendCommand(buildPortalPacket({
22886
22891
  commandId: PORTAL_CMD_SET_PAYLOAD,
22887
22892
  channel: PORTAL_STATION_CHANNEL,
22888
22893
  segment: this.startSegment,
@@ -22906,7 +22911,7 @@ var RtcLiveStream = class extends EventEmitter7 {
22906
22911
  }
22907
22912
  }
22908
22913
  }));
22909
- if (!sent) {
22914
+ if (!sent2) {
22910
22915
  queueMicrotask(() => this.fail(new Error(`rtc live ${this.tag}: command channel not open`)));
22911
22916
  return this;
22912
22917
  }