- 옮김: B04 2 · B05 23 · B06 11 · A00_Common/design 13 (9,299 줄) · 이미 logic/ 에 있던 16 파일 그대로 - 안 옮김: 묶음 입구(package.json build:*) · 파이썬 · 순수지만 계산 아닌 8 (보기 결선 · 콜백 · API 타입 · 갈아끼움 알림판) - import 266 줄(142 파일) · 시험 · 주석 · 짝 표시 문자열 경로 고침 · B05 · B06 CLAUDE.md 짝 줄 logic/ - 시험 도우미 새 경로: 가짜 require 열쇠 · B05()/B06() 부름 · 형제 import 자리 · tsc 묶어 돌리는 시험 · 정규식 · rglob - design_view_cross 줄 한도 시험 685 → 688 (긴 import 경로 줄바꿈 3줄) - 확인: typecheck 0 · 서버 묶음 넷(corridor · server-calc · b07-extent · b07-note) 다시 지어 코드 같음(//#region 경로 주석만 다름) · 관련 시험 270 파일 — 남은 실패 19 는 옮기기 전과 같음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
115 lines
4.8 KiB
JavaScript
115 lines
4.8 KiB
JavaScript
/* 178-3 사면안정 흙막이 · 옹벽 「추가 단」 헬퍼 — 화면 TS 를 그 자리에서 트랜스파일해 Node 로 돌림.
|
|
* ① 명세 상자 저장 왕복(readState → writeOptions) ② 구조물 정본 → 벽 제원(`wallSpecsFrom`) → 횡단 형상
|
|
* (`computeRevetmentLayout`) 단 수 · 단마다 형태 · 높이. 입력 측점 = 73-4 픽스처(helper_79 와 같은 180 측점).
|
|
* 결과 = 표준출력 JSON 한 벌 · 짝 = `test_178_3_slope_tiers.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);
|
|
if (full.endsWith(".json")) {
|
|
const data = JSON.parse(fs.readFileSync(full, "utf8"));
|
|
cache.set(full, data);
|
|
return data;
|
|
}
|
|
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`;
|
|
|
|
const design = (f) => path.join(ROOT, "A00_Common", "design", f);
|
|
const spec = loadTs(design("logic/design_structure_spec.ts"));
|
|
const { ADDON_SPECS } = loadTs(design("logic/design_structure_slope_tier.ts"));
|
|
const { STRUCTURE_SPECS } = loadTs(design("logic/design_structure_pipe.ts"));
|
|
const { wallSpecsFrom } = loadTs(path.join(ROOT, "common_util", "common_util_structure_walls.ts"));
|
|
const { computeRevetmentLayout } = loadTs(
|
|
path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Revetment.ts"),
|
|
);
|
|
|
|
const r3 = (v) => Math.round(v * 1000) / 1000;
|
|
const out = {};
|
|
|
|
// ① 저장 왕복 — 상자 둘(흙막이) · 하나(옹벽) · 빈 상자(값 없이 추가만)
|
|
const soil = ADDON_SPECS.soil_guard;
|
|
const wall = ADDON_SPECS.retaining_wall;
|
|
const soilOptions = {
|
|
form: "돌쌓기(찰)",
|
|
height_m: 2,
|
|
tier_1_form: "콘크리트",
|
|
tier_1_height: 2,
|
|
tier_2_form: "돌망태",
|
|
tier_2_height: 1.2,
|
|
};
|
|
const soilState = spec.readState(soil, soilOptions);
|
|
out.roundTrip = {
|
|
items: Object.fromEntries(
|
|
Object.entries(ADDON_SPECS).map(([k, s]) => [k, s.containers[0].items.map((i) => i.id)]),
|
|
),
|
|
soilState: soilState.tier,
|
|
soilBack: spec.writeOptions(soil, soilState),
|
|
wallBack: spec.writeOptions(wall, { tier: [{ height: "1.8" }] }),
|
|
emptyBox: spec.writeOptions(soil, { tier: [{}] }),
|
|
notMainSpecs: Object.keys(ADDON_SPECS).filter((k) => k in STRUCTURE_SPECS),
|
|
};
|
|
|
|
// ② 형상 — 정본 → 벽 제원 → 횡단 단
|
|
const fixture = JSON.parse(
|
|
fs.readFileSync(path.join(__dirname, "fixtures", "b06_73_4_body_guard_sections.json"), "utf8"),
|
|
);
|
|
const base = fixture.cross_sections.find((s) => Math.abs(s.chainage_m - 180) < 0.6);
|
|
const names = new Map([
|
|
["soil_guard", "흙막이"],
|
|
["retaining_wall", "옹벽"],
|
|
]);
|
|
function shape(typeId, options) {
|
|
const [wallSpec] = wallSpecsFrom(
|
|
[{ structure_id: "t", type_id: typeId, chainage_m: 180, start_m: 170, end_m: 190, options }],
|
|
names,
|
|
);
|
|
const section = JSON.parse(JSON.stringify(base));
|
|
section.revetment = { ...wallSpec, side: "우" };
|
|
const layout = computeRevetmentLayout(section, null);
|
|
return {
|
|
tiers: wallSpec.tiers,
|
|
extras: wallSpec.extras,
|
|
requested: layout?.requestedTiers ?? null,
|
|
walls: (layout?.walls ?? []).map((w) => ({ form: w.form, pure: r3(w.height + 0.5) })),
|
|
};
|
|
}
|
|
out.soil2 = shape("soil_guard", soilOptions);
|
|
out.wall1 = shape("retaining_wall", { height_m: 2.5, tier_1_height: 1.8 });
|
|
out.emptyBox = shape("soil_guard", { form: "돌망태", height_m: 2, tier_1_form: "" });
|
|
out.legacy = shape("soil_guard", { form: "돌망태", height_m: 2, tiers: 2 });
|
|
out.none = shape("retaining_wall", { height_m: 2.5 });
|
|
process.stdout.write(JSON.stringify(out));
|