@@ -146,27 +146,25 @@ async function computeSelectorProps(node: ComponentSetNode): Promise<{
146146
147147 const defaultProps = await getProps ( node . defaultVariant )
148148
149- const result = Object . entries ( node . componentPropertyDefinitions ) . reduce (
150- ( acc , [ name , definition ] ) => {
151- if ( name === 'effect' || name === 'viewport' ) return acc
152-
153- const sanitizedName = sanitizePropertyName ( name )
154- if ( definition . type === 'VARIANT' && definition . variantOptions ) {
155- acc . variants [ sanitizedName ] = definition . variantOptions
156- . map ( ( option ) => `'${ option } '` )
157- . join ( ' | ' )
158- } else if ( definition . type === 'INSTANCE_SWAP' ) {
159- acc . variants [ sanitizedName ] = 'React.ReactNode'
160- } else if ( definition . type === 'BOOLEAN' ) {
161- acc . variants [ sanitizedName ] = 'boolean'
162- }
163- return acc
164- } ,
165- {
166- props : { } as Record < string , object | string > ,
167- variants : { } as Record < string , string > ,
168- } ,
169- )
149+ const result : {
150+ props : Record < string , object | string >
151+ variants : Record < string , string >
152+ } = { props : { } , variants : { } }
153+ const defs = node . componentPropertyDefinitions
154+ for ( const name in defs ) {
155+ if ( name === 'effect' || name === 'viewport' ) continue
156+ const definition = defs [ name ]
157+ const sanitizedName = sanitizePropertyName ( name )
158+ if ( definition . type === 'VARIANT' && definition . variantOptions ) {
159+ result . variants [ sanitizedName ] = definition . variantOptions
160+ . map ( ( option ) => `'${ option } '` )
161+ . join ( ' | ' )
162+ } else if ( definition . type === 'INSTANCE_SWAP' ) {
163+ result . variants [ sanitizedName ] = 'React.ReactNode'
164+ } else if ( definition . type === 'BOOLEAN' ) {
165+ result . variants [ sanitizedName ] = 'boolean'
166+ }
167+ }
170168
171169 if ( components . length > 0 ) {
172170 const findNodeAction = ( action : Action ) => action . type === 'NODE'
@@ -213,10 +211,12 @@ export async function getSelectorPropsForGroup(
213211
214212 // Build cache key from componentSet.id + filter + viewport
215213 const setId = componentSet . id
216- const filterKey = Object . entries ( variantFilter )
217- . sort ( ( [ a ] , [ b ] ) => a . localeCompare ( b ) )
218- . map ( ( [ k , v ] ) => `${ k } =${ v } ` )
219- . join ( '|' )
214+ const filterParts : string [ ] = [ ]
215+ for ( const k in variantFilter ) {
216+ filterParts . push ( `${ k } =${ variantFilter [ k ] } ` )
217+ }
218+ filterParts . sort ( )
219+ const filterKey = filterParts . join ( '|' )
220220 const cacheKey = setId ? `${ setId } ::${ filterKey } ::${ viewportValue ?? '' } ` : ''
221221
222222 if ( cacheKey ) {
@@ -252,8 +252,8 @@ async function computeSelectorPropsForGroup(
252252 const variantProps = child . variantProperties || { }
253253
254254 // Check all filter conditions match
255- for ( const [ key , value ] of Object . entries ( variantFilter ) ) {
256- if ( variantProps [ key ] !== value ) return false
255+ for ( const key in variantFilter ) {
256+ if ( variantProps [ key ] !== variantFilter [ key ] ) return false
257257 }
258258
259259 // Check viewport if specified
@@ -335,13 +335,12 @@ function triggerTypeToEffect(triggerType: Trigger['type'] | undefined) {
335335}
336336
337337function difference ( a : Record < string , unknown > , b : Record < string , unknown > ) {
338- return Object . entries ( a ) . reduce (
339- ( acc , [ key , value ] ) => {
340- if ( value !== undefined && b [ key ] !== value ) {
341- acc [ key ] = value
342- }
343- return acc
344- } ,
345- { } as Record < string , unknown > ,
346- )
338+ const result : Record < string , unknown > = { }
339+ for ( const key in a ) {
340+ const value = a [ key ]
341+ if ( value !== undefined && b [ key ] !== value ) {
342+ result [ key ] = value
343+ }
344+ }
345+ return result
347346}
0 commit comments