@apocaliss92/nodelink-js 0.4.23 → 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-P4X5OU25.js";
6
+ } from "../chunk-F3XCYKYT.js";
7
7
  import "../chunk-AHY4L7JI.js";
8
8
  import {
9
9
  __require
package/dist/index.cjs CHANGED
@@ -17723,9 +17723,10 @@ function parseRectTags(block) {
17723
17723
  function decodePrivacyMaskZones(xml) {
17724
17724
  const canvas = extractCanvasFromShelterXml(xml);
17725
17725
  const enable = Number(getXmlText(xml, "enable") ?? "0") === 1;
17726
- const maxNum = Number(getXmlText(xml, "maxNum") ?? "0") | 0;
17727
17726
  const trackEnable = Number(getXmlText(xml, "trackEnable") ?? "0") === 1;
17728
17727
  const maxTrackShelterNum = Number(getXmlText(xml, "maxTrackShelterNum") ?? "0") | 0;
17728
+ const rawMaxNum = getXmlText(xml, "maxNum");
17729
+ const maxNum = rawMaxNum !== void 0 ? Number(rawMaxNum) | 0 : maxTrackShelterNum > 0 ? maxTrackShelterNum : 4;
17729
17730
  const shelterList = [];
17730
17731
  const shelterListBlock = xml.match(
17731
17732
  /<shelterList>([\s\S]*?)<\/shelterList>/
@@ -19634,6 +19635,39 @@ var applyFloodlightSettingsToXml = (xml, settings) => {
19634
19635
  return modifiedXml;
19635
19636
  };
19636
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
+
19637
19671
  // src/reolink/baichuan/ReolinkBaichuanApi.ts
19638
19672
  var DUAL_LENS_DUAL_MOTION_MODELS = /* @__PURE__ */ new Set([
19639
19673
  "Reolink Duo PoE",
@@ -19912,7 +19946,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
19912
19946
  });
19913
19947
  client.on("push", (frame) => {
19914
19948
  const cmdId = frame.header.cmdId;
19915
- 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) {
19916
19950
  return;
19917
19951
  }
19918
19952
  try {
@@ -28953,6 +28987,33 @@ ${xml}`
28953
28987
  };
28954
28988
  return;
28955
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
+ }
28956
29017
  }
28957
29018
  /** Read-only snapshot of cached settings pushes (cmd_id 78/79/464/484/623/723). */
28958
29019
  getSettingsPushCacheSnapshot() {
@@ -28985,6 +29046,18 @@ ${xml}`
28985
29046
  ...entry.coordinatePointList,
28986
29047
  value: { ...entry.coordinatePointList.value }
28987
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
+ }
28988
29061
  } : {}
28989
29062
  });
28990
29063
  }
@@ -29008,6 +29081,29 @@ ${xml}`
29008
29081
  getCoordinatePointListFromPushCache(channel = 0) {
29009
29082
  return this.settingsPushCache.get(channel)?.coordinatePointList;
29010
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
+ }
29011
29107
  // --------------------
29012
29108
  // PCAP-derived settings getters (typed wrappers)
29013
29109
  // --------------------