/* 315 물넘이포장 도수로 · 돌붙임 길이(성토) · 월류 높이선 성토 쪽 연장 헬퍼 — 진짜 TS 를 Node 로 돌려 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 cache = new Map(); const load = (file) => { if (cache.has(file)) return cache.get(file); const js = ts.transpileModule(fs.readFileSync(file, "utf8"), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, }).outputText; const box = { exports: {} }; cache.set(file, box.exports); const near = (m) => { if (m.startsWith("@config/")) return load(path.join(ROOT, "config", `${m.slice(8)}.ts`)); if (m.startsWith("@util/")) return load(path.join(ROOT, "common_util", `${m.slice(6)}.ts`)); if (m.startsWith(".")) return load(path.join(path.dirname(file), `${m}.ts`)); return new Proxy({}, { get: () => () => {} }); }; new Function("exports", "module", "require", js)(box.exports, box, near); return box.exports; }; class Node { constructor(tag) { this.tag = tag; this.attrs = {}; this.children = []; this.dataset = {}; this.style = {}; } setAttribute(k, v) { this.attrs[k] = String(v); } getAttribute(k) { return this.attrs[k] ?? null; } append(...kids) { this.children.push(...kids); } } globalThis.document = { createElementNS: (_ns, tag) => new Node(tag) }; const input = JSON.parse(fs.readFileSync(process.argv[2], "utf8")); const pave = load(path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Ford_Pavement.ts")); const hatch = load(path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Wall_Hatch.ts")); const fillGround = hatch.groundLine(input.fillSamples); const dipGround = hatch.groundLine(input.dipSamples); const chute = (design, ground, length) => pave.fordChuteLine(design, length ? { length_m: length } : {}, ground); // 그린 SVG — 띠(돌붙임) · 월류 높이선 점 수 const svg = new Node("g"); pave.appendFordPavementOverlay( svg, { span_m: 8, depth_m: 0.3, slope_pct: 5, chute: { structure: "돌붙임", thickness_m: 0.3, length_m: 6 }, }, input.fillDesign, (o) => o, (e) => e, fillGround, ); const deck = svg.children.find((k) => k.attrs.class === "b06-chart__ford-deck-plan"); const band = svg.children.find((k) => k.attrs.class === "b06-chart__culvert-pitching"); const out = { fillNone: chute(input.fillDesign, fillGround), fillShort: chute(input.fillDesign, fillGround, 1), fillLong: chute(input.fillDesign, fillGround, 6), dipNone: chute(input.dipDesign, dipGround), dipLong: chute(input.dipDesign, dipGround, 2), fillOverflow: pave.overflowLine(input.fillDesign, 0.3), dipOverflow: pave.overflowLine(input.dipDesign, 0.3), fillEdges: pave.fordEdges(input.fillDesign), dipEdges: pave.fordEdges(input.dipDesign), deckPoints: deck?.attrs.points ?? null, bandPoints: band?.attrs.points ?? null, }; process.stdout.write(JSON.stringify(out));