Files
Aislo/resources/tester/helper_347_pipe_id_reconcile.cjs
T
eomsangdonandClaude Opus 5.5 38e6b65f37 test(508-1d 빨강 가림 2/2): 모양 다른 헬퍼 일곱 공용 불러오기로 · 공용 불러오기 옵션 둘(target · rewrite)
- 공용 불러오기: target(트랜스파일 대상) · rewrite(트랜스파일 글 손봄 · import.meta) 옵션
- 280_2(import.meta.env.DEV) · 345_4(import.meta.url) = rewrite · 298_3 = target ES2022
- 322_0 = fileStub(경로 가짜 맵 · .css) · 347 = 파일별 진짜 import 목록 · 427_1 · 459 = load(뿌리 기준)
- 풀이 함수 본문 그대로 · 헬퍼 출력 전 · 후 같음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 18:01:55 +09:00

49 lines
2.0 KiB
JavaScript

/* 347 덧 관 고정 id — `reconcilePipes`(되돌리기 · 구조물 폼으로 관 목록이 바뀔 때)가 id 를 따라 옮기는지.
* `B05_Profile_UI_Drainage_Parts.ts` 를 그 자리에서 트랜스파일 · 그 밖 import 는 빈 껍데기(틀 = helper_281_1).
*/
const path = require("path");
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
const ROOT = path.join(__dirname, "..", "..");
const stub = new Proxy(function () {}, { get: () => stub, apply: () => stub });
const TOP = path.join(ROOT, "B05_Profile", "B05_Profile_UI_Drainage_Parts.ts");
// 진짜로 부를 import — 맨 위 = 고름 · 그 밑 = 관 짝 맞춤(472-6) · 그 밖 = 빈 껍데기
const realOf = (full) => (full === TOP ? ["design_selection"] : ["common_util_pipe_match"]);
const { loadTs } = makeLoader({
root: ROOT,
cache: false,
requireFor: (full) => (request) =>
realOf(full).some((name) => request.endsWith(name))
? loadTs(path.join(path.dirname(full), `${request}.ts`))
: stub,
});
const { adoptDraftPipes, reconcilePipes } = loadTs(TOP);
const before = [
{ chainage_m: 100, reason: "stream", id: "a1" },
{ chainage_m: 200, reason: "user", id: "b2" },
];
process.stdout.write(
JSON.stringify({
same: reconcilePipes(before, [100, 200]),
moved: reconcilePipes(before, [100, 250]),
added: reconcilePipes(before, [100, 200, 300]),
twoMoved: reconcilePipes(before, [150, 250]),
// 369 되돌리기 — 그 걸음 초안이 같은 자리면 초안 속성 · id 를 씀 · 다르면 null
adopt: (() => {
const next = [
{ chainage_m: 100, reason: "user" },
{ chainage_m: 200, reason: "user" },
];
const draft = [
{ chainage_m: 100, id: "a1", facility: "ford_bridge" },
{ chainage_m: 200.004, id: "b2" },
];
return { draft: adoptDraftPipes(draft, next), next };
})(),
adoptOther: adoptDraftPipes([{ chainage_m: 120, id: "z" }], [{ chainage_m: 100 }]),
adoptNone: adoptDraftPipes(null, [{ chainage_m: 100 }]),
}),
);