@camstack/addon-provider-reolink 1.2.226 → 1.2.227
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/CHANGELOG.md +7 -0
- package/dist/addon.js +284 -23
- package/dist/addon.mjs +284 -23
- package/i18n/en.json +13 -1
- package/i18n/it.json +13 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.227] - 2026-11-05
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Reolink clip catalog refresh default is declared on the fleet-default hook; the form and stored value are unchanged.
|
|
15
|
+
- A camera adopted under an NVR / Home Hub now shows its hub and channel in settings, no longer lets you edit its address or credentials (they belong to the integration), and hides the hub-wide ports and time sections.
|
|
16
|
+
|
|
10
17
|
## [1.2.226] - 2026-11-05
|
|
11
18
|
|
|
12
19
|
### Changed
|
package/dist/addon.js
CHANGED
|
@@ -106677,7 +106677,7 @@ var ZodIssueCode = {
|
|
|
106677
106677
|
var ZodFirstPartyTypeKind;
|
|
106678
106678
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
106679
106679
|
//#endregion
|
|
106680
|
-
//#region ../types/dist/sleep-
|
|
106680
|
+
//#region ../types/dist/sleep-DEZaLbiu.mjs
|
|
106681
106681
|
/**
|
|
106682
106682
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
106683
106683
|
* window to float samples (D455).
|
|
@@ -107486,6 +107486,12 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
107486
107486
|
}
|
|
107487
107487
|
return out;
|
|
107488
107488
|
}
|
|
107489
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
107490
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
107491
|
+
"cluster",
|
|
107492
|
+
"device-defaults",
|
|
107493
|
+
"node"
|
|
107494
|
+
];
|
|
107489
107495
|
/**
|
|
107490
107496
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
107491
107497
|
*
|
|
@@ -108377,6 +108383,13 @@ var BaseAddon = class {
|
|
|
108377
108383
|
*/
|
|
108378
108384
|
secretStatePaths = [];
|
|
108379
108385
|
_addonSecretTree = null;
|
|
108386
|
+
/**
|
|
108387
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
108388
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
108389
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
108390
|
+
*/
|
|
108391
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
108392
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
108380
108393
|
_deviceSecretTree = null;
|
|
108381
108394
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
108382
108395
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -108446,6 +108459,7 @@ var BaseAddon = class {
|
|
|
108446
108459
|
this._ctx = context;
|
|
108447
108460
|
this._secretSettings = null;
|
|
108448
108461
|
}
|
|
108462
|
+
await this.loadScopedSchemas();
|
|
108449
108463
|
await this.resolveConfig();
|
|
108450
108464
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
108451
108465
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -108455,6 +108469,7 @@ var BaseAddon = class {
|
|
|
108455
108469
|
const normalized = normalizeAddonInitResult(result);
|
|
108456
108470
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
108457
108471
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
108472
|
+
await this.loadScopedSchemas();
|
|
108458
108473
|
return normalized;
|
|
108459
108474
|
}
|
|
108460
108475
|
/**
|
|
@@ -108543,6 +108558,16 @@ var BaseAddon = class {
|
|
|
108543
108558
|
schema(schema) {
|
|
108544
108559
|
return schema;
|
|
108545
108560
|
}
|
|
108561
|
+
/**
|
|
108562
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
108563
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
108564
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
108565
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
108566
|
+
* once known.
|
|
108567
|
+
*/
|
|
108568
|
+
scopedSettingsCapabilities() {
|
|
108569
|
+
return [];
|
|
108570
|
+
}
|
|
108546
108571
|
/** Override to provide global-level settings UI schema. */
|
|
108547
108572
|
globalSettingsSchema(_cap) {
|
|
108548
108573
|
return null;
|
|
@@ -108586,7 +108611,8 @@ var BaseAddon = class {
|
|
|
108586
108611
|
return [];
|
|
108587
108612
|
}
|
|
108588
108613
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
108589
|
-
|
|
108614
|
+
await this.loadScopedSchemas(cap);
|
|
108615
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
108590
108616
|
if (!schema) return { sections: [] };
|
|
108591
108617
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
108592
108618
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -108717,6 +108743,7 @@ var BaseAddon = class {
|
|
|
108717
108743
|
* resolved blob back is a no-op for every unchanged secret.
|
|
108718
108744
|
*/
|
|
108719
108745
|
async resolveGlobalStore(nodeId, cap) {
|
|
108746
|
+
await this.loadScopedSchemas(cap);
|
|
108720
108747
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
108721
108748
|
return this.projectForNode(raw, nodeId, cap);
|
|
108722
108749
|
}
|
|
@@ -108727,6 +108754,7 @@ var BaseAddon = class {
|
|
|
108727
108754
|
}
|
|
108728
108755
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
108729
108756
|
async readRawProjectedStore(nodeId, cap) {
|
|
108757
|
+
await this.loadScopedSchemas(cap);
|
|
108730
108758
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
108731
108759
|
return this.projectForNode(raw, nodeId, cap);
|
|
108732
108760
|
}
|
|
@@ -108829,6 +108857,7 @@ var BaseAddon = class {
|
|
|
108829
108857
|
await this.applyGlobalPatch(patch, nodeId);
|
|
108830
108858
|
}
|
|
108831
108859
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
108860
|
+
await this.loadScopedSchemas();
|
|
108832
108861
|
const keys = this.perNodeKeys();
|
|
108833
108862
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
108834
108863
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -108842,7 +108871,8 @@ var BaseAddon = class {
|
|
|
108842
108871
|
await this.resolveConfig();
|
|
108843
108872
|
await this.onConfigChanged();
|
|
108844
108873
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
108845
|
-
|
|
108874
|
+
const legacy = this.globalSettingsSchema();
|
|
108875
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
108846
108876
|
}
|
|
108847
108877
|
/**
|
|
108848
108878
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -108850,14 +108880,67 @@ var BaseAddon = class {
|
|
|
108850
108880
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
108851
108881
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
108852
108882
|
*/
|
|
108853
|
-
|
|
108883
|
+
/**
|
|
108884
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
108885
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
108886
|
+
* derived from the previous set. Idempotent.
|
|
108887
|
+
*/
|
|
108888
|
+
async loadScopedSchemas(extraCap) {
|
|
108889
|
+
const caps = new Set([
|
|
108890
|
+
...this.scopedSettingsCapabilities(),
|
|
108891
|
+
...this._registeredCapNames,
|
|
108892
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
108893
|
+
]);
|
|
108894
|
+
let added = false;
|
|
108895
|
+
for (const cap of caps) {
|
|
108896
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
108897
|
+
const loaded = [];
|
|
108898
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
108899
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
108900
|
+
if (schema !== null) loaded.push({
|
|
108901
|
+
scope,
|
|
108902
|
+
schema
|
|
108903
|
+
});
|
|
108904
|
+
}
|
|
108905
|
+
this._scopedByCap.set(cap, loaded);
|
|
108906
|
+
added = true;
|
|
108907
|
+
}
|
|
108908
|
+
if (!added) return;
|
|
108909
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
108910
|
+
this._addonSecretTree = null;
|
|
108911
|
+
}
|
|
108912
|
+
/**
|
|
108913
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
108914
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
108915
|
+
*/
|
|
108916
|
+
scopedFormSchema(cap) {
|
|
108917
|
+
const byId = /* @__PURE__ */ new Map();
|
|
108918
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
108919
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
108920
|
+
}
|
|
108921
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
108922
|
+
loadedScopedSchemas(cap) {
|
|
108923
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
108924
|
+
return [...this._scopedByCap.values()].flat();
|
|
108925
|
+
}
|
|
108926
|
+
/**
|
|
108927
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
108928
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
108929
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
108930
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
108931
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
108932
|
+
*/
|
|
108854
108933
|
perNodeKeys(cap) {
|
|
108855
108934
|
const cacheKey = cap ?? "";
|
|
108856
|
-
const cached = this.
|
|
108935
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
108857
108936
|
if (cached) return cached;
|
|
108858
|
-
const
|
|
108859
|
-
const keys = new Set(
|
|
108860
|
-
this.
|
|
108937
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
108938
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
108939
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
108940
|
+
if (scope !== "node") continue;
|
|
108941
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
108942
|
+
}
|
|
108943
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
108861
108944
|
return keys;
|
|
108862
108945
|
}
|
|
108863
108946
|
/**
|
|
@@ -108867,10 +108950,9 @@ var BaseAddon = class {
|
|
|
108867
108950
|
* time to return its response before the addon is torn down and
|
|
108868
108951
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
108869
108952
|
*/
|
|
108870
|
-
maybeAutoRestart(patchKeys,
|
|
108871
|
-
if (!schema) return;
|
|
108953
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
108872
108954
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
108873
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
108955
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
108874
108956
|
if (field.type === "separator" || field.type === "info") continue;
|
|
108875
108957
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
108876
108958
|
}
|
|
@@ -109066,12 +109148,14 @@ var BaseAddon = class {
|
|
|
109066
109148
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
109067
109149
|
*/
|
|
109068
109150
|
async getDeclaredSettingsKeys() {
|
|
109151
|
+
await this.loadScopedSchemas();
|
|
109069
109152
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
109070
109153
|
}
|
|
109071
109154
|
declaredKeySet() {
|
|
109072
109155
|
const keys = new Set(Object.keys(this.defaults));
|
|
109073
109156
|
const schema = this.globalSettingsSchema();
|
|
109074
109157
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
109158
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
109075
109159
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
109076
109160
|
for (const path of this.secretStatePaths) {
|
|
109077
109161
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -109167,7 +109251,11 @@ var BaseAddon = class {
|
|
|
109167
109251
|
}
|
|
109168
109252
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
109169
109253
|
addonSecretTree() {
|
|
109170
|
-
this._addonSecretTree
|
|
109254
|
+
if (this._addonSecretTree === null) {
|
|
109255
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
109256
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
109257
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
109258
|
+
}
|
|
109171
109259
|
return this._addonSecretTree;
|
|
109172
109260
|
}
|
|
109173
109261
|
deviceSecretTree() {
|
|
@@ -109417,6 +109505,23 @@ function dropPerNodeFields(fields) {
|
|
|
109417
109505
|
}
|
|
109418
109506
|
return kept;
|
|
109419
109507
|
}
|
|
109508
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
109509
|
+
function collectValueFieldKeys(fields) {
|
|
109510
|
+
const collected = [];
|
|
109511
|
+
for (const field of fields) {
|
|
109512
|
+
if (field.type === "group") {
|
|
109513
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
109514
|
+
continue;
|
|
109515
|
+
}
|
|
109516
|
+
if (field.type === "sub-tabs") {
|
|
109517
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
109518
|
+
continue;
|
|
109519
|
+
}
|
|
109520
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
109521
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
109522
|
+
}
|
|
109523
|
+
return collected;
|
|
109524
|
+
}
|
|
109420
109525
|
function collectFieldKeys(fields) {
|
|
109421
109526
|
const collected = [];
|
|
109422
109527
|
for (const field of fields) {
|
|
@@ -208980,6 +209085,114 @@ async function connectReolinkHub(connection) {
|
|
|
208980
209085
|
return api;
|
|
208981
209086
|
}
|
|
208982
209087
|
//#endregion
|
|
209088
|
+
//#region src/hub-child-settings.ts
|
|
209089
|
+
/**
|
|
209090
|
+
* A camera adopted under an NVR / Home Hub dials through the integration's session: the address
|
|
209091
|
+
* and the credentials belong to the integration, never to the camera. These are the per-camera
|
|
209092
|
+
* keys a hub child must refuse to change.
|
|
209093
|
+
*/
|
|
209094
|
+
var HUB_CHILD_CONNECTION_KEYS = [
|
|
209095
|
+
"host",
|
|
209096
|
+
"port",
|
|
209097
|
+
"username",
|
|
209098
|
+
"password"
|
|
209099
|
+
];
|
|
209100
|
+
/**
|
|
209101
|
+
* Sections that act on the hub itself (no channel in the call) or on the per-camera connection,
|
|
209102
|
+
* hidden for a hub child:
|
|
209103
|
+
* - `connection`: the per-camera address and credentials (the integration owns them);
|
|
209104
|
+
* - `network-ports`: `setPortConfig` rewrites the NVR's own service ports;
|
|
209105
|
+
* - `time-ntp`: `setNtp` / `setSystemGeneral` / `setDst` rewrite the NVR's clock.
|
|
209106
|
+
*/
|
|
209107
|
+
var HUB_CHILD_HIDDEN_SECTION_IDS = [
|
|
209108
|
+
"connection",
|
|
209109
|
+
"network-ports",
|
|
209110
|
+
"time-ntp"
|
|
209111
|
+
];
|
|
209112
|
+
/** Thrown by `applySettingsPatch` for a refused hub-child patch; carries the typed reason. */
|
|
209113
|
+
var HubChildPatchRefusedError = class extends Error {
|
|
209114
|
+
refusal;
|
|
209115
|
+
constructor(refusal) {
|
|
209116
|
+
super(describeRefusal(refusal));
|
|
209117
|
+
this.refusal = refusal;
|
|
209118
|
+
this.name = "HubChildPatchRefusedError";
|
|
209119
|
+
}
|
|
209120
|
+
};
|
|
209121
|
+
function describeRefusal(refusal) {
|
|
209122
|
+
switch (refusal.reason) {
|
|
209123
|
+
case "connection-owned-by-integration": return `This camera is connected through its NVR / Home Hub integration: ${refusal.keys.join(", ")} can only be changed on the integration`;
|
|
209124
|
+
case "channel-not-an-integer": return `The hub channel must be a whole number, got ${String(refusal.value)}`;
|
|
209125
|
+
case "channel-out-of-range": return `Channel ${refusal.value} is not one of the hub's channels (${refusal.channels.join(", ")})`;
|
|
209126
|
+
}
|
|
209127
|
+
}
|
|
209128
|
+
/**
|
|
209129
|
+
* Judge a settings patch against the hub-child rules. `channels` is the hub's last good channel
|
|
209130
|
+
* list (empty when unknown — then only the integer rule applies).
|
|
209131
|
+
*/
|
|
209132
|
+
function judgeHubChildPatch(patch, channels) {
|
|
209133
|
+
const touched = HUB_CHILD_CONNECTION_KEYS.filter((k) => patch[k] !== void 0);
|
|
209134
|
+
if (touched.length > 0) return {
|
|
209135
|
+
reason: "connection-owned-by-integration",
|
|
209136
|
+
keys: touched
|
|
209137
|
+
};
|
|
209138
|
+
if (patch["channel"] === void 0) return null;
|
|
209139
|
+
const value = patch["channel"];
|
|
209140
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) return {
|
|
209141
|
+
reason: "channel-not-an-integer",
|
|
209142
|
+
value
|
|
209143
|
+
};
|
|
209144
|
+
if (channels.length > 0 && !channels.includes(value)) return {
|
|
209145
|
+
reason: "channel-out-of-range",
|
|
209146
|
+
value,
|
|
209147
|
+
channels
|
|
209148
|
+
};
|
|
209149
|
+
return null;
|
|
209150
|
+
}
|
|
209151
|
+
/** What a hub child shows before its session has read the hub's channel list. */
|
|
209152
|
+
var EMPTY_HUB_CHANNEL_SNAPSHOT = {
|
|
209153
|
+
channels: [],
|
|
209154
|
+
lastRefreshAt: null,
|
|
209155
|
+
lastError: null
|
|
209156
|
+
};
|
|
209157
|
+
/** The hub-child "Hub" section: which hub, and the one editable connection field, the channel. */
|
|
209158
|
+
function buildHubChildSection(snapshot) {
|
|
209159
|
+
return {
|
|
209160
|
+
id: "hub",
|
|
209161
|
+
tab: "general",
|
|
209162
|
+
title: "Hub",
|
|
209163
|
+
titleKey: "provider-reolink:schema.s_hub.title",
|
|
209164
|
+
description: "This camera is connected through its NVR / Home Hub. Address and credentials belong to that integration; the channel is kept in line with the hub automatically.",
|
|
209165
|
+
descriptionKey: "provider-reolink:schema.s_hub.description",
|
|
209166
|
+
columns: 2,
|
|
209167
|
+
fields: [{
|
|
209168
|
+
type: "text",
|
|
209169
|
+
key: "hubName",
|
|
209170
|
+
label: "Connected to",
|
|
209171
|
+
labelKey: "provider-reolink:schema.s_hub.hubName.label",
|
|
209172
|
+
disabled: true
|
|
209173
|
+
}, {
|
|
209174
|
+
type: "number",
|
|
209175
|
+
key: "channel",
|
|
209176
|
+
label: "Hub channel",
|
|
209177
|
+
labelKey: "provider-reolink:schema.s_hub.channel.label",
|
|
209178
|
+
min: 0,
|
|
209179
|
+
...snapshot.channels.length > 0 ? { max: Math.max(...snapshot.channels.map((c) => c.channel)) } : {},
|
|
209180
|
+
step: 1
|
|
209181
|
+
}]
|
|
209182
|
+
};
|
|
209183
|
+
}
|
|
209184
|
+
/** Replace the connection/hub-acting sections of a standalone schema with the Hub section. */
|
|
209185
|
+
function applyHubChildSections(sections, snapshot) {
|
|
209186
|
+
const kept = sections.filter((s) => !HUB_CHILD_HIDDEN_SECTION_IDS.includes(s.id));
|
|
209187
|
+
const at = kept.findIndex((s) => s.id === "driver-refresh");
|
|
209188
|
+
const hub = buildHubChildSection(snapshot);
|
|
209189
|
+
return at < 0 ? [hub, ...kept] : [
|
|
209190
|
+
...kept.slice(0, at + 1),
|
|
209191
|
+
hub,
|
|
209192
|
+
...kept.slice(at + 1)
|
|
209193
|
+
];
|
|
209194
|
+
}
|
|
209195
|
+
//#endregion
|
|
208983
209196
|
//#region src/sleep-state-decision.ts
|
|
208984
209197
|
/**
|
|
208985
209198
|
* Hysteresis is ASYMMETRIC, because the two directions have very different
|
|
@@ -212687,6 +212900,18 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
212687
212900
|
isHubChild() {
|
|
212688
212901
|
return this.hubIntegrationId() !== null && typeof this.config.get("channel") === "number";
|
|
212689
212902
|
}
|
|
212903
|
+
/**
|
|
212904
|
+
* The host this camera is reached at: the integration's for a hub child (the stored per-camera
|
|
212905
|
+
* `host` of a child is never read), the camera's own otherwise. `null` when there is none.
|
|
212906
|
+
*/
|
|
212907
|
+
connectionHost() {
|
|
212908
|
+
if (this.isHubChild()) {
|
|
212909
|
+
const host = this.hubSession()?.relayEndpoint().host;
|
|
212910
|
+
return host !== void 0 && host.length > 0 ? host : null;
|
|
212911
|
+
}
|
|
212912
|
+
const host = this.config.get("host");
|
|
212913
|
+
return typeof host === "string" && host.length > 0 ? host : null;
|
|
212914
|
+
}
|
|
212690
212915
|
/** The integration (one NVR / Home Hub, D985) this camera was adopted from, or `null`. */
|
|
212691
212916
|
hubIntegrationId() {
|
|
212692
212917
|
const id = this.config.get("integrationId");
|
|
@@ -213322,7 +213547,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
213322
213547
|
isBattery: this.isBattery,
|
|
213323
213548
|
sleeping: this.sleeping,
|
|
213324
213549
|
timeZone: resolveClipTimeZoneOnce(Intl.DateTimeFormat().resolvedOptions().timeZone, reolinkTimeZoneToIana(this.config.get("deviceCache")?.systemGeneralSnapshot?.timeZone), this.ctx.logger, this.id, this.clipTimeZoneWarned),
|
|
213325
|
-
hostKey:
|
|
213550
|
+
hostKey: this.connectionHost() ?? `device-${this.id}`,
|
|
213326
213551
|
getApi: () => this.ensureApi()
|
|
213327
213552
|
};
|
|
213328
213553
|
}
|
|
@@ -213655,7 +213880,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
213655
213880
|
} });
|
|
213656
213881
|
this.ctx.registerNativeCap(deviceAdminLinkCapability, { getAdminLink: async ({ deviceId }) => {
|
|
213657
213882
|
if (deviceId !== this.id) throw new Error(`ReolinkCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
|
|
213658
|
-
const host = this.
|
|
213883
|
+
const host = this.connectionHost() ?? "";
|
|
213659
213884
|
const built = buildDeviceAdminUrl({
|
|
213660
213885
|
host,
|
|
213661
213886
|
port: null,
|
|
@@ -217008,6 +217233,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
217008
217233
|
* FLV publication for those devices rather than emitting a broken URL.
|
|
217009
217234
|
*/
|
|
217010
217235
|
buildFlvUrl(channel, profile) {
|
|
217236
|
+
if (this.isHubChild()) return null;
|
|
217011
217237
|
const host = this.config.get("host");
|
|
217012
217238
|
if (typeof host !== "string" || host.length === 0) return null;
|
|
217013
217239
|
return `http://${host}/flv?port=1935&app=bcs&stream=channel${channel}_${profile}.bcs&user=${encodeURIComponent(String(this.config.get("username") ?? ""))}&password=${encodeURIComponent(String(this.config.get("password") ?? ""))}`;
|
|
@@ -219138,12 +219364,23 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
219138
219364
|
...buildBatteryRefreshDeviceSection({ isBattery: this.isBattery })
|
|
219139
219365
|
]
|
|
219140
219366
|
};
|
|
219367
|
+
const hubChild = this.isHubChild();
|
|
219368
|
+
const hubSession = this.hubSession();
|
|
219369
|
+
const shownSchema = hubChild ? {
|
|
219370
|
+
...schema,
|
|
219371
|
+
sections: applyHubChildSections(schema.sections, hubSession?.channelSnapshot() ?? EMPTY_HUB_CHANNEL_SNAPSHOT)
|
|
219372
|
+
} : schema;
|
|
219141
219373
|
const emailSnap = cache?.emailConfigSnapshot;
|
|
219142
|
-
return hydrateSchema(
|
|
219143
|
-
|
|
219144
|
-
|
|
219145
|
-
|
|
219146
|
-
|
|
219374
|
+
return hydrateSchema(shownSchema, {
|
|
219375
|
+
...hubChild ? {
|
|
219376
|
+
hubName: hubSession?.name ?? this.hubIntegrationId() ?? "",
|
|
219377
|
+
channel: this.config.get("channel")
|
|
219378
|
+
} : {
|
|
219379
|
+
host: this.config.get("host"),
|
|
219380
|
+
port: this.config.get("port"),
|
|
219381
|
+
username: this.config.get("username"),
|
|
219382
|
+
password: this.config.get("password")
|
|
219383
|
+
},
|
|
219147
219384
|
emailSmtpServer: emailSnap?.smtpServer ?? "",
|
|
219148
219385
|
emailSmtpPort: emailSnap?.smtpPort ?? 587,
|
|
219149
219386
|
emailUserName: emailSnap?.userName ?? "",
|
|
@@ -219224,8 +219461,26 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
219224
219461
|
intercomGain: this.config.get("intercomGain") ?? 1
|
|
219225
219462
|
});
|
|
219226
219463
|
}
|
|
219464
|
+
/**
|
|
219465
|
+
* A hub child's connection belongs to its integration. A patch touching host / port /
|
|
219466
|
+
* username / password, or naming a channel the hub does not list, is refused with a typed,
|
|
219467
|
+
* logged reason — never silently dropped. The read-only `hubName` echo is not a setting.
|
|
219468
|
+
*/
|
|
219469
|
+
refuseHubChildPatch(patch) {
|
|
219470
|
+
const refusal = judgeHubChildPatch(patch, (this.hubSession()?.channelSnapshot().channels ?? []).map((c) => c.channel));
|
|
219471
|
+
if (refusal === null) return;
|
|
219472
|
+
this.ctx.logger.warn("hub child settings patch refused", {
|
|
219473
|
+
tags: { deviceId: this.id },
|
|
219474
|
+
meta: {
|
|
219475
|
+
...refusal,
|
|
219476
|
+
integrationId: this.hubIntegrationId()
|
|
219477
|
+
}
|
|
219478
|
+
});
|
|
219479
|
+
throw new HubChildPatchRefusedError(refusal);
|
|
219480
|
+
}
|
|
219227
219481
|
async applySettingsPatch(patch) {
|
|
219228
|
-
|
|
219482
|
+
if (this.isHubChild()) this.refuseHubChildPatch(patch);
|
|
219483
|
+
const { emailSmtpServer, emailSmtpPort, emailUserName, emailPassword, emailSsl, emailRecipient1, emailRecipient2, emailRecipient3, emailSendNickname, emailScheduleEnabled, osdChannelEnabled, osdChannelName, osdChannelPosition, osdTimeEnabled, osdTimePosition, osdWatermark, hubName: _hubName, ...rest } = patch;
|
|
219229
219484
|
if ((osdChannelEnabled !== void 0 || osdChannelName !== void 0 || osdChannelPosition !== void 0 || osdTimeEnabled !== void 0 || osdTimePosition !== void 0 || osdWatermark !== void 0 || emailSmtpServer !== void 0 || emailRecipient1 !== void 0) && !await this.wakeIfSleeping()) this.ctx.logger.warn("settings write: battery cam did not wake — writing anyway", { tags: { deviceId: this.id } });
|
|
219230
219485
|
const emailFields = {
|
|
219231
219486
|
emailSmtpServer,
|
|
@@ -222634,11 +222889,17 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
222634
222889
|
async onConfigChanged() {
|
|
222635
222890
|
await this.refreshClipRefreshGlobalStore();
|
|
222636
222891
|
}
|
|
222892
|
+
scopedSettingsCapabilities() {
|
|
222893
|
+
return ["videoclips"];
|
|
222894
|
+
}
|
|
222637
222895
|
/**
|
|
222638
|
-
* The
|
|
222639
|
-
*
|
|
222896
|
+
* The fleet default of the clip-catalog refresh. (The battery push has no addon-level setting:
|
|
222897
|
+
* the mailbox is a broker and the webhook is a plane of the data plane.) Per-camera overrides
|
|
222898
|
+
* live on the device under the same key and resolve through `resolveClipCatalogRefreshMinutes`
|
|
222899
|
+
* — reset == unset == this value.
|
|
222640
222900
|
*/
|
|
222641
|
-
|
|
222901
|
+
async deviceDefaultsSchema(cap) {
|
|
222902
|
+
if (cap !== "videoclips") return null;
|
|
222642
222903
|
return { sections: [...buildClipRefreshSettingsSchema().sections] };
|
|
222643
222904
|
}
|
|
222644
222905
|
async onInitialize() {
|
package/dist/addon.mjs
CHANGED
|
@@ -106669,7 +106669,7 @@ var ZodIssueCode = {
|
|
|
106669
106669
|
var ZodFirstPartyTypeKind;
|
|
106670
106670
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
106671
106671
|
//#endregion
|
|
106672
|
-
//#region ../types/dist/sleep-
|
|
106672
|
+
//#region ../types/dist/sleep-DEZaLbiu.mjs
|
|
106673
106673
|
/**
|
|
106674
106674
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
106675
106675
|
* window to float samples (D455).
|
|
@@ -107478,6 +107478,12 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
107478
107478
|
}
|
|
107479
107479
|
return out;
|
|
107480
107480
|
}
|
|
107481
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
107482
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
107483
|
+
"cluster",
|
|
107484
|
+
"device-defaults",
|
|
107485
|
+
"node"
|
|
107486
|
+
];
|
|
107481
107487
|
/**
|
|
107482
107488
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
107483
107489
|
*
|
|
@@ -108369,6 +108375,13 @@ var BaseAddon = class {
|
|
|
108369
108375
|
*/
|
|
108370
108376
|
secretStatePaths = [];
|
|
108371
108377
|
_addonSecretTree = null;
|
|
108378
|
+
/**
|
|
108379
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
108380
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
108381
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
108382
|
+
*/
|
|
108383
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
108384
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
108372
108385
|
_deviceSecretTree = null;
|
|
108373
108386
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
108374
108387
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -108438,6 +108451,7 @@ var BaseAddon = class {
|
|
|
108438
108451
|
this._ctx = context;
|
|
108439
108452
|
this._secretSettings = null;
|
|
108440
108453
|
}
|
|
108454
|
+
await this.loadScopedSchemas();
|
|
108441
108455
|
await this.resolveConfig();
|
|
108442
108456
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
108443
108457
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -108447,6 +108461,7 @@ var BaseAddon = class {
|
|
|
108447
108461
|
const normalized = normalizeAddonInitResult(result);
|
|
108448
108462
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
108449
108463
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
108464
|
+
await this.loadScopedSchemas();
|
|
108450
108465
|
return normalized;
|
|
108451
108466
|
}
|
|
108452
108467
|
/**
|
|
@@ -108535,6 +108550,16 @@ var BaseAddon = class {
|
|
|
108535
108550
|
schema(schema) {
|
|
108536
108551
|
return schema;
|
|
108537
108552
|
}
|
|
108553
|
+
/**
|
|
108554
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
108555
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
108556
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
108557
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
108558
|
+
* once known.
|
|
108559
|
+
*/
|
|
108560
|
+
scopedSettingsCapabilities() {
|
|
108561
|
+
return [];
|
|
108562
|
+
}
|
|
108538
108563
|
/** Override to provide global-level settings UI schema. */
|
|
108539
108564
|
globalSettingsSchema(_cap) {
|
|
108540
108565
|
return null;
|
|
@@ -108578,7 +108603,8 @@ var BaseAddon = class {
|
|
|
108578
108603
|
return [];
|
|
108579
108604
|
}
|
|
108580
108605
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
108581
|
-
|
|
108606
|
+
await this.loadScopedSchemas(cap);
|
|
108607
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
108582
108608
|
if (!schema) return { sections: [] };
|
|
108583
108609
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
108584
108610
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -108709,6 +108735,7 @@ var BaseAddon = class {
|
|
|
108709
108735
|
* resolved blob back is a no-op for every unchanged secret.
|
|
108710
108736
|
*/
|
|
108711
108737
|
async resolveGlobalStore(nodeId, cap) {
|
|
108738
|
+
await this.loadScopedSchemas(cap);
|
|
108712
108739
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
108713
108740
|
return this.projectForNode(raw, nodeId, cap);
|
|
108714
108741
|
}
|
|
@@ -108719,6 +108746,7 @@ var BaseAddon = class {
|
|
|
108719
108746
|
}
|
|
108720
108747
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
108721
108748
|
async readRawProjectedStore(nodeId, cap) {
|
|
108749
|
+
await this.loadScopedSchemas(cap);
|
|
108722
108750
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
108723
108751
|
return this.projectForNode(raw, nodeId, cap);
|
|
108724
108752
|
}
|
|
@@ -108821,6 +108849,7 @@ var BaseAddon = class {
|
|
|
108821
108849
|
await this.applyGlobalPatch(patch, nodeId);
|
|
108822
108850
|
}
|
|
108823
108851
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
108852
|
+
await this.loadScopedSchemas();
|
|
108824
108853
|
const keys = this.perNodeKeys();
|
|
108825
108854
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
108826
108855
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -108834,7 +108863,8 @@ var BaseAddon = class {
|
|
|
108834
108863
|
await this.resolveConfig();
|
|
108835
108864
|
await this.onConfigChanged();
|
|
108836
108865
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
108837
|
-
|
|
108866
|
+
const legacy = this.globalSettingsSchema();
|
|
108867
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
108838
108868
|
}
|
|
108839
108869
|
/**
|
|
108840
108870
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -108842,14 +108872,67 @@ var BaseAddon = class {
|
|
|
108842
108872
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
108843
108873
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
108844
108874
|
*/
|
|
108845
|
-
|
|
108875
|
+
/**
|
|
108876
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
108877
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
108878
|
+
* derived from the previous set. Idempotent.
|
|
108879
|
+
*/
|
|
108880
|
+
async loadScopedSchemas(extraCap) {
|
|
108881
|
+
const caps = new Set([
|
|
108882
|
+
...this.scopedSettingsCapabilities(),
|
|
108883
|
+
...this._registeredCapNames,
|
|
108884
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
108885
|
+
]);
|
|
108886
|
+
let added = false;
|
|
108887
|
+
for (const cap of caps) {
|
|
108888
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
108889
|
+
const loaded = [];
|
|
108890
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
108891
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
108892
|
+
if (schema !== null) loaded.push({
|
|
108893
|
+
scope,
|
|
108894
|
+
schema
|
|
108895
|
+
});
|
|
108896
|
+
}
|
|
108897
|
+
this._scopedByCap.set(cap, loaded);
|
|
108898
|
+
added = true;
|
|
108899
|
+
}
|
|
108900
|
+
if (!added) return;
|
|
108901
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
108902
|
+
this._addonSecretTree = null;
|
|
108903
|
+
}
|
|
108904
|
+
/**
|
|
108905
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
108906
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
108907
|
+
*/
|
|
108908
|
+
scopedFormSchema(cap) {
|
|
108909
|
+
const byId = /* @__PURE__ */ new Map();
|
|
108910
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
108911
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
108912
|
+
}
|
|
108913
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
108914
|
+
loadedScopedSchemas(cap) {
|
|
108915
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
108916
|
+
return [...this._scopedByCap.values()].flat();
|
|
108917
|
+
}
|
|
108918
|
+
/**
|
|
108919
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
108920
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
108921
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
108922
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
108923
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
108924
|
+
*/
|
|
108846
108925
|
perNodeKeys(cap) {
|
|
108847
108926
|
const cacheKey = cap ?? "";
|
|
108848
|
-
const cached = this.
|
|
108927
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
108849
108928
|
if (cached) return cached;
|
|
108850
|
-
const
|
|
108851
|
-
const keys = new Set(
|
|
108852
|
-
this.
|
|
108929
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
108930
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
108931
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
108932
|
+
if (scope !== "node") continue;
|
|
108933
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
108934
|
+
}
|
|
108935
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
108853
108936
|
return keys;
|
|
108854
108937
|
}
|
|
108855
108938
|
/**
|
|
@@ -108859,10 +108942,9 @@ var BaseAddon = class {
|
|
|
108859
108942
|
* time to return its response before the addon is torn down and
|
|
108860
108943
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
108861
108944
|
*/
|
|
108862
|
-
maybeAutoRestart(patchKeys,
|
|
108863
|
-
if (!schema) return;
|
|
108945
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
108864
108946
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
108865
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
108947
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
108866
108948
|
if (field.type === "separator" || field.type === "info") continue;
|
|
108867
108949
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
108868
108950
|
}
|
|
@@ -109058,12 +109140,14 @@ var BaseAddon = class {
|
|
|
109058
109140
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
109059
109141
|
*/
|
|
109060
109142
|
async getDeclaredSettingsKeys() {
|
|
109143
|
+
await this.loadScopedSchemas();
|
|
109061
109144
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
109062
109145
|
}
|
|
109063
109146
|
declaredKeySet() {
|
|
109064
109147
|
const keys = new Set(Object.keys(this.defaults));
|
|
109065
109148
|
const schema = this.globalSettingsSchema();
|
|
109066
109149
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
109150
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
109067
109151
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
109068
109152
|
for (const path of this.secretStatePaths) {
|
|
109069
109153
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -109159,7 +109243,11 @@ var BaseAddon = class {
|
|
|
109159
109243
|
}
|
|
109160
109244
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
109161
109245
|
addonSecretTree() {
|
|
109162
|
-
this._addonSecretTree
|
|
109246
|
+
if (this._addonSecretTree === null) {
|
|
109247
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
109248
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
109249
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
109250
|
+
}
|
|
109163
109251
|
return this._addonSecretTree;
|
|
109164
109252
|
}
|
|
109165
109253
|
deviceSecretTree() {
|
|
@@ -109409,6 +109497,23 @@ function dropPerNodeFields(fields) {
|
|
|
109409
109497
|
}
|
|
109410
109498
|
return kept;
|
|
109411
109499
|
}
|
|
109500
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
109501
|
+
function collectValueFieldKeys(fields) {
|
|
109502
|
+
const collected = [];
|
|
109503
|
+
for (const field of fields) {
|
|
109504
|
+
if (field.type === "group") {
|
|
109505
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
109506
|
+
continue;
|
|
109507
|
+
}
|
|
109508
|
+
if (field.type === "sub-tabs") {
|
|
109509
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
109510
|
+
continue;
|
|
109511
|
+
}
|
|
109512
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
109513
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
109514
|
+
}
|
|
109515
|
+
return collected;
|
|
109516
|
+
}
|
|
109412
109517
|
function collectFieldKeys(fields) {
|
|
109413
109518
|
const collected = [];
|
|
109414
109519
|
for (const field of fields) {
|
|
@@ -208972,6 +209077,114 @@ async function connectReolinkHub(connection) {
|
|
|
208972
209077
|
return api;
|
|
208973
209078
|
}
|
|
208974
209079
|
//#endregion
|
|
209080
|
+
//#region src/hub-child-settings.ts
|
|
209081
|
+
/**
|
|
209082
|
+
* A camera adopted under an NVR / Home Hub dials through the integration's session: the address
|
|
209083
|
+
* and the credentials belong to the integration, never to the camera. These are the per-camera
|
|
209084
|
+
* keys a hub child must refuse to change.
|
|
209085
|
+
*/
|
|
209086
|
+
var HUB_CHILD_CONNECTION_KEYS = [
|
|
209087
|
+
"host",
|
|
209088
|
+
"port",
|
|
209089
|
+
"username",
|
|
209090
|
+
"password"
|
|
209091
|
+
];
|
|
209092
|
+
/**
|
|
209093
|
+
* Sections that act on the hub itself (no channel in the call) or on the per-camera connection,
|
|
209094
|
+
* hidden for a hub child:
|
|
209095
|
+
* - `connection`: the per-camera address and credentials (the integration owns them);
|
|
209096
|
+
* - `network-ports`: `setPortConfig` rewrites the NVR's own service ports;
|
|
209097
|
+
* - `time-ntp`: `setNtp` / `setSystemGeneral` / `setDst` rewrite the NVR's clock.
|
|
209098
|
+
*/
|
|
209099
|
+
var HUB_CHILD_HIDDEN_SECTION_IDS = [
|
|
209100
|
+
"connection",
|
|
209101
|
+
"network-ports",
|
|
209102
|
+
"time-ntp"
|
|
209103
|
+
];
|
|
209104
|
+
/** Thrown by `applySettingsPatch` for a refused hub-child patch; carries the typed reason. */
|
|
209105
|
+
var HubChildPatchRefusedError = class extends Error {
|
|
209106
|
+
refusal;
|
|
209107
|
+
constructor(refusal) {
|
|
209108
|
+
super(describeRefusal(refusal));
|
|
209109
|
+
this.refusal = refusal;
|
|
209110
|
+
this.name = "HubChildPatchRefusedError";
|
|
209111
|
+
}
|
|
209112
|
+
};
|
|
209113
|
+
function describeRefusal(refusal) {
|
|
209114
|
+
switch (refusal.reason) {
|
|
209115
|
+
case "connection-owned-by-integration": return `This camera is connected through its NVR / Home Hub integration: ${refusal.keys.join(", ")} can only be changed on the integration`;
|
|
209116
|
+
case "channel-not-an-integer": return `The hub channel must be a whole number, got ${String(refusal.value)}`;
|
|
209117
|
+
case "channel-out-of-range": return `Channel ${refusal.value} is not one of the hub's channels (${refusal.channels.join(", ")})`;
|
|
209118
|
+
}
|
|
209119
|
+
}
|
|
209120
|
+
/**
|
|
209121
|
+
* Judge a settings patch against the hub-child rules. `channels` is the hub's last good channel
|
|
209122
|
+
* list (empty when unknown — then only the integer rule applies).
|
|
209123
|
+
*/
|
|
209124
|
+
function judgeHubChildPatch(patch, channels) {
|
|
209125
|
+
const touched = HUB_CHILD_CONNECTION_KEYS.filter((k) => patch[k] !== void 0);
|
|
209126
|
+
if (touched.length > 0) return {
|
|
209127
|
+
reason: "connection-owned-by-integration",
|
|
209128
|
+
keys: touched
|
|
209129
|
+
};
|
|
209130
|
+
if (patch["channel"] === void 0) return null;
|
|
209131
|
+
const value = patch["channel"];
|
|
209132
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) return {
|
|
209133
|
+
reason: "channel-not-an-integer",
|
|
209134
|
+
value
|
|
209135
|
+
};
|
|
209136
|
+
if (channels.length > 0 && !channels.includes(value)) return {
|
|
209137
|
+
reason: "channel-out-of-range",
|
|
209138
|
+
value,
|
|
209139
|
+
channels
|
|
209140
|
+
};
|
|
209141
|
+
return null;
|
|
209142
|
+
}
|
|
209143
|
+
/** What a hub child shows before its session has read the hub's channel list. */
|
|
209144
|
+
var EMPTY_HUB_CHANNEL_SNAPSHOT = {
|
|
209145
|
+
channels: [],
|
|
209146
|
+
lastRefreshAt: null,
|
|
209147
|
+
lastError: null
|
|
209148
|
+
};
|
|
209149
|
+
/** The hub-child "Hub" section: which hub, and the one editable connection field, the channel. */
|
|
209150
|
+
function buildHubChildSection(snapshot) {
|
|
209151
|
+
return {
|
|
209152
|
+
id: "hub",
|
|
209153
|
+
tab: "general",
|
|
209154
|
+
title: "Hub",
|
|
209155
|
+
titleKey: "provider-reolink:schema.s_hub.title",
|
|
209156
|
+
description: "This camera is connected through its NVR / Home Hub. Address and credentials belong to that integration; the channel is kept in line with the hub automatically.",
|
|
209157
|
+
descriptionKey: "provider-reolink:schema.s_hub.description",
|
|
209158
|
+
columns: 2,
|
|
209159
|
+
fields: [{
|
|
209160
|
+
type: "text",
|
|
209161
|
+
key: "hubName",
|
|
209162
|
+
label: "Connected to",
|
|
209163
|
+
labelKey: "provider-reolink:schema.s_hub.hubName.label",
|
|
209164
|
+
disabled: true
|
|
209165
|
+
}, {
|
|
209166
|
+
type: "number",
|
|
209167
|
+
key: "channel",
|
|
209168
|
+
label: "Hub channel",
|
|
209169
|
+
labelKey: "provider-reolink:schema.s_hub.channel.label",
|
|
209170
|
+
min: 0,
|
|
209171
|
+
...snapshot.channels.length > 0 ? { max: Math.max(...snapshot.channels.map((c) => c.channel)) } : {},
|
|
209172
|
+
step: 1
|
|
209173
|
+
}]
|
|
209174
|
+
};
|
|
209175
|
+
}
|
|
209176
|
+
/** Replace the connection/hub-acting sections of a standalone schema with the Hub section. */
|
|
209177
|
+
function applyHubChildSections(sections, snapshot) {
|
|
209178
|
+
const kept = sections.filter((s) => !HUB_CHILD_HIDDEN_SECTION_IDS.includes(s.id));
|
|
209179
|
+
const at = kept.findIndex((s) => s.id === "driver-refresh");
|
|
209180
|
+
const hub = buildHubChildSection(snapshot);
|
|
209181
|
+
return at < 0 ? [hub, ...kept] : [
|
|
209182
|
+
...kept.slice(0, at + 1),
|
|
209183
|
+
hub,
|
|
209184
|
+
...kept.slice(at + 1)
|
|
209185
|
+
];
|
|
209186
|
+
}
|
|
209187
|
+
//#endregion
|
|
208975
209188
|
//#region src/sleep-state-decision.ts
|
|
208976
209189
|
/**
|
|
208977
209190
|
* Hysteresis is ASYMMETRIC, because the two directions have very different
|
|
@@ -212679,6 +212892,18 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
212679
212892
|
isHubChild() {
|
|
212680
212893
|
return this.hubIntegrationId() !== null && typeof this.config.get("channel") === "number";
|
|
212681
212894
|
}
|
|
212895
|
+
/**
|
|
212896
|
+
* The host this camera is reached at: the integration's for a hub child (the stored per-camera
|
|
212897
|
+
* `host` of a child is never read), the camera's own otherwise. `null` when there is none.
|
|
212898
|
+
*/
|
|
212899
|
+
connectionHost() {
|
|
212900
|
+
if (this.isHubChild()) {
|
|
212901
|
+
const host = this.hubSession()?.relayEndpoint().host;
|
|
212902
|
+
return host !== void 0 && host.length > 0 ? host : null;
|
|
212903
|
+
}
|
|
212904
|
+
const host = this.config.get("host");
|
|
212905
|
+
return typeof host === "string" && host.length > 0 ? host : null;
|
|
212906
|
+
}
|
|
212682
212907
|
/** The integration (one NVR / Home Hub, D985) this camera was adopted from, or `null`. */
|
|
212683
212908
|
hubIntegrationId() {
|
|
212684
212909
|
const id = this.config.get("integrationId");
|
|
@@ -213314,7 +213539,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
213314
213539
|
isBattery: this.isBattery,
|
|
213315
213540
|
sleeping: this.sleeping,
|
|
213316
213541
|
timeZone: resolveClipTimeZoneOnce(Intl.DateTimeFormat().resolvedOptions().timeZone, reolinkTimeZoneToIana(this.config.get("deviceCache")?.systemGeneralSnapshot?.timeZone), this.ctx.logger, this.id, this.clipTimeZoneWarned),
|
|
213317
|
-
hostKey:
|
|
213542
|
+
hostKey: this.connectionHost() ?? `device-${this.id}`,
|
|
213318
213543
|
getApi: () => this.ensureApi()
|
|
213319
213544
|
};
|
|
213320
213545
|
}
|
|
@@ -213647,7 +213872,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
213647
213872
|
} });
|
|
213648
213873
|
this.ctx.registerNativeCap(deviceAdminLinkCapability, { getAdminLink: async ({ deviceId }) => {
|
|
213649
213874
|
if (deviceId !== this.id) throw new Error(`ReolinkCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
|
|
213650
|
-
const host = this.
|
|
213875
|
+
const host = this.connectionHost() ?? "";
|
|
213651
213876
|
const built = buildDeviceAdminUrl({
|
|
213652
213877
|
host,
|
|
213653
213878
|
port: null,
|
|
@@ -217000,6 +217225,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
217000
217225
|
* FLV publication for those devices rather than emitting a broken URL.
|
|
217001
217226
|
*/
|
|
217002
217227
|
buildFlvUrl(channel, profile) {
|
|
217228
|
+
if (this.isHubChild()) return null;
|
|
217003
217229
|
const host = this.config.get("host");
|
|
217004
217230
|
if (typeof host !== "string" || host.length === 0) return null;
|
|
217005
217231
|
return `http://${host}/flv?port=1935&app=bcs&stream=channel${channel}_${profile}.bcs&user=${encodeURIComponent(String(this.config.get("username") ?? ""))}&password=${encodeURIComponent(String(this.config.get("password") ?? ""))}`;
|
|
@@ -219130,12 +219356,23 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
219130
219356
|
...buildBatteryRefreshDeviceSection({ isBattery: this.isBattery })
|
|
219131
219357
|
]
|
|
219132
219358
|
};
|
|
219359
|
+
const hubChild = this.isHubChild();
|
|
219360
|
+
const hubSession = this.hubSession();
|
|
219361
|
+
const shownSchema = hubChild ? {
|
|
219362
|
+
...schema,
|
|
219363
|
+
sections: applyHubChildSections(schema.sections, hubSession?.channelSnapshot() ?? EMPTY_HUB_CHANNEL_SNAPSHOT)
|
|
219364
|
+
} : schema;
|
|
219133
219365
|
const emailSnap = cache?.emailConfigSnapshot;
|
|
219134
|
-
return hydrateSchema(
|
|
219135
|
-
|
|
219136
|
-
|
|
219137
|
-
|
|
219138
|
-
|
|
219366
|
+
return hydrateSchema(shownSchema, {
|
|
219367
|
+
...hubChild ? {
|
|
219368
|
+
hubName: hubSession?.name ?? this.hubIntegrationId() ?? "",
|
|
219369
|
+
channel: this.config.get("channel")
|
|
219370
|
+
} : {
|
|
219371
|
+
host: this.config.get("host"),
|
|
219372
|
+
port: this.config.get("port"),
|
|
219373
|
+
username: this.config.get("username"),
|
|
219374
|
+
password: this.config.get("password")
|
|
219375
|
+
},
|
|
219139
219376
|
emailSmtpServer: emailSnap?.smtpServer ?? "",
|
|
219140
219377
|
emailSmtpPort: emailSnap?.smtpPort ?? 587,
|
|
219141
219378
|
emailUserName: emailSnap?.userName ?? "",
|
|
@@ -219216,8 +219453,26 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
219216
219453
|
intercomGain: this.config.get("intercomGain") ?? 1
|
|
219217
219454
|
});
|
|
219218
219455
|
}
|
|
219456
|
+
/**
|
|
219457
|
+
* A hub child's connection belongs to its integration. A patch touching host / port /
|
|
219458
|
+
* username / password, or naming a channel the hub does not list, is refused with a typed,
|
|
219459
|
+
* logged reason — never silently dropped. The read-only `hubName` echo is not a setting.
|
|
219460
|
+
*/
|
|
219461
|
+
refuseHubChildPatch(patch) {
|
|
219462
|
+
const refusal = judgeHubChildPatch(patch, (this.hubSession()?.channelSnapshot().channels ?? []).map((c) => c.channel));
|
|
219463
|
+
if (refusal === null) return;
|
|
219464
|
+
this.ctx.logger.warn("hub child settings patch refused", {
|
|
219465
|
+
tags: { deviceId: this.id },
|
|
219466
|
+
meta: {
|
|
219467
|
+
...refusal,
|
|
219468
|
+
integrationId: this.hubIntegrationId()
|
|
219469
|
+
}
|
|
219470
|
+
});
|
|
219471
|
+
throw new HubChildPatchRefusedError(refusal);
|
|
219472
|
+
}
|
|
219219
219473
|
async applySettingsPatch(patch) {
|
|
219220
|
-
|
|
219474
|
+
if (this.isHubChild()) this.refuseHubChildPatch(patch);
|
|
219475
|
+
const { emailSmtpServer, emailSmtpPort, emailUserName, emailPassword, emailSsl, emailRecipient1, emailRecipient2, emailRecipient3, emailSendNickname, emailScheduleEnabled, osdChannelEnabled, osdChannelName, osdChannelPosition, osdTimeEnabled, osdTimePosition, osdWatermark, hubName: _hubName, ...rest } = patch;
|
|
219221
219476
|
if ((osdChannelEnabled !== void 0 || osdChannelName !== void 0 || osdChannelPosition !== void 0 || osdTimeEnabled !== void 0 || osdTimePosition !== void 0 || osdWatermark !== void 0 || emailSmtpServer !== void 0 || emailRecipient1 !== void 0) && !await this.wakeIfSleeping()) this.ctx.logger.warn("settings write: battery cam did not wake — writing anyway", { tags: { deviceId: this.id } });
|
|
219222
219477
|
const emailFields = {
|
|
219223
219478
|
emailSmtpServer,
|
|
@@ -222626,11 +222881,17 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
222626
222881
|
async onConfigChanged() {
|
|
222627
222882
|
await this.refreshClipRefreshGlobalStore();
|
|
222628
222883
|
}
|
|
222884
|
+
scopedSettingsCapabilities() {
|
|
222885
|
+
return ["videoclips"];
|
|
222886
|
+
}
|
|
222629
222887
|
/**
|
|
222630
|
-
* The
|
|
222631
|
-
*
|
|
222888
|
+
* The fleet default of the clip-catalog refresh. (The battery push has no addon-level setting:
|
|
222889
|
+
* the mailbox is a broker and the webhook is a plane of the data plane.) Per-camera overrides
|
|
222890
|
+
* live on the device under the same key and resolve through `resolveClipCatalogRefreshMinutes`
|
|
222891
|
+
* — reset == unset == this value.
|
|
222632
222892
|
*/
|
|
222633
|
-
|
|
222893
|
+
async deviceDefaultsSchema(cap) {
|
|
222894
|
+
if (cap !== "videoclips") return null;
|
|
222634
222895
|
return { sections: [...buildClipRefreshSettingsSchema().sections] };
|
|
222635
222896
|
}
|
|
222636
222897
|
async onInitialize() {
|
package/i18n/en.json
CHANGED
|
@@ -204,5 +204,17 @@
|
|
|
204
204
|
"connection.s_hub-debug.debugSocketLogs.label": "Socket trace categories",
|
|
205
205
|
"connection.s_hub-debug.debugSocketLogs.description": "Each area adds log volume.",
|
|
206
206
|
"connection.s_hub-debug.debugSocketLogs.o_traceEvents.label": "Events (cmd 33 — AlarmEventList push)",
|
|
207
|
-
"connection.s_connection.rtspPort.label": "RTSP port"
|
|
207
|
+
"connection.s_connection.rtspPort.label": "RTSP port",
|
|
208
|
+
"schema": {
|
|
209
|
+
"s_hub": {
|
|
210
|
+
"title": "Hub",
|
|
211
|
+
"description": "This camera is connected through its NVR / Home Hub. Address and credentials belong to that integration; the channel is kept in line with the hub automatically.",
|
|
212
|
+
"hubName": {
|
|
213
|
+
"label": "Connected to"
|
|
214
|
+
},
|
|
215
|
+
"channel": {
|
|
216
|
+
"label": "Hub channel"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
208
220
|
}
|
package/i18n/it.json
CHANGED
|
@@ -204,5 +204,17 @@
|
|
|
204
204
|
"connection.s_hub-debug.debugSocketLogs.label": "Categorie di trace del socket",
|
|
205
205
|
"connection.s_hub-debug.debugSocketLogs.description": "Ogni area aumenta il volume dei log.",
|
|
206
206
|
"connection.s_hub-debug.debugSocketLogs.o_traceEvents.label": "Eventi (cmd 33 — push AlarmEventList)",
|
|
207
|
-
"connection.s_connection.rtspPort.label": "Porta RTSP"
|
|
207
|
+
"connection.s_connection.rtspPort.label": "Porta RTSP",
|
|
208
|
+
"schema": {
|
|
209
|
+
"s_hub": {
|
|
210
|
+
"title": "Hub",
|
|
211
|
+
"description": "Questa telecamera è collegata tramite il suo NVR / Home Hub. Indirizzo e credenziali appartengono a quell'integrazione; il canale resta allineato all'hub in automatico.",
|
|
212
|
+
"hubName": {
|
|
213
|
+
"label": "Collegata a"
|
|
214
|
+
},
|
|
215
|
+
"channel": {
|
|
216
|
+
"label": "Canale dell'hub"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
208
220
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-reolink",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.227",
|
|
4
4
|
"description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"werift"
|
|
97
97
|
],
|
|
98
98
|
"requires": {
|
|
99
|
-
"server": ">=1.2.
|
|
99
|
+
"server": ">=1.2.775"
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"files": [
|