지움
- flushDesignStore(design_store · 부름 0) — 시험 344-4 의 flush 대조 한 줄도
- b_page_state 옛 세션 열쇠 옮김(legacy · migrate) · b_project_switch 옛 키 머리
— 옛 열쇠는 세션 저장소(탭 닫으면 사라짐) · 지금 코드가 안 씀 · storage · DB 에 없음
· 시험 290-1 · 401 · 384-1 의 옛 키 줄 뺌
- 시험만 부르던 TS — planFootprint(346-2 거울은 footprintRecord + slopePieces 로 그대로)
· shiftSegment · shiftMovingPoints(쉬프트 단추는 09-02 지움 · min_cover_guard 쉬프트 시험 뺌)
· dropStationsNear(test_b05_station_merge.mjs 지움) · createIrregularStationsSection(부름 0)
· generalStations(234-1 은 기본 맞춤 값으로 같은 것 잼) · sameSummaryItem
- test_b05_b06_save_roundtrip + helper_b05_save_payload 둘 — 프로젝트 936be972 storage 없어 늘 skip
· 같은 저장 왕복은 test_472_6_design_save(창구 원자성) · test_449_save_pipes(관 PUT)
· test_238_1_save_keeps_structure_stations(구조물 측점)가 잼
남김
- migrateLegacyStations — 부르는 곳 있음(design_view_profile_sections) · storage 에 비정규 측점 남음
- common_util_excavation 셋 — 지금은 운영이 부름(design_calc_node)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
90 lines
3.2 KiB
JavaScript
90 lines
3.2 KiB
JavaScript
/* 290-1 다른 프로젝트 열면 그 밖 프로젝트 캐시 지움 — 진짜 TS(b_page_state · b_project_switch)를
|
|
* 가짜 저장소 위에서 돌려 JSON 으로 냄(공용 storage · 브라우저 안 씀). */
|
|
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 = (rel, requireStub) => {
|
|
const js = ts.transpileModule(fs.readFileSync(path.join(ROOT, rel), "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const exports = {};
|
|
new Function("exports", "require", "window", js)(exports, requireStub, global.window);
|
|
return exports;
|
|
};
|
|
|
|
function fakeStorage() {
|
|
const map = new Map();
|
|
return {
|
|
get length() {
|
|
return map.size;
|
|
},
|
|
key: (i) => [...map.keys()][i] ?? null,
|
|
getItem: (k) => (map.has(k) ? map.get(k) : null),
|
|
setItem: (k, v) => map.set(k, String(v)),
|
|
removeItem: (k) => map.delete(k),
|
|
dump: () => Object.fromEntries(map),
|
|
};
|
|
}
|
|
global.window = { sessionStorage: fakeStorage(), localStorage: fakeStorage() };
|
|
|
|
const pageState = load("A00_Common/b_page_state.ts", () => ({}));
|
|
const asked = [];
|
|
const purged = [];
|
|
let answer = true;
|
|
const sw = load("A00_Common/b_project_switch.ts", (id) => {
|
|
if (id.includes("b_page_state")) return pageState;
|
|
if (id.includes("b_asset_cache")) return { purgeOtherProjects: async (p) => purged.push(p) };
|
|
return {
|
|
showConfirmDialog: async (msg, ok, cancel) => (asked.push([msg, ok, cancel]), answer),
|
|
};
|
|
});
|
|
|
|
const A = "aaaa1111";
|
|
const B = "bbbb2222";
|
|
const C = "cccc3333";
|
|
const SEED = {
|
|
[`aislo:draft:structures:${A}`]: '[{"id":1}]',
|
|
[`aislo:draft:crossw:${A}:12`]: '{"10":1}',
|
|
[`aislo:result:latest:${A}`]: '{"r":1}',
|
|
[`aislo:draft:structures:${B}`]: '[{"id":2}]',
|
|
[`aislo:result:section-detail:${B}:7`]: '{"d":1}',
|
|
[`aislo:result:latest:${C}`]: '{"r":3}',
|
|
[`aislo:draft:pipes:${C}`]: "{}", // 빈 초안 = 고침 없음
|
|
[`b09:page-cache:${C}`]: "1", // 등록표 밖 페이지 칸
|
|
"aislo.otp-pending": "x", // 프로젝트와 무관
|
|
};
|
|
const seed = (extra = {}) => {
|
|
global.window.sessionStorage = fakeStorage();
|
|
Object.entries({ ...SEED, ...extra }).forEach(([k, v]) =>
|
|
global.window.sessionStorage.setItem(k, v),
|
|
);
|
|
asked.length = 0;
|
|
purged.length = 0;
|
|
};
|
|
const keys = () => Object.keys(global.window.sessionStorage.dump()).sort();
|
|
const nameOf = async (id) => `이름-${id}`;
|
|
global.window.localStorage.setItem(`aislo:pref:routeedit-view:${A}`, "{}");
|
|
|
|
(async () => {
|
|
const out = {};
|
|
seed();
|
|
answer = true;
|
|
await sw.enterProject(B, nameOf);
|
|
out.drop = { keys: keys(), asked: [...asked], purged: [...purged] };
|
|
|
|
seed();
|
|
answer = false;
|
|
await sw.enterProject(B, nameOf);
|
|
out.keep = { keys: keys(), asked: asked.length };
|
|
|
|
seed({ "aislo:entered-project": B });
|
|
await sw.enterProject(B, nameOf);
|
|
out.same = { keys: keys(), asked: asked.length, purged: purged.length };
|
|
|
|
out.pref = global.window.localStorage.getItem(`aislo:pref:routeedit-view:${A}`);
|
|
out.plan = sw.planProjectPurge(SEED, B).draftProjects;
|
|
process.stdout.write(JSON.stringify(out));
|
|
})();
|