From 102d012748c66062da56724ac60ff25f52ed75ac Mon Sep 17 00:00:00 2001 From: owjs3901 Date: Tue, 24 Mar 2026 21:10:50 +0900 Subject: [PATCH] Add CustomShadows and CustomLength --- .../changepack_log_8vb3iWgjR0gltow_Jfi6F.json | 1 + __tests__/convert-type.test.ts | 11 ++++---- build.ts | 4 +-- bun.lock | 26 +++++++++---------- package.json | 4 +-- src/index.d.ts | 8 ++++-- 6 files changed, 29 insertions(+), 25 deletions(-) create mode 100644 .changepacks/changepack_log_8vb3iWgjR0gltow_Jfi6F.json diff --git a/.changepacks/changepack_log_8vb3iWgjR0gltow_Jfi6F.json b/.changepacks/changepack_log_8vb3iWgjR0gltow_Jfi6F.json new file mode 100644 index 0000000..e3a57d6 --- /dev/null +++ b/.changepacks/changepack_log_8vb3iWgjR0gltow_Jfi6F.json @@ -0,0 +1 @@ +{"changes":{"package.json":"Patch"},"note":"Add CustomShadows and CustomLength","date":"2026-03-24T12:10:37.421989100Z"} \ No newline at end of file diff --git a/__tests__/convert-type.test.ts b/__tests__/convert-type.test.ts index 82bf937..c1247b7 100644 --- a/__tests__/convert-type.test.ts +++ b/__tests__/convert-type.test.ts @@ -2,9 +2,8 @@ import { expect, test } from 'bun:test' import { convertType } from '../convert-type' -test.each([['string', '"string" | Globals']])( - 'convertType', - (type, expected) => { - expect(convertType(type, {})).toEqual(expected) - }, -) +test.each([ + ['string', '"string" | Globals'], +])('convertType', (type, expected) => { + expect(convertType(type, {})).toEqual(expected) +}) diff --git a/build.ts b/build.ts index 5417b94..71f298d 100644 --- a/build.ts +++ b/build.ts @@ -2,7 +2,7 @@ import { convertType } from './convert-type' import { toCamelCase } from './to-camelcase' import { toPascalCase } from './to-pascalcase' -let output = `// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomColors{}\nexport as namespace CSS;\n` +let output = `// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomColors{}\n// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomLength{}\n// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomShadows{}\nexport as namespace CSS;\n` const syntaxes = (await fetch( 'https://raw.githubusercontent.com/mdn/data/refs/heads/main/css/syntaxes.json', @@ -177,7 +177,7 @@ for (const [property, value] of Object.entries(syntaxes)) { if (property in customSyntaxes) { continue } - output += `export type T${toPascalCase(property)} = ${convertType(value.syntax.replace(' |'), syntaxes)}${property === 'color' ? ' | keyof CustomColors' : ''};\n` + output += `export type T${toPascalCase(property)} = ${convertType(value.syntax.replace(' |'), syntaxes)}${property === 'color' ? ' | keyof CustomColors' : property === 'length-percentage' ? ' | keyof CustomLength' : property === 'shadow' ? ' | keyof CustomShadows' : ''};\n` } Bun.write('src/index.d.ts', output) diff --git a/bun.lock b/bun.lock index 48c984f..0d181ae 100644 --- a/bun.lock +++ b/bun.lock @@ -5,10 +5,10 @@ "": { "name": "csstypes", "devDependencies": { - "@biomejs/biome": "^2.3", + "@biomejs/biome": "^2.4", "@types/bun": "latest", "@types/css-tree": "^2.3.11", - "css-tree": "^3.1.0", + "css-tree": "^3.2.1", "husky": "^9.1", }, "peerDependencies": { @@ -17,23 +17,23 @@ }, }, "packages": { - "@biomejs/biome": ["@biomejs/biome@2.3.5", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.3.5", "@biomejs/cli-darwin-x64": "2.3.5", "@biomejs/cli-linux-arm64": "2.3.5", "@biomejs/cli-linux-arm64-musl": "2.3.5", "@biomejs/cli-linux-x64": "2.3.5", "@biomejs/cli-linux-x64-musl": "2.3.5", "@biomejs/cli-win32-arm64": "2.3.5", "@biomejs/cli-win32-x64": "2.3.5" }, "bin": { "biome": "bin/biome" } }, "sha512-HvLhNlIlBIbAV77VysRIBEwp55oM/QAjQEin74QQX9Xb259/XP/D5AGGnZMOyF1el4zcvlNYYR3AyTMUV3ILhg=="], + "@biomejs/biome": ["@biomejs/biome@2.4.8", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.4.8", "@biomejs/cli-darwin-x64": "2.4.8", "@biomejs/cli-linux-arm64": "2.4.8", "@biomejs/cli-linux-arm64-musl": "2.4.8", "@biomejs/cli-linux-x64": "2.4.8", "@biomejs/cli-linux-x64-musl": "2.4.8", "@biomejs/cli-win32-arm64": "2.4.8", "@biomejs/cli-win32-x64": "2.4.8" }, "bin": { "biome": "bin/biome" } }, "sha512-ponn0oKOky1oRXBV+rlSaUlixUxf1aZvWC19Z41zBfUOUesthrQqL3OtiAlSB1EjFjyWpn98Q64DHelhA6jNlA=="], - "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.3.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-fLdTur8cJU33HxHUUsii3GLx/TR0BsfQx8FkeqIiW33cGMtUD56fAtrh+2Fx1uhiCsVZlFh6iLKUU3pniZREQw=="], + "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.4.8", "", { "os": "darwin", "cpu": "arm64" }, "sha512-ARx0tECE8I7S2C2yjnWYLNbBdDoPdq3oyNLhMglmuctThwUsuzFWRKrHmIGwIRWKz0Mat9DuzLEDp52hGnrxGQ=="], - "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.3.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-qpT8XDqeUlzrOW8zb4k3tjhT7rmvVRumhi2657I2aGcY4B+Ft5fNwDdZGACzn8zj7/K1fdWjgwYE3i2mSZ+vOA=="], + "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.4.8", "", { "os": "darwin", "cpu": "x64" }, "sha512-Jg9/PsB9vDCJlANE8uhG7qDhb5w0Ix69D7XIIc8IfZPUoiPrbLm33k2Ig3NOJ/7nb3UbesFz3D1aDKm9DvzjhQ=="], - "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-u/pybjTBPGBHB66ku4pK1gj+Dxgx7/+Z0jAriZISPX1ocTO8aHh8x8e7Kb1rB4Ms0nA/SzjtNOVJ4exVavQBCw=="], + "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.4.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-5CdrsJct76XG2hpKFwXnEtlT1p+4g4yV+XvvwBpzKsTNLO9c6iLlAxwcae2BJ7ekPGWjNGw9j09T5KGPKKxQig=="], - "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-eGUG7+hcLgGnMNl1KHVZUYxahYAhC462jF/wQolqu4qso2MSk32Q+QrpN7eN4jAHAg7FUMIo897muIhK4hXhqg=="], + "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.4.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-Zo9OhBQDJ3IBGPlqHiTISloo5H0+FBIpemqIJdW/0edJ+gEcLR+MZeZozcUyz3o1nXkVA7++DdRKQT0599j9jA=="], - "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-XrIVi9YAW6ye0CGQ+yax0gLfx+BFOtKaNX74n+xHWla6Cl6huUmcKNO7HPx7BiKnJUzrxXY1qYlm7xMvi08X4g=="], + "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.4.8", "", { "os": "linux", "cpu": "x64" }, "sha512-PdKXspVEaMCQLjtZCn6vfSck/li4KX9KGwSDbZdgIqlrizJ2MnMcE3TvHa2tVfXNmbjMikzcfJpuPWH695yJrw=="], - "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-awVuycTPpVTH/+WDVnEEYSf6nbCBHf/4wB3lquwT7puhNg8R4XvonWNZzUsfHZrCkjkLhFH/vCZK5jHatD9FEg=="], + "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.4.8", "", { "os": "linux", "cpu": "x64" }, "sha512-Gi8quv8MEuDdKaPFtS2XjEnMqODPsRg6POT6KhoP+VrkNb+T2ywunVB+TvOU0LX1jAZzfBr+3V1mIbBhzAMKvw=="], - "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.3.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-DlBiMlBZZ9eIq4H7RimDSGsYcOtfOIfZOaI5CqsWiSlbTfqbPVfWtCf92wNzx8GNMbu1s7/g3ZZESr6+GwM/SA=="], + "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.4.8", "", { "os": "win32", "cpu": "arm64" }, "sha512-LoFatS0tnHv6KkCVpIy3qZCih+MxUMvdYiPWLHRri7mhi2vyOOs8OrbZBcLTUEWCS+ktO72nZMy4F96oMhkOHQ=="], - "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.3.5", "", { "os": "win32", "cpu": "x64" }, "sha512-nUmR8gb6yvrKhtRgzwo/gDimPwnO5a4sCydf8ZS2kHIJhEmSmk+STsusr1LHTuM//wXppBawvSQi2xFXJCdgKQ=="], + "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.4.8", "", { "os": "win32", "cpu": "x64" }, "sha512-vAn7iXDoUbqFXqVocuq1sMYAd33p8+mmurqJkWl6CtIhobd/O6moe4rY5AJvzbunn/qZCdiDVcveqtkFh1e7Hg=="], "@types/bun": ["@types/bun@1.3.2", "", { "dependencies": { "bun-types": "1.3.2" } }, "sha512-t15P7k5UIgHKkxwnMNkJbWlh/617rkDGEdSsDbu+qNHTaz9SKf7aC8fiIlUdD5RPpH6GEkP0cK7WlvmrEBRtWg=="], @@ -45,13 +45,13 @@ "bun-types": ["bun-types@1.3.2", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-i/Gln4tbzKNuxP70OWhJRZz1MRfvqExowP7U6JKoI8cntFrtxg7RJK3jvz7wQW54UuvNC8tbKHHri5fy74FVqg=="], - "css-tree": ["css-tree@3.1.0", "", { "dependencies": { "mdn-data": "2.12.2", "source-map-js": "^1.0.1" } }, "sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w=="], + "css-tree": ["css-tree@3.2.1", "", { "dependencies": { "mdn-data": "2.27.1", "source-map-js": "^1.2.1" } }, "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA=="], "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], "husky": ["husky@9.1.7", "", { "bin": { "husky": "bin.js" } }, "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA=="], - "mdn-data": ["mdn-data@2.12.2", "", {}, "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA=="], + "mdn-data": ["mdn-data@2.27.1", "", {}, "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ=="], "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="], diff --git a/package.json b/package.json index 8bc6ce7..39754fb 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,10 @@ ], "types": "src/index.d.ts", "devDependencies": { - "@biomejs/biome": "^2.3", + "@biomejs/biome": "^2.4", "@types/bun": "latest", "@types/css-tree": "^2.3.11", - "css-tree": "^3.1.0", + "css-tree": "^3.2.1", "husky": "^9.1" }, "peerDependencies": { diff --git a/src/index.d.ts b/src/index.d.ts index ff73fe0..dc386b3 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,5 +1,9 @@ // biome-ignore lint/suspicious/noEmptyInterface: gen export interface CustomColors {} +// biome-ignore lint/suspicious/noEmptyInterface: gen +export interface CustomLength {} +// biome-ignore lint/suspicious/noEmptyInterface: gen +export interface CustomShadows {} export as namespace CSS export interface StandardLonghandProperties { accentColor?: Property.AccentColor | undefined @@ -4155,7 +4159,7 @@ export type TKeyframeSelector = export type TKeyframesName = (string & {}) | Globals export type TLayerName = "'.'" | Globals export type TLeaderType = 'dotted' | 'solid' | 'space' | (string & {}) | Globals -export type TLengthPercentage = number | Globals +export type TLengthPercentage = number | Globals | keyof CustomLength export type TLineNameList = TLineNames | TNameRepeat | Globals export type TLineNames = "'['" | "']'" | Globals export type TLineStyle = @@ -4661,7 +4665,7 @@ export type TSelfPosition = | 'flex-start' | 'flex-end' | Globals -export type TShadow = 'inset' | number | TColor | Globals +export type TShadow = 'inset' | number | TColor | Globals | keyof CustomShadows export type TShadowT = number | TColor | Globals export type TShape = Globals export type TShapeBox = TVisualBox | 'margin-box' | Globals