Skip to content

refactor: consolidate the duplicated visual-paint heuristics on the SDK's styleInk #3079

Description

@hblee12294

Deferred from #3070 (thread).

The repo now carries several independently-maintained "does this element visually paint" heuristics:

They already disagree: studio counts box-shadow and audio; the sdk counts the element's own text and per-pixel <img> alpha. That drift is the problem — same-looking predicates answering differently.

Direction: sdk as the shared home, studio delegating. The dependency arrow already points that way (studio → sdk), so studio can import but not the reverse.

But not as one predicate. They answer different questions — "is this element worth showing as an editable leaf" versus "is there ink at this exact point". The per-point half is meaningless for studio, and audio is meaningless for the paint query. The shared core is styleInk plus the transparent-colour parse, with each caller keeping its own policy on top.

Easiest first slice: the transparent-colour test. isTransparentColor in the sdk is a pure function with no policy in it, and it is currently duplicated three times with at least one copy that string-matches known spellings rather than reading the alpha (the bug fixed in #3070) — so the duplicates are likely wrong in the same way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions