From 961d15a3897c0645bbd2c27a889786318084098f Mon Sep 17 00:00:00 2001 From: Karstein Phobic Nyvold Kvistad Date: Tue, 28 Apr 2026 21:08:50 +0200 Subject: [PATCH] tui: add domain types (Project, POU, Hunk, Selection) --- src/tui/shared/types.ts | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/tui/shared/types.ts diff --git a/src/tui/shared/types.ts b/src/tui/shared/types.ts new file mode 100644 index 0000000..c36775c --- /dev/null +++ b/src/tui/shared/types.ts @@ -0,0 +1,52 @@ +export type POUKind = + | 'PRG' + | 'FB' + | 'GVL' + | 'STRUCT' + | 'ENUM' + | 'METHOD' + | 'PROPERTY_GETTER' + | 'PROPERTY_SETTER' + | 'META' + | 'OTHER'; + +export interface POU { + /** Display name without .st extension */ + name: string; + kind: POUKind; + /** Path relative to the device root, with forward slashes. */ + relPath: string; + absPath: string; + /** Non-blank line count */ + loc: number; + mtimeMs: number; +} + +export interface Device { + /** Top-level subdir under mcp-mirror/, e.g. "CodesysRpi" */ + name: string; + pous: POU[]; +} + +export interface Project { + /** The project's parent directory (the dir that contains mcp-mirror/) */ + rootDir: string; + /** Mirror dir mtime — used for the "stale" indicator */ + mirrorMtimeMs: number; + devices: Device[]; +} + +export interface Selection { + device: string; + pou: POU; + viewerLine: number; +} + +export type HunkKind = 'add' | 'del' | 'ctx'; + +export interface Hunk { + kind: HunkKind; + /** 1-based line number in the side this hunk belongs to (new-side for add/ctx, old-side for del). */ + lineNo: number; + text: string; +}