Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
design_variants.hpp
Go to the documentation of this file.
1#pragma once
2
3// pulp::design — variant sets -> typed parameterized component contract.
4//
5// A design-tool component set (a Figma variant set, or the equivalent in a
6// decoded `.fig`) names each member with a `Prop=Value` string, e.g.
7// "Size=Large, State=Hover". Imported naively that is N frozen frames. This
8// translation unit collapses the set into one *typed* component contract: each
9// property with its observed value enum and a chosen default. That contract is
10// the supply side R1's manifest and R2's adherence lint consume — a widget the
11// importer can bind to by prop, instead of a wall of one-off frames.
12//
13// It is pure and deterministic: it takes the variant *names* (which both intake
14// lanes already produce) and computes the prop model. Resolving per-variant
15// style deltas from instance overrides needs the decoded node geometry and is
16// deliberately out of scope here — this layer models well-formed variant sets
17// first and emits named issues for anything it could not cleanly collapse, so a
18// downstream fidelity ledger (design_fidelity_ledger) can report what was baked.
19
20#include <string>
21#include <string_view>
22#include <vector>
23
24namespace pulp::design {
25
27inline constexpr std::string_view kVariantContractVersion = "2026.07-variant-contract-v1";
28
31 std::string name;
32 std::string value;
33};
34
38std::vector<VariantProperty> parse_variant_name(std::string_view name);
39
43 std::string name;
44 std::vector<std::string> values;
45 std::string default_value;
46};
47
54 std::string kind;
55 std::string detail;
56};
57
60 std::string format_version;
61 std::string component;
62 std::vector<ContractProp> props;
64 std::vector<VariantIssue> issues;
65};
66
73 const std::vector<std::string>& variant_names);
74
76std::string component_contract_json(const ComponentContract& contract);
77
78} // namespace pulp::design
Definition design_adherence.hpp:32
std::string component_contract_json(const ComponentContract &contract)
Serialize a contract to deterministic JSON (feeds R1's manifest / R2's lint).
std::vector< VariantProperty > parse_variant_name(std::string_view name)
Parse a component-set variant name ("Size=Large, State=Hover") into ordered properties.
constexpr std::string_view kVariantContractVersion
Format id stamped into the contract; bump on a non-additive shape change.
Definition design_variants.hpp:27
ComponentContract build_component_contract(std::string_view component, const std::vector< std::string > &variant_names)
Build a contract from a component-set name and its member variant names.
The typed component contract synthesized from a variant set.
Definition design_variants.hpp:59
std::string component
the component-set name
Definition design_variants.hpp:61
std::string format_version
kVariantContractVersion
Definition design_variants.hpp:60
std::vector< ContractProp > props
sorted by property name
Definition design_variants.hpp:62
std::vector< VariantIssue > issues
in a stable (kind, detail) order
Definition design_variants.hpp:64
int variant_count
Definition design_variants.hpp:63
One property in the synthesized contract: its name, the sorted-unique value set observed across the s...
Definition design_variants.hpp:42
std::string default_value
see default rules on build_component_contract
Definition design_variants.hpp:45
std::vector< std::string > values
sorted, unique
Definition design_variants.hpp:44
std::string name
Definition design_variants.hpp:43
A named issue about a variant set that could not be cleanly collapsed.
Definition design_variants.hpp:53
std::string kind
Definition design_variants.hpp:54
std::string detail
Definition design_variants.hpp:55
One property parsed from a variant name: "Size=Large" -> {"Size","Large"}.
Definition design_variants.hpp:30
std::string value
Definition design_variants.hpp:32
std::string name
Definition design_variants.hpp:31