@glasshome/widget-sdk 1.6.1 → 1.8.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/deprecations.js +8 -0
- package/dist/framework/config/index.d.ts +12 -0
- package/dist/framework/fields.d.ts +1 -1
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +51 -0
- package/dist/host/instantiate-widget.d.ts +48 -0
- package/dist/index.js +325 -339
- package/dist/tokens-Bdfb1xYe.js +33 -0
- package/dist/vite/index.d.ts +26 -0
- package/dist/vite/index.js +111 -60
- package/package.json +6 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "solid-js";
|
|
2
|
+
//#region src/framework/hooks/use-widget-context.ts
|
|
3
|
+
var n = e();
|
|
4
|
+
function r() {
|
|
5
|
+
let e = t(n);
|
|
6
|
+
if (!e) throw Error("useWidgetContext must be used within a Widget component");
|
|
7
|
+
return e;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/framework/theming/tokens.css?raw
|
|
11
|
+
var i = "/* Authoritative SDK CSS contract. Injected once on first Widget mount\n * via framework/theming/tokens.ts.\n *\n * All widget-internal visual scale is driven from CSS custom properties +\n * container queries on the `.glasshome-widget` shell (`container-type: size`).\n * No JS classifier, no size tier enum.\n */\n\n:root {\n --tone-success: oklch(0.70 0.18 145);\n --tone-warning: oklch(0.80 0.17 75);\n --tone-danger: oklch(0.64 0.22 27);\n --tone-info: oklch(0.66 0.20 245);\n --tone-neutral: oklch(0.65 0.02 250);\n --tone-accent: oklch(0.74 0.18 60);\n\n --widget-grad-strength: 1;\n --widget-glow-default: 0.4;\n --widget-border-highlight: oklch(0.98 0 0 / 0.4);\n}\n\n.dark {\n --tone-success: oklch(0.74 0.18 145);\n --tone-warning: oklch(0.82 0.17 75);\n --tone-danger: oklch(0.68 0.22 27);\n --tone-info: oklch(0.70 0.20 245);\n --tone-neutral: oklch(0.69 0.02 250);\n --tone-accent: oklch(0.78 0.18 60);\n\n --widget-grad-strength: 1.1;\n --widget-glow-default: 0.5;\n --widget-border-highlight: oklch(1 0 0 / 0.08);\n}\n\n@property --widget-color {\n syntax: \"<color>\";\n inherits: true;\n initial-value: oklch(0.65 0.02 250);\n}\n\n/* === Widget shell ===\n * Fluid scale tokens — tied to the shell's own container box (cqb=height, cqi=width).\n * Icon/pad/gap track HEIGHT (cqb) not the shortest side: two widgets of equal\n * height match regardless of width (a 2×2 and a 4×2 get the same icon). cqmin\n * starved portrait tiles by pinning the icon to the narrow width. Tune\n * multipliers / clamps to adjust density. */\n.glasshome-widget {\n --widget-color: var(--tone-neutral);\n --widget-glow-strength: var(--widget-glow-default);\n\n --widget-icon-box: clamp(44px, 25cqb, 58px);\n --widget-icon-glyph: clamp(24px, 14cqb, 33px);\n --widget-pad: clamp(8px, 3.5cqb, 22px);\n --widget-gap: clamp(6px, 2cqb, 14px);\n --widget-title-size: clamp(12px, 2cqi, 18px);\n --widget-subtitle: clamp(12px, 2.5cqi, 20px);\n --widget-status-size: clamp(14px, 5cqi, 36px);\n --widget-value-size: clamp(18px, 7cqi, 48px);\n --widget-badge-size: clamp(11px, 1.6cqi, 14px);\n}\n\n.glasshome-widget {\n background: var(--widget-gradient,\n linear-gradient(135deg,\n color-mix(in oklch, var(--widget-color) calc(22% * var(--widget-grad-strength)), transparent),\n color-mix(in oklch, var(--widget-color-to, var(--widget-color)) calc(11% * var(--widget-grad-strength)), transparent)\n )\n );\n box-shadow: inset 0 1px 0 var(--widget-border-highlight);\n}\n\n/* === Slot: content layout === */\n/* Default: column. Flip to row only on wide-and-short widgets (matches the\n * old contentLayout heuristic: aspect > 1 AND height < 150px). */\n.glasshome-widget-content {\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 100%;\n height: 100%;\n padding: var(--widget-pad);\n gap: var(--widget-gap);\n overflow: hidden;\n}\n@container widget (min-aspect-ratio: 1) and (max-height: 149px) {\n .glasshome-widget-content {\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n }\n}\n\n/* === Compact 1×1 ===\n * Small in BOTH axes → stack the tile: icon on top, label + status centered\n * under it. Icon stays moderate (not a hero) so the text keeps room. Wide\n * tiles (2×1) fail the width test and keep the row layout above. Placed after\n * the row-flip so it wins. */\n@container widget (max-width: 189px) and (max-height: 189px) {\n .glasshome-widget-content {\n flex-direction: column;\n align-items: center;\n justify-content: center;\n text-align: center;\n gap: clamp(4px, 2.5cqmin, 8px);\n }\n .glasshome-widget-content > * { align-items: center; text-align: center; }\n .glasshome-widget-icon {\n --widget-icon-box: clamp(36px, 30cqmin, 56px);\n --widget-icon-glyph: clamp(20px, 17cqmin, 32px);\n }\n .glasshome-widget-title { font-size: clamp(11px, 6cqmin, 14px); max-width: 100%; }\n .glasshome-widget-status,\n .glasshome-widget-value { font-size: clamp(13px, 7cqmin, 17px); }\n .glasshome-widget-content [class*=\"ml-auto\"] { margin-left: 0 !important; }\n}\n.glasshome-widget-content [class*=\"ml-auto\"] {\n position: relative;\n z-index: 30;\n}\n\n/* === Slot: icon === */\n.glasshome-widget-icon {\n width: var(--widget-icon-box);\n height: var(--widget-icon-box);\n border-radius: var(--radius-sm, 12px);\n background: var(--widget-icon-color, var(--widget-color));\n box-shadow: 0 0 calc(var(--widget-glow-strength) * 30px)\n color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 50%, transparent);\n color: oklch(from var(--widget-icon-color, var(--widget-color)) calc(0.52 + sign(0.5 - l) * 0.43) calc(c * 0.2) h);\n}\n.glasshome-widget-icon-glyph {\n font-size: var(--widget-icon-glyph);\n line-height: 1;\n}\n.glasshome-widget-icon-stack {\n position: absolute;\n width: 102%;\n height: 102%;\n border-radius: var(--radius-sm, 12px);\n}\n.glasshome-widget-icon-stack-2 { bottom: -14%; right: -10%; opacity: 0.45; z-index: -2; }\n.glasshome-widget-icon-stack-3 { bottom: -28%; right: -20%; opacity: 0.20; z-index: -3; }\n\n/* === Slot: text === */\n.glasshome-widget-title {\n font-size: var(--widget-title-size);\n line-height: 1.2;\n color: color-mix(in oklch, var(--color-foreground, currentColor) 60%, transparent);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.glasshome-widget-subtitle {\n font-size: var(--widget-subtitle);\n color: color-mix(in oklch, var(--color-foreground, currentColor) 60%, transparent);\n}\n.glasshome-widget-status {\n font-size: var(--widget-status-size);\n font-weight: 700;\n color: var(--color-foreground, currentColor);\n line-height: 1.1;\n}\n.glasshome-widget-value {\n font-size: var(--widget-value-size);\n font-weight: 700;\n color: var(--color-foreground, currentColor);\n line-height: 1.05;\n}\n.glasshome-widget-badge {\n font-size: var(--widget-badge-size);\n font-weight: 500;\n padding: 0.125rem 0.5rem;\n border-radius: 9999px;\n background: color-mix(in oklch, var(--color-foreground, currentColor) 20%, transparent);\n color: var(--color-foreground, currentColor);\n}\n\n.glasshome-widget-loading {\n background: color-mix(in oklch, var(--widget-color) 20%, transparent);\n}\n\n/* === Slider fill ===\n * Value flows in via --widget-fill-value (0-100). Vertical orientation auto-\n * detected via container query. */\n.glasshome-widget-slider-fill {\n --widget-fill-value: 0;\n background: color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 30%, transparent);\n box-shadow: 0 0 calc(var(--widget-glow-strength) * 40px)\n color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 40%, transparent);\n clip-path: inset(0 calc((100 - var(--widget-fill-value)) * 1%) 0 0);\n}\n@container widget (max-aspect-ratio: 1) {\n .glasshome-widget-slider-fill {\n clip-path: inset(calc((100 - var(--widget-fill-value)) * 1%) 0 0 0);\n }\n}\n", a = !1, o, s = /* @__PURE__ */ new WeakSet();
|
|
12
|
+
function c() {
|
|
13
|
+
return o || (o = new CSSStyleSheet(), o.replaceSync(i.replace(/:root\b/g, ":host").replace(/^\.dark\b/gm, ":host(.dark)"))), o;
|
|
14
|
+
}
|
|
15
|
+
function l(e) {
|
|
16
|
+
if (typeof ShadowRoot < "u" && e instanceof ShadowRoot) {
|
|
17
|
+
if (s.has(e)) return;
|
|
18
|
+
let t = c();
|
|
19
|
+
e.adoptedStyleSheets.includes(t) || (e.adoptedStyleSheets = [...e.adoptedStyleSheets, t]), s.add(e);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (a) return;
|
|
23
|
+
let t = e ?? (typeof document > "u" ? void 0 : document);
|
|
24
|
+
if (!t) return;
|
|
25
|
+
if (t.head.querySelector?.("style[data-glasshome-tokens]")) {
|
|
26
|
+
a = !0;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
let n = t.createElement("style");
|
|
30
|
+
n.setAttribute("data-glasshome-tokens", ""), n.textContent = i, t.head.appendChild(n), a = !0;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { n, r, l as t };
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -3,6 +3,32 @@ export interface GlasshomeWidgetOptions {
|
|
|
3
3
|
/** Entry file for the widget (default: "src/index.tsx") */
|
|
4
4
|
entry?: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Most previews anyone will look at, and the ceiling the hub renders to.
|
|
8
|
+
*
|
|
9
|
+
* Declaring more than this used to mean the extras were quietly not rendered:
|
|
10
|
+
* the gallery looked complete and was not. Failing the build instead makes the
|
|
11
|
+
* author decide which states matter rather than discovering the loss never.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAX_EXAMPLES = 20;
|
|
14
|
+
/**
|
|
15
|
+
* Configuration-drift guard (D-11). Imports the built bundle, derives the JSON
|
|
16
|
+
* Schema from its configSchema, and compares against the recorded
|
|
17
|
+
* `.schema-hash`. A shape change without a configVersion bump fails the build:
|
|
18
|
+
* tsc cannot catch this class of break because the old persisted config still
|
|
19
|
+
* parses, only its meaning shifts. Legacy plain-hash records (written by
|
|
20
|
+
* pre-1.7 builds) cannot prove a missing bump, so they only warn, then upgrade
|
|
21
|
+
* to the JSON record format.
|
|
22
|
+
*
|
|
23
|
+
* When `manifestPath` is given (single-widget projects), the generated JSON
|
|
24
|
+
* Schema is also written into `manifest.json` as `schema`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function runSchemaGuard(args: {
|
|
27
|
+
outFile: string;
|
|
28
|
+
hashFile: string;
|
|
29
|
+
widgetName: string;
|
|
30
|
+
manifestPath?: string;
|
|
31
|
+
}): Promise<void>;
|
|
6
32
|
/**
|
|
7
33
|
* Packages provided by the host import map — widgets must not bundle these.
|
|
8
34
|
* Delegates to the shared list in @glasshome/widget-contract so the host's
|
package/dist/vite/index.js
CHANGED
|
@@ -10,17 +10,75 @@ function v(e) {
|
|
|
10
10
|
let t = JSON.stringify(e, Object.keys(e).sort());
|
|
11
11
|
return r("sha256").update(t).digest("hex").slice(0, 16);
|
|
12
12
|
}
|
|
13
|
-
var y =
|
|
14
|
-
function
|
|
13
|
+
var y = 20;
|
|
14
|
+
async function b(e, t) {
|
|
15
|
+
if (e === void 0) return;
|
|
16
|
+
let n;
|
|
17
|
+
try {
|
|
18
|
+
({z: n} = await import("zod"));
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let r = n.number().int().positive(), i = n.array(n.object({
|
|
23
|
+
config: n.record(n.string(), n.unknown()),
|
|
24
|
+
size: n.object({
|
|
25
|
+
w: r,
|
|
26
|
+
h: r
|
|
27
|
+
}),
|
|
28
|
+
label: n.string().optional()
|
|
29
|
+
})).max(20).safeParse(e);
|
|
30
|
+
if (i.success) return;
|
|
31
|
+
let a = i.error.issues.map((e) => ` examples${e.path.length ? `[${e.path.join("][")}]` : ""}: ${e.message}`).join("\n");
|
|
32
|
+
throw Error(`[widget-sdk] Invalid \`examples\` for "${t}":\n${a}\nEach example needs a \`config\` object and a \`size\` of whole positive tiles, and at most 20 are rendered.`);
|
|
33
|
+
}
|
|
34
|
+
async function x(e) {
|
|
35
|
+
if (!i(e.outFile)) return;
|
|
36
|
+
let t;
|
|
37
|
+
try {
|
|
38
|
+
t = (await import(`${e.outFile}?t=${Date.now()}`)).default;
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (await b(t?.manifest?.examples, t?.manifest?.name ?? e.widgetName), !t?.configSchema) return;
|
|
43
|
+
let n;
|
|
44
|
+
try {
|
|
45
|
+
let { z: e } = await import("zod");
|
|
46
|
+
n = e.toJSONSchema(t.configSchema, { unrepresentable: "any" });
|
|
47
|
+
} catch {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (e.manifestPath && i(e.manifestPath)) {
|
|
51
|
+
let t = JSON.parse(o(e.manifestPath, "utf-8"));
|
|
52
|
+
t.schema = n, u(e.manifestPath, JSON.stringify(t, null, 2));
|
|
53
|
+
}
|
|
54
|
+
let r = v(n), a = t.manifest?.configVersion ?? null, s = t.manifest?.name ?? e.widgetName;
|
|
55
|
+
if (i(e.hashFile)) {
|
|
56
|
+
let t = o(e.hashFile, "utf-8").trim(), n = null;
|
|
57
|
+
if (t.startsWith("{")) try {
|
|
58
|
+
n = JSON.parse(t);
|
|
59
|
+
} catch {
|
|
60
|
+
n = null;
|
|
61
|
+
}
|
|
62
|
+
if (n) {
|
|
63
|
+
if (n.hash !== r && n.configVersion === a) throw Error(`[widget-sdk] Config schema shape changed for "${s}" without a configVersion bump. Bump configVersion in defineWidget (currently ${a ?? "unset"}) or revert the schema change, then rebuild. Recorded in ${e.hashFile}`);
|
|
64
|
+
} else t !== r && console.warn(`[widget-sdk] Schema shape changed for "${s}" — verify configVersion was bumped`);
|
|
65
|
+
}
|
|
66
|
+
u(e.hashFile, `${JSON.stringify({
|
|
67
|
+
hash: r,
|
|
68
|
+
configVersion: a
|
|
69
|
+
})}\n`);
|
|
70
|
+
}
|
|
71
|
+
var S = "virtual:glasshome-widget", C = "\0virtual:glasshome-widget", w = "/@glasshome/preview";
|
|
72
|
+
function T(e) {
|
|
15
73
|
return h === "\\" ? e.split(h).join("/") : e;
|
|
16
74
|
}
|
|
17
|
-
function
|
|
75
|
+
function E() {
|
|
18
76
|
return m(f(g(import.meta.url)), "../../preview");
|
|
19
77
|
}
|
|
20
|
-
function
|
|
78
|
+
function D(e) {
|
|
21
79
|
return t(e);
|
|
22
80
|
}
|
|
23
|
-
function
|
|
81
|
+
function O() {
|
|
24
82
|
return {
|
|
25
83
|
name: "glasshome-widget:sync-layer-guard",
|
|
26
84
|
apply: "build",
|
|
@@ -30,15 +88,15 @@ function T() {
|
|
|
30
88
|
}
|
|
31
89
|
};
|
|
32
90
|
}
|
|
33
|
-
var
|
|
34
|
-
function
|
|
91
|
+
var k = "node_modules/.cache/glasshome-widgets";
|
|
92
|
+
function A(e) {
|
|
35
93
|
try {
|
|
36
94
|
return d(p(process.cwd(), "package.json")).resolve(e);
|
|
37
95
|
} catch {
|
|
38
96
|
return null;
|
|
39
97
|
}
|
|
40
98
|
}
|
|
41
|
-
var
|
|
99
|
+
var j = [
|
|
42
100
|
"--radius",
|
|
43
101
|
"--background",
|
|
44
102
|
"--foreground",
|
|
@@ -48,21 +106,21 @@ var O = [
|
|
|
48
106
|
"--muted",
|
|
49
107
|
"--accent"
|
|
50
108
|
];
|
|
51
|
-
function
|
|
109
|
+
function M(e, t) {
|
|
52
110
|
let n = p(e, `${t}.css`);
|
|
53
111
|
if (!i(n)) return;
|
|
54
112
|
let r = o(n, "utf-8");
|
|
55
113
|
for (let e of r.matchAll(/:host[^{]*\{([^}]*)\}/g)) {
|
|
56
|
-
let n = e[1] ?? "", r =
|
|
114
|
+
let n = e[1] ?? "", r = j.find((e) => n.includes(`${e}:`));
|
|
57
115
|
if (r) throw Error(`[glasshome-widget] "${t}.css" defines theme variable "${r}" on :host. Theme variables must inherit from the document so widgets follow the household theme — never re-scope them into the widget's shadow root.`);
|
|
58
116
|
}
|
|
59
117
|
}
|
|
60
|
-
function
|
|
61
|
-
let r = m(e,
|
|
118
|
+
function N(e, t, n) {
|
|
119
|
+
let r = m(e, k);
|
|
62
120
|
a(r, { recursive: !0 });
|
|
63
|
-
let o =
|
|
121
|
+
let o = A("@glasshome/ui/styles");
|
|
64
122
|
if (!o) throw Error("[widget-sdk] @glasshome/ui is required to build widgets (it provides the theme every GlassHome widget ships with). Add it to your widget's dependencies.");
|
|
65
|
-
let s = m(f(o), "../.."), c =
|
|
123
|
+
let s = m(f(o), "../.."), c = A("@glasshome/widget-sdk/tailwind-sources"), l = c ? f(c) : null, d = [
|
|
66
124
|
p(s, "src"),
|
|
67
125
|
p(s, "dist"),
|
|
68
126
|
...l ? [p(l, "src"), p(l, "dist")] : [],
|
|
@@ -72,7 +130,7 @@ function A(e, t, n) {
|
|
|
72
130
|
"@import \"tailwindcss\" source(none);",
|
|
73
131
|
"@import \"tw-animate-css\";",
|
|
74
132
|
"@import \"@glasshome/ui/styles/theme\";",
|
|
75
|
-
...d.map((e) => `@source "${
|
|
133
|
+
...d.map((e) => `@source "${T(e)}";`),
|
|
76
134
|
"@custom-variant dark {",
|
|
77
135
|
" &:is(.dark *) { @slot }",
|
|
78
136
|
" :host(.dark) & { @slot }",
|
|
@@ -81,17 +139,17 @@ function A(e, t, n) {
|
|
|
81
139
|
].join("\n"));
|
|
82
140
|
let g = m(r, `${t}.entry.ts`);
|
|
83
141
|
return u(g, [
|
|
84
|
-
`import "${
|
|
85
|
-
`export { default } from "${
|
|
142
|
+
`import "${T(h)}";`,
|
|
143
|
+
`export { default } from "${T(n)}";`,
|
|
86
144
|
""
|
|
87
145
|
].join("\n")), g;
|
|
88
146
|
}
|
|
89
|
-
function
|
|
147
|
+
function P() {
|
|
90
148
|
let e = _();
|
|
91
149
|
for (let t of e) t.apply ??= "build";
|
|
92
150
|
return e;
|
|
93
151
|
}
|
|
94
|
-
function
|
|
152
|
+
function F(e) {
|
|
95
153
|
let t = [];
|
|
96
154
|
if (!i(e)) return t;
|
|
97
155
|
for (let n of s(e)) {
|
|
@@ -105,7 +163,7 @@ function M(e) {
|
|
|
105
163
|
}
|
|
106
164
|
return t;
|
|
107
165
|
}
|
|
108
|
-
function
|
|
166
|
+
function I(t, r) {
|
|
109
167
|
let c = [];
|
|
110
168
|
if (i(t)) for (let a of s(t)) {
|
|
111
169
|
if (!l(p(t, a)).isDirectory()) continue;
|
|
@@ -128,8 +186,8 @@ function N(t, r) {
|
|
|
128
186
|
};
|
|
129
187
|
i(r) || a(r, { recursive: !0 }), u(p(r, "registry.json"), JSON.stringify(d, null, 2)), console.log(`[registry] Generated registry.json with ${c.length} widget(s)`);
|
|
130
188
|
}
|
|
131
|
-
async function
|
|
132
|
-
let { build: t } = await import("vite"), n = process.cwd(), r = m(n, e?.srcDir ?? "src"), o = m(n, e?.outDir ?? "dist"), s =
|
|
189
|
+
async function L(e) {
|
|
190
|
+
let { build: t } = await import("vite"), n = process.cwd(), r = m(n, e?.srcDir ?? "src"), o = m(n, e?.outDir ?? "dist"), s = F(r);
|
|
133
191
|
if (s.length === 0) {
|
|
134
192
|
console.warn("[glasshome-widgets] No widgets found in", r);
|
|
135
193
|
return;
|
|
@@ -143,29 +201,33 @@ async function P(e) {
|
|
|
143
201
|
configFile: !1,
|
|
144
202
|
root: n,
|
|
145
203
|
plugins: [
|
|
146
|
-
...
|
|
204
|
+
...P(),
|
|
147
205
|
...e?.plugins ?? [],
|
|
148
|
-
|
|
206
|
+
O()
|
|
149
207
|
],
|
|
150
208
|
...e?.viteConfig,
|
|
151
209
|
build: {
|
|
152
210
|
lib: {
|
|
153
|
-
entry:
|
|
211
|
+
entry: N(n, r.name, r.entry),
|
|
154
212
|
formats: ["es"],
|
|
155
213
|
fileName: r.name,
|
|
156
214
|
cssFileName: r.name
|
|
157
215
|
},
|
|
158
|
-
rollupOptions: { external:
|
|
216
|
+
rollupOptions: { external: D },
|
|
159
217
|
outDir: o,
|
|
160
218
|
emptyOutDir: !1,
|
|
161
219
|
copyPublicDir: !1,
|
|
162
220
|
...e?.viteConfig?.build
|
|
163
221
|
},
|
|
164
222
|
logLevel: "warn"
|
|
165
|
-
}),
|
|
166
|
-
|
|
223
|
+
}), M(o, r.name), await x({
|
|
224
|
+
outFile: p(o, `${r.name}.js`),
|
|
225
|
+
hashFile: p(f(r.entry), ".schema-hash"),
|
|
226
|
+
widgetName: r.name
|
|
227
|
+
});
|
|
228
|
+
I(r, o);
|
|
167
229
|
}
|
|
168
|
-
function
|
|
230
|
+
function R(e) {
|
|
169
231
|
let t = e?.entry ?? "src/index.tsx", n = {
|
|
170
232
|
name: "glasshome-widget:build",
|
|
171
233
|
apply: "build",
|
|
@@ -173,12 +235,12 @@ function F(e) {
|
|
|
173
235
|
let e = process.cwd();
|
|
174
236
|
return { build: {
|
|
175
237
|
lib: {
|
|
176
|
-
entry:
|
|
238
|
+
entry: N(e, "index", m(e, t)),
|
|
177
239
|
formats: ["es"],
|
|
178
240
|
fileName: "index",
|
|
179
241
|
cssFileName: "index"
|
|
180
242
|
},
|
|
181
|
-
rollupOptions: { external:
|
|
243
|
+
rollupOptions: { external: D }
|
|
182
244
|
} };
|
|
183
245
|
}
|
|
184
246
|
}, r = {
|
|
@@ -186,7 +248,7 @@ function F(e) {
|
|
|
186
248
|
apply: "serve",
|
|
187
249
|
enforce: "pre",
|
|
188
250
|
config() {
|
|
189
|
-
let e =
|
|
251
|
+
let e = E(), t = process.cwd();
|
|
190
252
|
return { server: { fs: { allow: [
|
|
191
253
|
e,
|
|
192
254
|
t,
|
|
@@ -194,7 +256,7 @@ function F(e) {
|
|
|
194
256
|
] } } };
|
|
195
257
|
},
|
|
196
258
|
configureServer(e) {
|
|
197
|
-
let t = p(
|
|
259
|
+
let t = p(E(), "preview.html");
|
|
198
260
|
e.middlewares.use(async (n, r, i) => {
|
|
199
261
|
if (n.url === "/" || n.url === "/index.html") try {
|
|
200
262
|
let i = o(t, "utf-8");
|
|
@@ -206,44 +268,33 @@ function F(e) {
|
|
|
206
268
|
});
|
|
207
269
|
},
|
|
208
270
|
resolveId(e) {
|
|
209
|
-
if (e ===
|
|
210
|
-
if (e ===
|
|
271
|
+
if (e === w) return T(p(E(), "host.tsx"));
|
|
272
|
+
if (e === S) return C;
|
|
211
273
|
},
|
|
212
274
|
load(e) {
|
|
213
|
-
if (e ===
|
|
275
|
+
if (e === C) return `export { default } from "${T(m(process.cwd(), t))}";`;
|
|
214
276
|
}
|
|
215
|
-
},
|
|
277
|
+
}, i = {
|
|
216
278
|
name: "glasshome-widget:schema",
|
|
217
279
|
apply: "build",
|
|
218
280
|
async closeBundle() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (i(a)) {
|
|
226
|
-
let e = JSON.parse(o(a, "utf-8"));
|
|
227
|
-
e.schema = r, u(a, JSON.stringify(e, null, 2));
|
|
228
|
-
}
|
|
229
|
-
let s = v(r), c = m(process.cwd(), ".schema-hash");
|
|
230
|
-
if (i(c) && o(c, "utf-8").trim() !== s) {
|
|
231
|
-
let e = t.manifest?.name ?? "unknown";
|
|
232
|
-
console.warn(`[widget-sdk] Schema shape changed for "${e}" — verify configVersion was bumped`);
|
|
233
|
-
}
|
|
234
|
-
u(c, s);
|
|
235
|
-
} catch {}
|
|
281
|
+
M(m(process.cwd(), "dist"), "index"), await x({
|
|
282
|
+
outFile: m(process.cwd(), "dist", "index.js"),
|
|
283
|
+
hashFile: m(process.cwd(), ".schema-hash"),
|
|
284
|
+
widgetName: "index",
|
|
285
|
+
manifestPath: m(process.cwd(), "manifest.json")
|
|
286
|
+
});
|
|
236
287
|
}
|
|
237
288
|
};
|
|
238
289
|
return [
|
|
239
|
-
...
|
|
290
|
+
...P(),
|
|
240
291
|
n,
|
|
241
|
-
|
|
242
|
-
|
|
292
|
+
O(),
|
|
293
|
+
i,
|
|
243
294
|
r
|
|
244
295
|
];
|
|
245
296
|
}
|
|
246
|
-
function
|
|
297
|
+
function z(e) {
|
|
247
298
|
let t = e?.srcDir ?? "src", n = e?.outDir ?? "dist", r = [];
|
|
248
299
|
return [{
|
|
249
300
|
name: "glasshome-widgets:build",
|
|
@@ -262,7 +313,7 @@ function I(e) {
|
|
|
262
313
|
if (e === "\0glasshome-noop") return "export {}";
|
|
263
314
|
},
|
|
264
315
|
async closeBundle() {
|
|
265
|
-
await
|
|
316
|
+
await L({
|
|
266
317
|
srcDir: t,
|
|
267
318
|
outDir: n,
|
|
268
319
|
plugins: r
|
|
@@ -271,4 +322,4 @@ function I(e) {
|
|
|
271
322
|
}];
|
|
272
323
|
}
|
|
273
324
|
//#endregion
|
|
274
|
-
export {
|
|
325
|
+
export { y as MAX_EXAMPLES, L as buildWidgets, F as discoverWidgets, I as generateRegistry, R as glasshomeWidget, z as glasshomeWidgets, D as isWidgetExternal, x as runSchemaGuard };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glasshome/widget-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "SDK for building GlassHome dashboard widgets with SolidJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"glasshome",
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"types": "./dist/deprecations.d.ts",
|
|
33
33
|
"import": "./dist/deprecations.js"
|
|
34
34
|
},
|
|
35
|
+
"./host": {
|
|
36
|
+
"@glasshome/source": "./src/host/index.ts",
|
|
37
|
+
"types": "./dist/host/index.d.ts",
|
|
38
|
+
"import": "./dist/host/index.js"
|
|
39
|
+
},
|
|
35
40
|
"./vite": {
|
|
36
41
|
"@glasshome/source": "./src/vite/index.ts",
|
|
37
42
|
"types": "./dist/vite/index.d.ts",
|