@glasshome/widget-sdk 1.27.0 → 1.28.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/README.md +2 -0
- package/dist/export-history.json +289 -0
- package/dist/framework/hooks/index.d.ts +3 -1
- package/dist/framework/hooks/use-widget-context.d.ts +8 -0
- package/dist/framework/hooks/use-widget-state.d.ts +10 -0
- package/dist/framework/index.d.ts +1 -1
- package/dist/index.js +790 -680
- package/guide/widgets.md +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ export default defineWidget({
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
Small values a widget keeps across reloads (recent picks, the last tab) go through `useWidgetState(key, schema, fallback)`, kept by the host for this widget and this person. `localStorage` is in memory and empty after a reload.
|
|
42
|
+
|
|
41
43
|
### `@glasshome/widget-sdk/vite` — Vite Plugin
|
|
42
44
|
|
|
43
45
|
Vite plugin for widget development. Handles widget bundling, preview server, and registry generation.
|
package/dist/export-history.json
CHANGED
|
@@ -5566,5 +5566,294 @@
|
|
|
5566
5566
|
"useWidgetViewer",
|
|
5567
5567
|
"widgetFields",
|
|
5568
5568
|
"z"
|
|
5569
|
+
],
|
|
5570
|
+
"1.27.1": [
|
|
5571
|
+
"Badge",
|
|
5572
|
+
"Button",
|
|
5573
|
+
"ButtonGroup",
|
|
5574
|
+
"Carousel",
|
|
5575
|
+
"CarouselContent",
|
|
5576
|
+
"CarouselDots",
|
|
5577
|
+
"CarouselItem",
|
|
5578
|
+
"CarouselNext",
|
|
5579
|
+
"CarouselPrevious",
|
|
5580
|
+
"ColorDisc",
|
|
5581
|
+
"ColorSlider",
|
|
5582
|
+
"ColorWheel",
|
|
5583
|
+
"CountPill",
|
|
5584
|
+
"Icon",
|
|
5585
|
+
"Input",
|
|
5586
|
+
"Label",
|
|
5587
|
+
"PanelEntityRow",
|
|
5588
|
+
"PanelFacts",
|
|
5589
|
+
"PanelRow",
|
|
5590
|
+
"PanelRows",
|
|
5591
|
+
"PanelSection",
|
|
5592
|
+
"Progress",
|
|
5593
|
+
"ResponsiveDialog",
|
|
5594
|
+
"ResponsiveDialogBody",
|
|
5595
|
+
"ResponsiveDialogClose",
|
|
5596
|
+
"ResponsiveDialogContent",
|
|
5597
|
+
"ResponsiveDialogDescription",
|
|
5598
|
+
"ResponsiveDialogFooter",
|
|
5599
|
+
"ResponsiveDialogHeader",
|
|
5600
|
+
"ResponsiveDialogTitle",
|
|
5601
|
+
"SDK_VERSION",
|
|
5602
|
+
"SchemaForm",
|
|
5603
|
+
"SectionIcon",
|
|
5604
|
+
"SectionTitle",
|
|
5605
|
+
"Select",
|
|
5606
|
+
"SelectContent",
|
|
5607
|
+
"SelectItem",
|
|
5608
|
+
"SelectTrigger",
|
|
5609
|
+
"SelectValue",
|
|
5610
|
+
"Slider",
|
|
5611
|
+
"SwatchPicker",
|
|
5612
|
+
"Switch",
|
|
5613
|
+
"Tabs",
|
|
5614
|
+
"TabsContent",
|
|
5615
|
+
"TabsList",
|
|
5616
|
+
"TabsTrigger",
|
|
5617
|
+
"TemperatureBar",
|
|
5618
|
+
"Toggle",
|
|
5619
|
+
"ToggleGroup",
|
|
5620
|
+
"ToggleGroupItem",
|
|
5621
|
+
"ToneSchema",
|
|
5622
|
+
"Widget",
|
|
5623
|
+
"WidgetAction",
|
|
5624
|
+
"WidgetBackdrop",
|
|
5625
|
+
"WidgetChip",
|
|
5626
|
+
"WidgetChoice",
|
|
5627
|
+
"WidgetContent",
|
|
5628
|
+
"WidgetControls",
|
|
5629
|
+
"WidgetCtx",
|
|
5630
|
+
"WidgetDebugTab",
|
|
5631
|
+
"WidgetDebugView",
|
|
5632
|
+
"WidgetDialog",
|
|
5633
|
+
"WidgetGlyph",
|
|
5634
|
+
"WidgetHead",
|
|
5635
|
+
"WidgetHero",
|
|
5636
|
+
"WidgetIcon",
|
|
5637
|
+
"WidgetLayer",
|
|
5638
|
+
"WidgetManifestSchema",
|
|
5639
|
+
"WidgetSizeCtx",
|
|
5640
|
+
"WidgetSliderFill",
|
|
5641
|
+
"WidgetStatus",
|
|
5642
|
+
"WidgetStepper",
|
|
5643
|
+
"WidgetTitle",
|
|
5644
|
+
"WidgetValue",
|
|
5645
|
+
"buildDebugData",
|
|
5646
|
+
"byDomain",
|
|
5647
|
+
"calculateLightGroup",
|
|
5648
|
+
"calculateSensorGroup",
|
|
5649
|
+
"copyText",
|
|
5650
|
+
"countActiveEntities",
|
|
5651
|
+
"defineConfig",
|
|
5652
|
+
"defineWidget",
|
|
5653
|
+
"deprecations",
|
|
5654
|
+
"field",
|
|
5655
|
+
"formatDeprecation",
|
|
5656
|
+
"formatSchemaError",
|
|
5657
|
+
"getEntityAttribute",
|
|
5658
|
+
"getForecasts",
|
|
5659
|
+
"getStream",
|
|
5660
|
+
"getWebRtcClientConfig",
|
|
5661
|
+
"hassMediaUrl",
|
|
5662
|
+
"imagePreset",
|
|
5663
|
+
"imageSrc",
|
|
5664
|
+
"imageUrl",
|
|
5665
|
+
"injectTokens",
|
|
5666
|
+
"isDark",
|
|
5667
|
+
"isEntityActive",
|
|
5668
|
+
"isPanelControllable",
|
|
5669
|
+
"mediaUrl",
|
|
5670
|
+
"monotoneCubicPath",
|
|
5671
|
+
"parseColor",
|
|
5672
|
+
"presetValue",
|
|
5673
|
+
"sendWebRtcCandidate",
|
|
5674
|
+
"startWebRtcSession",
|
|
5675
|
+
"state",
|
|
5676
|
+
"svgColors",
|
|
5677
|
+
"trackEntityHistory",
|
|
5678
|
+
"untrackEntityHistory",
|
|
5679
|
+
"useArea",
|
|
5680
|
+
"useCalendarEvents",
|
|
5681
|
+
"useCamera",
|
|
5682
|
+
"useConfirm",
|
|
5683
|
+
"useConnection",
|
|
5684
|
+
"useCopyText",
|
|
5685
|
+
"useCurrency",
|
|
5686
|
+
"useDaylight",
|
|
5687
|
+
"useEntities",
|
|
5688
|
+
"useEntity",
|
|
5689
|
+
"useEntityHistory",
|
|
5690
|
+
"useEntityStatistics",
|
|
5691
|
+
"useForecast",
|
|
5692
|
+
"useHassConfig",
|
|
5693
|
+
"useIntersectionPause",
|
|
5694
|
+
"useLocale",
|
|
5695
|
+
"useMaterial",
|
|
5696
|
+
"useReducedMotion",
|
|
5697
|
+
"useService",
|
|
5698
|
+
"useStore",
|
|
5699
|
+
"useTemperatureUnit",
|
|
5700
|
+
"useToggle",
|
|
5701
|
+
"useTurnOff",
|
|
5702
|
+
"useTurnOn",
|
|
5703
|
+
"useUnitSystem",
|
|
5704
|
+
"useWidgetContext",
|
|
5705
|
+
"useWidgetDashboard",
|
|
5706
|
+
"useWidgetDialog",
|
|
5707
|
+
"useWidgetDimensions",
|
|
5708
|
+
"useWidgetEntityGroup",
|
|
5709
|
+
"useWidgetGestures",
|
|
5710
|
+
"useWidgetViewer",
|
|
5711
|
+
"widgetFields",
|
|
5712
|
+
"z"
|
|
5713
|
+
],
|
|
5714
|
+
"1.28.0": [
|
|
5715
|
+
"Badge",
|
|
5716
|
+
"Button",
|
|
5717
|
+
"ButtonGroup",
|
|
5718
|
+
"Carousel",
|
|
5719
|
+
"CarouselContent",
|
|
5720
|
+
"CarouselDots",
|
|
5721
|
+
"CarouselItem",
|
|
5722
|
+
"CarouselNext",
|
|
5723
|
+
"CarouselPrevious",
|
|
5724
|
+
"ColorDisc",
|
|
5725
|
+
"ColorSlider",
|
|
5726
|
+
"ColorWheel",
|
|
5727
|
+
"CountPill",
|
|
5728
|
+
"Icon",
|
|
5729
|
+
"Input",
|
|
5730
|
+
"Label",
|
|
5731
|
+
"PanelEntityRow",
|
|
5732
|
+
"PanelFacts",
|
|
5733
|
+
"PanelRow",
|
|
5734
|
+
"PanelRows",
|
|
5735
|
+
"PanelSection",
|
|
5736
|
+
"Progress",
|
|
5737
|
+
"ResponsiveDialog",
|
|
5738
|
+
"ResponsiveDialogBody",
|
|
5739
|
+
"ResponsiveDialogClose",
|
|
5740
|
+
"ResponsiveDialogContent",
|
|
5741
|
+
"ResponsiveDialogDescription",
|
|
5742
|
+
"ResponsiveDialogFooter",
|
|
5743
|
+
"ResponsiveDialogHeader",
|
|
5744
|
+
"ResponsiveDialogTitle",
|
|
5745
|
+
"SDK_VERSION",
|
|
5746
|
+
"SchemaForm",
|
|
5747
|
+
"SectionIcon",
|
|
5748
|
+
"SectionTitle",
|
|
5749
|
+
"Select",
|
|
5750
|
+
"SelectContent",
|
|
5751
|
+
"SelectItem",
|
|
5752
|
+
"SelectTrigger",
|
|
5753
|
+
"SelectValue",
|
|
5754
|
+
"Slider",
|
|
5755
|
+
"SwatchPicker",
|
|
5756
|
+
"Switch",
|
|
5757
|
+
"Tabs",
|
|
5758
|
+
"TabsContent",
|
|
5759
|
+
"TabsList",
|
|
5760
|
+
"TabsTrigger",
|
|
5761
|
+
"TemperatureBar",
|
|
5762
|
+
"Toggle",
|
|
5763
|
+
"ToggleGroup",
|
|
5764
|
+
"ToggleGroupItem",
|
|
5765
|
+
"ToneSchema",
|
|
5766
|
+
"Widget",
|
|
5767
|
+
"WidgetAction",
|
|
5768
|
+
"WidgetBackdrop",
|
|
5769
|
+
"WidgetChip",
|
|
5770
|
+
"WidgetChoice",
|
|
5771
|
+
"WidgetContent",
|
|
5772
|
+
"WidgetControls",
|
|
5773
|
+
"WidgetCtx",
|
|
5774
|
+
"WidgetDebugTab",
|
|
5775
|
+
"WidgetDebugView",
|
|
5776
|
+
"WidgetDialog",
|
|
5777
|
+
"WidgetGlyph",
|
|
5778
|
+
"WidgetHead",
|
|
5779
|
+
"WidgetHero",
|
|
5780
|
+
"WidgetIcon",
|
|
5781
|
+
"WidgetLayer",
|
|
5782
|
+
"WidgetManifestSchema",
|
|
5783
|
+
"WidgetSizeCtx",
|
|
5784
|
+
"WidgetSliderFill",
|
|
5785
|
+
"WidgetStatus",
|
|
5786
|
+
"WidgetStepper",
|
|
5787
|
+
"WidgetTitle",
|
|
5788
|
+
"WidgetValue",
|
|
5789
|
+
"buildDebugData",
|
|
5790
|
+
"byDomain",
|
|
5791
|
+
"calculateLightGroup",
|
|
5792
|
+
"calculateSensorGroup",
|
|
5793
|
+
"copyText",
|
|
5794
|
+
"countActiveEntities",
|
|
5795
|
+
"defineConfig",
|
|
5796
|
+
"defineWidget",
|
|
5797
|
+
"deprecations",
|
|
5798
|
+
"field",
|
|
5799
|
+
"formatDeprecation",
|
|
5800
|
+
"formatSchemaError",
|
|
5801
|
+
"getEntityAttribute",
|
|
5802
|
+
"getForecasts",
|
|
5803
|
+
"getStream",
|
|
5804
|
+
"getWebRtcClientConfig",
|
|
5805
|
+
"hassMediaUrl",
|
|
5806
|
+
"imagePreset",
|
|
5807
|
+
"imageSrc",
|
|
5808
|
+
"imageUrl",
|
|
5809
|
+
"injectTokens",
|
|
5810
|
+
"isDark",
|
|
5811
|
+
"isEntityActive",
|
|
5812
|
+
"isPanelControllable",
|
|
5813
|
+
"mediaUrl",
|
|
5814
|
+
"monotoneCubicPath",
|
|
5815
|
+
"parseColor",
|
|
5816
|
+
"presetValue",
|
|
5817
|
+
"sendWebRtcCandidate",
|
|
5818
|
+
"startWebRtcSession",
|
|
5819
|
+
"state",
|
|
5820
|
+
"svgColors",
|
|
5821
|
+
"trackEntityHistory",
|
|
5822
|
+
"untrackEntityHistory",
|
|
5823
|
+
"useArea",
|
|
5824
|
+
"useCalendarEvents",
|
|
5825
|
+
"useCamera",
|
|
5826
|
+
"useConfirm",
|
|
5827
|
+
"useConnection",
|
|
5828
|
+
"useCopyText",
|
|
5829
|
+
"useCurrency",
|
|
5830
|
+
"useDaylight",
|
|
5831
|
+
"useEntities",
|
|
5832
|
+
"useEntity",
|
|
5833
|
+
"useEntityHistory",
|
|
5834
|
+
"useEntityStatistics",
|
|
5835
|
+
"useForecast",
|
|
5836
|
+
"useHassConfig",
|
|
5837
|
+
"useIntersectionPause",
|
|
5838
|
+
"useLocale",
|
|
5839
|
+
"useMaterial",
|
|
5840
|
+
"useReducedMotion",
|
|
5841
|
+
"useService",
|
|
5842
|
+
"useStore",
|
|
5843
|
+
"useTemperatureUnit",
|
|
5844
|
+
"useToggle",
|
|
5845
|
+
"useTurnOff",
|
|
5846
|
+
"useTurnOn",
|
|
5847
|
+
"useUnitSystem",
|
|
5848
|
+
"useWidgetContext",
|
|
5849
|
+
"useWidgetDashboard",
|
|
5850
|
+
"useWidgetDialog",
|
|
5851
|
+
"useWidgetDimensions",
|
|
5852
|
+
"useWidgetEntityGroup",
|
|
5853
|
+
"useWidgetGestures",
|
|
5854
|
+
"useWidgetState",
|
|
5855
|
+
"useWidgetViewer",
|
|
5856
|
+
"widgetFields",
|
|
5857
|
+
"z"
|
|
5569
5858
|
]
|
|
5570
5859
|
}
|
|
@@ -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 WidgetDashboard, type WidgetMaterial, type WidgetViewer, type WidgetDimensions, } from "./use-widget-context";
|
|
6
|
+
export { type ReactiveWidgetContext, type ServiceCallFn, useWidgetContext, WidgetCtx, type WidgetDashboard, type WidgetMaterial, type WidgetViewer, type WidgetDimensions, type WidgetStateStore, } from "./use-widget-context";
|
|
7
|
+
export { useWidgetState } from "./use-widget-state";
|
|
8
|
+
export type { WidgetStateVerdict } from "@glasshome/widget-contract/state";
|
|
7
9
|
export { useWidgetDashboard } from "./use-widget-dashboard";
|
|
8
10
|
export { useWidgetViewer } from "./use-widget-viewer";
|
|
9
11
|
export { useMaterial } from "./use-material";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MaterialTerms } from "@glasshome/ui/tokens";
|
|
2
|
+
import type { WidgetStateVerdict } from "@glasshome/widget-contract/state";
|
|
2
3
|
/**
|
|
3
4
|
* Reactive widget context.
|
|
4
5
|
*
|
|
@@ -34,6 +35,11 @@ export interface WidgetMaterial {
|
|
|
34
35
|
id: string;
|
|
35
36
|
terms: MaterialTerms;
|
|
36
37
|
}
|
|
38
|
+
/** Values a widget keeps across reloads. `read` is reactive; `write(key, undefined)` deletes; a refused write changes nothing. */
|
|
39
|
+
export interface WidgetStateStore {
|
|
40
|
+
read(key: string): unknown;
|
|
41
|
+
write(key: string, value: unknown): WidgetStateVerdict;
|
|
42
|
+
}
|
|
37
43
|
export interface ReactiveWidgetContext {
|
|
38
44
|
updateConfig: (config: Record<string, unknown>) => void;
|
|
39
45
|
/**
|
|
@@ -67,6 +73,8 @@ export interface ReactiveWidgetContext {
|
|
|
67
73
|
tone: string | null;
|
|
68
74
|
lift: number | null;
|
|
69
75
|
} | null) => void;
|
|
76
|
+
/** Kept by the host across reloads, for this widget and this person. Absent on hosts that predate this field. */
|
|
77
|
+
state?: WidgetStateStore;
|
|
70
78
|
}
|
|
71
79
|
export declare const WidgetCtx: import("solid-js").Context<ReactiveWidgetContext | undefined>;
|
|
72
80
|
export declare function useWidgetContext(): ReactiveWidgetContext;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type WidgetStateVerdict } from "@glasshome/widget-contract/state";
|
|
2
|
+
import { type Accessor } from "solid-js";
|
|
3
|
+
import type { z } from "zod";
|
|
4
|
+
/**
|
|
5
|
+
* A small value this widget keeps across reloads, for this widget on this board and this person.
|
|
6
|
+
* The stored value is read through `schema`; anything it refuses reads as `fallback`.
|
|
7
|
+
* The setter returns the host's verdict: anything but "ok" changed nothing. A value that would not read back
|
|
8
|
+
* through `schema` after a JSON round trip (a Date, NaN) is refused as "value".
|
|
9
|
+
*/
|
|
10
|
+
export declare function useWidgetState<T>(key: string, schema: z.ZodType<T>, fallback: T): [Accessor<T>, (next: T | ((prev: T) => T)) => WidgetStateVerdict];
|
|
@@ -36,7 +36,7 @@ export { WidgetSliderFill } from "./backgrounds/WidgetSliderFill";
|
|
|
36
36
|
export { type PanelFact, PanelFacts, PanelRow, type PanelRowProps, PanelRows, PanelSection, type PanelSlide, } from "./panel/panel";
|
|
37
37
|
export { isPanelControllable, PanelEntityRow } from "./panel/panel-entity";
|
|
38
38
|
export { buildDebugData, WidgetDebugTab, type WidgetDebugData, type WidgetDebugEntity, WidgetDebugView, WidgetDialog, type SheetTile, type WidgetDialogProps, type WidgetDialogTab, } from "./dialogs";
|
|
39
|
-
export { type AggregationPreset, type ReactiveWidgetContext, type ServiceCallFn, type UseWidgetEntityGroupOptions, type UseWidgetEntityGroupResult, type Daylight, type DaylightPhase, useDaylight, useIntersectionPause, useReducedMotion, useWidgetContext, useWidgetDashboard, useMaterial, useWidgetViewer, useWidgetDialog, useWidgetDimensions, useWidgetEntityGroup, WidgetCtx, type WidgetDashboard, type WidgetMaterial, type WidgetViewer, type WidgetDialogReturn, type WidgetDimensions, type WidgetDimensionsAccessor, WidgetSizeCtx, } from "./hooks";
|
|
39
|
+
export { type AggregationPreset, type ReactiveWidgetContext, type ServiceCallFn, type UseWidgetEntityGroupOptions, type UseWidgetEntityGroupResult, type Daylight, type DaylightPhase, useDaylight, useIntersectionPause, useReducedMotion, useWidgetContext, useWidgetDashboard, useMaterial, useWidgetViewer, useWidgetState, useWidgetDialog, useWidgetDimensions, useWidgetEntityGroup, WidgetCtx, type WidgetDashboard, type WidgetMaterial, type WidgetViewer, type WidgetStateStore, type WidgetStateVerdict, type WidgetDialogReturn, type WidgetDimensions, type WidgetDimensionsAccessor, WidgetSizeCtx, } from "./hooks";
|
|
40
40
|
export { type GestureHandlers, useWidgetGestures } from "./gestures/use-widget-gestures";
|
|
41
41
|
export { injectTokens, type SvgColorKey, svgColors, type Tone, ToneSchema } from "./theming";
|
|
42
42
|
export { widgetFields } from "./fields";
|