@glasshome/sync-layer 0.1.12 → 0.1.13

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.
@@ -179,9 +179,6 @@ function useStore(selector) {
179
179
 
180
180
  //#endregion
181
181
  //#region src/solid/indices.ts
182
- /**
183
- * Group items by a key function
184
- */
185
182
  function groupBy(items, keyFn) {
186
183
  const result = {};
187
184
  for (const item of items) {
@@ -190,26 +187,14 @@ function groupBy(items, keyFn) {
190
187
  }
191
188
  return result;
192
189
  }
193
- /**
194
- * Create a lazily-initialized memo. The actual createMemo runs on first
195
- * access, inside whichever Solid root is current at that point.
196
- * This avoids top-level createMemo calls that execute outside any root.
197
- */
198
- function lazyMemo(fn) {
199
- let memo;
200
- return () => {
201
- if (!memo) memo = createMemo(fn);
202
- return memo();
203
- };
204
- }
205
190
  /** Entity IDs grouped by domain (e.g., "light" -> ["light.living_room", ...]) */
206
- const byDomain = lazyMemo(() => groupBy(Object.keys(state.entities), (id) => extractDomain(id)));
191
+ const byDomain = () => groupBy(Object.keys(state.entities), (id) => extractDomain(id));
207
192
  /** Entity IDs grouped by area (via entity registry area_id) */
208
- const byArea = lazyMemo(() => groupBy(Object.keys(state.entityRegistry), (id) => state.entityRegistry[id]?.area_id ?? null));
193
+ const byArea = () => groupBy(Object.keys(state.entityRegistry), (id) => state.entityRegistry[id]?.area_id ?? null);
209
194
  /** Entity IDs grouped by device (via entity registry device_id) */
210
- const byDevice = lazyMemo(() => groupBy(Object.keys(state.entityRegistry), (id) => state.entityRegistry[id]?.device_id ?? null));
195
+ const byDevice = () => groupBy(Object.keys(state.entityRegistry), (id) => state.entityRegistry[id]?.device_id ?? null);
211
196
  /** Entity IDs grouped by floor (device -> area -> floor chain) */
212
- const byFloor = lazyMemo(() => {
197
+ const byFloor = () => {
213
198
  const result = {};
214
199
  for (const [entityId, reg] of Object.entries(state.entityRegistry)) if (reg.device_id) {
215
200
  const device = state.devices[reg.device_id];
@@ -219,15 +204,15 @@ const byFloor = lazyMemo(() => {
219
204
  }
220
205
  }
221
206
  return result;
222
- });
207
+ };
223
208
  /** Entity IDs grouped by label */
224
- const byLabel = lazyMemo(() => {
209
+ const byLabel = () => {
225
210
  const result = {};
226
211
  for (const [entityId, reg] of Object.entries(state.entityRegistry)) for (const label of reg.labels ?? []) (result[label] ??= []).push(entityId);
227
212
  return result;
228
- });
213
+ };
229
214
  /** All entity IDs currently in the store */
230
- const allEntityIds = lazyMemo(() => Object.keys(state.entities));
215
+ const allEntityIds = () => Object.keys(state.entities);
231
216
 
232
217
  //#endregion
233
218
  export { allEntityIds, byArea, byDevice, byDomain, byFloor, byLabel, useArea, useAreas, useCamera, useConnection, useEntities, useEntity, useEntityHistory, useEntityState, useForecast, useService, useStore, useToggle, useTurnOff, useTurnOn };
@@ -1,4 +1,5 @@
1
- /** Reactive derived entity indices — lazily created inside the caller's root. */
1
+ /** Reactive derived entity indices. Each call reads from the SolidJS store directly,
2
+ * so consumers wrap in createMemo within their own reactive root for memoization. */
2
3
  import type { Accessor } from "solid-js";
3
4
  /** Entity IDs grouped by domain (e.g., "light" -> ["light.living_room", ...]) */
4
5
  export declare const byDomain: Accessor<Record<string, string[]>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/sync-layer",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Type-safe, reactive state synchronization layer for Home Assistant",
5
5
  "repository": {
6
6
  "type": "git",