@apocaliss92/nodelink-js 0.4.19 → 0.4.20

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.
@@ -18970,9 +18970,11 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
18970
18970
  if (!this.sessionGuardIntervalTimer) {
18971
18971
  client.once("push", () => {
18972
18972
  void this.logActiveSessionsOnStartup();
18973
- this.sessionGuardIntervalTimer = setInterval(() => {
18974
- void this.maybeRebootOnTooManySessions();
18975
- }, 6e4);
18973
+ if (this.sessionGuardEnabled) {
18974
+ this.sessionGuardIntervalTimer = setInterval(() => {
18975
+ void this.maybeRebootOnTooManySessions();
18976
+ }, 6e4);
18977
+ }
18976
18978
  });
18977
18979
  }
18978
18980
  }
@@ -19005,6 +19007,19 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19005
19007
  _isMultiFocal;
19006
19008
  /** Maximum dedicated sessions allowed before triggering a reboot (default: 7). */
19007
19009
  maxDedicatedSessionsBeforeReboot;
19010
+ /**
19011
+ * Opt-in: when `false` (default), the lib never starts the 60s periodic
19012
+ * `getOnlineUserList` poll and never schedules an automatic reboot based
19013
+ * on the session count. The post-socket-create probe at line ~1859 is
19014
+ * also skipped. Consumers that want the legacy behaviour can pass
19015
+ * `enableSessionGuard: true` to the constructor.
19016
+ *
19017
+ * Rationale: on BCUDP (battery cameras) the periodic poll wakes the
19018
+ * camera every minute and triggers a perpetual sleeping↔awake cycle —
19019
+ * see issue #18. Even on AC cameras the auto-reboot side effect is
19020
+ * surprising; making it explicit avoids astonishment.
19021
+ */
19022
+ sessionGuardEnabled = false;
19008
19023
  sessionGuardRebootInFlight;
19009
19024
  sessionGuardLastRebootAtMs;
19010
19025
  /** Track last known session count and IDs for change detection. */
@@ -19696,7 +19711,9 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19696
19711
  } catch {
19697
19712
  }
19698
19713
  }
19699
- void this.maybeRebootOnTooManySessions();
19714
+ if (this.sessionGuardEnabled) {
19715
+ void this.maybeRebootOnTooManySessions();
19716
+ }
19700
19717
  return newClient;
19701
19718
  } catch (loginError) {
19702
19719
  const prevCooldown = this.socketPoolCooldowns.get(this.host);
@@ -20006,6 +20023,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
20006
20023
  logger: this.logger,
20007
20024
  debugConfig: generalClient.getDebugConfig?.()
20008
20025
  });
20026
+ this.sessionGuardEnabled = opts.enableSessionGuard === true;
20009
20027
  const maxSessions = opts.maxDedicatedSessionsBeforeReboot;
20010
20028
  if (typeof maxSessions === "number" && Number.isFinite(maxSessions) && maxSessions > 0) {
20011
20029
  this.maxDedicatedSessionsBeforeReboot = Math.floor(maxSessions);
@@ -20179,6 +20197,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
20179
20197
  */
20180
20198
  async maybeRebootOnTooManySessions() {
20181
20199
  if (!this.client.isSocketConnected?.()) return;
20200
+ if (this.client.getTransport?.() === "udp") return;
20182
20201
  const threshold = this.maxDedicatedSessionsBeforeReboot ?? 10;
20183
20202
  if (this.sessionGuardRebootInFlight) return;
20184
20203
  const cooldownMs = 10 * 6e4;
@@ -26523,7 +26542,17 @@ ${xml}`
26523
26542
  const isSingleMotionModel = normalizedModel ? checkModelMatch(DUAL_LENS_SINGLE_MOTION_MODELS, normalizedModel) : false;
26524
26543
  const channelNumValue = typeof channelNum === "string" ? Number.parseInt(channelNum, 10) : channelNum;
26525
26544
  const hasDualLensChannelCount = channelNumValue === 2 && Number.isFinite(channelNumValue);
26526
- const isDualLens = isDualMotionModel || isSingleMotionModel || hasDualLensChannelCount;
26545
+ const supportItemForChannel = (() => {
26546
+ if (!supportInfo) return void 0;
26547
+ const items = supportInfo.items;
26548
+ if (!Array.isArray(items)) return void 0;
26549
+ return items.find(
26550
+ (it) => typeof it === "object" && it !== null && "ledCtrl" in it
26551
+ );
26552
+ })();
26553
+ const binoCfgRaw = supportItemForChannel ? supportItemForChannel.binoCfg : void 0;
26554
+ const hasBinoCfgFlag = typeof binoCfgRaw === "number" ? binoCfgRaw > 0 : typeof binoCfgRaw === "string" ? Number(binoCfgRaw) > 0 : false;
26555
+ const isDualLens = hasBinoCfgFlag || isDualMotionModel || isSingleMotionModel || hasDualLensChannelCount;
26527
26556
  if (!isDualLens) {
26528
26557
  return {
26529
26558
  isDualLens: false,