/* 177-3 횡단 카드 ↔ 종단 측점선 헬퍼 — 진짜 design_profile.ts 의 `setSelectedStation` · `setSelectedStructure` * 본문을 떼어(TS 는 그 자리 트랜스파일) 측점 · 구조물 짝 흉내에 붙이고, B06 카드 고름 차례 * (showCard → setSelectedStation · 리스너 → selectMark → setSelectedStructure(mark, true))와 B05 기본 길을 돌려 * 남은 측점선 id 를 표준출력 JSON 한 벌로. */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const ROOT = path.join(__dirname, "..", ".."); const src = fs.readFileSync(path.join(ROOT, "A00_Common", "design", "design_profile.ts"), "utf8"); const method = (name) => { const pattern = String.raw`\r?\n ${name}\([^\r\n]*\) \{\r?\n[\s\S]*?\r?\n \},`; const match = src.match(new RegExp(pattern)); if (!match) throw new Error(`본문 없음: ${name}`); return match[0]; }; const body = ` let selectedStationId = null; let selectedStructureId = null; // 관(pipe-80.17)만 측점선(irr-80)이 있음 — 벽 · 노면공은 선 없음(PST stationIdAtStructure) const structureIdAtStation = (stationId) => (stationId === "irr-80" ? "pipe-80.17" : null); const stationIdAtStructure = (structureId) => (structureId === "pipe-80.17" ? "irr-80" : null); const draw = () => {}; const revealPick = () => {}; // 화면 밖이면 가운데로(273-1) — 이 시험 몫 아님 module.exports = { line: () => selectedStationId, ${method("setSelectedStation")} ${method("setSelectedStructure")} };`; const js = ts.transpileModule(body, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, }).outputText; const box = { exports: {} }; new Function("exports", "module", js)(box.exports, box); const dp = box.exports; /** B06 카드 고름 — showCard(카드 · 관 측점이면 관 선) 뒤 리스너가 selectMark(mark) = keepStation true. */ const b06Card = (lineId, mark) => { dp.setSelectedStation(lineId); dp.setSelectedStructure(mark, true); return dp.line(); }; /** B05 목록 고름 — 기본값(keepStation 없음). */ const b05Pick = (lineId, structureId) => { dp.setSelectedStation(lineId); dp.setSelectedStructure(structureId); return dp.line(); }; const out = { plainCard: b06Card("s40", null), // 일반 카드 — 덮는 것 없음 wallCard: b06Card("s100", "wall"), // 벽(선 없는 구조물) 카드 paveCard: b06Card("s140", "pave"), // 노면공 범위 안 카드 pipeCard: b06Card("irr-80", "pipe-80.17"), // 관 카드 = 관 선 pipeFromPlain: b06Card("s60", "pipe-80.17"), // 관 알약 = 관 선으로 옮김 // 반대 길 — 종단 측점선 누름 → 카드 고름 → 같은 리스너(selectMark null) profileClick: b06Card("s200", null), // 카드 풂 = showCard(null) → 선 끔 release: (dp.setSelectedStation(null), dp.line()), b05Wall: b05Pick("s100", "wall"), // B05 = 지금 그대로(선 없는 구조물 → 선 끔) b05Pipe: b05Pick("s40", "pipe-80.17"), b05Keep: b05Pick("irr-80", "pipe-80.17"), }; process.stdout.write(JSON.stringify(out));