@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.
@@ -0,0 +1 @@
1
+ export declare function normalizePath(p: string): string;
@@ -0,0 +1,28 @@
1
+ import type { Plugin } from "vite";
2
+ export interface GlasshomeWidgetOptions {
3
+ /** Entry file for the widget (default: "src/index.tsx") */
4
+ entry?: string;
5
+ }
6
+ /**
7
+ * Vite plugin for GlassHome widget development and building.
8
+ *
9
+ * Returns an array of plugins:
10
+ * - Build mode: configures library build with proper externals
11
+ * - Dev mode: serves a preview host with dark mode toggle and manifest display
12
+ */
13
+ export declare function glasshomeWidget(options?: GlasshomeWidgetOptions): Plugin[];
14
+ export interface GlasshomeWidgetsOptions {
15
+ /** Directory containing widget subdirectories (default: "src") */
16
+ srcDir?: string;
17
+ /** Output directory for built bundles and registry (default: "dist") */
18
+ outDir?: string;
19
+ }
20
+ /**
21
+ * Vite plugin for multi-widget projects.
22
+ *
23
+ * In build mode, delegates to `buildWidgets()` which runs a separate Vite
24
+ * build per widget so shared code is inlined (no chunk splitting).
25
+ * The plugin's `config()` returns a minimal build config to suppress Vite's
26
+ * default build, and `closeBundle()` runs the actual per-widget builds.
27
+ */
28
+ export declare function glasshomeWidgets(options?: GlasshomeWidgetsOptions): Plugin[];
@@ -0,0 +1,26 @@
1
+ import { type CapabilityGrant } from "@glasshome/widget-contract";
2
+ import { type IntrospectResult, type IntrospectSession } from "./introspect-session";
3
+ /** The most previews the hub renders; declaring more fails the build instead of dropping extras. */
4
+ export declare const MAX_EXAMPLES = 20;
5
+ /** SDK hooks that read a fixed entity on the widget's behalf, so the widget must declare that read. */
6
+ export declare const HOOK_READS: Record<string, string>;
7
+ export declare function assertHookReadsDeclared(code: string, capabilities: readonly CapabilityGrant[], widgetName: string): void;
8
+ export type Introspector = (outFile: string) => IntrospectResult | Promise<IntrospectResult>;
9
+ export declare function runSchemaGuard(args: {
10
+ outFile: string;
11
+ hashFile: string;
12
+ widgetName: string;
13
+ manifestPath?: string;
14
+ /** Persistent worker to reuse. Only `bun widget connect`'s watch loop passes one. */
15
+ session?: IntrospectSession;
16
+ /** Reads the bundle when no session is given. Defaults to one subprocess per call. */
17
+ introspect?: Introspector;
18
+ }): Promise<void>;
19
+ /** The two checks every built widget passes, in this order: host theme vars in its CSS, then the schema guard on its bundle. */
20
+ export declare function checkBuiltWidget(args: {
21
+ outDir: string;
22
+ name: string;
23
+ hashFile: string;
24
+ manifestPath: string;
25
+ session?: IntrospectSession;
26
+ }): Promise<void>;
@@ -0,0 +1,19 @@
1
+ import type { Plugin } from "vite";
2
+ /** The widget's own folder plus the project's shared folders: Tailwind only
3
+ * emits utilities for files it is pointed at, and a widget's shared component
4
+ * is as much its source as its entry. A sibling widget's folder stays out. */
5
+ export declare function widgetProjectScanDirs(srcDir: string, widgetEntry: string): string[];
6
+ /** 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. */
7
+ export declare function hostStylesUi(sdkRange: string | undefined): boolean;
8
+ /** 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. */
9
+ export declare function widgetTailwindEntry(scanDirs: string[], uiDir: string | null): string;
10
+ export declare function createWidgetBuildEntry(root: string, name: string, widgetEntry: string, srcDir: string, manifestPath: string): string;
11
+ /** Some embedded WebViews (Shelly Wall Display) drop hex colors with alpha, so
12
+ * the minifier must keep `transparent` / `rgba()` instead of `#0000` / `#rrggbbaa`. */
13
+ export declare function widgetCssConfig(): {
14
+ lightningcss: {
15
+ include: 16384;
16
+ };
17
+ };
18
+ /** Tailwind's vite plugin, constrained to build so dev-server setups that already run it don't double-process. */
19
+ export declare function buildOnlyTailwind(): Plugin[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-sdk",
3
- "version": "1.34.0",
3
+ "version": "1.34.2",
4
4
  "description": "SDK for building GlassHome dashboard widgets with SolidJS",
5
5
  "keywords": [
6
6
  "dashboard",
@@ -82,7 +82,7 @@
82
82
  "lint": "oxlint --type-aware . && oxfmt --check ."
83
83
  },
84
84
  "dependencies": {
85
- "@glasshome/widget-contract": "0.8.0",
85
+ "@glasshome/widget-contract": "0.9.0",
86
86
  "@tailwindcss/vite": "^4.1.13",
87
87
  "clsx": "^2.1.1",
88
88
  "happy-dom": "^20.0.0",