Files
Aislo/resources/tester/helper_52_structure_spec_box.cjs
T
eomsangdonandClaude Opus 5.5 281c71b55b refactor(logic): 348-1 순수 계산 TS 49 파일 <페이지>/logic/ 로 옮김 — 이름 앞머리 그대로 · 동작 고침 없음
- 옮김: 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
2026-10-16 13:44:50 +09:00

75 lines
3.2 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: {} };
// 같은 폴더 명세(흙막이 양식 · 65-2)는 그 자리에서 옮김
const near = (m) =>
m.startsWith("./")
? load(path.posix.join(path.posix.dirname(file), `${m.slice(2)}.ts`))
: require(m);
new Function("exports", "module", "require", js)(box.exports, box, near);
return box.exports;
};
const s = load("logic/design_structure_spec.ts");
const b = load("logic/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));