Files
Aislo/resources/tester/helper_54_10_soil_tiers.cjs
T
eomsangdonandClaude Opus 5.5 bbd6254892 feat(구조물표): 322-1 부품 상자 · 표 읽기 — 목록 · 측점 · 카드 이름 · 형상 고르기 · 3D 몸체 · 알약 띠가 종류 키 · 군 글자 · 자리꼴 · managed_by 대신 구조물 표(catalog) 한 줄을 읽음 · 코드 숨김 목록 걷음 · ★ 넷 + 관 공식 한 벌
- 부품 상자 common_util_structure_parts.json(갈래마다 부품 · 읽는 칸 · 자리꼴 · 정본 · 42종 처음값) · 표 읽기 common_util_structure_catalog.ts / .py 짝(정의 반영 ⊕ 처음값 ⊕ 부품 끔) · 거울 시험 test_322_1_catalog_mirror
- 목록: pickGroups 군 차례 = 구조물군 열쇠 · 페이지 거르기 listPick(B05 both · B06 both + b06) · HIDDEN_PICK_GROUPS · HIDDEN_PICK_TYPES · pickable 걷음(옛 대피 셋 asRoad 그대로)
- 측점: structureStationMarks · pipeStationMarks · is_station_planting_type · resolve_extra_stations = 표 횡단도(anchor · span3 · none)
- 카드 이름: cardTitle / card_title 한 공식(빈칸 = 그 종류 정의 기본값) · 표시 이름이 정의 관종도 앎
- 형상: 벽 = shape wall(형태 = 형상칸.form · 물빼기 = 형상칸.weep) · 포장 = shape pavement(「사용 중」 거르기 없앰) · 맹암거 · 사토 · 관 지점 시설 세트 = shape
- 3D 몸체 = 그림 자료 주인 종류의 표 3D 부품 · 알약 띠 = 표 자리꼴 구간(관 지점 시설은 알약만)
- ★1 노출형 · 개거 횡단도 none · ★2 쇄석 화면에서도 포장층 · ★3 기슭막이 표 자리꼴 interval(정의 파일 그대로) · ★4 코드 숨김 10종 list hidden · ★5 관 빈칸 D800 → 정의 기본 D1000
- 옛 시험: 도움 파일 로더 27개가 표 모듈 공용 한 벌(helper_322_catalog_module) 씀 · 기대값 고침(272_1 · b05_extra_stations · roundtrip · 314 · 52_7 · walls 거울 · wall_drain_pipe)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
2026-10-14 15:09:45 +09:00

230 lines
8.2 KiB
JavaScript

/* 다단 흙막이 ↔ 흙막이 컨테이너(PLAN 54-10) 단위검증 헬퍼 — TS 를 그 자리에서 트랜스파일해 Node 로 돌린다.
* ① 폼 → 다단 그림(`applyPipeOptionsToCache`) ② 밖에서 정한 개수보다 많은 컨테이너 값은 가리기만(`createSpecForm`).
* 결과는 표준출력에 JSON 한 벌. 짝 = `test_54_10_soil_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();
// ── 화면 그릇 흉내 — 태그 · 클래스 · data 만 ─────────────────────────────────
class FakeNode {
constructor(tag) {
this.tagName = tag.toUpperCase();
this.children = [];
this.dataset = {};
this.style = {};
this._classes = new Set();
this._text = "";
this.value = "";
const self = this;
this.classList = {
add: (...n) => n.forEach((c) => self._classes.add(c)),
remove: (...n) => n.forEach((c) => self._classes.delete(c)),
toggle: (c, f) =>
(f ?? !self._classes.has(c)) ? self._classes.add(c) : self._classes.delete(c),
contains: (c) => self._classes.has(c),
};
}
set className(v) {
this._classes = new Set(String(v).split(/\s+/).filter(Boolean));
}
set textContent(v) {
this._text = String(v);
this.children = [];
}
get textContent() {
return this._text + this.children.map((c) => c.textContent ?? "").join("");
}
append(...kids) {
kids.forEach((k) => this.children.push(typeof k === "string" ? { textContent: k } : k));
}
replaceChildren(...kids) {
this.children = [];
this.append(...kids);
}
add(kid) {
this.children.push(kid);
}
setAttribute(n, v) {
this[n] = v;
}
addEventListener() {}
closest() {
return null;
}
matches(sel) {
return sel.split(",").some((s) => {
s = s.trim();
return s.startsWith(".") ? this._classes.has(s.slice(1)) : this.tagName === s.toUpperCase();
});
}
querySelectorAll(sel) {
const found = [];
const walk = (n) =>
(n.children ?? []).forEach((k) => {
if (k.matches?.(sel)) found.push(k);
walk(k);
});
walk(this);
return found;
}
querySelector(sel) {
return this.querySelectorAll(sel)[0] ?? null;
}
}
globalThis.document = { createElement: (t) => new FakeNode(t) };
globalThis.queueMicrotask = (fn) => fn(); // 폼 되돌림을 바로 받아 봄
globalThis.Option = function (text, value) {
const o = new FakeNode("option");
o.textContent = text;
o.value = value;
return o;
};
const toasts = [];
const STUBS = {
"@ui/ui_template_elements": { showToast: (msg) => toasts.push(msg) },
"@config/config_frontend": { FORD_MANNING_N: 0.03, FORD_SLOPE: 0.02 },
"./ui_template_checkbox.css": {},
"./B06_Section_UI_Page_Ford_Controls": {
applyFordFormOptions: () => {},
applyBoxFormOptions: () => {},
},
"../../B05_Profile/B05_Profile_UI_Structures_Summary_Row": { buildSummaryRow: () => null },
};
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 },
}).outputText;
const box = { exports: {} };
cache.set(full, box.exports);
const localRequire = (request) => {
if (CATALOG.isCatalogRequest(request)) return CATALOG;
if (STUBS[request]) return STUBS[request];
if (request.startsWith("@util/"))
return loadTs(path.join(ROOT, "common_util", `${request.slice(6)}.ts`));
return loadTs(path.join(path.dirname(full), `${request}.ts`));
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
cache.set(full, box.exports);
return box.exports;
}
const out = {};
// ── ① 폼 → 다단 그림 ──────────────────────────────────────────────────────
const { applyPipeOptionsToCache } = loadTs(
path.join(ROOT, "B06_Section", "B06_Section_UI_Page_Pipe_Options.ts"),
);
const adjusts = {};
const updates = [];
const tiers = [];
const overrides = [];
const section = {
chainage_m: 100,
culvert: { diameter_m: 1, hidden_pipe: false, inlet: {}, outlet: { revet_form: "돌쌓기(찰)" } },
};
const ctx = {
detail: () => ({ cross_sections: [section] }),
ford: {},
box: {},
revetOffset: {
adjustFor: (_s, role) => adjusts[role] ?? { x: 0, d: null, h: null, m: null },
update: (_c, role, patch) => {
updates.push({ role, ...patch });
const now = adjusts[role] ?? { x: 0, d: null, h: null, m: null };
const m = patch.m === undefined ? now.m : patch.m;
// 기하 되받기(syncApplied) 흉내 — 형태별 높이 한도 없음(54-42 · 입력 높이 그대로)
const h = patch.h === undefined ? now.h : patch.h;
adjusts[role] = { ...now, h, m };
},
},
structureSpan: {
tierValuesFor: () => ({ lengthM: 10, beforeM: 5, afterM: 5 }),
updateTier: (_s, key, patch) => tiers.push({ key, ...patch }),
},
soilTiers: () => 2,
overrideOptions: (_c, values) => overrides.push(values),
refreshCard: () => {},
};
applyPipeOptionsToCache(ctx, 100, {
soil_add_1_form: "콘크리트",
soil_add_1_height: 1.8,
soil_add_1_length: 8,
soil_add_1_before: 3,
soil_add_1_after: 5,
soil_add_2_form: "돌쌓기(메)",
soil_add_2_height: 2.5,
soil_add_3_height: 1.2, // 지형이 못 세운 단 — 그림에 안 감
});
out.filled = { updates: updates.splice(0), tiers: tiers.splice(0), overrides: overrides.splice(0) };
out.toasts = toasts.splice(0);
// 같은 값을 다시 보내면 다시 그리지 않음
applyPipeOptionsToCache(ctx, 100, {
soil_add_1_form: "콘크리트",
soil_add_1_height: 1.8,
soil_add_2_form: "돌쌓기(메)",
soil_add_2_height: 2.5,
});
out.same = { updates: updates.splice(0), tiers: tiers.splice(0) };
// 그림이 안 서는 높이(0 이하)만 하한 0.1 에서 멈춰 폼에 되돌림 · 토스트 없음(54-51)
applyPipeOptionsToCache(ctx, 100, {
soil_add_1_form: "콘크리트",
soil_add_1_height: 0,
soil_add_2_form: "돌쌓기(메)",
soil_add_2_height: 2.5,
});
out.floor = { updates: updates.splice(0), overrides: overrides.splice(0) };
out.toasts.push(...toasts.splice(0));
// 비운 칸 = 자동(높이 · 형태) · 구간값은 그대로
applyPipeOptionsToCache(ctx, 100, {});
out.cleared = { updates: updates.splice(0), tiers: tiers.splice(0) };
// 독립 기슭막이(관 숨김)는 다단을 안 만짐
section.culvert.hidden_pipe = true;
applyPipeOptionsToCache(ctx, 100, { soil_add_1_height: 1.0 });
out.hidden = updates.splice(0);
// ── ② 개수보다 많은 컨테이너 값은 가리기만 · 값은 남김 ───────────────────────
const { createSpecForm } = loadTs(
path.join(ROOT, "A00_Common", "design", "design_structure_form.ts"),
);
const { PIPE_SPEC } = loadTs(path.join(ROOT, "A00_Common", "design", "design_structure_pipe.ts"));
let count = 1;
const form = createSpecForm(null, { count: (c) => (c.id === "soil_add" ? count : undefined) });
form.write(PIPE_SPEC, {
pipe_diameter_mm: 1000,
soil_add_1_form: "콘크리트",
soil_add_2_form: "돌망태",
soil_add_2_height: 1.5,
chute_add_1_structure: "돌붙임",
});
// 상자 이름표 단추(136-3) — 글 「삭제」 + title
out.remove = form.root
.querySelectorAll("button")
.filter((b) => b.dataset.specRemove)
.map((b) => ({ id: b.dataset.specRemove, text: b.textContent, title: b.title }));
const boxes = () =>
form.root.children.filter((k) => k.dataset?.specContainer === "soil_add").length;
const soilKeys = () =>
Object.keys(form.read())
.filter((k) => k.startsWith("soil_add_"))
.sort();
out.form = { shown1: boxes(), keys1: soilKeys() };
count = 0; // 단 수 0 저장 — 옛 흙막이 값도 남음
form.recount();
out.form.shown0 = boxes();
out.form.keys0 = soilKeys();
count = 3;
form.recount();
out.form.shown3 = boxes();
out.form.keys3 = soilKeys();
process.stdout.write(JSON.stringify(out));