Files
Aislo/resources/tester/helper_52_structure_spec_box.cjs
T
eomsangdonandClaude Opus 5.5 1a9055444f fix(box): 본체 「사용자 입력」 빈 칸 저장 뒤 다시 열어도 사용자 입력 · B06 다리가 유입·유출 구조 글 유지(52-19)
- 규격 판정(bodyOf): 가로 · 세로 중 손 값 하나라도 있으면 사용자 입력 + 빈 칸은 빈 채
- 둘 다 비면 표시 키 body_custom 만 저장 · 폼 칸 목록에 넣어 숫자 채우면 지워짐
- B06 폼→조정창 다리: 흙막이 · 날개벽 글을 있음/없음으로 바꿔 적던 것 → 글 그대로
- 시험: 52-2 헬퍼 한 칸 · 두 칸 빈 경우 · ui_checks 52-19

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4uKaV4ZBhsJN4GHG7yRj4
2026-10-06 01:43:24 +09:00

70 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* 박스암거 명세 단위검증 헬퍼(PLAN 52-2) — `design_structure_spec.ts` · `design_structure_box.ts` 를
* 그 자리에서 트랜스파일해 Node 로 돌림(꼴만 import). 결과 = JSON 한 벌.
* 인자 `names` 면 박스암거 이름 표(정의 `종류.box_culvert.이름`)만 냄.
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
const load = (file) => {
const src = fs.readFileSync(path.join(ROOT, "A00_Common", "design", file), "utf8");
const js = ts.transpileModule(src, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
new Function("exports", "module", "require", js)(box.exports, box, require);
return box.exports;
};
const s = load("design_structure_spec.ts");
const b = load("design_structure_box.ts");
const SPEC = b.BOX_SPEC;
if (process.argv[2] === "names") {
process.stdout.write(JSON.stringify(s.nameTable(SPEC)));
process.exit(0);
}
/** 화면이 하는 차례 그대로 — 옛 값 정리 → 명세 읽기 → 본체 칸 되찾기 → 저장 옵션. */
const roundTrip = (options, edit) => {
const state = s.readState(SPEC, b.boxOptionsIn(options));
Object.assign(state.body[0], b.bodyOf(options));
edit?.(state);
return { state, out: { ...s.writeOptions(SPEC, state), ...b.bodyOptions(state.body[0]) } };
};
const body = SPEC.containers.find((c) => c.id === "body");
const width = body.items.find((i) => i.id === "width");
const old = { body_width_m: 3, body_height_m: 2.5, wing_in: "있음", wing_in_length_m: 2 };
const out = {
containers: SPEC.containers.map((c) => [c.id, c.title, c.required]),
links: SPEC.containers.map((c) => s.linkOf(c, 1)),
sizes: body.items[0].choices.map((c) => c.value),
structures: SPEC.containers[1].items[0].choices.map((c) => c.value),
customHidden: s.branchOf(width, { size: "2.0×2.0" }),
customShown: s.branchOf(width, { size: "사용자 입력" }),
old: roundTrip(old),
preset: roundTrip({ body_width_m: 2, body_height_m: 2, wing_out: "없음" }),
toPreset: roundTrip(old, (st) => {
st.body[0].size = "3.0×3.0";
st.outlet[0].structure = "흙막이";
}),
toCustom: roundTrip({ body_width_m: 2, body_height_m: 2 }, (st) => {
st.body[0].size = "사용자 입력";
st.body[0].width = "2.4";
st.body[0].height = "1.8";
}),
blank: roundTrip({}),
// 52-19 — 사용자 입력에서 한 칸 · 두 칸 비우고 저장 → 다시 열기
oneBlank: roundTrip({ body_height_m: 2.5 }),
bothBlank: roundTrip({ body_width_m: 2, body_height_m: 2 }, (st) => {
st.body[0].size = "사용자 입력";
st.body[0].width = "";
st.body[0].height = "";
}),
keys: s.specKeys(SPEC),
retired: SPEC.retired,
};
out.bothBlankAgain = roundTrip(out.bothBlank.out);
process.stdout.write(JSON.stringify(out));