/* PLAN 189-1 단위검증 헬퍼 — 카드 안 누른 포장층 → 그 노면공(`pavementAt`) · 범위 표식으로 겹친 노면공 가름. * 화면 TS(`B06_Section_UI_Cross_Design_Surface.ts`)를 그 자리에서 트랜스파일해 Node 로 돌림 · 결과 = 표준출력 JSON. * 짝 = `test_189_1_pave_pick.py`(세 갈래 상태는 `helper_165_pavement_flow.cjs` 가 냄). */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const ROOT = path.join(__dirname, "..", ".."); const file = path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Design_Surface.ts"); const js = ts.transpileModule(fs.readFileSync(file, "utf8"), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, }).outputText; const box = { exports: {} }; new Function("exports", "module", "require", js)(box.exports, box, () => ({})); const { pavementAt } = box.exports; const marks = [ { structure_id: "pave", type_id: "pavement_concrete", start_m: 30, end_m: 250 }, { structure_id: "pave2", type_id: "pavement_concrete", start_m: 100, end_m: 200 }, { structure_id: "wall", type_id: "retaining_wall", start_m: 100, end_m: 200 }, ]; /** 누른 요소 흉내 — `closest(".b06-chart__pavement")` 가 그 층(없으면 null). */ const hit = (dataset) => ({ closest: () => (dataset ? { dataset } : null) }); const layer = (type, start, end) => ({ paveType: type, paveStart: String(start), paveEnd: String(end), }); const out = { pave: pavementAt(hit(layer("pavement_concrete", 30, 250)), marks)?.structure_id ?? null, pave2: pavementAt(hit(layer("pavement_concrete", 100, 200)), marks)?.structure_id ?? null, plainLayer: pavementAt(hit({}), marks)?.structure_id ?? null, // 범위 표식 없는 카드 포장 outside: pavementAt(hit(null), marks)?.structure_id ?? null, noTarget: pavementAt(null, marks)?.structure_id ?? null, unknown: pavementAt(hit(layer("pavement_concrete", 0, 10)), marks)?.structure_id ?? null, }; process.stdout.write(JSON.stringify(out));