/* PLAN 505-2 단위검증 헬퍼 — 진짜 `design_pipeline_stations.ts` snapOptions(옛 초안 간격) · * `design_structure_pipe_calc.ts` set 풀개(떠난 페이지를 놓음). 짝 = `test_505_2_save_pick.py`. */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const ROOT = path.join(__dirname, "..", ".."); function load(rel) { const js = ts.transpileModule(fs.readFileSync(path.join(ROOT, rel), "utf8"), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, }).outputText; const box = { exports: {} }; new Function("exports", "module", "require", js)(box.exports, box, () => ({})); return box.exports; } (async () => { const out = {}; // 2b — 초안 간격 · 저장 간격 → 측점 셈 간격(서버 load_station_snap_step 과 같아야 함) const { snapOptions } = load("A00_Common/design/logic/design_pipeline_stations.ts"); out.draft = [10, 0.1, 1, 20, null].map( (step) => snapOptions({ stationSnap: true, stationSnapStep: step }, null).stationSnapStep, ); out.saved = [10, 0.1, 1, null].map( (step) => snapOptions(null, { station_snap: true, station_snap_step: step }).stationSnapStep, ); out.snapKept = snapOptions({ stationSnap: true, stationSnapStep: 0.1 }, null).stationSnap; // 7 — 풀개는 자기 값일 때만 비움 const calc = load("A00_Common/design/design_structure_pipe_calc.ts"); const opened = { a: 0, b: 0 }; const releaseA = calc.setPipeCrossOpener(async () => void (opened.a += 1)); releaseA(); await calc.setPipeExtraCount(null, 1); out.afterRelease = opened.a; // 0 — 풀린 옛 페이지를 안 부름 const releaseA2 = calc.setPipeCrossOpener(async () => void (opened.a += 1)); calc.setPipeCrossOpener(async () => void (opened.b += 1)); releaseA2(); // 옛 것 풀개 — 새 것은 그대로 await calc.setPipeExtraCount(null, 1); out.newKept = { ...opened }; let sunk = 0; const releaseSink = calc.setPipeExtraCountSink(() => void (sunk += 1)); await calc.setPipeExtraCount(null, 1); out.sinkOpened = opened.b; // sink 있으면 열지 않음 → 그대로 1 releaseSink(); await calc.setPipeExtraCount(null, 1); out.sinkReleasedOpened = opened.b; // sink 풀림 → 새 횡단 보기를 엶 → 2 process.stdout.write(JSON.stringify(out)); })().catch((error) => { console.error(error); process.exit(1); });