Files
Aislo/resources/tester/helper_323_6_change.cjs
T
eomsangdonandClaude Opus 5.5 529baca3ff feat(구조물표): 323-6 바꿈 한 길 — 바뀜 신호 하나(구조물 초안도 설계 가게 · watchDrafts) · 종류 바꿈 표 규칙(swapsInPlace · E · F 점형 ↔ 구간형 = 지우고 같은 기준 측점에 새로) · 조용한 되돌림 없앰(알림) · 그리기가 조정값 안 만듦 · replayDraftPipeOptions 걷음
- 구조물 초안 쓰기 = useDesignStore().set("structures")(칸 그대로) → 관 초안과 같은 구독 · 횡단 보기 watchDrafts(구조물 = 늘 · 관 = 자리 · 종류 · 구간 · 잇기가 바뀔 때만 · 옵션만은 폼 길이 그 카드만 · 카드 줌 · 팬 지킴) · 옛 되부름 onStructuresChanged 걷음
- 종류 바꿈 = 표(catalog) swapsInPlace — 정본 다름 · 구조물 자리꼴 다름(E · F) = 지우고 같은 기준 측점에 새로(구간 = 기본 길이) · 같으면 종류 키만 · 막히면 옛 기록 · 옛 종류 폼 + 알림(전엔 [수정] 조기 반환 → 조용히 되돌림 · 드롭다운만 새 종류)
- syncApplied = 사용자가 조작한 세션이 있을 때만 깎음(카드 그리기가 자동 배치를 조정값으로 굳혀 [저장]으로 내보내던 것)
- replayDraftPipeOptions 걷음 — 그림 자료는 형상 얹기(초안 현황) · 다단 조정값은 조정 세션이 정본
- 시험: test_323_6_change(신호 · 거르기 · 표 규칙 · 그리기 · 걷음) · test_319 점형 ↔ 구간형 · 막힘 알림 · 되얹기 시험 = 형상 얹기로 · 옛 기대 글 고침

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

83 lines
3.5 KiB
JavaScript

/* PLAN 323-6 바꿈 한 길 헬퍼 — 진짜 `B05_Profile_Api_Structures.ts`(구조물 초안) · `design_store.ts`(바뀜 신호)를
* 그 자리에서 트랜스파일해 Node 로 돌림(세션만 흉내) · 결과 = 표준출력 JSON. 짝 = `test_323_6_change.py`.
*/
const fs = require("fs");
const path = require("path");
const ROOT = path.join(__dirname, "..", "..");
const ts = require(path.join(ROOT, "config", "node_modules", "typescript"));
const CATALOG = require("./helper_322_catalog_module.cjs");
const memory = new Map();
const store = {
getItem: (k) => (memory.has(k) ? memory.get(k) : null),
setItem: (k, v) => memory.set(k, String(v)),
removeItem: (k) => memory.delete(k),
key: (i) => [...memory.keys()][i] ?? null,
get length() {
return memory.size;
},
};
globalThis.window = { sessionStorage: store, localStorage: store, addEventListener: () => {} };
globalThis.sessionStorage = store;
globalThis.localStorage = store;
const cache = new Map();
function load(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 need = (spec) => {
if (CATALOG.isCatalogRequest(spec)) return CATALOG;
if (spec.startsWith("@ui/")) return new Proxy({}, { get: () => () => {} });
if (spec.startsWith("@config/")) return load(path.join(ROOT, "config", `${spec.slice(8)}.ts`));
if (spec.startsWith(".")) return load(path.join(path.dirname(full), `${spec}.ts`));
return require(spec);
};
new Function("exports", "module", "require", js)(box.exports, box, need);
return box.exports;
}
const api = load(path.join(ROOT, "B05_Profile", "B05_Profile_Api_Structures.ts"));
const { useDesignStore } = load(path.join(ROOT, "A00_Common", "design", "design_store.ts"));
const heard = { structures: [], pipes: [] };
const shop = useDesignStore("P", null);
for (const key of ["structures", "pipes"]) shop.subscribe(key, (value) => heard[key].push(value));
const wall = { structure_id: "w1", type_id: "retaining_wall", chainage_m: 10 };
api.writePendingStructures("P", [wall]);
api.writePendingStructures("P", null);
api.writePendingStructures("P", [wall]);
// 바뀜 신호 거르기 — 구조물 = 늘 · 관 = 자리 · 종류 · 구간 · 잇기가 바뀔 때만(옵션만 = 폼 길이 그 카드)
const status = load(path.join(ROOT, "A00_Common", "design", "design_structure_status.ts"));
let fired = 0;
const off = status.watchDrafts("Q", () => (fired += 1));
const shopQ = useDesignStore("Q", null);
shopQ.set("pipes", [{ chainage_m: 10, source: "user", options: { a: 1 } }]);
shopQ.set("pipes", [{ chainage_m: 10, source: "user", options: { a: 2 } }]);
shopQ.set("pipes", [{ chainage_m: 12, source: "user", options: { a: 2 } }]);
shopQ.set("pipes", [{ chainage_m: 12, source: "user", facility: "box_culvert" }]);
shopQ.set("structures", []);
off();
shopQ.set("structures", null);
process.stdout.write(
JSON.stringify({
watch: fired,
heard: heard.structures.map((v) => (v ? v.length : null)),
pipesHeard: heard.pipes.length,
read: api.readPendingStructures("P"),
key: memory.has("aislo:draft:structures:P"),
swaps: [
"mirror>curb",
"mirror>guardrail",
"refuge>work_yard",
"pipe>box_culvert",
"pipe>revetment",
"cross_underdrain>pipe",
].map((pair) => [pair, CATALOG.swapsInPlace(...pair.split(">"))]),
}),
);