paseo-plugin-genui 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/shared/core/evaluate.ts +4 -0
- package/shared/genui.test.ts +9 -0
package/package.json
CHANGED
package/shared/core/evaluate.ts
CHANGED
|
@@ -519,6 +519,10 @@ const Interpreter = defineClass(
|
|
|
519
519
|
for (const child of item) visit(child);
|
|
520
520
|
} else if (isNode(item)) {
|
|
521
521
|
out.push(item);
|
|
522
|
+
} else if (isAction(item) && item.type !== "set") {
|
|
523
|
+
// A bare action where a component belongs: render it as the Button the agent meant.
|
|
524
|
+
const text = item.type === "openUrl" ? `Open ${new URL(item.url).host}` : item.type === "copy" ? "Copy" : item.text;
|
|
525
|
+
out.push(this.node("Button", `${key}.${out.length}`, { label: text, action: [item], variant: null, icon: null }, pos));
|
|
522
526
|
} else {
|
|
523
527
|
throw new RuntimeError(pos, `${label} must be components or text, got ${describe(item)}`);
|
|
524
528
|
}
|
package/shared/genui.test.ts
CHANGED
|
@@ -60,6 +60,15 @@ describe("paseo-plugin-genui core, instructions, and gallery", () => {
|
|
|
60
60
|
expect(roots.map((root) => root.props.text)).toEqual(["x,z,y", "1,9,10", "x,y"]);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it("renders a bare Send, OpenUrl or Copy among children as a Button", () => {
|
|
64
|
+
const compiled = compile('Card("x", [Text("a"), OpenUrl("https://docs.google.com/x"), Send("Go"), Copy("id")])');
|
|
65
|
+
expect(compiled.diagnostics.filter((d) => d.severity === "error")).toEqual([]);
|
|
66
|
+
const { roots, diagnostics } = evaluate(compiled.program!, initialState(compiled.program!));
|
|
67
|
+
expect(diagnostics).toEqual([]);
|
|
68
|
+
const buttons = (roots[0]!.props.children as { type: string; props: { label: string } }[]).filter((c) => c.type === "Button");
|
|
69
|
+
expect(buttons.map((b) => b.props.label)).toEqual(["Open docs.google.com", "Go", "Copy"]);
|
|
70
|
+
});
|
|
71
|
+
|
|
63
72
|
it("covers all 86 catalog components in the gallery and compiles + evaluates every gallery spec", async () => {
|
|
64
73
|
const files = await listGallery();
|
|
65
74
|
expect(files.length).toBeGreaterThanOrEqual(170);
|