dominus-cli 0.5.8 → 0.5.9

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/dist/index.js CHANGED
@@ -2618,6 +2618,11 @@ async function startMcpServer() {
2618
2618
  for (const p of parts) r += `[${luaStr(p)}]`;
2619
2619
  return r;
2620
2620
  }
2621
+ function cleanNum(n) {
2622
+ if (Number.isInteger(n)) return String(n);
2623
+ const rounded = Math.round(n * 1e3) / 1e3;
2624
+ return String(rounded);
2625
+ }
2621
2626
  function generateComponentCode(tree, componentName, framework) {
2622
2627
  const isReact = framework === "react";
2623
2628
  const lib = isReact ? "React" : "Roact";
@@ -2675,7 +2680,7 @@ async function startMcpServer() {
2675
2680
  function luaValue(val, _depth) {
2676
2681
  if (val === null || val === void 0) return "nil";
2677
2682
  if (typeof val === "boolean") return String(val);
2678
- if (typeof val === "number") return String(val);
2683
+ if (typeof val === "number") return cleanNum(val);
2679
2684
  if (typeof val === "string") {
2680
2685
  if (val.startsWith("#") && val.length === 7) {
2681
2686
  return `Color3.fromHex("${val}")`;
@@ -2687,15 +2692,15 @@ async function startMcpServer() {
2687
2692
  }
2688
2693
  if (Array.isArray(val)) {
2689
2694
  if (val.length === 4 && val.every((v) => typeof v === "number")) {
2690
- return `UDim2.new(${val.join(", ")})`;
2695
+ return `UDim2.new(${val.map(cleanNum).join(", ")})`;
2691
2696
  }
2692
2697
  if (val.length === 2 && val.every((v) => typeof v === "number")) {
2693
- return `Vector2.new(${val.join(", ")})`;
2698
+ return `Vector2.new(${val.map(cleanNum).join(", ")})`;
2694
2699
  }
2695
2700
  if (val.length === 3 && val.every((v) => typeof v === "number")) {
2696
2701
  const allSmall = val.every((v) => v <= 1);
2697
- if (allSmall) return `Color3.new(${val.join(", ")})`;
2698
- return `Color3.fromRGB(${val.join(", ")})`;
2702
+ if (allSmall) return `Color3.new(${val.map(cleanNum).join(", ")})`;
2703
+ return `Color3.fromRGB(${val.map((v) => String(Math.round(v))).join(", ")})`;
2699
2704
  }
2700
2705
  return `{${val.map((v) => luaValue(v, _depth)).join(", ")}}`;
2701
2706
  }