@glasshome/widget-sdk 1.14.2 → 1.15.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.
@@ -56,6 +56,14 @@ var e = "https://glasshome.app/docs/widget-sdk/config", t = [
56
56
  docsUrl: "https://glasshome.app/docs/widget-styling#importing-ui-components",
57
57
  sourcePattern: "from\\s+[\"']@glasshome/ui(/[^\"']*)?[\"']"
58
58
  },
59
+ {
60
+ id: "iconify-icon",
61
+ since: "1.15.0",
62
+ removeIn: "2.0.0",
63
+ replacement: "<Icon icon=\"prefix:name\" /> from \"@glasshome/widget-sdk\"",
64
+ docsUrl: e,
65
+ sourcePattern: "(?:from|import)\\s+[\"']@?iconify-icon(/solid)?[\"']"
66
+ },
59
67
  {
60
68
  id: "raw-zod-config",
61
69
  since: "1.4.0",
@@ -44,6 +44,8 @@ type ChoiceOpts<T extends string> = {
44
44
  title: string;
45
45
  description?: string;
46
46
  default?: T;
47
+ /** Display names for the options; the raw value shows without them. */
48
+ labels?: Partial<Record<T, string>>;
47
49
  };
48
50
  type EntitiesOpts = {
49
51
  title?: string;
@@ -68,6 +70,15 @@ declare function choice<const T extends string>(values: readonly T[], o: ChoiceO
68
70
  declare function choice<const T extends string>(values: readonly T[], o: ChoiceOpts<T>): z.ZodOptional<z.ZodEnum<{
69
71
  [K in T]: K;
70
72
  }>>;
73
+ type ChoicesOpts<T extends string> = {
74
+ title: string;
75
+ description?: string;
76
+ default?: readonly T[];
77
+ labels?: Partial<Record<T, string>>;
78
+ };
79
+ declare function choices<const T extends string>(values: readonly T[], o: ChoicesOpts<T>): z.ZodDefault<z.ZodArray<z.ZodEnum<{
80
+ [K in T]: K;
81
+ }>>>;
71
82
  declare function entities(domain: string, o?: EntitiesOpts): z.ZodDefault<z.ZodArray<z.ZodString>>;
72
83
  declare function entity(domain: string, o?: EntitiesOpts): z.ZodDefault<z.ZodArray<z.ZodString>>;
73
84
  declare function area(o?: {
@@ -79,10 +90,12 @@ declare function area(o?: {
79
90
  */
80
91
  declare function icon(o: {
81
92
  title?: string;
93
+ description?: string;
82
94
  default: string;
83
95
  }): z.ZodDefault<z.ZodString>;
84
96
  declare function icon(o?: {
85
97
  title?: string;
98
+ description?: string;
86
99
  }): z.ZodOptional<z.ZodString>;
87
100
  /**
88
101
  * Image id (an opaque handle, not a URL). The host renders its picker and
@@ -141,6 +154,7 @@ export declare const field: {
141
154
  number: typeof number;
142
155
  toggle: typeof toggle;
143
156
  choice: typeof choice;
157
+ choices: typeof choices;
144
158
  entities: typeof entities;
145
159
  entity: typeof entity;
146
160
  area: typeof area;
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * Hooks for widget development: context, dialog, entity group.
5
5
  */
6
- export { type ReactiveWidgetContext, type ServiceCallFn, useWidgetContext, WidgetCtx, type WidgetDimensions, } from "./use-widget-context";
6
+ export { type ReactiveWidgetContext, type ServiceCallFn, useWidgetContext, WidgetCtx, type WidgetDashboard, type WidgetViewer, type WidgetDimensions, } from "./use-widget-context";
7
+ export { useWidgetDashboard } from "./use-widget-dashboard";
8
+ export { useWidgetViewer } from "./use-widget-viewer";
7
9
  export { useWidgetDimensions, type WidgetDimensionsAccessor, WidgetSizeCtx, } from "./use-widget-dimensions";
8
10
  export { useIntersectionPause } from "./use-intersection-pause";
9
11
  export { useReducedMotion } from "./use-reduced-motion";
@@ -11,6 +11,11 @@ export interface WidgetDimensions {
11
11
  width: number;
12
12
  height: number;
13
13
  }
14
+ export interface WidgetDashboard {
15
+ name: string;
16
+ icon: string;
17
+ areaId: string | null;
18
+ }
14
19
  /** Capability-routed service call: an RPC into the host's HA bridge worker,
15
20
  validated there against the widget's granted capabilities. Pass
16
21
  `{ returnResponse: true }` for services that return data (e.g.
@@ -19,6 +24,10 @@ export interface WidgetDimensions {
19
24
  export type ServiceCallFn = (domain: string, service: string, serviceData?: Record<string, unknown>, target?: Record<string, unknown>, options?: {
20
25
  returnResponse?: boolean;
21
26
  }) => Promise<unknown>;
27
+ export interface WidgetViewer {
28
+ /** The signed-in person's name, or null for a paired screen. */
29
+ name: string | null;
30
+ }
22
31
  export interface ReactiveWidgetContext {
23
32
  updateConfig: (config: Record<string, unknown>) => void;
24
33
  /**
@@ -33,6 +42,10 @@ export interface ReactiveWidgetContext {
33
42
  /** Present when the host mounts the widget; the service hooks route
34
43
  through it. Absent in previews/tests (direct sync-layer fallback). */
35
44
  callService?: ServiceCallFn;
45
+ /** The dashboard this instance sits on. Absent on hosts that predate this field. */
46
+ dashboard?: () => WidgetDashboard;
47
+ /** Who is looking. Absent on hosts that predate this field. */
48
+ viewer?: () => WidgetViewer;
36
49
  }
37
50
  export declare const WidgetCtx: import("solid-js").Context<ReactiveWidgetContext | undefined>;
38
51
  export declare function useWidgetContext(): ReactiveWidgetContext;
@@ -0,0 +1,2 @@
1
+ import { type WidgetDashboard } from "./use-widget-context";
2
+ export declare function useWidgetDashboard(): () => WidgetDashboard;
@@ -0,0 +1,4 @@
1
+ import { type WidgetViewer } from "./use-widget-context";
2
+ /** Who is looking. A paired screen belongs to a room, not to a person, so it
3
+ * reads as nobody and nothing greets it by name. */
4
+ export declare function useWidgetViewer(): () => WidgetViewer;
@@ -37,7 +37,7 @@ export { WidgetTitle } from "./components/WidgetTitle";
37
37
  export { WidgetValue } from "./components/WidgetValue";
38
38
  export { WidgetSliderFill } from "./backgrounds/WidgetSliderFill";
39
39
  export { WidgetDialog, type WidgetDialogProps, type WidgetDialogTab } from "./dialogs";
40
- export { type AggregationPreset, type ReactiveWidgetContext, type ServiceCallFn, type UseWidgetEntityGroupOptions, type UseWidgetEntityGroupResult, useIntersectionPause, useReducedMotion, useWidgetContext, useWidgetDialog, useWidgetDimensions, useWidgetEntityGroup, WidgetCtx, type WidgetDialogReturn, type WidgetDimensions, type WidgetDimensionsAccessor, WidgetSizeCtx, } from "./hooks";
40
+ export { type AggregationPreset, type ReactiveWidgetContext, type ServiceCallFn, type UseWidgetEntityGroupOptions, type UseWidgetEntityGroupResult, useIntersectionPause, useReducedMotion, useWidgetContext, useWidgetDashboard, useWidgetViewer, useWidgetDialog, useWidgetDimensions, useWidgetEntityGroup, WidgetCtx, type WidgetDashboard, type WidgetViewer, type WidgetDialogReturn, type WidgetDimensions, type WidgetDimensionsAccessor, WidgetSizeCtx, } from "./hooks";
41
41
  export { type GestureHandlers, useWidgetGestures } from "./gestures/use-widget-gestures";
42
42
  export { injectTokens, type SvgColorKey, svgColors, type Tone, ToneSchema, } from "./theming";
43
43
  export { widgetFields } from "./fields";