Skip to content

Commit f12a15b

Browse files
committed
fix: improve dashboard readability
1 parent d442be8 commit f12a15b

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

lib/compiler-v13.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { compilePine as compileBase } from "./compiler-v12";
2+
import type { StrategyConfig } from "./types";
3+
4+
export function compilePine(config: StrategyConfig): string {
5+
let code = compileBase(config);
6+
7+
if (!config.execution.showDashboard) return code;
8+
9+
let dashboardCells = 0;
10+
code = code.replace(/^ table\.cell\(dashboard,.*\)$/gm, (line) => {
11+
dashboardCells += 1;
12+
13+
let updated = line
14+
.replace(/bgcolor=color\.new\(color\.black, 18\)/g, "bgcolor=color.new(color.rgb(15, 23, 42), 8)")
15+
.replace(/text_size=size\.small/g, "text_size=size.normal");
16+
17+
if (!updated.includes("text_color=")) {
18+
updated = `${updated.slice(0, -1)}, text_color=color.white)`;
19+
}
20+
21+
return updated;
22+
});
23+
24+
if (dashboardCells === 0) {
25+
throw new Error("Compiler transform anchor missing: dashboard cells");
26+
}
27+
28+
return code;
29+
}

0 commit comments

Comments
 (0)