/* 387-4 헬퍼 — 저장 안 한 조정창 값(세션)을 상세 가게가 얹는지(`B06_Section_Section_Adjusts`) · 얹은 뒤 구조물 * 면적(`structureAreaRows`)이 그 값으로 바뀌는지 · 다른 노선 칸은 안 얹는지. 짝 = `test_384_4_cross_window.py`. */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const CATALOG = require("./helper_322_catalog_module.cjs"); // 구조물 표(322-1) const ROOT = path.join(__dirname, "..", ".."); const cache = new Map(); const STUBS = { "@ui/ui_template_toast": { showToast: () => undefined } }; function loadTs(file) { const full = path.resolve(file); if (cache.has(full)) return cache.get(full); const js = ts.transpileModule(fs.readFileSync(full, "utf8"), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020, esModuleInterop: true, }, }).outputText; const box = { exports: {} }; cache.set(full, box.exports); const localRequire = (request) => { if (CATALOG.isCatalogRequest(request)) return CATALOG; if (STUBS[request]) return STUBS[request]; const alias = { "@util/": "common_util", "@ui/": "ui_template", "@config/": "config" }; for (const [prefix, dir] of Object.entries(alias)) if (request.startsWith(prefix)) return loadTs(resolve(path.join(ROOT, dir, request.slice(prefix.length)))); return loadTs(resolve(path.join(path.dirname(full), request))); }; new Function("exports", "module", "require", js)(box.exports, box, localRequire); cache.set(full, box.exports); return box.exports; } const resolve = (base) => [base, `${base}.ts`, path.join(base, "index.ts")].find( (p) => fs.existsSync(p) && fs.statSync(p).isFile(), ) ?? `${base}.ts`; function memoryStorage() { const map = new Map(); return { getItem: (k) => (map.has(k) ? map.get(k) : null), setItem: (k, v) => map.set(k, String(v)), removeItem: (k) => map.delete(k), key: (i) => [...map.keys()][i] ?? null, get length() { return map.size; }, }; } globalThis.window = { sessionStorage: memoryStorage(), localStorage: memoryStorage() }; const B06 = (f) => path.join(ROOT, "B06_Section", `${f}.ts`); const { structureAreaRows } = loadTs(B06("B06_Section_Structure_Layouts")); const { withDraftAdjusts } = loadTs(B06("B06_Section_Section_Adjusts")); const { writeState } = loadTs(path.join(ROOT, "A00_Common", "b_page_state.ts")); const sections = JSON.parse( fs.readFileSync(path.join(__dirname, "fixtures", "b06_186_1_pipe_292.json"), "utf8"), ).cross_sections; const detail = { cross_sections: sections }; const section = sections.find((s) => s.culvert); const at = section.chainage_m.toFixed(2); const area = () => { const row = structureAreaRows(sections).find((r) => r.chainage_m === section.chainage_m); return row ? [row.cut_area_m2, row.fill_area_m2] : null; }; const out = { before: area() }; // 다른 노선 칸 — 안 얹음 writeState("revetx", { [`${at}:outlet`]: { x: 3, d: null, h: null, m: null } }, "p", 8); withDraftAdjusts(detail, "p", 7); out.otherRoute = section.design.revet_adjust?.outlet ?? null; // 이 노선 — 유출 벽 4축 · 유입 형식 · 다단 수 writeState("revetx", { [`${at}:outlet`]: { x: 1.5, d: 0, h: null, m: null } }, "p", 7); writeState("inletstruct", { [at]: "L" }, "p", 7); writeState("extrawall", { [at]: 2 }, "p", 7); withDraftAdjusts(detail, "p", 7); out.laid = { revet: section.design.revet_adjust.outlet, inlet: section.design.inlet_structure, extra: section.design.extra_wall_counts, }; out.after = area(); withDraftAdjusts(detail, "p", 7); out.again = area(); process.stdout.write(JSON.stringify(out));