ID:WORK-114Status:readyPriority:mediumComplexity:complexMilestone:v1.0.0
Implement element projection (hide, group, relocate)
Add a projection field to RuneConfig that enables declarative structural reshaping of the output tree. Projection runs as a distinct pass after BEM class application but before meta tag filtering, operating on data-name addresses. This is SPEC-033's most powerful feature, giving themes control over schema-produced elements.
Acceptance Criteria
RuneConfiginpackages/transform/src/types.tshasprojection?: { relocate?, group?, hide? }with the interfaces from SPEC-033- The engine implements a projection pass between Phase 6 (recursion/BEM) and Phase 7 (meta filtering)
- Hide: elements matching
hideentries are removed from the children array entirely - Group: elements matching
membersare collected, removed from current positions, wrapped in a new container withdata-nameset to the group key, and placed at the first collected member's position (or into a named slot) - Relocate: elements found by
data-nameare moved into the target (anotherdata-nameelement or a slot name) at the specified position (prepend/append) - Execution order is hide → group → relocate (so groups can be relocation targets)
- Group wrappers get BEM element classes via normal
applyBemClassesflow mergeThemeConfighandlesprojection(theme projection fully replaces base, not deep-merged)- Unit tests cover: hide removes element, group collects and wraps, relocate moves into target, relocate into slot, combined hide+group+relocate, invalid data-name references are no-ops
- TypeScript compiles cleanly
- All existing tests pass
Approach
- Add
projectioninterfaces to types - Implement the projection pass as a separate function in the engine, called between Phase 6 and Phase 7
- Each sub-pass (hide, group, relocate) walks the children array and applies its transformation
- For
relocatetargeting slots, integrate with the slot assembly from WORK-112 - Update merge logic
- Write comprehensive tests for each operation and their composition
References
- SPEC-033 (Feature 5 — Element Projection)
- WORK-112 (slots — projection relocate can target slot names)
Relationships
Related
- SPEC-033acceptedspecStructure Slots and Declarative Flexibility
- WORK-112readyworkImplement named slots with ordering for structure entries
- WORK-116readyworkUpdate inspect and contracts tooling for structure slots features
- WORK-115readyworkMigrate community package postTransform uses to declarative config