paseo-plugin-genui 0.1.5 → 0.1.6
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
CHANGED
package/shared/core/catalog.ts
CHANGED
package/shared/core/evaluate.ts
CHANGED
|
@@ -696,6 +696,11 @@ const Interpreter = defineClass(
|
|
|
696
696
|
return receiver.toUpperCase();
|
|
697
697
|
case "toLowerCase":
|
|
698
698
|
return receiver.toLowerCase();
|
|
699
|
+
// A function replacement keeps `$&` and similar patterns literal.
|
|
700
|
+
case "replace":
|
|
701
|
+
return checkString(receiver.replace(textAt(0), () => textAt(1)), call.pos);
|
|
702
|
+
case "replaceAll":
|
|
703
|
+
return checkString(receiver.replaceAll(textAt(0), () => textAt(1)), call.pos);
|
|
699
704
|
}
|
|
700
705
|
} else if (typeof receiver === "number" && call.name === "toFixed") {
|
|
701
706
|
const digits = args.length > 0 ? this.digits(args[0], call.args[0].pos, label) : 0;
|
package/shared/core/validate.ts
CHANGED
|
@@ -33,7 +33,7 @@ const METHOD_ARITY: ReadonlyMap<string, Arity> = new Map(
|
|
|
33
33
|
map: [1, 1], filter: [1, 1], find: [1, 1], some: [1, 1], every: [1, 1],
|
|
34
34
|
join: [0, 1], slice: [0, 2], includes: [1, 1], indexOf: [1, 1], concat: [1, Infinity], sort: [0, 1],
|
|
35
35
|
split: [1, 1], trim: [0, 0], toUpperCase: [0, 0], toLowerCase: [0, 0],
|
|
36
|
-
startsWith: [1, 1], endsWith: [1, 1], toFixed: [0, 1],
|
|
36
|
+
startsWith: [1, 1], endsWith: [1, 1], replace: [2, 2], replaceAll: [2, 2], toFixed: [0, 1],
|
|
37
37
|
} satisfies Record<MethodName, Arity>),
|
|
38
38
|
);
|
|
39
39
|
|
package/shared/genui.test.ts
CHANGED
|
@@ -69,6 +69,18 @@ describe("paseo-plugin-genui core, instructions, and gallery", () => {
|
|
|
69
69
|
expect(buttons.map((b) => b.props.label)).toEqual(["Open docs.google.com", "Go", "Copy"]);
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
+
it("supports .replace() and .replaceAll() on text", () => {
|
|
73
|
+
const compiled = compile(
|
|
74
|
+
[
|
|
75
|
+
"Text(\"katalon-studio/a-b-b\".replace(\"katalon-studio/\", \"\").replaceAll(\"-\", \" \"))",
|
|
76
|
+
"Text(\"a.b\".replace(\".\", \"$&!\"))",
|
|
77
|
+
].join("\n"),
|
|
78
|
+
);
|
|
79
|
+
expect(compiled.diagnostics).toEqual([]);
|
|
80
|
+
const { roots } = evaluate(compiled.program!, initialState(compiled.program!));
|
|
81
|
+
expect(roots.map((root) => root.props.text)).toEqual(["a b b", "a$&!b"]);
|
|
82
|
+
});
|
|
83
|
+
|
|
72
84
|
it("covers all 86 catalog components in the gallery and compiles + evaluates every gallery spec", async () => {
|
|
73
85
|
const files = await listGallery();
|
|
74
86
|
expect(files.length).toBeGreaterThanOrEqual(170);
|
package/shared/instructions.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const REFERENCE_MORE_GROUPS: readonly ComponentGroup[] = ["Inputs", "Widg
|
|
|
24
24
|
|
|
25
25
|
export const UI_REFERENCE = `# Inline UI reference
|
|
26
26
|
The \`\`\`ui language used by the Inline UI section below.
|
|
27
|
-
Syntax: one statement per line. \`$x = 8\` is state inputs bind to; \`name = expr\` names a value and \`f = (a, b) => expr\` a function; each bare expression renders. JS expressions incl. ** ?: ?? \`\${x}\` [lists] {objects} x.y map/filter/find/sort/concat/join/length, plus round(x, d), fmt(x, d), sum, min, max, abs, entries, Load(path). Named args go last: Slider($n, 0, 10, label: "N").
|
|
27
|
+
Syntax: one statement per line. \`$x = 8\` is state inputs bind to; \`name = expr\` names a value and \`f = (a, b) => expr\` a function; each bare expression renders. JS expressions incl. ** ?: ?? \`\${x}\` [lists] {objects} x.y map/filter/find/sort/concat/join/replace/length, plus round(x, d), fmt(x, d), sum, min, max, abs, entries, Load(path). Named args go last: Slider($n, 0, 10, label: "N").
|
|
28
28
|
Components (? optional; tone: neutral|good|warn|bad|info if meaningful; more in the next section):
|
|
29
29
|
${componentLines(REFERENCE_GROUPS)}
|
|
30
30
|
Actions: ${actionList}; a list runs in order; Send posts as the user.
|