@camstack/server 1.2.928 → 1.2.930
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 +12 -0
- package/package.json +10 -10
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/actions-service.d.ts +18 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +8670 -386
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +8294 -11
- package/system/dist/builtins/core-blocks/tcp-connect.d.ts +3 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +250 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +230 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +12 -10
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
- 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 +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-BEUWn2s_.mjs +391 -0
- package/system/dist/composition-sources-acfR4hDq.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-BMeMCBrx.js +18733 -0
- package/system/dist/core-blocks.cap-BRPsLAij.mjs +18008 -0
- package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +832 -220
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-BDh0LDhV.js +3428 -0
- package/system/dist/notification-rules.cap-DUmiMBQB.mjs +3357 -0
- package/system/dist/notification-targets-CRH-9Dy5.js +509 -0
- package/system/dist/notification-targets-DaNE-pIt.mjs +486 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-BkMxoXpL.js +843 -0
- package/system/dist/prefix-walk-ifwg_ukx.mjs +790 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-BJsL58Ih.js +34798 -0
- package/system/dist/rename-composition-block-OAtErZgq.mjs +33631 -0
- package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
|
@@ -3,12 +3,591 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const require_stream_catalog_cap = require("../../stream-catalog.cap-D3uwePiA.js");
|
|
7
|
+
const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
|
|
8
|
+
const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
|
|
9
|
+
const require_rename_composition_block = require("../../rename-composition-block-BJsL58Ih.js");
|
|
10
|
+
const require_quantity = require("../../quantity-lY1KiTSZ.js");
|
|
11
|
+
const require_device_type = require("../../device-type-CbQsnFdC.js");
|
|
12
|
+
const require_core_blocks_cap = require("../../core-blocks.cap-BMeMCBrx.js");
|
|
13
|
+
const require_addon_settings_cap = require("../../addon-settings.cap-DAiE0Nb0.js");
|
|
14
|
+
const require_error_cap = require("../../error.cap-DBhgPeWK.js");
|
|
15
|
+
const require_source_info = require("../../source-info-DtWf4k2j.js");
|
|
16
|
+
const require_composition_sources = require("../../composition-sources-acfR4hDq.js");
|
|
17
|
+
const require_declared_device = require("../../declared-device-BWphj9WE.js");
|
|
18
|
+
const require_base_device = require("../../base-device-2sL1DMm1.js");
|
|
19
|
+
const require_capture_engine = require("../../capture-engine-DZ0LIUqA.js");
|
|
9
20
|
const require_retention = require("../../retention-BcOSL6b9.js");
|
|
10
|
-
const require_rename_composition_block = require("../../rename-composition-block-C9HuBrKS.js");
|
|
11
21
|
let zod = require("zod");
|
|
22
|
+
//#region ../types/dist/esm/remote/remote-media-features.mjs
|
|
23
|
+
/**
|
|
24
|
+
* Which media-player surfaces a remote's BOUND roles give a device (D967
|
|
25
|
+
* amendment). A television driven by infrared reports nothing, so its surface is
|
|
26
|
+
* exactly what the operator wired: a bound `volume_up` is `VolumeStep`, never a
|
|
27
|
+
* level. One mapping, read by the composer (the device's `features`) and by an
|
|
28
|
+
* exporter deciding what to offer.
|
|
29
|
+
*/
|
|
30
|
+
var FEATURE_ROLES = [
|
|
31
|
+
[require_device_type.DeviceFeature.MediaPlayerPower, [
|
|
32
|
+
"power",
|
|
33
|
+
"power_on",
|
|
34
|
+
"power_off"
|
|
35
|
+
]],
|
|
36
|
+
[require_device_type.DeviceFeature.MediaPlayerVolumeStep, ["volume_up", "volume_down"]],
|
|
37
|
+
[require_device_type.DeviceFeature.MediaPlayerChannelStep, ["channel_up", "channel_down"]],
|
|
38
|
+
[require_device_type.DeviceFeature.MediaPlayerMute, ["mute"]],
|
|
39
|
+
[require_device_type.DeviceFeature.MediaPlayerStop, ["stop"]],
|
|
40
|
+
[require_device_type.DeviceFeature.MediaPlayerNext, ["next"]],
|
|
41
|
+
[require_device_type.DeviceFeature.MediaPlayerPrevious, ["previous"]]
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* The features the bound roles stand for, in a stable order. A source surface
|
|
45
|
+
* exists only for DECLARED sources (planning#460): a bound `input` or custom
|
|
46
|
+
* button is a button, not a source.
|
|
47
|
+
*/
|
|
48
|
+
function mediaPlayerFeaturesOfRoles(roles, declaredSources) {
|
|
49
|
+
const bound = new Set(roles);
|
|
50
|
+
const fixed = FEATURE_ROLES.filter(([, wanted]) => wanted.some((role) => bound.has(role))).map(([feature]) => feature);
|
|
51
|
+
return declaredSources > 0 ? [...fixed, require_device_type.DeviceFeature.MediaPlayerSelectSource] : fixed;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region ../types/dist/esm/composition/helpers/actuator-methods.mjs
|
|
55
|
+
/**
|
|
56
|
+
* One method table per actuator type (D944). A group offers a method only
|
|
57
|
+
* when every member can take it, so a command never reaches a member that
|
|
58
|
+
* lacks the surface: the cap must be bound by every member (the primary cap of
|
|
59
|
+
* the type is the exception — a member that lacks it is simply not commanded),
|
|
60
|
+
* and a row that names a device feature needs every member to advertise it.
|
|
61
|
+
* Offline does not remove a method: capability is the binding, not liveness.
|
|
62
|
+
*/
|
|
63
|
+
var ACTUATOR_TEMPLATE_IDS = [
|
|
64
|
+
"switch",
|
|
65
|
+
"light",
|
|
66
|
+
"fan",
|
|
67
|
+
"cover",
|
|
68
|
+
"valve",
|
|
69
|
+
"lock",
|
|
70
|
+
"media-player",
|
|
71
|
+
"climate"
|
|
72
|
+
];
|
|
73
|
+
function row(cap, method, requires = null, confirm = false) {
|
|
74
|
+
return {
|
|
75
|
+
cap,
|
|
76
|
+
method,
|
|
77
|
+
requires,
|
|
78
|
+
confirm
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** The first row's cap is the type's own: always offered, members without it are skipped. */
|
|
82
|
+
var ACTUATOR_METHODS = {
|
|
83
|
+
switch: [/* @__PURE__ */ row("switch", "setState")],
|
|
84
|
+
light: [
|
|
85
|
+
/* @__PURE__ */ row("switch", "setState"),
|
|
86
|
+
/* @__PURE__ */ row("brightness", "setBrightness"),
|
|
87
|
+
/* @__PURE__ */ row("color", "setColor")
|
|
88
|
+
],
|
|
89
|
+
fan: [
|
|
90
|
+
/* @__PURE__ */ row("switch", "setState"),
|
|
91
|
+
/* @__PURE__ */ row("fan-control", "setPercentage", require_device_type.DeviceFeature.FanSpeed),
|
|
92
|
+
/* @__PURE__ */ row("fan-control", "setPreset", require_device_type.DeviceFeature.FanPreset),
|
|
93
|
+
/* @__PURE__ */ row("fan-control", "setDirection", require_device_type.DeviceFeature.FanDirection),
|
|
94
|
+
/* @__PURE__ */ row("fan-control", "setOscillating", require_device_type.DeviceFeature.FanOscillating)
|
|
95
|
+
],
|
|
96
|
+
cover: [
|
|
97
|
+
/* @__PURE__ */ row("cover", "open"),
|
|
98
|
+
/* @__PURE__ */ row("cover", "close"),
|
|
99
|
+
/* @__PURE__ */ row("cover", "stop", require_device_type.DeviceFeature.CoverStoppable),
|
|
100
|
+
/* @__PURE__ */ row("cover", "setPosition", require_device_type.DeviceFeature.CoverPositionable),
|
|
101
|
+
/* @__PURE__ */ row("cover", "setTiltPosition", require_device_type.DeviceFeature.CoverTilt)
|
|
102
|
+
],
|
|
103
|
+
valve: [
|
|
104
|
+
/* @__PURE__ */ row("valve", "open"),
|
|
105
|
+
/* @__PURE__ */ row("valve", "close"),
|
|
106
|
+
/* @__PURE__ */ row("valve", "setPosition", require_device_type.DeviceFeature.ValvePositionable)
|
|
107
|
+
],
|
|
108
|
+
lock: [/* @__PURE__ */ row("lock-control", "lock"), /* @__PURE__ */ row("lock-control", "unlock", null, true)],
|
|
109
|
+
"media-player": [
|
|
110
|
+
/* @__PURE__ */ row("media-player", "play"),
|
|
111
|
+
/* @__PURE__ */ row("media-player", "pause"),
|
|
112
|
+
/* @__PURE__ */ row("media-player", "setVolume", require_device_type.DeviceFeature.MediaPlayerVolume)
|
|
113
|
+
],
|
|
114
|
+
climate: [
|
|
115
|
+
/* @__PURE__ */ row("climate-control", "setMode"),
|
|
116
|
+
/* @__PURE__ */ row("climate-control", "setTarget"),
|
|
117
|
+
/* @__PURE__ */ row("climate-control", "setFanMode", require_device_type.DeviceFeature.ClimateFanMode)
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The rows every member can take. An empty member list shares nothing; the
|
|
122
|
+
* caller passes a surface for every member it could read, or none at all.
|
|
123
|
+
*/
|
|
124
|
+
function sharedActuatorMethods(templateId, members) {
|
|
125
|
+
if (members.length === 0) return [];
|
|
126
|
+
const rows = ACTUATOR_METHODS[templateId];
|
|
127
|
+
const primary = rows[0]?.cap;
|
|
128
|
+
return rows.filter((item) => {
|
|
129
|
+
if (!(item.cap === primary || members.every((member) => member.caps.includes(item.cap)))) return false;
|
|
130
|
+
const needed = item.requires;
|
|
131
|
+
return needed === null || members.every((member) => member.features.includes(needed));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** The device features every member has, among those the table gates on, in table order. */
|
|
135
|
+
function sharedActuatorFeatures(templateId, featureLists) {
|
|
136
|
+
if (featureLists.length === 0) return [];
|
|
137
|
+
const gated = ACTUATOR_METHODS[templateId].flatMap((item) => item.requires === null ? [] : [item.requires]);
|
|
138
|
+
return [...new Set(gated)].filter((feature) => featureLists.every((features) => features.includes(feature)));
|
|
139
|
+
}
|
|
140
|
+
var UNLOCK_CONFIRMATION = "unlocking a group of locks needs an explicit confirmation (confirm: true) — it was not given, so no lock was sent anything";
|
|
141
|
+
/**
|
|
142
|
+
* Why a call must not be fanned out, or null. Only a confirmed row passes
|
|
143
|
+
* without `confirm: true`; anything else is the caller's to refuse by name.
|
|
144
|
+
*/
|
|
145
|
+
function methodRefusal(method, args) {
|
|
146
|
+
if (method === null) return "that method is not one this group shares";
|
|
147
|
+
if (method.confirm && args.confirm !== true) return UNLOCK_CONFIRMATION;
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region ../types/dist/esm/composition/helpers/aggregate.mjs
|
|
152
|
+
function isBinaryReducer(reducer) {
|
|
153
|
+
return reducer === "any" || reducer === "all";
|
|
154
|
+
}
|
|
155
|
+
function includedValue(reducer, member, activeWhen) {
|
|
156
|
+
if (member.state !== "fresh") return null;
|
|
157
|
+
if (isBinaryReducer(reducer)) {
|
|
158
|
+
if (activeWhen !== void 0) return typeof member.value === "string" ? activeWhen.includes(member.value) : null;
|
|
159
|
+
return typeof member.value === "boolean" ? member.value : null;
|
|
160
|
+
}
|
|
161
|
+
return typeof member.value === "number" && Number.isFinite(member.value) ? member.value : null;
|
|
162
|
+
}
|
|
163
|
+
function median(values) {
|
|
164
|
+
const sorted = [...values].toSorted((a, b) => a - b);
|
|
165
|
+
const mid = Math.floor(sorted.length / 2);
|
|
166
|
+
const right = sorted[mid];
|
|
167
|
+
const left = sorted[mid - 1];
|
|
168
|
+
if (right === void 0) throw new Error("median requires at least one finite number");
|
|
169
|
+
if (sorted.length % 2 === 1) return right;
|
|
170
|
+
if (left === void 0) throw new Error("median requires at least one finite number");
|
|
171
|
+
return (left + right) / 2;
|
|
172
|
+
}
|
|
173
|
+
function reduceNumbers(reducer, values) {
|
|
174
|
+
if (reducer === "min") return Math.min(...values);
|
|
175
|
+
if (reducer === "max") return Math.max(...values);
|
|
176
|
+
if (reducer === "sum") return values.reduce((sum, value) => sum + value, 0);
|
|
177
|
+
if (reducer === "median") return median(values);
|
|
178
|
+
return values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
179
|
+
}
|
|
180
|
+
function reduceBooleans(reducer, values) {
|
|
181
|
+
return reducer === "all" ? values.every((value) => value) : values.some((value) => value);
|
|
182
|
+
}
|
|
183
|
+
function countsOf(included, total) {
|
|
184
|
+
return {
|
|
185
|
+
included,
|
|
186
|
+
excluded: total - included,
|
|
187
|
+
total
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function fatalReason(members) {
|
|
191
|
+
const reasons = members.flatMap((member) => member.state === "unavailable" && member.fatal === true ? [member.reason ?? "source gone"] : []);
|
|
192
|
+
return reasons.length === 0 ? null : reasons.join("; ");
|
|
193
|
+
}
|
|
194
|
+
function emptyOutcome(empty, counts) {
|
|
195
|
+
if (empty === "null") return {
|
|
196
|
+
kind: "value",
|
|
197
|
+
value: null,
|
|
198
|
+
counts
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
kind: "unavailable",
|
|
202
|
+
fatal: false,
|
|
203
|
+
reason: "no member included — unknown is not 0 or off",
|
|
204
|
+
counts
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/** Pure. `members` is not mutated. An empty included set is null or unavailable, never 0 or false. */
|
|
208
|
+
function evaluateAggregate(input) {
|
|
209
|
+
const included = input.members.flatMap((member) => {
|
|
210
|
+
const value = includedValue(input.reducer, member, input.activeWhen);
|
|
211
|
+
return value === null ? [] : [value];
|
|
212
|
+
});
|
|
213
|
+
const counts = countsOf(included.length, input.members.length);
|
|
214
|
+
const gone = fatalReason(input.members);
|
|
215
|
+
if (gone !== null) return {
|
|
216
|
+
kind: "unavailable",
|
|
217
|
+
fatal: true,
|
|
218
|
+
reason: gone,
|
|
219
|
+
counts
|
|
220
|
+
};
|
|
221
|
+
if (input.publish === "included") return {
|
|
222
|
+
kind: "value",
|
|
223
|
+
value: counts.included,
|
|
224
|
+
counts
|
|
225
|
+
};
|
|
226
|
+
if (input.publish === "excluded") return {
|
|
227
|
+
kind: "value",
|
|
228
|
+
value: counts.excluded,
|
|
229
|
+
counts
|
|
230
|
+
};
|
|
231
|
+
if (input.publish === "total") return {
|
|
232
|
+
kind: "value",
|
|
233
|
+
value: counts.total,
|
|
234
|
+
counts
|
|
235
|
+
};
|
|
236
|
+
if (included.length === 0) return emptyOutcome(input.empty, counts);
|
|
237
|
+
if (isBinaryReducer(input.reducer)) {
|
|
238
|
+
const flags = included.filter((value) => typeof value === "boolean");
|
|
239
|
+
return {
|
|
240
|
+
kind: "value",
|
|
241
|
+
value: reduceBooleans(input.reducer, flags),
|
|
242
|
+
counts
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
const numbers = included.filter((value) => typeof value === "number");
|
|
246
|
+
return {
|
|
247
|
+
kind: "value",
|
|
248
|
+
value: reduceNumbers(input.reducer, numbers),
|
|
249
|
+
counts
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region ../types/dist/esm/composition/actuator-running.mjs
|
|
254
|
+
/**
|
|
255
|
+
* Switch on = device on (D933, amended): a device with an ACTUATOR switch - its
|
|
256
|
+
* own `switch`, the one that turns its function on - runs while that switch is on.
|
|
257
|
+
* A SUPPLY switch (`power-source.switchOn`, an appliance on a plug) is never a
|
|
258
|
+
* running source: the appliance keeps its power while it is idle.
|
|
259
|
+
*
|
|
260
|
+
* The default is derived from STRUCTURE (an actuator switch is present and no
|
|
261
|
+
* supply relation is), computed at plan time and never written into the stored
|
|
262
|
+
* composition: a stored composition is never rewritten silently, and an
|
|
263
|
+
* authored `running` field always wins. The operator turns the default on and
|
|
264
|
+
* off in the Customize running row ("Follow the device's switch").
|
|
265
|
+
*/
|
|
266
|
+
var RUNNING_CAP = "running-state";
|
|
267
|
+
var SWITCH_CAP = "switch";
|
|
268
|
+
var ON_FIELD = "on";
|
|
269
|
+
var CHANGED_AT_FIELD = "lastChangedAt";
|
|
270
|
+
function fieldsFeatureOf(composition, cap) {
|
|
271
|
+
const feature = composition.features.find((f) => f.cap === cap);
|
|
272
|
+
return feature !== void 0 && feature.kind === "fields" ? feature : null;
|
|
273
|
+
}
|
|
274
|
+
/** The device switch the composed `switch.on` reads, when it is one plain `from` of a switch. */
|
|
275
|
+
function actuatorSwitchRead(composition) {
|
|
276
|
+
const feature = fieldsFeatureOf(composition, SWITCH_CAP);
|
|
277
|
+
if (feature === null || !require_error_cap.compositionFeatureEnabled(feature)) return null;
|
|
278
|
+
const field = feature.fields[ON_FIELD];
|
|
279
|
+
if (field === void 0 || field.kind !== "from" || field.cap !== SWITCH_CAP) return null;
|
|
280
|
+
return {
|
|
281
|
+
source: field.source,
|
|
282
|
+
cap: field.cap,
|
|
283
|
+
fieldPath: field.fieldPath
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function hasSupplyRelation(composition) {
|
|
287
|
+
const feature = fieldsFeatureOf(composition, "power-source");
|
|
288
|
+
return feature !== null && require_error_cap.compositionFeatureEnabled(feature) && feature.fields["switchOn"] !== void 0;
|
|
289
|
+
}
|
|
290
|
+
/** Anything stored for running - a rule, or the opt-out - is the operator's, and the default stays out of it. */
|
|
291
|
+
function hasAuthoredRunning(composition) {
|
|
292
|
+
return fieldsFeatureOf(composition, RUNNING_CAP) !== null;
|
|
293
|
+
}
|
|
294
|
+
/** A NEW device of a type that offers "running", with an actuator switch and no supply relation. */
|
|
295
|
+
function actuatorSwitchDrivesRunning(composition) {
|
|
296
|
+
const target = composition.target;
|
|
297
|
+
if (target.kind !== "new") return false;
|
|
298
|
+
if (!require_rename_composition_block.RUNNING_CUSTOMIZE_DEVICE_TYPES.some((type) => type === target.type)) return false;
|
|
299
|
+
return actuatorSwitchRead(composition) !== null && !hasSupplyRelation(composition);
|
|
300
|
+
}
|
|
301
|
+
/** The `running-state` feature that reads the actuator switch: the one the scalar compiler stores. */
|
|
302
|
+
function followSwitchRunningFeature(composition, host) {
|
|
303
|
+
const read = actuatorSwitchRead(composition);
|
|
304
|
+
if (read === null) return null;
|
|
305
|
+
const compiled = require_composition_sources.compileScalarOverride({
|
|
306
|
+
draft: {
|
|
307
|
+
kind: "scalar",
|
|
308
|
+
cap: RUNNING_CAP,
|
|
309
|
+
targetId: "running",
|
|
310
|
+
source: {
|
|
311
|
+
...read.source,
|
|
312
|
+
cap: read.cap,
|
|
313
|
+
fieldPath: read.fieldPath
|
|
314
|
+
},
|
|
315
|
+
transform: { kind: "identity" }
|
|
316
|
+
},
|
|
317
|
+
device: host,
|
|
318
|
+
apply: "add",
|
|
319
|
+
sourceValueKind: "boolean",
|
|
320
|
+
changedAtField: CHANGED_AT_FIELD,
|
|
321
|
+
sourceUnit: null
|
|
322
|
+
});
|
|
323
|
+
return compiled.ok ? compiled.value : null;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* The composition the composer PLANS: the stored one, plus the derived running
|
|
327
|
+
* field when nothing is authored for it. The input is never changed; with nothing
|
|
328
|
+
* to add it is returned as it is.
|
|
329
|
+
*/
|
|
330
|
+
function withDefaultRunning(composition, blockId) {
|
|
331
|
+
if (hasAuthoredRunning(composition) || !actuatorSwitchDrivesRunning(composition)) return composition;
|
|
332
|
+
const feature = followSwitchRunningFeature(composition, require_error_cap.composedDeviceRef(blockId));
|
|
333
|
+
return feature === null ? composition : {
|
|
334
|
+
...composition,
|
|
335
|
+
features: [...composition.features, feature]
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region ../types/dist/esm/composition/evaluate-field.mjs
|
|
340
|
+
/**
|
|
341
|
+
* One composed field, evaluated from what its sources say NOW (D659).
|
|
342
|
+
*
|
|
343
|
+
* Pure. The composer calls it on every source change, and the slice-5 editor
|
|
344
|
+
* will call it for its live preview, so both see the same answer.
|
|
345
|
+
*
|
|
346
|
+
* The rules (spec §2):
|
|
347
|
+
* - a source that is offline or unreadable keeps its last value and is marked
|
|
348
|
+
* STALE; the field is stale and keeps computing (D49);
|
|
349
|
+
* - a source that is GONE makes the field UNAVAILABLE, `fatal`, and never a
|
|
350
|
+
* plausible number (D393);
|
|
351
|
+
* - a source that is unavailable but NOT gone (e.g. a cap unregistered at
|
|
352
|
+
* runtime, R7b) makes the field UNAVAILABLE, non-fatal, `value: null`: it
|
|
353
|
+
* may come back on its own, no block failure is raised for it;
|
|
354
|
+
* - an expression that fails on a value makes the field unavailable for that
|
|
355
|
+
* value, and NOT fatal: the next value may compute.
|
|
356
|
+
*
|
|
357
|
+
* `confirmed` (D663, D49): whether a NON-fatal unavailability is an ANSWER — a
|
|
358
|
+
* cap the provider unregistered and a re-read agreed, a field the source
|
|
359
|
+
* reported without, an expression that failed on a value — or only the
|
|
360
|
+
* absence of one (a failed read, a first or empty read, a source not tracked
|
|
361
|
+
* yet). Only a confirmed unavailability may hand a `release`-mode field back
|
|
362
|
+
* to the native provider; an unconfirmed one holds it on its last value.
|
|
363
|
+
* Absent means NOT confirmed. Fatal is always confirmed.
|
|
364
|
+
*
|
|
365
|
+
* When an expression has more than one unavailable binding, a FATAL one always
|
|
366
|
+
* wins the outcome, regardless of position: every binding is scanned before
|
|
367
|
+
* the field is judged, so an earlier non-fatal binding (e.g. a cap that is
|
|
368
|
+
* momentarily unregistered) can never hide a later fatal one (a deleted
|
|
369
|
+
* source) behind an early return.
|
|
370
|
+
*/
|
|
371
|
+
function describeRead(read) {
|
|
372
|
+
return `${require_error_cap.compositionSourceKey(read.source)} ${read.cap}.${read.fieldPath}`;
|
|
373
|
+
}
|
|
374
|
+
function isConfirmed(reading) {
|
|
375
|
+
return reading.fatal || reading.confirmed === true;
|
|
376
|
+
}
|
|
377
|
+
/** Whether a non-null value is of the kind a field of `kind` holds. */
|
|
378
|
+
function valueFitsKind(value, kind) {
|
|
379
|
+
if (value === null) return true;
|
|
380
|
+
return typeof value === (kind === "enum" ? "string" : kind);
|
|
381
|
+
}
|
|
382
|
+
function fromReading(reading, read, targetKind) {
|
|
383
|
+
if (reading.state === "unavailable") return {
|
|
384
|
+
state: "unavailable",
|
|
385
|
+
value: null,
|
|
386
|
+
reason: `${describeRead(read)}: ${reading.reason}`,
|
|
387
|
+
fatal: reading.fatal,
|
|
388
|
+
confirmed: isConfirmed(reading)
|
|
389
|
+
};
|
|
390
|
+
if (targetKind !== void 0 && !valueFitsKind(reading.value, targetKind)) return {
|
|
391
|
+
state: "unavailable",
|
|
392
|
+
value: null,
|
|
393
|
+
reason: `${describeRead(read)}: source-kind-mismatch, it reads a ${typeof reading.value} and the field takes a ${targetKind}`,
|
|
394
|
+
fatal: false,
|
|
395
|
+
confirmed: true
|
|
396
|
+
};
|
|
397
|
+
return {
|
|
398
|
+
state: reading.state,
|
|
399
|
+
value: reading.value,
|
|
400
|
+
reason: reading.state === "stale" ? `${describeRead(read)}: ${reading.reason}` : null,
|
|
401
|
+
deadline: null
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function expressionOutcome(source, read, now, stateful) {
|
|
405
|
+
const values = {};
|
|
406
|
+
const staleReasons = [];
|
|
407
|
+
let fatalUnavailable = null;
|
|
408
|
+
let nonFatalUnavailable = null;
|
|
409
|
+
for (const [name, binding] of Object.entries(source.bindings)) {
|
|
410
|
+
if (binding.kind === "literal") {
|
|
411
|
+
values[name] = binding.value;
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
const reading = read(binding);
|
|
415
|
+
if (reading.state === "unavailable") {
|
|
416
|
+
const outcome = {
|
|
417
|
+
state: "unavailable",
|
|
418
|
+
value: null,
|
|
419
|
+
reason: `binding \`${name}\` (${describeRead(binding)}): ${reading.reason}`,
|
|
420
|
+
fatal: reading.fatal,
|
|
421
|
+
confirmed: isConfirmed(reading)
|
|
422
|
+
};
|
|
423
|
+
if (reading.fatal) {
|
|
424
|
+
fatalUnavailable = outcome;
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
if (nonFatalUnavailable === null || outcome.confirmed && !nonFatalUnavailable.confirmed) nonFatalUnavailable = outcome;
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
values[name] = reading.value;
|
|
431
|
+
if (reading.state === "fresh" && reading.transition !== void 0 && stateful !== void 0) stateful.expressionMemory.dwellTransition = reading.transition;
|
|
432
|
+
if (reading.state === "stale") staleReasons.push(`\`${name}\`: ${reading.reason}`);
|
|
433
|
+
}
|
|
434
|
+
const unavailable = fatalUnavailable ?? nonFatalUnavailable;
|
|
435
|
+
if (unavailable !== null) {
|
|
436
|
+
if (stateful !== void 0 && stateful.currentOutput !== void 0 && require_core_blocks_cap.expressionContainsBuiltinCall(source.expr, "count")) return {
|
|
437
|
+
state: "stale",
|
|
438
|
+
value: require_error_cap.evaluateCount(null, {
|
|
439
|
+
kind: "count",
|
|
440
|
+
highWater: null,
|
|
441
|
+
primed: false
|
|
442
|
+
}, stateful.currentOutput),
|
|
443
|
+
reason: `${unavailable.reason}; holding the last accumulator value`,
|
|
444
|
+
deadline: null
|
|
445
|
+
};
|
|
446
|
+
return unavailable;
|
|
447
|
+
}
|
|
448
|
+
const deadlines = [];
|
|
449
|
+
const hooks = {
|
|
450
|
+
noteDeadline: (at) => deadlines.push(at),
|
|
451
|
+
...stateful?.timerDriven === true ? { timerDriven: true } : {},
|
|
452
|
+
convert: (value, from, to) => require_addon_settings_cap.tryConvertUnit(value, require_source_info.normalizeUnit(from) ?? from, require_source_info.normalizeUnit(to) ?? to) ?? null
|
|
453
|
+
};
|
|
454
|
+
const result = require_error_cap.evaluateExpressionSource(source.expr, values, now, {
|
|
455
|
+
hooks,
|
|
456
|
+
...stateful === void 0 ? {} : { invokeStateful: (invocation) => require_error_cap.evaluateStatefulExpressionCall(stateful.callPathPrefix === void 0 ? invocation : {
|
|
457
|
+
...invocation,
|
|
458
|
+
path: `${stateful.callPathPrefix}@${invocation.path}`
|
|
459
|
+
}, stateful.expressionMemory, {
|
|
460
|
+
currentOutput: stateful.currentOutput,
|
|
461
|
+
startedAtMs: stateful.startedAtMs,
|
|
462
|
+
nowMs: now
|
|
463
|
+
}, hooks) }
|
|
464
|
+
});
|
|
465
|
+
const transition = stateful?.expressionMemory.dwellTransition ?? null;
|
|
466
|
+
if (stateful !== void 0) stateful.expressionMemory.dwellTransition = null;
|
|
467
|
+
if (!result.ok) return {
|
|
468
|
+
state: "unavailable",
|
|
469
|
+
value: null,
|
|
470
|
+
reason: `the expression failed: ${result.error}`,
|
|
471
|
+
fatal: false,
|
|
472
|
+
confirmed: true,
|
|
473
|
+
expressionFailed: true
|
|
474
|
+
};
|
|
475
|
+
return {
|
|
476
|
+
state: staleReasons.length > 0 ? "stale" : "fresh",
|
|
477
|
+
value: result.value,
|
|
478
|
+
reason: staleReasons.length > 0 ? staleReasons.join("; ") : null,
|
|
479
|
+
deadline: deadlines.length > 0 ? Math.min(...deadlines) : null,
|
|
480
|
+
...transition === null ? {} : { transition }
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
function aggregateRead(reading) {
|
|
484
|
+
if (reading.state === "unavailable") return {
|
|
485
|
+
state: "unavailable",
|
|
486
|
+
fatal: reading.fatal,
|
|
487
|
+
reason: reading.reason
|
|
488
|
+
};
|
|
489
|
+
return {
|
|
490
|
+
state: reading.state,
|
|
491
|
+
value: reading.value,
|
|
492
|
+
...reading.state === "stale" ? { reason: reading.reason } : {}
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
function aggregateField(source, read) {
|
|
496
|
+
const outcome = evaluateAggregate({
|
|
497
|
+
reducer: source.reducer,
|
|
498
|
+
...source.activeWhen === void 0 ? {} : { activeWhen: source.activeWhen },
|
|
499
|
+
members: source.reads.map((item) => aggregateRead(read(item))),
|
|
500
|
+
publish: source.publish,
|
|
501
|
+
empty: source.empty
|
|
502
|
+
});
|
|
503
|
+
if (outcome.kind === "value") return {
|
|
504
|
+
state: "fresh",
|
|
505
|
+
value: outcome.value,
|
|
506
|
+
reason: null,
|
|
507
|
+
deadline: null
|
|
508
|
+
};
|
|
509
|
+
return {
|
|
510
|
+
state: "unavailable",
|
|
511
|
+
value: null,
|
|
512
|
+
reason: outcome.reason,
|
|
513
|
+
fatal: outcome.fatal,
|
|
514
|
+
confirmed: true
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function evaluateCompositionField(input) {
|
|
518
|
+
const { source } = input;
|
|
519
|
+
switch (source.kind) {
|
|
520
|
+
case "from": return fromReading(input.read(source), source, input.targetKind);
|
|
521
|
+
case "expression": return expressionOutcome(source, input.read, input.now, input.stateful);
|
|
522
|
+
case "aggregate": return aggregateField(source, input.read);
|
|
523
|
+
case "series": return {
|
|
524
|
+
state: "unavailable",
|
|
525
|
+
value: null,
|
|
526
|
+
reason: "a series field is written from device history",
|
|
527
|
+
fatal: false,
|
|
528
|
+
confirmed: false
|
|
529
|
+
};
|
|
530
|
+
case "code": return {
|
|
531
|
+
state: "unavailable",
|
|
532
|
+
value: null,
|
|
533
|
+
reason: "code fields are not runnable in the composer — they arrive in slice 4",
|
|
534
|
+
fatal: true,
|
|
535
|
+
confirmed: true
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
require_device_type.DeviceType.Cover, require_device_type.DeviceType.Valve, require_device_type.DeviceType.Humidifier, require_device_type.DeviceType.WaterHeater, require_device_type.DeviceType.HeatPump, require_device_type.DeviceType.EnergySystem, require_device_type.DeviceType.Workload, require_device_type.DeviceType.Camera, require_device_type.DeviceType.Switch, require_device_type.DeviceType.Siren, require_device_type.DeviceType.Light, require_device_type.DeviceType.Fan, require_device_type.DeviceType.Sensor, require_device_type.DeviceType.Climate, require_device_type.DeviceType.Button, require_device_type.DeviceType.EventEmitter, require_device_type.DeviceType.Update, require_device_type.DeviceType.Generic, require_device_type.DeviceType.Notifier, require_device_type.DeviceType.Script, require_device_type.DeviceType.Automation, require_device_type.DeviceType.Lock, require_device_type.DeviceType.MediaPlayer, require_device_type.DeviceType.AlarmPanel, require_device_type.DeviceType.Control, require_device_type.DeviceType.Presence, require_device_type.DeviceType.Weather, require_device_type.DeviceType.WeatherStation, require_device_type.DeviceType.Vacuum, require_device_type.DeviceType.LawnMower, require_device_type.DeviceType.Container, require_device_type.DeviceType.Image, require_device_type.DeviceType.PetFeeder, require_device_type.DeviceType.PetFountain, require_device_type.DeviceType.Dishwasher, require_device_type.DeviceType.Washer, require_device_type.DeviceType.Dryer, require_device_type.DeviceType.Gateway;
|
|
540
|
+
/** True when a value is a navigable node: a plain object OR a tRPC v11 client
|
|
541
|
+
* proxy node (a callable `Proxy(noop)` → `typeof === 'function'`, NOT an
|
|
542
|
+
* object). A `typeof === 'object'`-only check REJECTS every real client proxy,
|
|
543
|
+
* so `resolveMutate` would return null and EVERY control becomes a silent
|
|
544
|
+
* no-op. Framework-free: operates on the SDK proxy shape only. */
|
|
545
|
+
function isNode(value) {
|
|
546
|
+
return value !== null && (typeof value === "object" || typeof value === "function");
|
|
547
|
+
}
|
|
548
|
+
/** Resolve `router.<method>.mutate` to a callable, or `null`. Walks the tRPC
|
|
549
|
+
* client proxy defensively (each hop guarded by `isNode`). */
|
|
550
|
+
function resolveMutate(router, method) {
|
|
551
|
+
if (!isNode(router)) return null;
|
|
552
|
+
const proc = router[method];
|
|
553
|
+
if (!isNode(proc)) return null;
|
|
554
|
+
const mutate = proc.mutate;
|
|
555
|
+
return typeof mutate === "function" ? mutate : null;
|
|
556
|
+
}
|
|
557
|
+
//#endregion
|
|
558
|
+
//#region ../types/dist/esm/helpers/process-time-zone.mjs
|
|
559
|
+
var UNKNOWN_ZONE = "Etc/Unknown";
|
|
560
|
+
/** True when `Intl.DateTimeFormat` accepts the zone and it is not `Etc/Unknown`. */
|
|
561
|
+
function isUsableTimeZone(timeZone) {
|
|
562
|
+
if (timeZone.length === 0 || timeZone === UNKNOWN_ZONE) return false;
|
|
563
|
+
try {
|
|
564
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
565
|
+
return true;
|
|
566
|
+
} catch {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
/** The process zone when usable, else `null`. Callers choose the fallback. */
|
|
571
|
+
function usableProcessTimeZone(probe = {}) {
|
|
572
|
+
const zone = (probe.read ?? (() => Intl.DateTimeFormat().resolvedOptions().timeZone))();
|
|
573
|
+
return typeof zone === "string" && isUsableTimeZone(zone) ? zone : null;
|
|
574
|
+
}
|
|
575
|
+
var warnedRejectedZone = false;
|
|
576
|
+
/** Process zone, or `fallback` (default `UTC`); warns once with the rejected value. */
|
|
577
|
+
function processTimeZoneOr(fallback, logger, probe = {}) {
|
|
578
|
+
const usable = usableProcessTimeZone(probe);
|
|
579
|
+
if (usable !== null) return usable;
|
|
580
|
+
if (!warnedRejectedZone) {
|
|
581
|
+
warnedRejectedZone = true;
|
|
582
|
+
const read = probe.read ?? (() => Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
583
|
+
logger?.warn("the process time zone is not usable, using a fallback", { meta: {
|
|
584
|
+
rejectedTimeZone: read(),
|
|
585
|
+
fallbackTimeZone: fallback
|
|
586
|
+
} });
|
|
587
|
+
}
|
|
588
|
+
return fallback;
|
|
589
|
+
}
|
|
590
|
+
//#endregion
|
|
12
591
|
//#region src/builtins/composer/actuator-invoke.ts
|
|
13
592
|
/**
|
|
14
593
|
* Turn one fan-out call into the member's existing cap method. A bad argument
|
|
@@ -44,14 +623,14 @@ async function invokeActuatorCall(api, call) {
|
|
|
44
623
|
case "switch.setState": return api.switchSetState(id, flag(args, "on", where));
|
|
45
624
|
case "brightness.setBrightness": return api.setBrightness(id, finiteNumber(args, "level", where));
|
|
46
625
|
case "color.setColor": {
|
|
47
|
-
const color =
|
|
626
|
+
const color = require_rename_composition_block.parseColorInput(args.color);
|
|
48
627
|
if (color === null) throw new Error("color.setColor needs a colour mode");
|
|
49
628
|
return api.setColor(id, color);
|
|
50
629
|
}
|
|
51
630
|
case "fan-control.setPercentage": return api.fanSetPercentage(id, finiteNumber(args, "speed", where));
|
|
52
631
|
case "fan-control.setPreset": return api.fanSetPreset(id, text(args, "preset", where));
|
|
53
632
|
case "fan-control.setDirection": {
|
|
54
|
-
const direction =
|
|
633
|
+
const direction = require_rename_composition_block.FanDirectionSchema.safeParse(args.direction);
|
|
55
634
|
if (!direction.success) throw new Error(`${where} needs a direction (forward or reverse)`);
|
|
56
635
|
return api.fanSetDirection(id, direction.data);
|
|
57
636
|
}
|
|
@@ -70,7 +649,7 @@ async function invokeActuatorCall(api, call) {
|
|
|
70
649
|
case "media-player.pause": return api.mediaPause(id);
|
|
71
650
|
case "media-player.setVolume": return api.mediaSetVolume(id, finiteNumber(args, "volumeLevel", where));
|
|
72
651
|
case "climate-control.setMode": {
|
|
73
|
-
const mode =
|
|
652
|
+
const mode = require_rename_composition_block.HvacModeSchema.safeParse(args.mode);
|
|
74
653
|
if (!mode.success) throw new Error(`${where} needs a mode`);
|
|
75
654
|
return api.climateSetMode(id, mode.data);
|
|
76
655
|
}
|
|
@@ -114,21 +693,21 @@ function actuatorDispatcher() {
|
|
|
114
693
|
*/
|
|
115
694
|
/** Device types a helper actuator group can be: they keep the last fan-out per member. */
|
|
116
695
|
var GROUP_COMMAND_TYPES = new Set([
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
696
|
+
require_device_type.DeviceType.Switch,
|
|
697
|
+
require_device_type.DeviceType.Light,
|
|
698
|
+
require_device_type.DeviceType.Fan,
|
|
699
|
+
require_device_type.DeviceType.Cover,
|
|
700
|
+
require_device_type.DeviceType.Valve,
|
|
701
|
+
require_device_type.DeviceType.Lock,
|
|
702
|
+
require_device_type.DeviceType.MediaPlayer,
|
|
703
|
+
require_device_type.DeviceType.Climate
|
|
125
704
|
]);
|
|
126
705
|
/** A call's arguments without the keys the caller left undefined. */
|
|
127
706
|
function present(args) {
|
|
128
707
|
return Object.fromEntries(Object.entries(args).filter(([, value]) => value !== void 0));
|
|
129
708
|
}
|
|
130
709
|
/** What the derived water item reads from the `pet-fountain` slice, and the clock it is stamped with. */
|
|
131
|
-
var TANK_READING =
|
|
710
|
+
var TANK_READING = require_rename_composition_block.PetFountainStatusSchema.pick({
|
|
132
711
|
waterLevel: true,
|
|
133
712
|
empty: true,
|
|
134
713
|
lastFetchedAt: true
|
|
@@ -142,7 +721,7 @@ function commandInput(input) {
|
|
|
142
721
|
function priorResults(slice) {
|
|
143
722
|
if (!isRecord$3(slice) || !Array.isArray(slice.results)) return [];
|
|
144
723
|
return slice.results.flatMap((row) => {
|
|
145
|
-
const parsed =
|
|
724
|
+
const parsed = require_rename_composition_block.GroupCommandResultSchema.safeParse(row);
|
|
146
725
|
return parsed.success ? [parsed.data] : [];
|
|
147
726
|
});
|
|
148
727
|
}
|
|
@@ -157,7 +736,7 @@ function sliceBoolean(slice, field) {
|
|
|
157
736
|
}
|
|
158
737
|
throw new Error(`composed ${field} is unknown — not a stand-in value`);
|
|
159
738
|
}
|
|
160
|
-
var ComposedDevice = class extends
|
|
739
|
+
var ComposedDevice = class extends require_base_device.BaseDevice {
|
|
161
740
|
sharedFeatures = [];
|
|
162
741
|
valvePositionable = false;
|
|
163
742
|
/** Features of caps bound on the device by others (a wrapper): derived from its bindings, never listed here. */
|
|
@@ -184,23 +763,23 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
184
763
|
type,
|
|
185
764
|
deviceStatus
|
|
186
765
|
});
|
|
187
|
-
this.derivesWater = type ===
|
|
766
|
+
this.derivesWater = type === require_device_type.DeviceType.PetFountain;
|
|
188
767
|
for (const cap of caps) {
|
|
189
|
-
if (cap.name ===
|
|
190
|
-
const read = () => this.runtimeState.getCapState(
|
|
191
|
-
ctx.registerNativeCap(
|
|
768
|
+
if (cap.name === require_stream_catalog_cap.motionCapability.name) {
|
|
769
|
+
const read = () => this.runtimeState.getCapState(require_stream_catalog_cap.motionCapability.name);
|
|
770
|
+
ctx.registerNativeCap(require_stream_catalog_cap.motionCapability, { isDetected: async () => sliceBoolean(read(), "detected") });
|
|
192
771
|
continue;
|
|
193
772
|
}
|
|
194
|
-
if (cap.name ===
|
|
195
|
-
ctx.registerNativeCap(
|
|
773
|
+
if (cap.name === require_rename_composition_block.switchCapability.name) {
|
|
774
|
+
ctx.registerNativeCap(require_rename_composition_block.switchCapability, { setState: async (input) => {
|
|
196
775
|
await this.dispatch("switch", "setState", { on: input.on });
|
|
197
776
|
} });
|
|
198
777
|
continue;
|
|
199
778
|
}
|
|
200
779
|
ctx.registerNativeCap(cap, this.commandProvider(cap));
|
|
201
780
|
}
|
|
202
|
-
if (GROUP_COMMAND_TYPES.has(type)) ctx.registerNativeCap(
|
|
203
|
-
if (this.derivesWater && !caps.some((cap) => cap.name ===
|
|
781
|
+
if (GROUP_COMMAND_TYPES.has(type)) ctx.registerNativeCap(require_rename_composition_block.groupCommandsCapability, {});
|
|
782
|
+
if (this.derivesWater && !caps.some((cap) => cap.name === require_rename_composition_block.consumablesCapability.name)) ctx.registerNativeCap(require_rename_composition_block.consumablesCapability, { reset: (input) => this.dispatch("consumables", "reset", commandInput(input)) });
|
|
204
783
|
this.markOnline(false);
|
|
205
784
|
}
|
|
206
785
|
/**
|
|
@@ -223,13 +802,13 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
223
802
|
* modes. Switch stays: it is the active state, registered with the device.
|
|
224
803
|
*/
|
|
225
804
|
syncShared(caps, modes) {
|
|
226
|
-
this.ensureExtra(
|
|
227
|
-
this.ctx.registerNativeCap(
|
|
805
|
+
this.ensureExtra(require_rename_composition_block.brightnessCapability.name, caps.includes(require_rename_composition_block.brightnessCapability.name), () => {
|
|
806
|
+
this.ctx.registerNativeCap(require_rename_composition_block.brightnessCapability, { setBrightness: async (input) => {
|
|
228
807
|
await this.dispatch("brightness", "setBrightness", { level: input.level });
|
|
229
808
|
} });
|
|
230
809
|
});
|
|
231
|
-
this.ensureExtra(
|
|
232
|
-
this.ctx.registerNativeCap(
|
|
810
|
+
this.ensureExtra(require_rename_composition_block.colorCapability.name, caps.includes(require_rename_composition_block.colorCapability.name), () => {
|
|
811
|
+
this.ctx.registerNativeCap(require_rename_composition_block.colorCapability, { setColor: async (input) => {
|
|
233
812
|
await this.dispatch("color", "setColor", { color: input.color });
|
|
234
813
|
} });
|
|
235
814
|
});
|
|
@@ -245,16 +824,16 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
245
824
|
*/
|
|
246
825
|
syncTypedCaps(caps, modes) {
|
|
247
826
|
const call = (cap, method, args) => this.dispatch(cap, method, present(args));
|
|
248
|
-
this.ensureExtra(
|
|
249
|
-
this.ctx.registerNativeCap(
|
|
827
|
+
this.ensureExtra(require_rename_composition_block.fanControlCapability.name, caps.includes(require_rename_composition_block.fanControlCapability.name), () => {
|
|
828
|
+
this.ctx.registerNativeCap(require_rename_composition_block.fanControlCapability, {
|
|
250
829
|
setPercentage: (input) => call("fan-control", "setPercentage", { speed: input.speed }),
|
|
251
830
|
setPreset: (input) => call("fan-control", "setPreset", { preset: input.preset }),
|
|
252
831
|
setDirection: (input) => call("fan-control", "setDirection", { direction: input.direction }),
|
|
253
832
|
setOscillating: (input) => call("fan-control", "setOscillating", { oscillating: input.oscillating })
|
|
254
833
|
});
|
|
255
834
|
});
|
|
256
|
-
this.ensureExtra(
|
|
257
|
-
this.ctx.registerNativeCap(
|
|
835
|
+
this.ensureExtra(require_rename_composition_block.coverCapability.name, caps.includes(require_rename_composition_block.coverCapability.name), () => {
|
|
836
|
+
this.ctx.registerNativeCap(require_rename_composition_block.coverCapability, {
|
|
258
837
|
open: () => call("cover", "open", {}),
|
|
259
838
|
close: () => call("cover", "close", {}),
|
|
260
839
|
stop: () => call("cover", "stop", {}),
|
|
@@ -262,21 +841,21 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
262
841
|
setTiltPosition: (input) => call("cover", "setTiltPosition", { tiltPosition: input.tiltPosition })
|
|
263
842
|
});
|
|
264
843
|
});
|
|
265
|
-
const positionable = modes.includes(
|
|
844
|
+
const positionable = modes.includes(require_device_type.DeviceFeature.ValvePositionable);
|
|
266
845
|
if (positionable !== this.valvePositionable) {
|
|
267
|
-
this.ensureExtra(
|
|
846
|
+
this.ensureExtra(require_rename_composition_block.valveCapability.name, false, () => {});
|
|
268
847
|
this.valvePositionable = positionable;
|
|
269
848
|
}
|
|
270
|
-
this.ensureExtra(
|
|
271
|
-
this.ctx.registerNativeCap(
|
|
849
|
+
this.ensureExtra(require_rename_composition_block.valveCapability.name, caps.includes(require_rename_composition_block.valveCapability.name), () => {
|
|
850
|
+
this.ctx.registerNativeCap(require_rename_composition_block.valveCapability, {
|
|
272
851
|
open: () => call("valve", "open", {}),
|
|
273
852
|
close: () => call("valve", "close", {}),
|
|
274
853
|
stop: () => call("valve", "stop", {}),
|
|
275
854
|
...positionable ? { setPosition: (input) => call("valve", "setPosition", { position: input.position }) } : {}
|
|
276
855
|
});
|
|
277
856
|
});
|
|
278
|
-
this.ensureExtra(
|
|
279
|
-
this.ctx.registerNativeCap(
|
|
857
|
+
this.ensureExtra(require_rename_composition_block.lockControlCapability.name, caps.includes(require_rename_composition_block.lockControlCapability.name), () => {
|
|
858
|
+
this.ctx.registerNativeCap(require_rename_composition_block.lockControlCapability, {
|
|
280
859
|
lock: (input) => call("lock-control", "lock", { code: input.code }),
|
|
281
860
|
unlock: (input) => call("lock-control", "unlock", {
|
|
282
861
|
code: input.code,
|
|
@@ -285,8 +864,8 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
285
864
|
open: () => call("lock-control", "open", {})
|
|
286
865
|
});
|
|
287
866
|
});
|
|
288
|
-
this.ensureExtra(
|
|
289
|
-
this.ctx.registerNativeCap(
|
|
867
|
+
this.ensureExtra(require_core_blocks_cap.mediaPlayerCapability.name, caps.includes(require_core_blocks_cap.mediaPlayerCapability.name), () => {
|
|
868
|
+
this.ctx.registerNativeCap(require_core_blocks_cap.mediaPlayerCapability, {
|
|
290
869
|
play: () => call("media-player", "play", {}),
|
|
291
870
|
pause: () => call("media-player", "pause", {}),
|
|
292
871
|
setVolume: (input) => call("media-player", "setVolume", { volumeLevel: input.volumeLevel }),
|
|
@@ -310,8 +889,8 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
310
889
|
})
|
|
311
890
|
});
|
|
312
891
|
});
|
|
313
|
-
this.ensureExtra(
|
|
314
|
-
this.ctx.registerNativeCap(
|
|
892
|
+
this.ensureExtra(require_rename_composition_block.climateControlCapability.name, caps.includes(require_rename_composition_block.climateControlCapability.name), () => {
|
|
893
|
+
this.ctx.registerNativeCap(require_rename_composition_block.climateControlCapability, {
|
|
315
894
|
setMode: (input) => call("climate-control", "setMode", { mode: input.mode }),
|
|
316
895
|
setTarget: (input) => call("climate-control", "setTarget", { target: input.target }),
|
|
317
896
|
setFanMode: (input) => call("climate-control", "setFanMode", { fanMode: input.fanMode }),
|
|
@@ -328,15 +907,15 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
328
907
|
}
|
|
329
908
|
/** Keep each member's latest attempt. A later command replaces that member only. */
|
|
330
909
|
recordCommands(incoming) {
|
|
331
|
-
const prior = priorResults(this.runtimeState.getCapState(
|
|
910
|
+
const prior = priorResults(this.runtimeState.getCapState(require_rename_composition_block.groupCommandsCapability.name));
|
|
332
911
|
const byDevice = new Map(prior.map((row) => [row.deviceId, row]));
|
|
333
912
|
for (const row of incoming) byDevice.set(row.deviceId, row);
|
|
334
913
|
try {
|
|
335
|
-
this.runtimeState.setCapState(
|
|
914
|
+
this.runtimeState.setCapState(require_rename_composition_block.groupCommandsCapability.name, { results: [...byDevice.values()] });
|
|
336
915
|
} catch (err) {
|
|
337
916
|
this.ctx.logger.error("actuator group could not store command results", {
|
|
338
917
|
tags: { deviceId: this.id },
|
|
339
|
-
meta: { error:
|
|
918
|
+
meta: { error: require_scoped_settings.errMsg(err) }
|
|
340
919
|
});
|
|
341
920
|
}
|
|
342
921
|
}
|
|
@@ -379,7 +958,7 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
379
958
|
}
|
|
380
959
|
writeSlice(op, capName, slice) {
|
|
381
960
|
const own = this.writeCap(op, capName, this.derivesWater ? this.withWater(capName, slice) : slice);
|
|
382
|
-
if (!own.ok || !this.derivesWater || capName !==
|
|
961
|
+
if (!own.ok || !this.derivesWater || capName !== require_rename_composition_block.petFountainCapability.name) return own;
|
|
383
962
|
return this.refreshWater();
|
|
384
963
|
}
|
|
385
964
|
writeCap(op, capName, slice) {
|
|
@@ -390,7 +969,7 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
390
969
|
} catch (err) {
|
|
391
970
|
return {
|
|
392
971
|
ok: false,
|
|
393
|
-
error:
|
|
972
|
+
error: require_scoped_settings.errMsg(err)
|
|
394
973
|
};
|
|
395
974
|
}
|
|
396
975
|
}
|
|
@@ -400,8 +979,8 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
400
979
|
* (`petFountainWaterItem`). A composition that names its own `water` item keeps it.
|
|
401
980
|
*/
|
|
402
981
|
withWater(capName, slice) {
|
|
403
|
-
if (capName !==
|
|
404
|
-
const parsed =
|
|
982
|
+
if (capName !== require_rename_composition_block.consumablesCapability.name) return slice;
|
|
983
|
+
const parsed = require_rename_composition_block.ConsumableItemSchema.array().safeParse(slice["items"]);
|
|
405
984
|
if (parsed.success) this.composedItems = parsed.data;
|
|
406
985
|
return {
|
|
407
986
|
...slice,
|
|
@@ -409,22 +988,22 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
409
988
|
};
|
|
410
989
|
}
|
|
411
990
|
fountainTank() {
|
|
412
|
-
const tank = TANK_READING.safeParse(this.runtimeState.getCapState(
|
|
991
|
+
const tank = TANK_READING.safeParse(this.runtimeState.getCapState(require_rename_composition_block.petFountainCapability.name));
|
|
413
992
|
return tank.success ? tank.data : null;
|
|
414
993
|
}
|
|
415
994
|
itemsWithWater() {
|
|
416
995
|
const tank = this.fountainTank();
|
|
417
996
|
if (tank === null || this.composedItems.some((item) => item.key === "water")) return this.composedItems;
|
|
418
|
-
return [...this.composedItems,
|
|
997
|
+
return [...this.composedItems, require_rename_composition_block.petFountainWaterItem(tank)];
|
|
419
998
|
}
|
|
420
999
|
/** The fountain slice moved: re-publish the consumables with the new water item. */
|
|
421
1000
|
refreshWater() {
|
|
422
1001
|
const tank = this.fountainTank();
|
|
423
1002
|
if (tank === null) return { ok: true };
|
|
424
|
-
const known = this.runtimeState.getCapState(
|
|
1003
|
+
const known = this.runtimeState.getCapState(require_rename_composition_block.consumablesCapability.name);
|
|
425
1004
|
const items = this.itemsWithWater();
|
|
426
1005
|
if (known !== void 0 && JSON.stringify(known["items"]) === JSON.stringify(items)) return { ok: true };
|
|
427
|
-
return this.writeCap(known === void 0 ? "seed" : "patch",
|
|
1006
|
+
return this.writeCap(known === void 0 ? "seed" : "patch", require_rename_composition_block.consumablesCapability.name, {
|
|
428
1007
|
items,
|
|
429
1008
|
lastChangedAt: tank.lastFetchedAt,
|
|
430
1009
|
lastFetchedAt: tank.lastFetchedAt
|
|
@@ -461,7 +1040,7 @@ function composedDeviceClass(type, caps) {
|
|
|
461
1040
|
*/
|
|
462
1041
|
var EngineHostedComposedDevice = class extends ComposedDevice {
|
|
463
1042
|
constructor(ctx) {
|
|
464
|
-
super(ctx,
|
|
1043
|
+
super(ctx, require_device_type.DeviceType.Camera, [], "external");
|
|
465
1044
|
}
|
|
466
1045
|
};
|
|
467
1046
|
var ComposedPlaceholderDevice = class extends ComposedDevice {
|
|
@@ -622,7 +1201,7 @@ async function adoptMathQuantities(blocks, ports) {
|
|
|
622
1201
|
...deviceId === null ? {} : { tags: { deviceId } },
|
|
623
1202
|
meta: {
|
|
624
1203
|
blockId: block.id,
|
|
625
|
-
error:
|
|
1204
|
+
error: require_scoped_settings.errMsg(err)
|
|
626
1205
|
}
|
|
627
1206
|
});
|
|
628
1207
|
}
|
|
@@ -684,7 +1263,7 @@ var ActuatorGroups = class {
|
|
|
684
1263
|
async remember(block) {
|
|
685
1264
|
const spec = block.helper;
|
|
686
1265
|
if (spec === void 0 || spec.kind !== "group") return null;
|
|
687
|
-
const template =
|
|
1266
|
+
const template = require_error_cap.groupTemplate(spec.templateId);
|
|
688
1267
|
if (template === null || template.family !== "actuator") return null;
|
|
689
1268
|
const templateId = actuatorTemplateId(template.id);
|
|
690
1269
|
if (templateId === null) return null;
|
|
@@ -695,7 +1274,7 @@ var ActuatorGroups = class {
|
|
|
695
1274
|
const shared = capsOf(methods);
|
|
696
1275
|
const previous = this.groups.get(block.id)?.shared;
|
|
697
1276
|
if (previous !== void 0) this.logCapChange(templateId, device.id, previous, shared, viewed);
|
|
698
|
-
const modes = templateId === "light" && shared.includes("color") ?
|
|
1277
|
+
const modes = templateId === "light" && shared.includes("color") ? require_error_cap.sharedColorModes(viewed.featureLists) : sharedActuatorFeatures(templateId, viewed.featureLists);
|
|
699
1278
|
device.syncShared(shared, modes);
|
|
700
1279
|
return {
|
|
701
1280
|
blockId: block.id,
|
|
@@ -754,8 +1333,8 @@ var ActuatorGroups = class {
|
|
|
754
1333
|
};
|
|
755
1334
|
}
|
|
756
1335
|
logCapChange(templateId, groupDeviceId, previous, shared, viewed) {
|
|
757
|
-
const primary =
|
|
758
|
-
const optional = [...new Set(
|
|
1336
|
+
const primary = ACTUATOR_METHODS[templateId][0]?.cap;
|
|
1337
|
+
const optional = [...new Set(ACTUATOR_METHODS[templateId].map((row) => row.cap).filter((cap) => cap !== primary))];
|
|
759
1338
|
for (const cap of optional) {
|
|
760
1339
|
const had = previous.includes(cap);
|
|
761
1340
|
const has = shared.includes(cap);
|
|
@@ -818,7 +1397,7 @@ var ActuatorGroups = class {
|
|
|
818
1397
|
});
|
|
819
1398
|
throw new Error(`group does not share ${input.cap}.${input.method}`);
|
|
820
1399
|
}
|
|
821
|
-
const refusal =
|
|
1400
|
+
const refusal = methodRefusal(row, input.args);
|
|
822
1401
|
if (refusal !== null) {
|
|
823
1402
|
this.deps.logger.warn(`${input.cap}.${input.method} was refused — nothing was sent`, {
|
|
824
1403
|
tags: { deviceId: input.groupDeviceId },
|
|
@@ -830,7 +1409,7 @@ var ActuatorGroups = class {
|
|
|
830
1409
|
});
|
|
831
1410
|
throw new Error(refusal);
|
|
832
1411
|
}
|
|
833
|
-
const results = await
|
|
1412
|
+
const results = await require_error_cap.runFanOut(require_error_cap.fanOutTargets(group.fanOut, input.cap, input.method, memberArgs(input.args)), (call) => this.deps.invoke(call));
|
|
834
1413
|
const failed = results.flatMap((result) => result.ok ? [] : [result]);
|
|
835
1414
|
for (const result of failed) this.deps.logger.warn("actuator group command failed on a member — the others were still attempted", {
|
|
836
1415
|
tags: { deviceId: result.deviceId },
|
|
@@ -861,18 +1440,18 @@ var ActuatorGroups = class {
|
|
|
861
1440
|
}
|
|
862
1441
|
};
|
|
863
1442
|
function actuatorTemplateId(id) {
|
|
864
|
-
return
|
|
1443
|
+
return ACTUATOR_TEMPLATE_IDS.find((item) => item === id) ?? null;
|
|
865
1444
|
}
|
|
866
1445
|
/**
|
|
867
1446
|
* Members that could not all be read leave only the type's own, ungated
|
|
868
1447
|
* methods on: a surface nobody confirmed is never offered.
|
|
869
1448
|
*/
|
|
870
1449
|
function methodsOf(templateId, viewed) {
|
|
871
|
-
const rows =
|
|
1450
|
+
const rows = ACTUATOR_METHODS[templateId];
|
|
872
1451
|
const primary = rows[0]?.cap;
|
|
873
1452
|
const own = rows.filter((row) => row.cap === primary && row.requires === null);
|
|
874
1453
|
if (viewed.capLists === null || viewed.capLists.length === 0) return own;
|
|
875
|
-
return
|
|
1454
|
+
return sharedActuatorMethods(templateId, viewed.capLists.map((caps, index) => ({
|
|
876
1455
|
caps,
|
|
877
1456
|
features: viewed.featureLists[index] ?? []
|
|
878
1457
|
})));
|
|
@@ -958,11 +1537,11 @@ var ComposedDeviceSet = class {
|
|
|
958
1537
|
});
|
|
959
1538
|
if (p.spec !== null) await this.deps.devices.applyDerivedSpec(device.id, p.spec);
|
|
960
1539
|
await this.deps.devices.decommission(device.id);
|
|
961
|
-
const stableId =
|
|
1540
|
+
const stableId = require_error_cap.composedDeviceStableId(p.block.id);
|
|
962
1541
|
this.devices = new Map([...this.devices].filter(([s]) => s !== stableId));
|
|
963
1542
|
this.declaredFingerprint = null;
|
|
964
1543
|
} catch (err) {
|
|
965
|
-
const error =
|
|
1544
|
+
const error = require_scoped_settings.errMsg(err);
|
|
966
1545
|
errors.set(p.block.id, error);
|
|
967
1546
|
this.deps.logger.warn("rebuilding a composed device failed — the old one is kept", {
|
|
968
1547
|
tags: { deviceId: device.id },
|
|
@@ -987,7 +1566,7 @@ var ComposedDeviceSet = class {
|
|
|
987
1566
|
this.declaredFingerprint = fingerprint;
|
|
988
1567
|
} catch (err) {
|
|
989
1568
|
this.deps.logger.warn("composer: the device declaration failed — keeping the devices already live", { meta: {
|
|
990
|
-
error:
|
|
1569
|
+
error: require_scoped_settings.errMsg(err),
|
|
991
1570
|
declarations: declarations.length
|
|
992
1571
|
} });
|
|
993
1572
|
}
|
|
@@ -1050,7 +1629,7 @@ function isRecord$2(value) {
|
|
|
1050
1629
|
/** The template with every `$input` replaced; an undefined replacement drops its key. */
|
|
1051
1630
|
function substitute(arg, input) {
|
|
1052
1631
|
if (typeof arg !== "object") return arg;
|
|
1053
|
-
if (
|
|
1632
|
+
if (require_error_cap.isForwardInputRef(arg)) return input[arg.$input];
|
|
1054
1633
|
return Object.fromEntries(Object.entries(arg).map(([key, value]) => [key, substitute(value, input)]).filter(([, value]) => value !== void 0));
|
|
1055
1634
|
}
|
|
1056
1635
|
/** The arguments a forward sends: the template, or the caller's input minus the device id. */
|
|
@@ -1076,7 +1655,7 @@ var ForwardCommands = class {
|
|
|
1076
1655
|
const extensions = /* @__PURE__ */ new Set();
|
|
1077
1656
|
for (const feature of block.features) {
|
|
1078
1657
|
for (const [method, target] of Object.entries(feature.commands ?? {})) if (target.kind === "extension") extensions.add(methodKey(feature.cap, method));
|
|
1079
|
-
for (const forward of
|
|
1658
|
+
for (const forward of require_core_blocks_cap.featureForwards(feature, 0)) {
|
|
1080
1659
|
if (forward.itemKey === void 0) {
|
|
1081
1660
|
byMethod.set(methodKey(feature.cap, forward.method), forward.command);
|
|
1082
1661
|
continue;
|
|
@@ -1121,13 +1700,13 @@ var ForwardCommands = class {
|
|
|
1121
1700
|
});
|
|
1122
1701
|
throw new ForwardRefusedError("no-command", `${input.cap}.${input.method}`, "the composition gives this method no command");
|
|
1123
1702
|
}
|
|
1124
|
-
const source =
|
|
1703
|
+
const source = require_error_cap.compositionSourceKey(command.source);
|
|
1125
1704
|
const sent = forwardArguments(command, this.callerInput(input));
|
|
1126
1705
|
const resolved = await this.resolveOrRefuse(input, command, source);
|
|
1127
1706
|
try {
|
|
1128
1707
|
await this.deps.callCapMethod(resolved, command.cap, command.method, sent);
|
|
1129
1708
|
} catch (err) {
|
|
1130
|
-
this.refuse(input, "source-call-failed", source,
|
|
1709
|
+
this.refuse(input, "source-call-failed", source, require_scoped_settings.errMsg(err), resolved);
|
|
1131
1710
|
}
|
|
1132
1711
|
}
|
|
1133
1712
|
/** A reset carries the item key, which selects the command and is not an argument. */
|
|
@@ -1147,7 +1726,7 @@ var ForwardCommands = class {
|
|
|
1147
1726
|
try {
|
|
1148
1727
|
resolution = await this.deps.resolve(command.source);
|
|
1149
1728
|
} catch (err) {
|
|
1150
|
-
return this.refuse(input, "source-unknown", source,
|
|
1729
|
+
return this.refuse(input, "source-unknown", source, require_scoped_settings.errMsg(err));
|
|
1151
1730
|
}
|
|
1152
1731
|
if (resolution.kind === "found") return resolution.deviceId;
|
|
1153
1732
|
if (resolution.kind === "missing") return this.refuse(input, "source-gone", source, resolution.reason);
|
|
@@ -1294,7 +1873,7 @@ function ungraftGoneTarget(input) {
|
|
|
1294
1873
|
tags: { deviceId },
|
|
1295
1874
|
meta: {
|
|
1296
1875
|
blockId: input.blockId,
|
|
1297
|
-
target:
|
|
1876
|
+
target: require_error_cap.compositionSourceKey(input.ref),
|
|
1298
1877
|
ungrafted: added,
|
|
1299
1878
|
graftHost: grafts !== void 0
|
|
1300
1879
|
}
|
|
@@ -1319,7 +1898,7 @@ var TargetDescriptions = class {
|
|
|
1319
1898
|
* null when there is none: the caller waits, and claims nothing.
|
|
1320
1899
|
*/
|
|
1321
1900
|
async describe(ref, deviceId, type, force) {
|
|
1322
|
-
const key =
|
|
1901
|
+
const key = require_error_cap.compositionSourceKey(ref);
|
|
1323
1902
|
const cached = this.cache.get(key);
|
|
1324
1903
|
const previous = cached !== void 0 && cached.deviceId === deviceId ? cached : null;
|
|
1325
1904
|
if (!force && previous !== null) return previous;
|
|
@@ -1357,8 +1936,8 @@ function addedCapsOf(features) {
|
|
|
1357
1936
|
return features.filter((f) => f.mode === "add").map((f) => f.cap);
|
|
1358
1937
|
}
|
|
1359
1938
|
function selfReadCaps(fields, target, features) {
|
|
1360
|
-
const targetKey =
|
|
1361
|
-
const read = new Set(fields.flatMap((f) => f.reads.filter((r) =>
|
|
1939
|
+
const targetKey = require_error_cap.compositionSourceKey(target);
|
|
1940
|
+
const read = new Set(fields.flatMap((f) => f.reads.filter((r) => require_error_cap.compositionSourceKey(r.source) === targetKey).map((r) => r.cap)));
|
|
1362
1941
|
const added = new Set(addedCapsOf(features));
|
|
1363
1942
|
return {
|
|
1364
1943
|
effective: [...read].filter((cap) => added.has(cap)),
|
|
@@ -1368,14 +1947,14 @@ function selfReadCaps(fields, target, features) {
|
|
|
1368
1947
|
/** The `degraded` reason (rule 8): one entry per released field, the source's own reason after the dash. */
|
|
1369
1948
|
function degradedReason(released) {
|
|
1370
1949
|
return released.map((r) => {
|
|
1371
|
-
const path = r.item === void 0 ? r.path :
|
|
1950
|
+
const path = r.item === void 0 ? r.path : require_error_cap.compositionItemFieldPath(r.item.arrayPath, r.item.key, r.path);
|
|
1372
1951
|
return `released to the native provider: ${r.cap}.${path} — ${r.reason}`;
|
|
1373
1952
|
}).join("; ");
|
|
1374
1953
|
}
|
|
1375
1954
|
/** The `starting` reason of a block with HELD fields: each keeps its last value and claim until its source answers (D49). */
|
|
1376
1955
|
function heldReason(held) {
|
|
1377
1956
|
return held.map((r) => {
|
|
1378
|
-
const path = r.item === void 0 ? r.path :
|
|
1957
|
+
const path = r.item === void 0 ? r.path : require_error_cap.compositionItemFieldPath(r.item.arrayPath, r.item.key, r.path);
|
|
1379
1958
|
return `held on its last value until its source answers: ${r.cap}.${path} — ${r.reason}`;
|
|
1380
1959
|
}).join("; ");
|
|
1381
1960
|
}
|
|
@@ -1463,7 +2042,7 @@ var ComposerGrafts = class {
|
|
|
1463
2042
|
if (ports === void 0) return;
|
|
1464
2043
|
const { deviceId } = input;
|
|
1465
2044
|
const added = input.enabled && input.settled ? addedCapsOf(input.features) : [];
|
|
1466
|
-
const nativeNow = new Set([...input.nativeCaps.entries()].filter(([, owner]) => owner !==
|
|
2045
|
+
const nativeNow = new Set([...input.nativeCaps.entries()].filter(([, owner]) => owner !== require_error_cap.COMPOSER_ADDON_ID).map(([cap]) => cap));
|
|
1467
2046
|
const replaced = new Set(input.features.filter((f) => f.mode === "replace").map((f) => f.cap));
|
|
1468
2047
|
for (const cap of ports.grafted(deviceId)) {
|
|
1469
2048
|
if (!nativeNow.has(cap) && !replaced.has(cap)) continue;
|
|
@@ -1510,7 +2089,7 @@ var ComposerGrafts = class {
|
|
|
1510
2089
|
} catch (err) {
|
|
1511
2090
|
read = {
|
|
1512
2091
|
kind: "unreadable",
|
|
1513
|
-
error:
|
|
2092
|
+
error: require_scoped_settings.errMsg(err)
|
|
1514
2093
|
};
|
|
1515
2094
|
}
|
|
1516
2095
|
if (read.kind === "unreadable") {
|
|
@@ -1587,10 +2166,10 @@ var RELEASE_SETTLED_CODES = new Set([
|
|
|
1587
2166
|
* twice).
|
|
1588
2167
|
*/
|
|
1589
2168
|
function operatorResetKeys(p) {
|
|
1590
|
-
const targetKey = p.target.kind === "existing" ?
|
|
2169
|
+
const targetKey = p.target.kind === "existing" ? require_error_cap.compositionSourceKey(p.target.ref) : null;
|
|
1591
2170
|
const keys = [];
|
|
1592
2171
|
for (const f of p.fields) for (const r of f.reads) {
|
|
1593
|
-
const key =
|
|
2172
|
+
const key = require_error_cap.compositionSourceKey(r.source);
|
|
1594
2173
|
if (key !== targetKey) keys.push(key);
|
|
1595
2174
|
}
|
|
1596
2175
|
return keys;
|
|
@@ -1603,7 +2182,7 @@ function trackedSourceRequests(live) {
|
|
|
1603
2182
|
const running = e.runtime !== null && e.planned.block.enabled;
|
|
1604
2183
|
let targetKey = null;
|
|
1605
2184
|
if (target.kind === "existing") {
|
|
1606
|
-
targetKey =
|
|
2185
|
+
targetKey = require_error_cap.compositionSourceKey(target.ref);
|
|
1607
2186
|
const self = running ? selfReadCaps(e.planned.fields, target.ref, target.features) : null;
|
|
1608
2187
|
requests.push({
|
|
1609
2188
|
ref: target.ref,
|
|
@@ -1613,7 +2192,7 @@ function trackedSourceRequests(live) {
|
|
|
1613
2192
|
});
|
|
1614
2193
|
}
|
|
1615
2194
|
if (!running) continue;
|
|
1616
|
-
for (const f of e.planned.fields) for (const r of f.reads) if (
|
|
2195
|
+
for (const f of e.planned.fields) for (const r of f.reads) if (require_error_cap.compositionSourceKey(r.source) !== targetKey) requests.push({
|
|
1617
2196
|
ref: r.source,
|
|
1618
2197
|
caps: [r.cap]
|
|
1619
2198
|
});
|
|
@@ -1698,7 +2277,7 @@ function planStillWantsClaim(planned, key) {
|
|
|
1698
2277
|
*/
|
|
1699
2278
|
function declarationFor(input) {
|
|
1700
2279
|
return {
|
|
1701
|
-
stableId:
|
|
2280
|
+
stableId: require_error_cap.composedDeviceStableId(input.blockId),
|
|
1702
2281
|
name: input.name,
|
|
1703
2282
|
type: input.target.type,
|
|
1704
2283
|
DeviceClass: input.hosted ? EngineHostedComposedDevice : composedDeviceClass(input.target.type, input.caps),
|
|
@@ -1724,7 +2303,7 @@ function placeholderDeclaration(stableId) {
|
|
|
1724
2303
|
return {
|
|
1725
2304
|
stableId,
|
|
1726
2305
|
name: stableId,
|
|
1727
|
-
type:
|
|
2306
|
+
type: require_device_type.DeviceType.Generic,
|
|
1728
2307
|
DeviceClass: ComposedPlaceholderDevice
|
|
1729
2308
|
};
|
|
1730
2309
|
}
|
|
@@ -1829,7 +2408,7 @@ var NO_PLAN = {
|
|
|
1829
2408
|
* it (D49).
|
|
1830
2409
|
*/
|
|
1831
2410
|
function planUnreadable(block, rows) {
|
|
1832
|
-
const stableId =
|
|
2411
|
+
const stableId = require_error_cap.composedDeviceStableId(block.id);
|
|
1833
2412
|
const hasRow = rows.has(stableId);
|
|
1834
2413
|
return {
|
|
1835
2414
|
...NO_PLAN,
|
|
@@ -1847,11 +2426,11 @@ function planUnreadable(block, rows) {
|
|
|
1847
2426
|
}
|
|
1848
2427
|
/** `target` is the block's own `new` target, narrowed by the caller: this path never sees an existing one (M-5). */
|
|
1849
2428
|
function planNew(block, target, lookupCap, rows) {
|
|
1850
|
-
const composition =
|
|
1851
|
-
const plan =
|
|
2429
|
+
const composition = withDefaultRunning(block.composition, block.id);
|
|
2430
|
+
const plan = require_core_blocks_cap.planComposition(composition, lookupCap);
|
|
1852
2431
|
const planned = { kind: "new" };
|
|
1853
2432
|
if (plan.problems.length > 0) {
|
|
1854
|
-
const stableId =
|
|
2433
|
+
const stableId = require_error_cap.composedDeviceStableId(block.id);
|
|
1855
2434
|
const hasRow = rows.has(stableId);
|
|
1856
2435
|
return {
|
|
1857
2436
|
...NO_PLAN,
|
|
@@ -1863,11 +2442,11 @@ function planNew(block, target, lookupCap, rows) {
|
|
|
1863
2442
|
};
|
|
1864
2443
|
}
|
|
1865
2444
|
const caps = composition.features.flatMap((f) => {
|
|
1866
|
-
if (!
|
|
2445
|
+
if (!require_error_cap.compositionFeatureEnabled(f)) return [];
|
|
1867
2446
|
const def = lookupCap(f.cap);
|
|
1868
2447
|
return def === null ? [] : [def];
|
|
1869
2448
|
});
|
|
1870
|
-
const hosted = composition.helper !== void 0 &&
|
|
2449
|
+
const hosted = composition.helper !== void 0 && require_error_cap.isEngineHostedHelper(composition.helper);
|
|
1871
2450
|
const declarationInput = {
|
|
1872
2451
|
blockId: block.id,
|
|
1873
2452
|
name: block.name,
|
|
@@ -1897,7 +2476,7 @@ async function planExisting(input) {
|
|
|
1897
2476
|
block
|
|
1898
2477
|
};
|
|
1899
2478
|
const ref = input.target.device;
|
|
1900
|
-
const key =
|
|
2479
|
+
const key = require_error_cap.compositionSourceKey(ref);
|
|
1901
2480
|
const knownId = prior?.kind === "existing" ? prior.deviceId : null;
|
|
1902
2481
|
if (input.claimsWait !== null) return waitingPlan(block, ref, knownId, input.claimsWait);
|
|
1903
2482
|
const resolution = await input.tracker.resolve(ref, operatorAction);
|
|
@@ -1921,7 +2500,7 @@ async function planExisting(input) {
|
|
|
1921
2500
|
};
|
|
1922
2501
|
const description = await input.targets.describe(ref, resolution.deviceId, resolution.type, operatorAction || prior?.kind === "existing" && prior.waiting !== null);
|
|
1923
2502
|
if (description === null) return waitingPlan(block, ref, resolution.deviceId, `the target device \`${key}\` could not be described (its bindings did not read) — nothing is claimed until it is; retried on the next apply`);
|
|
1924
|
-
const plan =
|
|
2503
|
+
const plan = require_core_blocks_cap.planComposition(block.composition, input.lookupCap, description);
|
|
1925
2504
|
const pending = unboundNativeCaps(block.composition, input.lookupCap, description, plan);
|
|
1926
2505
|
if (pending.length > 0) return waitingPlan(block, ref, resolution.deviceId, `the target device \`${key}\` has not bound ${pending.map((cap) => `\`${cap}\``).join(", ")} yet — its provider has not registered it; re-evaluated when its bindings change`);
|
|
1927
2506
|
return {
|
|
@@ -1951,10 +2530,10 @@ function unboundNativeCaps(composition, lookupCap, description, plan) {
|
|
|
1951
2530
|
if (plan.problems.length === 0) return [];
|
|
1952
2531
|
const unbound = [...new Set(composition.features.flatMap((feature) => {
|
|
1953
2532
|
const def = lookupCap(feature.cap);
|
|
1954
|
-
return
|
|
2533
|
+
return require_error_cap.compositionFeatureEnabled(feature) && def !== null && require_core_blocks_cap.commandedMethods(def).length > 0 && !description.nativeCaps.has(feature.cap) ? [feature.cap] : [];
|
|
1955
2534
|
}))];
|
|
1956
2535
|
if (unbound.length === 0) return [];
|
|
1957
|
-
return
|
|
2536
|
+
return require_core_blocks_cap.planComposition(composition, lookupCap, {
|
|
1958
2537
|
...description,
|
|
1959
2538
|
nativeCaps: new Map([...description.nativeCaps, ...unbound.map((cap) => [cap, PRESUMED_NATIVE_OWNER])])
|
|
1960
2539
|
}).problems.length === 0 ? unbound : [];
|
|
@@ -2034,7 +2613,7 @@ function logPlanTransition(logger, previous, p, liveTags) {
|
|
|
2034
2613
|
...extras,
|
|
2035
2614
|
meta: {
|
|
2036
2615
|
...extras.meta,
|
|
2037
|
-
target:
|
|
2616
|
+
target: require_error_cap.compositionSourceKey(target.ref)
|
|
2038
2617
|
}
|
|
2039
2618
|
});
|
|
2040
2619
|
else if (target.kind === "existing" && target.waiting !== null) logger.warn("customization waits — nothing is claimed or released until it plans", {
|
|
@@ -2065,7 +2644,7 @@ function logPlanTransition(logger, previous, p, liveTags) {
|
|
|
2065
2644
|
*/
|
|
2066
2645
|
var NO_FIELDS = /* @__PURE__ */ new Set();
|
|
2067
2646
|
function fieldKey(plan) {
|
|
2068
|
-
return
|
|
2647
|
+
return require_core_blocks_cap.compositionFieldKey(plan);
|
|
2069
2648
|
}
|
|
2070
2649
|
function isRecord$1(value) {
|
|
2071
2650
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -2092,7 +2671,7 @@ function createFieldRecord(plan, byCap, lookupCap) {
|
|
|
2092
2671
|
initial,
|
|
2093
2672
|
hasWritten: false,
|
|
2094
2673
|
written: void 0,
|
|
2095
|
-
expressionMemory:
|
|
2674
|
+
expressionMemory: require_error_cap.createStatefulExpressionMemory(),
|
|
2096
2675
|
eventHighWater: typeof initial === "number" && Number.isFinite(initial) ? initial : null,
|
|
2097
2676
|
pulseHold: false
|
|
2098
2677
|
};
|
|
@@ -2129,7 +2708,7 @@ function topLevelField(plan) {
|
|
|
2129
2708
|
}
|
|
2130
2709
|
/** The field as a report or a log line names it: `items[desiccant].status` for an item leaf. */
|
|
2131
2710
|
function fieldPath(plan) {
|
|
2132
|
-
return plan.item === void 0 ? plan.path :
|
|
2711
|
+
return plan.item === void 0 ? plan.path : require_error_cap.compositionItemFieldPath(plan.item.arrayPath, plan.item.key, plan.path);
|
|
2133
2712
|
}
|
|
2134
2713
|
function itemOf(plan) {
|
|
2135
2714
|
return plan.item === void 0 ? {} : { item: plan.item };
|
|
@@ -2282,7 +2861,7 @@ function isExpressionValue(value) {
|
|
|
2282
2861
|
/** Whether the field's output is LATCHED by `rose`: it is the last edge, not a reading of now. */
|
|
2283
2862
|
function isEdgeLatch(record) {
|
|
2284
2863
|
const source = record.plan.source;
|
|
2285
|
-
return source.kind === "expression" &&
|
|
2864
|
+
return source.kind === "expression" && require_core_blocks_cap.expressionContainsBuiltinCall(source.expr, "rose");
|
|
2286
2865
|
}
|
|
2287
2866
|
/**
|
|
2288
2867
|
* D713: an edge-latched field keeps its last known value when a source stops
|
|
@@ -2360,9 +2939,9 @@ function evaluateFields(host, keys, now, timerDriven = false) {
|
|
|
2360
2939
|
const record = next.get(key);
|
|
2361
2940
|
if (record === void 0) continue;
|
|
2362
2941
|
if (record.plan.source.kind === "series") continue;
|
|
2363
|
-
const candidateMemory =
|
|
2364
|
-
if (wasDown(record.outcome))
|
|
2365
|
-
const evaluatedOutcome =
|
|
2942
|
+
const candidateMemory = require_error_cap.cloneStatefulExpressionMemory(record.expressionMemory);
|
|
2943
|
+
if (wasDown(record.outcome)) require_error_cap.disarmRoseMemory(candidateMemory);
|
|
2944
|
+
const evaluatedOutcome = evaluateCompositionField({
|
|
2366
2945
|
source: record.plan.source,
|
|
2367
2946
|
read,
|
|
2368
2947
|
now,
|
|
@@ -2420,8 +2999,8 @@ function emitStateDerivedEvent(ctx, plan, timestamp) {
|
|
|
2420
2999
|
}
|
|
2421
3000
|
};
|
|
2422
3001
|
try {
|
|
2423
|
-
if (plan.category !==
|
|
2424
|
-
const event =
|
|
3002
|
+
if (plan.category !== require_base_addon.EventCategory.DoorbellOnPressed) throw new Error(`unsupported state-derived event category \`${plan.category}\``);
|
|
3003
|
+
const event = require_base_addon.createEvent(require_base_addon.EventCategory.DoorbellOnPressed, {
|
|
2425
3004
|
type: "device",
|
|
2426
3005
|
id: ctx.deviceId,
|
|
2427
3006
|
deviceId: ctx.deviceId
|
|
@@ -2478,7 +3057,7 @@ function setPath(record, segments, value) {
|
|
|
2478
3057
|
}
|
|
2479
3058
|
function itemArrayOf(group, lookupCap) {
|
|
2480
3059
|
const itemArray = lookupCap(group.cap)?.status?.itemArray;
|
|
2481
|
-
if (itemArray === void 0 || itemArray.path !== group.arrayPath) throw new Error(`\`${group.cap}\` has no item array at \`${group.arrayPath}\` — \`${
|
|
3060
|
+
if (itemArray === void 0 || itemArray.path !== group.arrayPath) throw new Error(`\`${group.cap}\` has no item array at \`${group.arrayPath}\` — \`${require_error_cap.compositionItemFieldPath(group.arrayPath, group.key, "*")}\` cannot be assembled`);
|
|
2482
3061
|
return itemArray;
|
|
2483
3062
|
}
|
|
2484
3063
|
function assembleItem(group, lookupCap) {
|
|
@@ -2487,7 +3066,7 @@ function assembleItem(group, lookupCap) {
|
|
|
2487
3066
|
...itemArray.emptyItem,
|
|
2488
3067
|
[itemArray.keyField]: group.key,
|
|
2489
3068
|
...itemArray.labelField === void 0 ? {} : { [itemArray.labelField]: group.label },
|
|
2490
|
-
...
|
|
3069
|
+
...require_core_blocks_cap.COMPOSED_ITEM_FIXED_FIELDS,
|
|
2491
3070
|
...group.resettable ? { resettable: true } : {}
|
|
2492
3071
|
};
|
|
2493
3072
|
return group.leaves.reduce((item, leaf) => setPath(item, leaf.plan.path.split("."), leaf.value), base);
|
|
@@ -2678,7 +3257,7 @@ var CompositionRuntime = class {
|
|
|
2678
3257
|
onSourcesChanged(sliceKeys) {
|
|
2679
3258
|
if (this.disabledReason !== null) return;
|
|
2680
3259
|
this.guarded("source", true, () => {
|
|
2681
|
-
const affected = [...this.records.values()].filter((r) => r.plan.reads.some((read) => ownKeyOf(this.evaluation, read) === null && sliceKeys.has(
|
|
3260
|
+
const affected = [...this.records.values()].filter((r) => r.plan.reads.some((read) => ownKeyOf(this.evaluation, read) === null && sliceKeys.has(require_error_cap.compositionSliceKey(read.source, read.cap)))).map((r) => fieldKey(r.plan));
|
|
2682
3261
|
if (affected.length > 0) this.pass(affected, "source");
|
|
2683
3262
|
});
|
|
2684
3263
|
}
|
|
@@ -3321,7 +3900,7 @@ var OwnedFieldsTarget = class {
|
|
|
3321
3900
|
meta: {
|
|
3322
3901
|
cap,
|
|
3323
3902
|
owner: this.deps.owner,
|
|
3324
|
-
error:
|
|
3903
|
+
error: require_scoped_settings.errMsg(err)
|
|
3325
3904
|
}
|
|
3326
3905
|
});
|
|
3327
3906
|
this.settled(cap);
|
|
@@ -3376,7 +3955,7 @@ var OwnedFieldsTarget = class {
|
|
|
3376
3955
|
if (claim) this.report(cap, "unsettled");
|
|
3377
3956
|
this.fail(cap, {
|
|
3378
3957
|
kind: "threw",
|
|
3379
|
-
error:
|
|
3958
|
+
error: require_scoped_settings.errMsg(err)
|
|
3380
3959
|
});
|
|
3381
3960
|
return;
|
|
3382
3961
|
}
|
|
@@ -3422,7 +4001,7 @@ var OwnedFieldsTarget = class {
|
|
|
3422
4001
|
} catch (err) {
|
|
3423
4002
|
this.fail(cap, {
|
|
3424
4003
|
kind: "threw",
|
|
3425
|
-
error:
|
|
4004
|
+
error: require_scoped_settings.errMsg(err)
|
|
3426
4005
|
});
|
|
3427
4006
|
return;
|
|
3428
4007
|
}
|
|
@@ -3512,9 +4091,9 @@ function writerFor(deps, p, device, onClaimEvent) {
|
|
|
3512
4091
|
}
|
|
3513
4092
|
function newCompositionRuntime(deps, p, target, seed, pulseSeeds) {
|
|
3514
4093
|
const self = p.target.kind === "existing" ? selfReadCaps(p.fields, p.target.ref, p.target.features) : null;
|
|
3515
|
-
const targetKey = p.target.kind === "existing" ?
|
|
4094
|
+
const targetKey = p.target.kind === "existing" ? require_error_cap.compositionSourceKey(p.target.ref) : null;
|
|
3516
4095
|
const nativeCaps = new Set(self?.native ?? []);
|
|
3517
|
-
const ownKey = targetKey ??
|
|
4096
|
+
const ownKey = targetKey ?? require_error_cap.compositionSourceKey(require_error_cap.composedDeviceRef(p.block.id));
|
|
3518
4097
|
return new CompositionRuntime({
|
|
3519
4098
|
blockId: p.block.id,
|
|
3520
4099
|
fields: p.fields,
|
|
@@ -3524,8 +4103,8 @@ function newCompositionRuntime(deps, p, target, seed, pulseSeeds) {
|
|
|
3524
4103
|
lookupCap: deps.lookupCap,
|
|
3525
4104
|
...seed === void 0 ? {} : { initialByCap: seed.byCap },
|
|
3526
4105
|
...pulseSeeds === void 0 ? {} : { pulseSeeds },
|
|
3527
|
-
read: (read) => deps.tracker.read(read,
|
|
3528
|
-
isOwnRead: (read) =>
|
|
4106
|
+
read: (read) => deps.tracker.read(read, require_error_cap.compositionSourceKey(read.source) === targetKey && nativeCaps.has(read.cap) ? "native" : "effective"),
|
|
4107
|
+
isOwnRead: (read) => require_error_cap.compositionSourceKey(read.source) === ownKey && !nativeCaps.has(read.cap),
|
|
3529
4108
|
now: deps.now,
|
|
3530
4109
|
timer: deps.newTimer(),
|
|
3531
4110
|
logger: deps.logger.child("runtime")
|
|
@@ -3601,7 +4180,7 @@ function composedRowSeed(deps) {
|
|
|
3601
4180
|
} catch (err) {
|
|
3602
4181
|
return {
|
|
3603
4182
|
kind: "unknown",
|
|
3604
|
-
error:
|
|
4183
|
+
error: require_scoped_settings.errMsg(err)
|
|
3605
4184
|
};
|
|
3606
4185
|
}
|
|
3607
4186
|
},
|
|
@@ -3631,7 +4210,7 @@ function claimIndexSeed(deps) {
|
|
|
3631
4210
|
} catch (err) {
|
|
3632
4211
|
return {
|
|
3633
4212
|
kind: "unknown",
|
|
3634
|
-
error:
|
|
4213
|
+
error: require_scoped_settings.errMsg(err)
|
|
3635
4214
|
};
|
|
3636
4215
|
}
|
|
3637
4216
|
},
|
|
@@ -3778,7 +4357,7 @@ var HistoryHelpers = class {
|
|
|
3778
4357
|
for (const block of this.ports.blocks()) {
|
|
3779
4358
|
if (block.helper.kind === "integral" || block.helper.window.kind !== "rolling") continue;
|
|
3780
4359
|
if (this.ports.sourceDeviceId(block.helper.source.source) !== deviceId) continue;
|
|
3781
|
-
const next = Math.max(now, (this.lastRun.get(block.blockId) ?? 0) +
|
|
4360
|
+
const next = Math.max(now, (this.lastRun.get(block.blockId) ?? 0) + require_error_cap.statisticCadenceMs(block.helper.window));
|
|
3782
4361
|
if (due === null || next < due) due = next;
|
|
3783
4362
|
}
|
|
3784
4363
|
if (due !== null) this.ports.timer.arm(due, () => void this.pass());
|
|
@@ -3812,23 +4391,23 @@ var HistoryHelpers = class {
|
|
|
3812
4391
|
try {
|
|
3813
4392
|
return await this.ports.retention();
|
|
3814
4393
|
} catch (err) {
|
|
3815
|
-
this.ports.logger.warn("history retention could not be read — the defaults stand", { meta: { error:
|
|
3816
|
-
return
|
|
4394
|
+
this.ports.logger.warn("history retention could not be read — the defaults stand", { meta: { error: require_scoped_settings.errMsg(err) } });
|
|
4395
|
+
return require_error_cap.DEFAULT_HISTORY_RETENTION;
|
|
3817
4396
|
}
|
|
3818
4397
|
}
|
|
3819
4398
|
async one(block, retention) {
|
|
3820
4399
|
const helper = block.helper;
|
|
3821
|
-
const kind =
|
|
4400
|
+
const kind = require_error_cap.declaredSeriesKind(helper.source);
|
|
3822
4401
|
if (kind === null || kind === "enum") {
|
|
3823
4402
|
this.note(block, `${helper.source.cap}.${helper.source.fieldPath} has no numeric history`);
|
|
3824
4403
|
return;
|
|
3825
4404
|
}
|
|
3826
|
-
const tierPlan = helper.kind === "integral" ?
|
|
4405
|
+
const tierPlan = helper.kind === "integral" ? require_error_cap.planResetTier(helper.reset, retention) : require_error_cap.planStatisticTier(helper.window, retention);
|
|
3827
4406
|
if (!tierPlan.ok) {
|
|
3828
4407
|
this.note(block, tierPlan.reason);
|
|
3829
4408
|
return;
|
|
3830
4409
|
}
|
|
3831
|
-
const range = helper.kind === "integral" ?
|
|
4410
|
+
const range = helper.kind === "integral" ? require_error_cap.openReset(helper.reset, this.ports.now(), this.ports.timeZone) : require_error_cap.openStatistic(helper.window, this.ports.now(), this.ports.timeZone);
|
|
3832
4411
|
if (range === null) {
|
|
3833
4412
|
this.note(block, `the hub timezone \`${this.ports.timeZone}\` is not a calendar`);
|
|
3834
4413
|
return;
|
|
@@ -3850,7 +4429,7 @@ var HistoryHelpers = class {
|
|
|
3850
4429
|
maxPoints: QUERY_MAX_POINTS
|
|
3851
4430
|
});
|
|
3852
4431
|
} catch (err) {
|
|
3853
|
-
this.note(block, `the history query failed — the last total is kept: ${
|
|
4432
|
+
this.note(block, `the history query failed — the last total is kept: ${require_scoped_settings.errMsg(err)}`);
|
|
3854
4433
|
return;
|
|
3855
4434
|
}
|
|
3856
4435
|
if (result.truncated || result.resolution !== tierPlan.tier) {
|
|
@@ -3885,7 +4464,7 @@ var HistoryHelpers = class {
|
|
|
3885
4464
|
meta: {
|
|
3886
4465
|
blockId: block.blockId,
|
|
3887
4466
|
sourceDeviceId,
|
|
3888
|
-
error:
|
|
4467
|
+
error: require_scoped_settings.errMsg(err)
|
|
3889
4468
|
}
|
|
3890
4469
|
});
|
|
3891
4470
|
return;
|
|
@@ -3898,7 +4477,7 @@ var HistoryHelpers = class {
|
|
|
3898
4477
|
tags: { deviceId: block.deviceId },
|
|
3899
4478
|
meta: {
|
|
3900
4479
|
blockId: block.blockId,
|
|
3901
|
-
error:
|
|
4480
|
+
error: require_scoped_settings.errMsg(err)
|
|
3902
4481
|
}
|
|
3903
4482
|
});
|
|
3904
4483
|
}
|
|
@@ -3918,31 +4497,31 @@ var HistoryHelpers = class {
|
|
|
3918
4497
|
}
|
|
3919
4498
|
const now = this.ports.now();
|
|
3920
4499
|
let at = now + cadenceFloor(this.ports.blocks());
|
|
3921
|
-
const midnight =
|
|
4500
|
+
const midnight = require_error_cap.nextLocalMidnight(now, this.ports.timeZone);
|
|
3922
4501
|
if (midnight !== null && midnight < at) at = midnight;
|
|
3923
4502
|
this.ports.timer.arm(Math.max(at, now), () => void this.pass());
|
|
3924
4503
|
}
|
|
3925
4504
|
};
|
|
3926
4505
|
function answerOf(helper, read) {
|
|
3927
4506
|
switch (helper.kind) {
|
|
3928
|
-
case "statistic": return
|
|
3929
|
-
case "derivative": return
|
|
3930
|
-
case "integral": return
|
|
4507
|
+
case "statistic": return require_error_cap.evaluateStatistic(helper.stat, read);
|
|
4508
|
+
case "derivative": return require_error_cap.evaluateDerivative(read, PER_MS[helper.per]);
|
|
4509
|
+
case "integral": return require_error_cap.integrateReading(read, helper.output === "energy" ? "energy-kwh" : "per-second");
|
|
3931
4510
|
}
|
|
3932
4511
|
}
|
|
3933
4512
|
var PER_MS = {
|
|
3934
4513
|
second: 1e3,
|
|
3935
|
-
minute:
|
|
3936
|
-
hour:
|
|
4514
|
+
minute: require_error_cap.MINUTE_MS,
|
|
4515
|
+
hour: require_error_cap.HOUR_MS
|
|
3937
4516
|
};
|
|
3938
4517
|
/** A rate of a temperature is not a temperature: only a statistic and a meter keep the unit. */
|
|
3939
4518
|
function inheritsSourceQuantity(helper) {
|
|
3940
4519
|
return helper.kind === "statistic" || helper.kind === "integral" && helper.output === "meter";
|
|
3941
4520
|
}
|
|
3942
4521
|
function cadenceFloor(blocks) {
|
|
3943
|
-
let ms =
|
|
4522
|
+
let ms = require_error_cap.HISTORY_SLOW_MS;
|
|
3944
4523
|
for (const block of blocks) {
|
|
3945
|
-
const cadence = block.helper.kind === "integral" ? block.helper.reset === "daily" ?
|
|
4524
|
+
const cadence = block.helper.kind === "integral" ? block.helper.reset === "daily" ? require_error_cap.HISTORY_FAST_MS : require_error_cap.HISTORY_SLOW_MS : require_error_cap.statisticCadenceMs(block.helper.window);
|
|
3946
4525
|
if (cadence < ms) ms = cadence;
|
|
3947
4526
|
}
|
|
3948
4527
|
return ms;
|
|
@@ -4009,7 +4588,7 @@ function toPoint(point, tier, to, timeZone) {
|
|
|
4009
4588
|
};
|
|
4010
4589
|
}
|
|
4011
4590
|
function bucketMs(tier, t, to, timeZone) {
|
|
4012
|
-
const end = tier === "1d" ?
|
|
4591
|
+
const end = tier === "1d" ? require_error_cap.nextLocalMidnight(t, timeZone) : t + (tier === "5m" ? 5 * require_error_cap.MINUTE_MS : require_error_cap.HOUR_MS);
|
|
4013
4592
|
if (end === null) return 0;
|
|
4014
4593
|
return Math.max(0, Math.min(end, to) - t);
|
|
4015
4594
|
}
|
|
@@ -4118,7 +4697,7 @@ async function resolvePulseSeeds(input) {
|
|
|
4118
4697
|
tags: { deviceId: input.deviceId },
|
|
4119
4698
|
meta: {
|
|
4120
4699
|
blockId: input.blockId,
|
|
4121
|
-
error:
|
|
4700
|
+
error: require_scoped_settings.errMsg(err)
|
|
4122
4701
|
}
|
|
4123
4702
|
});
|
|
4124
4703
|
return /* @__PURE__ */ new Map();
|
|
@@ -4138,7 +4717,7 @@ async function resolveNow(input) {
|
|
|
4138
4717
|
return seeds;
|
|
4139
4718
|
}
|
|
4140
4719
|
function isPulseTimestamp(field) {
|
|
4141
|
-
return field.source.kind === "expression" &&
|
|
4720
|
+
return field.source.kind === "expression" && require_core_blocks_cap.expressionContainsBuiltinCall(field.source.expr, "rose");
|
|
4142
4721
|
}
|
|
4143
4722
|
async function readClaims(input) {
|
|
4144
4723
|
try {
|
|
@@ -4157,7 +4736,7 @@ async function readClaims(input) {
|
|
|
4157
4736
|
tags: { deviceId: input.deviceId },
|
|
4158
4737
|
meta: {
|
|
4159
4738
|
blockId: input.blockId,
|
|
4160
|
-
error:
|
|
4739
|
+
error: require_scoped_settings.errMsg(err)
|
|
4161
4740
|
}
|
|
4162
4741
|
});
|
|
4163
4742
|
return null;
|
|
@@ -4215,7 +4794,7 @@ async function historyOf(input, deviceId, pair) {
|
|
|
4215
4794
|
sourceDeviceId: deviceId,
|
|
4216
4795
|
cap: pair.cap,
|
|
4217
4796
|
field: pair.activeField,
|
|
4218
|
-
error:
|
|
4797
|
+
error: require_scoped_settings.errMsg(err)
|
|
4219
4798
|
}
|
|
4220
4799
|
});
|
|
4221
4800
|
return { kind: "unread" };
|
|
@@ -4231,7 +4810,7 @@ async function levelOf(input, deviceId, pair) {
|
|
|
4231
4810
|
blockId: input.blockId,
|
|
4232
4811
|
sourceDeviceId: deviceId,
|
|
4233
4812
|
cap: pair.cap,
|
|
4234
|
-
error:
|
|
4813
|
+
error: require_scoped_settings.errMsg(err)
|
|
4235
4814
|
}
|
|
4236
4815
|
});
|
|
4237
4816
|
return { kind: "unread" };
|
|
@@ -4449,7 +5028,7 @@ function logDecision(input, field, decision) {
|
|
|
4449
5028
|
*/
|
|
4450
5029
|
/** The configured zone, else the process zone when usable, else `UTC` (an empty `TZ` reads `Etc/Unknown`). */
|
|
4451
5030
|
function resolveComposerTimeZone(configured, logger) {
|
|
4452
|
-
return configured ??
|
|
5031
|
+
return configured ?? processTimeZoneOr("UTC", logger);
|
|
4453
5032
|
}
|
|
4454
5033
|
var Composer = class {
|
|
4455
5034
|
deps;
|
|
@@ -4582,7 +5161,7 @@ var Composer = class {
|
|
|
4582
5161
|
this.dispatch(await this.deps.tracker.onBindingsChanged(data.deviceId, data.capName, data.reason));
|
|
4583
5162
|
await this.chained(() => this.actuators?.onMemberBindings(data.deviceId));
|
|
4584
5163
|
await this.chained(() => this.replanWaitingOn(data.deviceId));
|
|
4585
|
-
await this.syncBoundFeatures([...this.live.keys()].filter((blockId) => this.composed.idOf(
|
|
5164
|
+
await this.syncBoundFeatures([...this.live.keys()].filter((blockId) => this.composed.idOf(require_error_cap.composedDeviceStableId(blockId)) === data.deviceId));
|
|
4586
5165
|
}
|
|
4587
5166
|
/**
|
|
4588
5167
|
* A composed device carries the features its BOUND caps stand for — the same
|
|
@@ -4593,10 +5172,10 @@ var Composer = class {
|
|
|
4593
5172
|
const read = this.deps.boundCapNames;
|
|
4594
5173
|
if (read === void 0) return;
|
|
4595
5174
|
for (const blockId of blockIds) {
|
|
4596
|
-
const device = this.composed.get(
|
|
5175
|
+
const device = this.composed.get(require_error_cap.composedDeviceStableId(blockId));
|
|
4597
5176
|
if (device === null || device.syncBoundFeatures === void 0) continue;
|
|
4598
5177
|
const caps = await read(device.id);
|
|
4599
|
-
if (caps !== null) device.syncBoundFeatures(
|
|
5178
|
+
if (caps !== null) device.syncBoundFeatures(require_device_type.featuresOfBoundCaps(caps));
|
|
4600
5179
|
}
|
|
4601
5180
|
}
|
|
4602
5181
|
shutdown() {
|
|
@@ -4614,7 +5193,7 @@ var Composer = class {
|
|
|
4614
5193
|
if (read === void 0) return;
|
|
4615
5194
|
for (const block of blocks) {
|
|
4616
5195
|
const served = block.features.some((feature) => Object.values(feature.commands ?? {}).some((target) => target.kind === "extension"));
|
|
4617
|
-
const device = this.composed.get(
|
|
5196
|
+
const device = this.composed.get(require_error_cap.composedDeviceStableId(block.id));
|
|
4618
5197
|
if (!served || device === null || !isActuatorGroupDevice(device)) continue;
|
|
4619
5198
|
const features = await read(device.id);
|
|
4620
5199
|
if (features !== null) device.syncShared([], features);
|
|
@@ -4627,7 +5206,7 @@ var Composer = class {
|
|
|
4627
5206
|
logger: deps.logger.child("forward"),
|
|
4628
5207
|
resolve: (ref) => deps.tracker.resolve(ref, true),
|
|
4629
5208
|
callCapMethod,
|
|
4630
|
-
deviceIdOf: (blockId) => this.composed.idOf(
|
|
5209
|
+
deviceIdOf: (blockId) => this.composed.idOf(require_error_cap.composedDeviceStableId(blockId))
|
|
4631
5210
|
});
|
|
4632
5211
|
}
|
|
4633
5212
|
/**
|
|
@@ -4651,7 +5230,7 @@ var Composer = class {
|
|
|
4651
5230
|
},
|
|
4652
5231
|
readMember: read,
|
|
4653
5232
|
deviceOf: (blockId) => {
|
|
4654
|
-
const device = this.composed.get(
|
|
5233
|
+
const device = this.composed.get(require_error_cap.composedDeviceStableId(blockId));
|
|
4655
5234
|
return device !== null && isActuatorGroupDevice(device) ? device : null;
|
|
4656
5235
|
},
|
|
4657
5236
|
invoke,
|
|
@@ -4682,7 +5261,7 @@ var Composer = class {
|
|
|
4682
5261
|
});
|
|
4683
5262
|
}
|
|
4684
5263
|
async adoptQuantityOf(blockId, quantity) {
|
|
4685
|
-
const device = this.composed.get(
|
|
5264
|
+
const device = this.composed.get(require_error_cap.composedDeviceStableId(blockId));
|
|
4686
5265
|
if (device?.adoptQuantity === void 0) throw new Error(`composed device for ${blockId} cannot store a quantity`);
|
|
4687
5266
|
await device.adoptQuantity(quantity);
|
|
4688
5267
|
}
|
|
@@ -4806,7 +5385,7 @@ var Composer = class {
|
|
|
4806
5385
|
});
|
|
4807
5386
|
continue;
|
|
4808
5387
|
}
|
|
4809
|
-
const device = p.target.kind === "existing" ? null : this.composed.get(
|
|
5388
|
+
const device = p.target.kind === "existing" ? null : this.composed.get(require_error_cap.composedDeviceStableId(p.block.id));
|
|
4810
5389
|
const appliedName = device === null ? null : p.block.name === null ? previous?.appliedName ?? device.name : await this.applyName(device, p.block.id, p.block.name, previous === void 0 ? null : {
|
|
4811
5390
|
appliedName: previous.appliedName,
|
|
4812
5391
|
blockName: previous.planned.block.name,
|
|
@@ -4850,12 +5429,12 @@ var Composer = class {
|
|
|
4850
5429
|
logger: this.deps.logger
|
|
4851
5430
|
});
|
|
4852
5431
|
} catch (err) {
|
|
4853
|
-
const reason = `the target device state could not be read before ownership (${
|
|
5432
|
+
const reason = `the target device state could not be read before ownership (${require_scoped_settings.errMsg(err)}) — nothing is grafted or claimed until it is; retried on the next apply`;
|
|
4854
5433
|
this.deps.logger.warn(previous?.runtime === null || previous === void 0 ? "customization target state could not be read — ownership is held" : "customization edit target state could not be read — the previous runtime stays installed", {
|
|
4855
5434
|
tags: { deviceId: p.target.deviceId },
|
|
4856
5435
|
meta: {
|
|
4857
5436
|
blockId: p.block.id,
|
|
4858
|
-
error:
|
|
5437
|
+
error: require_scoped_settings.errMsg(err)
|
|
4859
5438
|
}
|
|
4860
5439
|
});
|
|
4861
5440
|
if (previous !== void 0) next.set(p.block.id, previous);
|
|
@@ -4876,7 +5455,7 @@ var Composer = class {
|
|
|
4876
5455
|
tags: { deviceId: device.id },
|
|
4877
5456
|
meta: {
|
|
4878
5457
|
blockId: p.block.id,
|
|
4879
|
-
error:
|
|
5458
|
+
error: require_scoped_settings.errMsg(err)
|
|
4880
5459
|
}
|
|
4881
5460
|
});
|
|
4882
5461
|
}
|
|
@@ -4908,7 +5487,7 @@ var Composer = class {
|
|
|
4908
5487
|
const held = new Set(declarations.map((d) => d.stableId));
|
|
4909
5488
|
for (const [blockId, entry] of this.live) {
|
|
4910
5489
|
if (next.has(blockId)) continue;
|
|
4911
|
-
if (held.has(
|
|
5490
|
+
if (held.has(require_error_cap.composedDeviceStableId(blockId))) next.set(blockId, entry);
|
|
4912
5491
|
else halt(entry.runtime);
|
|
4913
5492
|
}
|
|
4914
5493
|
this.live = next;
|
|
@@ -4941,7 +5520,7 @@ var Composer = class {
|
|
|
4941
5520
|
cap,
|
|
4942
5521
|
owner,
|
|
4943
5522
|
event,
|
|
4944
|
-
error:
|
|
5523
|
+
error: require_scoped_settings.errMsg(err)
|
|
4945
5524
|
}
|
|
4946
5525
|
});
|
|
4947
5526
|
}
|
|
@@ -4981,7 +5560,7 @@ var Composer = class {
|
|
|
4981
5560
|
meta: {
|
|
4982
5561
|
blockId,
|
|
4983
5562
|
name,
|
|
4984
|
-
error:
|
|
5563
|
+
error: require_scoped_settings.errMsg(err)
|
|
4985
5564
|
}
|
|
4986
5565
|
});
|
|
4987
5566
|
return remembered?.appliedName ?? device.name;
|
|
@@ -5002,7 +5581,7 @@ var Composer = class {
|
|
|
5002
5581
|
tags: { deviceId: device.id },
|
|
5003
5582
|
meta: {
|
|
5004
5583
|
name,
|
|
5005
|
-
error:
|
|
5584
|
+
error: require_scoped_settings.errMsg(err)
|
|
5006
5585
|
}
|
|
5007
5586
|
});
|
|
5008
5587
|
return applied ?? device.name;
|
|
@@ -5020,7 +5599,7 @@ var Composer = class {
|
|
|
5020
5599
|
meta: {
|
|
5021
5600
|
blockId,
|
|
5022
5601
|
name,
|
|
5023
|
-
error:
|
|
5602
|
+
error: require_scoped_settings.errMsg(err)
|
|
5024
5603
|
}
|
|
5025
5604
|
});
|
|
5026
5605
|
}
|
|
@@ -5044,7 +5623,7 @@ var Composer = class {
|
|
|
5044
5623
|
return await this.deps.tracker.sync(requests, reset);
|
|
5045
5624
|
} catch (err) {
|
|
5046
5625
|
this.deps.logger.warn("composer: syncing the tracked sources failed — retried on the next apply", { meta: {
|
|
5047
|
-
error:
|
|
5626
|
+
error: require_scoped_settings.errMsg(err),
|
|
5048
5627
|
sources: requests.length
|
|
5049
5628
|
} });
|
|
5050
5629
|
return /* @__PURE__ */ new Set();
|
|
@@ -5076,7 +5655,7 @@ var Composer = class {
|
|
|
5076
5655
|
try {
|
|
5077
5656
|
outcome = await this.deps.claims.releaseClaim(key);
|
|
5078
5657
|
} catch (err) {
|
|
5079
|
-
const error =
|
|
5658
|
+
const error = require_scoped_settings.errMsg(err);
|
|
5080
5659
|
this.claimGate.releaseFailed(key, error);
|
|
5081
5660
|
return error;
|
|
5082
5661
|
}
|
|
@@ -5135,7 +5714,7 @@ var Composer = class {
|
|
|
5135
5714
|
}
|
|
5136
5715
|
tagsOf(blockId) {
|
|
5137
5716
|
const entry = this.live.get(blockId);
|
|
5138
|
-
const deviceId = this.composed.idOf(
|
|
5717
|
+
const deviceId = this.composed.idOf(require_error_cap.composedDeviceStableId(blockId)) ?? (entry === void 0 ? null : this.deviceIdOf(entry));
|
|
5139
5718
|
return deviceId === null ? {} : { deviceId };
|
|
5140
5719
|
}
|
|
5141
5720
|
verdict(blockId) {
|
|
@@ -5150,7 +5729,7 @@ function historySpecsOf(blocks) {
|
|
|
5150
5729
|
const specs = /* @__PURE__ */ new Map();
|
|
5151
5730
|
for (const block of blocks) {
|
|
5152
5731
|
const helper = block.composition.helper;
|
|
5153
|
-
if (helper === void 0 || !
|
|
5732
|
+
if (helper === void 0 || !require_error_cap.isHistoryHelper(helper)) continue;
|
|
5154
5733
|
specs.set(block.id, helper);
|
|
5155
5734
|
}
|
|
5156
5735
|
return specs;
|
|
@@ -5167,7 +5746,7 @@ var unattachedInvoke = async () => {
|
|
|
5167
5746
|
function forwardBlocksOf(blocks) {
|
|
5168
5747
|
return blocks.flatMap((block) => {
|
|
5169
5748
|
if (!block.enabled || block.composition.target.kind !== "new") return [];
|
|
5170
|
-
const features = block.composition.features.flatMap((feature) => feature.kind === "fields" &&
|
|
5749
|
+
const features = block.composition.features.flatMap((feature) => feature.kind === "fields" && require_error_cap.compositionFeatureEnabled(feature) ? [feature] : []);
|
|
5171
5750
|
return [{
|
|
5172
5751
|
id: block.id,
|
|
5173
5752
|
features
|
|
@@ -5295,7 +5874,7 @@ var GraftHost = class {
|
|
|
5295
5874
|
try {
|
|
5296
5875
|
ctx.registerNativeCap(def, provider);
|
|
5297
5876
|
} catch (err) {
|
|
5298
|
-
return this.refuse(deviceId, capName, `registerNativeCap threw — ${
|
|
5877
|
+
return this.refuse(deviceId, capName, `registerNativeCap threw — ${require_scoped_settings.errMsg(err)}`);
|
|
5299
5878
|
}
|
|
5300
5879
|
this.caps = new Map([...this.caps, [deviceId, new Set([...this.grafted(deviceId), capName])]]);
|
|
5301
5880
|
this.ports.logger.info("graft: an added cap is served on a device the composer does not own", {
|
|
@@ -5370,7 +5949,7 @@ var GraftHost = class {
|
|
|
5370
5949
|
meta: {
|
|
5371
5950
|
cap: capName,
|
|
5372
5951
|
reason,
|
|
5373
|
-
error:
|
|
5952
|
+
error: require_scoped_settings.errMsg(err)
|
|
5374
5953
|
}
|
|
5375
5954
|
});
|
|
5376
5955
|
return "threw";
|
|
@@ -5592,7 +6171,7 @@ var SourceTracker = class {
|
|
|
5592
6171
|
*/
|
|
5593
6172
|
resolve(ref, reset) {
|
|
5594
6173
|
return this.serialized(async () => {
|
|
5595
|
-
const k =
|
|
6174
|
+
const k = require_error_cap.compositionSourceKey(ref);
|
|
5596
6175
|
const prior = this.sources.get(k);
|
|
5597
6176
|
const before = reset ? void 0 : prior;
|
|
5598
6177
|
if (before !== void 0 && (before.deviceId !== null || before.missingReason !== null)) return resolutionOf(before);
|
|
@@ -5630,10 +6209,10 @@ var SourceTracker = class {
|
|
|
5630
6209
|
}
|
|
5631
6210
|
/** The last settled resolution of a ref; `unknown` when it was never resolved. Synchronous, from memory. */
|
|
5632
6211
|
resolution(ref) {
|
|
5633
|
-
const source = this.sources.get(
|
|
6212
|
+
const source = this.sources.get(require_error_cap.compositionSourceKey(ref));
|
|
5634
6213
|
return source === void 0 ? {
|
|
5635
6214
|
kind: "unknown",
|
|
5636
|
-
error: `source \`${
|
|
6215
|
+
error: `source \`${require_error_cap.compositionSourceKey(ref)}\` is not tracked`
|
|
5637
6216
|
} : resolutionOf(source);
|
|
5638
6217
|
}
|
|
5639
6218
|
onStateChanged(deviceId, capName, slice) {
|
|
@@ -5658,7 +6237,7 @@ var SourceTracker = class {
|
|
|
5658
6237
|
async syncNow(requests, reset) {
|
|
5659
6238
|
const merged = /* @__PURE__ */ new Map();
|
|
5660
6239
|
for (const request of requests) {
|
|
5661
|
-
const k =
|
|
6240
|
+
const k = require_error_cap.compositionSourceKey(request.ref);
|
|
5662
6241
|
const prior = merged.get(k);
|
|
5663
6242
|
merged.set(k, {
|
|
5664
6243
|
ref: request.ref,
|
|
@@ -5676,15 +6255,15 @@ var SourceTracker = class {
|
|
|
5676
6255
|
next.set(k, after);
|
|
5677
6256
|
for (const entry of entriesOf(request)) {
|
|
5678
6257
|
const key = entryKey(entry);
|
|
5679
|
-
if (before?.caps.get(key) !== after.caps.get(key) || before?.missingReason !== after.missingReason) changed.add(
|
|
6258
|
+
if (before?.caps.get(key) !== after.caps.get(key) || before?.missingReason !== after.missingReason) changed.add(require_error_cap.compositionSliceKey(request.ref, entry.cap));
|
|
5680
6259
|
}
|
|
5681
6260
|
}
|
|
5682
6261
|
this.sources = next;
|
|
5683
6262
|
return changed;
|
|
5684
6263
|
}
|
|
5685
6264
|
read(read, view = "effective") {
|
|
5686
|
-
const label = `${
|
|
5687
|
-
const tracked = this.sources.get(
|
|
6265
|
+
const label = `${require_error_cap.compositionSourceKey(read.source)} ${read.cap}.${read.fieldPath}`;
|
|
6266
|
+
const tracked = this.sources.get(require_error_cap.compositionSourceKey(read.source));
|
|
5688
6267
|
if (tracked === void 0) return {
|
|
5689
6268
|
state: "unavailable",
|
|
5690
6269
|
reason: `${label}: not tracked yet`,
|
|
@@ -5713,7 +6292,7 @@ var SourceTracker = class {
|
|
|
5713
6292
|
confirmed
|
|
5714
6293
|
};
|
|
5715
6294
|
}
|
|
5716
|
-
const value =
|
|
6295
|
+
const value = require_error_cap.toExpressionValue(valueAtPath(cap.slice, read.fieldPath));
|
|
5717
6296
|
if (value === void 0) return {
|
|
5718
6297
|
state: "unavailable",
|
|
5719
6298
|
reason: `${label}: the field is absent or not a scalar`,
|
|
@@ -5748,7 +6327,7 @@ var SourceTracker = class {
|
|
|
5748
6327
|
...updated,
|
|
5749
6328
|
online
|
|
5750
6329
|
};
|
|
5751
|
-
for (const key of source.caps.keys()) changed.add(
|
|
6330
|
+
for (const key of source.caps.keys()) changed.add(require_error_cap.compositionSliceKey(source.ref, entryOf(key).cap));
|
|
5752
6331
|
}
|
|
5753
6332
|
}
|
|
5754
6333
|
const views = source.nativeOwner !== null && this.held.shadowsNative(deviceId, capName, source.nativeOwner) ? ["effective"] : ["effective", "native"];
|
|
@@ -5768,7 +6347,7 @@ var SourceTracker = class {
|
|
|
5768
6347
|
staleReason: null
|
|
5769
6348
|
}]])
|
|
5770
6349
|
};
|
|
5771
|
-
changed.add(
|
|
6350
|
+
changed.add(require_error_cap.compositionSliceKey(source.ref, capName));
|
|
5772
6351
|
}
|
|
5773
6352
|
if (updated !== source) next.set(k, updated);
|
|
5774
6353
|
}
|
|
@@ -5795,7 +6374,7 @@ var SourceTracker = class {
|
|
|
5795
6374
|
staleReason: null
|
|
5796
6375
|
}]])
|
|
5797
6376
|
});
|
|
5798
|
-
changed.add(
|
|
6377
|
+
changed.add(require_error_cap.compositionSliceKey(source.ref, capName));
|
|
5799
6378
|
}
|
|
5800
6379
|
this.sources = next;
|
|
5801
6380
|
return changed;
|
|
@@ -5830,7 +6409,7 @@ var SourceTracker = class {
|
|
|
5830
6409
|
}
|
|
5831
6410
|
});
|
|
5832
6411
|
this.sources = new Map([...this.sources, [k, next]]);
|
|
5833
|
-
for (const key of source.caps.keys()) changed.add(
|
|
6412
|
+
for (const key of source.caps.keys()) changed.add(require_error_cap.compositionSliceKey(source.ref, entryOf(key).cap));
|
|
5834
6413
|
}
|
|
5835
6414
|
return changed;
|
|
5836
6415
|
}
|
|
@@ -5884,12 +6463,12 @@ var SourceTracker = class {
|
|
|
5884
6463
|
...updated,
|
|
5885
6464
|
online
|
|
5886
6465
|
};
|
|
5887
|
-
for (const key of source.caps.keys()) changed.add(
|
|
6466
|
+
for (const key of source.caps.keys()) changed.add(require_error_cap.compositionSliceKey(source.ref, entryOf(key).cap));
|
|
5888
6467
|
}
|
|
5889
6468
|
}
|
|
5890
6469
|
if (updated === source) continue;
|
|
5891
6470
|
this.sources = new Map([...this.sources, [k, updated]]);
|
|
5892
|
-
if (updated.caps !== source.caps) changed.add(
|
|
6471
|
+
if (updated.caps !== source.caps) changed.add(require_error_cap.compositionSliceKey(source.ref, capName));
|
|
5893
6472
|
}
|
|
5894
6473
|
return changed;
|
|
5895
6474
|
}
|
|
@@ -5923,7 +6502,7 @@ var SourceTracker = class {
|
|
|
5923
6502
|
nativeOwner
|
|
5924
6503
|
};
|
|
5925
6504
|
}
|
|
5926
|
-
const k =
|
|
6505
|
+
const k = require_error_cap.compositionSourceKey(request.ref);
|
|
5927
6506
|
const first = lists.get(request.ref.addonId) ?? await this.ports.listDevicesOf(request.ref.addonId);
|
|
5928
6507
|
lists.set(request.ref.addonId, first);
|
|
5929
6508
|
const resolution = await this.resolveConfirmed(request.ref, first);
|
|
@@ -5993,13 +6572,13 @@ var SourceTracker = class {
|
|
|
5993
6572
|
if (second.kind === "found") {
|
|
5994
6573
|
this.ports.logger.warn("composition source: the device index disagreed with itself — keeping the source", {
|
|
5995
6574
|
tags: { deviceId: second.deviceId },
|
|
5996
|
-
meta: { source:
|
|
6575
|
+
meta: { source: require_error_cap.compositionSourceKey(ref) }
|
|
5997
6576
|
});
|
|
5998
6577
|
return second;
|
|
5999
6578
|
}
|
|
6000
6579
|
return second.kind === "absent" ? {
|
|
6001
6580
|
kind: "missing",
|
|
6002
|
-
reason: `source \`${
|
|
6581
|
+
reason: `source \`${require_error_cap.compositionSourceKey(ref)}\` does not exist`
|
|
6003
6582
|
} : second;
|
|
6004
6583
|
}
|
|
6005
6584
|
/**
|
|
@@ -6088,7 +6667,7 @@ var SourceTracker = class {
|
|
|
6088
6667
|
...latest,
|
|
6089
6668
|
caps: new Map([...latest.caps, [key, reading]])
|
|
6090
6669
|
}]]);
|
|
6091
|
-
changed.add(
|
|
6670
|
+
changed.add(require_error_cap.compositionSliceKey(source.ref, cap));
|
|
6092
6671
|
}
|
|
6093
6672
|
return changed;
|
|
6094
6673
|
}
|
|
@@ -6144,7 +6723,7 @@ function parseNativeShadowChanged(data) {
|
|
|
6144
6723
|
native
|
|
6145
6724
|
};
|
|
6146
6725
|
}
|
|
6147
|
-
var ComposerAddon = class extends
|
|
6726
|
+
var ComposerAddon = class extends require_base_addon.BaseAddon {
|
|
6148
6727
|
composer = null;
|
|
6149
6728
|
constructor() {
|
|
6150
6729
|
super({});
|
|
@@ -6166,7 +6745,7 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6166
6745
|
} catch (err) {
|
|
6167
6746
|
return {
|
|
6168
6747
|
kind: "unreadable",
|
|
6169
|
-
error:
|
|
6748
|
+
error: require_scoped_settings.errMsg(err)
|
|
6170
6749
|
};
|
|
6171
6750
|
}
|
|
6172
6751
|
};
|
|
@@ -6188,7 +6767,7 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6188
6767
|
} catch (err) {
|
|
6189
6768
|
return {
|
|
6190
6769
|
kind: "unreadable",
|
|
6191
|
-
error:
|
|
6770
|
+
error: require_scoped_settings.errMsg(err)
|
|
6192
6771
|
};
|
|
6193
6772
|
}
|
|
6194
6773
|
},
|
|
@@ -6209,16 +6788,16 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6209
6788
|
} catch (err) {
|
|
6210
6789
|
return {
|
|
6211
6790
|
kind: "unreadable",
|
|
6212
|
-
error:
|
|
6791
|
+
error: require_scoped_settings.errMsg(err)
|
|
6213
6792
|
};
|
|
6214
6793
|
}
|
|
6215
6794
|
},
|
|
6216
6795
|
readBoundCaps
|
|
6217
6796
|
});
|
|
6218
|
-
const listOwnDevices = async () => api.deviceManager.listAll.query({ addonId:
|
|
6219
|
-
const declared = new
|
|
6797
|
+
const listOwnDevices = async () => api.deviceManager.listAll.query({ addonId: require_error_cap.COMPOSER_ADDON_ID });
|
|
6798
|
+
const declared = new require_declared_device.DeclaredDevices({
|
|
6220
6799
|
logger: logger.child("declaration"),
|
|
6221
|
-
addonId:
|
|
6800
|
+
addonId: require_error_cap.COMPOSER_ADDON_ID,
|
|
6222
6801
|
devices: this.ctx.kernel.devices,
|
|
6223
6802
|
localNodeId: this.ctx.kernel.localNodeId,
|
|
6224
6803
|
getIntegration: async () => {
|
|
@@ -6233,7 +6812,7 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6233
6812
|
listOwnDevices
|
|
6234
6813
|
});
|
|
6235
6814
|
const devices = this.ctx.kernel.devices;
|
|
6236
|
-
const lookupCap =
|
|
6815
|
+
const lookupCap = require_core_blocks_cap.buildCapabilityLookup(require_rename_composition_block.ALL_CAPABILITY_DEFINITIONS);
|
|
6237
6816
|
const grafts = new GraftHost({
|
|
6238
6817
|
createContext: (stableId, id) => devices.createContext(stableId, id),
|
|
6239
6818
|
logger: logger.child("graft")
|
|
@@ -6297,7 +6876,7 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6297
6876
|
} catch (err) {
|
|
6298
6877
|
return {
|
|
6299
6878
|
kind: "unread",
|
|
6300
|
-
error:
|
|
6879
|
+
error: require_scoped_settings.errMsg(err)
|
|
6301
6880
|
};
|
|
6302
6881
|
}
|
|
6303
6882
|
},
|
|
@@ -6310,13 +6889,13 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6310
6889
|
maxPoints: input.maxPoints
|
|
6311
6890
|
}),
|
|
6312
6891
|
readHistoryRetention: async () => {
|
|
6313
|
-
return
|
|
6892
|
+
return require_error_cap.historyRetentionFromSettings(await api.addonSettingsRaw.getGlobal.query({ addonId: "device-history" }));
|
|
6314
6893
|
},
|
|
6315
6894
|
readSourceQuantity: async (deviceId) => {
|
|
6316
6895
|
const quantity = (await api.deviceManager.getDevice.query({ deviceId }))?.sourceInfo?.quantity;
|
|
6317
|
-
return
|
|
6896
|
+
return require_quantity.isReadingQuantity(quantity) ? quantity : null;
|
|
6318
6897
|
},
|
|
6319
|
-
timeZone:
|
|
6898
|
+
timeZone: processTimeZoneOr("UTC", logger),
|
|
6320
6899
|
describeTarget: readBoundCaps,
|
|
6321
6900
|
grafts,
|
|
6322
6901
|
now: () => Date.now(),
|
|
@@ -6333,12 +6912,12 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6333
6912
|
} catch (err) {
|
|
6334
6913
|
return {
|
|
6335
6914
|
kind: "unreadable",
|
|
6336
|
-
error:
|
|
6915
|
+
error: require_scoped_settings.errMsg(err)
|
|
6337
6916
|
};
|
|
6338
6917
|
}
|
|
6339
6918
|
},
|
|
6340
6919
|
callCapMethod: async (deviceId, cap, method, args) => {
|
|
6341
|
-
const mutate =
|
|
6920
|
+
const mutate = resolveMutate(Reflect.get(api, require_rename_composition_block.kebabToCamel(cap)), method);
|
|
6342
6921
|
if (mutate === null) throw new Error(`\`${cap}.${method}\` is not a mutation reachable through ctx.api`);
|
|
6343
6922
|
await mutate({
|
|
6344
6923
|
deviceId,
|
|
@@ -6362,7 +6941,7 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6362
6941
|
} catch (err) {
|
|
6363
6942
|
this.ctx.logger.warn("composer: the bindings of a composed device could not be read", {
|
|
6364
6943
|
tags: { deviceId },
|
|
6365
|
-
meta: { error:
|
|
6944
|
+
meta: { error: require_scoped_settings.errMsg(err) }
|
|
6366
6945
|
});
|
|
6367
6946
|
return null;
|
|
6368
6947
|
}
|
|
@@ -6370,11 +6949,11 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6370
6949
|
extensionFeatures: async (deviceId) => {
|
|
6371
6950
|
try {
|
|
6372
6951
|
const list = await api.remote.listCommands.query({ deviceId });
|
|
6373
|
-
return
|
|
6952
|
+
return mediaPlayerFeaturesOfRoles(list.commands.map((c) => c.role), list.sources.length);
|
|
6374
6953
|
} catch (err) {
|
|
6375
6954
|
this.ctx.logger.warn("composer: the remote of a media player could not be read", {
|
|
6376
6955
|
tags: { deviceId },
|
|
6377
|
-
meta: { error:
|
|
6956
|
+
meta: { error: require_scoped_settings.errMsg(err) }
|
|
6378
6957
|
});
|
|
6379
6958
|
return null;
|
|
6380
6959
|
}
|
|
@@ -6499,31 +7078,31 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6499
7078
|
}
|
|
6500
7079
|
}, call)
|
|
6501
7080
|
});
|
|
6502
|
-
this.subscribe({ category:
|
|
7081
|
+
this.subscribe({ category: require_base_addon.EventCategory.DeviceStateChanged }, (event) => {
|
|
6503
7082
|
const data = require_capture_engine.parseConfirmedStateChanged(event.data);
|
|
6504
7083
|
if (data !== null) this.composer?.onStateChanged(data).catch((err) => {
|
|
6505
7084
|
this.logEventFailure("device.state-changed", data.deviceId, err);
|
|
6506
7085
|
});
|
|
6507
7086
|
});
|
|
6508
|
-
this.subscribe({ category:
|
|
7087
|
+
this.subscribe({ category: require_base_addon.EventCategory.DeviceNativeShadowChanged }, (event) => {
|
|
6509
7088
|
const data = parseNativeShadowChanged(event.data);
|
|
6510
7089
|
if (data !== null) this.composer?.onNativeChanged(data).catch((err) => {
|
|
6511
|
-
this.logEventFailure(
|
|
7090
|
+
this.logEventFailure(require_base_addon.EventCategory.DeviceNativeShadowChanged, data.deviceId, err);
|
|
6512
7091
|
});
|
|
6513
7092
|
});
|
|
6514
|
-
this.subscribe({ category:
|
|
7093
|
+
this.subscribe({ category: require_base_addon.EventCategory.DeviceUnregistered }, (event) => {
|
|
6515
7094
|
this.composer?.onDeviceUnregistered(event.data.deviceId).catch((err) => {
|
|
6516
7095
|
this.logEventFailure("device.unregistered", event.data.deviceId, err);
|
|
6517
7096
|
});
|
|
6518
7097
|
});
|
|
6519
|
-
this.subscribe({ category:
|
|
7098
|
+
this.subscribe({ category: require_base_addon.EventCategory.DeviceBindingsChanged }, (event) => {
|
|
6520
7099
|
this.composer?.onBindingsChanged(event.data).catch((err) => {
|
|
6521
7100
|
this.logEventFailure("device.bindings-changed", event.data.deviceId, err);
|
|
6522
7101
|
});
|
|
6523
7102
|
});
|
|
6524
7103
|
logger.info("composer ready — waiting for core-blocks to apply the compositions");
|
|
6525
7104
|
return [{
|
|
6526
|
-
capability:
|
|
7105
|
+
capability: require_rename_composition_block.composerCapability,
|
|
6527
7106
|
provider: this.buildProvider()
|
|
6528
7107
|
}];
|
|
6529
7108
|
}
|
|
@@ -6537,7 +7116,7 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6537
7116
|
tags: { deviceId },
|
|
6538
7117
|
meta: {
|
|
6539
7118
|
category,
|
|
6540
|
-
error:
|
|
7119
|
+
error: require_scoped_settings.errMsg(err)
|
|
6541
7120
|
}
|
|
6542
7121
|
});
|
|
6543
7122
|
}
|