@glasshome/widget-sdk 1.11.0 → 1.11.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.
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
2
  export declare const ToneSchema: z.ZodEnum<{
3
- success: "success";
4
- warning: "warning";
3
+ accent: "accent";
5
4
  danger: "danger";
6
5
  info: "info";
7
6
  neutral: "neutral";
8
- accent: "accent";
7
+ success: "success";
8
+ warning: "warning";
9
9
  }>;
10
10
  export type Tone = z.infer<typeof ToneSchema>;
package/dist/index.js CHANGED
@@ -1451,7 +1451,7 @@ function Un() {
1451
1451
  //#region src/version.ts
1452
1452
  var Wn = {
1453
1453
  name: "@glasshome/widget-sdk",
1454
- version: "1.11.0",
1454
+ version: "1.11.1",
1455
1455
  description: "SDK for building GlassHome dashboard widgets with SolidJS",
1456
1456
  keywords: [
1457
1457
  "glasshome",
@@ -1520,6 +1520,7 @@ var Wn = {
1520
1520
  "@tailwindcss/vite": "^4.1.13",
1521
1521
  clsx: "^2.1.1",
1522
1522
  "happy-dom": "^20.0.0",
1523
+ lightningcss: "^1.33.0",
1523
1524
  "tailwind-merge": "^3.5.0",
1524
1525
  tailwindcss: "^4.1.13",
1525
1526
  zod: "^4.1.13"
@@ -1529,7 +1530,7 @@ var Wn = {
1529
1530
  "@solidjs/testing-library": "^0.8.10",
1530
1531
  "@types/bun": "latest",
1531
1532
  "@types/node": "^25.2.2",
1532
- typescript: "^5",
1533
+ typescript: "^7.0.2",
1533
1534
  vite: "^8.1.0",
1534
1535
  "vite-plugin-solid": "^2.11.12",
1535
1536
  vitest: "^4.1.10"
@@ -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 b, spawnSync as x } from "node:child_process";
9
+ import { spawn as te, spawnSync as b } from "node:child_process";
10
10
  //#region src/vite/introspect-session.ts
11
- var te = 262144e3, S = 3e4, C = 3e3;
12
- function w(e) {
11
+ var ne = 262144e3, x = 3e4, S = 3e3;
12
+ function C(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 T(e) {
17
- let t = w("introspect");
16
+ function w(e) {
17
+ let t = C("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 = x(process.execPath, [
22
+ let n = b(process.execPath, [
23
23
  "--conditions",
24
24
  "browser",
25
25
  t,
26
26
  e
27
27
  ], {
28
28
  encoding: "utf-8",
29
- timeout: S
29
+ timeout: x
30
30
  });
31
31
  if (n.error) return {
32
32
  ok: !1,
@@ -48,16 +48,16 @@ function T(e) {
48
48
  };
49
49
  }
50
50
  }
51
- function ne() {
51
+ function re() {
52
52
  return {
53
- introspect: async (e) => T(e),
53
+ introspect: async (e) => w(e),
54
54
  dispose: async () => {},
55
55
  childPid: null
56
56
  };
57
57
  }
58
- function re(e) {
59
- if (process.env.GLASSHOME_WIDGET_NO_WORKER === "1") return ne();
60
- let t = e?.rssLimitBytes ?? te, n = e?.timeoutMs ?? S, r = e?.slowMs ?? C, i = null, a = null, o = !1, s = !1, c = 0, l = Promise.resolve(), u = /* @__PURE__ */ new Map();
58
+ function ie(e) {
59
+ if (process.env.GLASSHOME_WIDGET_NO_WORKER === "1") return re();
60
+ let t = e?.rssLimitBytes ?? ne, n = e?.timeoutMs ?? x, r = e?.slowMs ?? S, i = null, a = null, o = !1, s = !1, c = 0, l = Promise.resolve(), u = /* @__PURE__ */ new Map();
61
61
  function d(e) {
62
62
  for (let t of u.values()) t({
63
63
  ok: !1,
@@ -89,9 +89,9 @@ function re(e) {
89
89
  function m() {
90
90
  if (i && a && !o) return a;
91
91
  (o || i) && f("worker was replaced");
92
- let e = w("introspect-worker");
92
+ let e = C("introspect-worker");
93
93
  if (!e) return Promise.reject(/* @__PURE__ */ Error("introspect-worker not found next to the sdk"));
94
- let t = Date.now(), n = b(process.execPath, [
94
+ let t = Date.now(), n = te(process.execPath, [
95
95
  "--conditions",
96
96
  "browser",
97
97
  e
@@ -182,12 +182,12 @@ function re(e) {
182
182
  }
183
183
  //#endregion
184
184
  //#region src/vite/index.ts
185
- function E(e) {
185
+ function T(e) {
186
186
  let t = JSON.stringify(e, Object.keys(e).sort());
187
187
  return a("sha256").update(t).digest("hex").slice(0, 16);
188
188
  }
189
- var D = 20;
190
- async function O(e, t) {
189
+ var E = 20;
190
+ async function D(e, t) {
191
191
  if (e === void 0) return;
192
192
  let n;
193
193
  try {
@@ -207,7 +207,7 @@ async function O(e, t) {
207
207
  let a = i.error.issues.map((e) => ` examples${e.path.length ? `[${e.path.join("][")}]` : ""}: ${e.message}`).join("\n");
208
208
  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
209
  }
210
- function k(e, t) {
210
+ function O(e, t) {
211
211
  if (!e?.length) return;
212
212
  let n = e.map((e) => {
213
213
  let t = e.label ? `"${e.label}"` : `#${e.index}`;
@@ -215,7 +215,7 @@ function k(e, t) {
215
215
  }).join("\n");
216
216
  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
217
  }
218
- var A = [
218
+ var k = [
219
219
  "schema",
220
220
  "defaultConfig",
221
221
  "examples",
@@ -228,26 +228,26 @@ var A = [
228
228
  "minSize",
229
229
  "maxSize"
230
230
  ];
231
- function j(e, t, n) {
231
+ function A(e, t, n) {
232
232
  let r = c(e, "utf-8"), i = JSON.parse(r), a = {
233
233
  ...t.manifest ?? {},
234
234
  schema: n
235
235
  };
236
- for (let e of A) a[e] !== void 0 && (i[e] = a[e]);
236
+ for (let e of k) a[e] !== void 0 && (i[e] = a[e]);
237
237
  let o = `${JSON.stringify(i, null, 2)}\n`;
238
238
  o !== r && f(e, o);
239
239
  }
240
- async function M(e) {
240
+ async function j(e) {
241
241
  if (!o(e.outFile)) return;
242
- let t = e.session ? await e.session.introspect(e.outFile) : T(e.outFile);
242
+ let t = e.session ? await e.session.introspect(e.outFile) : w(e.outFile);
243
243
  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
244
  This usually means the bundle throws while being imported.`);
245
245
  let n = t.value, r = n.manifest?.name ?? e.widgetName;
246
- await O(n.manifest?.examples, r), k(n.exampleConfigIssues, r);
246
+ await D(n.manifest?.examples, r), O(n.exampleConfigIssues, r);
247
247
  let i = n.jsonSchema;
248
248
  if (!i) return;
249
- e.manifestPath && o(e.manifestPath) && j(e.manifestPath, n, i);
250
- let a = E(i), s = n.manifest?.configVersion ?? null, l = n.manifest?.name ?? e.widgetName;
249
+ e.manifestPath && o(e.manifestPath) && A(e.manifestPath, n, i);
250
+ let a = T(i), s = n.manifest?.configVersion ?? null, l = n.manifest?.name ?? e.widgetName;
251
251
  if (o(e.hashFile)) {
252
252
  let t = c(e.hashFile, "utf-8").trim(), n = null;
253
253
  if (t.startsWith("{")) try {
@@ -264,44 +264,44 @@ async function M(e) {
264
264
  configVersion: s
265
265
  })}\n`);
266
266
  }
267
- var ie = "virtual:glasshome-widget", N = "\0virtual:glasshome-widget", P = "/@glasshome/preview";
268
- function F(e) {
267
+ var ae = "virtual:glasshome-widget", M = "\0virtual:glasshome-widget", N = "/@glasshome/preview";
268
+ function P(e) {
269
269
  return v === "\\" ? e.split(v).join("/") : e;
270
270
  }
271
- function I() {
271
+ function F() {
272
272
  let e = y(import.meta.url);
273
273
  return _(m(e), "../../preview");
274
274
  }
275
- function L(e) {
275
+ function I(e) {
276
276
  return r(e);
277
277
  }
278
- var R = /\.(ts|tsx|js|jsx)$/, z = /from\s+["']@glasshome\/sync-layer(\/[^"']*)?["']/;
279
- function B(e, t) {
280
- let n = F(e).split("?")[0] ?? "";
281
- return n.includes("/node_modules/") || !R.test(n) ? !1 : z.test(t);
278
+ var L = /\.(ts|tsx|js|jsx)$/, R = /from\s+["']@glasshome\/sync-layer(\/[^"']*)?["']/;
279
+ function z(e, t) {
280
+ let n = P(e).split("?")[0] ?? "";
281
+ return n.includes("/node_modules/") || !L.test(n) ? !1 : R.test(t);
282
282
  }
283
- function V() {
283
+ function B() {
284
284
  return {
285
285
  name: "glasshome-widget:sync-layer-guard",
286
286
  apply: "build",
287
287
  enforce: "pre",
288
288
  transform(e, t) {
289
- 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).`);
289
+ if (z(t, e)) throw Error(`Widgets must not import "@glasshome/sync-layer" directly (imported by ${P(g(process.cwd(), t.split("?")[0] ?? t))}). Import the equivalent hook from "@glasshome/widget-sdk" instead (e.g. useEntity, useEntities, useService).`);
290
290
  return null;
291
291
  }
292
292
  };
293
293
  }
294
- function H(t, n) {
295
- let r = F(t).split("?")[0] ?? "";
296
- if (r.includes("/node_modules/") || !R.test(r)) return !1;
294
+ function V(t, n) {
295
+ let r = P(t).split("?")[0] ?? "";
296
+ if (r.includes("/node_modules/") || !L.test(r)) return !1;
297
297
  let i = e.find((e) => e.id === "direct-ui-import");
298
298
  return i?.sourcePattern ? new RegExp(i.sourcePattern).test(n) : !1;
299
299
  }
300
- function U(e = /* @__PURE__ */ new Set()) {
300
+ function H(e = /* @__PURE__ */ new Set()) {
301
301
  let t = /* @__PURE__ */ new Set();
302
302
  return {
303
303
  scan(e, n) {
304
- H(e, n) && t.add(F(g(process.cwd(), e.split("?")[0] ?? e)));
304
+ V(e, n) && t.add(P(g(process.cwd(), e.split("?")[0] ?? e)));
305
305
  },
306
306
  take() {
307
307
  let n = [...t].filter((t) => !e.has(t));
@@ -310,8 +310,8 @@ function U(e = /* @__PURE__ */ new Set()) {
310
310
  }
311
311
  };
312
312
  }
313
- function W(n) {
314
- let r = U(n);
313
+ function U(n) {
314
+ let r = H(n);
315
315
  return {
316
316
  name: "glasshome-widget:ui-import-guard",
317
317
  apply: "build",
@@ -327,15 +327,15 @@ function W(n) {
327
327
  }
328
328
  };
329
329
  }
330
- var G = "node_modules/.cache/glasshome-widgets";
331
- function K(e) {
330
+ var W = "node_modules/.cache/glasshome-widgets";
331
+ function G(e) {
332
332
  try {
333
333
  return p(h(process.cwd(), "package.json")).resolve(e);
334
334
  } catch {
335
335
  return null;
336
336
  }
337
337
  }
338
- var q = [
338
+ var K = [
339
339
  "--radius",
340
340
  "--background",
341
341
  "--foreground",
@@ -345,21 +345,21 @@ var q = [
345
345
  "--muted",
346
346
  "--accent"
347
347
  ];
348
- function J(e, t) {
348
+ function q(e, t) {
349
349
  let n = h(e, `${t}.css`);
350
350
  if (!o(n)) return;
351
351
  let r = c(n, "utf-8");
352
352
  for (let e of r.matchAll(/:host[^{]*\{([^}]*)\}/g)) {
353
- let n = e[1] ?? "", r = q.find((e) => n.includes(`${e}:`));
353
+ let n = e[1] ?? "", r = K.find((e) => n.includes(`${e}:`));
354
354
  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.`);
355
355
  }
356
356
  }
357
- function Y(e, t, n) {
358
- let r = _(e, G);
357
+ function J(e, t, n) {
358
+ let r = _(e, W);
359
359
  s(r, { recursive: !0 });
360
- let i = K("@glasshome/ui/styles");
360
+ let i = G("@glasshome/ui/styles");
361
361
  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.");
362
- let a = _(m(i), "../.."), c = K("@glasshome/widget-sdk/tailwind-sources"), l = c ? m(c) : null, u = [
362
+ let a = _(m(i), "../.."), c = G("@glasshome/widget-sdk/tailwind-sources"), l = c ? m(c) : null, u = [
363
363
  h(a, "src"),
364
364
  h(a, "dist"),
365
365
  ...l ? [h(l, "src"), h(l, "dist")] : [],
@@ -369,7 +369,7 @@ function Y(e, t, n) {
369
369
  "@import \"tailwindcss\" source(none);",
370
370
  "@import \"tw-animate-css\";",
371
371
  "@import \"@glasshome/ui/styles/theme\";",
372
- ...u.map((e) => `@source "${F(e)}";`),
372
+ ...u.map((e) => `@source "${P(e)}";`),
373
373
  "@custom-variant dark {",
374
374
  " &:is(.dark *) { @slot }",
375
375
  " :host(.dark) & { @slot }",
@@ -378,11 +378,15 @@ function Y(e, t, n) {
378
378
  ].join("\n"));
379
379
  let p = _(r, `${t}.entry.ts`);
380
380
  return f(p, [
381
- `import "${F(d)}";`,
382
- `export { default } from "${F(n)}";`,
381
+ `import "${P(d)}";`,
382
+ `export { default } from "${P(n)}";`,
383
383
  ""
384
384
  ].join("\n")), p;
385
385
  }
386
+ function Y() {
387
+ let { Features: e } = p(import.meta.url)("lightningcss");
388
+ return { lightningcss: { include: e.HexAlphaColors } };
389
+ }
386
390
  function X() {
387
391
  let e = ee();
388
392
  for (let t of e) t.apply ??= "build";
@@ -443,25 +447,29 @@ async function $(e) {
443
447
  plugins: [
444
448
  ...X(),
445
449
  ...e?.plugins ?? [],
446
- V(),
447
- W(c)
450
+ B(),
451
+ U(c)
448
452
  ],
449
453
  ...e?.viteConfig,
454
+ css: {
455
+ ...e?.viteConfig?.css,
456
+ ...Y()
457
+ },
450
458
  build: {
451
459
  lib: {
452
- entry: Y(n, r.name, r.entry),
460
+ entry: J(n, r.name, r.entry),
453
461
  formats: ["es"],
454
462
  fileName: r.name,
455
463
  cssFileName: r.name
456
464
  },
457
- rollupOptions: { external: L },
465
+ rollupOptions: { external: I },
458
466
  outDir: i,
459
467
  emptyOutDir: !1,
460
468
  copyPublicDir: !1,
461
469
  ...e?.viteConfig?.build
462
470
  },
463
471
  logLevel: "warn"
464
- }), J(i, r.name), await M({
472
+ }), q(i, r.name), await j({
465
473
  outFile: h(i, `${r.name}.js`),
466
474
  hashFile: h(m(r.entry), ".schema-hash"),
467
475
  widgetName: r.name,
@@ -470,28 +478,31 @@ async function $(e) {
470
478
  });
471
479
  Q(r, i);
472
480
  }
473
- function ae(e) {
481
+ function oe(e) {
474
482
  let t = e?.entry ?? "src/index.tsx", n = {
475
483
  name: "glasshome-widget:build",
476
484
  apply: "build",
477
485
  config() {
478
486
  let e = process.cwd();
479
- return { build: {
480
- lib: {
481
- entry: Y(e, "index", _(e, t)),
482
- formats: ["es"],
483
- fileName: "index",
484
- cssFileName: "index"
485
- },
486
- rollupOptions: { external: L }
487
- } };
487
+ return {
488
+ css: Y(),
489
+ build: {
490
+ lib: {
491
+ entry: J(e, "index", _(e, t)),
492
+ formats: ["es"],
493
+ fileName: "index",
494
+ cssFileName: "index"
495
+ },
496
+ rollupOptions: { external: I }
497
+ }
498
+ };
488
499
  }
489
500
  }, r = {
490
501
  name: "glasshome-widget:dev",
491
502
  apply: "serve",
492
503
  enforce: "pre",
493
504
  config() {
494
- let e = I(), t = process.cwd();
505
+ let e = F(), t = process.cwd();
495
506
  return { server: { fs: { allow: [
496
507
  e,
497
508
  t,
@@ -499,7 +510,7 @@ function ae(e) {
499
510
  ] } } };
500
511
  },
501
512
  configureServer(e) {
502
- let t = I(), n = h(t, "preview.html");
513
+ let t = F(), n = h(t, "preview.html");
503
514
  e.middlewares.use(async (t, r, i) => {
504
515
  if (t.url === "/" || t.url === "/index.html") try {
505
516
  let i = c(n, "utf-8");
@@ -511,20 +522,20 @@ function ae(e) {
511
522
  });
512
523
  },
513
524
  resolveId(e) {
514
- if (e === P) {
515
- let e = I();
516
- return F(h(e, "host.tsx"));
525
+ if (e === N) {
526
+ let e = F();
527
+ return P(h(e, "host.tsx"));
517
528
  }
518
- if (e === ie) return N;
529
+ if (e === ae) return M;
519
530
  },
520
531
  load(e) {
521
- if (e === N) return `export { default } from "${F(_(process.cwd(), t))}";`;
532
+ if (e === M) return `export { default } from "${P(_(process.cwd(), t))}";`;
522
533
  }
523
534
  }, i = {
524
535
  name: "glasshome-widget:schema",
525
536
  apply: "build",
526
537
  async closeBundle() {
527
- J(_(process.cwd(), "dist"), "index"), await M({
538
+ q(_(process.cwd(), "dist"), "index"), await j({
528
539
  outFile: _(process.cwd(), "dist", "index.js"),
529
540
  hashFile: _(process.cwd(), ".schema-hash"),
530
541
  widgetName: "index",
@@ -535,13 +546,13 @@ function ae(e) {
535
546
  return [
536
547
  ...X(),
537
548
  n,
538
- V(),
539
- W(),
549
+ B(),
550
+ U(),
540
551
  i,
541
552
  r
542
553
  ];
543
554
  }
544
- function oe(e) {
555
+ function se(e) {
545
556
  let t = e?.srcDir ?? "src", n = e?.outDir ?? "dist", r = [];
546
557
  return [{
547
558
  name: "glasshome-widgets:build",
@@ -569,4 +580,4 @@ function oe(e) {
569
580
  }];
570
581
  }
571
582
  //#endregion
572
- export { D as MAX_EXAMPLES, $ as buildWidgets, re as createIntrospectSession, U as createUiImportTracker, Z as discoverWidgets, Q as generateRegistry, ae as glasshomeWidget, oe as glasshomeWidgets, T as introspectOnce, B as isDirectSyncLayerImportSource, H as isDirectUiImportSource, L as isWidgetExternal, M as runSchemaGuard };
583
+ export { E as MAX_EXAMPLES, $ as buildWidgets, ie as createIntrospectSession, H as createUiImportTracker, Z as discoverWidgets, Q as generateRegistry, oe as glasshomeWidget, se as glasshomeWidgets, w as introspectOnce, z as isDirectSyncLayerImportSource, V as isDirectUiImportSource, I as isWidgetExternal, j as runSchemaGuard };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-sdk",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "SDK for building GlassHome dashboard widgets with SolidJS",
5
5
  "keywords": [
6
6
  "glasshome",
@@ -69,6 +69,7 @@
69
69
  "@tailwindcss/vite": "^4.1.13",
70
70
  "clsx": "^2.1.1",
71
71
  "happy-dom": "^20.0.0",
72
+ "lightningcss": "^1.33.0",
72
73
  "tailwind-merge": "^3.5.0",
73
74
  "tailwindcss": "^4.1.13",
74
75
  "zod": "^4.1.13"
@@ -78,7 +79,7 @@
78
79
  "@solidjs/testing-library": "^0.8.10",
79
80
  "@types/bun": "latest",
80
81
  "@types/node": "^25.2.2",
81
- "typescript": "^5",
82
+ "typescript": "^7.0.2",
82
83
  "vite": "^8.1.0",
83
84
  "vite-plugin-solid": "^2.11.12",
84
85
  "vitest": "^4.1.10"