Complete prepared presentation build and runtime integration
This commit is contained in:
@@ -251,7 +251,7 @@ export function generateComponentClientBindings(plan: ExecutionPlan, packageRevi
|
||||
.join("\n");
|
||||
return (
|
||||
interfaces +
|
||||
'\nimport {createObjectRenderer,definePackageQuery,definePackageFragment,type ComponentType,type ComponentProps} from "@quixos/camino-react";\n' +
|
||||
'\nimport {createObjectRenderer,definePackageQuery,definePackageFragment,type ComponentType,type ComponentProps,type PreparedPresentation} from "@quixos/camino-react";\n' +
|
||||
subjectBindings +
|
||||
"\n" +
|
||||
queries +
|
||||
@@ -272,7 +272,27 @@ export function generateComponentClientBindings(plan: ExecutionPlan, packageRevi
|
||||
.map((component) => {
|
||||
const module = modules.find((module) => module.id === component.id)!;
|
||||
const key = JSON.stringify([module.interfaceRevisionId, module.memberId]);
|
||||
return `${JSON.stringify(component.displayName)}: ComponentType<ComponentProps<${JSON.stringify(component.subject)}, ${JSON.stringify(module.contract)}, ${moduleArguments(find(module.interfaceRevisionId))}> & ExtraModuleProps<${JSON.stringify(key)}>>;`;
|
||||
const artifact = pkg.buildArtifacts?.["org.quixos.react.preparation/1"] as
|
||||
| import("../react-build/declarations.js").ReactPreparationArtifact
|
||||
| undefined;
|
||||
const preparation = artifact?.modules.find((entry) => entry.module === module.id);
|
||||
const composition = pkg.queryCompositions?.find((entry) => entry.id === preparation?.composition);
|
||||
if (!preparation || !composition)
|
||||
throw new ExecutionPlanError("MISSING_PRESENTATION_INPUTS", module.id, "Declare inputs in quixos.react.json");
|
||||
const children = preparation.children.map((child) => {
|
||||
let extra = "{}";
|
||||
if (child.role) {
|
||||
const iface = find(child.role.interface);
|
||||
const member = iface.members.find(
|
||||
(entry) => entry.id === child.role!.member || entry.displayName === child.role!.member,
|
||||
)!;
|
||||
extra = props(iface.revisionId, member.id);
|
||||
}
|
||||
const handle = `PreparedPresentation<${JSON.stringify(child.subject)}, ${extra}>`;
|
||||
return `readonly ${JSON.stringify(child.name)}: ${child.each ? `readonly ${handle}[]` : child.with || child.when ? `${handle} | null` : handle}`;
|
||||
});
|
||||
const input = `${tsType(composition.output)} & {readonly children: {${children.join(";")}}}`;
|
||||
return `${JSON.stringify(component.displayName)}: ComponentType<ComponentProps<${JSON.stringify(component.subject)}, ${JSON.stringify(module.contract)}, ${moduleArguments(find(module.interfaceRevisionId))}, ${input}> & ExtraModuleProps<${JSON.stringify(key)}>>;`;
|
||||
})
|
||||
.join("\n") +
|
||||
"\n}\n"
|
||||
|
||||
Reference in New Issue
Block a user