@apocaliss92/nodelink-js 0.3.5 → 0.3.9

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,10 +3,10 @@ import {
3
3
  BaichuanRtspServer,
4
4
  ReolinkBaichuanApi,
5
5
  autoDetectDeviceType
6
- } from "../chunk-UDS2UR4S.js";
6
+ } from "../chunk-OGIKBDON.js";
7
7
  import {
8
8
  __require
9
- } from "../chunk-APEEZ4UN.js";
9
+ } from "../chunk-6Q6MK4WG.js";
10
10
 
11
11
  // src/cli/rtsp-server.ts
12
12
  function parseArgs() {
package/dist/index.cjs CHANGED
@@ -3103,6 +3103,7 @@ var init_urls = __esm({
3103
3103
  // src/debug/DiagnosticsTools.ts
3104
3104
  var DiagnosticsTools_exports = {};
3105
3105
  __export(DiagnosticsTools_exports, {
3106
+ captureModelFixtures: () => captureModelFixtures,
3106
3107
  collectCgiDiagnostics: () => collectCgiDiagnostics,
3107
3108
  collectMultifocalDiagnostics: () => collectMultifocalDiagnostics,
3108
3109
  collectNativeDiagnostics: () => collectNativeDiagnostics,
@@ -3136,6 +3137,10 @@ function writeJson(filePath, obj) {
3136
3137
  mkdirp(path4.dirname(filePath));
3137
3138
  fs4.writeFileSync(filePath, JSON.stringify(obj, null, 2));
3138
3139
  }
3140
+ function writeText(filePath, text) {
3141
+ mkdirp(path4.dirname(filePath));
3142
+ fs4.writeFileSync(filePath, text);
3143
+ }
3139
3144
  function appendNdjson(filePath, obj) {
3140
3145
  mkdirp(path4.dirname(filePath));
3141
3146
  fs4.appendFileSync(filePath, JSON.stringify(obj) + "\n");
@@ -5399,6 +5404,172 @@ async function runAllDiagnosticsConsecutively(params) {
5399
5404
  streamsDir
5400
5405
  };
5401
5406
  }
5407
+ async function captureModelFixtures(params) {
5408
+ const { api, channel, outDir } = params;
5409
+ const log = params.log ?? console.log;
5410
+ mkdirp(outDir);
5411
+ const calls = {};
5412
+ const errors = [];
5413
+ async function capture(name, fn, writer) {
5414
+ try {
5415
+ const value = await fn();
5416
+ calls[name] = { ok: true, value };
5417
+ if (writer && value !== void 0 && value !== null) {
5418
+ writer(value);
5419
+ }
5420
+ log(` \u2713 ${name}`);
5421
+ return value;
5422
+ } catch (e) {
5423
+ const msg = e instanceof Error ? e.message : String(e);
5424
+ calls[name] = { ok: false, error: msg };
5425
+ errors.push(`${name}: ${msg}`);
5426
+ log(` \u2717 ${name}: ${msg}`);
5427
+ return void 0;
5428
+ }
5429
+ }
5430
+ const info = await capture(
5431
+ "getInfo",
5432
+ () => api.getInfo(channel),
5433
+ (v) => writeJson(path4.join(outDir, "device-info.json"), v)
5434
+ );
5435
+ const support = await capture(
5436
+ "getSupportInfo",
5437
+ () => api.getSupportInfo(),
5438
+ (v) => writeJson(path4.join(outDir, "support-info.json"), v)
5439
+ );
5440
+ const abilities = await capture(
5441
+ "getAbilityInfo",
5442
+ () => api.getAbilityInfo(),
5443
+ (v) => writeJson(path4.join(outDir, "ability-info.json"), v)
5444
+ );
5445
+ await capture(
5446
+ "getDeviceCapabilities",
5447
+ () => api.getDeviceCapabilities(channel),
5448
+ (v) => writeJson(path4.join(outDir, "capabilities.json"), v)
5449
+ );
5450
+ await capture("cmd289-WhiteLed", () => api.sendXml({
5451
+ cmdId: BC_CMD_ID_GET_WHITE_LED,
5452
+ channel,
5453
+ timeoutMs: 3e3
5454
+ }), (v) => writeText(path4.join(outDir, "cmd289-white-led.xml"), v));
5455
+ await capture(
5456
+ "getStreamMetadata",
5457
+ () => api.getStreamMetadata(channel),
5458
+ (v) => writeJson(path4.join(outDir, "stream-metadata.json"), v)
5459
+ );
5460
+ await capture(
5461
+ "getEncXml",
5462
+ () => api.getEncXml(channel),
5463
+ (v) => writeText(path4.join(outDir, "enc-config.xml"), v)
5464
+ );
5465
+ await capture(
5466
+ "getPorts",
5467
+ () => api.getPorts(),
5468
+ (v) => writeJson(path4.join(outDir, "ports.json"), v)
5469
+ );
5470
+ await capture(
5471
+ "getTalkAbility",
5472
+ () => api.getTalkAbility(channel),
5473
+ (v) => writeJson(path4.join(outDir, "talk-ability.json"), v)
5474
+ );
5475
+ await capture(
5476
+ "getTwoWayAudioConfig",
5477
+ () => api.getTwoWayAudioConfig(channel),
5478
+ (v) => writeJson(path4.join(outDir, "two-way-audio-config.json"), v)
5479
+ );
5480
+ await capture(
5481
+ "getAiState",
5482
+ () => api.getAiState(channel),
5483
+ (v) => writeJson(path4.join(outDir, "ai-state.json"), v)
5484
+ );
5485
+ await capture(
5486
+ "getAiCfg",
5487
+ () => api.getAiCfg(channel),
5488
+ (v) => writeJson(path4.join(outDir, "ai-cfg.json"), v)
5489
+ );
5490
+ await capture(
5491
+ "getOsd",
5492
+ () => api.getOsd(channel),
5493
+ (v) => writeJson(path4.join(outDir, "osd.json"), v)
5494
+ );
5495
+ await capture(
5496
+ "getMotionAlarm",
5497
+ () => api.getMotionAlarm(channel),
5498
+ (v) => writeJson(path4.join(outDir, "motion-alarm.json"), v)
5499
+ );
5500
+ await capture(
5501
+ "getRecordCfg",
5502
+ () => api.getRecordCfg(channel),
5503
+ (v) => writeJson(path4.join(outDir, "record-cfg.json"), v)
5504
+ );
5505
+ await capture(
5506
+ "getVideoInput",
5507
+ () => api.getVideoInput(channel),
5508
+ (v) => writeJson(path4.join(outDir, "video-input.json"), v)
5509
+ );
5510
+ await capture(
5511
+ "getPtzPresets",
5512
+ () => api.getPtzPresets(channel),
5513
+ (v) => writeJson(path4.join(outDir, "ptz-presets.json"), v)
5514
+ );
5515
+ await capture(
5516
+ "getNetworkInfo",
5517
+ () => api.getNetworkInfo(),
5518
+ (v) => writeJson(path4.join(outDir, "network-info.json"), v)
5519
+ );
5520
+ await capture(
5521
+ "getSystemGeneral",
5522
+ () => api.getSystemGeneral(),
5523
+ (v) => writeJson(path4.join(outDir, "system-general.json"), v)
5524
+ );
5525
+ await capture(
5526
+ "getWifiSignal",
5527
+ () => api.getWifiSignal(channel),
5528
+ (v) => writeJson(path4.join(outDir, "wifi-signal.json"), v)
5529
+ );
5530
+ await capture(
5531
+ "getWhiteLedState",
5532
+ () => api.getWhiteLedState(channel),
5533
+ (v) => writeJson(path4.join(outDir, "white-led-state.json"), v)
5534
+ );
5535
+ await capture(
5536
+ "getFloodlightOnMotion",
5537
+ () => api.getFloodlightOnMotion(channel),
5538
+ (v) => writeJson(path4.join(outDir, "floodlight-on-motion.json"), v)
5539
+ );
5540
+ await capture(
5541
+ "buildVideoStreamOptions",
5542
+ () => api.buildVideoStreamOptions({ channel }),
5543
+ (v) => writeJson(path4.join(outDir, "video-stream-options.json"), v)
5544
+ );
5545
+ const total = Object.keys(calls).length;
5546
+ const ok = Object.values(calls).filter((c) => c.ok).length;
5547
+ const failed = total - ok;
5548
+ const summary = { total, ok, failed, errors };
5549
+ writeJson(path4.join(outDir, "_summary.json"), {
5550
+ collectedAt: (/* @__PURE__ */ new Date()).toISOString(),
5551
+ model: info?.type ?? "unknown",
5552
+ itemNo: info?.itemNo ?? "unknown",
5553
+ firmwareVersion: info?.firmwareVersion ?? "unknown",
5554
+ channel,
5555
+ ...summary,
5556
+ calls: Object.fromEntries(
5557
+ Object.entries(calls).map(([k, v]) => [
5558
+ k,
5559
+ v.ok ? "ok" : `FAILED: ${v.error}`
5560
+ ])
5561
+ )
5562
+ });
5563
+ log(`
5564
+ Summary: ${ok}/${total} ok, ${failed} failed`);
5565
+ if (errors.length) {
5566
+ log(` Errors:`);
5567
+ for (const err of errors) {
5568
+ log(` - ${err}`);
5569
+ }
5570
+ }
5571
+ return { calls, outDir, summary };
5572
+ }
5402
5573
  var fs4, path4, import_node_child_process, import_node_path;
5403
5574
  var init_DiagnosticsTools = __esm({
5404
5575
  "src/debug/DiagnosticsTools.ts"() {
@@ -7486,6 +7657,7 @@ __export(index_exports, {
7486
7657
  buildSirenTimesXml: () => buildSirenTimesXml,
7487
7658
  buildStartZoomFocusXml: () => buildStartZoomFocusXml,
7488
7659
  buildWhiteLedStateXml: () => buildWhiteLedStateXml,
7660
+ captureModelFixtures: () => captureModelFixtures,
7489
7661
  collectCgiDiagnostics: () => collectCgiDiagnostics,
7490
7662
  collectMultifocalDiagnostics: () => collectMultifocalDiagnostics,
7491
7663
  collectNativeDiagnostics: () => collectNativeDiagnostics,
@@ -7567,6 +7739,7 @@ __export(index_exports, {
7567
7739
  splitH265AnnexBToNalPayloads: () => splitAnnexBToNalPayloads2,
7568
7740
  testChannelStreams: () => testChannelStreams,
7569
7741
  xmlEscape: () => xmlEscape,
7742
+ xmlIndicatesFloodlight: () => xmlIndicatesFloodlight,
7570
7743
  zipDirectory: () => zipDirectory
7571
7744
  });
7572
7745
  module.exports = __toCommonJS(index_exports);
@@ -15317,6 +15490,17 @@ function computeDeviceCapabilities(params) {
15317
15490
  if (ptzMode !== void 0) result.ptzMode = ptzMode;
15318
15491
  return result;
15319
15492
  }
15493
+ function xmlIndicatesFloodlight(xml) {
15494
+ if (/(<FloodlightTask\b|<FloodlightManual\b|<FloodlightStatusList\b)/i.test(
15495
+ xml
15496
+ )) {
15497
+ return true;
15498
+ }
15499
+ if (/<WhiteLed\b/i.test(xml)) {
15500
+ return /(<brightness_cur>|<bright>|<LightingSchedule\b)/i.test(xml);
15501
+ }
15502
+ return false;
15503
+ }
15320
15504
 
15321
15505
  // src/reolink/baichuan/utils/abilityInfo.ts
15322
15506
  init_xml();
@@ -24353,9 +24537,7 @@ ${stderr}`)
24353
24537
  `probeFloodlightSupportByCmd289: received XML for channel ${ch}:
24354
24538
  ${xml}`
24355
24539
  );
24356
- return /(<FloodlightTask\b|<FloodlightManual\b|<FloodlightStatusList\b|<WhiteLed\b)/i.test(
24357
- xml
24358
- );
24540
+ return xmlIndicatesFloodlight(xml);
24359
24541
  } catch {
24360
24542
  return false;
24361
24543
  }
@@ -36487,6 +36669,7 @@ var CompositeRtspServer = class extends import_node_events12.EventEmitter {
36487
36669
  buildSirenTimesXml,
36488
36670
  buildStartZoomFocusXml,
36489
36671
  buildWhiteLedStateXml,
36672
+ captureModelFixtures,
36490
36673
  collectCgiDiagnostics,
36491
36674
  collectMultifocalDiagnostics,
36492
36675
  collectNativeDiagnostics,
@@ -36568,6 +36751,7 @@ var CompositeRtspServer = class extends import_node_events12.EventEmitter {
36568
36751
  splitH265AnnexBToNalPayloads,
36569
36752
  testChannelStreams,
36570
36753
  xmlEscape,
36754
+ xmlIndicatesFloodlight,
36571
36755
  zipDirectory
36572
36756
  });
36573
36757
  //# sourceMappingURL=index.cjs.map