@glasshome/sync-layer 0.7.2 → 0.8.1

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.
Files changed (58) hide show
  1. package/dist/index.d.ts +1291 -54
  2. package/dist/index.js +203 -304
  3. package/dist/service-C8H42I-Q.d.ts +459 -0
  4. package/dist/solid/index.d.ts +119 -6
  5. package/dist/solid/index.js +20 -15
  6. package/dist/{statistics-CtRfIF6D.js → statistics-DyCCTwv2.js} +83 -95
  7. package/dist/worker/worker-main.d.ts +11 -8
  8. package/dist/worker/worker-main.js +2 -3
  9. package/dist/{worker-main-C-3QM4di.js → worker-main-D_wyGAIG.js} +47 -157
  10. package/package.json +4 -4
  11. package/dist/calendar/track.d.ts +0 -19
  12. package/dist/calendar/types.d.ts +0 -32
  13. package/dist/camera/fetch.d.ts +0 -16
  14. package/dist/camera/query.d.ts +0 -15
  15. package/dist/camera/types.d.ts +0 -85
  16. package/dist/camera/webrtc.d.ts +0 -31
  17. package/dist/commands/service.d.ts +0 -53
  18. package/dist/commands/types.d.ts +0 -113
  19. package/dist/connection/adapter.d.ts +0 -48
  20. package/dist/connection/auth.d.ts +0 -126
  21. package/dist/connection/bridged.d.ts +0 -16
  22. package/dist/connection/manager.d.ts +0 -51
  23. package/dist/connection/subscription-manager.d.ts +0 -48
  24. package/dist/connection/subscriptions.d.ts +0 -31
  25. package/dist/connection/types.d.ts +0 -151
  26. package/dist/core/privileged-conn.d.ts +0 -29
  27. package/dist/core/reducers.d.ts +0 -99
  28. package/dist/core/store.d.ts +0 -100
  29. package/dist/core/types.d.ts +0 -339
  30. package/dist/demo/demo-data.d.ts +0 -24
  31. package/dist/demo/demo-provider.d.ts +0 -40
  32. package/dist/demo/energy-sim.d.ts +0 -112
  33. package/dist/energy/prefs.d.ts +0 -56
  34. package/dist/entities/area-views.d.ts +0 -32
  35. package/dist/entities/index.d.ts +0 -54
  36. package/dist/entities/views.d.ts +0 -35
  37. package/dist/history/constants.d.ts +0 -16
  38. package/dist/history/fetch.d.ts +0 -19
  39. package/dist/history/query.d.ts +0 -27
  40. package/dist/history/statistics.d.ts +0 -55
  41. package/dist/history/types.d.ts +0 -146
  42. package/dist/host-api.d.ts +0 -50
  43. package/dist/media/url.d.ts +0 -14
  44. package/dist/query/area-builder.d.ts +0 -25
  45. package/dist/query/builder.d.ts +0 -18
  46. package/dist/query/helpers.d.ts +0 -21
  47. package/dist/query/memoization.d.ts +0 -18
  48. package/dist/query/projections.d.ts +0 -74
  49. package/dist/query/types.d.ts +0 -260
  50. package/dist/solid/hooks.d.ts +0 -119
  51. package/dist/solid/indices.d.ts +0 -15
  52. package/dist/weather/fetch.d.ts +0 -19
  53. package/dist/weather/query.d.ts +0 -23
  54. package/dist/weather/types.d.ts +0 -126
  55. package/dist/worker/bridge-client.d.ts +0 -47
  56. package/dist/worker/enforcement.d.ts +0 -53
  57. package/dist/worker/protocol.d.ts +0 -129
  58. package/dist/worker/token-store.d.ts +0 -3
@@ -0,0 +1,459 @@
1
+ import { AreaEntry, DeviceEntry, Domain, EntityCategory, EntityRegistryEntry, ServiceCall, ServiceName, WsCommandType } from "@glasshome/ha-types";
2
+ //#region src/core/types.d.ts
3
+ /**
4
+ * Unique entity identifier (e.g., "light.living_room")
5
+ */
6
+ type EntityId = string;
7
+ /**
8
+ * Domain extracted from entity_id (e.g., "light")
9
+ */
10
+ type EntityDomain = string;
11
+ /**
12
+ * Unique device identifier (UUID)
13
+ */
14
+ type DeviceId = string;
15
+ /**
16
+ * Unique area identifier
17
+ */
18
+ type AreaId = string;
19
+ /**
20
+ * Floor identifier
21
+ */
22
+ type FloorId = string;
23
+ /**
24
+ * Label identifier
25
+ */
26
+ type LabelId = string;
27
+ /**
28
+ * Runtime entity state from Home Assistant
29
+ *
30
+ * This represents the live state of an entity as received
31
+ * from the WebSocket API's `get_states` command or `subscribe_entities` subscription.
32
+ */
33
+ interface HassEntity {
34
+ /** Unique entity identifier */
35
+ entity_id: EntityId;
36
+ /** Current state value (e.g., "on", "off", "23.5") */
37
+ state: string;
38
+ /** Entity attributes (brightness, temperature, etc.) */
39
+ attributes: Record<string, any>;
40
+ /** ISO 8601 timestamp of last state change */
41
+ last_changed: string;
42
+ /** ISO 8601 timestamp of last update */
43
+ last_updated: string;
44
+ /** Event context */
45
+ context: {
46
+ /** Context ID */
47
+ id: string;
48
+ /** Parent context ID */
49
+ parent_id: string | null;
50
+ /** User ID that triggered the change */
51
+ user_id: string | null;
52
+ };
53
+ }
54
+ /**
55
+ * Device registry entry
56
+ *
57
+ * @alias DeviceEntry
58
+ */
59
+ type DeviceRegistryEntry = DeviceEntry;
60
+ /**
61
+ * Area registry entry
62
+ *
63
+ * @alias AreaEntry
64
+ * @note AreaEntry uses 'id' field, not 'area_id'
65
+ */
66
+ type AreaRegistryEntry = AreaEntry;
67
+ /**
68
+ * Floor registry entry
69
+ *
70
+ * Response structure from `config/floor_registry/list`
71
+ */
72
+ interface FloorRegistryEntry {
73
+ /** Unique floor identifier */
74
+ floor_id: FloorId;
75
+ /** Floor name */
76
+ name: string;
77
+ /** Floor level (integer, 0 = ground floor) */
78
+ level: number;
79
+ /** Floor icon */
80
+ icon: string | null;
81
+ /** Floor aliases */
82
+ aliases: string[];
83
+ /** Created timestamp */
84
+ created_at: string;
85
+ /** Modified timestamp */
86
+ modified_at: string;
87
+ }
88
+ /**
89
+ * Label registry entry
90
+ *
91
+ * Response structure from `config/label_registry/list`
92
+ */
93
+ interface LabelRegistryEntry {
94
+ /** Unique label identifier */
95
+ label_id: LabelId;
96
+ /** Label name */
97
+ name: string;
98
+ /** Label color (hex) */
99
+ color: string | null;
100
+ /** Label icon */
101
+ icon: string | null;
102
+ /** Label description */
103
+ description: string | null;
104
+ /** Created timestamp */
105
+ created_at: string;
106
+ /** Modified timestamp */
107
+ modified_at: string;
108
+ }
109
+ /**
110
+ * Statistics metadata
111
+ *
112
+ * Response structure from `recorder/get_statistics_metadata`
113
+ */
114
+ interface StatisticMetadata {
115
+ /** Statistic ID */
116
+ statistic_id: string;
117
+ /** Data source */
118
+ source: string;
119
+ /** Unit of measurement */
120
+ unit_of_measurement: string | null;
121
+ /** Whether statistic has mean values */
122
+ has_mean: boolean;
123
+ /** Whether statistic has sum values */
124
+ has_sum: boolean;
125
+ /** Display name */
126
+ name: string | null;
127
+ }
128
+ /**
129
+ * Statistics data point
130
+ *
131
+ * Response structure from `recorder/statistics_during_period`
132
+ */
133
+ interface StatisticData {
134
+ /** Statistic ID */
135
+ statistic_id: string;
136
+ /** Period start (ISO 8601) */
137
+ start: string;
138
+ /** Period end (ISO 8601) */
139
+ end: string;
140
+ /** Mean value */
141
+ mean?: number;
142
+ /** Minimum value */
143
+ min?: number;
144
+ /** Maximum value */
145
+ max?: number;
146
+ /** Last reset timestamp */
147
+ last_reset?: string;
148
+ /** State value */
149
+ state?: number;
150
+ /** Sum value */
151
+ sum?: number;
152
+ }
153
+ /**
154
+ * Unified entity view combining runtime state and registry metadata
155
+ *
156
+ * This is the primary interface for working with entities in the sync-layer.
157
+ * It combines live state data with registry metadata to provide a complete
158
+ * view of an entity.
159
+ */
160
+ interface EntityView {
161
+ /** Unique entity identifier */
162
+ id: EntityId;
163
+ /** Entity domain (e.g., "light", "sensor") */
164
+ domain: EntityDomain;
165
+ /** Current state value */
166
+ state: string;
167
+ /**
168
+ * Entity attributes from Home Assistant, excluding keys that are
169
+ * surfaced as canonical resolved fields elsewhere on EntityView
170
+ * (`deviceClass`, `unitOfMeasurement`, `friendlyName`, `icon`).
171
+ * Use those fields instead of reaching into `attributes`.
172
+ */
173
+ attributes: Omit<Record<string, any>, "device_class" | "unit_of_measurement" | "friendly_name" | "icon">;
174
+ lastChanged: Date;
175
+ lastUpdated: Date;
176
+ /** Event context */
177
+ context: {
178
+ id: string;
179
+ parentId: string | null;
180
+ userId: string | null;
181
+ };
182
+ /** Entity name (from registry or friendly_name) */
183
+ name: string;
184
+ /** Friendly display name */
185
+ friendlyName: string;
186
+ /** Area ID where entity is located */
187
+ areaId: AreaId | null;
188
+ /** Device ID this entity belongs to */
189
+ deviceId: DeviceId | null;
190
+ /** Platform/integration that provides this entity */
191
+ platform: string;
192
+ /** Unique ID from integration */
193
+ uniqueId: string | null;
194
+ /** Whether entity is disabled */
195
+ isDisabled: boolean;
196
+ /** Whether entity is hidden */
197
+ isHidden: boolean;
198
+ /** Resolved icon (registry icon, attribute icon, or domain default) */
199
+ icon: string | null;
200
+ /** Icon source (registry, attribute, or default) */
201
+ iconSource: "registry" | "attribute" | "default";
202
+ /** Entity category (config, diagnostic, or null) */
203
+ entityCategory: EntityCategory | null;
204
+ /** Labels applied to this entity */
205
+ labels: LabelId[];
206
+ /** Entity aliases */
207
+ aliases: string[];
208
+ /** Device class (e.g., "temperature", "humidity") */
209
+ deviceClass?: string | null;
210
+ /** Unit of measurement */
211
+ unitOfMeasurement?: string | null;
212
+ /** Supported features bitmask */
213
+ supportedFeatures?: number;
214
+ }
215
+ /**
216
+ * Device view combining registry data with computed properties
217
+ */
218
+ interface DeviceView {
219
+ /** Unique device identifier */
220
+ id: DeviceId;
221
+ /** Device name */
222
+ name: string;
223
+ /** User-friendly name */
224
+ nameByUser: string | null;
225
+ /** Manufacturer */
226
+ manufacturer: string | null;
227
+ /** Model */
228
+ model: string | null;
229
+ /** Software version */
230
+ swVersion: string | null;
231
+ /** Area ID where device is located */
232
+ areaId: AreaId | null;
233
+ /** Configuration entry IDs */
234
+ configEntries: string[];
235
+ /** Device connections */
236
+ connections: Array<[string, string]>;
237
+ /** Device identifiers */
238
+ identifiers: Array<[string, string]>;
239
+ /** Whether device is disabled */
240
+ disabledBy: string | null;
241
+ }
242
+ /**
243
+ * Area view combining registry data with computed entities and devices
244
+ */
245
+ interface AreaView {
246
+ /** Unique area identifier */
247
+ id: AreaId;
248
+ /** Area name */
249
+ name: string;
250
+ /** Normalized area name (for searching) */
251
+ normalizedName: string;
252
+ /** Area aliases */
253
+ aliases: string[];
254
+ /** Floor ID this area belongs to */
255
+ floorId: FloorId | null;
256
+ /** Area icon */
257
+ icon: string | null;
258
+ /** Area picture */
259
+ picture: string | null;
260
+ /** Labels applied to this area */
261
+ labels: LabelId[];
262
+ /** Temperature entity ID for this area */
263
+ temperatureEntityId: EntityId | null;
264
+ /** Humidity entity ID for this area */
265
+ humidityEntityId: EntityId | null;
266
+ /** Created timestamp */
267
+ createdAt: string;
268
+ /** Last modified timestamp */
269
+ modifiedAt: string;
270
+ /** Entities in this area (direct + via devices) - uses query engine */
271
+ entities: EntityView[];
272
+ /** Devices in this area */
273
+ devices: DeviceView[];
274
+ /** Entity IDs for fast lookups */
275
+ entityIds: EntityId[];
276
+ /** Device IDs for fast lookups */
277
+ deviceIds: DeviceId[];
278
+ }
279
+ /**
280
+ * WebSocket connection state
281
+ */
282
+ type ConnectionState = "connecting" | "connected" | "disconnected" | "reconnecting" | "error";
283
+ /**
284
+ * Unsubscribe function returned by subscriptions
285
+ */
286
+ type UnsubscribeFunc = () => void;
287
+ /**
288
+ * Generic callback type
289
+ */
290
+ type Callback<T> = (data: T) => void;
291
+ /**
292
+ * Predicate function for filtering
293
+ */
294
+ type PredicateFunc<T> = (item: T) => boolean;
295
+ /**
296
+ * Mapping function for transformations
297
+ */
298
+ type MapFunc<T, R> = (item: T) => R;
299
+ /**
300
+ * Extract domain from entity ID
301
+ */
302
+ declare function extractDomain(entityId: EntityId): EntityDomain;
303
+ //#endregion
304
+ //#region src/calendar/types.d.ts
305
+ /**
306
+ * One calendar event as HA serializes it over `calendar/event/subscribe`:
307
+ * dates/datetimes are ISO strings (date-only for all-day events), and
308
+ * None-valued fields are omitted.
309
+ */
310
+ interface CalendarEvent {
311
+ start: string;
312
+ end: string;
313
+ summary: string;
314
+ description?: string;
315
+ location?: string;
316
+ uid?: string;
317
+ recurrence_id?: string;
318
+ rrule?: string;
319
+ }
320
+ /** Live event window for one calendar entity, held in the store. */
321
+ interface CalendarEventsData {
322
+ entityId: EntityId;
323
+ events: CalendarEvent[];
324
+ /** True until the first snapshot for the current subscription arrives. */
325
+ loading: boolean;
326
+ error: Error | null;
327
+ /** Subscribed window bounds (ISO). */
328
+ start: string;
329
+ end: string;
330
+ }
331
+ /** Per-tracker window request, in whole days relative to now. */
332
+ interface CalendarWindowOptions {
333
+ daysBehind?: number;
334
+ daysAhead?: number;
335
+ }
336
+ //#endregion
337
+ //#region src/commands/types.d.ts
338
+ /**
339
+ * Service call target
340
+ *
341
+ * Defines what entities the service call should affect
342
+ */
343
+ interface ServiceTarget {
344
+ /** Entity IDs */
345
+ entity_id?: string | string[];
346
+ /** Device IDs */
347
+ device_id?: string | string[];
348
+ /** Area IDs */
349
+ area_id?: string | string[];
350
+ }
351
+ /**
352
+ * Service call with full context
353
+ */
354
+ interface ServiceCallContext {
355
+ /** Domain (e.g., "light", "switch") */
356
+ domain: Domain;
357
+ /** Service name (e.g., "turn_on", "toggle") */
358
+ service: ServiceName<Domain>;
359
+ /** Service data */
360
+ serviceData?: ServiceCall<Domain, ServiceName<Domain>>;
361
+ /** Target entities/devices/areas */
362
+ target?: ServiceTarget;
363
+ }
364
+ /**
365
+ * Command success result
366
+ */
367
+ interface CommandSuccess<T = unknown> {
368
+ success: true;
369
+ result: T;
370
+ }
371
+ /**
372
+ * Command error result
373
+ */
374
+ interface CommandError {
375
+ success: false;
376
+ error: {
377
+ code: string;
378
+ message: string;
379
+ };
380
+ }
381
+ /**
382
+ * Command result (success or error)
383
+ */
384
+ type CommandResult<T = unknown> = CommandSuccess<T> | CommandError;
385
+ /**
386
+ * Entity registry update fields
387
+ *
388
+ * Fields that can be updated in the entity registry
389
+ */
390
+ interface EntityUpdateFields {
391
+ /** Friendly name */
392
+ name?: string;
393
+ /** Icon */
394
+ icon?: string;
395
+ /** Area ID */
396
+ area_id?: string | null;
397
+ /** Disabled by (null to enable) */
398
+ disabled_by?: string | null;
399
+ /** Hidden by (null to unhide) */
400
+ hidden_by?: string | null;
401
+ }
402
+ /**
403
+ * Command execution options
404
+ */
405
+ interface CommandOptions {
406
+ /** Timeout in milliseconds */
407
+ timeout?: number;
408
+ /** Retry on failure */
409
+ retry?: boolean;
410
+ /** Number of retry attempts */
411
+ retries?: number;
412
+ }
413
+ //#endregion
414
+ //#region src/commands/service.d.ts
415
+ /**
416
+ * Call a Home Assistant service
417
+ */
418
+ declare function callService<D extends Domain, S extends ServiceName<D>>(domain: D, service: S, serviceData?: ServiceCall<D, S>, target?: ServiceTarget): Promise<void>;
419
+ /**
420
+ * Turn on entity or entities
421
+ */
422
+ declare function turnOn(entityId: EntityId | EntityId[], serviceData?: Record<string, any>): Promise<void>;
423
+ /**
424
+ * Turn off entity or entities
425
+ */
426
+ declare function turnOff(entityId: EntityId | EntityId[], serviceData?: Record<string, any>): Promise<void>;
427
+ /**
428
+ * Toggle entity or entities
429
+ */
430
+ declare function toggle(entityId: EntityId | EntityId[], serviceData?: Record<string, any>): Promise<void>;
431
+ /**
432
+ * Update entity registry entry
433
+ */
434
+ declare function updateEntity(entityId: EntityId, updates: EntityUpdateFields): Promise<any>;
435
+ /**
436
+ * Send a generic WebSocket command
437
+ */
438
+ declare function sendCommand<T = unknown>(command: {
439
+ type: WsCommandType | string;
440
+ [key: string]: unknown;
441
+ }): Promise<T>;
442
+ /**
443
+ * Execute multiple service calls in parallel
444
+ */
445
+ declare function batchServiceCalls(calls: Array<{
446
+ domain: Domain;
447
+ service: ServiceName<Domain>;
448
+ serviceData?: ServiceCall<Domain, ServiceName<Domain>>;
449
+ target?: ServiceTarget;
450
+ }>): Promise<void>;
451
+ /**
452
+ * Execute multiple entity updates in parallel
453
+ */
454
+ declare function batchEntityUpdates(updates: Array<{
455
+ entityId: EntityId;
456
+ updates: EntityUpdateFields;
457
+ }>): Promise<any[]>;
458
+ //#endregion
459
+ export { HassEntity as A, DeviceRegistryEntry as C, EntityView as D, EntityId as E, StatisticData as F, StatisticMetadata as I, UnsubscribeFunc as L, LabelRegistryEntry as M, MapFunc as N, FloorId as O, PredicateFunc as P, extractDomain as R, DeviceId as S, EntityDomain as T, AreaId as _, toggle as a, Callback as b, updateEntity as c, EntityUpdateFields as d, ServiceCallContext as f, CalendarWindowOptions as g, CalendarEventsData as h, sendCommand as i, LabelId as j, FloorRegistryEntry as k, CommandOptions as l, CalendarEvent as m, batchServiceCalls as n, turnOff as o, ServiceTarget as p, callService as r, turnOn as s, batchEntityUpdates as t, CommandResult as u, AreaRegistryEntry as v, DeviceView as w, ConnectionState as x, AreaView as y };
@@ -1,10 +1,123 @@
1
+ import { a as toggle, g as CalendarWindowOptions, h as CalendarEventsData, o as turnOff, r as callService, s as turnOn } from "../service-C8H42I-Q.js";
2
+ import { Accessor, Resource } from "solid-js";
3
+ import { HassConfig, HassUnitSystem } from "@glasshome/ha-types";
4
+ import { AreaView, CameraStreamData, ConnectionState, EntityHistoryData, EntityView, GlassHomeState, HassEntity, StatisticValue, StatisticsQueryOptions, WeatherForecastsData } from "@glasshome/sync-layer";
5
+ //#region src/solid/hooks.d.ts
1
6
  /**
2
- * SolidJS Adapter for @glasshome/sync-layer
7
+ * Get a reactive EntityView for an entity ID.
3
8
  *
4
- * Thin reactive layer over the native SolidJS store.
5
- * Import from `@glasshome/sync-layer/solid`.
9
+ * Registers the entity for live updates via the subscription manager.
10
+ * Only re-runs when the specific entity's data changes.
11
+ */
12
+ declare function useEntity(entityId: Accessor<string> | string): Accessor<EntityView | undefined>;
13
+ /**
14
+ * Get reactive EntityViews for multiple entity IDs.
15
+ *
16
+ * Registers all entity IDs for live updates via the subscription manager.
17
+ */
18
+ declare function useEntities(entityIds: Accessor<string[]>): Accessor<EntityView[]>;
19
+ /**
20
+ * Get raw HassEntity state (without EntityView transformation).
21
+ *
22
+ * Registers the entity for live updates via the subscription manager.
23
+ */
24
+ declare function useEntityState(entityId: Accessor<string> | string): Accessor<HassEntity | undefined>;
25
+ /**
26
+ * Get reactive connection status.
27
+ */
28
+ declare function useConnection(): {
29
+ status: Accessor<ConnectionState>;
30
+ isConnected: Accessor<boolean>;
31
+ };
32
+ /** Reactive Home Assistant core config (null until loaded). */
33
+ declare function useHassConfig(): Accessor<HassConfig | null>;
34
+ /** Reactive HA unit system (length/mass/temperature/volume), or null until loaded. */
35
+ declare function useUnitSystem(): Accessor<HassUnitSystem | null>;
36
+ /** Reactive temperature unit from HA config, including the degree sign. Defaults to "°C". */
37
+ declare function useTemperatureUnit(): Accessor<string>;
38
+ /** Reactive UI locale (BCP 47 tag) from HA config. Defaults to "en". */
39
+ declare function useLocale(): Accessor<string>;
40
+ /** Reactive currency (ISO 4217) from HA config. Defaults to "USD". */
41
+ declare function useCurrency(): Accessor<string>;
42
+ /**
43
+ * Get all service call functions.
44
+ */
45
+ declare function useService(): {
46
+ callService: typeof callService;
47
+ turnOn: typeof turnOn;
48
+ turnOff: typeof turnOff;
49
+ toggle: typeof toggle;
50
+ };
51
+ /** Get turnOn command function */
52
+ declare function useTurnOn(): typeof turnOn;
53
+ /** Get turnOff command function */
54
+ declare function useTurnOff(): typeof turnOff;
55
+ /** Get toggle command function */
56
+ declare function useToggle(): typeof toggle;
57
+ /**
58
+ * Get reactive list of all area views.
59
+ */
60
+ declare function useAreas(): Accessor<AreaView[]>;
61
+ /**
62
+ * Get a reactive AreaView for a specific area.
63
+ *
64
+ * Registers all entities in the area for live updates.
65
+ */
66
+ declare function useArea(areaId: Accessor<string> | string): Accessor<AreaView | undefined>;
67
+ /**
68
+ * Get reactive entity history data.
69
+ *
70
+ * History data is populated into the store via subscriptions;
71
+ * this hook simply reads it reactively.
72
+ */
73
+ declare function useEntityHistory(entityId: Accessor<string> | string): Accessor<EntityHistoryData | undefined>;
74
+ /**
75
+ * Get reactive long-term statistics for a statistic id.
76
+ *
77
+ * Fetches via `recorder/statistics_during_period` and re-fetches whenever the
78
+ * statistic id or options change. The returned Resource exposes `.loading`
79
+ * and `.error` alongside the value accessor.
80
+ */
81
+ declare function useEntityStatistics(statisticId: Accessor<string> | string, options: Accessor<StatisticsQueryOptions> | StatisticsQueryOptions): Resource<StatisticValue[]>;
82
+ /**
83
+ * Get reactive camera stream data.
84
+ */
85
+ declare function useCamera(entityId: Accessor<string> | string): {
86
+ stream: Accessor<CameraStreamData | null>;
87
+ refresh: () => void;
88
+ };
89
+ /**
90
+ * Live calendar events for one calendar entity.
91
+ *
92
+ * Tracks the entity on mount (opening or joining the shared
93
+ * `calendar/event/subscribe`) and untracks on cleanup; HA pushes the initial
94
+ * snapshot and every later change, so the accessor is reactive with no
95
+ * polling. `undefined` until the subscription is established.
96
+ */
97
+ declare function useCalendarEvents(entityId: Accessor<string> | string, options?: CalendarWindowOptions): Accessor<CalendarEventsData | undefined>;
98
+ /**
99
+ * Get reactive weather forecast data.
100
+ */
101
+ declare function useForecast(entityId: Accessor<string> | string): Accessor<WeatherForecastsData | undefined>;
102
+ /**
103
+ * Escape hatch for direct store access with a selector.
6
104
  *
7
- * @packageDocumentation
105
+ * Use when no specific hook exists for your data need.
8
106
  */
9
- export { useArea, useAreas, useCalendarEvents, useCamera, useConnection, useCurrency, useEntities, useEntity, useEntityHistory, useEntityState, useEntityStatistics, useForecast, useHassConfig, useLocale, useService, useStore, useTemperatureUnit, useToggle, useTurnOff, useTurnOn, useUnitSystem, } from "./hooks";
10
- export { allEntityIds, byArea, byDevice, byDomain, byFloor, byLabel, } from "./indices";
107
+ declare function useStore<T>(selector: (s: GlassHomeState) => T): Accessor<T>;
108
+ //#endregion
109
+ //#region src/solid/indices.d.ts
110
+ /** Entity IDs grouped by domain (e.g., "light" -> ["light.living_room", ...]) */
111
+ declare const byDomain: Accessor<Record<string, string[]>>;
112
+ /** Entity IDs grouped by area (via entity registry area_id) */
113
+ declare const byArea: Accessor<Record<string, string[]>>;
114
+ /** Entity IDs grouped by device (via entity registry device_id) */
115
+ declare const byDevice: Accessor<Record<string, string[]>>;
116
+ /** Entity IDs grouped by floor (device -> area -> floor chain) */
117
+ declare const byFloor: Accessor<Record<string, string[]>>;
118
+ /** Entity IDs grouped by label */
119
+ declare const byLabel: Accessor<Record<string, string[]>>;
120
+ /** All entity IDs currently in the store */
121
+ declare const allEntityIds: Accessor<string[]>;
122
+ //#endregion
123
+ export { allEntityIds, byArea, byDevice, byDomain, byFloor, byLabel, useArea, useAreas, useCalendarEvents, useCamera, useConnection, useCurrency, useEntities, useEntity, useEntityHistory, useEntityState, useEntityStatistics, useForecast, useHassConfig, useLocale, useService, useStore, useTemperatureUnit, useToggle, useTurnOff, useTurnOn, useUnitSystem };
@@ -1,8 +1,19 @@
1
- import { buildAreaView, callService, entityViewEquals, extractDomain, fetchStatisticsDuringPeriod, getAreaViews, getEntityView, isDemoMode, privilegedConn, registerEntity, state, toggle, trackCalendarEvents, turnOff, turnOn } from "../statistics-CtRfIF6D.js";
1
+ import { A as extractDomain, B as state, I as trackCalendarEvents, L as privilegedConn, M as registerEntity, _ as turnOff, c as entityViewEquals, g as toggle, m as callService, o as getAreaViews, r as buildAreaView, t as fetchStatisticsDuringPeriod, u as getEntityView, v as turnOn, x as isDemoMode } from "../statistics-DyCCTwv2.js";
2
2
  import { createEffect, createMemo, createResource, onCleanup } from "solid-js";
3
-
4
3
  //#region src/solid/hooks.ts
5
4
  /**
5
+ * SolidJS Hooks for Sync-Layer
6
+ *
7
+ * Thin createMemo wrappers over the native SolidJS store.
8
+ * Since the store IS SolidJS (Plan 01 replaced Zustand with createStore),
9
+ * no subscription bridge is needed -- SolidJS auto-tracks fine-grained
10
+ * reactivity through the store proxy.
11
+ *
12
+ * Every hook is just `createMemo(() => state.something)`.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+ /**
6
17
  * Get a reactive EntityView for an entity ID.
7
18
  *
8
19
  * Registers the entity for live updates via the subscription manager.
@@ -29,8 +40,7 @@ function useEntity(entityId) {
29
40
  */
30
41
  function useEntities(entityIds) {
31
42
  createEffect(() => {
32
- const ids = entityIds();
33
- const unregisters = ids.map((id) => registerEntity(id));
43
+ const unregisters = entityIds().map((id) => registerEntity(id));
34
44
  onCleanup(() => {
35
45
  for (const unreg of unregisters) unreg();
36
46
  });
@@ -62,11 +72,9 @@ function useEntityState(entityId) {
62
72
  * Get reactive connection status.
63
73
  */
64
74
  function useConnection() {
65
- const status = createMemo(() => state.connectionState);
66
- const isConnected = createMemo(() => state.connectionState === "connected");
67
75
  return {
68
- status,
69
- isConnected
76
+ status: createMemo(() => state.connectionState),
77
+ isConnected: createMemo(() => state.connectionState === "connected")
70
78
  };
71
79
  }
72
80
  /** Reactive Home Assistant core config (null until loaded). */
@@ -140,7 +148,7 @@ function useArea(areaId) {
140
148
  try {
141
149
  return buildAreaView(id);
142
150
  } catch {
143
- return void 0;
151
+ return;
144
152
  }
145
153
  });
146
154
  createEffect(() => {
@@ -168,7 +176,7 @@ function useEntityHistory(entityId) {
168
176
  * sends a message, so this only satisfies the signature.
169
177
  */
170
178
  const DEMO_STATS_CONNECTION = { sendMessagePromise() {
171
- return Promise.reject(new Error("demo mode: no connection"));
179
+ return Promise.reject(/* @__PURE__ */ new Error("demo mode: no connection"));
172
180
  } };
173
181
  /**
174
182
  * Get reactive long-term statistics for a statistic id.
@@ -187,8 +195,7 @@ function useEntityStatistics(statisticId, options) {
187
195
  if (!id) return [];
188
196
  const conn = privilegedConn();
189
197
  if (!conn && !isDemoMode()) return [];
190
- const result = await fetchStatisticsDuringPeriod(conn ?? DEMO_STATS_CONNECTION, [id], opts);
191
- return result[id] ?? [];
198
+ return (await fetchStatisticsDuringPeriod(conn ?? DEMO_STATS_CONNECTION, [id], opts))[id] ?? [];
192
199
  });
193
200
  return data;
194
201
  }
@@ -235,7 +242,6 @@ function useForecast(entityId) {
235
242
  function useStore(selector) {
236
243
  return createMemo(() => selector(state));
237
244
  }
238
-
239
245
  //#endregion
240
246
  //#region src/solid/indices.ts
241
247
  function groupBy(items, keyFn) {
@@ -272,6 +278,5 @@ const byLabel = () => {
272
278
  };
273
279
  /** All entity IDs currently in the store */
274
280
  const allEntityIds = () => Object.keys(state.entities);
275
-
276
281
  //#endregion
277
- export { allEntityIds, byArea, byDevice, byDomain, byFloor, byLabel, useArea, useAreas, useCalendarEvents, useCamera, useConnection, useCurrency, useEntities, useEntity, useEntityHistory, useEntityState, useEntityStatistics, useForecast, useHassConfig, useLocale, useService, useStore, useTemperatureUnit, useToggle, useTurnOff, useTurnOn, useUnitSystem };
282
+ export { allEntityIds, byArea, byDevice, byDomain, byFloor, byLabel, useArea, useAreas, useCalendarEvents, useCamera, useConnection, useCurrency, useEntities, useEntity, useEntityHistory, useEntityState, useEntityStatistics, useForecast, useHassConfig, useLocale, useService, useStore, useTemperatureUnit, useToggle, useTurnOff, useTurnOn, useUnitSystem };