@camstack/server 1.2.746 → 1.2.747
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 +6 -0
- package/dist/api/trpc/generated-cap-routers.js +63 -0
- package/package.json +22 -10
- package/system/dist/{agent-https-p__QCKx2.mjs → agent-https-BfUY5VmU.mjs} +1 -1
- package/system/dist/{agent-https-CeiGBOLL.js → agent-https-CAt94pY2.js} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +75 -11
- package/system/dist/builtins/composer/composer.addon.mjs +75 -11
- package/system/dist/builtins/composer/composer.d.ts +13 -1
- package/system/dist/builtins/composer/forward-commands.d.ts +11 -0
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +161 -85
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +161 -85
- package/system/dist/builtins/core-blocks/remote-call-redirect.d.ts +9 -3
- package/system/dist/builtins/core-blocks/remote-service.d.ts +32 -6
- package/system/dist/builtins/core-blocks/remote-wiring.d.ts +8 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +3 -3
- package/system/dist/builtins/keychain/index.mjs +3 -3
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.d.ts +8 -0
- package/system/dist/builtins/local-network/local-network.addon.js +99 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +99 -2
- package/system/dist/builtins/local-network/migrations/hub-node-fields.d.ts +30 -0
- package/system/dist/builtins/local-network/migrations/index.d.ts +8 -0
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{composition-sources-C9lrcs0U.js → composition-sources-BY81UoJk.js} +1 -1
- package/system/dist/{composition-sources-MLdAmm_H.mjs → composition-sources-DsufFrcN.mjs} +1 -1
- package/system/dist/{constants-DCW5J_Df.mjs → constants-BoiK7ZwD.mjs} +1 -1
- package/system/dist/{constants-DNhyMkdx.js → constants-C7y03EtR.js} +1 -1
- package/system/dist/{device-ca-AYCsUsY8.js → device-ca-DN_6Q65t.js} +1 -1
- package/system/dist/{device-ca-Cp0tBm4M.mjs → device-ca-FC5a_gAu.mjs} +1 -1
- package/system/dist/{dist-B1ZljzFe.js → dist-5gi6RCY-.js} +465 -220
- package/system/dist/{dist-CMxM4-FW.mjs → dist-KFDdjTXv.mjs} +448 -221
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-Xf67S6hV.js → hub-mdns-ciao-B2_CA_s6.js} +2 -2
- package/system/dist/{hub-mdns-ciao-CbnDQ6lH.mjs → hub-mdns-ciao-dArIz3_4.mjs} +2 -2
- package/system/dist/index.js +7 -7
- package/system/dist/index.mjs +7 -7
- package/system/dist/{restore-archive-CMJvv4hx.mjs → restore-archive-BpSFO8p5.mjs} +82 -82
- package/system/dist/{restore-archive-DLTNZsfo.js → restore-archive-CPvKHlE8.js} +1 -1
- package/system/dist/{retention-DggVaaFh.mjs → retention-C2ZNWzrF.mjs} +1 -1
- package/system/dist/{retention-tfu-EBh4.js → retention-v4AG_OmX.js} +1 -1
- package/system/dist/{wal-maintenance-B5qz1TlP.js → wal-maintenance-D60-hpsh.js} +0 -0
- package/system/dist/{wal-maintenance-Ch9XhjjA.mjs → wal-maintenance-VpFJg7Z1.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -29,6 +29,17 @@ export declare class ForwardRefusedError extends Error {
|
|
|
29
29
|
readonly source: string;
|
|
30
30
|
constructor(reason: ForwardRefusalReason, source: string, detail: string);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* A method the `remote` extension serves was not taken by it: its role is not
|
|
34
|
+
* bound (D967 amendment). The redirect runs a BOUND role before a call ever
|
|
35
|
+
* reaches the native, so reaching it means nothing is bound — a typed answer,
|
|
36
|
+
* never a silent no-op.
|
|
37
|
+
*/
|
|
38
|
+
export declare class MediaPlayerUnsupportedError extends Error {
|
|
39
|
+
readonly method: string;
|
|
40
|
+
readonly code = "media-player.unsupported";
|
|
41
|
+
constructor(method: string);
|
|
42
|
+
}
|
|
32
43
|
export interface ForwardBlock {
|
|
33
44
|
readonly id: string;
|
|
34
45
|
readonly features: readonly CompositionFieldsFeature[];
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-5gi6RCY-.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
//#region src/builtins/console-logging/console-destination.ts
|
|
9
9
|
var LEVEL_RANK = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ti as logDestinationCapability, vo as BaseAddon } from "../../dist-KFDdjTXv.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/console-logging/console-destination.ts
|
|
4
4
|
var LEVEL_RANK = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-5gi6RCY-.js");
|
|
4
4
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
5
|
-
const require_composition_sources = require("../../composition-sources-
|
|
5
|
+
const require_composition_sources = require("../../composition-sources-BY81UoJk.js");
|
|
6
6
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
7
7
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
8
8
|
let zod = require("zod");
|
|
@@ -5001,27 +5001,23 @@ async function seedLockDoors(deps) {
|
|
|
5001
5001
|
* A binding that FAILS fails the call: the native cap never silently runs in
|
|
5002
5002
|
* its place. `repeat`, where the caller supplies one, is passed through.
|
|
5003
5003
|
* - `getStatus` is answered from the remote's own bookkeeping — marked
|
|
5004
|
-
* `assumed` — only when NO
|
|
5005
|
-
* with a native media-player cap is reported by it, as before
|
|
5004
|
+
* `assumed` — only when NO reading source exists for the device. A device
|
|
5005
|
+
* with a driver's native media-player cap is reported by it, as before; a
|
|
5006
|
+
* composed IR television (D967 `extension`) has none, so the remote answers.
|
|
5007
|
+
* - A step command (`volumeUp`, `channelDown`, …) takes `steps` as its repeat:
|
|
5008
|
+
* N full sends (D964).
|
|
5006
5009
|
*/
|
|
5007
5010
|
var MEDIA_PLAYER = "media-player";
|
|
5008
|
-
var COMMANDS = new Set(
|
|
5009
|
-
"play",
|
|
5010
|
-
"pause",
|
|
5011
|
-
"stop",
|
|
5012
|
-
"next",
|
|
5013
|
-
"previous",
|
|
5014
|
-
"setMute",
|
|
5015
|
-
"selectSource"
|
|
5016
|
-
]);
|
|
5011
|
+
var COMMANDS = new Set(require_dist.REMOTE_MEDIA_COMMANDS);
|
|
5017
5012
|
function isCommand(method) {
|
|
5018
5013
|
return COMMANDS.has(method);
|
|
5019
5014
|
}
|
|
5020
5015
|
function field(args, key) {
|
|
5021
5016
|
return args !== null && typeof args === "object" ? Reflect.get(args, key) : void 0;
|
|
5022
5017
|
}
|
|
5018
|
+
/** The caller's count: `steps` (a step method) or `repeat` (D964), at most `REMOTE_MAX_REPEAT`. */
|
|
5023
5019
|
function repeatOf(args) {
|
|
5024
|
-
const raw = field(args, "repeat");
|
|
5020
|
+
const raw = field(args, "steps") ?? field(args, "repeat");
|
|
5025
5021
|
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1) return 1;
|
|
5026
5022
|
return Math.min(raw, 50);
|
|
5027
5023
|
}
|
|
@@ -5071,30 +5067,9 @@ function remoteCallRedirect(deps) {
|
|
|
5071
5067
|
}
|
|
5072
5068
|
};
|
|
5073
5069
|
}
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
* The `remote` cap (D963, D964): a button panel over a media-player device. It
|
|
5078
|
-
* keeps the per-device configuration (layout template, role bindings, custom
|
|
5079
|
-
* buttons, power mode) in the device's settings store and runs a bound ROLE by
|
|
5080
|
-
* calling the action it is bound to — the shape an Action step has, so an
|
|
5081
|
-
* infrared code and a smart-TV call are the same thing here.
|
|
5082
|
-
*
|
|
5083
|
-
* Decisions that shape this file:
|
|
5084
|
-
* - **What a button does is the action's business.** This service never
|
|
5085
|
-
* knows what an infrared code is; it invokes a cap method on a device.
|
|
5086
|
-
* - **`repeat` is the caller's** (volume ×5), never stored. A failing send
|
|
5087
|
-
* stops the row and reports the cause; it is never swallowed.
|
|
5088
|
-
* - **State is read from the running-state cap if the device has one, else
|
|
5089
|
-
* from a native media-player reading, else assumed.** An assumption moves
|
|
5090
|
-
* only AFTER a send succeeded, is persisted per device and never recorded
|
|
5091
|
-
* in history. A toggle power code is sent only when the current state
|
|
5092
|
-
* differs from the requested one; a discrete pair is always sent. A mute on
|
|
5093
|
-
* a device that does not report it is sent and marked assumed.
|
|
5094
|
-
* - **Precedence** (`sendMediaCommand`): a media-player command takes the
|
|
5095
|
-
* remote when its role is bound, else answers `not-routed` so the native
|
|
5096
|
-
* cap runs. The dispatch redirect asks this for every caller.
|
|
5097
|
-
*/
|
|
5070
|
+
var realSleep = (ms) => new Promise((resolve) => {
|
|
5071
|
+
setTimeout(resolve, ms);
|
|
5072
|
+
});
|
|
5098
5073
|
var POWER_OFF_STATES = new Set(["off", "standby"]);
|
|
5099
5074
|
/** Roles a media-player command tries, in order. The first BOUND one wins. */
|
|
5100
5075
|
function rolesFor(command) {
|
|
@@ -5105,6 +5080,12 @@ function rolesFor(command) {
|
|
|
5105
5080
|
case "next": return ["next"];
|
|
5106
5081
|
case "previous": return ["previous"];
|
|
5107
5082
|
case "setMute": return ["mute"];
|
|
5083
|
+
case "turnOn": return ["power_on"];
|
|
5084
|
+
case "turnOff": return ["power_off"];
|
|
5085
|
+
case "volumeUp": return ["volume_up"];
|
|
5086
|
+
case "volumeDown": return ["volume_down"];
|
|
5087
|
+
case "channelUp": return ["channel_up"];
|
|
5088
|
+
case "channelDown": return ["channel_down"];
|
|
5108
5089
|
case "selectSource": return [];
|
|
5109
5090
|
}
|
|
5110
5091
|
}
|
|
@@ -5114,9 +5095,11 @@ function errorText(err) {
|
|
|
5114
5095
|
var RemoteService = class {
|
|
5115
5096
|
deps;
|
|
5116
5097
|
now;
|
|
5098
|
+
sleep;
|
|
5117
5099
|
constructor(deps) {
|
|
5118
5100
|
this.deps = deps;
|
|
5119
5101
|
this.now = deps.now ?? Date.now;
|
|
5102
|
+
this.sleep = deps.sleep ?? realSleep;
|
|
5120
5103
|
}
|
|
5121
5104
|
getConfig = async ({ deviceId }) => this.deps.store.read(deviceId);
|
|
5122
5105
|
setConfig = async ({ deviceId, config }) => {
|
|
@@ -5163,42 +5146,64 @@ var RemoteService = class {
|
|
|
5163
5146
|
return this.run(deviceId, config, role, repeat);
|
|
5164
5147
|
};
|
|
5165
5148
|
/**
|
|
5166
|
-
*
|
|
5167
|
-
*
|
|
5168
|
-
* `getStatus` hook asks the native source FIRST and serves this only when
|
|
5169
|
-
* none answers. Power comes from the running-state cap when there is one,
|
|
5170
|
-
* else from the assumption; mute comes from the assumption.
|
|
5149
|
+
* What the remote ASSUMES (the last power and mute it sent), or null when it
|
|
5150
|
+
* knows neither. No plug, no running-state: that is `assumedStatus`.
|
|
5171
5151
|
*/
|
|
5172
|
-
async
|
|
5173
|
-
const kept = await this.
|
|
5174
|
-
|
|
5152
|
+
getAssumedStatus = async ({ deviceId }) => {
|
|
5153
|
+
const kept = await this.readAssumed(deviceId);
|
|
5154
|
+
if (kept.power === null && kept.muted === null) return null;
|
|
5155
|
+
const config = await this.deps.store.read(deviceId);
|
|
5175
5156
|
const assumedFields = [];
|
|
5176
|
-
|
|
5177
|
-
let changedAt;
|
|
5178
|
-
if (running !== null) {
|
|
5179
|
-
state = running ? "on" : "off";
|
|
5180
|
-
changedAt = this.now();
|
|
5181
|
-
} else if (kept.power !== null) {
|
|
5182
|
-
state = kept.power.state;
|
|
5183
|
-
changedAt = kept.power.at;
|
|
5184
|
-
assumedFields.push("state");
|
|
5185
|
-
} else return null;
|
|
5157
|
+
if (kept.power !== null) assumedFields.push("state");
|
|
5186
5158
|
if (kept.muted !== null) assumedFields.push("isMuted");
|
|
5159
|
+
return this.statusOf({
|
|
5160
|
+
state: kept.power?.state ?? "standby",
|
|
5161
|
+
assumedFields,
|
|
5162
|
+
muted: kept.muted?.value ?? null,
|
|
5163
|
+
changedAt: Math.max(kept.power?.at ?? 0, kept.muted?.at ?? 0),
|
|
5164
|
+
sources: config.customButtons.map((b) => b.name)
|
|
5165
|
+
});
|
|
5166
|
+
};
|
|
5167
|
+
/**
|
|
5168
|
+
* The device's state as the remote knows it, or null when it knows no power
|
|
5169
|
+
* state. Power truth, in order: a `running-state` reading; the linked plug
|
|
5170
|
+
* (off is `off`, a reading; on is `standby` until a power command was sent,
|
|
5171
|
+
* then what the remote sent); the remote's own assumption. Mute comes from
|
|
5172
|
+
* the assumption, and only while the device may be on.
|
|
5173
|
+
*/
|
|
5174
|
+
async assumedStatus(deviceId) {
|
|
5175
|
+
const kept = await this.readAssumed(deviceId);
|
|
5176
|
+
const truth = await this.powerTruth(deviceId);
|
|
5177
|
+
if (truth === null) return null;
|
|
5178
|
+
const assumedFields = truth.assumed ? ["state"] : [];
|
|
5179
|
+
const state = truth.state;
|
|
5180
|
+
const changedAt = truth.at;
|
|
5181
|
+
const mute = state === "off" ? null : kept.muted ?? null;
|
|
5182
|
+
if (mute !== null) assumedFields.push("isMuted");
|
|
5187
5183
|
const config = await this.deps.store.read(deviceId);
|
|
5188
|
-
return {
|
|
5184
|
+
return this.statusOf({
|
|
5189
5185
|
state,
|
|
5190
|
-
stateSource: assumedFields.length > 0 ? "assumed" : "reported",
|
|
5191
5186
|
assumedFields,
|
|
5187
|
+
muted: mute?.value ?? null,
|
|
5188
|
+
changedAt: Math.max(changedAt, mute?.at ?? 0),
|
|
5189
|
+
sources: config.customButtons.map((b) => b.name)
|
|
5190
|
+
});
|
|
5191
|
+
}
|
|
5192
|
+
statusOf(input) {
|
|
5193
|
+
return {
|
|
5194
|
+
state: input.state,
|
|
5195
|
+
stateSource: input.assumedFields.length > 0 ? "assumed" : "reported",
|
|
5196
|
+
assumedFields: [...input.assumedFields],
|
|
5192
5197
|
volumeLevel: null,
|
|
5193
|
-
isMuted:
|
|
5198
|
+
isMuted: input.muted,
|
|
5194
5199
|
source: "",
|
|
5195
|
-
availableSources:
|
|
5200
|
+
availableSources: [...input.sources],
|
|
5196
5201
|
currentMedia: null,
|
|
5197
5202
|
position: null,
|
|
5198
5203
|
duration: null,
|
|
5199
5204
|
shuffle: null,
|
|
5200
5205
|
repeat: null,
|
|
5201
|
-
lastChangedAt:
|
|
5206
|
+
lastChangedAt: input.changedAt
|
|
5202
5207
|
};
|
|
5203
5208
|
}
|
|
5204
5209
|
mediaRole(config, input) {
|
|
@@ -5222,7 +5227,49 @@ var RemoteService = class {
|
|
|
5222
5227
|
if (running !== null) return running ? "on" : "off";
|
|
5223
5228
|
const reported = await this.deps.reportedStatus(deviceId);
|
|
5224
5229
|
if (reported !== null) return POWER_OFF_STATES.has(reported.state) ? "off" : "on";
|
|
5225
|
-
|
|
5230
|
+
const truth = await this.powerTruth(deviceId);
|
|
5231
|
+
if (truth === null || truth.state === "standby") return null;
|
|
5232
|
+
return truth.state === "off" ? "off" : "on";
|
|
5233
|
+
}
|
|
5234
|
+
/**
|
|
5235
|
+
* THE ordered power truth, read by the status and by the toggle guard alike:
|
|
5236
|
+
* a `running-state` reading; the linked plug (off is `off`, a reading, and
|
|
5237
|
+
* it forgets what the remote assumed, so the next plug-on starts from
|
|
5238
|
+
* standby; on contradicts an assumed `off`, which is dropped); then the
|
|
5239
|
+
* remote's own assumption; a plug on with nothing sent is `standby`.
|
|
5240
|
+
*/
|
|
5241
|
+
async powerTruth(deviceId) {
|
|
5242
|
+
const running = await this.deps.runningState(deviceId);
|
|
5243
|
+
if (running !== null) return {
|
|
5244
|
+
state: running ? "on" : "off",
|
|
5245
|
+
assumed: false,
|
|
5246
|
+
at: this.now()
|
|
5247
|
+
};
|
|
5248
|
+
const plug = await this.deps.plugOn(deviceId);
|
|
5249
|
+
const kept = await this.readAssumed(deviceId);
|
|
5250
|
+
if (plug === false) {
|
|
5251
|
+
if (kept.power !== null) await this.deps.assumptions.write(deviceId, {
|
|
5252
|
+
...kept,
|
|
5253
|
+
power: null
|
|
5254
|
+
});
|
|
5255
|
+
return {
|
|
5256
|
+
state: "off",
|
|
5257
|
+
assumed: false,
|
|
5258
|
+
at: this.now()
|
|
5259
|
+
};
|
|
5260
|
+
}
|
|
5261
|
+
const keptPower = plug === true && kept.power?.state === "off" ? null : kept.power;
|
|
5262
|
+
if (keptPower !== null) return {
|
|
5263
|
+
state: keptPower.state,
|
|
5264
|
+
assumed: true,
|
|
5265
|
+
at: keptPower.at
|
|
5266
|
+
};
|
|
5267
|
+
if (plug === true) return {
|
|
5268
|
+
state: "standby",
|
|
5269
|
+
assumed: true,
|
|
5270
|
+
at: this.now()
|
|
5271
|
+
};
|
|
5272
|
+
return null;
|
|
5226
5273
|
}
|
|
5227
5274
|
/** The mute as a native source reads it, else as last assumed, else unknown. */
|
|
5228
5275
|
async currentMute(deviceId) {
|
|
@@ -5285,27 +5332,30 @@ var RemoteService = class {
|
|
|
5285
5332
|
};
|
|
5286
5333
|
}
|
|
5287
5334
|
const times = wantsState === null && role !== "power" ? repeat : 1;
|
|
5288
|
-
for (let sent = 0; sent < times; sent += 1)
|
|
5289
|
-
await this.
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5335
|
+
for (let sent = 0; sent < times; sent += 1) {
|
|
5336
|
+
if (sent > 0) await this.sleep(150);
|
|
5337
|
+
try {
|
|
5338
|
+
await this.deps.invoke({
|
|
5339
|
+
deviceId: bound.action.deviceId,
|
|
5340
|
+
cap: bound.action.cap,
|
|
5341
|
+
method: bound.action.method,
|
|
5342
|
+
args: bound.action.args ?? {}
|
|
5343
|
+
});
|
|
5344
|
+
} catch (err) {
|
|
5345
|
+
this.deps.logger.warn("remote: the bound action failed, nothing further was sent", {
|
|
5346
|
+
tags: { deviceId },
|
|
5347
|
+
meta: {
|
|
5348
|
+
role,
|
|
5349
|
+
sent,
|
|
5350
|
+
error: errorText(err)
|
|
5351
|
+
}
|
|
5352
|
+
});
|
|
5353
|
+
return {
|
|
5354
|
+
status: "refused",
|
|
5355
|
+
reason: "action-failed",
|
|
5356
|
+
detail: errorText(err)
|
|
5357
|
+
};
|
|
5358
|
+
}
|
|
5309
5359
|
}
|
|
5310
5360
|
await this.moveAssumption(deviceId, role, wantsState);
|
|
5311
5361
|
return {
|
|
@@ -5564,6 +5614,26 @@ function runningStateOver(api, logger) {
|
|
|
5564
5614
|
}
|
|
5565
5615
|
};
|
|
5566
5616
|
}
|
|
5617
|
+
/**
|
|
5618
|
+
* The linked plug of a device (`power-source`): its switch state, null when no
|
|
5619
|
+
* plug is linked, it errors, or the state is unknown (D393) — never "off".
|
|
5620
|
+
*/
|
|
5621
|
+
function plugOnOver(api, logger) {
|
|
5622
|
+
return async (deviceId) => {
|
|
5623
|
+
const current = api();
|
|
5624
|
+
if (current === void 0) return null;
|
|
5625
|
+
try {
|
|
5626
|
+
const parsed = require_dist.PowerSourceInfoSchema.safeParse(await current.powerSource.getStatus.query({ deviceId }));
|
|
5627
|
+
return parsed.success && parsed.data.linked ? parsed.data.switchOn : null;
|
|
5628
|
+
} catch (err) {
|
|
5629
|
+
logger.debug("remote: no power-source reading for the device", {
|
|
5630
|
+
tags: { deviceId },
|
|
5631
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
5632
|
+
});
|
|
5633
|
+
return null;
|
|
5634
|
+
}
|
|
5635
|
+
};
|
|
5636
|
+
}
|
|
5567
5637
|
/** The devices whose remote configuration points at a template. */
|
|
5568
5638
|
function templateUsageOver(settings, api) {
|
|
5569
5639
|
return { devicesUsing: async (templateId) => {
|
|
@@ -5621,8 +5691,11 @@ function buildRemoteRuntime(deps) {
|
|
|
5621
5691
|
},
|
|
5622
5692
|
reportedStatus: reportedStatusOver(deps.api, deps.logger.child("remote")),
|
|
5623
5693
|
runningState: runningStateOver(deps.api, deps.logger.child("remote")),
|
|
5694
|
+
plugOn: plugOnOver(deps.api, deps.logger.child("remote")),
|
|
5624
5695
|
assumptions: remoteAssumptionStoreOver(deps.settings, deps.logger.child("remote")),
|
|
5625
|
-
logger: deps.logger.child("remote")
|
|
5696
|
+
logger: deps.logger.child("remote"),
|
|
5697
|
+
...deps.sleep === void 0 ? {} : { sleep: deps.sleep },
|
|
5698
|
+
...deps.now === void 0 ? {} : { now: deps.now }
|
|
5626
5699
|
})
|
|
5627
5700
|
};
|
|
5628
5701
|
}
|
|
@@ -7024,7 +7097,10 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
7024
7097
|
const runtime = this.remoteRuntime;
|
|
7025
7098
|
registry.setDeviceCallRedirect(composeRedirects([...runtime === null ? [] : [remoteCallRedirect({
|
|
7026
7099
|
remote: runtime.remote,
|
|
7027
|
-
hasNative: (deviceId) =>
|
|
7100
|
+
hasNative: (deviceId) => {
|
|
7101
|
+
const owner = registry.getNativeAddonId("media-player", deviceId);
|
|
7102
|
+
return owner !== null && owner !== "composer";
|
|
7103
|
+
},
|
|
7028
7104
|
logger: this.ctx.logger.child("remote")
|
|
7029
7105
|
})], gate.redirect()]));
|
|
7030
7106
|
}
|