feat(pbs): add sprite animation and shared Studio authoring
Implement DEC-0084 with factory-only Sprite/Animator structs, complete result lowering, validated animation sidecars, generated PBS factories and JavaFX/MCP authoring through shared services. Qualify native dev/release with ordinary and optimized producers, zero-allocation playback, private-cycle reclamation, canonical Composer pixels, installed JARs and JavaFX lifecycle. Preserve the runtime checkout and existing host ABI.
This commit is contained in:
+5
-2
@@ -14,8 +14,11 @@ public final class LspServerLifecycleImpl implements LspServerLifecycle {
|
||||
private final CompilerLanguageServiceBridge compilerBridge;
|
||||
private final ConcurrentMap<String, TcpLspServerHost> activeServers;
|
||||
|
||||
public LspServerLifecycleImpl() {
|
||||
this.compilerBridge = new CompilerLanguageServiceBridge();
|
||||
public LspServerLifecycleImpl() { this(null); }
|
||||
|
||||
public LspServerLifecycleImpl(p.animation.GlyphBankLayoutSource layouts) { this(layouts,null); }
|
||||
public LspServerLifecycleImpl(p.animation.GlyphBankLayoutSource layouts,p.animation.AnimationOriginNavigation navigation) {
|
||||
this.compilerBridge = new CompilerLanguageServiceBridge(layouts,navigation);
|
||||
this.serverHostFactory = new TcpLspServerHostFactory();
|
||||
this.activeServers = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
+23
-2
@@ -115,14 +115,32 @@ public final class CompilerLanguageServiceBridge implements LanguageServiceBridg
|
||||
}
|
||||
return new BaselineDefinition(List.copyOf(mapped));
|
||||
}
|
||||
private final AssetSurfaceContextLoader assetSurfaceContextLoader = new AssetSurfaceContextLoader();
|
||||
private final AssetSurfaceContextLoader assetSurfaceContextLoader;
|
||||
private final p.animation.GlyphBankLayoutSource layouts;
|
||||
private p.animation.AnimationOriginNavigation animationNavigation;
|
||||
private final Function<String, FrontendProvider> frontendProviderResolver;
|
||||
|
||||
public CompilerLanguageServiceBridge() {
|
||||
this(FrontendRegistryService::require);
|
||||
}
|
||||
|
||||
CompilerLanguageServiceBridge(final Function<String, FrontendProvider> frontendProviderResolver) {
|
||||
public CompilerLanguageServiceBridge(p.animation.GlyphBankLayoutSource layouts) { this(FrontendRegistryService::require, layouts); }
|
||||
public CompilerLanguageServiceBridge(p.animation.GlyphBankLayoutSource layouts,p.animation.AnimationOriginNavigation navigation) {
|
||||
this(FrontendRegistryService::require,layouts);this.animationNavigation=navigation;
|
||||
}
|
||||
public void openAnimationOrigin(LspProjectContext context,String uri,int offset,ExternalSourceRegistry registry,String consumer) {
|
||||
if(animationNavigation==null||offset<0)throw new IllegalArgumentException("Animation origin navigation is unavailable");
|
||||
registry.revalidate(consumer,uri,path->currentSource(context,path));
|
||||
var source=registry.source(consumer,uri);
|
||||
if(!source.origin().equals("generated"))throw new IllegalArgumentException("Source is not generated animation");
|
||||
var origin=source.origins().stream().filter(o->o.assetUuid()!=null&&offset>=o.startOffset()&&offset<o.endOffset()).findFirst().orElseThrow(()->new IllegalArgumentException("No authored animation field at this position"));
|
||||
animationNavigation.open(context.projectRoot(),java.util.UUID.fromString(origin.assetUuid()),origin.jsonPointer());
|
||||
}
|
||||
|
||||
CompilerLanguageServiceBridge(final Function<String, FrontendProvider> frontendProviderResolver) { this(frontendProviderResolver,null); }
|
||||
|
||||
private CompilerLanguageServiceBridge(Function<String, FrontendProvider> frontendProviderResolver,p.animation.GlyphBankLayoutSource layouts) {
|
||||
this.layouts=layouts;this.assetSurfaceContextLoader=new AssetSurfaceContextLoader(layouts);
|
||||
this.frontendProviderResolver = Objects.requireNonNull(frontendProviderResolver, "frontendProviderResolver");
|
||||
}
|
||||
|
||||
@@ -367,6 +385,7 @@ public final class CompilerLanguageServiceBridge implements LanguageServiceBridg
|
||||
context.projectRoot().toString(),
|
||||
"core-v1",
|
||||
SourceProviderFactory.overlayUtf8(Map.of())));
|
||||
pipelineContext.glyphBankLayoutSource=layouts;
|
||||
BuilderPipelineService.INSTANCE.analyze(pipelineContext, LogAggregator.empty());
|
||||
final FrontendPhaseContext frontendPhaseContext = new FrontendPhaseContext(
|
||||
pipelineContext.resolvedWorkspace.graph().projectTable(),
|
||||
@@ -888,6 +907,7 @@ public final class CompilerLanguageServiceBridge implements LanguageServiceBridg
|
||||
context.projectRoot().toString(),
|
||||
"core-v1",
|
||||
SourceProviderFactory.overlayUtf8(overlays)));
|
||||
pipelineContext.glyphBankLayoutSource=layouts;
|
||||
return BuilderPipelineService.INSTANCE.analyze(pipelineContext, LogAggregator.empty());
|
||||
}
|
||||
|
||||
@@ -906,6 +926,7 @@ public final class CompilerLanguageServiceBridge implements LanguageServiceBridg
|
||||
context.projectRoot().toString(),
|
||||
"core-v1",
|
||||
SourceProviderFactory.overlayUtf8(text == null ? Map.of() : Map.of(documentPath, text))));
|
||||
pipelineContext.glyphBankLayoutSource=layouts;
|
||||
BuilderPipelineService.INSTANCE.analyze(pipelineContext, LogAggregator.empty());
|
||||
final FileId fileId = findFileId(pipelineContext, documentPath);
|
||||
if (fileId == null) {
|
||||
|
||||
+10
-3
@@ -8,8 +8,15 @@ import java.util.function.Function;
|
||||
|
||||
/** Owned by one project host, never by the shared compiler bridge. */
|
||||
public final class ExternalSourceRegistry implements AutoCloseable {
|
||||
/** Wire metadata must contain URI/text values, never filesystem implementation objects. */
|
||||
public record Origin(int startOffset, int endOffset, String definitionPath, String jsonPointer, String assetUuid) {
|
||||
private static Origin from(FrontendSourceDocument.OriginSpan span) {
|
||||
return new Origin(span.startOffset(), span.endOffset(), span.definitionPath().toUri().toString(),
|
||||
span.jsonPointer(), span.assetUuid());
|
||||
}
|
||||
}
|
||||
public record Descriptor(String uri, String revision, String origin, String name,
|
||||
String languageId, boolean readOnly) {}
|
||||
String languageId, boolean readOnly, List<Origin> origins) {}
|
||||
public record Content(Descriptor descriptor, String text) {}
|
||||
private static final class Entry {
|
||||
final Descriptor descriptor;
|
||||
@@ -55,7 +62,7 @@ public final class ExternalSourceRegistry implements AutoCloseable {
|
||||
// must not change the opaque identity by normalizing escaped slashes.
|
||||
final String uri = "prometeu-source://" + session + "/" + UUID.randomUUID() + "/"
|
||||
+ source.revision() + "/" + source.name().replaceAll("[^A-Za-z0-9._-]", "-");
|
||||
entry = new Entry(new Descriptor(uri, source.revision(), source.origin(), source.name(), source.languageId(), true), source);
|
||||
entry = new Entry(new Descriptor(uri, source.revision(), source.origin(), source.name(), source.languageId(), true, source.origins().stream().map(Origin::from).toList()), source);
|
||||
entries.put(uri, entry);
|
||||
}
|
||||
consumer.grants.add(entry.descriptor.uri());
|
||||
@@ -68,7 +75,7 @@ public final class ExternalSourceRegistry implements AutoCloseable {
|
||||
return left == right || left != null && left.path().equals(right.path())
|
||||
&& left.context().projectSurface() != null
|
||||
&& left.context().projectSurface() == right.context().projectSurface()
|
||||
&& left.text().equals(right.text());
|
||||
&& left.text().equals(right.text()) && left.revision().equals(right.revision());
|
||||
}
|
||||
|
||||
public synchronized FrontendSourceDocument source(String consumerId, String uri) {
|
||||
|
||||
+2
@@ -7,6 +7,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface ExternalSourceLanguageServer extends LanguageServer {
|
||||
record Request(String consumerId, String uri) {}
|
||||
record AnimationOriginRequest(String consumerId,String uri,int offset) {}
|
||||
@JsonRequest("prometeu/openAnimationOrigin") CompletableFuture<Void> openAnimationOrigin(AnimationOriginRequest request);
|
||||
@JsonRequest("prometeu/readExternalSource") CompletableFuture<Content> readExternalSource(Request request);
|
||||
@JsonRequest("prometeu/retainExternalSource") CompletableFuture<Content> retainExternalSource(Request request);
|
||||
@JsonRequest("prometeu/releaseExternalSource") CompletableFuture<Void> releaseExternalSource(Request request);
|
||||
|
||||
+5
@@ -61,6 +61,11 @@ public final class PrometeuLanguageServer implements ExternalSourceLanguageServe
|
||||
failure.getMessage(), null)));
|
||||
}
|
||||
}
|
||||
@Override public CompletableFuture<Void> openAnimationOrigin(AnimationOriginRequest request) {
|
||||
return external(new Request(request.consumerId(),request.uri()),()->{
|
||||
((CompilerLanguageServiceBridge)languageServiceBridge).openAnimationOrigin(project,request.uri(),request.offset(),externalSources,consumerId);return null;
|
||||
});
|
||||
}
|
||||
@Override public CompletableFuture<p.studio.lsp.services.compiler.ExternalSourceRegistry.Content> readExternalSource(Request request) {
|
||||
return external(request, () -> externalSources.read(consumerId, request.uri()));
|
||||
}
|
||||
|
||||
+12
@@ -65,6 +65,18 @@ class ExternalSourceRegistryTest {
|
||||
assertThrows(IllegalStateException.class, () -> registry.read(next, uri));
|
||||
}
|
||||
|
||||
@Test void generatedOriginMetadataSerializesWithoutFilesystemInternals() {
|
||||
var base=source("fn generated() {}");
|
||||
var generated=new FrontendSourceDocument(base.path(),base.text(),"generated",base.name(),"pbs",true,base.context(),
|
||||
java.util.List.of(new FrontendSourceDocument.OriginSpan(0,10,Path.of("/project/assets/bank/animations.studio.json"),"/animators/0/id","12345678-1234-1234-1234-123456789abc")),"generator-revision");
|
||||
try(var registry=new ExternalSourceRegistry()){
|
||||
String consumer=registry.connect(null,false);String uri=registry.register(consumer,generated);
|
||||
String json=new com.google.gson.Gson().toJson(registry.read(consumer,uri));
|
||||
assertTrue(json.contains("file:///project/assets/bank/animations.studio.json"));
|
||||
assertTrue(json.contains("/animators/0/id"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test void cancelledOrUnopenedNavigationDoesNotRetainASnapshot() {
|
||||
try (var registry = new ExternalSourceRegistry()) {
|
||||
final String consumer = registry.connect(null, true);
|
||||
|
||||
Reference in New Issue
Block a user