@glasshome/widget-sdk 1.24.0 → 1.25.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.
@@ -30,7 +30,7 @@ var h = (e) => {
30
30
  if (typeof document < "u") {
31
31
  let e = [...n];
32
32
  i(e);
33
- for (let t of e) document.addEventListener(t, h);
33
+ for (let t of e) document.addEventListener(t, h, { passive: !0 });
34
34
  }
35
35
  function g(e, t = /* @__PURE__ */ new Set()) {
36
36
  if (e.mode !== "closed") return () => {};
@@ -39,7 +39,7 @@ function g(e, t = /* @__PURE__ */ new Set()) {
39
39
  removeEventListener: (t, n) => e.removeEventListener(t, n)
40
40
  };
41
41
  i(a, o);
42
- for (let t of a) e.addEventListener(t, h);
42
+ for (let t of a) e.addEventListener(t, h, { passive: !0 });
43
43
  return () => {
44
44
  r(o);
45
45
  for (let t of a) e.removeEventListener(t, h);
package/dist/index.js CHANGED
@@ -3136,7 +3136,7 @@ function Co() {
3136
3136
  //#region src/version.ts
3137
3137
  var wo = {
3138
3138
  name: "@glasshome/widget-sdk",
3139
- version: "1.24.0",
3139
+ version: "1.25.1",
3140
3140
  description: "SDK for building GlassHome dashboard widgets with SolidJS",
3141
3141
  keywords: [
3142
3142
  "dashboard",
@@ -3192,14 +3192,15 @@ var wo = {
3192
3192
  types: "./dist/vite/index.d.ts",
3193
3193
  import: "./dist/vite/index.js"
3194
3194
  },
3195
+ "./export-history": "./dist/export-history.json",
3195
3196
  "./tailwind-sources": "./tailwind-sources.css",
3196
3197
  "./package.json": "./package.json"
3197
3198
  },
3198
3199
  publishConfig: { access: "public" },
3199
3200
  scripts: {
3200
- build: "vite build && tsc -p tsconfig.build.json && bun scripts/check-host-singleton.ts",
3201
+ build: "vite build && tsc -p tsconfig.build.json && bun scripts/check-host-singleton.ts && bun scripts/export-names.ts --emit",
3201
3202
  dev: "vite build --watch",
3202
- test: "bun test src && vitest run",
3203
+ test: "bun test src scripts && vitest run",
3203
3204
  "test:dom": "vitest run",
3204
3205
  "test:dom:watch": "vitest",
3205
3206
  "typecheck:test": "tsc --noEmit",
@@ -3207,7 +3208,7 @@ var wo = {
3207
3208
  lint: "oxlint --type-aware . && oxfmt --check ."
3208
3209
  },
3209
3210
  dependencies: {
3210
- "@glasshome/widget-contract": "0.4.1",
3211
+ "@glasshome/widget-contract": "0.5.1",
3211
3212
  "@tailwindcss/vite": "^4.1.13",
3212
3213
  clsx: "^2.1.1",
3213
3214
  "happy-dom": "^20.0.0",
@@ -3221,14 +3222,16 @@ var wo = {
3221
3222
  "@solidjs/testing-library": "^0.8.10",
3222
3223
  "@types/bun": "^1.4.0",
3223
3224
  "@types/node": "^25.2.2",
3225
+ "@vitest/browser-playwright": "4.1.11",
3224
3226
  fallow: "3.17.0",
3225
3227
  oxfmt: "0.65.0",
3226
3228
  oxlint: "1.81.0",
3227
3229
  "oxlint-tsgolint": "7.0.2001",
3230
+ playwright: "1.63.0",
3228
3231
  typescript: "^7.0.2",
3229
3232
  vite: "^8.1.0",
3230
3233
  "vite-plugin-solid": "^2.11.12",
3231
- vitest: "^4.1.10"
3234
+ vitest: "4.1.11"
3232
3235
  },
3233
3236
  peerDependencies: {
3234
3237
  "@glasshome/sync-layer": "0.9.1",
@@ -16,8 +16,6 @@ export interface GlasshomeWidgetOptions {
16
16
  * author decide which states matter rather than discovering the loss never.
17
17
  */
18
18
  export declare const MAX_EXAMPLES = 20;
19
- /** What a built bundle imports from the SDK, by exported name; `*` for a namespace or dynamic import. */
20
- export declare function sdkImportsOf(code: string): Set<string>;
21
19
  /** SDK hooks that read a fixed entity on the widget's behalf, so the widget must declare that read. */
22
20
  export declare const HOOK_READS: Record<string, string>;
23
21
  export declare function assertHookReadsDeclared(code: string, capabilities: readonly CapabilityGrant[], widgetName: string): void;
@@ -5,16 +5,17 @@ import { existsSync as s, mkdirSync as c, readFileSync as l, readdirSync as u, r
5
5
  import { createRequire as m } from "node:module";
6
6
  import { dirname as h, join as g, relative as _, resolve as v, sep as y } from "node:path";
7
7
  import { fileURLToPath as b } from "node:url";
8
- import ee from "@tailwindcss/vite";
9
- import { spawn as te, spawnSync as x } from "node:child_process";
8
+ import { sdkImportsOf as ee } from "@glasshome/widget-contract/sdk-floor";
9
+ import te from "@tailwindcss/vite";
10
+ import { spawn as ne, spawnSync as re } from "node:child_process";
10
11
  //#region node_modules/@glasshome/widget-contract/dist/clock.mjs
11
- var S = (e) => e, C = (e) => e, ne = {
12
+ var x = (e) => e, S = (e) => e, ie = {
12
13
  now: () => Date.now(),
13
- setTimeout: (e, t) => S(globalThis.setTimeout(e, t)),
14
- clearTimeout: (e) => globalThis.clearTimeout(C(e)),
15
- setInterval: (e, t) => S(globalThis.setInterval(e, t)),
16
- clearInterval: (e) => globalThis.clearInterval(C(e))
17
- }, re = 262144e3, w = 3e4, ie = 3e3;
14
+ setTimeout: (e, t) => x(globalThis.setTimeout(e, t)),
15
+ clearTimeout: (e) => globalThis.clearTimeout(S(e)),
16
+ setInterval: (e, t) => x(globalThis.setInterval(e, t)),
17
+ clearInterval: (e) => globalThis.clearInterval(S(e))
18
+ }, C = 262144e3, w = 3e4, ae = 3e3;
18
19
  function T(e) {
19
20
  let t = h(b(import.meta.url));
20
21
  return [g(t, `${e}.js`), g(t, `${e}.ts`)].find((e) => s(e)) ?? null;
@@ -25,7 +26,7 @@ function E(e, t) {
25
26
  ok: !1,
26
27
  reason: "introspect not found next to the sdk"
27
28
  };
28
- let r = x(process.execPath, [
29
+ let r = re(process.execPath, [
29
30
  "--conditions",
30
31
  "browser",
31
32
  n,
@@ -54,8 +55,8 @@ function E(e, t) {
54
55
  };
55
56
  }
56
57
  }
57
- function ae(e) {
58
- let t = te(process.execPath, [
58
+ function D(e) {
59
+ let t = ne(process.execPath, [
59
60
  "--conditions",
60
61
  "browser",
61
62
  e
@@ -99,7 +100,7 @@ function oe(e) {
99
100
  }
100
101
  function se(e) {
101
102
  if (process.env.GLASSHOME_WIDGET_NO_WORKER === "1") return oe(e?.timeoutMs);
102
- let t = e?.rssLimitBytes ?? re, n = e?.timeoutMs ?? w, r = e?.slowMs ?? ie, i = e?.clock ?? ne, a = e?.spawnWorker ?? ae, o = null, s = !1, c = 0, l = Promise.resolve();
103
+ let t = e?.rssLimitBytes ?? C, n = e?.timeoutMs ?? w, r = e?.slowMs ?? ae, i = e?.clock ?? ie, a = e?.spawnWorker ?? D, o = null, s = !1, c = 0, l = Promise.resolve();
103
104
  function u(e, t) {
104
105
  for (let n of e.pending.values()) n({
105
106
  ok: !1,
@@ -206,17 +207,17 @@ function se(e) {
206
207
  }
207
208
  //#endregion
208
209
  //#region src/vite/index.ts
209
- var D = 2;
210
- function O(e) {
211
- if (Array.isArray(e)) return `[${e.map(O).join(",")}]`;
210
+ var O = 2;
211
+ function k(e) {
212
+ if (Array.isArray(e)) return `[${e.map(k).join(",")}]`;
212
213
  if (typeof e == "object" && e) {
213
214
  let t = e;
214
- return `{${Object.keys(t).sort().filter((e) => t[e] !== void 0).map((e) => `${JSON.stringify(e)}:${O(t[e])}`).join(",")}}`;
215
+ return `{${Object.keys(t).sort().filter((e) => t[e] !== void 0).map((e) => `${JSON.stringify(e)}:${k(t[e])}`).join(",")}}`;
215
216
  }
216
217
  return JSON.stringify(e) ?? "null";
217
218
  }
218
219
  function ce(e) {
219
- return o("sha256").update(O(e)).digest("hex").slice(0, 16);
220
+ return o("sha256").update(k(e)).digest("hex").slice(0, 16);
220
221
  }
221
222
  var le = 20;
222
223
  async function ue(e, t) {
@@ -269,20 +270,9 @@ function pe(e, t, n) {
269
270
  let o = `${JSON.stringify(i, null, 2)}\n`;
270
271
  o !== r && p(e, o);
271
272
  }
272
- var me = /import\s*(\{[^}]*\}|\*\s*as\s+[\w$]+)\s*from\s*["']@glasshome\/widget-sdk["']/g, he = /import\(\s*["']@glasshome\/widget-sdk["']\s*\)/;
273
- function k(e) {
274
- let t = /* @__PURE__ */ new Set();
275
- he.test(e) && t.add("*");
276
- for (let [, n = ""] of e.matchAll(me)) if (!n.startsWith("{")) t.add("*");
277
- else for (let e of n.slice(1, -1).split(",")) {
278
- let n = e.trim().split(/\s+as\s+/)[0];
279
- n && t.add(n);
280
- }
281
- return t;
282
- }
283
273
  var A = { useDaylight: "sun.sun" };
284
274
  function j(e, t, n) {
285
- let r = k(e);
275
+ let r = ee(e);
286
276
  for (let [e, a] of Object.entries(A)) {
287
277
  if (!r.has(e) && !r.has("*") || i(t, a)) continue;
288
278
  let o = a.split(".")[0];
@@ -308,18 +298,18 @@ async function M(e) {
308
298
  } catch {
309
299
  n = null;
310
300
  }
311
- if (n && n.hashVersion === D) {
301
+ if (n && n.hashVersion === O) {
312
302
  if (n.hash !== c && n.configVersion === u) throw Error(`[widget-sdk] Config schema shape changed for "${d}" without a configVersion bump. Bump configVersion in defineWidget (currently ${u ?? "unset"}) or revert the schema change, then rebuild. Recorded in ${e.hashFile}`);
313
- } else console.warn(`[widget-sdk] Schema shape record for "${d}" was written by an older SDK, so it cannot be compared. Re-recording it under hash format ${D}. This build is not checked for a missing configVersion bump; the next one is. (${e.hashFile})`);
303
+ } else console.warn(`[widget-sdk] Schema shape record for "${d}" was written by an older SDK, so it cannot be compared. Re-recording it under hash format ${O}. This build is not checked for a missing configVersion bump; the next one is. (${e.hashFile})`);
314
304
  }
315
305
  let m = `${JSON.stringify({
316
306
  hash: c,
317
307
  configVersion: u,
318
- hashVersion: D
308
+ hashVersion: O
319
309
  })}\n`;
320
310
  m !== f && p(e.hashFile, m);
321
311
  }
322
- var ge = "virtual:glasshome-widget", N = "\0virtual:glasshome-widget", P = "/@glasshome/preview";
312
+ var N = "virtual:glasshome-widget", P = "\0virtual:glasshome-widget", me = "/@glasshome/preview";
323
313
  function F(e) {
324
314
  return y === "\\" ? e.split(y).join("/") : e;
325
315
  }
@@ -330,10 +320,10 @@ function I() {
330
320
  function L(e) {
331
321
  return r(e);
332
322
  }
333
- var R = /\.(ts|tsx|js|jsx)$/, _e = /from\s+["']@glasshome\/sync-layer(\/[^"']*)?["']/;
323
+ var R = /\.(ts|tsx|js|jsx)$/, he = /from\s+["']@glasshome\/sync-layer(\/[^"']*)?["']/;
334
324
  function z(e, t) {
335
325
  let n = F(e).split("?")[0] ?? "";
336
- return n.includes("/node_modules/") || !R.test(n) ? !1 : _e.test(t);
326
+ return n.includes("/node_modules/") || !R.test(n) ? !1 : he.test(t);
337
327
  }
338
328
  function B() {
339
329
  return {
@@ -382,7 +372,7 @@ function U(n) {
382
372
  }
383
373
  };
384
374
  }
385
- var ve = "node_modules/.cache/glasshome-widgets";
375
+ var ge = "node_modules/.cache/glasshome-widgets";
386
376
  function W(e) {
387
377
  try {
388
378
  return m(g(process.cwd(), "package.json")).resolve(e);
@@ -390,7 +380,7 @@ function W(e) {
390
380
  return null;
391
381
  }
392
382
  }
393
- var ye = [
383
+ var _e = [
394
384
  "--radius",
395
385
  "--background",
396
386
  "--foreground",
@@ -409,7 +399,7 @@ function K(e, t) {
409
399
  let r = l(n, "utf-8"), i = G(r);
410
400
  i !== r && p(n, i);
411
401
  for (let e of i.matchAll(/:host[^{]*\{([^}]*)\}/g)) {
412
- let n = e[1] ?? "", r = ye.find((e) => n.includes(`${e}:`));
402
+ let n = e[1] ?? "", r = _e.find((e) => n.includes(`${e}:`));
413
403
  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.`);
414
404
  }
415
405
  }
@@ -418,7 +408,7 @@ function q(e, t) {
418
408
  return [r, ...u(n, { withFileTypes: !0 }).filter((e) => e.isDirectory()).map((e) => g(n, e.name)).filter((e) => !i.has(e))];
419
409
  }
420
410
  function J(e, t, n, r) {
421
- let i = v(e, ve);
411
+ let i = v(e, ge);
422
412
  c(i, { recursive: !0 });
423
413
  let a = W("@glasshome/ui/styles");
424
414
  if (!a) 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.");
@@ -451,7 +441,7 @@ function Y() {
451
441
  return { lightningcss: { include: e.HexAlphaColors } };
452
442
  }
453
443
  function X() {
454
- let e = ee();
444
+ let e = te();
455
445
  for (let t of e) t.apply ??= "build";
456
446
  return e;
457
447
  }
@@ -541,7 +531,7 @@ async function $(e) {
541
531
  });
542
532
  Q(r, i);
543
533
  }
544
- function be(e) {
534
+ function ve(e) {
545
535
  let t = e?.entry ?? "src/index.tsx", n = {
546
536
  name: "glasshome-widget:build",
547
537
  apply: "build",
@@ -585,14 +575,14 @@ function be(e) {
585
575
  });
586
576
  },
587
577
  resolveId(e) {
588
- if (e === P) {
578
+ if (e === me) {
589
579
  let e = I();
590
580
  return F(g(e, "host.tsx"));
591
581
  }
592
- if (e === ge) return N;
582
+ if (e === N) return P;
593
583
  },
594
584
  load(e) {
595
- if (e === N) return `export { default } from "${F(v(process.cwd(), t))}";`;
585
+ if (e === P) return `export { default } from "${F(v(process.cwd(), t))}";`;
596
586
  }
597
587
  }, i = {
598
588
  name: "glasshome-widget:schema",
@@ -615,7 +605,7 @@ function be(e) {
615
605
  r
616
606
  ];
617
607
  }
618
- function xe(e) {
608
+ function ye(e) {
619
609
  let t = e?.srcDir ?? "src", n = e?.outDir ?? "dist", r = [];
620
610
  return [{
621
611
  name: "glasshome-widgets:build",
@@ -643,4 +633,4 @@ function xe(e) {
643
633
  }];
644
634
  }
645
635
  //#endregion
646
- export { A as HOOK_READS, le as MAX_EXAMPLES, j as assertHookReadsDeclared, $ as buildWidgets, se as createIntrospectSession, H as createUiImportTracker, Z as discoverWidgets, G as dropSelfReferencingVars, Q as generateRegistry, be as glasshomeWidget, xe as glasshomeWidgets, E as introspectOnce, z as isDirectSyncLayerImportSource, V as isDirectUiImportSource, L as isWidgetExternal, M as runSchemaGuard, k as sdkImportsOf, q as widgetProjectScanDirs };
636
+ export { A as HOOK_READS, le as MAX_EXAMPLES, j as assertHookReadsDeclared, $ as buildWidgets, se as createIntrospectSession, H as createUiImportTracker, Z as discoverWidgets, G as dropSelfReferencingVars, Q as generateRegistry, ve as glasshomeWidget, ye as glasshomeWidgets, E as introspectOnce, z as isDirectSyncLayerImportSource, V as isDirectUiImportSource, L as isWidgetExternal, M as runSchemaGuard, q as widgetProjectScanDirs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-sdk",
3
- "version": "1.24.0",
3
+ "version": "1.25.1",
4
4
  "description": "SDK for building GlassHome dashboard widgets with SolidJS",
5
5
  "keywords": [
6
6
  "dashboard",
@@ -58,6 +58,7 @@
58
58
  "types": "./dist/vite/index.d.ts",
59
59
  "import": "./dist/vite/index.js"
60
60
  },
61
+ "./export-history": "./dist/export-history.json",
61
62
  "./tailwind-sources": "./tailwind-sources.css",
62
63
  "./package.json": "./package.json"
63
64
  },
@@ -65,9 +66,9 @@
65
66
  "access": "public"
66
67
  },
67
68
  "scripts": {
68
- "build": "vite build && tsc -p tsconfig.build.json && bun scripts/check-host-singleton.ts",
69
+ "build": "vite build && tsc -p tsconfig.build.json && bun scripts/check-host-singleton.ts && bun scripts/export-names.ts --emit",
69
70
  "dev": "vite build --watch",
70
- "test": "bun test src && vitest run",
71
+ "test": "bun test src scripts && vitest run",
71
72
  "test:dom": "vitest run",
72
73
  "test:dom:watch": "vitest",
73
74
  "typecheck:test": "tsc --noEmit",
@@ -75,7 +76,7 @@
75
76
  "lint": "oxlint --type-aware . && oxfmt --check ."
76
77
  },
77
78
  "dependencies": {
78
- "@glasshome/widget-contract": "0.4.1",
79
+ "@glasshome/widget-contract": "0.5.1",
79
80
  "@tailwindcss/vite": "^4.1.13",
80
81
  "clsx": "^2.1.1",
81
82
  "happy-dom": "^20.0.0",
@@ -89,14 +90,16 @@
89
90
  "@solidjs/testing-library": "^0.8.10",
90
91
  "@types/bun": "^1.4.0",
91
92
  "@types/node": "^25.2.2",
93
+ "@vitest/browser-playwright": "4.1.11",
92
94
  "fallow": "3.17.0",
93
95
  "oxfmt": "0.65.0",
94
96
  "oxlint": "1.81.0",
95
97
  "oxlint-tsgolint": "7.0.2001",
98
+ "playwright": "1.63.0",
96
99
  "typescript": "^7.0.2",
97
100
  "vite": "^8.1.0",
98
101
  "vite-plugin-solid": "^2.11.12",
99
- "vitest": "^4.1.10"
102
+ "vitest": "4.1.11"
100
103
  },
101
104
  "peerDependencies": {
102
105
  "@glasshome/sync-layer": "0.9.1",