figma-transformer: decode hyperlinks and reaction URL/navigation links#336
Merged
Conversation
The normalizer's normalizeHyperlinkValue()/normalizeReactionLink() and the emitter's <a class="figma-link"> wrapping already existed, but `hyperlink` and the prototype-interaction list were absent from the selective Kiwi decoder's field policy, so links carried in .fig files were silently skipped at gate 1 (coverage issue #328). Buttons and linked text therefore never became anchors. Decode the link surface and bridge the REST-vs-Kiwi shape gaps: - FigKiwiDecoder: whitelist `hyperlink`, `prototypeInteractions`, `reactions`, and `transitionNodeID` on NodeChange, plus the supporting `Hyperlink`, `PrototypeInteraction`, `PrototypeEvent`, and `PrototypeAction` struct policies needed for the URL/navigation fields to reach the IR. - ScenegraphNormalizer: the Kiwi schema names differ from REST. Read the Kiwi `Hyperlink.guid` as a node target, iterate `prototypeInteractions` alongside `reactions`, and map `PrototypeAction.connectionType`/`connectionURL`/ `navigationType`/`transitionNodeID` (GUID) onto the existing action-link path. Scope is link extraction only: URL links and node navigation (mapped to the target frame's page_path, else a `#` placeholder + diagnostic). The richer prototype payload PrototypeAction also carries (transition animations, overlay and swap behavior, variable mutations) is intentionally left undecoded; full prototype-fidelity is a separate, larger effort. Tests (tests/contract/run.php): assert a Kiwi-shaped `hyperlink` URL and an ON_CLICK `prototypeInteractions` URL action each emit a real <a href> anchor, plus a binary-Kiwi decode fixture proving the new field policy carries the hyperlink URL, connection type/URL, trigger, and GUID destination through the real generic decoder.
31af0c4 to
9070340
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires Figma hyperlinks and prototype navigation through the figma-transformer. Per coverage issue #328, the normalizer's
normalizeReactionLink()/normalizeHyperlinkValue()and the emitter's<a class="figma-link">wrapping already existed, buthyperlinkand the prototype-interaction list were not in the selective Kiwi decoder's field policy, so links carried in.figfiles were silently skipped at gate 1. Buttons and linked text therefore never became real anchors.What changed
FigKiwiDecoder.php— whitelisthyperlink,prototypeInteractions,reactions, andtransitionNodeIDonNodeChange, plus the supportingHyperlink,PrototypeInteraction,PrototypeEvent, andPrototypeActionstruct policies needed for the URL/navigation fields to decode. Kiwi names/enum tokens were verified by decoding a real.figschema chunk (the schema embedsHyperlink {url, guid},PrototypeInteraction {event, actions},PrototypeAction {transitionNodeID, connectionType, connectionURL, navigationType},ConnectionType {NONE, INTERNAL_NODE, URL, ...},NavigationType {NAVIGATE, OVERLAY, SWAP, SCROLL_TO}).ScenegraphNormalizer.php— the decoded Kiwi shape differs from the REST shape the normalizer was written for, so bridge the gaps without changing behavior:Hyperlink.guidas a node target (the struct has no RESTtypefield);prototypeInteractionsalongsidereactions(same list, different name);PrototypeAction.connectionType(URL/INTERNAL_NODE),connectionURL,navigationType, and thetransitionNodeIDGUID onto the existing action-link extraction.wrapWithLink()already wraps in<a href>, resolving node navigation to the target frame'spage_path(or a#placeholder +link_target_unresolveddiagnostic).Scope boundary (prototype animation)
This is about links — URL and node navigation — not full prototype fidelity.
PrototypeActionalso carries transition animations, overlay/swap behavior, and variable mutations; those fields are intentionally left undecoded. Full prototype-animation/overlay/swap support is a separate, larger effort.Tests (real output)
Added to
tests/contract/run.phpand passing (php tests/contract/run.php):hyperlinkURL node emits<a class="figma-link" href="https://..." data-figma-link-type="url">;ON_CLICKprototypeInteractionsentry with a URL action emits the same anchor wrapper;Refs #328.
AI assistance