- design_save 차례 = 노선 → 관 → 구조물 → 계획고(옛 노선 칸 → 새 노선) → 암거 옵션 → 상단측 → 횡단(carryStationDrafts 뒤 저장) · 잠금 막 = [저장] 하나 · 실패 = 멈춤 · 초안 그대로 · 오류 한 줄 - [확정] 중 노선이 바뀌면 노선만 저장하고 다시 세움(새 노선으로 다시 [확정]) - _RouteEdit_Apply = 노선 저장 이음(편집기 등록부 · pendingRouteSave · saveRouteDraft · carryAfterRouteSave · routeSaveSummary · rebuildAfterRouteSave) · 단추 듣기 없음 - 결과 한 줄 = 관 지킴 · 새 교차 관 · 오목 보충 · 구조물 옮김 · 멀어짐 · 노선 밖 고침(서버 cross_dropped + 화면) · 배수유역 낡음 - RE_Chrome [노선 반영] 지움 · [반영 전으로] → [저장 전으로] · replanRoute 본문 = RouteSaveBody - 시험: test_design_store_save 차례 넷 더함 · 꼴 시험 셋 고쳐 씀 · 323_9 대역 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmC34fsxxbweEG3RUjs3Mn
134 lines
5.0 KiB
JavaScript
134 lines
5.0 KiB
JavaScript
/* PLAN 323-9 ① — B06 [저장] 뒤 카드 = 서버 새 상세. 진짜 `design_save.ts`(저장 차례) ·
|
|
* `B06_Section_UI_Page_Persist.ts`(횡단 뒤처리) · `B06_Section_Section_Store.ts`(상세 캐시)를 Node 로 돌림.
|
|
* 서버 창구만 가짜 — 상세는 저장 전(옛 자리) · 저장 뒤(새 자리) 두 벌.
|
|
*/
|
|
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 memory = () => {
|
|
const map = new Map();
|
|
return {
|
|
getItem: (key) => (map.has(key) ? map.get(key) : null),
|
|
setItem: (key, value) => map.set(key, String(value)),
|
|
removeItem: (key) => map.delete(key),
|
|
key: (index) => [...map.keys()][index] ?? null,
|
|
get length() {
|
|
return map.size;
|
|
},
|
|
};
|
|
};
|
|
globalThis.window = { sessionStorage: memory(), localStorage: memory() };
|
|
globalThis.sessionStorage = globalThis.window.sessionStorage;
|
|
|
|
const calls = [];
|
|
let server = "옛 자리 4+5";
|
|
const detail = () => ({ cross_sections: [], longitudinal: { stations: [] }, tag: server });
|
|
const B06 = path.join(ROOT, "B06_Section");
|
|
const STUBS = {
|
|
"@ui/ui_template_elements": {
|
|
showToast: (_text, kind) => calls.push(`toast:${kind}`),
|
|
showLoadingOverlay: () => calls.push("overlay:on"),
|
|
hideLoadingOverlay: () => calls.push("overlay:off"),
|
|
},
|
|
// 노선 저장(346-3) — 이 시험은 노선이 그대로인 [저장]만 봄
|
|
[path.join(ROOT, "B05_Profile", "B05_Profile_UI_RouteEdit_Apply.ts")]: {
|
|
pendingRouteSave: async () => null,
|
|
},
|
|
[path.join(B06, "B06_Section_Api_Fetch.ts")]: {
|
|
fetchSectionDetail: async () => (calls.push(`fetch:${server}`), detail()),
|
|
saveSections: async () => calls.push("cross:save"),
|
|
confirmSections: async () => calls.push("cross:confirm"),
|
|
},
|
|
};
|
|
|
|
const cache = new Map();
|
|
function loadTs(file) {
|
|
const full = path.resolve(file);
|
|
if (STUBS[full]) return STUBS[full];
|
|
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 (STUBS[request]) return STUBS[request];
|
|
if (CATALOG.isCatalogRequest(request)) return CATALOG;
|
|
if (request.endsWith(".json")) return require(path.join(path.dirname(full), request));
|
|
if (request.endsWith(".css")) return {};
|
|
if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
|
|
if (request.startsWith("@")) return new Proxy({}, { get: () => () => undefined });
|
|
return require(request);
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
cache.set(full, box.exports);
|
|
return box.exports;
|
|
}
|
|
|
|
const { saveDesign, savingDesign } = loadTs(
|
|
path.join(ROOT, "A00_Common", "design", "design_save.ts"),
|
|
);
|
|
const { crossSaveParts } = loadTs(path.join(B06, "B06_Section_UI_Page_Persist.ts"));
|
|
const { loadSectionDetail } = loadTs(path.join(B06, "B06_Section_Section_Store.ts"));
|
|
|
|
(async () => {
|
|
const P = "p1";
|
|
const R = 7;
|
|
// 횡단 보기 = 바뀜 신호마다 `refreshDetailForStructures` 와 같은 차례(최신만 · 저장 도중 안 그림)
|
|
let shown = null;
|
|
let seq = 0;
|
|
const refresh = async () => {
|
|
const mine = ++seq;
|
|
if (savingDesign(P)) return calls.push("refresh:skip");
|
|
const got = await loadSectionDetail(P, R);
|
|
if (mine === seq) shown = got.tag;
|
|
};
|
|
await refresh(); // 저장 전 화면(캐시 = 옛 서버)
|
|
const before = shown;
|
|
const ctx = {
|
|
projectId: P,
|
|
routeId: () => R,
|
|
detail: () => null,
|
|
context: () => null,
|
|
standardValues: () => undefined,
|
|
flushCulvertOptions: async () => undefined,
|
|
patchSources: () =>
|
|
Object.fromEntries(
|
|
["rockOffsets", "cutSlopeRatios", "stationWidths", "inletStructures", "basinAdjustments"]
|
|
.concat(["revetAdjusts", "extraCounts", "extraSpans", "fordAdjusts", "boxAdjusts"])
|
|
.concat(["linkFlags"])
|
|
.map((key) => [key, new Map()]),
|
|
),
|
|
reconcileDesigns: async () => undefined,
|
|
redraw: refresh,
|
|
};
|
|
const parts = crossSaveParts(ctx);
|
|
calls.length = 0;
|
|
const savingSeen = [];
|
|
const ok = await saveDesign({
|
|
projectId: P,
|
|
routeId: () => R,
|
|
steps: {
|
|
// 관 · 구조물 초안이 정본으로 나가며 가게가 바뀜 → 바뀜 신호(저장 도중)
|
|
structures: async () => {
|
|
server = "새 자리 4+8 · 47+0";
|
|
savingSeen.push(savingDesign(P));
|
|
await refresh();
|
|
},
|
|
...parts.steps,
|
|
},
|
|
cross: (confirm) => parts.cross(confirm),
|
|
done: async () => {
|
|
savingSeen.push(savingDesign(P));
|
|
await parts.done(false);
|
|
},
|
|
failed: (error) => calls.push(`failed:${error}`),
|
|
});
|
|
process.stdout.write(
|
|
JSON.stringify({ ok, before, after: shown, savingSeen, calls, savingIdle: savingDesign(P) }),
|
|
);
|
|
})();
|