Skip to content

Commit 7de2d95

Browse files
committed
Optimize
1 parent 083bc2a commit 7de2d95

File tree

3 files changed

+31
-45
lines changed

3 files changed

+31
-45
lines changed

src/codegen/props/effect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { optimizeHex } from '../../utils/optimize-hex'
22
import { rgbaToHex } from '../../utils/rgba-to-hex'
33
import { addPx } from '../utils/add-px'
44

5-
export async function getEffectProps(
5+
export function getEffectProps(
66
node: SceneNode,
7-
): Promise<Record<string, string> | undefined> {
7+
): Record<string, string> | undefined {
88
if ('effects' in node && node.effects.length > 0) {
99
return node.effects.reduce(
1010
(acc, effect) => {

src/codegen/props/index.ts

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,8 @@ export async function getProps(
5454
const borderP = getBorderProps(node)
5555
const tBg = perfStart()
5656
const bgP = getBackgroundProps(node)
57-
const tEffect = perfStart()
58-
const effectP = getEffectProps(node)
5957
const tTextStroke = perfStart()
6058
const textStrokeP = isText ? getTextStrokeProps(node) : undefined
61-
const tTextShadow = perfStart()
62-
const textShadowP = isText ? getTextShadowProps(node) : undefined
6359
const tReaction = perfStart()
6460
const reactionP = getReactionProps(node)
6561

@@ -78,52 +74,42 @@ export async function getProps(
7874
const objectFitProps = getObjectFitProps(node)
7975
const maxLineProps = isText ? getMaxLineProps(node) : undefined
8076
const ellipsisProps = isText ? getEllipsisProps(node) : undefined
77+
const tEffect = perfStart()
78+
const effectProps = getEffectProps(node)
79+
perfEnd('getProps.effect', tEffect)
8180
const positionProps = getPositionProps(node)
8281
const gridChildProps = getGridChildProps(node)
8382
const transformProps = getTransformProps(node)
8483
const overflowProps = getOverflowProps(node)
84+
const tTextShadow = perfStart()
85+
const textShadowProps = isText ? getTextShadowProps(node) : undefined
86+
perfEnd('getProps.textShadow', tTextShadow)
8587
const cursorProps = getCursorProps(node)
8688
const visibilityProps = getVisibilityProps(node)
8789
perfEnd('getProps.sync', tSync)
8890

8991
// PHASE 3: Await async results — likely already resolved during sync phase.
90-
const [
91-
borderProps,
92-
backgroundProps,
93-
effectProps,
94-
textStrokeProps,
95-
textShadowProps,
96-
reactionProps,
97-
] = await Promise.all([
98-
borderP.then((r) => {
99-
perfEnd('getProps.border', tBorder)
100-
return r
101-
}),
102-
bgP.then((r) => {
103-
perfEnd('getProps.background', tBg)
104-
return r
105-
}),
106-
effectP.then((r) => {
107-
perfEnd('getProps.effect', tEffect)
108-
return r
109-
}),
110-
textStrokeP
111-
? textStrokeP.then((r) => {
112-
perfEnd('getProps.textStroke', tTextStroke)
113-
return r
114-
})
115-
: undefined,
116-
textShadowP
117-
? textShadowP.then((r) => {
118-
perfEnd('getProps.textShadow', tTextShadow)
119-
return r
120-
})
121-
: undefined,
122-
reactionP.then((r) => {
123-
perfEnd('getProps.reaction', tReaction)
124-
return r
125-
}),
126-
])
92+
const [borderProps, backgroundProps, textStrokeProps, reactionProps] =
93+
await Promise.all([
94+
borderP.then((r) => {
95+
perfEnd('getProps.border', tBorder)
96+
return r
97+
}),
98+
bgP.then((r) => {
99+
perfEnd('getProps.background', tBg)
100+
return r
101+
}),
102+
textStrokeP
103+
? textStrokeP.then((r) => {
104+
perfEnd('getProps.textStroke', tTextStroke)
105+
return r
106+
})
107+
: undefined,
108+
reactionP.then((r) => {
109+
perfEnd('getProps.reaction', tReaction)
110+
return r
111+
}),
112+
])
127113

128114
// PHASE 4: Merge in the ORIGINAL interleaved order to preserve last-key-wins.
129115
// async results (border, background, effect, textStroke, textShadow, reaction)

src/codegen/props/text-shadow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { optimizeHex } from '../../utils/optimize-hex'
22
import { rgbaToHex } from '../../utils/rgba-to-hex'
33
import { addPx } from '../utils/add-px'
44

5-
export async function getTextShadowProps(
5+
export function getTextShadowProps(
66
node: SceneNode,
7-
): Promise<Record<string, string> | undefined> {
7+
): Record<string, string> | undefined {
88
if (node.type !== 'TEXT') return
99

1010
const effects = node.effects.filter((effect) => effect.visible)

0 commit comments

Comments
 (0)