@apocaliss92/nodelink-js 0.4.24 → 0.4.26

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.
@@ -3,7 +3,7 @@ import {
3
3
  BaichuanRtspServer,
4
4
  ReolinkBaichuanApi,
5
5
  autoDetectDeviceType
6
- } from "../chunk-JYHK2ZSH.js";
6
+ } from "../chunk-F3XCYKYT.js";
7
7
  import "../chunk-AHY4L7JI.js";
8
8
  import {
9
9
  __require
package/dist/index.cjs CHANGED
@@ -19635,6 +19635,39 @@ var applyFloodlightSettingsToXml = (xml, settings) => {
19635
19635
  return modifiedXml;
19636
19636
  };
19637
19637
 
19638
+ // src/reolink/baichuan/utils/whiteLedStatusPush.ts
19639
+ var parseFloodlightStatusListPushXml = (xml) => {
19640
+ const out = [];
19641
+ const re = /<channel>\s*(\d+)\s*<\/channel>[\s\S]*?<status>\s*(\d+)\s*<\/status>/gi;
19642
+ let m;
19643
+ while ((m = re.exec(xml)) !== null) {
19644
+ const channel = Number.parseInt(m[1] ?? "", 10);
19645
+ const status = Number.parseInt(m[2] ?? "", 10);
19646
+ if (!Number.isFinite(channel) || !Number.isFinite(status)) continue;
19647
+ out.push({ channel, status });
19648
+ }
19649
+ return out;
19650
+ };
19651
+
19652
+ // src/reolink/baichuan/utils/sirenStatusPush.ts
19653
+ var parseSirenStatusListPushXml = (xml) => {
19654
+ const out = [];
19655
+ const re = /<(?:channelId|channel)>\s*(\d+)\s*<\/(?:channelId|channel)>[\s\S]*?<status>\s*(\d+)\s*<\/status>(?:[\s\S]*?<playing>\s*(\d+)\s*<\/playing>)?/gi;
19656
+ let m;
19657
+ while ((m = re.exec(xml)) !== null) {
19658
+ const channel = Number.parseInt(m[1] ?? "", 10);
19659
+ const status = Number.parseInt(m[2] ?? "", 10);
19660
+ if (!Number.isFinite(channel) || !Number.isFinite(status)) continue;
19661
+ const entry = { channel, status };
19662
+ if (m[3] !== void 0) {
19663
+ const playing = Number.parseInt(m[3], 10);
19664
+ if (Number.isFinite(playing)) entry.playing = playing;
19665
+ }
19666
+ out.push(entry);
19667
+ }
19668
+ return out;
19669
+ };
19670
+
19638
19671
  // src/reolink/baichuan/ReolinkBaichuanApi.ts
19639
19672
  var DUAL_LENS_DUAL_MOTION_MODELS = /* @__PURE__ */ new Set([
19640
19673
  "Reolink Duo PoE",
@@ -19913,7 +19946,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19913
19946
  });
19914
19947
  client.on("push", (frame) => {
19915
19948
  const cmdId = frame.header.cmdId;
19916
- if (cmdId !== BC_CMD_ID_PUSH_VIDEO_INPUT && cmdId !== BC_CMD_ID_PUSH_SERIAL && cmdId !== BC_CMD_ID_PUSH_NET_INFO && cmdId !== BC_CMD_ID_PUSH_DINGDONG_LIST && cmdId !== BC_CMD_ID_PUSH_SLEEP_STATUS && cmdId !== BC_CMD_ID_PUSH_COORDINATE_POINT_LIST) {
19949
+ if (cmdId !== BC_CMD_ID_PUSH_VIDEO_INPUT && cmdId !== BC_CMD_ID_PUSH_SERIAL && cmdId !== BC_CMD_ID_PUSH_NET_INFO && cmdId !== BC_CMD_ID_PUSH_DINGDONG_LIST && cmdId !== BC_CMD_ID_PUSH_SLEEP_STATUS && cmdId !== BC_CMD_ID_PUSH_COORDINATE_POINT_LIST && cmdId !== BC_CMD_ID_FLOODLIGHT_STATUS_LIST && cmdId !== BC_CMD_ID_GET_AUDIO_ALARM) {
19917
19950
  return;
19918
19951
  }
19919
19952
  try {
@@ -28954,6 +28987,33 @@ ${xml}`
28954
28987
  };
28955
28988
  return;
28956
28989
  }
28990
+ if (cmdId === BC_CMD_ID_FLOODLIGHT_STATUS_LIST) {
28991
+ const entries = parseFloodlightStatusListPushXml(xml);
28992
+ if (entries.length === 0) return;
28993
+ for (const entry of entries) {
28994
+ const channel = normalizePushChannel(entry.channel) ?? channelFromHeader;
28995
+ getEntry(channel).floodlightStatus = {
28996
+ updatedAtMs: now,
28997
+ value: { status: entry.status === 1 }
28998
+ };
28999
+ }
29000
+ return;
29001
+ }
29002
+ if (cmdId === BC_CMD_ID_GET_AUDIO_ALARM) {
29003
+ const entries = parseSirenStatusListPushXml(xml);
29004
+ if (entries.length === 0) return;
29005
+ for (const entry of entries) {
29006
+ const channel = normalizePushChannel(entry.channel) ?? channelFromHeader;
29007
+ getEntry(channel).sirenStatus = {
29008
+ updatedAtMs: now,
29009
+ value: {
29010
+ status: entry.status === 1,
29011
+ ...entry.playing !== void 0 ? { playing: entry.playing === 1 } : {}
29012
+ }
29013
+ };
29014
+ }
29015
+ return;
29016
+ }
28957
29017
  }
28958
29018
  /** Read-only snapshot of cached settings pushes (cmd_id 78/79/464/484/623/723). */
28959
29019
  getSettingsPushCacheSnapshot() {
@@ -28986,6 +29046,18 @@ ${xml}`
28986
29046
  ...entry.coordinatePointList,
28987
29047
  value: { ...entry.coordinatePointList.value }
28988
29048
  }
29049
+ } : {},
29050
+ ...entry.floodlightStatus ? {
29051
+ floodlightStatus: {
29052
+ ...entry.floodlightStatus,
29053
+ value: { ...entry.floodlightStatus.value }
29054
+ }
29055
+ } : {},
29056
+ ...entry.sirenStatus ? {
29057
+ sirenStatus: {
29058
+ ...entry.sirenStatus,
29059
+ value: { ...entry.sirenStatus.value }
29060
+ }
28989
29061
  } : {}
28990
29062
  });
28991
29063
  }
@@ -29009,6 +29081,29 @@ ${xml}`
29009
29081
  getCoordinatePointListFromPushCache(channel = 0) {
29010
29082
  return this.settingsPushCache.get(channel)?.coordinatePointList;
29011
29083
  }
29084
+ /**
29085
+ * Last cmd_id 291 (FloodlightStatusList) push observed for the channel.
29086
+ * The camera emits this whenever the floodlight transitions on/off,
29087
+ * including the auto-off after the FloodlightManual duration. This is
29088
+ * the only reliable source for the current manual state because cmd 289
29089
+ * only returns the FloodlightTask config.
29090
+ *
29091
+ * Returns undefined when no push has been received yet.
29092
+ */
29093
+ getCachedFloodlightStatus(channel = 0) {
29094
+ return this.settingsPushCache.get(channel)?.floodlightStatus;
29095
+ }
29096
+ /**
29097
+ * Last cmd_id 547 (SirenStatusList) push observed for the channel.
29098
+ * Captures the actual on/off transitions including the firmware's
29099
+ * built-in auto-off after the siren playback duration expires —
29100
+ * polling cmd 547 alone can race that auto-off.
29101
+ *
29102
+ * Returns undefined when no push has been received yet.
29103
+ */
29104
+ getCachedSirenStatus(channel = 0) {
29105
+ return this.settingsPushCache.get(channel)?.sirenStatus;
29106
+ }
29012
29107
  // --------------------
29013
29108
  // PCAP-derived settings getters (typed wrappers)
29014
29109
  // --------------------