Mirror Eve surface trees over CultMesh
This commit is contained in:
parent
c45eec6a83
commit
576f7b4fde
3 changed files with 105 additions and 2 deletions
|
|
@ -150,3 +150,7 @@ The old `nodes` array is no longer expected to carry complete UI composition.
|
|||
It is a compatibility/debug/data surface. Clients that understand `surface`
|
||||
should render the composed tree first and use `nodes` only for selection,
|
||||
state-path binding, and fallback.
|
||||
|
||||
The binary CultMesh state document mirrors this ownership: field 7 carries the
|
||||
optional `surface` tree. Older clients can stop at the node projection; current
|
||||
Eve clients should prefer `surface.root` whenever it is present.
|
||||
|
|
|
|||
|
|
@ -311,7 +311,8 @@ internal sealed class EveDashboardServer(int port, EveDashboardProviderCatalog p
|
|||
node.Health,
|
||||
node.ProviderId,
|
||||
node.Command,
|
||||
node.Endpoint)).ToArray());
|
||||
node.Endpoint)).ToArray(),
|
||||
ToCultMeshSurface(state.Surface));
|
||||
await SendBinaryFrameAsync(socket.Stream, MessagePackSerializer.Serialize(document)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
|
@ -319,6 +320,53 @@ internal sealed class EveDashboardServer(int port, EveDashboardProviderCatalog p
|
|||
await SendTextFrameAsync(socket.Stream, JsonSerializer.Serialize(state, JsonOptions)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static MimirEveDashboardSurfaceSnapshot? ToCultMeshSurface(DashboardSurface? surface)
|
||||
{
|
||||
if (surface == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new MimirEveDashboardSurfaceSnapshot(
|
||||
surface.Schema,
|
||||
surface.Id,
|
||||
surface.Title,
|
||||
ToCultMeshElement(surface.Root),
|
||||
surface.Assets
|
||||
.Select(static asset => new MimirEveDashboardSurfaceAssetSnapshot(asset.Id, asset.Kind, asset.Uri))
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
private static MimirEveDashboardUiElementSnapshot ToCultMeshElement(DashboardUiElement element)
|
||||
{
|
||||
return new MimirEveDashboardUiElementSnapshot(
|
||||
element.Id,
|
||||
element.Kind,
|
||||
element.Role,
|
||||
element.Text,
|
||||
element.AssetRef,
|
||||
element.AssetUri,
|
||||
element.BindNodeId,
|
||||
element.CommandId,
|
||||
element.Layout == null
|
||||
? null
|
||||
: new MimirEveDashboardUiLayoutSnapshot(
|
||||
element.Layout.Direction,
|
||||
element.Layout.Width,
|
||||
element.Layout.Height,
|
||||
element.Layout.Grow,
|
||||
element.Layout.Gap,
|
||||
element.Layout.Padding,
|
||||
element.Layout.Overflow),
|
||||
element.Style == null
|
||||
? null
|
||||
: new MimirEveDashboardUiStyleSnapshot(element.Style.Variant, element.Style.Tone),
|
||||
element.Metric == null
|
||||
? null
|
||||
: new MimirEveDashboardUiMetricSnapshot(element.Metric.Label, element.Metric.Value, element.Metric.Tone),
|
||||
element.Children.Select(ToCultMeshElement).ToArray());
|
||||
}
|
||||
|
||||
private async Task BroadcastStateAsync()
|
||||
{
|
||||
foreach (var (id, socket) in clients)
|
||||
|
|
|
|||
|
|
@ -129,7 +129,8 @@ public sealed record MimirEveDashboardStateDocument(
|
|||
[property: Key(3)] string UpdatedAtUtc,
|
||||
[property: Key(4)] string SelectedNodeId,
|
||||
[property: Key(5)] string LutPreset,
|
||||
[property: Key(6)] MimirEveDashboardNodeSnapshot[] Nodes);
|
||||
[property: Key(6)] MimirEveDashboardNodeSnapshot[] Nodes,
|
||||
[property: Key(7)] MimirEveDashboardSurfaceSnapshot? Surface);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardNodeSnapshot(
|
||||
|
|
@ -149,6 +150,56 @@ public sealed record MimirEveDashboardNodeSnapshot(
|
|||
[property: Key(13)] string? Command,
|
||||
[property: Key(14)] string? Endpoint);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardSurfaceSnapshot(
|
||||
[property: Key(0)] string Schema,
|
||||
[property: Key(1)] string Id,
|
||||
[property: Key(2)] string Title,
|
||||
[property: Key(3)] MimirEveDashboardUiElementSnapshot Root,
|
||||
[property: Key(4)] MimirEveDashboardSurfaceAssetSnapshot[] Assets);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardSurfaceAssetSnapshot(
|
||||
[property: Key(0)] string Id,
|
||||
[property: Key(1)] string Kind,
|
||||
[property: Key(2)] string Uri);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardUiElementSnapshot(
|
||||
[property: Key(0)] string Id,
|
||||
[property: Key(1)] string Kind,
|
||||
[property: Key(2)] string? Role,
|
||||
[property: Key(3)] string? Text,
|
||||
[property: Key(4)] string? AssetRef,
|
||||
[property: Key(5)] string? AssetUri,
|
||||
[property: Key(6)] string? BindNodeId,
|
||||
[property: Key(7)] string? CommandId,
|
||||
[property: Key(8)] MimirEveDashboardUiLayoutSnapshot? Layout,
|
||||
[property: Key(9)] MimirEveDashboardUiStyleSnapshot? Style,
|
||||
[property: Key(10)] MimirEveDashboardUiMetricSnapshot? Metric,
|
||||
[property: Key(11)] MimirEveDashboardUiElementSnapshot[] Children);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardUiLayoutSnapshot(
|
||||
[property: Key(0)] string Direction,
|
||||
[property: Key(1)] double? Width,
|
||||
[property: Key(2)] double? Height,
|
||||
[property: Key(3)] double? Grow,
|
||||
[property: Key(4)] double? Gap,
|
||||
[property: Key(5)] double? Padding,
|
||||
[property: Key(6)] string? Overflow);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardUiStyleSnapshot(
|
||||
[property: Key(0)] string Variant,
|
||||
[property: Key(1)] string? Tone);
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardUiMetricSnapshot(
|
||||
[property: Key(0)] string Label,
|
||||
[property: Key(1)] double Value,
|
||||
[property: Key(2)] string Tone);
|
||||
|
||||
[CultDocument("mimir.eve_dashboard_command", "mimir.eve_dashboard_command.v1")]
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveDashboardCommandDocument(
|
||||
|
|
|
|||
Loading…
Reference in a new issue