@glasshome/widget-sdk 1.29.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",
@@ -6000,5 +6000,150 @@
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"
6003
6148
  ]
6004
6149
  }
@@ -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.js CHANGED
@@ -3406,7 +3406,7 @@ function ls(e) {
3406
3406
  //#region src/version.ts
3407
3407
  var us = {
3408
3408
  name: "@glasshome/widget-sdk",
3409
- version: "1.29.0",
3409
+ version: "1.30.0",
3410
3410
  description: "SDK for building GlassHome dashboard widgets with SolidJS",
3411
3411
  keywords: [
3412
3412
  "dashboard",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-sdk",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "SDK for building GlassHome dashboard widgets with SolidJS",
5
5
  "keywords": [
6
6
  "dashboard",