Reframe Unity plugins as projection adapters

This commit is contained in:
Meta Vens 2026-07-09 00:48:40 +01:00
commit 4712f7c7f8
22 changed files with 274 additions and 86 deletions

View file

@ -7,14 +7,15 @@ It owns native projection only. Providers still own truth, accepted state,
style token values, and command effects through CultMesh/CultNet. Unknown
component kinds degrade to inert containers instead of gaining local semantics.
Plugin semantics enter through runtime plugin hosts. The package includes a
first-party `sai.vn` host proof for `vn.stage`, dialogue panels, action rails,
and story command projection. Sai still owns story state and command semantics;
Unity only owns native projection and emits `gamecult.eve.command.v1` requests.
The package also includes a `norn.graph` host proof for `embed.norn`; Norn still
owns graph layout and graph semantics, while Unity owns the embedded graph shell
and command emission. `tex.math` still passes through as generic Eve component
structure until it gains an explicit Unity plugin host.
Plugin semantics enter through plugin ABI sidecars and advertisements, not
through Unity. This package includes first-party projection adapters for the
`sai.vn` projection surface (`vn.stage`, dialogue panels, action rails, and
story command requests) and the `norn.graph` projection surface (`embed.norn`).
Sai still owns story state and command semantics. Norn still owns graph layout
and graph semantics. Unity only owns native projection of already-declared
plugin capabilities and emits `gamecult.eve.command.v1` requests. `tex.math`
still passes through as generic Eve component structure until it gains an
explicit Unity projection adapter.
This package lives in the Eve repository as the shared Unity lowering target.
Aetheria and other Unity consumers should import it from Eve instead of
@ -37,7 +38,8 @@ The runtime capability manifest is
evidence:
- release: incubating UPM package identity and import surface;
- test: Aetheria consumer-build smoke through Unity's generated project;
- test: package-owned EditMode tests plus Aetheria consumer-build smoke through
Unity's generated project;
- capture: pending Unity editor or batchmode artifact.
Those lifecycle claims are validated by the parity harness. A missing evidence

View file

@ -76,9 +76,9 @@ namespace GameCult.Eve.UnityUIToolkit
EveSurfaceDocument document,
Action<EveSurfaceCommandRequest>? commandSink)
{
var pluginHost = _options.FindPluginHost(component);
if (pluginHost != null)
return pluginHost.Lower(component, document, commandSink);
var projectionAdapter = _options.FindPluginProjectionAdapter(component);
if (projectionAdapter != null)
return projectionAdapter.Lower(component, document, commandSink);
switch (NormalizeKind(component.Kind))
{

View file

@ -13,23 +13,23 @@ namespace GameCult.Eve.UnityUIToolkit
public EveUiToolkitSurfaceOptions(
Func<EveEmbeddedDocumentSlot, EveSurfaceDocument?>? embeddedDocumentResolver = null,
IReadOnlyList<IEveUiToolkitPluginHost>? pluginHosts = null)
IReadOnlyList<IEveUiToolkitPluginProjectionAdapter>? pluginProjectionAdapters = null)
{
EmbeddedDocumentResolver = embeddedDocumentResolver;
PluginHosts = pluginHosts ?? new IEveUiToolkitPluginHost[]
PluginProjectionAdapters = pluginProjectionAdapters ?? new IEveUiToolkitPluginProjectionAdapter[]
{
new SaiVisualNovelUiToolkitPluginHost(),
new NornGraphUiToolkitPluginHost()
new SaiVisualNovelUiToolkitProjectionAdapter(),
new NornGraphUiToolkitProjectionAdapter()
};
}
public Func<EveEmbeddedDocumentSlot, EveSurfaceDocument?>? EmbeddedDocumentResolver { get; }
public IReadOnlyList<IEveUiToolkitPluginHost> PluginHosts { get; }
public IReadOnlyList<IEveUiToolkitPluginProjectionAdapter> PluginProjectionAdapters { get; }
public IEveUiToolkitPluginHost? FindPluginHost(EveSurfaceComponent component)
public IEveUiToolkitPluginProjectionAdapter? FindPluginProjectionAdapter(EveSurfaceComponent component)
{
return PluginHosts.FirstOrDefault(host => host.CanLower(component));
return PluginProjectionAdapters.FirstOrDefault(adapter => adapter.CanLower(component));
}
}
}

View file

@ -7,7 +7,7 @@ using UnityEngine.UIElements;
namespace GameCult.Eve.UnityUIToolkit
{
public interface IEveUiToolkitPluginHost
public interface IEveUiToolkitPluginProjectionAdapter
{
string PluginId { get; }

View file

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace GameCult.Eve.UnityUIToolkit
{
public sealed class NornGraphUiToolkitPluginHost : IEveUiToolkitPluginHost
public sealed class NornGraphUiToolkitProjectionAdapter : IEveUiToolkitPluginProjectionAdapter
{
public string PluginId => "norn.graph";
@ -29,7 +29,7 @@ namespace GameCult.Eve.UnityUIToolkit
Action<EveSurfaceCommandRequest>? commandSink)
{
var graph = new VisualElement();
graph.AddToClassList("eve-plugin-host");
graph.AddToClassList("eve-plugin-projection");
graph.AddToClassList("eve-plugin-norn-graph");
graph.AddToClassList("norn-graph");
graph.style.flexDirection = FlexDirection.Column;

View file

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace GameCult.Eve.UnityUIToolkit
{
public sealed class SaiVisualNovelUiToolkitPluginHost : IEveUiToolkitPluginHost
public sealed class SaiVisualNovelUiToolkitProjectionAdapter : IEveUiToolkitPluginProjectionAdapter
{
public string PluginId => "sai.vn";
@ -62,7 +62,7 @@ namespace GameCult.Eve.UnityUIToolkit
private static VisualElement Stage(EveSurfaceComponent component)
{
var stage = new VisualElement();
stage.AddToClassList("eve-plugin-host");
stage.AddToClassList("eve-plugin-projection");
stage.AddToClassList("eve-plugin-sai-vn");
stage.AddToClassList("sai-vn-stage");
stage.style.flexGrow = 1;
@ -86,7 +86,7 @@ namespace GameCult.Eve.UnityUIToolkit
private static VisualElement DialoguePanel(EveSurfaceComponent component)
{
var panel = new VisualElement();
panel.AddToClassList("eve-plugin-host");
panel.AddToClassList("eve-plugin-projection");
panel.AddToClassList("eve-plugin-sai-vn");
panel.AddToClassList("sai-vn-dialogue");
panel.style.flexDirection = FlexDirection.Column;
@ -114,7 +114,7 @@ namespace GameCult.Eve.UnityUIToolkit
private static VisualElement DialogueText(EveSurfaceComponent component)
{
var text = new Label(component.GetProp("text"));
text.AddToClassList("eve-plugin-host");
text.AddToClassList("eve-plugin-projection");
text.AddToClassList("eve-plugin-sai-vn");
text.AddToClassList("sai-vn-dialogue-text");
return text;
@ -123,7 +123,7 @@ namespace GameCult.Eve.UnityUIToolkit
private static VisualElement ActionRail()
{
var rail = new VisualElement();
rail.AddToClassList("eve-plugin-host");
rail.AddToClassList("eve-plugin-projection");
rail.AddToClassList("eve-plugin-sai-vn");
rail.AddToClassList("sai-vn-actions");
rail.style.flexDirection = FlexDirection.Row;
@ -139,7 +139,7 @@ namespace GameCult.Eve.UnityUIToolkit
var label = component.GetProp("label", component.GetProp("title", "Continue"));
var command = StoryCommand(component);
var button = new Button(() => EmitStoryCommand(document, component, command, commandSink)) { text = label };
button.AddToClassList("eve-plugin-host");
button.AddToClassList("eve-plugin-projection");
button.AddToClassList("eve-plugin-sai-vn");
button.AddToClassList("sai-vn-story-command");
button.AddToClassList($"sai-vn-command-{SafeClass(command)}");

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 694b4921723a4d56a9f0f72ad2240feb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: acfcd889183e4bfbac82f8883deef300
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using GameCult.Eve.Surface;
using GameCult.Mesh;
using NUnit.Framework;
using UnityEngine.UIElements;
#nullable enable
namespace GameCult.Eve.UnityUIToolkit.Tests
{
public sealed class EveUiToolkitSurfaceLowererTests
{
[Test]
public void DefaultOptionsExposeSaiAndNornProjectionAdapters()
{
var options = EveUiToolkitSurfaceOptions.Default;
Assert.That(options.FindPluginProjectionAdapter(Component("stage", "vn.stage"))?.PluginId, Is.EqualTo("sai.vn"));
Assert.That(options.FindPluginProjectionAdapter(Component("graph", "embed.norn"))?.PluginId, Is.EqualTo("norn.graph"));
}
[Test]
public void SaiStageLowersThroughRuntimeProjectionAdapter()
{
var document = Document(Component(
"stage",
"vn.stage",
new Dictionary<string, string>
{
["storyId"] = "sai.fixture",
["currentPath"] = "intro"
}));
var root = new EveUiToolkitSurfaceLowerer().Lower(document);
Assert.That(root.ClassListContains("eve-plugin-projection"), Is.True);
Assert.That(root.ClassListContains("eve-plugin-sai-vn"), Is.True);
Assert.That(root.ClassListContains("sai-vn-stage"), Is.True);
}
[Test]
public void NornGraphLowersThroughRuntimeProjectionAdapter()
{
var document = Document(Component(
"graph",
"embed.norn",
new Dictionary<string, string>
{
["label"] = "World graph",
["mode"] = "embedded"
}));
var root = new EveUiToolkitSurfaceLowerer().Lower(document);
Assert.That(root.ClassListContains("eve-plugin-projection"), Is.True);
Assert.That(root.ClassListContains("eve-plugin-norn-graph"), Is.True);
Assert.That(root.ClassListContains("norn-graph"), Is.True);
}
[Test]
public void EmbeddedDocumentSlotMountsResolverBackedChildSurface()
{
var child = Document(
Component("child-root", "text", new Dictionary<string, string> { ["text"] = "Nested surface" }),
surfaceId: "child-surface");
var parentRoot = new EveSurfaceComponent(
"parent-root",
"surface",
EmptyProps(),
Array.Empty<EveSurfaceComponent>(),
Array.Empty<CultMeshStateBindingDescriptor>(),
new[]
{
new EveEmbeddedDocumentSlot(
"child-slot",
"child-surface",
EveSurfaceDocument.SchemaId,
"inline")
});
var lowerer = new EveUiToolkitSurfaceLowerer(new EveUiToolkitSurfaceOptions(
embeddedDocumentResolver: _ => child,
pluginProjectionAdapters: Array.Empty<IEveUiToolkitPluginProjectionAdapter>()));
var root = lowerer.Lower(Document(parentRoot));
var embedded = root.Query<VisualElement>(className: "eve-embedded-document").First();
Assert.That(embedded, Is.Not.Null);
Assert.That(embedded.name, Is.EqualTo("child-slot"));
Assert.That(embedded.ClassListContains("eve-embedded-kind-inline"), Is.True);
}
private static EveSurfaceDocument Document(EveSurfaceComponent root, string surfaceId = "test-surface")
{
return new EveSurfaceDocument(
"gamecult.eve.unity.tests",
"runtime.test",
"Unity UI Toolkit tests",
1,
"2026-07-08T00:00:00Z",
new EveSurfaceTree(surfaceId, root, Array.Empty<EveStyleToken>()),
Array.Empty<EveCommandTemplate>());
}
private static EveSurfaceComponent Component(
string id,
string kind,
IReadOnlyDictionary<string, string>? props = null)
{
return new EveSurfaceComponent(
id,
kind,
props ?? EmptyProps(),
Array.Empty<EveSurfaceComponent>());
}
private static IReadOnlyDictionary<string, string> EmptyProps()
{
return new Dictionary<string, string>(StringComparer.Ordinal);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2921e30d39fe49098bc3763c538ed67c

View file

@ -0,0 +1,23 @@
{
"name": "GameCult.Eve.UnityUIToolkit.Tests",
"rootNamespace": "GameCult.Eve.UnityUIToolkit.Tests",
"references": [
"GameCult.Eve.UnityUIToolkit",
"GameCult.Eve.Surface",
"GameCult.Mesh"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"optionalUnityReferences": [
"TestAssemblies"
],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 353e1aea044b46ac98835959a19fe0ac
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -7,7 +7,7 @@
"ownerRepo": "EveUnity",
"currentHostRepo": "Eve",
"splitTarget": "EveUnity",
"graduationTrigger": "Split when Unity package has independent UPM release, plugin host behavior, and Unity test/capture lifecycle."
"graduationTrigger": "Split when Unity package has independent UPM release, plugin projection adapter behavior, and Unity test/capture lifecycle."
},
"supportedFeatures": [
"embeddedDocuments"
@ -21,20 +21,20 @@
"story.continue",
"story.jump"
],
"host": "SaiVisualNovelUiToolkitPluginHost"
"projectionAdapter": "SaiVisualNovelUiToolkitProjectionAdapter"
},
{
"pluginId": "norn.graph",
"capabilities": [
"embed.norn"
],
"host": "NornGraphUiToolkitPluginHost"
"projectionAdapter": "NornGraphUiToolkitProjectionAdapter"
}
],
"unsupportedPlugins": [
{
"pluginId": "tex.math",
"reason": "Unity UI Toolkit currently preserves embed.tex as generic Eve structure; no TeX render plugin host exists in this runtime."
"reason": "Unity UI Toolkit currently preserves embed.tex as generic Eve structure; no TeX projection adapter exists in this runtime."
}
],
"commandTransport": {
@ -59,13 +59,15 @@
},
"test": {
"ownerRepo": "EveUnity",
"status": "consumer-build-smoke",
"status": "authored-editmode-tests-and-consumer-build-smoke",
"command": "powershell -ExecutionPolicy Bypass -File .\\scripts\\run-aetheria-unity-package-smoke.ps1",
"evidencePaths": [
"packages/org.gamecult.eve.unity-uitoolkit/Tests/Editor/GameCult.Eve.UnityUIToolkit.Tests.asmdef",
"packages/org.gamecult.eve.unity-uitoolkit/Tests/Editor/EveUiToolkitSurfaceLowererTests.cs",
"scripts/run-aetheria-unity-package-smoke.ps1"
],
"pendingProofs": [
"Unity EditMode or PlayMode test assembly runs from the runtime repo."
"Unity EditMode or PlayMode test assembly runs from the runtime repo in batchmode."
]
},
"capture": {