@glasshome/sync-layer 0.5.0 → 0.7.0
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/dist/calendar/track.d.ts +19 -0
- package/dist/calendar/types.d.ts +32 -0
- package/dist/core/privileged-conn.d.ts +29 -0
- package/dist/core/store.d.ts +3 -2
- package/dist/host-api.d.ts +50 -0
- package/dist/index.d.ts +16 -7
- package/dist/index.js +168 -2369
- package/dist/solid/hooks.d.ts +11 -1
- package/dist/solid/index.d.ts +1 -1
- package/dist/solid/index.js +21 -3
- package/dist/statistics-CtRfIF6D.js +2175 -0
- package/dist/worker/protocol.d.ts +4 -0
- package/dist/worker/worker-main.js +1 -1
- package/dist/{worker-main-Cf-k4f2N.js → worker-main-C-3QM4di.js} +5 -3
- package/package.json +2 -2
package/dist/solid/hooks.d.ts
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
import type { HassConfig, HassUnitSystem } from "@glasshome/ha-types";
|
|
14
14
|
import type { Accessor, Resource } from "solid-js";
|
|
15
15
|
import type { AreaView, CameraStreamData, ConnectionState, EntityHistoryData, EntityView, GlassHomeState, HassEntity, StatisticsQueryOptions, StatisticValue, WeatherForecastsData } from "@glasshome/sync-layer";
|
|
16
|
-
import { callService, toggle, turnOff, turnOn } from "
|
|
16
|
+
import { callService, toggle, turnOff, turnOn } from "../commands/service";
|
|
17
|
+
import type { CalendarEventsData, CalendarWindowOptions } from "../calendar/types";
|
|
17
18
|
/**
|
|
18
19
|
* Get a reactive EntityView for an entity ID.
|
|
19
20
|
*
|
|
@@ -97,6 +98,15 @@ export declare function useCamera(entityId: Accessor<string> | string): {
|
|
|
97
98
|
stream: Accessor<CameraStreamData | null>;
|
|
98
99
|
refresh: () => void;
|
|
99
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* Live calendar events for one calendar entity.
|
|
103
|
+
*
|
|
104
|
+
* Tracks the entity on mount (opening or joining the shared
|
|
105
|
+
* `calendar/event/subscribe`) and untracks on cleanup; HA pushes the initial
|
|
106
|
+
* snapshot and every later change, so the accessor is reactive with no
|
|
107
|
+
* polling. `undefined` until the subscription is established.
|
|
108
|
+
*/
|
|
109
|
+
export declare function useCalendarEvents(entityId: Accessor<string> | string, options?: CalendarWindowOptions): Accessor<CalendarEventsData | undefined>;
|
|
100
110
|
/**
|
|
101
111
|
* Get reactive weather forecast data.
|
|
102
112
|
*/
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export { useArea, useAreas, useCamera, useConnection, useCurrency, useEntities, useEntity, useEntityHistory, useEntityState, useEntityStatistics, useForecast, useHassConfig, useLocale, useService, useStore, useTemperatureUnit, useToggle, useTurnOff, useTurnOn, useUnitSystem, } from "./hooks";
|
|
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
10
|
export { allEntityIds, byArea, byDevice, byDomain, byFloor, byLabel, } from "./indices";
|
package/dist/solid/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { buildAreaView, callService, entityViewEquals, extractDomain, fetchStatisticsDuringPeriod, getAreaViews, getEntityView, isDemoMode, privilegedConn, registerEntity, state, toggle, trackCalendarEvents, turnOff, turnOn } from "../statistics-CtRfIF6D.js";
|
|
1
2
|
import { createEffect, createMemo, createResource, onCleanup } from "solid-js";
|
|
2
|
-
import { buildAreaView, callService, entityViewEquals, extractDomain, fetchStatisticsDuringPeriod, getAreaViews, getEntityView, isDemoMode, registerEntity, state, toggle, turnOff, turnOn } from "@glasshome/sync-layer";
|
|
3
3
|
|
|
4
4
|
//#region src/solid/hooks.ts
|
|
5
5
|
/**
|
|
@@ -185,7 +185,7 @@ function useEntityStatistics(statisticId, options) {
|
|
|
185
185
|
options: getOptions()
|
|
186
186
|
}), async ({ id, options: opts }) => {
|
|
187
187
|
if (!id) return [];
|
|
188
|
-
const conn =
|
|
188
|
+
const conn = privilegedConn();
|
|
189
189
|
if (!conn && !isDemoMode()) return [];
|
|
190
190
|
const result = await fetchStatisticsDuringPeriod(conn ?? DEMO_STATS_CONNECTION, [id], opts);
|
|
191
191
|
return result[id] ?? [];
|
|
@@ -203,6 +203,24 @@ function useCamera(entityId) {
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
|
+
* Live calendar events for one calendar entity.
|
|
207
|
+
*
|
|
208
|
+
* Tracks the entity on mount (opening or joining the shared
|
|
209
|
+
* `calendar/event/subscribe`) and untracks on cleanup; HA pushes the initial
|
|
210
|
+
* snapshot and every later change, so the accessor is reactive with no
|
|
211
|
+
* polling. `undefined` until the subscription is established.
|
|
212
|
+
*/
|
|
213
|
+
function useCalendarEvents(entityId, options) {
|
|
214
|
+
const getId = typeof entityId === "function" ? entityId : () => entityId;
|
|
215
|
+
createEffect(() => {
|
|
216
|
+
const id = getId();
|
|
217
|
+
if (!id) return;
|
|
218
|
+
const untrack = trackCalendarEvents(id, options);
|
|
219
|
+
onCleanup(untrack);
|
|
220
|
+
});
|
|
221
|
+
return createMemo(() => state.calendars[getId()]);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
206
224
|
* Get reactive weather forecast data.
|
|
207
225
|
*/
|
|
208
226
|
function useForecast(entityId) {
|
|
@@ -256,4 +274,4 @@ const byLabel = () => {
|
|
|
256
274
|
const allEntityIds = () => Object.keys(state.entities);
|
|
257
275
|
|
|
258
276
|
//#endregion
|
|
259
|
-
export { allEntityIds, byArea, byDevice, byDomain, byFloor, byLabel, useArea, useAreas, useCamera, useConnection, useCurrency, useEntities, useEntity, useEntityHistory, useEntityState, useEntityStatistics, useForecast, useHassConfig, useLocale, useService, useStore, useTemperatureUnit, useToggle, useTurnOff, useTurnOn, useUnitSystem };
|
|
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 };
|