@glasshome/widget-sdk 1.26.0 → 1.27.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/theme.d.ts CHANGED
@@ -1,9 +1,7 @@
1
+ /** Whether `<html>` carries `name`, read live: a memo or effect that calls it runs again when it flips. */
2
+ export declare function htmlHasClass(name: string): boolean;
1
3
  /**
2
- * Theme utilities — plain DOM reads.
3
- * Framework-agnostic: no SolidJS imports.
4
- */
5
- /**
6
- * Check whether the current theme is dark mode.
7
- * Reads the presence of the "dark" class on <html>.
4
+ * Whether the home is in dark mode: the "dark" class on <html>. Reactive inside a memo or effect,
5
+ * in every engine.
8
6
  */
9
7
  export declare function isDark(): boolean;
package/dist/types.d.ts CHANGED
@@ -41,9 +41,13 @@ export interface WidgetManifest<C = Record<string, unknown>> {
41
41
  /**
42
42
  * Runtime context provided to widgets by the host.
43
43
  * Framework-agnostic: plain objects and functions.
44
+ *
45
+ * @deprecated No host provides it; removed in 2.0.0. Read the theme with `isDark()` and the
46
+ * size with `useWidgetDimensions()`.
44
47
  */
45
48
  export interface WidgetContext {
46
49
  config: Record<string, unknown>;
50
+ /** @deprecated Removed in 2.0.0 with `WidgetContext`. Use `isDark()`. */
47
51
  theme: {
48
52
  getToken: (name: string) => string;
49
53
  isDark: () => boolean;
package/guide/widgets.md CHANGED
@@ -59,7 +59,8 @@ Render `<WidgetDialog>` next to `<Widget>`, spreading the dialog parts (`Respons
59
59
  - Theme vars only (`--foreground`, `--muted-foreground`, `--card`, `--primary`, `--border`, `--success`, `--warning`, `--destructive`, `--radius`). Never declare them on `:host`; no own colour/radius tokens; no `--color-*`.
60
60
  - Material: a part you draw follows the home's material through `--material-*` (`--material-accent`, `--material-face`, `--material-well`, `--material-raised`, `--material-pressed`, `--material-control-track|fill|knob`, `--material-blur`, `--material-clarity`, `--material-tint`, `--material-glow`) and its own color through `--surface-tone`, `--surface-wash`. `useMaterial()` to decide (`terms.face`, `terms.glow`), never to paint. Never read `--glass-*` or `--_*`; the build warns, and names the retired `--material-*` ones.
61
61
  - Own CSS = layout and bespoke art. No custom panel/row/chip/button chrome.
62
- - Tailwind classes literal in source, never concatenated. `dark:` works; `isDark()` for the boolean.
62
+ - Tailwind classes literal in source, never concatenated.
63
+ - Dark mode: style with `dark:` and theme vars, which follow the home everywhere. `isDark()` for logic, reactive in a memo or effect. `prefers-color-scheme` is the device's setting, not the home's mode.
63
64
  - No dot status lamps. No thin vertical bars (read as a text caret). No all-caps. Separator ` · `.
64
65
  - One icon per item, not per line. Icons, fills and pictures before text.
65
66
  - Lead with the answer (value + unit, or a verdict); one small line explains it. Never show a value twice. States per device class (Open/Closed, Detected/Clear).
@@ -68,14 +69,14 @@ Render `<WidgetDialog>` next to `<Widget>`, spreading the dialog parts (`Respons
68
69
  - Groups: one tap brings all members to one state; locks never unlock in one tap; doors, gates, garage doors never join bulk actions.
69
70
  - Readings update text in place; never rebuild DOM. `Index` for lists of readings. Over 20 s of changing demo data a widget adds and removes no DOM nodes.
70
71
  - Everything sits on an edge; text left, values/actions right. One accent per view; defaults quiet. No card in a card.
71
- - Motion: colours morph, never snap; time transitions with `--duration-state` / `--ease-morph` (zeroed under reduced motion). Decorative loops scale by `var(--motion-ambient, 0)`. Gate on `useReducedMotion()`; pause offscreen with `useIntersectionPause()`.
72
+ - Motion: colours morph, never snap; time transitions with `--duration-state` / `--ease-morph` (zeroed under reduced motion). Decorative loops scale by `var(--motion-ambient, 0)`. Gate on `useReducedMotion()` (the device's setting or the home's Reduce motion); pause offscreen with `useIntersectionPause()`.
72
73
 
73
74
  ## Sealed engine
74
75
 
75
76
  Dash 1.5 previews the engine every widget will run in: QuickJS, no page access. Test there before publishing: Settings, Developer Mode, Sealed widgets (preview), reload, then `bun widget connect`. `bun widget preview` still renders in the page, so it does not prove a widget runs sealed.
76
77
 
77
78
  - Import only `@glasshome/widget-sdk` and `solid-js` (`/store`, `/web`).
78
- - No `fetch`, `XMLHttpRequest`, WebSocket, cookies, Capacitor. `localStorage` is in-memory and empties on reload. Built-ins are frozen: no `z.config`, no global patches.
79
+ - No `fetch`, `XMLHttpRequest`, WebSocket, cookies, Capacitor. `localStorage` and `sessionStorage` are in memory, one pair per widget (every copy of a widget shares it), and empty on reload. They keep widgets apart but are no security boundary: widgets in one engine share its memory. Module top-level code uses its widget's store; a timer or listener set up there runs for no widget, so storage throws a catchable SecurityError in it and the engine runs on. Keep what must last in config through `updateConfig`. Built-ins are frozen: no `z.config`, no global patches.
79
80
  - DOM is mirrored through an allowlist: no `<style>`, `<link>`, `<script>`, no `el.click()`; images only `data:image/…`, same-origin `blob:` or `/ha-proxy/media`.
80
81
  - Limits: CPU 250 ms per second, setup 1.5 s per 10 s (both stop the widget until the homeowner turns it back on), 500 ms per run and 256 MB (both crash it), 20,000 elements, 512 timers, 128 observers.
81
82
  - Refusals and CPU use: Settings > Sealed widgets (Developer Mode). Each refusal has a sentence and a code; fix every one.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-sdk",
3
- "version": "1.26.0",
3
+ "version": "1.27.0",
4
4
  "description": "SDK for building GlassHome dashboard widgets with SolidJS",
5
5
  "keywords": [
6
6
  "dashboard",