Files
Aislo/resources/tester/helper_design_profile_single.cjs
T
eomsangdonandClaude Opus 5.5 002d0e85ac refactor(387-1): 설계 화면 세션 직접 접근 → 등록부 · 프로젝트 없는 열쇠 걷음
- 되돌리기 사진 = 연 프로젝트 초안 칸만(projectStateKeys) · 옛 b05/b06 접두 지움
- 관 자리 b05:pipes 걷음 → 가게 pipes 초안으로 되돌림
- 조정창 · 연동 · 세월교 · BOX 세션 맵 = readByKey · writeByKey
- 노선 편집 횡단 반폭 = routeStateKeys · 계획고 옛 키(프로젝트 없음) 안 받음
- 새 test_384_1_session_keys · 사진첩 시험 헬퍼 = 진짜 등록부 부름

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
2026-10-17 17:29:17 +09:00

80 lines
3.1 KiB
JavaScript

/* 종단도 한 벌(계획서 24-2c) 단위검증 헬퍼 — 계획고 초안이 등록부 칸(`alignment-draft`)으로
* 옮겨졌는지 · 옛 키 값을 옮겨 받는지 · 되돌리기 사진이 새 칸을 찍는지를 Node 로 돌린다.
* `A00_Common/design/design_store.ts` · `B05_Profile_UI_Profile_History.ts` 를 그 자리에서
* 트랜스파일한다.
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
function memoryStorage() {
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;
},
keys: () => [...map.keys()],
};
}
const session = memoryStorage();
const local = memoryStorage();
globalThis.window = { sessionStorage: session, localStorage: local };
globalThis.sessionStorage = session;
const cache = new Map();
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 (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
return require(request);
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
cache.set(full, box.exports);
return box.exports;
}
const { useDesignStore } = loadTs(path.join(ROOT, "A00_Common", "design", "design_store.ts"));
const history = loadTs(path.join(ROOT, "B05_Profile", "B05_Profile_UI_Profile_History.ts"));
const out = {};
// ① 옛 키(프로젝트 없음)에 남은 초안 — 안 받음(387-1 · 다른 프로젝트 초안일 수 있음).
local.setItem("frd_current_project_id", "p-1");
session.setItem(
"b05-profile-alignment-draft:7",
JSON.stringify({ station_offsets: { "20.000": 0.3 }, curve_radii: {} }),
);
out.adopted = useDesignStore(null, 7).get("alignmentDraft");
out.keysAfterAdopt = session.keys();
// ② 쓰기는 새 칸으로 — 프로젝트를 준 가게와 안 준 가게가 같은 칸.
useDesignStore("p-1", 7).set("alignmentDraft", {
station_offsets: { "40.000": 0.1 },
curve_radii: {},
});
out.sameSlot = useDesignStore(null, 7).get("alignmentDraft");
// ③ 되돌리기가 새 칸을 사진 찍는다 — 편집 한 걸음을 쌓고 되돌리면 앞 값이 돌아온다.
const undoStack = history.createProfileHistory(() => undefined);
useDesignStore("p-1", 7).set("alignmentDraft", {
station_offsets: { "40.000": 0.2 },
curve_radii: {},
});
undoStack.record();
out.beforeUndo = useDesignStore("p-1", 7).get("alignmentDraft");
out.undone = undoStack.undo();
out.afterUndo = useDesignStore("p-1", 7).get("alignmentDraft");
process.stdout.write(JSON.stringify(out));