@glasshome/widget-sdk 1.14.3 → 1.15.1
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 +14 -0
- package/dist/framework/hooks/index.d.ts +3 -1
- package/dist/framework/hooks/use-widget-context.d.ts +13 -0
- package/dist/framework/hooks/use-widget-dashboard.d.ts +2 -0
- package/dist/framework/hooks/use-widget-viewer.d.ts +4 -0
- package/dist/framework/index.d.ts +1 -1
- package/dist/index.js +286 -258
- package/dist/ui.d.ts +3 -2
- package/dist/vite/index.js +136 -123
- package/package.json +4 -4
package/dist/ui.d.ts
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* The set is exactly what shipped widgets use; extending it is an additive
|
|
11
11
|
* SDK minor. Direct `@glasshome/ui` imports keep working but are deprecated
|
|
12
|
-
* (`direct-ui-import` in the registry), removed in 2.0.0.
|
|
12
|
+
* (`direct-ui-import` in the registry), removed in 2.0.0. `Icon` is the
|
|
13
|
+
* replacement for the `iconify-icon` element (`iconify-icon` in the registry).
|
|
13
14
|
*
|
|
14
15
|
* `@glasshome/ui/solid` is a vite external of this package: these re-exports
|
|
15
16
|
* resolve to the host-provided singleton at runtime, never a bundled copy.
|
|
16
17
|
*/
|
|
17
|
-
export { Badge, Button, Carousel, type CarouselApi, CarouselContent, CarouselDots, CarouselItem, CarouselNext, CarouselPrevious, type CarouselTransition, type Color, ColorSlider, ColorWheel, imageUrl, Input, Label, mediaUrl, parseColor, ResponsiveDialog, ResponsiveDialogBody, ResponsiveDialogClose, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, SchemaForm, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Switch, Tabs, TabsContent, TabsList, TabsTrigger, } from "@glasshome/ui/solid";
|
|
18
|
+
export { Badge, Button, Carousel, type CarouselApi, CarouselContent, CarouselDots, CarouselItem, CarouselNext, CarouselPrevious, type CarouselTransition, type Color, ColorSlider, ColorWheel, CountPill, Icon, imageUrl, Input, Label, mediaUrl, parseColor, ResponsiveDialog, ResponsiveDialogBody, ResponsiveDialogClose, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, SchemaForm, SectionIcon, SectionTitle, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Switch, Tabs, TabsContent, TabsList, TabsTrigger, } from "@glasshome/ui/solid";
|
package/dist/vite/index.js
CHANGED
|
@@ -6,27 +6,27 @@ import { createRequire as p } from "node:module";
|
|
|
6
6
|
import { dirname as m, join as h, relative as g, resolve as _, sep as v } from "node:path";
|
|
7
7
|
import { fileURLToPath as y } from "node:url";
|
|
8
8
|
import ee from "@tailwindcss/vite";
|
|
9
|
-
import { spawn as te, spawnSync as
|
|
9
|
+
import { spawn as te, spawnSync as ne } from "node:child_process";
|
|
10
10
|
//#region src/vite/introspect-session.ts
|
|
11
|
-
var
|
|
12
|
-
function
|
|
11
|
+
var re = 262144e3, b = 3e4, ie = 3e3;
|
|
12
|
+
function x(e) {
|
|
13
13
|
let t = m(y(import.meta.url));
|
|
14
14
|
return [h(t, `${e}.js`), h(t, `${e}.ts`)].find((e) => o(e)) ?? null;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
let t =
|
|
16
|
+
function S(e) {
|
|
17
|
+
let t = x("introspect");
|
|
18
18
|
if (!t) return {
|
|
19
19
|
ok: !1,
|
|
20
20
|
reason: "introspect not found next to the sdk"
|
|
21
21
|
};
|
|
22
|
-
let n =
|
|
22
|
+
let n = ne(process.execPath, [
|
|
23
23
|
"--conditions",
|
|
24
24
|
"browser",
|
|
25
25
|
t,
|
|
26
26
|
e
|
|
27
27
|
], {
|
|
28
28
|
encoding: "utf-8",
|
|
29
|
-
timeout:
|
|
29
|
+
timeout: b
|
|
30
30
|
});
|
|
31
31
|
if (n.error) return {
|
|
32
32
|
ok: !1,
|
|
@@ -48,49 +48,44 @@ function w(e) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function ae() {
|
|
52
52
|
return {
|
|
53
|
-
introspect: async (e) =>
|
|
53
|
+
introspect: async (e) => S(e),
|
|
54
54
|
dispose: async () => {},
|
|
55
55
|
childPid: null
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
if (process.env.GLASSHOME_WIDGET_NO_WORKER === "1") return
|
|
60
|
-
let t = e?.rssLimitBytes ??
|
|
61
|
-
function
|
|
62
|
-
for (let
|
|
58
|
+
function C(e) {
|
|
59
|
+
if (process.env.GLASSHOME_WIDGET_NO_WORKER === "1") return ae();
|
|
60
|
+
let t = e?.rssLimitBytes ?? re, n = e?.timeoutMs ?? b, r = e?.slowMs ?? ie, i = null, a = !1, o = 0, s = Promise.resolve();
|
|
61
|
+
function c(e, t) {
|
|
62
|
+
for (let n of e.pending.values()) n({
|
|
63
63
|
ok: !1,
|
|
64
|
-
reason:
|
|
64
|
+
reason: t
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
e.pending.clear();
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
i = null, a = null, o = !1, d(e), t?.kill();
|
|
68
|
+
function l(e, t) {
|
|
69
|
+
i === e && (i = null), c(e, t), e.proc.kill();
|
|
71
70
|
}
|
|
72
|
-
function
|
|
73
|
-
let
|
|
71
|
+
function u(e, n) {
|
|
72
|
+
let i;
|
|
74
73
|
try {
|
|
75
|
-
|
|
74
|
+
i = JSON.parse(n);
|
|
76
75
|
} catch {
|
|
77
76
|
return;
|
|
78
77
|
}
|
|
79
|
-
if (typeof
|
|
80
|
-
let
|
|
81
|
-
|
|
78
|
+
if (typeof i.id != "number") return;
|
|
79
|
+
let a = e.pending.get(i.id);
|
|
80
|
+
a && (e.pending.delete(i.id), (i.rss ?? 0) > t && (e.retireAfterRequest = !0), (i.importMs ?? 0) > r && console.warn(`[widget-sdk] introspection took ${i.importMs}ms`), a(i.ok ? {
|
|
82
81
|
ok: !0,
|
|
83
|
-
value:
|
|
82
|
+
value: i.value
|
|
84
83
|
} : {
|
|
85
84
|
ok: !1,
|
|
86
|
-
reason:
|
|
85
|
+
reason: i.reason ?? "introspection failed"
|
|
87
86
|
}));
|
|
88
87
|
}
|
|
89
|
-
function
|
|
90
|
-
if (i && a && !o) return a;
|
|
91
|
-
(o || i) && f("worker was replaced");
|
|
92
|
-
let e = C("introspect-worker");
|
|
93
|
-
if (!e) return Promise.reject(/* @__PURE__ */ Error("introspect-worker not found next to the sdk"));
|
|
88
|
+
function d(e) {
|
|
94
89
|
let t = Date.now(), n = te(process.execPath, [
|
|
95
90
|
"--conditions",
|
|
96
91
|
"browser",
|
|
@@ -99,68 +94,77 @@ function ie(e) {
|
|
|
99
94
|
"pipe",
|
|
100
95
|
"pipe",
|
|
101
96
|
"inherit"
|
|
102
|
-
] })
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
] }), a = {
|
|
98
|
+
proc: n,
|
|
99
|
+
ready: Promise.resolve(),
|
|
100
|
+
pending: /* @__PURE__ */ new Map(),
|
|
101
|
+
retireAfterRequest: !1
|
|
102
|
+
};
|
|
103
|
+
return a.ready = new Promise((e, o) => {
|
|
104
|
+
let s = "", l = !1;
|
|
106
105
|
n.stdout?.setEncoding("utf-8"), n.stdout?.on("data", (n) => {
|
|
107
106
|
s += n;
|
|
108
107
|
let i = s.indexOf("\n");
|
|
109
108
|
for (; i >= 0;) {
|
|
110
109
|
let n = s.slice(0, i).trim();
|
|
111
110
|
if (s = s.slice(i + 1), n) {
|
|
112
|
-
if (!
|
|
113
|
-
|
|
111
|
+
if (!l && n.includes("\"ready\"")) {
|
|
112
|
+
l = !0;
|
|
114
113
|
let n = Date.now() - t;
|
|
115
114
|
n > r && console.warn(`[widget-sdk] introspect worker took ${n}ms to boot`), e();
|
|
116
|
-
} else
|
|
115
|
+
} else u(a, n);
|
|
117
116
|
}
|
|
118
117
|
i = s.indexOf("\n");
|
|
119
118
|
}
|
|
120
119
|
});
|
|
121
|
-
let
|
|
122
|
-
i ===
|
|
120
|
+
let d = (e) => {
|
|
121
|
+
l || o(Error(e)), i === a && (i = null), c(a, e);
|
|
123
122
|
};
|
|
124
|
-
n.on("error", (e) =>
|
|
125
|
-
});
|
|
126
|
-
return a = s, s;
|
|
123
|
+
n.on("error", (e) => d(e.message)), n.on("exit", (e, t) => d(`introspect worker exited (${t ?? `code ${e}`})`));
|
|
124
|
+
}), a;
|
|
127
125
|
}
|
|
128
|
-
async function
|
|
129
|
-
if (
|
|
126
|
+
async function f(e) {
|
|
127
|
+
if (a) return {
|
|
130
128
|
ok: !1,
|
|
131
129
|
reason: "introspect session disposed"
|
|
132
130
|
};
|
|
131
|
+
let t = x("introspect-worker");
|
|
132
|
+
if (!t) return {
|
|
133
|
+
ok: !1,
|
|
134
|
+
reason: "introspect-worker not found next to the sdk"
|
|
135
|
+
};
|
|
136
|
+
i?.retireAfterRequest && l(i, "worker was replaced");
|
|
137
|
+
let r = i ??= d(t);
|
|
133
138
|
try {
|
|
134
|
-
await
|
|
139
|
+
await r.ready;
|
|
135
140
|
} catch (e) {
|
|
136
141
|
return {
|
|
137
142
|
ok: !1,
|
|
138
143
|
reason: e instanceof Error ? e.message : String(e)
|
|
139
144
|
};
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
if (!t?.stdin?.writable) return {
|
|
146
|
+
if (!r.proc.stdin?.writable) return {
|
|
143
147
|
ok: !1,
|
|
144
148
|
reason: "introspect worker is not writable"
|
|
145
149
|
};
|
|
146
|
-
let
|
|
147
|
-
return new Promise((
|
|
148
|
-
let
|
|
149
|
-
|
|
150
|
+
let s = ++o;
|
|
151
|
+
return new Promise((t) => {
|
|
152
|
+
let i = setTimeout(() => {
|
|
153
|
+
r.pending.delete(s), l(r, `introspection timed out after ${n}ms`), t({
|
|
150
154
|
ok: !1,
|
|
151
155
|
reason: `introspection timed out after ${n}ms`
|
|
152
156
|
});
|
|
153
157
|
}, n);
|
|
154
|
-
|
|
155
|
-
clearTimeout(
|
|
158
|
+
r.pending.set(s, (e) => {
|
|
159
|
+
clearTimeout(i), t(e);
|
|
156
160
|
});
|
|
157
161
|
try {
|
|
158
|
-
|
|
159
|
-
id:
|
|
162
|
+
r.proc.stdin?.write(`${JSON.stringify({
|
|
163
|
+
id: s,
|
|
160
164
|
outFile: e
|
|
161
165
|
})}\n`);
|
|
162
166
|
} catch (e) {
|
|
163
|
-
clearTimeout(
|
|
167
|
+
clearTimeout(i), r.pending.delete(s), r.retireAfterRequest = !0, t({
|
|
164
168
|
ok: !1,
|
|
165
169
|
reason: e instanceof Error ? e.message : String(e)
|
|
166
170
|
});
|
|
@@ -169,25 +173,33 @@ function ie(e) {
|
|
|
169
173
|
}
|
|
170
174
|
return {
|
|
171
175
|
introspect(e) {
|
|
172
|
-
let t =
|
|
173
|
-
return
|
|
176
|
+
let t = s.then(() => f(e));
|
|
177
|
+
return s = t.catch(() => void 0), t;
|
|
174
178
|
},
|
|
175
179
|
async dispose() {
|
|
176
|
-
|
|
180
|
+
a = !0, i && l(i, "introspect session disposed");
|
|
177
181
|
},
|
|
178
182
|
get childPid() {
|
|
179
|
-
return i?.pid ?? null;
|
|
183
|
+
return i?.proc.pid ?? null;
|
|
180
184
|
}
|
|
181
185
|
};
|
|
182
186
|
}
|
|
183
187
|
//#endregion
|
|
184
188
|
//#region src/vite/index.ts
|
|
189
|
+
var w = 2;
|
|
185
190
|
function T(e) {
|
|
186
|
-
|
|
187
|
-
|
|
191
|
+
if (Array.isArray(e)) return `[${e.map(T).join(",")}]`;
|
|
192
|
+
if (typeof e == "object" && e) {
|
|
193
|
+
let t = e;
|
|
194
|
+
return `{${Object.keys(t).sort().filter((e) => t[e] !== void 0).map((e) => `${JSON.stringify(e)}:${T(t[e])}`).join(",")}}`;
|
|
195
|
+
}
|
|
196
|
+
return JSON.stringify(e) ?? "null";
|
|
197
|
+
}
|
|
198
|
+
function E(e) {
|
|
199
|
+
return a("sha256").update(T(e)).digest("hex").slice(0, 16);
|
|
188
200
|
}
|
|
189
|
-
var
|
|
190
|
-
async function
|
|
201
|
+
var D = 20;
|
|
202
|
+
async function O(e, t) {
|
|
191
203
|
if (e === void 0) return;
|
|
192
204
|
let n;
|
|
193
205
|
try {
|
|
@@ -207,7 +219,7 @@ async function D(e, t) {
|
|
|
207
219
|
let a = i.error.issues.map((e) => ` examples${e.path.length ? `[${e.path.join("][")}]` : ""}: ${e.message}`).join("\n");
|
|
208
220
|
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.`);
|
|
209
221
|
}
|
|
210
|
-
function
|
|
222
|
+
function k(e, t) {
|
|
211
223
|
if (!e?.length) return;
|
|
212
224
|
let n = e.map((e) => {
|
|
213
225
|
let t = e.label ? `"${e.label}"` : `#${e.index}`;
|
|
@@ -215,7 +227,7 @@ function O(e, t) {
|
|
|
215
227
|
}).join("\n");
|
|
216
228
|
throw Error(`[widget-sdk] Example config rejected by "${t}"'s own configSchema:\n${n}\nEach example's \`config\` must be a config the widget would actually accept, or its preview renders empty.`);
|
|
217
229
|
}
|
|
218
|
-
var
|
|
230
|
+
var A = [
|
|
219
231
|
"schema",
|
|
220
232
|
"defaultConfig",
|
|
221
233
|
"examples",
|
|
@@ -228,26 +240,26 @@ var k = [
|
|
|
228
240
|
"minSize",
|
|
229
241
|
"maxSize"
|
|
230
242
|
];
|
|
231
|
-
function
|
|
243
|
+
function j(e, t, n) {
|
|
232
244
|
let r = c(e, "utf-8"), i = JSON.parse(r), a = {
|
|
233
245
|
...t.manifest ?? {},
|
|
234
246
|
schema: n
|
|
235
247
|
};
|
|
236
|
-
for (let e of
|
|
248
|
+
for (let e of A) a[e] !== void 0 && (i[e] = a[e]);
|
|
237
249
|
let o = `${JSON.stringify(i, null, 2)}\n`;
|
|
238
250
|
o !== r && f(e, o);
|
|
239
251
|
}
|
|
240
|
-
async function
|
|
252
|
+
async function M(e) {
|
|
241
253
|
if (!o(e.outFile)) return;
|
|
242
|
-
let t = e.session ? await e.session.introspect(e.outFile) :
|
|
254
|
+
let t = e.session ? await e.session.introspect(e.outFile) : S(e.outFile);
|
|
243
255
|
if (!t.ok) throw Error(`[widget-sdk] Could not read "${e.widgetName}" to check it: ${t.reason}\n Its examples and config schema could not be validated, so the build cannot continue.
|
|
244
256
|
This usually means the bundle throws while being imported.`);
|
|
245
257
|
let n = t.value, r = n.manifest?.name ?? e.widgetName;
|
|
246
|
-
await
|
|
258
|
+
await O(n.manifest?.examples, r), k(n.exampleConfigIssues, r);
|
|
247
259
|
let i = n.jsonSchema;
|
|
248
260
|
if (!i) return;
|
|
249
|
-
e.manifestPath && o(e.manifestPath) &&
|
|
250
|
-
let a =
|
|
261
|
+
e.manifestPath && o(e.manifestPath) && j(e.manifestPath, n, i);
|
|
262
|
+
let a = E(i), s = n.manifest?.configVersion ?? null, l = n.manifest?.name ?? e.widgetName, u = o(e.hashFile) ? c(e.hashFile, "utf-8") : null;
|
|
251
263
|
if (u !== null) {
|
|
252
264
|
let t = u.trim(), n = null;
|
|
253
265
|
if (t.startsWith("{")) try {
|
|
@@ -255,54 +267,55 @@ async function j(e) {
|
|
|
255
267
|
} catch {
|
|
256
268
|
n = null;
|
|
257
269
|
}
|
|
258
|
-
if (n) {
|
|
270
|
+
if (n && n.hashVersion === w) {
|
|
259
271
|
if (n.hash !== a && n.configVersion === s) throw Error(`[widget-sdk] Config schema shape changed for "${l}" without a configVersion bump. Bump configVersion in defineWidget (currently ${s ?? "unset"}) or revert the schema change, then rebuild. Recorded in ${e.hashFile}`);
|
|
260
|
-
} else
|
|
272
|
+
} else console.warn(`[widget-sdk] Schema shape record for "${l}" was written by an older SDK, so it cannot be compared. Re-recording it under hash format ${w}. This build is not checked for a missing configVersion bump; the next one is. (${e.hashFile})`);
|
|
261
273
|
}
|
|
262
274
|
let d = `${JSON.stringify({
|
|
263
275
|
hash: a,
|
|
264
|
-
configVersion: s
|
|
276
|
+
configVersion: s,
|
|
277
|
+
hashVersion: w
|
|
265
278
|
})}\n`;
|
|
266
279
|
d !== u && f(e.hashFile, d);
|
|
267
280
|
}
|
|
268
|
-
var
|
|
269
|
-
function
|
|
281
|
+
var oe = "virtual:glasshome-widget", N = "\0virtual:glasshome-widget", P = "/@glasshome/preview";
|
|
282
|
+
function F(e) {
|
|
270
283
|
return v === "\\" ? e.split(v).join("/") : e;
|
|
271
284
|
}
|
|
272
|
-
function
|
|
285
|
+
function I() {
|
|
273
286
|
let e = y(import.meta.url);
|
|
274
287
|
return _(m(e), "../../preview");
|
|
275
288
|
}
|
|
276
|
-
function
|
|
289
|
+
function L(e) {
|
|
277
290
|
return r(e);
|
|
278
291
|
}
|
|
279
|
-
var
|
|
280
|
-
function
|
|
281
|
-
let n =
|
|
282
|
-
return n.includes("/node_modules/") || !
|
|
292
|
+
var R = /\.(ts|tsx|js|jsx)$/, z = /from\s+["']@glasshome\/sync-layer(\/[^"']*)?["']/;
|
|
293
|
+
function B(e, t) {
|
|
294
|
+
let n = F(e).split("?")[0] ?? "";
|
|
295
|
+
return n.includes("/node_modules/") || !R.test(n) ? !1 : z.test(t);
|
|
283
296
|
}
|
|
284
|
-
function
|
|
297
|
+
function V() {
|
|
285
298
|
return {
|
|
286
299
|
name: "glasshome-widget:sync-layer-guard",
|
|
287
300
|
apply: "build",
|
|
288
301
|
enforce: "pre",
|
|
289
302
|
transform(e, t) {
|
|
290
|
-
if (
|
|
303
|
+
if (B(t, e)) throw Error(`Widgets must not import "@glasshome/sync-layer" directly (imported by ${F(g(process.cwd(), t.split("?")[0] ?? t))}). Import the equivalent hook from "@glasshome/widget-sdk" instead (e.g. useEntity, useEntities, useService).`);
|
|
291
304
|
return null;
|
|
292
305
|
}
|
|
293
306
|
};
|
|
294
307
|
}
|
|
295
|
-
function
|
|
296
|
-
let r =
|
|
297
|
-
if (r.includes("/node_modules/") || !
|
|
308
|
+
function H(t, n) {
|
|
309
|
+
let r = F(t).split("?")[0] ?? "";
|
|
310
|
+
if (r.includes("/node_modules/") || !R.test(r)) return !1;
|
|
298
311
|
let i = e.find((e) => e.id === "direct-ui-import");
|
|
299
312
|
return i?.sourcePattern ? new RegExp(i.sourcePattern).test(n) : !1;
|
|
300
313
|
}
|
|
301
|
-
function
|
|
314
|
+
function U(e = /* @__PURE__ */ new Set()) {
|
|
302
315
|
let t = /* @__PURE__ */ new Set();
|
|
303
316
|
return {
|
|
304
317
|
scan(e, n) {
|
|
305
|
-
|
|
318
|
+
H(e, n) && t.add(F(g(process.cwd(), e.split("?")[0] ?? e)));
|
|
306
319
|
},
|
|
307
320
|
take() {
|
|
308
321
|
let n = [...t].filter((t) => !e.has(t));
|
|
@@ -311,8 +324,8 @@ function H(e = /* @__PURE__ */ new Set()) {
|
|
|
311
324
|
}
|
|
312
325
|
};
|
|
313
326
|
}
|
|
314
|
-
function
|
|
315
|
-
let r =
|
|
327
|
+
function W(n) {
|
|
328
|
+
let r = U(n);
|
|
316
329
|
return {
|
|
317
330
|
name: "glasshome-widget:ui-import-guard",
|
|
318
331
|
apply: "build",
|
|
@@ -328,15 +341,15 @@ function U(n) {
|
|
|
328
341
|
}
|
|
329
342
|
};
|
|
330
343
|
}
|
|
331
|
-
var
|
|
332
|
-
function
|
|
344
|
+
var G = "node_modules/.cache/glasshome-widgets";
|
|
345
|
+
function K(e) {
|
|
333
346
|
try {
|
|
334
347
|
return p(h(process.cwd(), "package.json")).resolve(e);
|
|
335
348
|
} catch {
|
|
336
349
|
return null;
|
|
337
350
|
}
|
|
338
351
|
}
|
|
339
|
-
var
|
|
352
|
+
var se = [
|
|
340
353
|
"--radius",
|
|
341
354
|
"--background",
|
|
342
355
|
"--foreground",
|
|
@@ -351,16 +364,16 @@ function q(e, t) {
|
|
|
351
364
|
if (!o(n)) return;
|
|
352
365
|
let r = c(n, "utf-8");
|
|
353
366
|
for (let e of r.matchAll(/:host[^{]*\{([^}]*)\}/g)) {
|
|
354
|
-
let n = e[1] ?? "", r =
|
|
367
|
+
let n = e[1] ?? "", r = se.find((e) => n.includes(`${e}:`));
|
|
355
368
|
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.`);
|
|
356
369
|
}
|
|
357
370
|
}
|
|
358
371
|
function J(e, t, n) {
|
|
359
|
-
let r = _(e,
|
|
372
|
+
let r = _(e, G);
|
|
360
373
|
s(r, { recursive: !0 });
|
|
361
|
-
let i =
|
|
374
|
+
let i = K("@glasshome/ui/styles");
|
|
362
375
|
if (!i) 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.");
|
|
363
|
-
let a = _(m(i), "../.."), c =
|
|
376
|
+
let a = _(m(i), "../.."), c = K("@glasshome/widget-sdk/tailwind-sources"), l = c ? m(c) : null, u = [
|
|
364
377
|
h(a, "src"),
|
|
365
378
|
h(a, "dist"),
|
|
366
379
|
...l ? [h(l, "src"), h(l, "dist")] : [],
|
|
@@ -370,7 +383,7 @@ function J(e, t, n) {
|
|
|
370
383
|
"@import \"tailwindcss\" source(none);",
|
|
371
384
|
"@import \"tw-animate-css\";",
|
|
372
385
|
"@import \"@glasshome/ui/styles/theme\";",
|
|
373
|
-
...u.map((e) => `@source "${
|
|
386
|
+
...u.map((e) => `@source "${F(e)}";`),
|
|
374
387
|
"@custom-variant dark {",
|
|
375
388
|
" &:is(.dark *) { @slot }",
|
|
376
389
|
" :host(.dark) & { @slot }",
|
|
@@ -379,8 +392,8 @@ function J(e, t, n) {
|
|
|
379
392
|
].join("\n"));
|
|
380
393
|
let p = _(r, `${t}.entry.ts`);
|
|
381
394
|
return f(p, [
|
|
382
|
-
`import "${
|
|
383
|
-
`export { default } from "${
|
|
395
|
+
`import "${F(d)}";`,
|
|
396
|
+
`export { default } from "${F(n)}";`,
|
|
384
397
|
""
|
|
385
398
|
].join("\n")), p;
|
|
386
399
|
}
|
|
@@ -448,8 +461,8 @@ async function $(e) {
|
|
|
448
461
|
plugins: [
|
|
449
462
|
...X(),
|
|
450
463
|
...e?.plugins ?? [],
|
|
451
|
-
|
|
452
|
-
|
|
464
|
+
V(),
|
|
465
|
+
W(c)
|
|
453
466
|
],
|
|
454
467
|
...e?.viteConfig,
|
|
455
468
|
css: {
|
|
@@ -463,14 +476,14 @@ async function $(e) {
|
|
|
463
476
|
fileName: r.name,
|
|
464
477
|
cssFileName: r.name
|
|
465
478
|
},
|
|
466
|
-
rollupOptions: { external:
|
|
479
|
+
rollupOptions: { external: L },
|
|
467
480
|
outDir: i,
|
|
468
481
|
emptyOutDir: !1,
|
|
469
482
|
copyPublicDir: !1,
|
|
470
483
|
...e?.viteConfig?.build
|
|
471
484
|
},
|
|
472
485
|
logLevel: "warn"
|
|
473
|
-
}), q(i, r.name), await
|
|
486
|
+
}), q(i, r.name), await M({
|
|
474
487
|
outFile: h(i, `${r.name}.js`),
|
|
475
488
|
hashFile: h(m(r.entry), ".schema-hash"),
|
|
476
489
|
widgetName: r.name,
|
|
@@ -479,7 +492,7 @@ async function $(e) {
|
|
|
479
492
|
});
|
|
480
493
|
Q(r, i);
|
|
481
494
|
}
|
|
482
|
-
function
|
|
495
|
+
function ce(e) {
|
|
483
496
|
let t = e?.entry ?? "src/index.tsx", n = {
|
|
484
497
|
name: "glasshome-widget:build",
|
|
485
498
|
apply: "build",
|
|
@@ -494,7 +507,7 @@ function oe(e) {
|
|
|
494
507
|
fileName: "index",
|
|
495
508
|
cssFileName: "index"
|
|
496
509
|
},
|
|
497
|
-
rollupOptions: { external:
|
|
510
|
+
rollupOptions: { external: L }
|
|
498
511
|
}
|
|
499
512
|
};
|
|
500
513
|
}
|
|
@@ -503,7 +516,7 @@ function oe(e) {
|
|
|
503
516
|
apply: "serve",
|
|
504
517
|
enforce: "pre",
|
|
505
518
|
config() {
|
|
506
|
-
let e =
|
|
519
|
+
let e = I(), t = process.cwd();
|
|
507
520
|
return { server: { fs: { allow: [
|
|
508
521
|
e,
|
|
509
522
|
t,
|
|
@@ -511,7 +524,7 @@ function oe(e) {
|
|
|
511
524
|
] } } };
|
|
512
525
|
},
|
|
513
526
|
configureServer(e) {
|
|
514
|
-
let t =
|
|
527
|
+
let t = I(), n = h(t, "preview.html");
|
|
515
528
|
e.middlewares.use(async (t, r, i) => {
|
|
516
529
|
if (t.url === "/" || t.url === "/index.html") try {
|
|
517
530
|
let i = c(n, "utf-8");
|
|
@@ -523,20 +536,20 @@ function oe(e) {
|
|
|
523
536
|
});
|
|
524
537
|
},
|
|
525
538
|
resolveId(e) {
|
|
526
|
-
if (e ===
|
|
527
|
-
let e =
|
|
528
|
-
return
|
|
539
|
+
if (e === P) {
|
|
540
|
+
let e = I();
|
|
541
|
+
return F(h(e, "host.tsx"));
|
|
529
542
|
}
|
|
530
|
-
if (e ===
|
|
543
|
+
if (e === oe) return N;
|
|
531
544
|
},
|
|
532
545
|
load(e) {
|
|
533
|
-
if (e ===
|
|
546
|
+
if (e === N) return `export { default } from "${F(_(process.cwd(), t))}";`;
|
|
534
547
|
}
|
|
535
548
|
}, i = {
|
|
536
549
|
name: "glasshome-widget:schema",
|
|
537
550
|
apply: "build",
|
|
538
551
|
async closeBundle() {
|
|
539
|
-
q(_(process.cwd(), "dist"), "index"), await
|
|
552
|
+
q(_(process.cwd(), "dist"), "index"), await M({
|
|
540
553
|
outFile: _(process.cwd(), "dist", "index.js"),
|
|
541
554
|
hashFile: _(process.cwd(), ".schema-hash"),
|
|
542
555
|
widgetName: "index",
|
|
@@ -547,13 +560,13 @@ function oe(e) {
|
|
|
547
560
|
return [
|
|
548
561
|
...X(),
|
|
549
562
|
n,
|
|
550
|
-
|
|
551
|
-
|
|
563
|
+
V(),
|
|
564
|
+
W(),
|
|
552
565
|
i,
|
|
553
566
|
r
|
|
554
567
|
];
|
|
555
568
|
}
|
|
556
|
-
function
|
|
569
|
+
function le(e) {
|
|
557
570
|
let t = e?.srcDir ?? "src", n = e?.outDir ?? "dist", r = [];
|
|
558
571
|
return [{
|
|
559
572
|
name: "glasshome-widgets:build",
|
|
@@ -581,4 +594,4 @@ function se(e) {
|
|
|
581
594
|
}];
|
|
582
595
|
}
|
|
583
596
|
//#endregion
|
|
584
|
-
export {
|
|
597
|
+
export { D as MAX_EXAMPLES, $ as buildWidgets, C as createIntrospectSession, U as createUiImportTracker, Z as discoverWidgets, Q as generateRegistry, ce as glasshomeWidget, le as glasshomeWidgets, S as introspectOnce, B as isDirectSyncLayerImportSource, H as isDirectUiImportSource, L as isWidgetExternal, M as runSchemaGuard };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glasshome/widget-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "SDK for building GlassHome dashboard widgets with SolidJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"glasshome",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@glasshome/sync-layer": "0.8.1",
|
|
63
|
-
"@glasshome/ui": "1.
|
|
63
|
+
"@glasshome/ui": "1.14.0",
|
|
64
64
|
"solid-js": "^1.9.11"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"zod": "^4.1.13"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@glasshome/ui": "1.
|
|
78
|
+
"@glasshome/ui": "1.14.0",
|
|
79
79
|
"@solidjs/testing-library": "^0.8.10",
|
|
80
|
-
"@types/bun": "
|
|
80
|
+
"@types/bun": "^1.4.0",
|
|
81
81
|
"@types/node": "^25.2.2",
|
|
82
82
|
"typescript": "^7.0.2",
|
|
83
83
|
"vite": "^8.1.0",
|