@camstack/addon-provider-amcrest 0.1.2 → 0.1.4

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/addon.js CHANGED
@@ -19596,7 +19596,15 @@ var FrameworkPackageStatusSchema = object({
19596
19596
  latestVersion: string().nullable(),
19597
19597
  hasUpdate: boolean(),
19598
19598
  /** Optional manifest description for the row tooltip. */
19599
- description: string().optional()
19599
+ description: string().optional(),
19600
+ /**
19601
+ * Content build-id (md5 of the resolved `dist/` tree) of the code the hub
19602
+ * ACTUALLY loaded. Framework packages ship code changes without always
19603
+ * bumping `currentVersion`, so semver alone hides "same version, new code".
19604
+ * `null` when the dist can't be hashed (not installed / empty). The admin-UI
19605
+ * surfaces this so a stale-code hub is visible even at an unchanged version.
19606
+ */
19607
+ buildId: string().nullable()
19600
19608
  });
19601
19609
  var LogStreamEntrySchema = object({
19602
19610
  timestamp: string(),
@@ -26526,17 +26534,21 @@ var AmcrestCgiClient = class AmcrestCgiClient {
26526
26534
  } catch {
26527
26535
  return [];
26528
26536
  }
26529
- const out = /* @__PURE__ */ new Map();
26530
26537
  const ch = channel - 1;
26538
+ const names = /* @__PURE__ */ new Map();
26539
+ const enabled = /* @__PURE__ */ new Set();
26531
26540
  for (const [key, value] of t) {
26532
- const m = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Name$`).exec(key);
26533
- if (!m) continue;
26534
- const idx = Number.parseInt(m[1], 10);
26535
- out.set(idx, value);
26541
+ const nameMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Name$`).exec(key);
26542
+ if (nameMatch) {
26543
+ names.set(Number.parseInt(nameMatch[1], 10), value);
26544
+ continue;
26545
+ }
26546
+ const enableMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Enable$`).exec(key);
26547
+ if (enableMatch && value.trim().toLowerCase() === "true") enabled.add(Number.parseInt(enableMatch[1], 10));
26536
26548
  }
26537
- return [...out.entries()].toSorted((a, b) => a[0] - b[0]).map(([id, name]) => ({
26538
- id,
26539
- name: name || `Preset ${id}`
26549
+ return [...enabled].toSorted((a, b) => a - b).map((idx) => ({
26550
+ id: idx + 1,
26551
+ name: names.get(idx) || `Preset ${idx + 1}`
26540
26552
  }));
26541
26553
  }
26542
26554
  };
@@ -27170,9 +27182,12 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
27170
27182
  },
27171
27183
  savePreset: async ({ deviceId, presetId, name }) => {
27172
27184
  if (deviceId !== this.id) return;
27173
- const id = Number.parseInt(presetId, 10);
27174
- if (!Number.isFinite(id)) return;
27175
- await this.ensureClient().ptzSetPreset(this.channel, id);
27185
+ const client = this.ensureClient();
27186
+ const requested = Number.parseInt(presetId, 10);
27187
+ const used = new Set((await client.getPtzPresets(this.channel)).map((p) => p.id));
27188
+ let slot = Number.isFinite(requested) && requested >= 1 && !used.has(requested) ? requested : 1;
27189
+ while (used.has(slot)) slot += 1;
27190
+ await client.ptzSetPreset(this.channel, slot);
27176
27191
  },
27177
27192
  deletePreset: async ({ deviceId, presetId }) => {
27178
27193
  if (deviceId !== this.id) return;
package/dist/addon.mjs CHANGED
@@ -19597,7 +19597,15 @@ var FrameworkPackageStatusSchema = object({
19597
19597
  latestVersion: string().nullable(),
19598
19598
  hasUpdate: boolean(),
19599
19599
  /** Optional manifest description for the row tooltip. */
19600
- description: string().optional()
19600
+ description: string().optional(),
19601
+ /**
19602
+ * Content build-id (md5 of the resolved `dist/` tree) of the code the hub
19603
+ * ACTUALLY loaded. Framework packages ship code changes without always
19604
+ * bumping `currentVersion`, so semver alone hides "same version, new code".
19605
+ * `null` when the dist can't be hashed (not installed / empty). The admin-UI
19606
+ * surfaces this so a stale-code hub is visible even at an unchanged version.
19607
+ */
19608
+ buildId: string().nullable()
19601
19609
  });
19602
19610
  var LogStreamEntrySchema = object({
19603
19611
  timestamp: string(),
@@ -26527,17 +26535,21 @@ var AmcrestCgiClient = class AmcrestCgiClient {
26527
26535
  } catch {
26528
26536
  return [];
26529
26537
  }
26530
- const out = /* @__PURE__ */ new Map();
26531
26538
  const ch = channel - 1;
26539
+ const names = /* @__PURE__ */ new Map();
26540
+ const enabled = /* @__PURE__ */ new Set();
26532
26541
  for (const [key, value] of t) {
26533
- const m = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Name$`).exec(key);
26534
- if (!m) continue;
26535
- const idx = Number.parseInt(m[1], 10);
26536
- out.set(idx, value);
26542
+ const nameMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Name$`).exec(key);
26543
+ if (nameMatch) {
26544
+ names.set(Number.parseInt(nameMatch[1], 10), value);
26545
+ continue;
26546
+ }
26547
+ const enableMatch = new RegExp(`^PtzPreset\\[${ch}\\]\\[(\\d+)\\]\\.Enable$`).exec(key);
26548
+ if (enableMatch && value.trim().toLowerCase() === "true") enabled.add(Number.parseInt(enableMatch[1], 10));
26537
26549
  }
26538
- return [...out.entries()].toSorted((a, b) => a[0] - b[0]).map(([id, name]) => ({
26539
- id,
26540
- name: name || `Preset ${id}`
26550
+ return [...enabled].toSorted((a, b) => a - b).map((idx) => ({
26551
+ id: idx + 1,
26552
+ name: names.get(idx) || `Preset ${idx + 1}`
26541
26553
  }));
26542
26554
  }
26543
26555
  };
@@ -27171,9 +27183,12 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
27171
27183
  },
27172
27184
  savePreset: async ({ deviceId, presetId, name }) => {
27173
27185
  if (deviceId !== this.id) return;
27174
- const id = Number.parseInt(presetId, 10);
27175
- if (!Number.isFinite(id)) return;
27176
- await this.ensureClient().ptzSetPreset(this.channel, id);
27186
+ const client = this.ensureClient();
27187
+ const requested = Number.parseInt(presetId, 10);
27188
+ const used = new Set((await client.getPtzPresets(this.channel)).map((p) => p.id));
27189
+ let slot = Number.isFinite(requested) && requested >= 1 && !used.has(requested) ? requested : 1;
27190
+ while (used.has(slot)) slot += 1;
27191
+ await client.ptzSetPreset(this.channel, slot);
27177
27192
  },
27178
27193
  deletePreset: async ({ deviceId, presetId }) => {
27179
27194
  if (deviceId !== this.id) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-amcrest",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
5
5
  "keywords": [
6
6
  "camstack",