From 00141b6473e2e58925da93de888fb92815358d04 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 15 Jul 2026 02:37:18 +0100 Subject: [PATCH] Lower provider-owned structured lists --- packages/eve-browser-lowering/dist/index.d.ts | 1 + packages/eve-browser-lowering/dist/index.js | 21 ++++++++++++++++- packages/eve-browser-lowering/src/index.ts | 23 ++++++++++++++++++- .../test/browser-lowering.test.mjs | 12 +++++++++- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/packages/eve-browser-lowering/dist/index.d.ts b/packages/eve-browser-lowering/dist/index.d.ts index 5e5c93d..c653c7d 100644 --- a/packages/eve-browser-lowering/dist/index.d.ts +++ b/packages/eve-browser-lowering/dist/index.d.ts @@ -173,4 +173,5 @@ export declare function createWorldActionIntent(command: string, action: Record< export declare function applyEveSurfaceStyles(styles: EveSurfaceStyles | undefined, body?: HTMLElement): void; export declare function createEveCommandIntent(commandId: string, props?: Record, options?: EveBrowserLoweringOptions): EveCommandIntent; export declare function emptyState(message: string): HTMLElement; +export declare function projectSemanticListItems(value: unknown): EveSemanticListItem[]; export * from "./input-gestures.js"; diff --git a/packages/eve-browser-lowering/dist/index.js b/packages/eve-browser-lowering/dist/index.js index fc225db..94297fe 100644 --- a/packages/eve-browser-lowering/dist/index.js +++ b/packages/eve-browser-lowering/dist/index.js @@ -374,6 +374,13 @@ export function renderEveComponent(node, options = currentOptions) { const title = stringProp(props.title, ""); if (title) list.append(el("h3", "cultui-list-title", title)); + for (const [index, item] of projectSemanticListItems(props.items).entries()) { + list.append(renderEveComponent({ + id: `${node.id || "list"}-item-${index}`, + kind: "list.item", + props: { ...item }, + }, options)); + } for (const child of children) list.append(renderEveComponent(child, options)); return list; @@ -623,7 +630,9 @@ export function projectSemanticListItem(node) { label: firstString(props.label, props.title, node.text, node.kind, "item"), status: firstString(props.status, ""), detail: firstString(props.detail, props.phase, ""), - badges: firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean), + badges: Array.isArray(props.badges) + ? props.badges.map(value => String(value).trim()).filter(Boolean) + : firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean), }; } function applyGeneratedLayout(element, layout, style = {}) { @@ -1592,6 +1601,16 @@ function assignId(element, node) { function objectProps(value) { return value && typeof value === "object" && !Array.isArray(value) ? value : {}; } +function arrayProp(value) { + return Array.isArray(value) ? value : []; +} +export function projectSemanticListItems(value) { + return arrayProp(value).map((item, index) => projectSemanticListItem({ + id: `list-item-${index}`, + kind: "list.item", + props: objectProps(item), + })); +} function stringProp(value, fallback) { return value === null || value === undefined ? fallback : String(value); } diff --git a/packages/eve-browser-lowering/src/index.ts b/packages/eve-browser-lowering/src/index.ts index 3970bbf..b4edef5 100644 --- a/packages/eve-browser-lowering/src/index.ts +++ b/packages/eve-browser-lowering/src/index.ts @@ -555,6 +555,13 @@ export function renderEveComponent( list.dataset.componentKind = kind; const title = stringProp(props.title, ""); if (title) list.append(el("h3", "cultui-list-title", title)); + for (const [index, item] of projectSemanticListItems(props.items).entries()) { + list.append(renderEveComponent({ + id: `${node.id || "list"}-item-${index}`, + kind: "list.item", + props: { ...item }, + }, options)); + } for (const child of children) list.append(renderEveComponent(child, options)); return list; } @@ -804,7 +811,9 @@ export function projectSemanticListItem(node: EveSurfaceComponent): EveSemanticL label: firstString(props.label, props.title, node.text, node.kind, "item"), status: firstString(props.status, ""), detail: firstString(props.detail, props.phase, ""), - badges: firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean), + badges: Array.isArray(props.badges) + ? props.badges.map(value => String(value).trim()).filter(Boolean) + : firstString(props.badges, "").split(",").map(value => value.trim()).filter(Boolean), }; } @@ -1813,6 +1822,18 @@ function objectProps(value: unknown): Record { return value && typeof value === "object" && !Array.isArray(value) ? value as Record : {}; } +function arrayProp(value: unknown): unknown[] { + return Array.isArray(value) ? value : []; +} + +export function projectSemanticListItems(value: unknown): EveSemanticListItem[] { + return arrayProp(value).map((item, index) => projectSemanticListItem({ + id: `list-item-${index}`, + kind: "list.item", + props: objectProps(item), + })); +} + function stringProp(value: unknown, fallback: string): string { return value === null || value === undefined ? fallback : String(value); } diff --git a/packages/eve-browser-lowering/test/browser-lowering.test.mjs b/packages/eve-browser-lowering/test/browser-lowering.test.mjs index 602818f..4b43bdc 100644 --- a/packages/eve-browser-lowering/test/browser-lowering.test.mjs +++ b/packages/eve-browser-lowering/test/browser-lowering.test.mjs @@ -1,7 +1,7 @@ import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import test from "node:test"; -import { applyEveStateBindingValue, createEveCommandIntent, createWorldActionIntent, normalizeFieldsDocument, projectSemanticListItem, projectWorldScene, resolveRequiredPluginAdapters, selectAdvertisedSurface } from "../dist/index.js"; +import { applyEveStateBindingValue, createEveCommandIntent, createWorldActionIntent, normalizeFieldsDocument, projectSemanticListItem, projectSemanticListItems, projectWorldScene, resolveRequiredPluginAdapters, selectAdvertisedSurface } from "../dist/index.js"; test("applies provider state bindings to component props instead of receipt diagnostics", () => { const component = { props: { value: 1.2 } }; @@ -93,6 +93,16 @@ test("projects unknown semantic items through the generic list contract", () => }); }); +test("projects provider-owned list data through the same semantic item contract", () => { + assert.deepEqual(projectSemanticListItems([ + { label: "Face One", status: "working", detail: "Current turn", badges: ["repo", "live"] }, + { label: "Face Two", status: "ready" }, + ]), [ + { label: "Face One", status: "working", detail: "Current turn", badges: ["repo", "live"] }, + { label: "Face Two", status: "ready", detail: "", badges: [] }, + ]); +}); + test("command intents use the active surface advertisement boundary", () => { const intent = createEveCommandIntent("aetheria.daemon.editor.inspect", { action: {