1414 * limitations under the License.
1515 */
1616
17+ import { PROPERTY_LIST , PROPERTY_VARIANTS } from "./list" ;
18+
1719export type UserSettings = {
1820 enabled : boolean ,
1921 generate : boolean ,
@@ -26,7 +28,8 @@ export type UserSettings = {
2628 states : string [ ] ,
2729 scopes : string [ ] ,
2830 xStyleAttribute : string ,
29- selectorAttribute : string
31+ selectorAttribute : string ,
32+ registeredProperties : { name : string , aliases : string [ ] } [ ] ,
3033} ;
3134type StyleType = string | { [ key : string ] : string } ;
3235const regex = / ( [ a - z 0 - 9 ] | (? = [ A - Z ] ) ) ( [ A - Z ] ) / g;
@@ -44,6 +47,7 @@ export function getUserSettings(dataset: {[key: string]: string}): UserSettings
4447 const cache = dataset . cache === undefined ? null : dataset . cache ;
4548 const cacheKey = dataset . cacheKey === undefined ? "assembler-css-cache" : dataset . cacheKey ;
4649 const dataScopes = dataset . scopes === undefined ? [ ] : getStringItemList ( dataset . scopes ) ;
50+ const registeredProperties = dataset . registerProperties === undefined ? [ ] : getRegisteredProperties ( dataset . registerProperties ) ;
4751 const scopes = [ "" , "text-clip" , "selection" , "placeholder" , "before" , "after" , "first-letter" , "first-line" ,
4852 "l1" , "l2" , "marker-l1" , "marker" , "sibling" , "child" , "even" , "odd" , "first" , "last" , "dark" , "light" ,
4953 "landscape" , "portrait" , "motion-reduce" , "motion-safe" ] ;
@@ -55,6 +59,16 @@ export function getUserSettings(dataset: {[key: string]: string}): UserSettings
5559 }
5660 }
5761
62+ for ( let i = 0 , l = registeredProperties . length ; i < l ; i ++ ) {
63+ const prop = registeredProperties [ i ] ;
64+ if ( PROPERTY_LIST . indexOf ( prop . name ) === - 1 ) {
65+ PROPERTY_LIST . push ( prop . name ) ;
66+ if ( prop . aliases . length > 0 ) {
67+ PROPERTY_VARIANTS [ prop . name ] = prop . aliases ;
68+ }
69+ }
70+ }
71+
5872 // Consider all bp
5973 let breakpoints = [ 'xs' , 'sm' , 'md' , 'lg' , 'xl' ] ;
6074
@@ -99,6 +113,7 @@ export function getUserSettings(dataset: {[key: string]: string}): UserSettings
99113 media : { xs, sm, md, lg, xl} ,
100114 xStyleAttribute,
101115 selectorAttribute,
116+ registeredProperties
102117 } ;
103118}
104119
@@ -135,6 +150,23 @@ function getStringItemList(value: string, unique: boolean = true): string[] {
135150 return unique ? items . filter ( uniqueItems ) : items ;
136151}
137152
153+ function getRegisteredProperties ( value : string ) : { name : string , aliases :string [ ] } [ ] {
154+ return value
155+ . split ( ';' )
156+ . map ( v => v . trim ( ) )
157+ . filter ( v => v !== '' )
158+ . map ( v => {
159+ const index = v . indexOf ( ':' ) ;
160+ if ( index < 0 ) {
161+ return { name : v , aliases : [ ] } ;
162+ }
163+ return {
164+ name : v . substr ( 0 , index ) ,
165+ aliases : v . substr ( index + 1 ) . split ( ',' ) . map ( v => v . trim ( ) ) . filter ( v => v !== '' )
166+ }
167+ } ) ;
168+ }
169+
138170export function trim ( value : string ) : string {
139171 return value . trim ( ) ;
140172}
0 commit comments