@apocaliss92/nodelink-js 0.6.5 → 0.6.6
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/{chunk-WQ2TQCYP.js → chunk-JQ5NSEVD.js} +61 -13
- package/dist/chunk-JQ5NSEVD.js.map +1 -0
- package/dist/cli/rtsp-server.cjs +60 -12
- package/dist/cli/rtsp-server.cjs.map +1 -1
- package/dist/cli/rtsp-server.js +1 -1
- package/dist/index.cjs +60 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-WQ2TQCYP.js.map +0 -1
|
@@ -9905,6 +9905,30 @@ function buildSetNtpXml(current, patch) {
|
|
|
9905
9905
|
);
|
|
9906
9906
|
}
|
|
9907
9907
|
|
|
9908
|
+
// src/reolink/baichuan/utils/channelEnumeration.ts
|
|
9909
|
+
async function resolveBaichuanChannels(deps) {
|
|
9910
|
+
const fromPush = dedupeSorted(deps.pushChannels);
|
|
9911
|
+
if (fromPush.length > 0) return fromPush;
|
|
9912
|
+
const slots = dedupeSorted(deps.supportChnIds);
|
|
9913
|
+
const candidates = slots.length > 0 ? slots : [0];
|
|
9914
|
+
const probed = await Promise.all(
|
|
9915
|
+
candidates.map(
|
|
9916
|
+
async (channel) => await deps.probe(channel) ? channel : void 0
|
|
9917
|
+
)
|
|
9918
|
+
);
|
|
9919
|
+
return dedupeSorted(
|
|
9920
|
+
probed.filter((c) => c !== void 0)
|
|
9921
|
+
);
|
|
9922
|
+
}
|
|
9923
|
+
function dedupeSorted(values) {
|
|
9924
|
+
const set = /* @__PURE__ */ new Set();
|
|
9925
|
+
for (const v of values) {
|
|
9926
|
+
const n = Number(v);
|
|
9927
|
+
if (Number.isFinite(n) && n >= 0) set.add(n);
|
|
9928
|
+
}
|
|
9929
|
+
return [...set].sort((a, b) => a - b);
|
|
9930
|
+
}
|
|
9931
|
+
|
|
9908
9932
|
// src/reolink/baichuan/utils/dst.ts
|
|
9909
9933
|
var parseNumberSafe3 = (text) => {
|
|
9910
9934
|
if (text === void 0) return void 0;
|
|
@@ -15598,13 +15622,21 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
|
|
|
15598
15622
|
* @param options.source - Data source for the channel list (default: `"cgi"`):
|
|
15599
15623
|
* - `"cgi"`: Uses HTTP `GetChannelstatus` — returns the channel list immediately,
|
|
15600
15624
|
* no dependency on async push messages. Recommended for first-call discovery.
|
|
15601
|
-
* - `"baichuan"`:
|
|
15602
|
-
*
|
|
15603
|
-
*
|
|
15604
|
-
*
|
|
15625
|
+
* - `"baichuan"`: HTTP-free discovery. Prefers the cmd_id 145 push cache when
|
|
15626
|
+
* populated; otherwise actively probes the channel slots advertised by Support
|
|
15627
|
+
* (`items[].chnID`) via `getInfo`. Use this for hubs with HTTP disabled.
|
|
15628
|
+
*
|
|
15629
|
+
* When the api was constructed with `nativeOnly`, the source is forced to
|
|
15630
|
+
* `"baichuan"` regardless of this option (no HTTP/CGI is ever attempted).
|
|
15605
15631
|
*/
|
|
15606
15632
|
async getNvrChannelsSummary(options) {
|
|
15607
|
-
const source = options?.source ?? "cgi";
|
|
15633
|
+
const source = this.nativeOnly ? "baichuan" : options?.source ?? "cgi";
|
|
15634
|
+
const support = await this.getSupportInfo().catch(() => {
|
|
15635
|
+
this.logger.error?.(
|
|
15636
|
+
"[ReolinkBaichuanApi] getNvrChannelsSummary: failed to get support info"
|
|
15637
|
+
);
|
|
15638
|
+
return void 0;
|
|
15639
|
+
});
|
|
15608
15640
|
let channels;
|
|
15609
15641
|
const cgiStatusByChannel = /* @__PURE__ */ new Map();
|
|
15610
15642
|
if (options?.channels?.length) {
|
|
@@ -15634,15 +15666,31 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
|
|
|
15634
15666
|
channels = [];
|
|
15635
15667
|
}
|
|
15636
15668
|
} else {
|
|
15637
|
-
const
|
|
15638
|
-
|
|
15669
|
+
const pushChannels = Array.from(
|
|
15670
|
+
this.getChannelInfoFromPushCache().keys()
|
|
15671
|
+
).map((c) => Number(c)).filter((n) => Number.isFinite(n));
|
|
15672
|
+
const supportChnIds = (support?.items ?? []).map((i) => Number(i.chnID)).filter((n) => Number.isFinite(n));
|
|
15673
|
+
const probeTimeoutMs = options?.timeoutMs ?? 2500;
|
|
15674
|
+
channels = await resolveBaichuanChannels({
|
|
15675
|
+
pushChannels,
|
|
15676
|
+
supportChnIds,
|
|
15677
|
+
probe: async (channel) => {
|
|
15678
|
+
try {
|
|
15679
|
+
await this.getInfo(channel, {
|
|
15680
|
+
timeoutMs: probeTimeoutMs,
|
|
15681
|
+
tags: ["type", "name"]
|
|
15682
|
+
});
|
|
15683
|
+
return true;
|
|
15684
|
+
} catch {
|
|
15685
|
+
return false;
|
|
15686
|
+
}
|
|
15687
|
+
}
|
|
15688
|
+
});
|
|
15689
|
+
this.logger.debug?.(
|
|
15690
|
+
`[ReolinkBaichuanApi] getNvrChannelsSummary: baichuan resolved ${channels.length} channel(s): [${channels.join(", ")}]`
|
|
15691
|
+
);
|
|
15639
15692
|
}
|
|
15640
15693
|
channels = channels.sort((a, b) => a - b);
|
|
15641
|
-
const support = await this.getSupportInfo().catch(() => {
|
|
15642
|
-
this.logger.error?.(
|
|
15643
|
-
"[ReolinkBaichuanApi] getNvrChannelsSummary: failed to get support info"
|
|
15644
|
-
);
|
|
15645
|
-
});
|
|
15646
15694
|
const truthyNumberLike = (v) => {
|
|
15647
15695
|
if (typeof v === "number") return v > 0;
|
|
15648
15696
|
if (typeof v === "string") {
|
|
@@ -26004,4 +26052,4 @@ export {
|
|
|
26004
26052
|
tcpReachabilityProbe,
|
|
26005
26053
|
autoDetectDeviceType
|
|
26006
26054
|
};
|
|
26007
|
-
//# sourceMappingURL=chunk-
|
|
26055
|
+
//# sourceMappingURL=chunk-JQ5NSEVD.js.map
|