@uselets/ui 0.6.0 → 0.6.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/skills/uselets-ui/SKILL.md +72 -0
- package/dist/skills/uselets-ui/agents/openai.yaml +4 -0
- package/dist/skills/uselets-ui/references/component-catalog.md +202 -0
- package/dist/skills/uselets-ui/references/package-guide.md +264 -0
- package/dist/skills/uselets-ui/scripts/print-public-api.mjs +174 -0
- package/dist/styles.css +1 -1
- package/dist/themes/gomax.css +1 -1
- package/dist/themes/max.css +1 -1
- package/package.json +1 -1
- package/skills/uselets-ui/SKILL.md +72 -0
- package/skills/uselets-ui/agents/openai.yaml +4 -0
- package/skills/uselets-ui/references/component-catalog.md +202 -0
- package/skills/uselets-ui/references/package-guide.md +264 -0
- package/skills/uselets-ui/scripts/print-public-api.mjs +174 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
|
|
6
|
+
function exists(targetPath) {
|
|
7
|
+
return fs.existsSync(targetPath)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function read(filePath) {
|
|
11
|
+
return fs.readFileSync(filePath, 'utf8')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function listFiles(dirPath, extension) {
|
|
15
|
+
return fs
|
|
16
|
+
.readdirSync(dirPath)
|
|
17
|
+
.filter((file) => file.endsWith(extension))
|
|
18
|
+
.sort((left, right) => left.localeCompare(right))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function uniqueSorted(values) {
|
|
22
|
+
return [...new Set(values)].sort((left, right) => left.localeCompare(right))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function findInstalledPackageJson(startDir) {
|
|
26
|
+
let currentDir = path.resolve(startDir)
|
|
27
|
+
|
|
28
|
+
while (true) {
|
|
29
|
+
const candidate = path.join(currentDir, 'node_modules/@uselets/ui/package.json')
|
|
30
|
+
|
|
31
|
+
if (exists(candidate)) {
|
|
32
|
+
return candidate
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const parentDir = path.dirname(currentDir)
|
|
36
|
+
|
|
37
|
+
if (parentDir === currentDir) {
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
currentDir = parentDir
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parseNamedPart(part) {
|
|
46
|
+
const trimmed = part.trim()
|
|
47
|
+
|
|
48
|
+
if (!trimmed) {
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const isType = trimmed.startsWith('type ')
|
|
53
|
+
const withoutType = isType ? trimmed.slice(5).trim() : trimmed
|
|
54
|
+
const segments = withoutType.split(/\s+as\s+/i)
|
|
55
|
+
const name = segments[segments.length - 1].trim()
|
|
56
|
+
|
|
57
|
+
if (!name) {
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { isType, name }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function collectExports(source) {
|
|
65
|
+
const runtime = []
|
|
66
|
+
const types = []
|
|
67
|
+
|
|
68
|
+
for (const match of source.matchAll(/export\s+(const|function|class|declare\s+const|declare\s+function|declare\s+class)\s+([A-Za-z0-9_]+)/g)) {
|
|
69
|
+
runtime.push(match[2])
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const match of source.matchAll(/export\s+(type|interface)\s+([A-Za-z0-9_]+)/g)) {
|
|
73
|
+
types.push(match[2])
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
for (const match of source.matchAll(/export\s+(type\s+)?\{([\s\S]*?)\}\s*(?:from\s+['"][^'"]+['"])?/g)) {
|
|
77
|
+
const blockIsTypeOnly = Boolean(match[1])
|
|
78
|
+
const parts = match[2].split(',').map((part) => parseNamedPart(part)).filter(Boolean)
|
|
79
|
+
|
|
80
|
+
for (const part of parts) {
|
|
81
|
+
if (blockIsTypeOnly || part.isType) {
|
|
82
|
+
types.push(part.name)
|
|
83
|
+
} else {
|
|
84
|
+
runtime.push(part.name)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
runtime: uniqueSorted(runtime),
|
|
91
|
+
types: uniqueSorted(types)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function buildModuleList(dirPath, extension, kind, packageRoot) {
|
|
96
|
+
if (!exists(dirPath)) {
|
|
97
|
+
return []
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return listFiles(dirPath, extension).map((fileName) => {
|
|
101
|
+
const source = read(path.join(dirPath, fileName))
|
|
102
|
+
const moduleName = fileName.replace(new RegExp(`${extension}$`), '')
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
kind,
|
|
106
|
+
module: moduleName,
|
|
107
|
+
source: path.relative(packageRoot, path.join(dirPath, fileName)),
|
|
108
|
+
subpath: getPublicSubpath(kind, moduleName),
|
|
109
|
+
...collectExports(source)
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getPublicSubpath(kind, moduleName) {
|
|
115
|
+
if (kind === 'hooks') {
|
|
116
|
+
return `@uselets/ui/hooks/${moduleName}`
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (kind === 'lib') {
|
|
120
|
+
return moduleName === 'utils' ? '@uselets/ui/utils' : `@uselets/ui/lib/${moduleName}`
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return `@uselets/ui/${moduleName}`
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function printModuleSection(title, modules) {
|
|
127
|
+
console.log(`\n## ${title}\n`)
|
|
128
|
+
|
|
129
|
+
for (const moduleInfo of modules) {
|
|
130
|
+
console.log(`### ${moduleInfo.module}`)
|
|
131
|
+
console.log(`- source: \`${moduleInfo.source}\``)
|
|
132
|
+
console.log(`- subpath: \`${moduleInfo.subpath}\``)
|
|
133
|
+
console.log(`- runtime exports: ${moduleInfo.runtime.length > 0 ? `\`${moduleInfo.runtime.join('`, `')}\`` : '_none_'}`)
|
|
134
|
+
console.log(`- type exports: ${moduleInfo.types.length > 0 ? `\`${moduleInfo.types.join('`, `')}\`` : '_none_'}`)
|
|
135
|
+
console.log('')
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const packageJsonPath = findInstalledPackageJson(process.cwd())
|
|
140
|
+
|
|
141
|
+
if (!packageJsonPath) {
|
|
142
|
+
console.log('# @uselets/ui public API\n')
|
|
143
|
+
console.log('No installed `@uselets/ui` package was found from the current working directory.')
|
|
144
|
+
console.log('Install the package first or use the bundled references in this skill as a snapshot.')
|
|
145
|
+
process.exit(0)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const packageRoot = path.dirname(packageJsonPath)
|
|
149
|
+
const packageJson = JSON.parse(read(packageJsonPath))
|
|
150
|
+
const distRoot = path.join(packageRoot, 'dist')
|
|
151
|
+
|
|
152
|
+
const componentModules = buildModuleList(path.join(distRoot, 'components'), '.d.ts', 'components', packageRoot)
|
|
153
|
+
const hookModules = buildModuleList(path.join(distRoot, 'hooks'), '.d.ts', 'hooks', packageRoot)
|
|
154
|
+
const libModules = buildModuleList(path.join(distRoot, 'lib'), '.d.ts', 'lib', packageRoot)
|
|
155
|
+
|
|
156
|
+
console.log('# @uselets/ui public API\n')
|
|
157
|
+
console.log(`- package root: \`${packageRoot}\``)
|
|
158
|
+
console.log(`- package version: \`${packageJson.version ?? 'unknown'}\``)
|
|
159
|
+
console.log('- barrel: `@uselets/ui`')
|
|
160
|
+
console.log('- component subpaths: `@uselets/ui/*`')
|
|
161
|
+
console.log('- hook subpaths: `@uselets/ui/hooks/*`')
|
|
162
|
+
console.log('- utility helpers: `@uselets/ui/utils`')
|
|
163
|
+
console.log('- styles: `@uselets/ui/styles.css` (legacy Max theme alias)')
|
|
164
|
+
console.log('- Max theme: `@uselets/ui/themes/max.css`')
|
|
165
|
+
console.log('- Gomax theme: `@uselets/ui/themes/gomax.css`')
|
|
166
|
+
console.log('- PostCSS preset: `@uselets/ui/postcss.config`')
|
|
167
|
+
console.log('')
|
|
168
|
+
console.log(`- components: ${componentModules.length}`)
|
|
169
|
+
console.log(`- hooks: ${hookModules.length}`)
|
|
170
|
+
console.log(`- lib modules: ${libModules.length}`)
|
|
171
|
+
|
|
172
|
+
printModuleSection('Components', componentModules)
|
|
173
|
+
printModuleSection('Hooks', hookModules)
|
|
174
|
+
printModuleSection('Lib', libModules)
|