@glasshome/ui 1.21.0 → 1.21.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.
Files changed (154) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/lib/use-is-mobile.d.ts +3 -1
  4. package/dist/solid/alert-dialog.d.ts +7 -1
  5. package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
  6. package/dist/solid/dialog-parts.d.ts +3 -2
  7. package/dist/solid/dialog.d.ts +7 -1
  8. package/dist/solid/docked-panel.d.ts +7 -1
  9. package/dist/solid/index.d.ts +9 -9
  10. package/dist/solid/index.js +5456 -5447
  11. package/dist/solid/media-store.d.ts +4 -1
  12. package/dist/solid/option-card.d.ts +4 -1
  13. package/dist/solid/responsive-dialog.d.ts +7 -1
  14. package/dist/solid/sheet.d.ts +7 -1
  15. package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
  16. package/package.json +128 -126
  17. package/scripts/check-gallery.ts +142 -142
  18. package/scripts/check-pack.ts +13 -13
  19. package/scripts/check-structural-classes.ts +20 -20
  20. package/scripts/check-tokens.ts +27 -27
  21. package/scripts/check-ui-drift.mjs +103 -103
  22. package/src/index.ts +75 -80
  23. package/src/lib/alert-tones.ts +41 -41
  24. package/src/lib/anchor-placement.ts +21 -21
  25. package/src/lib/button-variants.ts +28 -28
  26. package/src/lib/card-classes.ts +9 -9
  27. package/src/lib/carousel-classes.ts +14 -14
  28. package/src/lib/glass-tone.ts +11 -11
  29. package/src/lib/input-classes.ts +6 -6
  30. package/src/lib/layers.ts +4 -4
  31. package/src/lib/logo-lockup.ts +8 -8
  32. package/src/lib/menu-classes.ts +2 -2
  33. package/src/lib/motion-classes.ts +8 -8
  34. package/src/lib/motion-window.ts +24 -24
  35. package/src/lib/overlay-classes.ts +6 -6
  36. package/src/lib/pill-classes.ts +3 -3
  37. package/src/lib/position-bar-classes.ts +1 -1
  38. package/src/lib/spotlight-geometry.ts +67 -67
  39. package/src/lib/thumb-classes.ts +2 -2
  40. package/src/lib/tier-badge.ts +16 -16
  41. package/src/lib/use-is-mobile.ts +17 -14
  42. package/src/lib/utils.ts +1 -1
  43. package/src/solid/accordion.tsx +41 -41
  44. package/src/solid/alert-dialog.tsx +95 -95
  45. package/src/solid/alert.tsx +88 -88
  46. package/src/solid/area-picker.tsx +204 -204
  47. package/src/solid/aspect-ratio.tsx +13 -13
  48. package/src/solid/avatar.tsx +27 -27
  49. package/src/solid/badge.tsx +49 -49
  50. package/src/solid/bottom-sheet/arbitration.ts +22 -22
  51. package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
  52. package/src/solid/bottom-sheet/drag-controller.ts +201 -201
  53. package/src/solid/bottom-sheet/focus-trap.ts +51 -47
  54. package/src/solid/bottom-sheet/index.ts +12 -12
  55. package/src/solid/bottom-sheet/keyboard.ts +25 -25
  56. package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
  57. package/src/solid/bottom-sheet/state-machine.ts +28 -28
  58. package/src/solid/bottom-sheet/velocity.ts +29 -29
  59. package/src/solid/breadcrumb.tsx +76 -76
  60. package/src/solid/button-group.tsx +46 -46
  61. package/src/solid/button.tsx +19 -19
  62. package/src/solid/card.tsx +67 -67
  63. package/src/solid/carousel.tsx +246 -246
  64. package/src/solid/charts.tsx +253 -253
  65. package/src/solid/checkbox.tsx +51 -51
  66. package/src/solid/collapsible.tsx +22 -22
  67. package/src/solid/color-disc.tsx +213 -213
  68. package/src/solid/color-slider.tsx +81 -81
  69. package/src/solid/color-wheel.tsx +61 -61
  70. package/src/solid/context-menu.tsx +63 -63
  71. package/src/solid/copy-button.tsx +31 -31
  72. package/src/solid/count-pill.tsx +11 -11
  73. package/src/solid/dashboard-preview.tsx +104 -104
  74. package/src/solid/data-table.tsx +228 -228
  75. package/src/solid/dialog-parts.tsx +129 -129
  76. package/src/solid/dialog.tsx +113 -113
  77. package/src/solid/dock-paging.ts +9 -9
  78. package/src/solid/dock.tsx +339 -338
  79. package/src/solid/docked-panel.tsx +35 -35
  80. package/src/solid/dropdown-menu.tsx +77 -77
  81. package/src/solid/empty.tsx +70 -70
  82. package/src/solid/entity-data.ts +38 -38
  83. package/src/solid/entity-selector.tsx +634 -634
  84. package/src/solid/field.tsx +205 -205
  85. package/src/solid/form.tsx +159 -159
  86. package/src/solid/hero-action.tsx +85 -85
  87. package/src/solid/hover-card.tsx +11 -11
  88. package/src/solid/icon-picker.tsx +401 -401
  89. package/src/solid/icon.tsx +101 -78
  90. package/src/solid/image-picker.tsx +416 -414
  91. package/src/solid/index.ts +265 -304
  92. package/src/solid/input-group.tsx +123 -123
  93. package/src/solid/input-otp.tsx +143 -143
  94. package/src/solid/input.tsx +4 -4
  95. package/src/solid/item.tsx +130 -130
  96. package/src/solid/kbd.tsx +20 -20
  97. package/src/solid/label.tsx +12 -12
  98. package/src/solid/list-reorder.ts +122 -122
  99. package/src/solid/logo.tsx +60 -60
  100. package/src/solid/media-copy.ts +21 -21
  101. package/src/solid/media-store.ts +60 -57
  102. package/src/solid/media-tile.tsx +85 -85
  103. package/src/solid/menu-parts.tsx +164 -164
  104. package/src/solid/number-field.tsx +56 -56
  105. package/src/solid/option-card.tsx +168 -165
  106. package/src/solid/ornament.tsx +43 -43
  107. package/src/solid/overlay.tsx +4 -4
  108. package/src/solid/page-header.tsx +75 -75
  109. package/src/solid/pagination.tsx +80 -80
  110. package/src/solid/password-input.tsx +51 -51
  111. package/src/solid/picker-row.tsx +83 -83
  112. package/src/solid/picker-search.tsx +65 -63
  113. package/src/solid/picker-trigger.tsx +59 -57
  114. package/src/solid/popover.tsx +54 -54
  115. package/src/solid/preview-tile.tsx +67 -67
  116. package/src/solid/progress.tsx +21 -21
  117. package/src/solid/radio-group.tsx +51 -51
  118. package/src/solid/resizable.tsx +128 -128
  119. package/src/solid/responsive-dialog.tsx +134 -134
  120. package/src/solid/schema-form.tsx +746 -739
  121. package/src/solid/scope-indicator.tsx +5 -5
  122. package/src/solid/scroll-area.tsx +16 -16
  123. package/src/solid/section-card.tsx +281 -281
  124. package/src/solid/select.tsx +101 -101
  125. package/src/solid/separator.tsx +25 -25
  126. package/src/solid/settings-row.tsx +122 -122
  127. package/src/solid/sheet.tsx +96 -96
  128. package/src/solid/skeleton.tsx +8 -8
  129. package/src/solid/slider.tsx +132 -132
  130. package/src/solid/sliding-indicator.tsx +280 -265
  131. package/src/solid/sonner.tsx +164 -164
  132. package/src/solid/spinner.tsx +12 -12
  133. package/src/solid/spotlight.tsx +140 -140
  134. package/src/solid/step-indicator.tsx +18 -18
  135. package/src/solid/swatch-picker.tsx +38 -38
  136. package/src/solid/switch.tsx +52 -52
  137. package/src/solid/table.tsx +63 -63
  138. package/src/solid/tabs.tsx +93 -93
  139. package/src/solid/textarea.tsx +8 -8
  140. package/src/solid/toggle-group.tsx +83 -83
  141. package/src/solid/toggle.tsx +33 -33
  142. package/src/solid/tooltip.tsx +16 -16
  143. package/src/solid/widget-card.tsx +90 -90
  144. package/src/solid/widget-identity.tsx +99 -99
  145. package/src/solid/widget-trust-badge.tsx +20 -20
  146. package/src/styles/globals.css +316 -319
  147. package/src/styles/theme.css +448 -448
  148. package/src/tokens/hex.ts +29 -29
  149. package/src/tokens/material.ts +75 -75
  150. package/src/tokens/presets.ts +303 -303
  151. package/src/tokens/readability.ts +32 -32
  152. package/src/tokens/theme-colors.ts +95 -95
  153. package/src/tokens/theme-css.ts +22 -22
  154. package/src/tokens/theme-recipe.ts +106 -106
package/package.json CHANGED
@@ -1,128 +1,130 @@
1
1
  {
2
- "name": "@glasshome/ui",
3
- "version": "1.21.0",
4
- "description": "SolidJS component library for GlassHome, built on Kobalte",
5
- "type": "module",
6
- "homepage": "https://github.com/glasshome/ui#readme",
7
- "bugs": {
8
- "url": "https://github.com/glasshome/ui/issues"
9
- },
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "engines": {
14
- "node": ">=20"
15
- },
16
- "sideEffects": [
17
- "**/*.css"
18
- ],
19
- "keywords": [
20
- "solidjs",
21
- "components",
22
- "kobalte",
23
- "ui",
24
- "home-assistant",
25
- "smart-home",
26
- "tailwindcss",
27
- "glasshome"
28
- ],
29
- "exports": {
30
- ".": {
31
- "@glasshome/source": "./src/index.ts",
32
- "solid": "./src/index.ts",
33
- "types": "./dist/index.d.ts",
34
- "import": "./dist/index.js"
35
- },
36
- "./solid": {
37
- "@glasshome/source": "./src/solid/index.ts",
38
- "solid": "./src/solid/index.ts",
39
- "types": "./dist/solid/index.d.ts",
40
- "import": "./dist/solid/index.js"
41
- },
42
- "./tokens": {
43
- "@glasshome/source": "./src/tokens/index.ts",
44
- "types": "./dist/tokens/index.d.ts",
45
- "import": "./dist/tokens/index.js"
46
- },
47
- "./styles": "./src/styles/globals.css",
48
- "./package.json": "./package.json",
49
- "./styles/theme": "./src/styles/theme.css",
50
- "./scripts/*": "./scripts/*",
51
- "./backgrounds": {
52
- "@glasshome/source": "./src/backgrounds/index.ts",
53
- "types": "./dist/backgrounds/index.d.ts",
54
- "import": "./dist/backgrounds/index.js"
55
- }
56
- },
57
- "files": [
58
- "dist",
59
- "src/index.ts",
60
- "src/backgrounds",
61
- "src/lib",
62
- "src/solid",
63
- "src/styles",
64
- "src/tokens",
65
- "scripts",
66
- "SPEC.md"
67
- ],
68
- "scripts": {
69
- "build": "rm -rf dist && vite build && tsc",
70
- "check:structural": "bun scripts/check-structural-classes.ts",
71
- "check:dead": "fallow dead-code --fail-on-issues",
72
- "check:gallery": "bun scripts/check-gallery.ts",
73
- "check:styling": "fallow health --css",
74
- "check:tokens": "bun scripts/check-tokens.ts",
75
- "check:types": "tsc --noEmit -p tsconfig.test.json",
76
- "check:publish": "publint && attw --pack . --profile esm-only --exclude-entrypoints ./styles ./styles/theme && bun scripts/check-pack.ts",
77
- "dev": "tsc -b --force && vite build --watch",
78
- "lint": "biome check .",
79
- "test": "vitest run",
80
- "test:watch": "vitest",
81
- "dev:gallery": "vite --config vite.dev.config.ts",
82
- "gallery:shots": "node dev/shoot.mjs"
83
- },
84
- "peerDependencies": {
85
- "solid-js": "^1.9.9",
86
- "tailwindcss": "^4.1.13",
87
- "tw-animate-css": "^1.4.0"
88
- },
89
- "dependencies": {
90
- "@iconify/types": "^2.0.0",
91
- "@iconify/utils": "^3.1.4",
92
- "@kobalte/core": "^0.13.13",
93
- "@types/json-schema": "^7.0.15",
94
- "clsx": "^2.1.1",
95
- "cva": "^1.0.0-beta.4",
96
- "embla-carousel": "^8.5.1",
97
- "embla-carousel-autoplay": "^8.5.1",
98
- "embla-carousel-fade": "^8.5.1",
99
- "solid-sonner": "^0.3.1",
100
- "tailwind-merge": "^3.4.0"
101
- },
102
- "devDependencies": {
103
- "@arethetypeswrong/cli": "^0.18.5",
104
- "@biomejs/biome": "2.4.15",
105
- "@iconify-json/lucide": "^1.2.130",
106
- "@iconify-json/mdi": "^1.2.3",
107
- "@iconify-json/simple-icons": "^1.2.95",
108
- "@solidjs/testing-library": "^0.8.10",
109
- "@tailwindcss/vite": "^4.1.13",
110
- "@types/node": "^25.2.2",
111
- "fallow": "3.17.0",
112
- "happy-dom": "^20.14.0",
113
- "playwright": "^1.60.0",
114
- "publint": "^0.3.21",
115
- "tailwindcss": "^4.1.13",
116
- "tw-animate-css": "^1.4.0",
117
- "typescript": "^7.0.2",
118
- "vite": "^8.1.0",
119
- "vite-plugin-solid": "^2.11.12",
120
- "vitest": "^4.1.10"
121
- },
122
- "repository": {
123
- "type": "git",
124
- "url": "git+https://github.com/glasshome/ui.git"
125
- },
126
- "author": "GlassHome Labs",
127
- "license": "MIT"
2
+ "name": "@glasshome/ui",
3
+ "version": "1.21.2",
4
+ "description": "SolidJS component library for GlassHome, built on Kobalte",
5
+ "keywords": [
6
+ "components",
7
+ "glasshome",
8
+ "home-assistant",
9
+ "kobalte",
10
+ "smart-home",
11
+ "solidjs",
12
+ "tailwindcss",
13
+ "ui"
14
+ ],
15
+ "homepage": "https://github.com/glasshome/ui#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/glasshome/ui/issues"
18
+ },
19
+ "license": "MIT",
20
+ "author": "GlassHome Labs",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/glasshome/ui.git"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "src/index.ts",
28
+ "src/backgrounds",
29
+ "src/lib",
30
+ "src/solid",
31
+ "src/styles",
32
+ "src/tokens",
33
+ "scripts",
34
+ "SPEC.md"
35
+ ],
36
+ "type": "module",
37
+ "sideEffects": [
38
+ "**/*.css"
39
+ ],
40
+ "exports": {
41
+ ".": {
42
+ "@glasshome/source": "./src/index.ts",
43
+ "solid": "./src/index.ts",
44
+ "types": "./dist/index.d.ts",
45
+ "import": "./dist/index.js"
46
+ },
47
+ "./solid": {
48
+ "@glasshome/source": "./src/solid/index.ts",
49
+ "solid": "./src/solid/index.ts",
50
+ "types": "./dist/solid/index.d.ts",
51
+ "import": "./dist/solid/index.js"
52
+ },
53
+ "./tokens": {
54
+ "@glasshome/source": "./src/tokens/index.ts",
55
+ "types": "./dist/tokens/index.d.ts",
56
+ "import": "./dist/tokens/index.js"
57
+ },
58
+ "./styles": "./src/styles/globals.css",
59
+ "./package.json": "./package.json",
60
+ "./styles/theme": "./src/styles/theme.css",
61
+ "./scripts/*": "./scripts/*",
62
+ "./backgrounds": {
63
+ "@glasshome/source": "./src/backgrounds/index.ts",
64
+ "types": "./dist/backgrounds/index.d.ts",
65
+ "import": "./dist/backgrounds/index.js"
66
+ }
67
+ },
68
+ "publishConfig": {
69
+ "access": "public"
70
+ },
71
+ "scripts": {
72
+ "build": "rm -rf dist && vite build && tsc",
73
+ "check:structural": "bun scripts/check-structural-classes.ts",
74
+ "check:dead": "fallow dead-code --fail-on-issues",
75
+ "check:gallery": "bun scripts/check-gallery.ts",
76
+ "check:styling": "fallow health --css",
77
+ "check:tokens": "bun scripts/check-tokens.ts",
78
+ "check:types": "tsc --noEmit -p tsconfig.test.json",
79
+ "check:publish": "publint && attw --pack . --profile esm-only --exclude-entrypoints ./styles ./styles/theme && bun scripts/check-pack.ts",
80
+ "dev": "tsc -b --force && vite build --watch",
81
+ "lint": "oxlint --type-aware . && oxfmt --check .",
82
+ "test": "vitest run",
83
+ "test:watch": "vitest",
84
+ "dev:gallery": "vite --config vite.dev.config.ts",
85
+ "gallery:shots": "node dev/shoot.mjs"
86
+ },
87
+ "dependencies": {
88
+ "@iconify/types": "^2.0.0",
89
+ "@iconify/utils": "^3.1.4",
90
+ "@kobalte/core": "^0.13.13",
91
+ "@types/json-schema": "^7.0.15",
92
+ "clsx": "^2.1.1",
93
+ "cva": "^1.0.0-beta.4",
94
+ "embla-carousel": "^8.5.1",
95
+ "embla-carousel-autoplay": "^8.5.1",
96
+ "embla-carousel-fade": "^8.5.1",
97
+ "solid-sonner": "^0.3.1",
98
+ "tailwind-merge": "^3.4.0"
99
+ },
100
+ "devDependencies": {
101
+ "@arethetypeswrong/cli": "^0.18.5",
102
+ "@iconify-json/lucide": "^1.2.130",
103
+ "@iconify-json/mdi": "^1.2.3",
104
+ "@iconify-json/simple-icons": "^1.2.95",
105
+ "@solidjs/testing-library": "^0.8.10",
106
+ "@tailwindcss/vite": "^4.1.13",
107
+ "@types/node": "^25.2.2",
108
+ "fallow": "3.17.0",
109
+ "happy-dom": "^20.14.0",
110
+ "oxfmt": "0.65.0",
111
+ "oxlint": "1.81.0",
112
+ "oxlint-tsgolint": "7.0.2001",
113
+ "playwright": "^1.60.0",
114
+ "publint": "^0.3.21",
115
+ "tailwindcss": "^4.1.13",
116
+ "tw-animate-css": "^1.4.0",
117
+ "typescript": "^7.0.2",
118
+ "vite": "^8.1.0",
119
+ "vite-plugin-solid": "^2.11.12",
120
+ "vitest": "^4.1.10"
121
+ },
122
+ "peerDependencies": {
123
+ "solid-js": "^1.9.9",
124
+ "tailwindcss": "^4.1.13",
125
+ "tw-animate-css": "^1.4.0"
126
+ },
127
+ "engines": {
128
+ "node": ">=20"
129
+ }
128
130
  }
@@ -2,22 +2,22 @@ import { readdirSync } from "node:fs";
2
2
  import { dirname, join, resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import {
5
- type Identifier,
6
- isIdentifier,
7
- isJsxAttribute,
8
- isJsxElement,
9
- isJsxSelfClosingElement,
10
- isStringLiteral,
11
- type JsxOpeningElement,
12
- type JsxSelfClosingElement,
13
- type Node,
5
+ type Identifier,
6
+ isIdentifier,
7
+ isJsxAttribute,
8
+ isJsxElement,
9
+ isJsxSelfClosingElement,
10
+ isStringLiteral,
11
+ type JsxOpeningElement,
12
+ type JsxSelfClosingElement,
13
+ type Node,
14
14
  } from "typescript/unstable/ast";
15
15
  import {
16
- API,
17
- type Checker,
18
- SignatureKind,
19
- SymbolFlags,
20
- type Symbol as TsSymbol,
16
+ API,
17
+ type Checker,
18
+ SignatureKind,
19
+ SymbolFlags,
20
+ type Symbol as TsSymbol,
21
21
  } from "typescript/unstable/async";
22
22
  import { ALLOW } from "../dev/coverage-allow";
23
23
 
@@ -31,160 +31,160 @@ export type Component = { name: string; module: string };
31
31
  export type SpecimenUse = { name: string; renders: string[] };
32
32
  export type Inventory = { exports: string[]; components: Component[]; specimens: SpecimenUse[] };
33
33
  export type Report = {
34
- uncovered: string[];
35
- unknownSpecimens: string[];
36
- emptyReasons: string[];
37
- staleAllows: string[];
34
+ uncovered: string[];
35
+ unknownSpecimens: string[];
36
+ emptyReasons: string[];
37
+ staleAllows: string[];
38
38
  };
39
39
  type Allow = ReadonlyArray<readonly [name: string, reason: string]>;
40
40
 
41
41
  export function judge(inventory: Inventory, allow: Allow): Report {
42
- const moduleOf = new Map(inventory.components.map((c) => [c.name, c.module]));
43
- const named = new Set(inventory.specimens.map((s) => s.name));
44
- const exportNames = new Set(inventory.exports);
45
- const renderedByOwnModule = (c: Component) =>
46
- inventory.specimens.some(
47
- (s) => moduleOf.get(s.name) === c.module && s.renders.includes(c.name),
48
- );
49
- const uncovered = inventory.components
50
- .filter((c) => !named.has(c.name) && !renderedByOwnModule(c))
51
- .map((c) => c.name);
52
- const unknown = [...named].filter((name) => !exportNames.has(name));
53
- const allowed = new Set(allow.map(([name]) => name));
54
- const failing = new Set([...uncovered, ...unknown]);
55
- return {
56
- uncovered: uncovered.filter((name) => !allowed.has(name)),
57
- unknownSpecimens: unknown.filter((name) => !allowed.has(name)),
58
- emptyReasons: allow.filter(([, reason]) => reason.trim() === "").map(([name]) => name),
59
- staleAllows: allow.filter(([name]) => !failing.has(name)).map(([name]) => name),
60
- };
42
+ const moduleOf = new Map(inventory.components.map((c) => [c.name, c.module]));
43
+ const named = new Set(inventory.specimens.map((s) => s.name));
44
+ const exportNames = new Set(inventory.exports);
45
+ const renderedByOwnModule = (c: Component) =>
46
+ inventory.specimens.some(
47
+ (s) => moduleOf.get(s.name) === c.module && s.renders.includes(c.name),
48
+ );
49
+ const uncovered = inventory.components
50
+ .filter((c) => !named.has(c.name) && !renderedByOwnModule(c))
51
+ .map((c) => c.name);
52
+ const unknown = [...named].filter((name) => !exportNames.has(name));
53
+ const allowed = new Set(allow.map(([name]) => name));
54
+ const failing = new Set([...uncovered, ...unknown]);
55
+ return {
56
+ uncovered: uncovered.filter((name) => !allowed.has(name)),
57
+ unknownSpecimens: unknown.filter((name) => !allowed.has(name)),
58
+ emptyReasons: allow.filter(([, reason]) => reason.trim() === "").map(([name]) => name),
59
+ staleAllows: allow.filter(([name]) => !failing.has(name)).map(([name]) => name),
60
+ };
61
61
  }
62
62
 
63
63
  async function resolveAlias(checker: Checker, symbol: TsSymbol): Promise<TsSymbol> {
64
- return symbol.flags & SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
64
+ return symbol.flags & SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
65
65
  }
66
66
 
67
67
  async function returnsJsx(checker: Checker, symbol: TsSymbol): Promise<boolean> {
68
- const type = await checker.getTypeOfSymbol(symbol);
69
- if (!type) return false;
70
- const signatures = await checker.getSignaturesOfType(type, SignatureKind.Call);
71
- if (signatures.length === 0) return false;
72
- for (const signature of signatures) {
73
- const returned = await checker.getReturnTypeOfSignature(signature);
74
- const alias = await returned?.getAliasSymbol();
75
- const namespace = await alias?.getParent();
76
- if (alias?.name !== "Element" || namespace?.name !== "JSX") return false;
77
- }
78
- return true;
68
+ const type = await checker.getTypeOfSymbol(symbol);
69
+ if (!type) return false;
70
+ const signatures = await checker.getSignaturesOfType(type, SignatureKind.Call);
71
+ if (signatures.length === 0) return false;
72
+ for (const signature of signatures) {
73
+ const returned = await checker.getReturnTypeOfSignature(signature);
74
+ const alias = await returned?.getAliasSymbol();
75
+ const namespace = await alias?.getParent();
76
+ if (alias?.name !== "Element" || namespace?.name !== "JSX") return false;
77
+ }
78
+ return true;
79
79
  }
80
80
 
81
81
  function openingOf(node: Node): JsxOpeningElement | JsxSelfClosingElement | undefined {
82
- if (isJsxElement(node)) return node.openingElement;
83
- return isJsxSelfClosingElement(node) ? node : undefined;
82
+ if (isJsxElement(node)) return node.openingElement;
83
+ return isJsxSelfClosingElement(node) ? node : undefined;
84
84
  }
85
85
 
86
86
  function jsxTag(node: Node): Identifier | undefined {
87
- const opening = openingOf(node);
88
- return opening && isIdentifier(opening.tagName) ? opening.tagName : undefined;
87
+ const opening = openingOf(node);
88
+ return opening && isIdentifier(opening.tagName) ? opening.tagName : undefined;
89
89
  }
90
90
 
91
91
  function specimenName(node: Node): string | undefined {
92
- const opening = openingOf(node);
93
- if (!opening || jsxTag(node)?.text !== "Specimen") return undefined;
94
- for (const attribute of opening.attributes.properties) {
95
- if (!isJsxAttribute(attribute) || !isIdentifier(attribute.name)) continue;
96
- if (attribute.name.text !== "name") continue;
97
- return attribute.initializer && isStringLiteral(attribute.initializer)
98
- ? attribute.initializer.text
99
- : "{non-literal name}";
100
- }
101
- return "{no name}";
92
+ const opening = openingOf(node);
93
+ if (!opening || jsxTag(node)?.text !== "Specimen") return undefined;
94
+ for (const attribute of opening.attributes.properties) {
95
+ if (!isJsxAttribute(attribute) || !isIdentifier(attribute.name)) continue;
96
+ if (attribute.name.text !== "name") continue;
97
+ return attribute.initializer && isStringLiteral(attribute.initializer)
98
+ ? attribute.initializer.text
99
+ : "{non-literal name}";
100
+ }
101
+ return "{no name}";
102
102
  }
103
103
 
104
104
  export async function collectInventory(): Promise<Inventory> {
105
- const api = new API({ cwd: pkg });
106
- try {
107
- const snapshot = await api.updateSnapshot({ openProjects: [CONFIG] });
108
- const project = snapshot.getProject(CONFIG);
109
- if (!project) throw new Error(`typescript did not load ${CONFIG}`);
110
- const { checker, program } = project;
111
-
112
- const entry = await program.getSourceFile(ENTRY);
113
- const entrySymbol = entry && (await checker.getSymbolAtLocation(entry));
114
- if (!entrySymbol) throw new Error(`typescript did not load ${ENTRY}`);
115
-
116
- const exports: string[] = [];
117
- const components: Component[] = [];
118
- const exportsByTarget = new Map<number, string[]>();
119
- for (const exported of await checker.getExportsOfModule(entrySymbol)) {
120
- const target = await resolveAlias(checker, exported);
121
- if (!(target.flags & SymbolFlags.Value)) continue;
122
- exports.push(exported.name);
123
- if (SCREAMING_CASE.test(exported.name) || !(await returnsJsx(checker, target))) continue;
124
- const declaration = target.valueDeclaration ?? target.declarations[0];
125
- components.push({ name: exported.name, module: declaration?.path ?? "" });
126
- exportsByTarget.set(target.id, [...(exportsByTarget.get(target.id) ?? []), exported.name]);
127
- }
128
-
129
- const specimens = new Map<string, Set<string>>();
130
- for (const file of readdirSync(GROUPS).filter((f) => f.endsWith(".tsx"))) {
131
- const source = await program.getSourceFile(join(GROUPS, file));
132
- if (!source) throw new Error(`typescript did not load dev/groups/${file}`);
133
- const tags: Array<{ specimen: string; tag: Node }> = [];
134
- const visit = (node: Node, specimen: string | undefined) => {
135
- const name = specimenName(node);
136
- const inside = name ?? specimen;
137
- if (name !== undefined && !specimens.has(name)) specimens.set(name, new Set());
138
- const tag = name === undefined ? jsxTag(node) : undefined;
139
- if (tag && inside) tags.push({ specimen: inside, tag });
140
- node.forEachChild((child) => {
141
- visit(child, inside);
142
- });
143
- };
144
- visit(source, undefined);
145
-
146
- const symbols = await checker.getSymbolAtLocation(tags.map((t) => t.tag));
147
- for (const [i, symbol] of symbols.entries()) {
148
- const use = tags[i];
149
- if (!symbol || !use) continue;
150
- const target = await resolveAlias(checker, symbol);
151
- for (const exported of exportsByTarget.get(target.id) ?? []) {
152
- specimens.get(use.specimen)?.add(exported);
153
- }
154
- }
155
- }
156
-
157
- return {
158
- exports,
159
- components,
160
- specimens: [...specimens].map(([name, renders]) => ({ name, renders: [...renders] })),
161
- };
162
- } finally {
163
- await api.close();
164
- }
105
+ const api = new API({ cwd: pkg });
106
+ try {
107
+ const snapshot = await api.updateSnapshot({ openProjects: [CONFIG] });
108
+ const project = snapshot.getProject(CONFIG);
109
+ if (!project) throw new Error(`typescript did not load ${CONFIG}`);
110
+ const { checker, program } = project;
111
+
112
+ const entry = await program.getSourceFile(ENTRY);
113
+ const entrySymbol = entry && (await checker.getSymbolAtLocation(entry));
114
+ if (!entrySymbol) throw new Error(`typescript did not load ${ENTRY}`);
115
+
116
+ const exports: string[] = [];
117
+ const components: Component[] = [];
118
+ const exportsByTarget = new Map<number, string[]>();
119
+ for (const exported of await checker.getExportsOfModule(entrySymbol)) {
120
+ const target = await resolveAlias(checker, exported);
121
+ if (!(target.flags & SymbolFlags.Value)) continue;
122
+ exports.push(exported.name);
123
+ if (SCREAMING_CASE.test(exported.name) || !(await returnsJsx(checker, target))) continue;
124
+ const declaration = target.valueDeclaration ?? target.declarations[0];
125
+ components.push({ name: exported.name, module: declaration?.path ?? "" });
126
+ exportsByTarget.set(target.id, [...(exportsByTarget.get(target.id) ?? []), exported.name]);
127
+ }
128
+
129
+ const specimens = new Map<string, Set<string>>();
130
+ for (const file of readdirSync(GROUPS).filter((f) => f.endsWith(".tsx"))) {
131
+ const source = await program.getSourceFile(join(GROUPS, file));
132
+ if (!source) throw new Error(`typescript did not load dev/groups/${file}`);
133
+ const tags: Array<{ specimen: string; tag: Node }> = [];
134
+ const visit = (node: Node, specimen: string | undefined) => {
135
+ const name = specimenName(node);
136
+ const inside = name ?? specimen;
137
+ if (name !== undefined && !specimens.has(name)) specimens.set(name, new Set());
138
+ const tag = name === undefined ? jsxTag(node) : undefined;
139
+ if (tag && inside) tags.push({ specimen: inside, tag });
140
+ node.forEachChild((child) => {
141
+ visit(child, inside);
142
+ });
143
+ };
144
+ visit(source, undefined);
145
+
146
+ const symbols = await checker.getSymbolAtLocation(tags.map((t) => t.tag));
147
+ for (const [i, symbol] of symbols.entries()) {
148
+ const use = tags[i];
149
+ if (!symbol || !use) continue;
150
+ const target = await resolveAlias(checker, symbol);
151
+ for (const exported of exportsByTarget.get(target.id) ?? []) {
152
+ specimens.get(use.specimen)?.add(exported);
153
+ }
154
+ }
155
+ }
156
+
157
+ return {
158
+ exports,
159
+ components,
160
+ specimens: [...specimens].map(([name, renders]) => ({ name, renders: [...renders] })),
161
+ };
162
+ } finally {
163
+ await api.close();
164
+ }
165
165
  }
166
166
 
167
167
  export async function galleryReport(allow: Allow = ALLOW): Promise<Report> {
168
- return judge(await collectInventory(), allow);
168
+ return judge(await collectInventory(), allow);
169
169
  }
170
170
 
171
171
  if (process.argv[1] === fileURLToPath(import.meta.url)) {
172
- const report = await galleryReport();
173
- const failures = [
174
- ...report.uncovered.map(
175
- (name) => `${name}: component export with no <Specimen name="${name}">`,
176
- ),
177
- ...report.unknownSpecimens.map(
178
- (name) => `<Specimen name="${name}">: not an export of src/solid`,
179
- ),
180
- ...report.emptyReasons.map((name) => `dev/coverage-allow.ts ${name}: empty reason`),
181
- ...report.staleAllows.map(
182
- (name) => `dev/coverage-allow.ts ${name}: nothing to allow any more, drop the entry`,
183
- ),
184
- ];
185
- if (failures.length > 0) {
186
- console.error(`check:gallery, ${failures.length} failing:\n${failures.join("\n")}`);
187
- process.exit(1);
188
- }
189
- console.log("check:gallery: every component export has a specimen");
172
+ const report = await galleryReport();
173
+ const failures = [
174
+ ...report.uncovered.map(
175
+ (name) => `${name}: component export with no <Specimen name="${name}">`,
176
+ ),
177
+ ...report.unknownSpecimens.map(
178
+ (name) => `<Specimen name="${name}">: not an export of src/solid`,
179
+ ),
180
+ ...report.emptyReasons.map((name) => `dev/coverage-allow.ts ${name}: empty reason`),
181
+ ...report.staleAllows.map(
182
+ (name) => `dev/coverage-allow.ts ${name}: nothing to allow any more, drop the entry`,
183
+ ),
184
+ ];
185
+ if (failures.length > 0) {
186
+ console.error(`check:gallery, ${failures.length} failing:\n${failures.join("\n")}`);
187
+ process.exit(1);
188
+ }
189
+ console.log("check:gallery: every component export has a specimen");
190
190
  }
@@ -4,29 +4,29 @@ import pkg from "../package.json" with { type: "json" };
4
4
 
5
5
  const root = new URL("..", import.meta.url).pathname;
6
6
  const pack = Bun.spawnSync(["npm", "pack", "--dry-run", "--json", "--ignore-scripts"], {
7
- cwd: root,
7
+ cwd: root,
8
8
  });
9
9
  if (pack.exitCode !== 0) {
10
- console.error(pack.stderr.toString());
11
- process.exit(pack.exitCode ?? 1);
10
+ console.error(pack.stderr.toString());
11
+ process.exit(pack.exitCode ?? 1);
12
12
  }
13
13
  const files = new Set<string>(
14
- (JSON.parse(pack.stdout.toString())[0].files as { path: string }[]).map((f) => f.path),
14
+ (JSON.parse(pack.stdout.toString())[0].files as { path: string }[]).map((f) => f.path),
15
15
  );
16
16
 
17
17
  function targets(value: unknown): string[] {
18
- if (typeof value === "string") return [value];
19
- if (value && typeof value === "object") return Object.values(value).flatMap(targets);
20
- return [];
18
+ if (typeof value === "string") return [value];
19
+ if (value && typeof value === "object") return Object.values(value).flatMap(targets);
20
+ return [];
21
21
  }
22
22
 
23
23
  const missing = [...new Set(targets(pkg.exports))]
24
- .map((t) => t.replace(/^\.\//, ""))
25
- .filter((t) =>
26
- t.endsWith("/*") ? ![...files].some((f) => f.startsWith(t.slice(0, -1))) : !files.has(t),
27
- );
24
+ .map((t) => t.replace(/^\.\//, ""))
25
+ .filter((t) =>
26
+ t.endsWith("/*") ? ![...files].some((f) => f.startsWith(t.slice(0, -1))) : !files.has(t),
27
+ );
28
28
  if (missing.length > 0) {
29
- console.error(`check-pack: exports point outside the tarball:\n ${missing.join("\n ")}`);
30
- process.exit(1);
29
+ console.error(`check-pack: exports point outside the tarball:\n ${missing.join("\n ")}`);
30
+ process.exit(1);
31
31
  }
32
32
  console.log(`check-pack: ${files.size} files, every export target present`);