@dominevo/ui-library 0.1.5 → 0.1.6

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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.6] - 2026-11-30
11
+
12
+ ### Changed
13
+
14
+ - Instance and provider lists also refresh at once on addon, runner, node and instance events
15
+
10
16
  ## [0.1.5] - 2026-11-30
11
17
 
12
18
  ### Changed
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The events after which `addons.listCapabilityProviders` / `addons.list` can
3
+ * answer differently: an addon came, went, crashed or was stopped, its runner
4
+ * died (terminally, or to be respawned) or its node went away or came back, or a
5
+ * capability was bound to another provider. They only make the provider lists
6
+ * faster than their 5 s poll: a capability registering with the hub
7
+ * (`registerNode`) announces nothing on the bus, so the poll stays.
8
+ */
9
+ import { EventCategory } from "@dominevo/types";
10
+ export declare const CAPABILITY_PROVIDER_EVENTS: readonly EventCategory[];
11
+ /**
12
+ * What makes the instance list of an addon's `integration-instances` holder
13
+ * move through the hub: an instance created, deleted or updated, or switched.
14
+ * It is NOT every change of the list: an instance's `status` follows the
15
+ * addon's own probes, which announce nothing, so a holder's list keeps a poll
16
+ * and follows these only to be faster than it.
17
+ */
18
+ export declare const INSTANCE_LIST_EVENTS: readonly EventCategory[];
19
+ /** `addons.listCapabilityProviders`, as a procedure path. */
20
+ export declare const LIST_CAPABILITY_PROVIDERS_PATH: readonly string[];
21
+ /** `addons.list`, as a procedure path. */
22
+ export declare const ADDONS_LIST_PATH: readonly string[];
@@ -43,6 +43,7 @@ export type { DestructiveAction, UseDestructiveActionOptions } from "./use-destr
43
43
  export { useDestructiveAction } from "./use-destructive-action";
44
44
  export type { DoorbellPressEvent, UseDoorbellEventsOptions, UseDoorbellEventsResult } from "./use-doorbell-events";
45
45
  export { useDoorbellEvents } from "./use-doorbell-events";
46
+ export { ADDONS_LIST_PATH, CAPABILITY_PROVIDER_EVENTS, INSTANCE_LIST_EVENTS, LIST_CAPABILITY_PROVIDERS_PATH } from "./capability-provider-events";
46
47
  export { LIVE_REFRESH_SAFETY_NET_MS, useEventInvalidation, type EventInvalidationHandle, type EventInvalidationKeyShape, type EventInvalidationOptions } from "./use-event-invalidation";
47
48
  export { useEventStreamLatest, useEventStreamMap } from "./use-event-stream";
48
49
  export { useIsMidWidth, useIsMobile, useIsPhone } from "./use-is-mobile";
package/dist/index.cjs CHANGED
@@ -17939,6 +17939,241 @@ function DeviceMultiSelectFormField(props) {
17939
17939
  });
17940
17940
  }
17941
17941
  //#endregion
17942
+ //#region src/hooks/capability-provider-events.ts
17943
+ /**
17944
+ * The events after which `addons.listCapabilityProviders` / `addons.list` can
17945
+ * answer differently: an addon came, went, crashed or was stopped, its runner
17946
+ * died (terminally, or to be respawned) or its node went away or came back, or a
17947
+ * capability was bound to another provider. They only make the provider lists
17948
+ * faster than their 5 s poll: a capability registering with the hub
17949
+ * (`registerNode`) announces nothing on the bus, so the poll stays.
17950
+ */
17951
+ var CAPABILITY_PROVIDER_EVENTS = [
17952
+ _dominevo_types.EventCategory.AddonStarted,
17953
+ _dominevo_types.EventCategory.AddonStopped,
17954
+ _dominevo_types.EventCategory.AddonRestarted,
17955
+ _dominevo_types.EventCategory.AddonUpdated,
17956
+ _dominevo_types.EventCategory.AddonInstalled,
17957
+ _dominevo_types.EventCategory.AddonUninstalled,
17958
+ _dominevo_types.EventCategory.AddonCrashed,
17959
+ _dominevo_types.EventCategory.AddonRunnerFailed,
17960
+ _dominevo_types.EventCategory.AddonLoadFailed,
17961
+ _dominevo_types.EventCategory.AddonLoadRecovered,
17962
+ _dominevo_types.EventCategory.ProcessCrashed,
17963
+ _dominevo_types.EventCategory.WorkerOffline,
17964
+ _dominevo_types.EventCategory.WorkerOnline,
17965
+ _dominevo_types.EventCategory.CapabilityBindingChanged,
17966
+ _dominevo_types.EventCategory.SystemAddonsReady
17967
+ ];
17968
+ /**
17969
+ * What makes the instance list of an addon's `integration-instances` holder
17970
+ * move through the hub: an instance created, deleted or updated, or switched.
17971
+ * It is NOT every change of the list: an instance's `status` follows the
17972
+ * addon's own probes, which announce nothing, so a holder's list keeps a poll
17973
+ * and follows these only to be faster than it.
17974
+ */
17975
+ var INSTANCE_LIST_EVENTS = [
17976
+ _dominevo_types.EventCategory.IntegrationInstancesChanged,
17977
+ _dominevo_types.EventCategory.IntegrationEnabled,
17978
+ _dominevo_types.EventCategory.IntegrationDisabled,
17979
+ _dominevo_types.EventCategory.IntegrationDeleted
17980
+ ];
17981
+ /** `addons.listCapabilityProviders`, as a procedure path. */
17982
+ var LIST_CAPABILITY_PROVIDERS_PATH = ["addons", "listCapabilityProviders"];
17983
+ /** `addons.list`, as a procedure path. */
17984
+ var ADDONS_LIST_PATH = ["addons", "list"];
17985
+ //#endregion
17986
+ //#region src/hooks/use-event-invalidation.ts
17987
+ /**
17988
+ * useEventInvalidation — subscribe to one or more EventBus categories
17989
+ * over the unified `System.subscribeEvent` push channel and invalidate
17990
+ * a React Query cache prefix when any of them fires.
17991
+ *
17992
+ * Lets callers drop their `refetchInterval` polling: the cache is kept
17993
+ * fresh by server-pushed events instead of timer-driven refetches. The
17994
+ * hook is a no-op when the WebSocket isn't available (e.g. during
17995
+ * initial reconnection) — the caller is free to keep a long
17996
+ * `staleTime` so React Query still serves the last good snapshot.
17997
+ *
17998
+ * Input shape — pass the tRPC procedure path directly:
17999
+ * ✔ `['integrations']` → invalidates every `integrations.*`
18000
+ * ✔ `['deviceManager', 'listAll']` → invalidates that one query
18001
+ *
18002
+ * The hook wraps the path into the `[[...path], ...]` form that
18003
+ * @tanstack/react-query + @trpc/react-query use under the hood —
18004
+ * passing a flat `['integrations']` to `invalidateQueries` directly
18005
+ * would never match the actual tRPC key
18006
+ * `[['integrations', 'list'], { input, type }]`. Caller doesn't have
18007
+ * to know about the wrap.
18008
+ *
18009
+ * Reconnect resilience: when `System.reconnect()` rebuilds the
18010
+ * underlying wsClient + tRPC client, the System reference doesn't
18011
+ * change — but `connectionVersion` bumps. We listen via
18012
+ * `subscribeConnectionEvents` so the subscription effect re-runs
18013
+ * against the freshly-rebuilt tRPC client.
18014
+ *
18015
+ * Lives in `@dominevo/ui-library` (not in admin-ui's hooks folder)
18016
+ * because addon widget bundles reach for it through the shared library.
18017
+ *
18018
+ * ## Replacing a poll
18019
+ *
18020
+ * The third argument carries what a caller needs to DROP its
18021
+ * `refetchInterval`:
18022
+ *
18023
+ * - `deviceId` — an event that names another device is ignored. One that
18024
+ * names no device at all still invalidates.
18025
+ * - `input` — narrow the invalidation to the query called with that input.
18026
+ * - `debounceMs` — the trailing window (default 1 s).
18027
+ * - `safetyNetMs` — events are telemetry and may be dropped, so a caller
18028
+ * with no poll of its own asks for a slow periodic invalidation
18029
+ * ({@link LIVE_REFRESH_SAFETY_NET_MS}).
18030
+ * - `enabled` — false does nothing at all (no id yet, a tab not shown).
18031
+ * - `paused` — the caller holds refreshes back (an open draft, a list being
18032
+ * read); `pending` says one is owed, and it is paid on resume or by
18033
+ * `refreshNow()`.
18034
+ *
18035
+ * And for every caller: a hidden document fetches nothing. Whatever arrived
18036
+ * meanwhile is paid as ONE invalidation when the document is visible again.
18037
+ */
18038
+ /** Trailing coalesce for event-driven invalidation — see the comment inside. */
18039
+ var EVENT_INVALIDATION_COALESCE_MS = 1e3;
18040
+ /**
18041
+ * The slow periodic invalidation of a query that is otherwise kept fresh by
18042
+ * events. An event may be dropped, so "never" is not an option; this bounds
18043
+ * how long a missed one can leave the page stale.
18044
+ */
18045
+ var LIVE_REFRESH_SAFETY_NET_MS = 6e4;
18046
+ function numericDeviceId(holder, key) {
18047
+ if (typeof holder !== "object" || holder === null || !(key in holder)) return void 0;
18048
+ const value = Reflect.get(holder, key);
18049
+ return typeof value === "number" ? value : void 0;
18050
+ }
18051
+ /**
18052
+ * The device an event is about: its payload's `deviceId`, else a `device`
18053
+ * source's id. `undefined` when it names none.
18054
+ */
18055
+ function eventDeviceId(event) {
18056
+ if (typeof event !== "object" || event === null) return void 0;
18057
+ const fromData = "data" in event ? numericDeviceId(event.data, "deviceId") : void 0;
18058
+ if (fromData !== void 0) return fromData;
18059
+ if (!("source" in event)) return void 0;
18060
+ const source = event.source;
18061
+ if (typeof source !== "object" || source === null || !("type" in source)) return void 0;
18062
+ return source.type === "device" ? numericDeviceId(source, "id") : void 0;
18063
+ }
18064
+ function isDocumentHidden() {
18065
+ return typeof document !== "undefined" && document.visibilityState === "hidden";
18066
+ }
18067
+ function buildQueryKey(keyJson, inputJson, keyShape) {
18068
+ const raw = JSON.parse(keyJson);
18069
+ const path = Array.isArray(raw) ? raw : [];
18070
+ if (keyShape === "raw") return path;
18071
+ const wrapped = path.length === 1 && Array.isArray(path[0]) ? path : [path];
18072
+ if (inputJson === void 0) return wrapped;
18073
+ const input = JSON.parse(inputJson);
18074
+ return [...wrapped, { input }];
18075
+ }
18076
+ function useEventInvalidation(queryKey, categories, options) {
18077
+ const system = useSystem();
18078
+ const queryClient = (0, _tanstack_react_query.useQueryClient)();
18079
+ const deviceId = options?.deviceId;
18080
+ const debounceMs = options?.debounceMs ?? EVENT_INVALIDATION_COALESCE_MS;
18081
+ const safetyNetMs = options?.safetyNetMs;
18082
+ const initial = options?.initial !== false;
18083
+ const keyShape = options?.keyShape ?? "trpc";
18084
+ const paused = options?.paused === true;
18085
+ const enabled = options?.enabled !== false;
18086
+ const [tick, setTick] = (0, react$1.useState)(system.connectionVersion);
18087
+ (0, react$1.useEffect)(() => {
18088
+ return system.subscribeConnectionEvents((state, version) => {
18089
+ if (state === "connected") setTick(version);
18090
+ });
18091
+ }, [system]);
18092
+ const key = categories.join("|");
18093
+ const keyJson = JSON.stringify(queryKey);
18094
+ const inputJson = options?.input === void 0 ? void 0 : JSON.stringify(options.input);
18095
+ const pausedRef = (0, react$1.useRef)(paused);
18096
+ pausedRef.current = paused;
18097
+ const owedRef = (0, react$1.useRef)(false);
18098
+ const [pending, setPending] = (0, react$1.useState)(false);
18099
+ const invalidateNow = (0, react$1.useCallback)(() => {
18100
+ owedRef.current = false;
18101
+ setPending(false);
18102
+ queryClient.invalidateQueries({ queryKey: buildQueryKey(keyJson, inputJson, keyShape) });
18103
+ }, [
18104
+ queryClient,
18105
+ keyJson,
18106
+ inputJson,
18107
+ keyShape
18108
+ ]);
18109
+ /** Invalidate, unless nobody is looking or the caller asked to wait. */
18110
+ const apply = (0, react$1.useCallback)(() => {
18111
+ if (isDocumentHidden()) {
18112
+ owedRef.current = true;
18113
+ return;
18114
+ }
18115
+ if (pausedRef.current) {
18116
+ owedRef.current = true;
18117
+ setPending(true);
18118
+ return;
18119
+ }
18120
+ invalidateNow();
18121
+ }, [invalidateNow]);
18122
+ (0, react$1.useEffect)(() => {
18123
+ if (!enabled) return void 0;
18124
+ const subs = [];
18125
+ let openWindow = null;
18126
+ const onEvent = (event) => {
18127
+ if (deviceId !== void 0) {
18128
+ const about = eventDeviceId(event);
18129
+ if (about !== void 0 && about !== deviceId) return;
18130
+ }
18131
+ if (openWindow !== null) return;
18132
+ openWindow = setTimeout(() => {
18133
+ openWindow = null;
18134
+ apply();
18135
+ }, debounceMs);
18136
+ };
18137
+ if (initial) invalidateNow();
18138
+ for (const category of key.split("|")) {
18139
+ if (!category) continue;
18140
+ try {
18141
+ subs.push(system.subscribeEvent(category, onEvent));
18142
+ } catch {}
18143
+ }
18144
+ const safetyNet = safetyNetMs !== void 0 && safetyNetMs > 0 ? setInterval(apply, safetyNetMs) : null;
18145
+ const onVisibility = () => {
18146
+ if (!isDocumentHidden() && owedRef.current) apply();
18147
+ };
18148
+ const visibilityTarget = typeof document === "undefined" ? null : document;
18149
+ visibilityTarget?.addEventListener("visibilitychange", onVisibility);
18150
+ return () => {
18151
+ if (openWindow !== null) clearTimeout(openWindow);
18152
+ if (safetyNet !== null) clearInterval(safetyNet);
18153
+ visibilityTarget?.removeEventListener("visibilitychange", onVisibility);
18154
+ for (const unsub of subs) unsub();
18155
+ };
18156
+ }, [
18157
+ system,
18158
+ key,
18159
+ tick,
18160
+ deviceId,
18161
+ debounceMs,
18162
+ safetyNetMs,
18163
+ initial,
18164
+ enabled,
18165
+ apply,
18166
+ invalidateNow
18167
+ ]);
18168
+ (0, react$1.useEffect)(() => {
18169
+ if (!paused && owedRef.current) apply();
18170
+ }, [paused, apply]);
18171
+ return {
18172
+ pending,
18173
+ refreshNow: invalidateNow
18174
+ };
18175
+ }
18176
+ //#endregion
17942
18177
  //#region src/hooks/use-instances-of-cap.ts
17943
18178
  /**
17944
18179
  * The instances an operator can link to, read from the ONE instance model (D1013 rule 5): every
@@ -17992,6 +18227,15 @@ function useInstancesOfCap(filter, opts = {}) {
17992
18227
  refetchInterval: POLL_INTERVAL_MS$2,
17993
18228
  enabled
17994
18229
  });
18230
+ useEventInvalidation(LIST_CAPABILITY_PROVIDERS_PATH, CAPABILITY_PROVIDER_EVENTS, {
18231
+ initial: false,
18232
+ enabled
18233
+ });
18234
+ useEventInvalidation([CAP_INSTANCES_QUERY_KEY], INSTANCE_LIST_EVENTS, {
18235
+ initial: false,
18236
+ keyShape: "raw",
18237
+ enabled
18238
+ });
17995
18239
  const queries = (0, _tanstack_react_query.useQueries)({ queries: (0, react$1.useMemo)(() => {
17996
18240
  const holding = new Set((holders.data ?? []).map((p) => p.addonId));
17997
18241
  return (capProviders.data ?? []).map((p) => p.addonId).filter((id) => holding.has(id));
@@ -104670,7 +104914,7 @@ function TaggedDataTable({ section, rows, columns, getTags, searchText, searchLa
104670
104914
  }
104671
104915
  //#endregion
104672
104916
  //#region src/ui-library-version.ts
104673
- var uiLibraryVersion = "0.1.5";
104917
+ var uiLibraryVersion = "0.1.6";
104674
104918
  //#endregion
104675
104919
  //#region src/hooks/use-account-unit-preferences.ts
104676
104920
  /**
@@ -105362,197 +105606,6 @@ function useDoorbellEvents(options) {
105362
105606
  };
105363
105607
  }
105364
105608
  //#endregion
105365
- //#region src/hooks/use-event-invalidation.ts
105366
- /**
105367
- * useEventInvalidation — subscribe to one or more EventBus categories
105368
- * over the unified `System.subscribeEvent` push channel and invalidate
105369
- * a React Query cache prefix when any of them fires.
105370
- *
105371
- * Lets callers drop their `refetchInterval` polling: the cache is kept
105372
- * fresh by server-pushed events instead of timer-driven refetches. The
105373
- * hook is a no-op when the WebSocket isn't available (e.g. during
105374
- * initial reconnection) — the caller is free to keep a long
105375
- * `staleTime` so React Query still serves the last good snapshot.
105376
- *
105377
- * Input shape — pass the tRPC procedure path directly:
105378
- * ✔ `['integrations']` → invalidates every `integrations.*`
105379
- * ✔ `['deviceManager', 'listAll']` → invalidates that one query
105380
- *
105381
- * The hook wraps the path into the `[[...path], ...]` form that
105382
- * @tanstack/react-query + @trpc/react-query use under the hood —
105383
- * passing a flat `['integrations']` to `invalidateQueries` directly
105384
- * would never match the actual tRPC key
105385
- * `[['integrations', 'list'], { input, type }]`. Caller doesn't have
105386
- * to know about the wrap.
105387
- *
105388
- * Reconnect resilience: when `System.reconnect()` rebuilds the
105389
- * underlying wsClient + tRPC client, the System reference doesn't
105390
- * change — but `connectionVersion` bumps. We listen via
105391
- * `subscribeConnectionEvents` so the subscription effect re-runs
105392
- * against the freshly-rebuilt tRPC client.
105393
- *
105394
- * Lives in `@dominevo/ui-library` (not in admin-ui's hooks folder)
105395
- * because addon widget bundles reach for it through the shared library.
105396
- *
105397
- * ## Replacing a poll
105398
- *
105399
- * The third argument carries what a caller needs to DROP its
105400
- * `refetchInterval`:
105401
- *
105402
- * - `deviceId` — an event that names another device is ignored. One that
105403
- * names no device at all still invalidates.
105404
- * - `input` — narrow the invalidation to the query called with that input.
105405
- * - `debounceMs` — the trailing window (default 1 s).
105406
- * - `safetyNetMs` — events are telemetry and may be dropped, so a caller
105407
- * with no poll of its own asks for a slow periodic invalidation
105408
- * ({@link LIVE_REFRESH_SAFETY_NET_MS}).
105409
- * - `enabled` — false does nothing at all (no id yet, a tab not shown).
105410
- * - `paused` — the caller holds refreshes back (an open draft, a list being
105411
- * read); `pending` says one is owed, and it is paid on resume or by
105412
- * `refreshNow()`.
105413
- *
105414
- * And for every caller: a hidden document fetches nothing. Whatever arrived
105415
- * meanwhile is paid as ONE invalidation when the document is visible again.
105416
- */
105417
- /** Trailing coalesce for event-driven invalidation — see the comment inside. */
105418
- var EVENT_INVALIDATION_COALESCE_MS = 1e3;
105419
- /**
105420
- * The slow periodic invalidation of a query that is otherwise kept fresh by
105421
- * events. An event may be dropped, so "never" is not an option; this bounds
105422
- * how long a missed one can leave the page stale.
105423
- */
105424
- var LIVE_REFRESH_SAFETY_NET_MS = 6e4;
105425
- function numericDeviceId(holder, key) {
105426
- if (typeof holder !== "object" || holder === null || !(key in holder)) return void 0;
105427
- const value = Reflect.get(holder, key);
105428
- return typeof value === "number" ? value : void 0;
105429
- }
105430
- /**
105431
- * The device an event is about: its payload's `deviceId`, else a `device`
105432
- * source's id. `undefined` when it names none.
105433
- */
105434
- function eventDeviceId(event) {
105435
- if (typeof event !== "object" || event === null) return void 0;
105436
- const fromData = "data" in event ? numericDeviceId(event.data, "deviceId") : void 0;
105437
- if (fromData !== void 0) return fromData;
105438
- if (!("source" in event)) return void 0;
105439
- const source = event.source;
105440
- if (typeof source !== "object" || source === null || !("type" in source)) return void 0;
105441
- return source.type === "device" ? numericDeviceId(source, "id") : void 0;
105442
- }
105443
- function isDocumentHidden() {
105444
- return typeof document !== "undefined" && document.visibilityState === "hidden";
105445
- }
105446
- function buildQueryKey(keyJson, inputJson, keyShape) {
105447
- const raw = JSON.parse(keyJson);
105448
- const path = Array.isArray(raw) ? raw : [];
105449
- if (keyShape === "raw") return path;
105450
- const wrapped = path.length === 1 && Array.isArray(path[0]) ? path : [path];
105451
- if (inputJson === void 0) return wrapped;
105452
- const input = JSON.parse(inputJson);
105453
- return [...wrapped, { input }];
105454
- }
105455
- function useEventInvalidation(queryKey, categories, options) {
105456
- const system = useSystem();
105457
- const queryClient = (0, _tanstack_react_query.useQueryClient)();
105458
- const deviceId = options?.deviceId;
105459
- const debounceMs = options?.debounceMs ?? EVENT_INVALIDATION_COALESCE_MS;
105460
- const safetyNetMs = options?.safetyNetMs;
105461
- const initial = options?.initial !== false;
105462
- const keyShape = options?.keyShape ?? "trpc";
105463
- const paused = options?.paused === true;
105464
- const enabled = options?.enabled !== false;
105465
- const [tick, setTick] = (0, react$1.useState)(system.connectionVersion);
105466
- (0, react$1.useEffect)(() => {
105467
- return system.subscribeConnectionEvents((state, version) => {
105468
- if (state === "connected") setTick(version);
105469
- });
105470
- }, [system]);
105471
- const key = categories.join("|");
105472
- const keyJson = JSON.stringify(queryKey);
105473
- const inputJson = options?.input === void 0 ? void 0 : JSON.stringify(options.input);
105474
- const pausedRef = (0, react$1.useRef)(paused);
105475
- pausedRef.current = paused;
105476
- const owedRef = (0, react$1.useRef)(false);
105477
- const [pending, setPending] = (0, react$1.useState)(false);
105478
- const invalidateNow = (0, react$1.useCallback)(() => {
105479
- owedRef.current = false;
105480
- setPending(false);
105481
- queryClient.invalidateQueries({ queryKey: buildQueryKey(keyJson, inputJson, keyShape) });
105482
- }, [
105483
- queryClient,
105484
- keyJson,
105485
- inputJson,
105486
- keyShape
105487
- ]);
105488
- /** Invalidate, unless nobody is looking or the caller asked to wait. */
105489
- const apply = (0, react$1.useCallback)(() => {
105490
- if (isDocumentHidden()) {
105491
- owedRef.current = true;
105492
- return;
105493
- }
105494
- if (pausedRef.current) {
105495
- owedRef.current = true;
105496
- setPending(true);
105497
- return;
105498
- }
105499
- invalidateNow();
105500
- }, [invalidateNow]);
105501
- (0, react$1.useEffect)(() => {
105502
- if (!enabled) return void 0;
105503
- const subs = [];
105504
- let openWindow = null;
105505
- const onEvent = (event) => {
105506
- if (deviceId !== void 0) {
105507
- const about = eventDeviceId(event);
105508
- if (about !== void 0 && about !== deviceId) return;
105509
- }
105510
- if (openWindow !== null) return;
105511
- openWindow = setTimeout(() => {
105512
- openWindow = null;
105513
- apply();
105514
- }, debounceMs);
105515
- };
105516
- if (initial) invalidateNow();
105517
- for (const category of key.split("|")) {
105518
- if (!category) continue;
105519
- try {
105520
- subs.push(system.subscribeEvent(category, onEvent));
105521
- } catch {}
105522
- }
105523
- const safetyNet = safetyNetMs !== void 0 && safetyNetMs > 0 ? setInterval(apply, safetyNetMs) : null;
105524
- const onVisibility = () => {
105525
- if (!isDocumentHidden() && owedRef.current) apply();
105526
- };
105527
- const visibilityTarget = typeof document === "undefined" ? null : document;
105528
- visibilityTarget?.addEventListener("visibilitychange", onVisibility);
105529
- return () => {
105530
- if (openWindow !== null) clearTimeout(openWindow);
105531
- if (safetyNet !== null) clearInterval(safetyNet);
105532
- visibilityTarget?.removeEventListener("visibilitychange", onVisibility);
105533
- for (const unsub of subs) unsub();
105534
- };
105535
- }, [
105536
- system,
105537
- key,
105538
- tick,
105539
- deviceId,
105540
- debounceMs,
105541
- safetyNetMs,
105542
- initial,
105543
- enabled,
105544
- apply,
105545
- invalidateNow
105546
- ]);
105547
- (0, react$1.useEffect)(() => {
105548
- if (!paused && owedRef.current) apply();
105549
- }, [paused, apply]);
105550
- return {
105551
- pending,
105552
- refreshNow: invalidateNow
105553
- };
105554
- }
105555
- //#endregion
105556
105609
  //#region src/hooks/use-collapsed-sections.ts
105557
105610
  function readStored(storageKey) {
105558
105611
  try {
@@ -105675,6 +105728,15 @@ function useBrokerInstances(filter = {}, opts = {}) {
105675
105728
  refetchInterval: POLL_INTERVAL_MS,
105676
105729
  enabled
105677
105730
  });
105731
+ useEventInvalidation(LIST_CAPABILITY_PROVIDERS_PATH, CAPABILITY_PROVIDER_EVENTS, {
105732
+ initial: false,
105733
+ enabled
105734
+ });
105735
+ useEventInvalidation([BROKER_INSTANCES_QUERY_KEY], INSTANCE_LIST_EVENTS, {
105736
+ initial: false,
105737
+ keyShape: "raw",
105738
+ enabled
105739
+ });
105678
105740
  const queries = (0, _tanstack_react_query.useQueries)({ queries: (0, react$1.useMemo)(() => {
105679
105741
  const holding = new Set((holders.data ?? []).map((p) => p.addonId));
105680
105742
  return (brokerProviders.data ?? []).map((p) => p.addonId).filter((id) => holding.has(id));
@@ -105931,6 +105993,7 @@ var SceneMonitorEditor = (0, react$1.lazy)(() => Promise.resolve().then(() => re
105931
105993
  /** Lazy-wrapped `PrivacyMaskSettings` — code-split off the main bundle. */
105932
105994
  var PrivacyMaskSettings = (0, react$1.lazy)(() => Promise.resolve().then(() => require("./PrivacyMaskSettings-BLM8OfT5.cjs")).then((m) => ({ default: m.PrivacyMaskSettings })));
105933
105995
  //#endregion
105996
+ exports.ADDONS_LIST_PATH = ADDONS_LIST_PATH;
105934
105997
  exports.ALARM_DISARMED = ALARM_DISARMED;
105935
105998
  exports.AMBIENT_LAYERS = AMBIENT_LAYERS;
105936
105999
  exports.ANEMOMETER_REVS_PER_MPS = ANEMOMETER_REVS_PER_MPS;
@@ -106023,6 +106086,7 @@ exports.Button = Button;
106023
106086
  exports.ButtonCard = ButtonCard;
106024
106087
  exports.ButtonGroup = ButtonGroup;
106025
106088
  exports.ButtonHeroCard = ButtonHeroCard;
106089
+ exports.CAPABILITY_PROVIDER_EVENTS = CAPABILITY_PROVIDER_EVENTS;
106026
106090
  exports.CAP_INSTANCES_QUERY_KEY = CAP_INSTANCES_QUERY_KEY;
106027
106091
  exports.CARD_GLYPHS = CARD_GLYPHS;
106028
106092
  exports.CARD_ICONS = CARD_ICONS;
@@ -106395,6 +106459,7 @@ exports.HumidifierHeroCard = HumidifierHeroCard;
106395
106459
  exports.HumidifierInlineControl = HumidifierInlineControl;
106396
106460
  exports.INPUT_COMPACT = INPUT_COMPACT;
106397
106461
  exports.INPUT_SHELL = INPUT_SHELL;
106462
+ exports.INSTANCE_LIST_EVENTS = INSTANCE_LIST_EVENTS;
106398
106463
  exports.IR_PROBE_IDLE = IR_PROBE_IDLE;
106399
106464
  exports.IR_UNKNOWN = IR_UNKNOWN;
106400
106465
  exports.IconAction = IconAction;
@@ -106423,6 +106488,7 @@ exports.LIGHT_PALETTE = LIGHT_PALETTE;
106423
106488
  exports.LIGHT_WHITE_MAX_K = LIGHT_WHITE_MAX_K;
106424
106489
  exports.LIGHT_WHITE_MIN_K = LIGHT_WHITE_MIN_K;
106425
106490
  exports.LIGHT_WHITE_STEP_K = LIGHT_WHITE_STEP_K;
106491
+ exports.LIST_CAPABILITY_PROVIDERS_PATH = LIST_CAPABILITY_PROVIDERS_PATH;
106426
106492
  exports.LIST_ROW = LIST_ROW;
106427
106493
  exports.LIVE_REFRESH_SAFETY_NET_MS = LIVE_REFRESH_SAFETY_NET_MS;
106428
106494
  exports.LQI_TONE_STROKE = LQI_TONE_STROKE;