@glasshome/widget-sdk 1.34.0 → 1.34.2

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.
@@ -7638,5 +7638,305 @@
7638
7638
  "useWidgetViewer",
7639
7639
  "widgetFields",
7640
7640
  "z"
7641
+ ],
7642
+ "1.34.1": [
7643
+ "Badge",
7644
+ "Button",
7645
+ "ButtonGroup",
7646
+ "CameraSourceContext",
7647
+ "CameraStream",
7648
+ "Carousel",
7649
+ "CarouselContent",
7650
+ "CarouselDots",
7651
+ "CarouselItem",
7652
+ "CarouselNext",
7653
+ "CarouselPrevious",
7654
+ "ColorDisc",
7655
+ "ColorSlider",
7656
+ "ColorWheel",
7657
+ "CountPill",
7658
+ "Icon",
7659
+ "Input",
7660
+ "Label",
7661
+ "PanelEntityRow",
7662
+ "PanelFacts",
7663
+ "PanelRow",
7664
+ "PanelRows",
7665
+ "PanelSection",
7666
+ "Progress",
7667
+ "ResponsiveDialog",
7668
+ "ResponsiveDialogBody",
7669
+ "ResponsiveDialogClose",
7670
+ "ResponsiveDialogContent",
7671
+ "ResponsiveDialogDescription",
7672
+ "ResponsiveDialogFooter",
7673
+ "ResponsiveDialogHeader",
7674
+ "ResponsiveDialogTitle",
7675
+ "SDK_VERSION",
7676
+ "SchemaForm",
7677
+ "SectionIcon",
7678
+ "SectionTitle",
7679
+ "Select",
7680
+ "SelectContent",
7681
+ "SelectItem",
7682
+ "SelectTrigger",
7683
+ "SelectValue",
7684
+ "Slider",
7685
+ "SwatchPicker",
7686
+ "Switch",
7687
+ "Tabs",
7688
+ "TabsContent",
7689
+ "TabsList",
7690
+ "TabsTrigger",
7691
+ "TemperatureBar",
7692
+ "Toggle",
7693
+ "ToggleGroup",
7694
+ "ToggleGroupItem",
7695
+ "ToneSchema",
7696
+ "Widget",
7697
+ "WidgetAction",
7698
+ "WidgetBackdrop",
7699
+ "WidgetChip",
7700
+ "WidgetChoice",
7701
+ "WidgetContent",
7702
+ "WidgetControls",
7703
+ "WidgetCtx",
7704
+ "WidgetDebugTab",
7705
+ "WidgetDebugView",
7706
+ "WidgetDialog",
7707
+ "WidgetGlyph",
7708
+ "WidgetHead",
7709
+ "WidgetHero",
7710
+ "WidgetIcon",
7711
+ "WidgetLayer",
7712
+ "WidgetManifestSchema",
7713
+ "WidgetSizeCtx",
7714
+ "WidgetSliderFill",
7715
+ "WidgetStatus",
7716
+ "WidgetStepper",
7717
+ "WidgetTitle",
7718
+ "WidgetValue",
7719
+ "buildDebugData",
7720
+ "byDomain",
7721
+ "calculateLightGroup",
7722
+ "calculateSensorGroup",
7723
+ "copyText",
7724
+ "countActiveEntities",
7725
+ "defineConfig",
7726
+ "defineWidget",
7727
+ "deprecations",
7728
+ "field",
7729
+ "formatDeprecation",
7730
+ "formatSchemaError",
7731
+ "getEntityAttribute",
7732
+ "getForecasts",
7733
+ "getStream",
7734
+ "getWebRtcClientConfig",
7735
+ "hassMediaUrl",
7736
+ "imagePreset",
7737
+ "imageSrc",
7738
+ "imageUrl",
7739
+ "injectTokens",
7740
+ "isDark",
7741
+ "isEntityActive",
7742
+ "isPanelControllable",
7743
+ "mediaUrl",
7744
+ "monotoneCubicPath",
7745
+ "parseColor",
7746
+ "presetValue",
7747
+ "provideCameraSource",
7748
+ "sendWebRtcCandidate",
7749
+ "startWebRtcSession",
7750
+ "state",
7751
+ "svgColors",
7752
+ "trackEntityHistory",
7753
+ "untrackEntityHistory",
7754
+ "useArea",
7755
+ "useCalendarEvents",
7756
+ "useCamera",
7757
+ "useCameraSource",
7758
+ "useConfirm",
7759
+ "useConnection",
7760
+ "useCopyText",
7761
+ "useCurrency",
7762
+ "useDaylight",
7763
+ "useEntities",
7764
+ "useEntity",
7765
+ "useEntityHistory",
7766
+ "useEntityStatistics",
7767
+ "useForecast",
7768
+ "useHassConfig",
7769
+ "useIntersectionPause",
7770
+ "useLocale",
7771
+ "useMaterial",
7772
+ "useReducedMotion",
7773
+ "useService",
7774
+ "useSheetDormant",
7775
+ "useStore",
7776
+ "useTemperatureUnit",
7777
+ "useToggle",
7778
+ "useTurnOff",
7779
+ "useTurnOn",
7780
+ "useUnitSystem",
7781
+ "useWidgetContext",
7782
+ "useWidgetDashboard",
7783
+ "useWidgetDialog",
7784
+ "useWidgetDimensions",
7785
+ "useWidgetEntityGroup",
7786
+ "useWidgetGestures",
7787
+ "useWidgetState",
7788
+ "useWidgetViewer",
7789
+ "widgetFields",
7790
+ "z"
7791
+ ],
7792
+ "1.34.2": [
7793
+ "Badge",
7794
+ "Button",
7795
+ "ButtonGroup",
7796
+ "CameraSourceContext",
7797
+ "CameraStream",
7798
+ "Carousel",
7799
+ "CarouselContent",
7800
+ "CarouselDots",
7801
+ "CarouselItem",
7802
+ "CarouselNext",
7803
+ "CarouselPrevious",
7804
+ "ColorDisc",
7805
+ "ColorSlider",
7806
+ "ColorWheel",
7807
+ "CountPill",
7808
+ "Icon",
7809
+ "Input",
7810
+ "Label",
7811
+ "PanelEntityRow",
7812
+ "PanelFacts",
7813
+ "PanelRow",
7814
+ "PanelRows",
7815
+ "PanelSection",
7816
+ "Progress",
7817
+ "ResponsiveDialog",
7818
+ "ResponsiveDialogBody",
7819
+ "ResponsiveDialogClose",
7820
+ "ResponsiveDialogContent",
7821
+ "ResponsiveDialogDescription",
7822
+ "ResponsiveDialogFooter",
7823
+ "ResponsiveDialogHeader",
7824
+ "ResponsiveDialogTitle",
7825
+ "SDK_VERSION",
7826
+ "SchemaForm",
7827
+ "SectionIcon",
7828
+ "SectionTitle",
7829
+ "Select",
7830
+ "SelectContent",
7831
+ "SelectItem",
7832
+ "SelectTrigger",
7833
+ "SelectValue",
7834
+ "Slider",
7835
+ "SwatchPicker",
7836
+ "Switch",
7837
+ "Tabs",
7838
+ "TabsContent",
7839
+ "TabsList",
7840
+ "TabsTrigger",
7841
+ "TemperatureBar",
7842
+ "Toggle",
7843
+ "ToggleGroup",
7844
+ "ToggleGroupItem",
7845
+ "ToneSchema",
7846
+ "Widget",
7847
+ "WidgetAction",
7848
+ "WidgetBackdrop",
7849
+ "WidgetChip",
7850
+ "WidgetChoice",
7851
+ "WidgetContent",
7852
+ "WidgetControls",
7853
+ "WidgetCtx",
7854
+ "WidgetDebugTab",
7855
+ "WidgetDebugView",
7856
+ "WidgetDialog",
7857
+ "WidgetGlyph",
7858
+ "WidgetHead",
7859
+ "WidgetHero",
7860
+ "WidgetIcon",
7861
+ "WidgetLayer",
7862
+ "WidgetManifestSchema",
7863
+ "WidgetSizeCtx",
7864
+ "WidgetSliderFill",
7865
+ "WidgetStatus",
7866
+ "WidgetStepper",
7867
+ "WidgetTitle",
7868
+ "WidgetValue",
7869
+ "buildDebugData",
7870
+ "byDomain",
7871
+ "calculateLightGroup",
7872
+ "calculateSensorGroup",
7873
+ "copyText",
7874
+ "countActiveEntities",
7875
+ "defineConfig",
7876
+ "defineWidget",
7877
+ "deprecations",
7878
+ "field",
7879
+ "formatDeprecation",
7880
+ "formatSchemaError",
7881
+ "getEntityAttribute",
7882
+ "getForecasts",
7883
+ "getStream",
7884
+ "getWebRtcClientConfig",
7885
+ "hassMediaUrl",
7886
+ "imagePreset",
7887
+ "imageSrc",
7888
+ "imageUrl",
7889
+ "injectTokens",
7890
+ "isDark",
7891
+ "isEntityActive",
7892
+ "isPanelControllable",
7893
+ "mediaUrl",
7894
+ "monotoneCubicPath",
7895
+ "parseColor",
7896
+ "presetValue",
7897
+ "provideCameraSource",
7898
+ "sendWebRtcCandidate",
7899
+ "startWebRtcSession",
7900
+ "state",
7901
+ "svgColors",
7902
+ "trackEntityHistory",
7903
+ "untrackEntityHistory",
7904
+ "useArea",
7905
+ "useCalendarEvents",
7906
+ "useCamera",
7907
+ "useCameraSource",
7908
+ "useConfirm",
7909
+ "useConnection",
7910
+ "useCopyText",
7911
+ "useCurrency",
7912
+ "useDaylight",
7913
+ "useEntities",
7914
+ "useEntity",
7915
+ "useEntityHistory",
7916
+ "useEntityStatistics",
7917
+ "useForecast",
7918
+ "useHassConfig",
7919
+ "useIntersectionPause",
7920
+ "useLocale",
7921
+ "useMaterial",
7922
+ "useReducedMotion",
7923
+ "useService",
7924
+ "useSheetDormant",
7925
+ "useStore",
7926
+ "useTemperatureUnit",
7927
+ "useToggle",
7928
+ "useTurnOff",
7929
+ "useTurnOn",
7930
+ "useUnitSystem",
7931
+ "useWidgetContext",
7932
+ "useWidgetDashboard",
7933
+ "useWidgetDialog",
7934
+ "useWidgetDimensions",
7935
+ "useWidgetEntityGroup",
7936
+ "useWidgetGestures",
7937
+ "useWidgetState",
7938
+ "useWidgetViewer",
7939
+ "widgetFields",
7940
+ "z"
7641
7941
  ]
7642
7942
  }
package/dist/index.js CHANGED
@@ -3449,7 +3449,7 @@ function Cs(e) {
3449
3449
  //#region src/version.ts
3450
3450
  var ws = {
3451
3451
  name: "@glasshome/widget-sdk",
3452
- version: "1.34.0",
3452
+ version: "1.34.2",
3453
3453
  description: "SDK for building GlassHome dashboard widgets with SolidJS",
3454
3454
  keywords: [
3455
3455
  "dashboard",
@@ -3527,7 +3527,7 @@ var ws = {
3527
3527
  lint: "oxlint --type-aware . && oxfmt --check ."
3528
3528
  },
3529
3529
  dependencies: {
3530
- "@glasshome/widget-contract": "0.8.0",
3530
+ "@glasshome/widget-contract": "0.9.0",
3531
3531
  "@tailwindcss/vite": "^4.1.13",
3532
3532
  clsx: "^2.1.1",
3533
3533
  "happy-dom": "^20.0.0",
@@ -0,0 +1,21 @@
1
+ import type { InlineConfig, Plugin } from "vite";
2
+ import type { IntrospectSession } from "./introspect-session";
3
+ export interface BuildWidgetsOptions {
4
+ /** Directory containing widget subdirectories (default: "src") */
5
+ srcDir?: string;
6
+ /** Output directory for built bundles and registry (default: "dist") */
7
+ outDir?: string;
8
+ /** Additional Vite plugins to apply to each widget build (e.g. solid()) */
9
+ plugins?: Plugin[];
10
+ /** Extra Vite config merged into each widget build */
11
+ viteConfig?: InlineConfig;
12
+ /** Build only these widget names (subdirectory names). Skips full clean. */
13
+ only?: string[];
14
+ /** Persistent introspection worker to reuse across rebuilds. */
15
+ session?: IntrospectSession;
16
+ }
17
+ /**
18
+ * Build each widget as a separate Vite invocation so shared code is inlined
19
+ * into each bundle (no chunk splitting).
20
+ */
21
+ export declare function buildWidgets(options?: BuildWidgetsOptions): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function dropSelfReferencingVars(css: string): string;
2
+ export declare function assertNoHostThemeVars(outDir: string, name: string): void;
@@ -0,0 +1,9 @@
1
+ interface DiscoveredWidget {
2
+ name: string;
3
+ entry: string;
4
+ }
5
+ /** Scan srcDir for subdirectories containing index.tsx + manifest.json. */
6
+ export declare function discoverWidgets(srcDir: string): DiscoveredWidget[];
7
+ /** Generate registry.json from widget manifests, validated against the contract schema. */
8
+ export declare function generateRegistry(srcDir: string, outDir: string): void;
9
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * Packages provided by the host import map; widgets must not bundle these.
4
+ * Delegates to the shared list in @glasshome/widget-contract so the host's
5
+ * import map and the widget build can never disagree again. Exact match only:
6
+ * a specifier the import map does not serve (e.g. "@glasshome/ui/tokens")
7
+ * must be bundled, because leaving it external is a runtime 404.
8
+ */
9
+ export declare function isWidgetExternal(id: string): boolean;
10
+ /**
11
+ * True when a widget source file imports `@glasshome/sync-layer` directly.
12
+ * Same file filters as `isDirectUiImportSource`: node_modules is the SDK's own
13
+ * business, and non-script assets are not scanned.
14
+ */
15
+ export declare function isDirectSyncLayerImportSource(id: string, code: string): boolean;
16
+ /**
17
+ * Fails the build when a widget imports @glasshome/sync-layer directly.
18
+ * The single store instance lives in the host; bundling a second copy would
19
+ * silently disconnect the widget from live state. Widgets must use the
20
+ * hooks re-exported by @glasshome/widget-sdk (capability-routed by the host).
21
+ *
22
+ * Detection is a `transform` source scan, not `resolveId`. Rollup consults
23
+ * `rollupOptions.external` before plugin `resolveId` hooks, so an externalized
24
+ * specifier never reaches them: under Vite 8 this guard threw on nothing at all
25
+ * and a seeded direct import built clean. A hard-error contract enforcing
26
+ * nothing is worse than no contract, because the green build is read as proof.
27
+ */
28
+ export declare function syncLayerImportGuard(): Plugin;
29
+ /**
30
+ * True when a widget source file imports `@glasshome/ui` directly. The regex is
31
+ * the registry's `sourcePattern` for `direct-ui-import`, so the build warning and
32
+ * the widget-cli lint can never disagree on what counts as a direct import.
33
+ * node_modules is excluded: dependencies and the SDK's own generated entries in
34
+ * BUILD_CACHE_DIR (the theme `@import`) are the SDK's business, not the widget's.
35
+ */
36
+ export declare function isDirectUiImportSource(id: string, code: string): boolean;
37
+ /**
38
+ * Warns (never fails) when widget source imports @glasshome/ui directly.
39
+ * Warn-only counterpart to syncLayerImportGuard: direct imports keep working
40
+ * until 2.0, but they bypass the sdkVersion gate, so ui can drift against
41
+ * published widgets with nothing checking compatibility. Detection scans
42
+ * module source in `transform` because externalized specifiers never reach
43
+ * `resolveId` (rollup consults `external` for the bare id first).
44
+ *
45
+ * `warned` carries the files already reported across every build in one run, so
46
+ * a module shared by N widgets is named once and not once per bundle it lands in.
47
+ */
48
+ export declare function createUiImportTracker(warned?: Set<string>): {
49
+ scan(id: string, code: string): void;
50
+ /** Offending files this run has not reported yet; marks them reported. */
51
+ take(): string[];
52
+ };
53
+ export declare function uiImportGuard(warned?: Set<string>): Plugin;
@@ -1,129 +1,11 @@
1
- import { type CapabilityGrant } from "@glasshome/widget-contract";
2
- import type { InlineConfig, Plugin } from "vite";
3
1
  import type { ExampleConfigIssue, WidgetIntrospection } from "./introspect-core";
4
- import { createIntrospectSession, type IntrospectResult, type IntrospectSession, type IntrospectSessionOptions, introspectOnce } from "./introspect-session";
2
+ import { createIntrospectSession, type IntrospectSession, type IntrospectSessionOptions, introspectOnce } from "./introspect-session";
5
3
  export { createIntrospectSession, introspectOnce };
6
4
  export type { ExampleConfigIssue, IntrospectSession, IntrospectSessionOptions, WidgetIntrospection, };
7
- export interface GlasshomeWidgetOptions {
8
- /** Entry file for the widget (default: "src/index.tsx") */
9
- entry?: string;
10
- }
11
- /**
12
- * Most previews anyone will look at, and the ceiling the hub renders to.
13
- *
14
- * Declaring more than this used to mean the extras were quietly not rendered:
15
- * the gallery looked complete and was not. Failing the build instead makes the
16
- * author decide which states matter rather than discovering the loss never.
17
- */
18
- export declare const MAX_EXAMPLES = 20;
19
- /** SDK hooks that read a fixed entity on the widget's behalf, so the widget must declare that read. */
20
- export declare const HOOK_READS: Record<string, string>;
21
- export declare function assertHookReadsDeclared(code: string, capabilities: readonly CapabilityGrant[], widgetName: string): void;
22
- export type Introspector = (outFile: string) => IntrospectResult | Promise<IntrospectResult>;
23
- export declare function runSchemaGuard(args: {
24
- outFile: string;
25
- hashFile: string;
26
- widgetName: string;
27
- manifestPath?: string;
28
- /** Persistent worker to reuse. Only `bun widget connect`'s watch loop passes one. */
29
- session?: IntrospectSession;
30
- /** Reads the bundle when no session is given. Defaults to one subprocess per call. */
31
- introspect?: Introspector;
32
- }): Promise<void>;
33
- /**
34
- * Packages provided by the host import map — widgets must not bundle these.
35
- * Delegates to the shared list in @glasshome/widget-contract so the host's
36
- * import map and the widget build can never disagree again. Exact match only:
37
- * a specifier the import map does not serve (e.g. "@glasshome/ui/tokens")
38
- * must be bundled, because leaving it external is a runtime 404.
39
- */
40
- export declare function isWidgetExternal(id: string): boolean;
41
- /**
42
- * True when a widget source file imports `@glasshome/sync-layer` directly.
43
- * Same file filters as `isDirectUiImportSource`: node_modules is the SDK's own
44
- * business, and non-script assets are not scanned.
45
- */
46
- export declare function isDirectSyncLayerImportSource(id: string, code: string): boolean;
47
- /**
48
- * True when a widget source file imports `@glasshome/ui` directly. The regex is
49
- * the registry's `sourcePattern` for `direct-ui-import`, so the build warning and
50
- * the widget-cli lint can never disagree on what counts as a direct import.
51
- * node_modules is excluded: dependencies and the SDK's own generated entries in
52
- * BUILD_CACHE_DIR (the theme `@import`) are the SDK's business, not the widget's.
53
- */
54
- export declare function isDirectUiImportSource(id: string, code: string): boolean;
55
- /**
56
- * Warns (never fails) when widget source imports @glasshome/ui directly.
57
- * Warn-only counterpart to syncLayerImportGuard: direct imports keep working
58
- * until 2.0, but they bypass the sdkVersion gate, so ui can drift against
59
- * published widgets with nothing checking compatibility. Detection scans
60
- * module source in `transform` because externalized specifiers never reach
61
- * `resolveId` (rollup consults `external` for the bare id first).
62
- *
63
- * `warned` carries the files already reported across every build in one run, so
64
- * a module shared by N widgets is named once and not once per bundle it lands in.
65
- */
66
- export declare function createUiImportTracker(warned?: Set<string>): {
67
- scan(id: string, code: string): void;
68
- /** Offending files this run has not reported yet; marks them reported. */
69
- take(): string[];
70
- };
71
- export declare function dropSelfReferencingVars(css: string): string;
72
- /** The widget's own folder plus the project's shared folders: Tailwind only
73
- * emits utilities for files it is pointed at, and a widget's shared component
74
- * is as much its source as its entry. A sibling widget's folder stays out. */
75
- export declare function widgetProjectScanDirs(srcDir: string, widgetEntry: string): string[];
76
- /** True when every host the range admits adopts ui's compiled CSS into each widget root, so the widget's sheet need not carry ui. */
77
- export declare function hostStylesUi(sdkRange: string | undefined): boolean;
78
- /** The Tailwind entry a widget's CSS compiles from: its own and the SDK's classes, plus all of ui while an older host it admits does not style ui itself. */
79
- export declare function widgetTailwindEntry(scanDirs: string[], uiDir: string | null): string;
80
- interface DiscoveredWidget {
81
- name: string;
82
- entry: string;
83
- }
84
- /** Scan srcDir for subdirectories containing index.tsx + manifest.json. */
85
- export declare function discoverWidgets(srcDir: string): DiscoveredWidget[];
86
- /** Generate registry.json from widget manifests, validated against the contract schema. */
87
- export declare function generateRegistry(srcDir: string, outDir: string): void;
88
- export interface BuildWidgetsOptions {
89
- /** Directory containing widget subdirectories (default: "src") */
90
- srcDir?: string;
91
- /** Output directory for built bundles and registry (default: "dist") */
92
- outDir?: string;
93
- /** Additional Vite plugins to apply to each widget build (e.g. solid()) */
94
- plugins?: Plugin[];
95
- /** Extra Vite config merged into each widget build */
96
- viteConfig?: InlineConfig;
97
- /** Build only these widget names (subdirectory names). Skips full clean. */
98
- only?: string[];
99
- /** Persistent introspection worker to reuse across rebuilds. */
100
- session?: IntrospectSession;
101
- }
102
- /**
103
- * Build each widget as a separate Vite invocation so shared code is inlined
104
- * into each bundle (no chunk splitting).
105
- */
106
- export declare function buildWidgets(options?: BuildWidgetsOptions): Promise<void>;
107
- /**
108
- * Vite plugin for GlassHome widget development and building.
109
- *
110
- * Returns an array of plugins:
111
- * - Build mode: configures library build with proper externals
112
- * - Dev mode: serves a preview host with dark mode toggle and manifest display
113
- */
114
- export declare function glasshomeWidget(options?: GlasshomeWidgetOptions): Plugin[];
115
- export interface GlasshomeWidgetsOptions {
116
- /** Directory containing widget subdirectories (default: "src") */
117
- srcDir?: string;
118
- /** Output directory for built bundles and registry (default: "dist") */
119
- outDir?: string;
120
- }
121
- /**
122
- * Vite plugin for multi-widget projects.
123
- *
124
- * In build mode, delegates to `buildWidgets()` which runs a separate Vite
125
- * build per widget so shared code is inlined (no chunk splitting).
126
- * The plugin's `config()` returns a minimal build config to suppress Vite's
127
- * default build, and `closeBundle()` runs the actual per-widget builds.
128
- */
129
- export declare function glasshomeWidgets(options?: GlasshomeWidgetsOptions): Plugin[];
5
+ export { type BuildWidgetsOptions, buildWidgets } from "./build";
6
+ export { discoverWidgets, generateRegistry } from "./discover";
7
+ export { createUiImportTracker, isDirectSyncLayerImportSource, isDirectUiImportSource, isWidgetExternal, } from "./import-guards";
8
+ export { assertHookReadsDeclared, HOOK_READS, type Introspector, MAX_EXAMPLES, runSchemaGuard, } from "./schema-guard";
9
+ export { dropSelfReferencingVars } from "./css-guard";
10
+ export { glasshomeWidget, type GlasshomeWidgetOptions, glasshomeWidgets, type GlasshomeWidgetsOptions, } from "./plugin";
11
+ export { hostStylesUi, widgetProjectScanDirs, widgetTailwindEntry } from "./tailwind-entry";