1- import { segment } from "./utils/segment" ;
2- import { findRoot } from "./find-root" ;
3- import { type FunctionalPlugin , functionalPlugins , namedPlugins , type Variant } from "./plugins" ;
4- import { parseVariant } from "./parse-variant" ;
5- import { inferDataType } from "./utils/infer-data-type" ;
6- import { getValue , type Value } from "./utils/value" ;
7- import type { Config , ScreensConfig } from "tailwindcss/types/config" ;
8- import { getTailwindTheme } from "./theme" ;
9- import { CalculateHexFromString } from "./utils/calculate-hex-from-string" ;
10- import { findTailwindColorFromHex } from "./utils/find-tailwind-color-from-hex" ;
11- import { buildModifier } from "./utils/build-modifier" ;
12- import { isColor } from "./utils/is-color" ;
13- import { decodeArbitraryValue } from "./utils/decodeArbitraryValue" ;
1+ import { segment } from "./utils/segment" ;
2+ import { findRoot } from "./find-root" ;
3+ import { type FunctionalPlugin , functionalPlugins , namedPlugins , type Variant } from "./plugins" ;
4+ import { parseVariant } from "./parse-variant" ;
5+ import { inferDataType } from "./utils/infer-data-type" ;
6+ import { getValue , type Value } from "./utils/value" ;
7+ import { getTailwindTheme } from "./theme" ;
8+ import { CalculateHexFromString } from "./utils/calculate-hex-from-string" ;
9+ import { findTailwindColorFromHex } from "./utils/find-tailwind-color-from-hex" ;
10+ import { buildModifier } from "./utils/build-modifier" ;
11+ import { isColor } from "./utils/is-color" ;
12+ import { decodeArbitraryValue } from "./utils/decodeArbitraryValue" ;
1413
1514export type State = {
1615 important : boolean
@@ -36,8 +35,8 @@ export type Error = {
3635 message : string
3736}
3837
39- export const parse = ( input : string , config ?: Config ) : AST | Error => {
40- if ( ! input ) {
38+ export const parse = ( input : string , config ?: any ) : AST | Error => {
39+ if ( ! input ) {
4140 return {
4241 root : "" ,
4342 kind : "error" ,
@@ -56,7 +55,7 @@ export const parse = (input: string, config?: Config): AST | Error => {
5655 let parsedCandidateVariants : Variant [ ] = [ ]
5756
5857 for ( let i = variants . length - 1 ; i >= 0 ; -- i ) {
59- let parsedVariant = parseVariant ( variants [ i ] , theme . screens as ScreensConfig )
58+ let parsedVariant = parseVariant ( variants [ i ] , theme . screens as any )
6059 if ( parsedVariant !== null )
6160 parsedCandidateVariants . push ( parsedVariant )
6261 }
@@ -112,23 +111,23 @@ export const parse = (input: string, config?: Config): AST | Error => {
112111
113112 if ( valueWithoutModifier && valueWithoutModifier [ 0 ] === '[' && valueWithoutModifier [ valueWithoutModifier . length - 1 ] === ']' ) {
114113 let arbitraryValue = valueWithoutModifier . slice ( 1 , - 1 )
115- const unitType = inferDataType ( arbitraryValue , [ ...availablePlugins . values ( ) ] . map ( ( { type} ) => type ) )
114+ const unitType = inferDataType ( arbitraryValue , [ ...availablePlugins . values ( ) ] . map ( ( { type } ) => type ) )
116115 let associatedPluginByType = availablePlugins ! . find ( plugin => plugin . type === unitType )
117116
118117 if ( unitType === "color" ) {
119118 const color = CalculateHexFromString ( arbitraryValue )
120- if ( ! color ) {
119+ if ( ! color ) {
121120 return {
122121 root : base ,
123122 kind : "error" ,
124123 message : "Color is not correct" ,
125124 }
126125 }
127126 valueWithoutModifier = findTailwindColorFromHex ( color . hex , theme [ associatedPluginByType ?. scaleKey || "colors" ] ) || color . hex
128- } else {
127+ } else {
129128 //It's not color, but it's still an arbitrary. We are just going to do parse it
130129 //The result might not be correct, but it's better than nothing and even tailwind will parse it anyway
131- if ( availablePlugins . length > 0 ) {
130+ if ( availablePlugins . length > 0 ) {
132131 associatedPluginByType = availablePlugins . find ( x => x . type === unitType ) || availablePlugins . find ( x => x . type !== "color" )
133132 }
134133 }
@@ -159,7 +158,7 @@ export const parse = (input: string, config?: Config): AST | Error => {
159158 }
160159
161160 //check value against each scale of available plugins
162- let matchedPlugin = availablePlugins . find ( ( { scaleKey} ) => value . split ( '-' ) [ 0 ] in theme [ scaleKey ] || valueWithoutModifier in theme [ scaleKey ] )
161+ let matchedPlugin = availablePlugins . find ( ( { scaleKey } ) => value . split ( '-' ) [ 0 ] in theme [ scaleKey ] || valueWithoutModifier in theme [ scaleKey ] )
163162 if ( ! matchedPlugin ) {
164163 return {
165164 root : base ,
0 commit comments