@glasshome/ui 1.21.1 → 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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/use-is-mobile.d.ts +3 -1
- package/dist/solid/index.d.ts +9 -9
- package/dist/solid/index.js +5431 -5424
- package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
- package/package.json +128 -126
- package/scripts/check-gallery.ts +142 -142
- package/scripts/check-pack.ts +13 -13
- package/scripts/check-structural-classes.ts +20 -20
- package/scripts/check-tokens.ts +27 -27
- package/scripts/check-ui-drift.mjs +103 -103
- package/src/index.ts +75 -80
- package/src/lib/alert-tones.ts +41 -41
- package/src/lib/anchor-placement.ts +21 -21
- package/src/lib/button-variants.ts +28 -28
- package/src/lib/card-classes.ts +9 -9
- package/src/lib/carousel-classes.ts +14 -14
- package/src/lib/glass-tone.ts +11 -11
- package/src/lib/input-classes.ts +6 -6
- package/src/lib/layers.ts +4 -4
- package/src/lib/logo-lockup.ts +8 -8
- package/src/lib/menu-classes.ts +2 -2
- package/src/lib/motion-classes.ts +8 -8
- package/src/lib/motion-window.ts +24 -24
- package/src/lib/overlay-classes.ts +6 -6
- package/src/lib/pill-classes.ts +3 -3
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/spotlight-geometry.ts +67 -67
- package/src/lib/thumb-classes.ts +2 -2
- package/src/lib/tier-badge.ts +16 -16
- package/src/lib/use-is-mobile.ts +17 -14
- package/src/lib/utils.ts +1 -1
- package/src/solid/accordion.tsx +41 -41
- package/src/solid/alert-dialog.tsx +95 -95
- package/src/solid/alert.tsx +88 -88
- package/src/solid/area-picker.tsx +204 -204
- package/src/solid/aspect-ratio.tsx +13 -13
- package/src/solid/avatar.tsx +27 -27
- package/src/solid/badge.tsx +49 -49
- package/src/solid/bottom-sheet/arbitration.ts +22 -22
- package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
- package/src/solid/bottom-sheet/drag-controller.ts +201 -201
- package/src/solid/bottom-sheet/focus-trap.ts +51 -47
- package/src/solid/bottom-sheet/index.ts +12 -12
- package/src/solid/bottom-sheet/keyboard.ts +25 -25
- package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
- package/src/solid/bottom-sheet/state-machine.ts +28 -28
- package/src/solid/bottom-sheet/velocity.ts +29 -29
- package/src/solid/breadcrumb.tsx +76 -76
- package/src/solid/button-group.tsx +46 -46
- package/src/solid/button.tsx +19 -19
- package/src/solid/card.tsx +67 -67
- package/src/solid/carousel.tsx +246 -246
- package/src/solid/charts.tsx +253 -253
- package/src/solid/checkbox.tsx +51 -51
- package/src/solid/collapsible.tsx +22 -22
- package/src/solid/color-disc.tsx +213 -213
- package/src/solid/color-slider.tsx +81 -81
- package/src/solid/color-wheel.tsx +61 -61
- package/src/solid/context-menu.tsx +63 -63
- package/src/solid/copy-button.tsx +31 -31
- package/src/solid/count-pill.tsx +11 -11
- package/src/solid/dashboard-preview.tsx +104 -104
- package/src/solid/data-table.tsx +228 -228
- package/src/solid/dialog-parts.tsx +127 -127
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -339
- package/src/solid/docked-panel.tsx +35 -35
- package/src/solid/dropdown-menu.tsx +77 -77
- package/src/solid/empty.tsx +70 -70
- package/src/solid/entity-data.ts +38 -38
- package/src/solid/entity-selector.tsx +634 -634
- package/src/solid/field.tsx +205 -205
- package/src/solid/form.tsx +159 -159
- package/src/solid/hero-action.tsx +85 -85
- package/src/solid/hover-card.tsx +11 -11
- package/src/solid/icon-picker.tsx +401 -401
- package/src/solid/icon.tsx +101 -78
- package/src/solid/image-picker.tsx +416 -414
- package/src/solid/index.ts +265 -304
- package/src/solid/input-group.tsx +123 -123
- package/src/solid/input-otp.tsx +143 -143
- package/src/solid/input.tsx +4 -4
- package/src/solid/item.tsx +130 -130
- package/src/solid/kbd.tsx +20 -20
- package/src/solid/label.tsx +12 -12
- package/src/solid/list-reorder.ts +122 -122
- package/src/solid/logo.tsx +60 -60
- package/src/solid/media-copy.ts +21 -21
- package/src/solid/media-store.ts +56 -56
- package/src/solid/media-tile.tsx +85 -85
- package/src/solid/menu-parts.tsx +164 -164
- package/src/solid/number-field.tsx +56 -56
- package/src/solid/option-card.tsx +164 -164
- package/src/solid/ornament.tsx +43 -43
- package/src/solid/overlay.tsx +4 -4
- package/src/solid/page-header.tsx +75 -75
- package/src/solid/pagination.tsx +80 -80
- package/src/solid/password-input.tsx +51 -51
- package/src/solid/picker-row.tsx +83 -83
- package/src/solid/picker-search.tsx +65 -63
- package/src/solid/picker-trigger.tsx +59 -57
- package/src/solid/popover.tsx +54 -54
- package/src/solid/preview-tile.tsx +67 -67
- package/src/solid/progress.tsx +21 -21
- package/src/solid/radio-group.tsx +51 -51
- package/src/solid/resizable.tsx +128 -128
- package/src/solid/responsive-dialog.tsx +134 -134
- package/src/solid/schema-form.tsx +743 -743
- package/src/solid/scope-indicator.tsx +5 -5
- package/src/solid/scroll-area.tsx +16 -16
- package/src/solid/section-card.tsx +281 -281
- package/src/solid/select.tsx +101 -101
- package/src/solid/separator.tsx +25 -25
- package/src/solid/settings-row.tsx +122 -122
- package/src/solid/sheet.tsx +96 -96
- package/src/solid/skeleton.tsx +8 -8
- package/src/solid/slider.tsx +132 -132
- package/src/solid/sliding-indicator.tsx +280 -265
- package/src/solid/sonner.tsx +164 -164
- package/src/solid/spinner.tsx +12 -12
- package/src/solid/spotlight.tsx +140 -140
- package/src/solid/step-indicator.tsx +18 -18
- package/src/solid/swatch-picker.tsx +38 -38
- package/src/solid/switch.tsx +52 -52
- package/src/solid/table.tsx +63 -63
- package/src/solid/tabs.tsx +93 -93
- package/src/solid/textarea.tsx +8 -8
- package/src/solid/toggle-group.tsx +83 -83
- package/src/solid/toggle.tsx +33 -33
- package/src/solid/tooltip.tsx +16 -16
- package/src/solid/widget-card.tsx +90 -90
- package/src/solid/widget-identity.tsx +99 -99
- package/src/solid/widget-trust-badge.tsx +20 -20
- package/src/styles/globals.css +316 -319
- package/src/styles/theme.css +448 -448
- package/src/tokens/hex.ts +29 -29
- package/src/tokens/material.ts +75 -75
- package/src/tokens/presets.ts +303 -303
- package/src/tokens/readability.ts +32 -32
- package/src/tokens/theme-colors.ts +95 -95
- package/src/tokens/theme-css.ts +22 -22
- package/src/tokens/theme-recipe.ts +106 -106
package/package.json
CHANGED
|
@@ -1,128 +1,130 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
}
|
package/scripts/check-gallery.ts
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
88
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
168
|
+
return judge(await collectInventory(), allow);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
}
|
package/scripts/check-pack.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
+
cwd: root,
|
|
8
8
|
});
|
|
9
9
|
if (pack.exitCode !== 0) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
console.error(pack.stderr.toString());
|
|
11
|
+
process.exit(pack.exitCode ?? 1);
|
|
12
12
|
}
|
|
13
13
|
const files = new Set<string>(
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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`);
|