@glasshome/widget-sdk 1.29.0 → 1.31.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/data.d.ts CHANGED
@@ -5,7 +5,16 @@
5
5
  * import map), and a direct import would bundle a second, disconnected
6
6
  * store. Phase 4 routes these through capability checks.
7
7
  */
8
- export { getForecasts, getStream, getWebRtcClientConfig, hassMediaUrl, sendWebRtcCandidate, startWebRtcSession, state, trackEntityHistory, untrackEntityHistory, } from "@glasshome/sync-layer";
8
+ import * as syncLayer from "@glasshome/sync-layer";
9
+ export { getForecasts, hassMediaUrl, state, trackEntityHistory, untrackEntityHistory, } from "@glasshome/sync-layer";
10
+ /** @deprecated since 1.31.0, removed in 2.0.0. Use `<CameraStream entityId kind="hls">`. */
11
+ export declare const getStream: typeof syncLayer.getStream;
12
+ /** @deprecated since 1.31.0, removed in 2.0.0. Use `<CameraStream entityId kind="webrtc">`. */
13
+ export declare const getWebRtcClientConfig: typeof syncLayer.getWebRtcClientConfig;
14
+ /** @deprecated since 1.31.0, removed in 2.0.0. Use `<CameraStream entityId kind="webrtc">`. */
15
+ export declare const startWebRtcSession: typeof syncLayer.startWebRtcSession;
16
+ /** @deprecated since 1.31.0, removed in 2.0.0. Use `<CameraStream entityId kind="webrtc">`. */
17
+ export declare const sendWebRtcCandidate: typeof syncLayer.sendWebRtcCandidate;
9
18
  export type { AreaView, CalendarEvent, CalendarEventsData, CalendarWindowOptions, ForecastType, WeatherForecast, } from "@glasshome/sync-layer";
10
19
  export { byDomain, useArea, useCalendarEvents, useCamera, useConnection, useCurrency, useEntities, useEntity, useEntityHistory, useEntityStatistics, useForecast, useHassConfig, useLocale, useStore, useTemperatureUnit, useUnitSystem, } from "@glasshome/sync-layer/solid";
11
20
  export { useService, useToggle, useTurnOff, useTurnOn } from "./framework/hooks/use-service";
@@ -103,6 +103,27 @@ 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
+ },
114
+ ...[
115
+ "getStream",
116
+ "getWebRtcClientConfig",
117
+ "startWebRtcSession",
118
+ "sendWebRtcCandidate"
119
+ ].map((e) => ({
120
+ id: e,
121
+ since: "1.31.0",
122
+ removeIn: "2.0.0",
123
+ replacement: "<CameraStream entityId kind>",
124
+ docsUrl: "https://glasshome.app/docs/widgets/widget-api-reference",
125
+ sourcePattern: `\\b${e}\\b`
126
+ })),
106
127
  {
107
128
  id: "WidgetContext.theme",
108
129
  since: "1.26.0",
@@ -6000,5 +6000,299 @@
6000
6000
  "useWidgetViewer",
6001
6001
  "widgetFields",
6002
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"
6148
+ ],
6149
+ "1.31.0": [
6150
+ "Badge",
6151
+ "Button",
6152
+ "ButtonGroup",
6153
+ "CameraSourceContext",
6154
+ "CameraStream",
6155
+ "Carousel",
6156
+ "CarouselContent",
6157
+ "CarouselDots",
6158
+ "CarouselItem",
6159
+ "CarouselNext",
6160
+ "CarouselPrevious",
6161
+ "ColorDisc",
6162
+ "ColorSlider",
6163
+ "ColorWheel",
6164
+ "CountPill",
6165
+ "Icon",
6166
+ "Input",
6167
+ "Label",
6168
+ "PanelEntityRow",
6169
+ "PanelFacts",
6170
+ "PanelRow",
6171
+ "PanelRows",
6172
+ "PanelSection",
6173
+ "Progress",
6174
+ "ResponsiveDialog",
6175
+ "ResponsiveDialogBody",
6176
+ "ResponsiveDialogClose",
6177
+ "ResponsiveDialogContent",
6178
+ "ResponsiveDialogDescription",
6179
+ "ResponsiveDialogFooter",
6180
+ "ResponsiveDialogHeader",
6181
+ "ResponsiveDialogTitle",
6182
+ "SDK_VERSION",
6183
+ "SchemaForm",
6184
+ "SectionIcon",
6185
+ "SectionTitle",
6186
+ "Select",
6187
+ "SelectContent",
6188
+ "SelectItem",
6189
+ "SelectTrigger",
6190
+ "SelectValue",
6191
+ "Slider",
6192
+ "SwatchPicker",
6193
+ "Switch",
6194
+ "Tabs",
6195
+ "TabsContent",
6196
+ "TabsList",
6197
+ "TabsTrigger",
6198
+ "TemperatureBar",
6199
+ "Toggle",
6200
+ "ToggleGroup",
6201
+ "ToggleGroupItem",
6202
+ "ToneSchema",
6203
+ "Widget",
6204
+ "WidgetAction",
6205
+ "WidgetBackdrop",
6206
+ "WidgetChip",
6207
+ "WidgetChoice",
6208
+ "WidgetContent",
6209
+ "WidgetControls",
6210
+ "WidgetCtx",
6211
+ "WidgetDebugTab",
6212
+ "WidgetDebugView",
6213
+ "WidgetDialog",
6214
+ "WidgetGlyph",
6215
+ "WidgetHead",
6216
+ "WidgetHero",
6217
+ "WidgetIcon",
6218
+ "WidgetLayer",
6219
+ "WidgetManifestSchema",
6220
+ "WidgetSizeCtx",
6221
+ "WidgetSliderFill",
6222
+ "WidgetStatus",
6223
+ "WidgetStepper",
6224
+ "WidgetTitle",
6225
+ "WidgetValue",
6226
+ "buildDebugData",
6227
+ "byDomain",
6228
+ "calculateLightGroup",
6229
+ "calculateSensorGroup",
6230
+ "copyText",
6231
+ "countActiveEntities",
6232
+ "defineConfig",
6233
+ "defineWidget",
6234
+ "deprecations",
6235
+ "field",
6236
+ "formatDeprecation",
6237
+ "formatSchemaError",
6238
+ "getEntityAttribute",
6239
+ "getForecasts",
6240
+ "getStream",
6241
+ "getWebRtcClientConfig",
6242
+ "hassMediaUrl",
6243
+ "imagePreset",
6244
+ "imageSrc",
6245
+ "imageUrl",
6246
+ "injectTokens",
6247
+ "isDark",
6248
+ "isEntityActive",
6249
+ "isPanelControllable",
6250
+ "mediaUrl",
6251
+ "monotoneCubicPath",
6252
+ "parseColor",
6253
+ "presetValue",
6254
+ "provideCameraSource",
6255
+ "sendWebRtcCandidate",
6256
+ "startWebRtcSession",
6257
+ "state",
6258
+ "svgColors",
6259
+ "trackEntityHistory",
6260
+ "untrackEntityHistory",
6261
+ "useArea",
6262
+ "useCalendarEvents",
6263
+ "useCamera",
6264
+ "useCameraSource",
6265
+ "useConfirm",
6266
+ "useConnection",
6267
+ "useCopyText",
6268
+ "useCurrency",
6269
+ "useDaylight",
6270
+ "useEntities",
6271
+ "useEntity",
6272
+ "useEntityHistory",
6273
+ "useEntityStatistics",
6274
+ "useForecast",
6275
+ "useHassConfig",
6276
+ "useIntersectionPause",
6277
+ "useLocale",
6278
+ "useMaterial",
6279
+ "useReducedMotion",
6280
+ "useService",
6281
+ "useStore",
6282
+ "useTemperatureUnit",
6283
+ "useToggle",
6284
+ "useTurnOff",
6285
+ "useTurnOn",
6286
+ "useUnitSystem",
6287
+ "useWidgetContext",
6288
+ "useWidgetDashboard",
6289
+ "useWidgetDialog",
6290
+ "useWidgetDimensions",
6291
+ "useWidgetEntityGroup",
6292
+ "useWidgetGestures",
6293
+ "useWidgetState",
6294
+ "useWidgetViewer",
6295
+ "widgetFields",
6296
+ "z"
6003
6297
  ]
6004
6298
  }
@@ -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;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { defineWidget } from "./define-widget";
2
2
  export * from "./data";
3
3
  export * from "./framework";
4
+ export { type CameraSource, CameraSourceContext, provideCameraSource, useCameraSource, type WebRtcSignal, } from "./media/camera-source";
5
+ export { CameraStream, type CameraStreamProps } from "@glasshome/widget-sdk/media/camera-stream";
4
6
  export { monotoneCubicPath } from "./shared/spline";
5
7
  export * from "./ui";
6
8
  export { formatSchemaError, WidgetManifestSchema } from "./schemas";