Select runtime capture surfaces explicitly
This commit is contained in:
parent
5852a5ffad
commit
718e9f773b
17 changed files with 166 additions and 10 deletions
|
|
@ -7,6 +7,7 @@ export function buildUnityCaptureRequest({
|
|||
capabilityManifest,
|
||||
advertisementPath = "",
|
||||
capabilityManifestPath = "",
|
||||
captureSurfaceId = "",
|
||||
stamp = new Date().toISOString().replace(/[:.]/g, "-"),
|
||||
} = {}) {
|
||||
if (!advertisement || typeof advertisement !== "object") {
|
||||
|
|
@ -21,8 +22,13 @@ export function buildUnityCaptureRequest({
|
|||
throw new Error("capability manifest is missing lifecycle.capture.captureContract");
|
||||
}
|
||||
|
||||
const captureSurface = selectCaptureSurface(captureContract, advertisement.providerId);
|
||||
const captureSurface = selectCaptureSurface(captureContract, advertisement.providerId, captureSurfaceId);
|
||||
if (!captureSurface) {
|
||||
if (captureSurfaceId) {
|
||||
throw new Error(
|
||||
`capture surface mismatch: expected ${captureSurfaceList(captureContract)} got ${advertisement.providerId || "missing"}:${captureSurfaceId}`,
|
||||
);
|
||||
}
|
||||
throw new Error(
|
||||
`capture provider mismatch: expected ${captureProviderList(captureContract)} got ${advertisement.providerId || "missing"}`,
|
||||
);
|
||||
|
|
@ -79,14 +85,20 @@ function replaceStamp(pattern, stamp) {
|
|||
return pattern.replace("{stamp}", stamp);
|
||||
}
|
||||
|
||||
function selectCaptureSurface(captureContract, providerId) {
|
||||
return captureSurfaceClaims(captureContract).find(claim => claim.providerId === providerId) || null;
|
||||
function selectCaptureSurface(captureContract, providerId, surfaceId = "") {
|
||||
const claims = captureSurfaceClaims(captureContract).filter(claim => claim.providerId === providerId);
|
||||
if (surfaceId) return claims.find(claim => claim.surfaceId === surfaceId) || null;
|
||||
return claims[0] || null;
|
||||
}
|
||||
|
||||
function captureProviderList(captureContract) {
|
||||
return captureSurfaceClaims(captureContract).map(claim => claim.providerId).filter(Boolean).join(", ") || "missing";
|
||||
}
|
||||
|
||||
function captureSurfaceList(captureContract) {
|
||||
return captureSurfaceClaims(captureContract).map(claim => `${claim.providerId}:${claim.surfaceId}`).join(", ") || "missing";
|
||||
}
|
||||
|
||||
function captureSurfaceClaims(captureContract) {
|
||||
return [
|
||||
{
|
||||
|
|
@ -134,6 +146,7 @@ function runCli() {
|
|||
capabilityManifest: loadJsonFile(args.capability),
|
||||
advertisementPath: args.advertisement,
|
||||
capabilityManifestPath: args.capability,
|
||||
captureSurfaceId: args["surface-id"] || "",
|
||||
stamp,
|
||||
});
|
||||
writeCaptureRequest(request, args.output);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,25 @@ test("builds Unity UI Toolkit capture request from provider advertisement", () =
|
|||
assert.match(request.authority, /provider state/);
|
||||
});
|
||||
|
||||
test("builds Unity UI Toolkit capture request for Aetheria editor surface", () => {
|
||||
const request = buildUnityCaptureRequest({
|
||||
advertisement,
|
||||
capabilityManifest,
|
||||
captureSurfaceId: "aetheria.daemon.editor",
|
||||
advertisementPath: "web/fixtures/aetheria.provider-advertisement.json",
|
||||
capabilityManifestPath: "packages/org.gamecult.eve.unity-uitoolkit/eve-runtime-capability.json",
|
||||
stamp: "smoke",
|
||||
});
|
||||
|
||||
assert.equal(request.runtimeId, "unity-uitoolkit");
|
||||
assert.equal(request.providerId, "aetheria");
|
||||
assert.equal(request.surfaceId, "aetheria.daemon.editor");
|
||||
assert.equal(request.surfaceKind, "interactive-world-editor");
|
||||
assert.equal(request.projectionKind, "provider-authored-world-editor-surface");
|
||||
assert.equal(request.commandBoundary, "aetheria.daemon.commands");
|
||||
assert.equal(request.receiptSchema, "aetheria.eve_command_acceptance_status.v1");
|
||||
});
|
||||
|
||||
test("builds Unity UI Toolkit capture request from a declared generic world provider", () => {
|
||||
const request = buildUnityCaptureRequest({
|
||||
advertisement: worldSmokeAdvertisement,
|
||||
|
|
@ -94,3 +113,15 @@ test("builds Unity scene capture request from a declared generic world provider"
|
|||
assert.equal(request.commandBoundary, "eve.world-smoke.commands");
|
||||
assert.equal(request.receiptSchema, "eve.world_smoke.command_receipt.v1");
|
||||
});
|
||||
|
||||
test("rejects Unity scene capture request for Aetheria editor surface", () => {
|
||||
assert.throws(
|
||||
() => buildUnityCaptureRequest({
|
||||
advertisement,
|
||||
capabilityManifest: sceneCapabilityManifest,
|
||||
captureSurfaceId: "aetheria.daemon.editor",
|
||||
stamp: "smoke",
|
||||
}),
|
||||
/capture surface mismatch/,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export function buildUnitySceneCaptureArtifact({
|
|||
surfaceDocument,
|
||||
advertisementPath = "",
|
||||
capabilityManifestPath = "",
|
||||
captureSurfaceId = "",
|
||||
stamp = "latest",
|
||||
} = {}) {
|
||||
const request = buildUnityCaptureRequest({
|
||||
|
|
@ -16,6 +17,7 @@ export function buildUnitySceneCaptureArtifact({
|
|||
capabilityManifest,
|
||||
advertisementPath,
|
||||
capabilityManifestPath,
|
||||
captureSurfaceId,
|
||||
stamp,
|
||||
});
|
||||
const projection = buildUnitySceneProjection(surfaceDocument, advertisement, request.surfaceId);
|
||||
|
|
@ -292,6 +294,7 @@ function runCli() {
|
|||
surfaceDocument: loadJsonFile(args.surface),
|
||||
advertisementPath: args.advertisement,
|
||||
capabilityManifestPath: args.capability,
|
||||
captureSurfaceId: args["surface-id"] || "",
|
||||
stamp,
|
||||
});
|
||||
writeUnitySceneCaptureArtifact(artifact, {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export function buildUnityUiToolkitCaptureArtifact({
|
|||
surfaceDocument,
|
||||
advertisementPath = "",
|
||||
capabilityManifestPath = "",
|
||||
captureSurfaceId = "",
|
||||
stamp = "latest",
|
||||
} = {}) {
|
||||
const request = buildUnityCaptureRequest({
|
||||
|
|
@ -16,6 +17,7 @@ export function buildUnityUiToolkitCaptureArtifact({
|
|||
capabilityManifest,
|
||||
advertisementPath,
|
||||
capabilityManifestPath,
|
||||
captureSurfaceId,
|
||||
stamp,
|
||||
});
|
||||
const projection = buildUnityUiToolkitProjection(surfaceDocument, advertisement, request.surfaceId);
|
||||
|
|
@ -308,6 +310,7 @@ function runCli() {
|
|||
surfaceDocument: loadJsonFile(args.surface),
|
||||
advertisementPath: args.advertisement,
|
||||
capabilityManifestPath: args.capability,
|
||||
captureSurfaceId: args["surface-id"] || "",
|
||||
stamp,
|
||||
});
|
||||
writeUnityUiToolkitCaptureArtifact(artifact, {
|
||||
|
|
|
|||
Loading…
Reference in a new issue