register method
Register port. Throws if the id is already taken or a prefix
collides with another registered runtime.
Implementation
void register(UiRuntimePort port) {
if (_byId.containsKey(port.id)) {
throw StateError('runtime already registered: ${port.id}');
}
for (final prefix in port.supportedPrefixes) {
final existing = _prefixToId[prefix];
if (existing != null) {
throw StateError(
'prefix collision $existing ↔ ${port.id}: $prefix',
);
}
}
_byId[port.id] = port;
for (final prefix in port.supportedPrefixes) {
_prefixToId[prefix] = port.id;
}
}