rspace-online/backlog/tasks/task-41 - Build-dynamic-Sha...

48 lines
1.7 KiB
Markdown

---
id: TASK-41
title: Build dynamic Shape Registry to replace hardcoded switch statements
status: Done
assignee: []
created_date: '2026-02-18 20:06'
updated_date: '2026-03-14 21:56'
labels:
- infrastructure
- phase-0
- ecosystem
milestone: m-1
dependencies: []
priority: high
status_history:
- status: Done
timestamp: '2026-03-14 21:56'
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Replace the 170-line switch statement in canvas.html's `createShapeElement()` and the 100-line type-switch in community-sync.ts's `#updateShapeElement()` with a dynamic ShapeRegistry.
Create lib/shape-registry.ts with:
- ShapeRegistration interface (tagName, elementClass, defaults, category, portDescriptors, eventDescriptors)
- ShapeRegistry class with register(), createElement(), updateElement(), listAll(), getByCategory()
- Each folk-*.ts gets a static `registration` property and static `fromData()` method
This is the prerequisite for all other ecosystem features (pipes, events, groups, nesting, embedding).
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 ShapeRegistry class created with register/createElement/updateElement methods
- [ ] #2 All 30+ folk-*.ts shapes have static registration property
- [ ] #3 canvas.html switch statement replaced with registry.createElement()
- [ ] #4 community-sync.ts type-switch replaced with registry.updateElement()
- [ ] #5 All existing shapes still create and sync correctly
- [ ] #6 No regression in shape creation or remote sync
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Shape registry implemented in lib/shape-registry.ts. Switch statements in community-sync.ts removed. Registry used by ecosystem-bridge for dynamic shape loading.
<!-- SECTION:NOTES:END -->