feat: add native runtime settings

This commit is contained in:
2026-07-21 12:07:18 +09:00
parent b6208c0971
commit fc4007d676
25 changed files with 3543 additions and 63 deletions

View File

@@ -633,7 +633,8 @@ public static class LegacyBridgeProtocol
payload,
static () => new LegacyImportManualListsIntent()),
"dismiss-dialog" => ParseDismiss(payload),
_ => LegacyPlayoutUiIntentParser.Parse(type, payload)
_ => LegacyOperatorSettingsUiIntentParser.Parse(type, payload) ??
LegacyPlayoutUiIntentParser.Parse(type, payload)
};
if (intent is null)
@@ -655,7 +656,8 @@ public static class LegacyBridgeProtocol
LegacyOperatorSnapshot snapshot,
bool isBusy = false,
LegacyOperatorPlayoutSnapshot? playout = null,
LegacyInteractionMetrics? interactionMetrics = null)
LegacyInteractionMetrics? interactionMetrics = null,
LegacyOperatorSettingsSnapshot? operatorSettings = null)
{
ArgumentNullException.ThrowIfNull(snapshot);
var normalizedInteractionMetrics = LegacyInteractionMetrics.Normalize(
@@ -1160,6 +1162,39 @@ public static class LegacyBridgeProtocol
hostRasterizationScale =
normalizedInteractionMetrics.HostRasterizationScale
},
operatorSettings = operatorSettings is null ? null : new
{
operatorSettings.Revision,
design = new
{
operatorSettings.Design.DisplayName,
operatorSettings.Design.IsCustom,
operatorSettings.Design.IsValid,
operatorSettings.Design.Status
},
resource = new
{
operatorSettings.Resource.DisplayName,
operatorSettings.Resource.IsCustom,
operatorSettings.Resource.IsValid,
operatorSettings.Resource.Status
},
background = new
{
operatorSettings.Background.DisplayName,
operatorSettings.Background.IsCustom,
operatorSettings.Background.IsValid,
operatorSettings.Background.Status
},
operatorSettings.NavigationExpanded,
operatorSettings.RestartRequired,
operatorSettings.Message,
operatorSettings.MessageKind,
operatorSettings.AppVersion,
operatorSettings.OracleState,
operatorSettings.MariaState,
operatorSettings.DatabasePollingSeconds
},
isBusy
};

View File

@@ -0,0 +1,117 @@
using System.Text.Json;
namespace MBN_STOCK_WEBVIEW.LegacyBridge;
public enum LegacyOperatorFolderKind
{
Design,
Resource,
Background
}
public enum LegacyOperatorSettingsMessageKind
{
Neutral,
Information,
Success,
Warning,
Error
}
public sealed record LegacyChooseOperatorFolderIntent(LegacyOperatorFolderKind Kind)
: LegacyUiIntent;
public sealed record LegacyResetOperatorFolderIntent(LegacyOperatorFolderKind Kind)
: LegacyUiIntent;
public sealed record LegacySetOperatorNavigationExpandedIntent(bool Expanded)
: LegacyUiIntent;
public sealed record LegacyOperatorFolderSnapshot(
string DisplayName,
bool IsCustom,
bool IsValid,
string Status);
public sealed record LegacyOperatorSettingsSnapshot(
long Revision,
LegacyOperatorFolderSnapshot Design,
LegacyOperatorFolderSnapshot Resource,
LegacyOperatorFolderSnapshot Background,
bool NavigationExpanded,
bool RestartRequired,
string Message,
LegacyOperatorSettingsMessageKind MessageKind,
string AppVersion,
string OracleState,
string MariaState,
int DatabasePollingSeconds);
internal static class LegacyOperatorSettingsUiIntentParser
{
public static LegacyUiIntent? Parse(string type, JsonElement payload) => type switch
{
"choose-operator-folder" => ParseFolder(
payload,
static kind => new LegacyChooseOperatorFolderIntent(kind)),
"reset-operator-folder" => ParseFolder(
payload,
static kind => new LegacyResetOperatorFolderIntent(kind)),
"set-operator-navigation-expanded" => ParseNavigationExpanded(payload),
_ => null
};
private static LegacyUiIntent? ParseFolder(
JsonElement payload,
Func<LegacyOperatorFolderKind, LegacyUiIntent> factory)
{
if (!HasExactSingleProperty(payload, "kind", out var kindElement) ||
kindElement.ValueKind != JsonValueKind.String)
{
return null;
}
var kind = kindElement.GetString() switch
{
"design" => LegacyOperatorFolderKind.Design,
"resource" => LegacyOperatorFolderKind.Resource,
"background" => LegacyOperatorFolderKind.Background,
_ => (LegacyOperatorFolderKind?)null
};
return kind.HasValue ? factory(kind.Value) : null;
}
private static LegacyUiIntent? ParseNavigationExpanded(JsonElement payload)
{
if (!HasExactSingleProperty(payload, "expanded", out var expandedElement) ||
expandedElement.ValueKind is not (JsonValueKind.True or JsonValueKind.False))
{
return null;
}
return new LegacySetOperatorNavigationExpandedIntent(expandedElement.GetBoolean());
}
private static bool HasExactSingleProperty(
JsonElement payload,
string propertyName,
out JsonElement propertyValue)
{
propertyValue = default;
if (payload.ValueKind != JsonValueKind.Object)
{
return false;
}
using var enumerator = payload.EnumerateObject();
if (!enumerator.MoveNext() ||
!string.Equals(enumerator.Current.Name, propertyName, StringComparison.Ordinal))
{
return false;
}
propertyValue = enumerator.Current.Value;
return !enumerator.MoveNext();
}
}