fix(formatting)
This commit is contained in:
parent
2a6c455464
commit
bfe1b63299
|
|
@ -332,7 +332,12 @@ function applyRawFigmaNodeFields(
|
|||
continue
|
||||
}
|
||||
// Also convert colorVar.assetRef in raw effects (e.g. shadow color variables)
|
||||
if (key === 'effects' && node.source.id && context.assetRefToVarGuid && context.assetRefToVarGuid.size > 0) {
|
||||
if (
|
||||
key === 'effects' &&
|
||||
node.source.id &&
|
||||
context.assetRefToVarGuid &&
|
||||
context.assetRefToVarGuid.size > 0
|
||||
) {
|
||||
const converted = convertColorVarAssetRefs(materialized[key], context.assetRefToVarGuid)
|
||||
;(nc as Record<string, unknown>)[key] = converted
|
||||
continue
|
||||
|
|
@ -351,10 +356,7 @@ function applyRawFigmaNodeFields(
|
|||
* reference resolvable regardless of whether key/version is present on the
|
||||
* VARIABLE NodeChange.
|
||||
*/
|
||||
function convertColorVarAssetRefs(
|
||||
paints: unknown,
|
||||
assetRefToVarGuid: Map<string, GUID>
|
||||
): unknown {
|
||||
function convertColorVarAssetRefs(paints: unknown, assetRefToVarGuid: Map<string, GUID>): unknown {
|
||||
if (!Array.isArray(paints)) return paints
|
||||
const result = paints.map((paint: Record<string, unknown>) => {
|
||||
const colorVar = paint.colorVar as Record<string, unknown> | undefined
|
||||
|
|
@ -368,9 +370,7 @@ function convertColorVarAssetRefs(
|
|||
const assetRef = alias.assetRef as { key: string; version?: string } | undefined
|
||||
if (!assetRef?.key) return paint
|
||||
// Look up by key@version first, then by key alone
|
||||
const lookupKey = assetRef.version
|
||||
? `${assetRef.key}@${assetRef.version}`
|
||||
: assetRef.key
|
||||
const lookupKey = assetRef.version ? `${assetRef.key}@${assetRef.version}` : assetRef.key
|
||||
const guid = assetRefToVarGuid.get(lookupKey) ?? assetRefToVarGuid.get(assetRef.key)
|
||||
if (!guid) return paint
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ import type { SceneGraph, SceneNode } from '#core/scene-graph'
|
|||
import type { Color, GUID, Matrix } from '#core/types'
|
||||
|
||||
import { guidToString, stringToGuid, VARIABLE_BINDING_FIELDS } from './convert'
|
||||
import { buildAssetRefToVarGuidMap, sceneNodeToKiwiWithContext, type KiwiNodeChange } from './export-node'
|
||||
import {
|
||||
buildAssetRefToVarGuidMap,
|
||||
sceneNodeToKiwiWithContext,
|
||||
type KiwiNodeChange
|
||||
} from './export-node'
|
||||
import { applyFontFeaturesToKiwi } from './font/features'
|
||||
import {
|
||||
BOUND_VARIABLES_PLUGIN_KEY,
|
||||
|
|
@ -230,10 +234,11 @@ function serializeCornerRadii(node: SceneNode, nc: KiwiNodeChange): void {
|
|||
// the raw Figma data. Figma may emit per-corner radii without setting the
|
||||
// independent flag (preserve rectangleCornerRadiiIndependent).
|
||||
const rawIndependent = node.source.id
|
||||
? ((node.source.fig.rawNodeFields as Record<string, unknown> | undefined)
|
||||
?.rectangleCornerRadiiIndependent)
|
||||
? (node.source.fig.rawNodeFields as Record<string, unknown> | undefined)
|
||||
?.rectangleCornerRadiiIndependent
|
||||
: undefined
|
||||
nc.rectangleCornerRadiiIndependent = typeof rawIndependent === 'boolean' ? rawIndependent : node.independentCorners
|
||||
nc.rectangleCornerRadiiIndependent =
|
||||
typeof rawIndependent === 'boolean' ? rawIndependent : node.independentCorners
|
||||
nc.rectangleTopLeftCornerRadius = node.topLeftRadius
|
||||
nc.rectangleTopRightCornerRadius = node.topRightRadius
|
||||
nc.rectangleBottomLeftCornerRadius = node.bottomLeftRadius
|
||||
|
|
|
|||
|
|
@ -222,7 +222,17 @@ function compareSceneProps(
|
|||
): void {
|
||||
const errors: Mismatch[] = []
|
||||
const generation = label.startsWith('G1') ? 1 : 0
|
||||
const opts: CompareOptions = { aNodes, bNodes, aGraph, bGraph, errors, fixture, verifiers, label, generation }
|
||||
const opts: CompareOptions = {
|
||||
aNodes,
|
||||
bNodes,
|
||||
aGraph,
|
||||
bGraph,
|
||||
errors,
|
||||
fixture,
|
||||
verifiers,
|
||||
label,
|
||||
generation
|
||||
}
|
||||
|
||||
for (const [p, aNode] of aNodes) {
|
||||
const bNode = bNodes.get(p)
|
||||
|
|
@ -564,9 +574,13 @@ function verifyFixture(spec: FixtureSpec): void {
|
|||
compareRawNodeFields(spec, g1Graph, g2Graph, g1, g2, 'G1->G2')
|
||||
})
|
||||
|
||||
test.todo('BUG: corner radius 999 sentinel lost for non-pill nodes on scene import (40 nodes, raw data preserved)')
|
||||
test.todo(
|
||||
'BUG: corner radius 999 sentinel lost for non-pill nodes on scene import (40 nodes, raw data preserved)'
|
||||
)
|
||||
test.todo('BUG: componentPropDefs verifier rejects 9 instances (verifier logic gap)')
|
||||
test.todo('BUG: derivedTextData baseline precision differs from raw (14 instances, font metrics)')
|
||||
test.todo(
|
||||
'BUG: derivedTextData baseline precision differs from raw (14 instances, font metrics)'
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,13 +65,9 @@ function verifyFontDigest(
|
|||
): void {
|
||||
if (amDigest && bmDigest) {
|
||||
const amHex =
|
||||
typeof amDigest === 'string'
|
||||
? amDigest
|
||||
: Buffer.from(amDigest as Uint8Array).toString('hex')
|
||||
typeof amDigest === 'string' ? amDigest : Buffer.from(amDigest as Uint8Array).toString('hex')
|
||||
const bmHex =
|
||||
typeof bmDigest === 'string'
|
||||
? bmDigest
|
||||
: Buffer.from(bmDigest as Uint8Array).toString('hex')
|
||||
typeof bmDigest === 'string' ? bmDigest : Buffer.from(bmDigest as Uint8Array).toString('hex')
|
||||
if (amHex !== bmHex) {
|
||||
ctx.errors.push({
|
||||
path: ctx.path,
|
||||
|
|
@ -82,12 +78,7 @@ function verifyFontDigest(
|
|||
}
|
||||
}
|
||||
|
||||
function verifyFontLineHeight(
|
||||
amLH: unknown,
|
||||
bmLH: unknown,
|
||||
i: number,
|
||||
ctx: VerifierContext
|
||||
): void {
|
||||
function verifyFontLineHeight(amLH: unknown, bmLH: unknown, i: number, ctx: VerifierContext): void {
|
||||
const amLineHeight = typeof amLH === 'number' ? amLH : 1.2
|
||||
const bmLineHeight = typeof bmLH === 'number' ? bmLH : 1.2
|
||||
if (bmLineHeight !== 1.2 && Math.abs(amLineHeight - bmLineHeight) > 0.05) {
|
||||
|
|
@ -277,8 +268,7 @@ function verifyAEntries(
|
|||
const found = bEntries.find((entryB) => {
|
||||
const aliasB = entryB.variableData?.value?.alias
|
||||
return (
|
||||
aliasB?.assetRef &&
|
||||
JSON.stringify(aliasB.assetRef) === JSON.stringify(aliasA.assetRef)
|
||||
aliasB?.assetRef && JSON.stringify(aliasB.assetRef) === JSON.stringify(aliasA.assetRef)
|
||||
)
|
||||
})
|
||||
if (found && found.variableField !== entryA.variableField) {
|
||||
|
|
@ -351,8 +341,12 @@ function verifyVarAlias(a: unknown, b: unknown): boolean {
|
|||
const bVal = b as Record<string, unknown> | undefined
|
||||
if (!aVal && !bVal) return true
|
||||
if (!aVal || !bVal) return false
|
||||
const aAlias = (aVal.value as Record<string, unknown>)?.alias as Record<string, unknown> | undefined
|
||||
const bAlias = (bVal.value as Record<string, unknown>)?.alias as Record<string, unknown> | undefined
|
||||
const aAlias = (aVal.value as Record<string, unknown>)?.alias as
|
||||
| Record<string, unknown>
|
||||
| undefined
|
||||
const bAlias = (bVal.value as Record<string, unknown>)?.alias as
|
||||
| Record<string, unknown>
|
||||
| undefined
|
||||
const aGuid = aAlias?.guid
|
||||
const bGuid = bAlias?.guid
|
||||
const aRef = aAlias?.assetRef
|
||||
|
|
@ -555,10 +549,13 @@ export const RAW_VERIFIERS = new Map<string, Verifier>([
|
|||
return ctx.b === '' || ctx.a === ctx.b
|
||||
}
|
||||
],
|
||||
['postscript', (ctx) => {
|
||||
if (isIdempotent(ctx)) return JSON.stringify(ctx.a) === JSON.stringify(ctx.b)
|
||||
return ctx.b === '' || ctx.a === ctx.b
|
||||
}],
|
||||
[
|
||||
'postscript',
|
||||
(ctx) => {
|
||||
if (isIdempotent(ctx)) return JSON.stringify(ctx.a) === JSON.stringify(ctx.b)
|
||||
return ctx.b === '' || ctx.a === ctx.b
|
||||
}
|
||||
],
|
||||
['textExplicitLayoutVersion', defaultEqual(1)],
|
||||
[
|
||||
'textUserLayoutVersion',
|
||||
|
|
@ -586,8 +583,11 @@ export const RAW_VERIFIERS = new Map<string, Verifier>([
|
|||
return verifyVarAlias(ctx.a, ctx.b)
|
||||
}
|
||||
],
|
||||
['opacityVar', (ctx) => {
|
||||
if (isIdempotent(ctx)) return JSON.stringify(ctx.a) === JSON.stringify(ctx.b)
|
||||
return verifyVarAlias(ctx.a, ctx.b)
|
||||
}]
|
||||
[
|
||||
'opacityVar',
|
||||
(ctx) => {
|
||||
if (isIdempotent(ctx)) return JSON.stringify(ctx.a) === JSON.stringify(ctx.b)
|
||||
return verifyVarAlias(ctx.a, ctx.b)
|
||||
}
|
||||
]
|
||||
])
|
||||
|
|
|
|||
Loading…
Reference in a new issue