@glasshome/widget-sdk 1.28.0 → 1.30.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.
@@ -103,6 +103,14 @@ var e = "https://glasshome.app/docs/widget-sdk/config", t = [
103
103
  replacement: "WidgetVariantConfig.styles (container, class, cssVars)",
104
104
  docsUrl: "https://glasshome.app/docs/widgets/widget-sdk#variants"
105
105
  },
106
+ {
107
+ id: "host.instantiateWidget",
108
+ since: "1.30.0",
109
+ removeIn: "2.0.0",
110
+ replacement: "the sealed engine: Dash's WidgetSlot, or bun widget preview",
111
+ docsUrl: "https://glasshome.app/docs/widgets/widget-sealed-engine",
112
+ sourcePattern: "\\binstantiateWidget\\b"
113
+ },
106
114
  {
107
115
  id: "WidgetContext.theme",
108
116
  since: "1.26.0",
@@ -5855,5 +5855,295 @@
5855
5855
  "useWidgetViewer",
5856
5856
  "widgetFields",
5857
5857
  "z"
5858
+ ],
5859
+ "1.29.0": [
5860
+ "Badge",
5861
+ "Button",
5862
+ "ButtonGroup",
5863
+ "Carousel",
5864
+ "CarouselContent",
5865
+ "CarouselDots",
5866
+ "CarouselItem",
5867
+ "CarouselNext",
5868
+ "CarouselPrevious",
5869
+ "ColorDisc",
5870
+ "ColorSlider",
5871
+ "ColorWheel",
5872
+ "CountPill",
5873
+ "Icon",
5874
+ "Input",
5875
+ "Label",
5876
+ "PanelEntityRow",
5877
+ "PanelFacts",
5878
+ "PanelRow",
5879
+ "PanelRows",
5880
+ "PanelSection",
5881
+ "Progress",
5882
+ "ResponsiveDialog",
5883
+ "ResponsiveDialogBody",
5884
+ "ResponsiveDialogClose",
5885
+ "ResponsiveDialogContent",
5886
+ "ResponsiveDialogDescription",
5887
+ "ResponsiveDialogFooter",
5888
+ "ResponsiveDialogHeader",
5889
+ "ResponsiveDialogTitle",
5890
+ "SDK_VERSION",
5891
+ "SchemaForm",
5892
+ "SectionIcon",
5893
+ "SectionTitle",
5894
+ "Select",
5895
+ "SelectContent",
5896
+ "SelectItem",
5897
+ "SelectTrigger",
5898
+ "SelectValue",
5899
+ "Slider",
5900
+ "SwatchPicker",
5901
+ "Switch",
5902
+ "Tabs",
5903
+ "TabsContent",
5904
+ "TabsList",
5905
+ "TabsTrigger",
5906
+ "TemperatureBar",
5907
+ "Toggle",
5908
+ "ToggleGroup",
5909
+ "ToggleGroupItem",
5910
+ "ToneSchema",
5911
+ "Widget",
5912
+ "WidgetAction",
5913
+ "WidgetBackdrop",
5914
+ "WidgetChip",
5915
+ "WidgetChoice",
5916
+ "WidgetContent",
5917
+ "WidgetControls",
5918
+ "WidgetCtx",
5919
+ "WidgetDebugTab",
5920
+ "WidgetDebugView",
5921
+ "WidgetDialog",
5922
+ "WidgetGlyph",
5923
+ "WidgetHead",
5924
+ "WidgetHero",
5925
+ "WidgetIcon",
5926
+ "WidgetLayer",
5927
+ "WidgetManifestSchema",
5928
+ "WidgetSizeCtx",
5929
+ "WidgetSliderFill",
5930
+ "WidgetStatus",
5931
+ "WidgetStepper",
5932
+ "WidgetTitle",
5933
+ "WidgetValue",
5934
+ "buildDebugData",
5935
+ "byDomain",
5936
+ "calculateLightGroup",
5937
+ "calculateSensorGroup",
5938
+ "copyText",
5939
+ "countActiveEntities",
5940
+ "defineConfig",
5941
+ "defineWidget",
5942
+ "deprecations",
5943
+ "field",
5944
+ "formatDeprecation",
5945
+ "formatSchemaError",
5946
+ "getEntityAttribute",
5947
+ "getForecasts",
5948
+ "getStream",
5949
+ "getWebRtcClientConfig",
5950
+ "hassMediaUrl",
5951
+ "imagePreset",
5952
+ "imageSrc",
5953
+ "imageUrl",
5954
+ "injectTokens",
5955
+ "isDark",
5956
+ "isEntityActive",
5957
+ "isPanelControllable",
5958
+ "mediaUrl",
5959
+ "monotoneCubicPath",
5960
+ "parseColor",
5961
+ "presetValue",
5962
+ "sendWebRtcCandidate",
5963
+ "startWebRtcSession",
5964
+ "state",
5965
+ "svgColors",
5966
+ "trackEntityHistory",
5967
+ "untrackEntityHistory",
5968
+ "useArea",
5969
+ "useCalendarEvents",
5970
+ "useCamera",
5971
+ "useConfirm",
5972
+ "useConnection",
5973
+ "useCopyText",
5974
+ "useCurrency",
5975
+ "useDaylight",
5976
+ "useEntities",
5977
+ "useEntity",
5978
+ "useEntityHistory",
5979
+ "useEntityStatistics",
5980
+ "useForecast",
5981
+ "useHassConfig",
5982
+ "useIntersectionPause",
5983
+ "useLocale",
5984
+ "useMaterial",
5985
+ "useReducedMotion",
5986
+ "useService",
5987
+ "useStore",
5988
+ "useTemperatureUnit",
5989
+ "useToggle",
5990
+ "useTurnOff",
5991
+ "useTurnOn",
5992
+ "useUnitSystem",
5993
+ "useWidgetContext",
5994
+ "useWidgetDashboard",
5995
+ "useWidgetDialog",
5996
+ "useWidgetDimensions",
5997
+ "useWidgetEntityGroup",
5998
+ "useWidgetGestures",
5999
+ "useWidgetState",
6000
+ "useWidgetViewer",
6001
+ "widgetFields",
6002
+ "z"
6003
+ ],
6004
+ "1.30.0": [
6005
+ "Badge",
6006
+ "Button",
6007
+ "ButtonGroup",
6008
+ "Carousel",
6009
+ "CarouselContent",
6010
+ "CarouselDots",
6011
+ "CarouselItem",
6012
+ "CarouselNext",
6013
+ "CarouselPrevious",
6014
+ "ColorDisc",
6015
+ "ColorSlider",
6016
+ "ColorWheel",
6017
+ "CountPill",
6018
+ "Icon",
6019
+ "Input",
6020
+ "Label",
6021
+ "PanelEntityRow",
6022
+ "PanelFacts",
6023
+ "PanelRow",
6024
+ "PanelRows",
6025
+ "PanelSection",
6026
+ "Progress",
6027
+ "ResponsiveDialog",
6028
+ "ResponsiveDialogBody",
6029
+ "ResponsiveDialogClose",
6030
+ "ResponsiveDialogContent",
6031
+ "ResponsiveDialogDescription",
6032
+ "ResponsiveDialogFooter",
6033
+ "ResponsiveDialogHeader",
6034
+ "ResponsiveDialogTitle",
6035
+ "SDK_VERSION",
6036
+ "SchemaForm",
6037
+ "SectionIcon",
6038
+ "SectionTitle",
6039
+ "Select",
6040
+ "SelectContent",
6041
+ "SelectItem",
6042
+ "SelectTrigger",
6043
+ "SelectValue",
6044
+ "Slider",
6045
+ "SwatchPicker",
6046
+ "Switch",
6047
+ "Tabs",
6048
+ "TabsContent",
6049
+ "TabsList",
6050
+ "TabsTrigger",
6051
+ "TemperatureBar",
6052
+ "Toggle",
6053
+ "ToggleGroup",
6054
+ "ToggleGroupItem",
6055
+ "ToneSchema",
6056
+ "Widget",
6057
+ "WidgetAction",
6058
+ "WidgetBackdrop",
6059
+ "WidgetChip",
6060
+ "WidgetChoice",
6061
+ "WidgetContent",
6062
+ "WidgetControls",
6063
+ "WidgetCtx",
6064
+ "WidgetDebugTab",
6065
+ "WidgetDebugView",
6066
+ "WidgetDialog",
6067
+ "WidgetGlyph",
6068
+ "WidgetHead",
6069
+ "WidgetHero",
6070
+ "WidgetIcon",
6071
+ "WidgetLayer",
6072
+ "WidgetManifestSchema",
6073
+ "WidgetSizeCtx",
6074
+ "WidgetSliderFill",
6075
+ "WidgetStatus",
6076
+ "WidgetStepper",
6077
+ "WidgetTitle",
6078
+ "WidgetValue",
6079
+ "buildDebugData",
6080
+ "byDomain",
6081
+ "calculateLightGroup",
6082
+ "calculateSensorGroup",
6083
+ "copyText",
6084
+ "countActiveEntities",
6085
+ "defineConfig",
6086
+ "defineWidget",
6087
+ "deprecations",
6088
+ "field",
6089
+ "formatDeprecation",
6090
+ "formatSchemaError",
6091
+ "getEntityAttribute",
6092
+ "getForecasts",
6093
+ "getStream",
6094
+ "getWebRtcClientConfig",
6095
+ "hassMediaUrl",
6096
+ "imagePreset",
6097
+ "imageSrc",
6098
+ "imageUrl",
6099
+ "injectTokens",
6100
+ "isDark",
6101
+ "isEntityActive",
6102
+ "isPanelControllable",
6103
+ "mediaUrl",
6104
+ "monotoneCubicPath",
6105
+ "parseColor",
6106
+ "presetValue",
6107
+ "sendWebRtcCandidate",
6108
+ "startWebRtcSession",
6109
+ "state",
6110
+ "svgColors",
6111
+ "trackEntityHistory",
6112
+ "untrackEntityHistory",
6113
+ "useArea",
6114
+ "useCalendarEvents",
6115
+ "useCamera",
6116
+ "useConfirm",
6117
+ "useConnection",
6118
+ "useCopyText",
6119
+ "useCurrency",
6120
+ "useDaylight",
6121
+ "useEntities",
6122
+ "useEntity",
6123
+ "useEntityHistory",
6124
+ "useEntityStatistics",
6125
+ "useForecast",
6126
+ "useHassConfig",
6127
+ "useIntersectionPause",
6128
+ "useLocale",
6129
+ "useMaterial",
6130
+ "useReducedMotion",
6131
+ "useService",
6132
+ "useStore",
6133
+ "useTemperatureUnit",
6134
+ "useToggle",
6135
+ "useTurnOff",
6136
+ "useTurnOn",
6137
+ "useUnitSystem",
6138
+ "useWidgetContext",
6139
+ "useWidgetDashboard",
6140
+ "useWidgetDialog",
6141
+ "useWidgetDimensions",
6142
+ "useWidgetEntityGroup",
6143
+ "useWidgetGestures",
6144
+ "useWidgetState",
6145
+ "useWidgetViewer",
6146
+ "widgetFields",
6147
+ "z"
5858
6148
  ]
5859
6149
  }
@@ -54,6 +54,9 @@ export interface ReactiveWidgetContext {
54
54
  /** Present when the host mounts the widget; the service hooks route
55
55
  through it. Absent in previews/tests (direct sync-layer fallback). */
56
56
  callService?: ServiceCallFn;
57
+ /** Whether the widget's own grant lets it make this call, so a control it cannot run is never drawn.
58
+ Absent on hosts that predate this field: draw the control and let the call answer. */
59
+ canCall?: (domain: string, service: string, entityIds: string[]) => boolean;
57
60
  /** The dashboard this instance sits on. Absent on hosts that predate this field. */
58
61
  dashboard?: () => WidgetDashboard;
59
62
  /** Who is looking. Absent on hosts that predate this field. */
@@ -4,6 +4,7 @@ export declare function isPanelControllable(domain: string): boolean;
4
4
  /**
5
5
  * A row for any entity, drawn and wired from its domain: a light dims, a cover
6
6
  * opens, a lock locks. The same row the area panel and every group panel use.
7
+ * A call the widget's grant refuses draws no control; the row still reads.
7
8
  */
8
9
  export declare function PanelEntityRow(props: {
9
10
  entityId: string;
@@ -9,7 +9,7 @@ export interface PanelSlide {
9
9
  onCommit?: (value: number) => void;
10
10
  /** Names the value for screen readers and the keyboard handle ("Brightness"). */
11
11
  label?: string;
12
- /** Keyboard step; the drag reports whole numbers. */
12
+ /** The value moves in steps of this size, by drag and by keyboard. Unset: the drag reports whole numbers and a key moves 5. */
13
13
  step?: number;
14
14
  }
15
15
  /** A labelled group in the panel's aside ("Lights", "Playing on"). */
@@ -1,63 +1,64 @@
1
- import { ErrorBoundary as e, createComponent as t } from "solid-js";
2
- import { DelegatedEvents as n, clearDelegatedEvents as r, delegateEvents as i, render as a } from "solid-js/web";
3
- import { WidgetCtx as o, injectTokens as s } from "@glasshome/widget-sdk";
1
+ import { deprecate as e } from "../deprecations.js";
2
+ import { ErrorBoundary as t, createComponent as n } from "solid-js";
3
+ import { DelegatedEvents as r, clearDelegatedEvents as i, delegateEvents as a, render as o } from "solid-js/web";
4
+ import { WidgetCtx as s, injectTokens as c } from "@glasshome/widget-sdk";
4
5
  //#region src/host/instantiate-widget.ts
5
- var c = /* @__PURE__ */ new Map();
6
- function l(e) {
7
- let t = c.get(e);
6
+ var l = /* @__PURE__ */ new Map();
7
+ function u(e) {
8
+ let t = l.get(e);
8
9
  if (t) return t;
9
10
  let n = new CSSStyleSheet();
10
- return n.replaceSync(e), c.set(e, n), n;
11
+ return n.replaceSync(e), l.set(e, n), n;
11
12
  }
12
- var u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map(), f = !1;
13
- function p(e, t) {
13
+ var d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map(), p = !1;
14
+ function m(e, t) {
14
15
  for (let n of t) e.classList.toggle(n, document.documentElement.classList.contains(n));
15
16
  }
16
- function m(e, t) {
17
- for (let e of t) u.add(e);
18
- return d.set(e, t), p(e, t), f || (f = !0, new MutationObserver(() => {
19
- for (let [e, t] of d) p(e, t);
17
+ function h(e, t) {
18
+ for (let e of t) d.add(e);
19
+ return f.set(e, t), m(e, t), p || (p = !0, new MutationObserver(() => {
20
+ for (let [e, t] of f) m(e, t);
20
21
  }).observe(document.documentElement, {
21
22
  attributes: !0,
22
23
  attributeFilter: ["class"]
23
24
  })), () => {
24
- d.delete(e);
25
+ f.delete(e);
25
26
  };
26
27
  }
27
- var h = (e) => {
28
+ var g = (e) => {
28
29
  Reflect.deleteProperty(e, "target"), Reflect.deleteProperty(e, "currentTarget");
29
30
  };
30
31
  if (typeof document < "u") {
31
- let e = [...n];
32
- i(e);
33
- for (let t of e) document.addEventListener(t, h, { passive: !0 });
32
+ let e = [...r];
33
+ a(e);
34
+ for (let t of e) document.addEventListener(t, g, { passive: !0 });
34
35
  }
35
- function g(e, t = /* @__PURE__ */ new Set()) {
36
+ function _(e, t = /* @__PURE__ */ new Set()) {
36
37
  if (e.mode !== "closed") return () => {};
37
- let a = [...n], o = {
38
+ let n = [...r], o = {
38
39
  addEventListener: (n, r) => e.addEventListener(n, r, { passive: t.has(n) }),
39
40
  removeEventListener: (t, n) => e.removeEventListener(t, n)
40
41
  };
41
- i(a, o);
42
- for (let t of a) e.addEventListener(t, h, { passive: !0 });
42
+ a(n, o);
43
+ for (let t of n) e.addEventListener(t, g, { passive: !0 });
43
44
  return () => {
44
- r(o);
45
- for (let t of a) e.removeEventListener(t, h);
45
+ i(o);
46
+ for (let t of n) e.removeEventListener(t, g);
46
47
  };
47
48
  }
48
- function _(n, r) {
49
- let i = n.attachShadow({ mode: "closed" }), c = g(i), u = m(n, r.mirrorClasses ?? ["dark"]);
50
- s(i), r.cssText !== null && (i.adoptedStyleSheets = [...i.adoptedStyleSheets, l(r.cssText)]), r.extraSheets?.length && (i.adoptedStyleSheets = [...i.adoptedStyleSheets, ...r.extraSheets]);
51
- let d = a(() => t(o.Provider, {
49
+ function v(e, r) {
50
+ let i = e.attachShadow({ mode: "closed" }), a = _(i), l = h(e, r.mirrorClasses ?? ["dark"]);
51
+ c(i), r.cssText !== null && (i.adoptedStyleSheets = [...i.adoptedStyleSheets, u(r.cssText)]), r.extraSheets?.length && (i.adoptedStyleSheets = [...i.adoptedStyleSheets, ...r.extraSheets]);
52
+ let d = o(() => n(s.Provider, {
52
53
  value: r.ctx,
53
54
  get children() {
54
- return t(e, {
55
+ return n(t, {
55
56
  fallback: (e) => {
56
57
  let t = e instanceof Error ? e : Error(String(e));
57
58
  return queueMicrotask(() => r.onCrash(t)), null;
58
59
  },
59
60
  get children() {
60
- return t(r.definition.component, { get config() {
61
+ return n(r.definition.component, { get config() {
61
62
  return r.config();
62
63
  } });
63
64
  }
@@ -65,8 +66,9 @@ function _(n, r) {
65
66
  }
66
67
  }), i);
67
68
  return { dispose: () => {
68
- u(), d(), c();
69
+ l(), d(), a();
69
70
  } };
70
71
  }
72
+ var y = e(v, "host.instantiateWidget");
71
73
  //#endregion
72
- export { g as delegateInside, _ as instantiateWidget };
74
+ export { _ as delegateInside, y as instantiateWidget };
@@ -34,19 +34,11 @@ export interface MountOptions {
34
34
  */
35
35
  export declare function delegateInside(shadow: ShadowRoot, passive?: ReadonlySet<string>): () => void;
36
36
  /**
37
- * Mount a widget into a closed shadow root on `host`.
37
+ * Mount a widget into a closed shadow root on `host`, on the page engine: SDK tokens, the widget's
38
+ * CSS and any host `extraSheets` adopted, the requested document classes mirrored, the widget rendered
39
+ * under a re-provided `WidgetCtx` and a crash boundary.
38
40
  *
39
- * The only ShadowRoot reference lives in this closure — `mode: "closed"` keeps
40
- * it off `host.shadowRoot`, so neither the widget nor another bundle can reach
41
- * into a foreign widget's DOM through the host element.
42
- *
43
- * This is the framework half of the widget host contract, shared by dash, the
44
- * preview harness, and the hub render worker. It attaches the shadow, injects
45
- * SDK tokens (tones + widget vars only — the ui theme reaches widgets by
46
- * document inheritance, never pinned on `:host`), adopts the widget's CSS and
47
- * any host `extraSheets`, mirrors the requested document classes, and renders
48
- * the widget under a re-provided `WidgetCtx` and a crash boundary. Trust
49
- * boundary steps that are host-specific (freeze-intrinsics, capability
50
- * enforcement) stay in the host and are not part of this recipe.
41
+ * @deprecated since 1.30.0, removed in 2.0.0. Homes and previews mount widgets in the sealed engine:
42
+ * Dash's WidgetSlot, or `bun widget preview`. See https://glasshome.app/docs/widgets/widget-sealed-engine
51
43
  */
52
- export declare function instantiateWidget(host: HTMLElement, opts: MountOptions): WidgetInstanceHandle;
44
+ export declare const instantiateWidget: (host: HTMLElement, opts: MountOptions) => WidgetInstanceHandle;