Skip to content

Commit e0172d4

Browse files
committed
Fix css files
1 parent f81291b commit e0172d4

File tree

2 files changed

+2552
-831
lines changed

2 files changed

+2552
-831
lines changed

build.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { convertType } from './convert-type'
22
import { toCamelCase } from './to-camelcase'
33
import { toPascalCase } from './to-pascalcase'
44

5-
let output = `// biome-ignore lint/suspicious/noEmptyInterface: <explanation>\nexport interface CustomColors{}\nexport as namespace CSS;\n`
5+
let output = `// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomColors{}\nexport as namespace CSS;\n`
66

77
const syntaxes = (await fetch(
88
'https://raw.githubusercontent.com/mdn/data/refs/heads/main/css/syntaxes.json',
@@ -67,11 +67,20 @@ const customSyntaxes = {
6767

6868
Object.assign(syntaxes, customSyntaxes)
6969

70-
const standardPropertyTypes: string[] = []
71-
const standardLonghandProperties: [string, { syntax: string; status: string }][] = []
72-
const standardShorthandProperties: [string, { syntax: string; status: string }][] = []
73-
const vendorLonghandProperties: [string, { syntax: string; status: string }][] = []
74-
const vendorShorthandProperties: [string, { syntax: string; status: string }][] = []
70+
const standardLonghandProperties: [
71+
string,
72+
{ syntax: string; status: string },
73+
][] = []
74+
const standardShorthandProperties: [
75+
string,
76+
{ syntax: string; status: string },
77+
][] = []
78+
const vendorLonghandProperties: [string, { syntax: string; status: string }][] =
79+
[]
80+
const vendorShorthandProperties: [
81+
string,
82+
{ syntax: string; status: string },
83+
][] = []
7584
for (const [property, value] of Object.entries(properties)) {
7685
// skip vendor prefixed properties
7786
if (property.startsWith('--')) continue
@@ -80,17 +89,15 @@ for (const [property, value] of Object.entries(properties)) {
8089
property.startsWith('-webkit-') ||
8190
property.startsWith('-moz-')
8291
) {
83-
if(Array.isArray(value.computed))
92+
if (Array.isArray(value.computed))
8493
vendorShorthandProperties.push([property, value])
85-
else
86-
vendorLonghandProperties.push([property, value])
94+
else vendorLonghandProperties.push([property, value])
8795
continue
8896
}
8997
if (value.status !== 'standard') continue
90-
if(Array.isArray(value.computed))
98+
if (Array.isArray(value.computed))
9199
standardShorthandProperties.push([property, value])
92-
else
93-
standardLonghandProperties.push([property, value])
100+
else standardLonghandProperties.push([property, value])
94101
}
95102

96103
output += `export interface StandardLonghandProperties {
@@ -109,17 +116,22 @@ output += `export interface VendorShorthandProperties {
109116
${vendorShorthandProperties.map(([p, _]) => ` ${toCamelCase(p).replace(/^Ms/, 'ms')}?: Property.${toPascalCase(p)} | undefined`).join('\n')}
110117
}\n`
111118

112-
113119
// AtRules
114-
output += `export type AtRules = ${Object.keys(atRules).map((p) => `"${p}"`).join(' | ')}\n`
120+
output += `export type AtRules = ${Object.keys(atRules)
121+
.map((p) => `"${p}"`)
122+
.join(' | ')}\n`
115123

116124
// advenced pseudos
117-
output += `export type AdvancedPseudos = ${Object.keys(selectors).filter((p) => p.includes('(') && p.includes(')')).map((p) => `"${p}"`).join(' | ')}\n`
118-
output += `export type SimplePseudos = ${Object.keys(selectors).filter((p) => !p.includes('(') && !p.includes(')')).map((p) => `"${p}"`).join(' | ')}\n`
125+
output += `export type AdvancedPseudos = ${Object.keys(selectors)
126+
.filter((p) => p.includes('(') && p.includes(')'))
127+
.map((p) => `"${p}"`)
128+
.join(' | ')}\n`
129+
output += `export type SimplePseudos = ${Object.keys(selectors)
130+
.filter((p) => !p.includes('(') && !p.includes(')'))
131+
.map((p) => `"${p}"`)
132+
.join(' | ')}\n`
119133
output += `export type Pseudos = AdvancedPseudos | SimplePseudos\n`
120134

121-
122-
123135
output += `export namespace Property {\n`
124136
for (const [property, value] of standardLonghandProperties) {
125137
output += ` export type ${toPascalCase(property)} = ${convertType(value.syntax, syntaxes)};\n`
@@ -156,4 +168,3 @@ Bun.write('src/index.d.ts', output)
156168
// $example: unknown
157169
// }
158170
// }
159-

0 commit comments

Comments
 (0)