diff --git a/A00_Common/design/design_pipeline_page.ts b/A00_Common/design/design_pipeline_page.ts index 6cdf39e0a..ab0676d89 100644 --- a/A00_Common/design/design_pipeline_page.ts +++ b/A00_Common/design/design_pipeline_page.ts @@ -128,6 +128,8 @@ interface PagePipeline { reconcile(): Promise; ownsCross: boolean; detail(): SectionDetailResponse | null; + /** 노선 초안 버림 동안(그리기 멈춤 ~ 풂) — 저장 노선 낡음 다시 셈을 안 띄움(472-5 덧). */ + holding(): boolean; dispose(): void; } @@ -165,6 +167,11 @@ export const pipelineCross = (projectId: string): void => pages.get(projectId)?. export const pipelineOwnsCross = (projectId: string): boolean => pages.get(projectId)?.ownsCross ?? false; +/** 노선 초안 버림 동안인가 — 되돌린 상세는 초안 전 그대로라 낡음 다시 셈이 필요 없음(시설 줄이 한 박자 늦어 + * 낡아 보임 · 그 사이 셈하면 옛 관 자리 계획선으로 셈한 면적이 보였음 · 472-5 덧). */ +export const pipelineHolding = (projectId: string): boolean => + pages.get(projectId)?.holding() ?? false; + /** 입력(세션 · 가게) 대 묶음 입력을 견줘 맞춤(365-2) — 돈 바퀴 수(0 = 같음 · -1 = 넘음 · 묶음 없음 = 0). */ export const reconcilePagePipeline = (projectId: string): Promise => pages.get(projectId)?.reconcile() ?? Promise.resolve(0); @@ -216,6 +223,20 @@ function createPagePipeline( let dropping: Promise | null = null; /** 초안을 버린 차례가 되돌림까지 못 감(뒤 차례에 밀림) — 뒤 차례도 조용히 · 그 끝에서 되돌림(B06 cross · 451). */ let dropPending = false; + /** 버린 차례의 종단도 저장 기준 맞춤 — 되돌림 바로 뒤 한 번(되돌린 상세가 먼저 그려지면 초안 종단과 섞인 유토곡선이 + * 한 틀 보였음 · 472-5 덧). */ + let dropAdopt: (() => void) | null = null; + /** 버림 동안 종단도 그리기 멈춤 · 낡음 다시 셈 미룸(`pipelineHolding`). */ + let holding = false; + const holdDraws = (on: boolean): void => { + holding = on; + link.holdDraw?.(on); + }; + const adoptAfterDrop = (): void => { + const adopt = dropAdopt; + dropAdopt = null; + adopt?.(); + }; /** 노선 초안 전 가게 관 · 구조물 — 초안 동안 follow 가 새 측점을 가게에 씀 · 초안을 버리면 이것으로. */ let beforeDraft: Facilities | null = null; let echo = false; // 묶음이 가게에 쓰는 동안(메아리 — 다시 입력으로 안 받음) @@ -366,14 +387,27 @@ function createPagePipeline( if (diff) record.restoreDiff = diff; } why = await restore(stations).catch(() => "error"); + adoptAfterDrop(); // 종단도 = 저장 기준 — 되돌린 상세 그림과 같은 틀(472-5 덧) // 가게 측점 · 종단 = 되돌린 상세 · 저장 기준(초안 측점이 남지 않게 · 466) if (why.startsWith("saved") || why === "no-saved") await publisher.shown(projectId, routeId as number).catch(() => undefined); } } Object.assign(record, { restored: why.startsWith("saved"), restoreWhy: why }); + void releaseWhenQuiet(); return why; }; + /** 버림 뒤 그리기 풂 — 되돌림이 부른 뒤 차례(시설 줄 · 저장 노선 다시 셈)까지 끝나 묶음이 조용해진 뒤 한 번 + * (시설 줄이 한 박자 늦어 그 사이 다시 셈이 옛 관 자리 계획선으로 셈한 면적이 한 틀 보였음 · 472-5 덧). + * ponytail: 50 ms 조용함 · 2 s 상한 — 차례 끝 알림이 생기면 그것으로. */ + const releaseWhenQuiet = async (): Promise => { + for (let i = 0, seen = -1; i < 40 && seen !== pipe.generation; i += 1) { + seen = pipe.generation; + await pipe.settled(); + await new Promise((resolve) => setTimeout(resolve, 50)); + } + holdDraws(false); // 낡음 확인은 시설 줄이 따라온 뒤 그쪽 다시 그림이 함(일찍 하면 옛 관 자리로 셈) + }; /** 노선 초안 시작 — 지금 저장 상세 · 되돌리는 함수를 맡김(횡단 초안 칸 · 측점 열쇠 · 관 · 구조물은 맡은 쪽이 떠 둠). */ const holdNow = (): typeof held => { const { detail = null, routeId } = savedSource(); @@ -442,11 +476,10 @@ function createPagePipeline( // 초안을 버린 차례 — 상세를 되돌린 뒤 저장 기준으로(그 전에 그리면 초안 상세를 낡음으로 봄 · 349-0l) const after = !draft && event.generation === quietGeneration ? dropping : null; if ((draft || drawnDraft) && base) { - if (after) - void after.then( - () => void (!pipe.input("route") && link.adoptPipeline(base, edits, false)), - ); - else link.adoptPipeline(base, edits, draft); + if (after) { + dropAdopt = () => void (!pipe.input("route") && link.adoptPipeline(base, edits, false)); + void after.then(adoptAfterDrop); // 되돌림이 안 돈 차례(밀림 · 실패)도 끝에서 + } else link.adoptPipeline(base, edits, draft); } drawnDraft = draft; }, "새 상세 · 종단도"); @@ -579,7 +612,9 @@ function createPagePipeline( ? savedStructures : plusStationsOf(projectId), input: (key) => pipe.input(key), - routed: () => pipe.input("route") !== null || store.get("routeDraft") !== null, + // 노선 초안 버림 중 = 버림 차례가 관 · 구조물도 초안 전 값으로 되돌림(follow) — 따로 먹이면 차례가 둘로 + // 갈려 버림이 밀리고 측점 · 상세 · 유토곡선이 엇갈림(472-5 덧) + routed: () => pipe.input("route") !== null || store.get("routeDraft") !== null || dropPending, feed: (source, value) => void feed(source, value), resync: async () => (forgetPageData(projectId), await loadPlan(), reconcile()), }); @@ -604,6 +639,7 @@ function createPagePipeline( const run = feed("route", draft, routeRange(before, after)); if (run && !draft && wasDraft) { quietGeneration = pipe.generation; + holdDraws(true); // 앞 걸음(초안) 그림 그대로 — 되돌림 끝에서 한 번(472-5 덧) dropPending = true; dropping = run.then(finishDrop); } @@ -639,6 +675,7 @@ function createPagePipeline( reconcile, ownsCross: Boolean(options.savedCross), detail: () => draftDetailOf(projectId), + holding: () => holding, dispose() { disposed = true; setDraftSectionDetail(projectId, null); diff --git a/A00_Common/design/design_pipeline_page_types.ts b/A00_Common/design/design_pipeline_page_types.ts index b2363f6cc..b783be862 100644 --- a/A00_Common/design/design_pipeline_page_types.ts +++ b/A00_Common/design/design_pipeline_page_types.ts @@ -31,6 +31,9 @@ export interface ProfileLink { adoptPipeline(base: AlignmentBase, edits: AlignmentEdits, draft: boolean): void; /** 새 노선 횡단이 왔음 — 다시 그림(유토곡선). */ redraw?(): void; + /** 노선 초안 버림 동안 그리기를 멈춤(`true`) · 되돌림 · 저장 기준 맞춤이 끝나면 풀고 한 번 그림 — 사이에 + * 초안 · 저장 상세 · 종단이 섞인 그림(유토곡선 · 배지)이 안 보이게(472-5 덧). */ + holdDraw?(hold: boolean): void; /** 배수유역 판 — drainage 단계. */ side?: { pipelineStage: StageFn<"drainage"> } | null; } diff --git a/A00_Common/design/design_profile.ts b/A00_Common/design/design_profile.ts index 7f750fdea..673a4d056 100644 --- a/A00_Common/design/design_profile.ts +++ b/A00_Common/design/design_profile.ts @@ -42,7 +42,10 @@ import { emptyEdits, toAlignmentBase, } from "../../B05_Profile/logic/B05_Profile_UI_Profile_Alignment"; -import { createProfileEditStore } from "../../B05_Profile/B05_Profile_UI_Profile_Edit"; +import { + createProfileEditStore, + routeAlignment, +} from "../../B05_Profile/B05_Profile_UI_Profile_Edit"; import { enforceMinCoverOf } from "../../B05_Profile/B05_Profile_Api_PageSettings"; import { applyPageSettings } from "../../B05_Profile/B05_Profile_UI_Page_Latest"; import { useDesignStore } from "./design_store"; @@ -356,7 +359,11 @@ export function createDesignProfile(ctx: DesignProfileContext) { heights.apply(allowGrow); const scheduleLightSync = (): void => heights.scheduleLightSync(); + /** 노선 초안 버림 동안 그리기 멈춤(`holdDraw`) — 멈춘 사이 부른 그림은 풀 때 한 번. */ + let drawHeld = false; + let drawWanted = false; function draw(): void { + if (drawHeld) return void (drawWanted = true); pagePipeline.pipelineWork("종단도", () => renderProfile({ // 그린 뒤 생긴 낡음도 다시 셈(317-1) · 노선 초안 동안은 묶음 cross 를 기다림 @@ -450,6 +457,12 @@ export function createDesignProfile(ctx: DesignProfileContext) { // 편집은 chainage 키라 새 base에 그대로 재적용된다(범위 밖·미매칭 변화점은 best-effort로 드롭). const routeChanged = nextRouteId !== routeId; const carried = routeChanged && store.edited() ? store.edits() : null; + // 노선 초안을 버리고 되돌린 저장 상세가 옴 — 종단도도 그 자리에서 저장 기준(초안 종단과 저장 상세가 한 틀 + // 섞여 그려지지 않게 · 묶음 맞춤 `adoptPipeline` 은 뒤에 같은 값으로 다시 · 472-5 덧) + if (store === preview && !pagePipeline.pagePipeline(projectId)?.input("route")) { + store = createProfileEditStore(routeId, undefined, () => rebuild()); + preview = null; + } // 서버 저장분을 기준으로 삼되, 남아 있는 세션 초안이 있으면 그쪽을 우선한다. if (routeChanged || (store !== preview && !store.dirty())) { routeId = nextRouteId ?? routeId; @@ -579,7 +592,14 @@ export function createDesignProfile(ctx: DesignProfileContext) { setEndOffset: (end: ProfileEnd, value: number): boolean => !!base && applyEdits(withEndOffset(base, store.edits(), end, value)), /** 계산 묶음(346-1) — 저장 노선의 종단 기준 · 지금 계획고 편집. */ - pipelineSource: () => ({ base: listed(), edits: store.edits(), detail, routeId }), + // 편집 = 저장 노선 것 — 노선 초안 미리보기(노선 0 칸) 동안도(버림 사이 저장 노선 횡단 다시 셈이 초안 계획고로 + // 셈해 관 측점 면적이 한 틀 틀렸음 · 472-5 덧) + pipelineSource: () => ({ + base: listed(), + edits: store === preview && routeId !== null ? routeAlignment(routeId) : store.edits(), + detail, + routeId, + }), /** 노선 초안으로 셈한 첫 계획선 · 옮긴 계획고를 그림 — 초안 동안 편집은 노선 0 칸(저장 노선에 * 안 씀 · [저장]이 노선 뒤 새 노선에 보냄) · 초안을 버리면 저장 기준 · 세션 편집으로 돌아옴. */ adoptPipeline(nextBase: AlignmentBase, edits: AlignmentEdits, draft: boolean) { @@ -621,6 +641,13 @@ export function createDesignProfile(ctx: DesignProfileContext) { }, /** 밖에서 바뀐 횡단 면적(카드 갱신)을 유토곡선 · 뱃지에 다시 싣는다. */ redraw: () => drawSoon(), + /** 노선 초안 버림 동안 그리기 멈춤 · 풀면 한 번(472-5 덧 · 묶음 페이지가 부름). */ + holdDraw(hold: boolean) { + drawHeld = hold; + if (hold || !drawWanted) return; + drawWanted = false; + drawSoon(); + }, /** 오른쪽 판(배수유역도) — 판 없이 만들었으면 null. */ side: drainagePanel, /** 그래프 영역 로딩 서클. 문구를 주면 켜고 null이면 끈다. */ diff --git a/B05_Profile/B05_Profile_UI_Profile_Edit.ts b/B05_Profile/B05_Profile_UI_Profile_Edit.ts index ef4cc08be..d9f92806e 100644 --- a/B05_Profile/B05_Profile_UI_Profile_Edit.ts +++ b/B05_Profile/B05_Profile_UI_Profile_Edit.ts @@ -127,6 +127,10 @@ export function clearAlignmentDrafts(): void { const savedOf = (routeId: number | null): AlignmentEdits => (routeId === null ? null : draftOf(routeId).get("alignmentSaved")) ?? emptyEdits(); +/** 그 노선 지금 편집(초안 ?? 저장분) — 창구 없이 읽음(노선 초안 미리보기 동안 저장 노선 셈 · 472-5 덧). */ +export const routeAlignment = (routeId: number): AlignmentEdits => + readAlignmentDraft(routeId) ?? savedOf(routeId); + /** [저장]이 보낼 계획고 초안 — 미저장 편집이 없으면 null. */ export function pendingAlignment(routeId: number): AlignmentEdits | null { return readAlignmentDraft(routeId); diff --git a/B06_Section/B06_Section_Section_Store.ts b/B06_Section/B06_Section_Section_Store.ts index c2fa3fc3b..1a3befedf 100644 --- a/B06_Section/B06_Section_Section_Store.ts +++ b/B06_Section/B06_Section_Section_Store.ts @@ -98,15 +98,25 @@ async function withDraftWalls( await loadSavedPlusStations(projectId); await withDraftStations(detail, projectId, routeId); // 옛 자리 숨김 · 새 자리 미리 뜬 횡단(273-2) await withDraftShapes(detail, projectId); - withDraftAdjusts(detail, projectId, routeId); // 저장 안 한 조정창 4축 · 구간 · 형식(387-4 · B05 만 열어도) - await withPipeOptions(detail, projectId); // 관 옵션 벽 높이 · 형태 · 흙막이 단(387-4b) - withStructureAreas(detail); + await withAdjustsAndAreas(detail, projectId, routeId); // 초안 자리 미리 뜬 횡단 = 서버가 저장 계획선으로 셈 · 묶음 cross 뒤에 얹힐 수 있음 — 다 돈 뒤 지금 계획선과 // 갈리면 cross 한 번 더(387-8 · 낡음 판정 = 가게 몫 · 종단 판이 접혀 그리기가 안 돌아도) recrossSaved(projectId, keyOf(projectId, routeId), detail, routeId); return detail; } +/** 얹기 꼬리 한 벌 — 읽기 · 갈아끼움 · 되돌림이 같은 차례(되돌린 상세에 관 옵션 없이 면적부터 셈해 유토곡선이 한 틀 + * 어긋났음 · 472-5 덧). */ +async function withAdjustsAndAreas( + detail: SectionDetailResponse, + projectId: string, + routeId: number, +): Promise { + withDraftAdjusts(detail, projectId, routeId); // 저장 안 한 조정창 4축 · 구간 · 형식(387-4 · B05 만 열어도) + await withPipeOptions(detail, projectId); // 관 옵션 벽 높이 · 형태 · 흙막이 단(387-4b) + withStructureAreas(detail); +} + /** * 구조물이 선 측점의 절·성토 면적을 **읽어 오는 자리에서 한 번** 다시 얹는다. * @@ -270,7 +280,7 @@ export async function swapSectionStations( cache.set(key, swap.detail); supersedeDraftStations(current); // 옛 상세에 돌던 맞춤이 새 열쇠 목록을 덮지 않게(415 H1) await withDraftShapes(swap.detail, projectId, true); // 늘 지금 현황으로 다시 얹음 · 이름 = 계획(323-4 · 458) - withStructureAreas(swap.detail); + await withAdjustsAndAreas(swap.detail, projectId, routeId); if (cache.get(key) !== swap.detail) return null; // 그 사이 다른 갈아끼움 · 새로 받음 emitSwap(swap.detail, swap.moves); // 세션 값 옮김 · 다시 그림(어느 보기든) listeners.get(key)?.forEach((fn) => fn(swap.detail, swap.moves)); @@ -303,6 +313,7 @@ function recrossSaved( if (cache.get(key) !== detail) return; const pipe = page.pagePipeline(projectId); if (!page.pipelineOwnsCross(projectId) || pipe?.input("route")) return; + if (page.pipelineHolding?.(projectId)) return; // 노선 초안 버림 동안 — 풀 때 한 번 확인(472-5 덧) if (staleOf !== undefined) { const stale = pipe?.generation ? staleKeyAgainstScreen(detail, staleOf) : ""; if (!stale || askedStale.get(detail) === stale) return; @@ -402,7 +413,7 @@ export async function restoreSectionDetail( await withDraftStations(saved, projectId, routeId); useStationKeyList(projectId, routeId, hold.keys); await withDraftShapes(saved, projectId); - withStructureAreas(saved); + await withAdjustsAndAreas(saved, projectId, routeId); if (cache.get(key) !== saved) return null; // 그 사이 다른 갈아끼움 · 새로 받음 const sections = saved.cross_sections; // 다시 얹은 뒤 측점(440-4) const same = diff --git a/docs/wiki/concepts/design_page/index.md b/docs/wiki/concepts/design_page/index.md index 419daaec7..eb0684d90 100644 --- a/docs/wiki/concepts/design_page/index.md +++ b/docs/wiki/concepts/design_page/index.md @@ -52,7 +52,7 @@ source: ["docs/raw/조사/2026-10-19_470_B05B06_데이터흐름.md", "docs/raw/ | ② 정본 사본 · 상세 칸 | `B06_Section_Section_Canon.ts:36` keepCanon · `:59` sessionDetail · `:72` savedDesigns · `:84` forgetCanon · `:107-143` 칸 셋(저장 정본 · 초안 전 hold · 노선 초안 · 472-5) | 서버 정본 설계 · 자리 · 표본 · invalidate 때 비움 · 칸 셋 = 떠남 · invalidate 때 비움 | | ③ 설계 가게 | `design_store.ts:226` useDesignStore · `:151` 메모리 칸 · `:160` 1 s | 읽고 쓰는 창구 · 쓰면 듣는 쪽 부름 | | ④ 세션 | `A00_Common/b_page_state.ts` 등록부 | draft = 사용자 값 · result = 계산 · 서버 사본 · [[design_page/session_keys]] | -| ⑤ 계산 묶음 | `logic/design_pipeline.ts:33` 단계 · `:44` 뒤 단계 · `:49` STAGE_DEPS · `design_pipeline_page.ts:177-182` dispose | 차례 번호 · 옛 차례 버림 · 입력 대 묶음 맞춤 최대 3 바퀴(`:116`) | +| ⑤ 계산 묶음 | `logic/design_pipeline.ts:33` 단계 · `:44` 뒤 단계 · `:49` STAGE_DEPS · `design_pipeline_page.ts:187-192` dispose | 차례 번호 · 옛 차례 버림 · 입력 대 묶음 맞춤 최대 3 바퀴(`:116`) | | ⑤ 묶음 → 가게 | `design_pipeline_page_publish.ts` publishPagePipeline · shown · opened · recheck | 측점 · 종단 · 발자국 냄 · 조용한 차례 = 상세 측점 | | ⑥ 서버 파생 | `_derived/haul/*` · `B05_Profile/route_recommend/*` · `04_detail_cache.pkl` | 입력 지문 다를 때만 다시 셈 · 지워도 다시 셈 | | ⑦ 서버 작업본 | DB `routes` · `route_points` · `route_statistics` · `longitudinal_sections` · `cross_sections` · 파일 `pipe_points.json` · `structures.json` · `plus_stations.json` · 노선 파일 · 곡선표 · 종단 파일(`mass_haul`) · 3D corridor | [저장] · [확정] · [초기화]만 씀(예외 = [[design_page/rules]]) | @@ -71,4 +71,4 @@ source: ["docs/raw/조사/2026-10-19_470_B05B06_데이터흐름.md", "docs/raw/ | cross | profile · ground · cross · pipes · structures | `logic/B06_Section_Cross_Stage.ts` · 저장 노선 = `B06_Section_Cross_Refresh.ts` | 횡단 설계선 · 면적 | | footprint | cross · ground | `logic/B05_Profile_Footprint_Stage.ts` | 평면 발자국 | | drainage(뒤) | route · pipes | 배수판 `pipelineStage` → 서버 | 배수유역 | -| corridor(뒤) | profile · cross | `design_pipeline_page.ts:334-337` | 3D 낡음 표시 | +| corridor(뒤) | profile · cross | `design_pipeline_page.ts:355-358` | 3D 낡음 표시 | diff --git a/docs/wiki/concepts/design_page/operations_common.md b/docs/wiki/concepts/design_page/operations_common.md index 457504b70..4583d3fea 100644 --- a/docs/wiki/concepts/design_page/operations_common.md +++ b/docs/wiki/concepts/design_page/operations_common.md @@ -38,4 +38,4 @@ source: ["docs/raw/조사/2026-10-19_470_B05B06_데이터흐름.md", "docs/raw/ | cross | `ctx.cross(confirm)` = 횡단 패치 한 요청 | `/sections/{노선}/save` · `confirm` · 재계산 맨 앞 종단 경고 다시 씀(`B06_Section_Server_Calc_Prebuild.py` refresh_alignment) | `carryAfterRouteSave`(새 측점으로 옮김) | `design_save.ts:275-283` | - 차례마다 따로 커밋 — 실패 = 그 차례에서 멈춤 · 이름째 알림 · 앞 차례는 저장된 채(`design_save.ts:297-299`). -- 저장 중 = `saving` 표시 · 묶음 맞춤은 저장 뒤로 미룸(`design_pipeline_page.ts:520`). +- 저장 중 = `saving` 표시 · 묶음 맞춤은 저장 뒤로 미룸(`design_pipeline_page.ts:553`). diff --git a/docs/wiki/concepts/design_page/rules.md b/docs/wiki/concepts/design_page/rules.md index 49869b693..9aec3f590 100644 --- a/docs/wiki/concepts/design_page/rules.md +++ b/docs/wiki/concepts/design_page/rules.md @@ -12,10 +12,10 @@ source: ["CLAUDE.md §5", "docs/raw/조사/2026-10-19_465_요구272_값안변함 | 규칙 | 지키는 자리(파일:줄) | 시험 | |---|---|---| -| 파생값 = 입력(저장 정본 + 세션 초안)만의 함수 — 보기 차례 · 접힘 · 메모리 · 새로고침 · 들어온 길로 안 갈림 | `logic/design_pipeline.ts:49` STAGE_DEPS · `design_pipeline_page.ts:512-535` reconcile | `test_272_*` | +| 파생값 = 입력(저장 정본 + 세션 초안)만의 함수 — 보기 차례 · 접힘 · 메모리 · 새로고침 · 들어온 길로 안 갈림 | `logic/design_pipeline.ts:49` STAGE_DEPS · `design_pipeline_page.ts:545-568` reconcile | `test_272_*` | | 상세 가게 메모리 = 페이지 수명 — 떠남 = `forgetSectionMemory` · [저장] · [확정] · [초기화] · 노선 저장 = `invalidateSectionDetail` | `design_page.ts:294` · `design_shared.ts:428 · 435` · `design_reset.ts:41` · `design_view_profile.ts:469` · `B05_Profile_UI_RouteEdit_Apply.ts:171 · 211` | `test_272_detail_memory` | | [폐기] = 세션 고침 칸만 지움 · 메모리는 떠남(dispose)이 비움 | `design_leave.ts:85-87` · `design_page.ts:286-295` | `test_346_4_design_leave` | -| 조용한 차례(열 때 · 노선 초안 버림) 끝 = 가게 측점 · 종단 = 지금 상세 측점 · 저장 기준 · 같은 목록은 다시 안 냄 | `design_pipeline_page_publish.ts` shown · opened · `design_pipeline_page.ts:370-371 · 497` | `test_272_drop_store_stations` | +| 조용한 차례(열 때 · 노선 초안 버림) 끝 = 가게 측점 · 종단 = 지금 상세 측점 · 저장 기준 · 같은 목록은 다시 안 냄 | `design_pipeline_page_publish.ts` shown · opened · `design_pipeline_page.ts:392-393 · 530` | `test_272_drop_store_stations` | | 노선 초안 없는 차례 = 서버 정본 측점 기하 · 표본을 브라우저 값으로 안 덮음(같은 자리 0.01 m · 축 1e-3 → 앞 횡단 → 그 자리 옛 횡단 → 저장 정본) | `logic/B06_Section_Station_Swap.ts:171-182 · 238-247` · `B06_Section_Section_Store.ts:241-248` | `test_272_swap_keeps_canon` | | 노선 초안 차례 = 새 · 옮긴 측점만 브라우저 지반 표본 | `logic/B06_Section_Station_Swap.ts:249-251` | `test_346_2_station_swap` | | 다시 셈 입력 물러섬 = 세션 고름 → 저장 정본 설계 → config 기본값 · 고름 단추는 메모리 상세 설계를 안 덮음 | `B06_Section_Cross_Refresh.ts:402-408` · `B06_Section_UI_Page_Design_Sync.ts:59-104` | `test_272_choice_undo` | @@ -28,6 +28,7 @@ source: ["CLAUDE.md §5", "docs/raw/조사/2026-10-19_465_요구272_값안변함 | [저장] · [확정] = 서버가 입력만으로 정본 다시 셈 · 브라우저 결과(면적 · 표본 · 측점) 받아 적지 않음 | `design_save.ts:58-68` · `B06_Section_Router_Confirm.py:203-215` | `test_b06_save_recompute` | | 자동저장(디바운스 PUT) 없음 · 화면 잠금 = [저장] · [확정] · [초기화] · 추천 [적용]만 | `design_save.ts:249` | — | | 측점 열쇠 = `common_util_station_key` 한 벌 · 노선 바뀜 = 관 · 구조물 좌표(x · y) 따라감 · 누가거리 다시 매김 | `common_util_station_key.ts:32` · `common_util_route_follow.ts:291` | `test_344_3_station_key_mirror` · `test_410_follow_xy` | +| 노선 초안 ↶(버림) = 차례 하나 · 버림 동안 종단도 그리기 멈춤 · 낡음 다시 셈 미룸 → 되돌림 · 저장 기준 맞춤 · 뒤 차례 끝에 한 번 그림(사이 섞인 유토곡선 없음) | `design_pipeline_page.ts:642 · 403` · `B06_Section_Section_Store.ts:316` | `test_472_5c_drop_once` | | B05 · B06 캐시 = 한 벌 · [저장] 한 번에 함께 나감 | `design_shared.ts:395-448` · `design_save.ts:237` | — | | 관 · 구조물 주인 = 가게 칸 하나 — 화면 사본은 가게 알림으로 맞춤(제 쓰기는 같은 값 · 남 고침은 다시 실음) | `design_view_profile.ts` 가게 구독 · `design_view_cross.ts` onShop · `B06_Section_UI_Page_Structures_Panel.ts` seen | `test_472_5_shop_owner` | | 정본 자리 = 값을 낳은 주인 — 노선 시설 = `pipe_points.json` · `structures.json` · 횡단 값 = 횡단 패치 | `B05_Profile_Api_Pipes_Draft.ts:30-37` · `B05_Profile_Structures_Router.py:386-405` · `B06_Section_Section_Store.ts:449` | — | diff --git a/resources/tester/helper_472_5c_drop_once.cjs b/resources/tester/helper_472_5c_drop_once.cjs new file mode 100644 index 000000000..64917ad12 --- /dev/null +++ b/resources/tester/helper_472_5c_drop_once.cjs @@ -0,0 +1,284 @@ +/* 472-5 덧 헬퍼 — 노선 초안(관이 따라 옮겨짐) ↶ = 차례 하나 · 값 하나. 진짜 TS(`design_pipeline_page` · 단계 + * 파일 전부)를 Node 로 · 서버 창구만 가짜(틀 = `helper_451_drop_cross.cjs`). 되돌리기 = 사진첩처럼 세션을 바로 + * 되쓰고(가게 알림 없음) 훅을 부름(노선 편집기 → 관 · 구조물 먹이기 차례 그대로). + * 입력 argv[2] JSON · argv[3] 격자 이진 · 결과 = 표준출력 JSON. 짝 = `test_472_5c_drop_once.py`. */ +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"); + +const ROOT = path.join(__dirname, "..", ".."); +const job = JSON.parse(fs.readFileSync(process.argv[2], "utf8")); + +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; + }, + }; +} +globalThis.window = { + sessionStorage: memoryStorage(), + localStorage: memoryStorage(), + setTimeout, + clearTimeout, +}; + +// 흙 배분 서버 — 늦게 답함 · 끊기면 버림 +const haul = { calls: 0, aborted: 0, answered: 0 }; +globalThis.fetch = (url, init) => + new Promise((resolve, reject) => { + haul.calls += 1; + const timer = setTimeout(() => { + haul.answered += 1; + resolve({ ok: true, json: async () => ({ haul_plan: { blocks: [], url } }) }); + }, job.haulDelayMs); + init.signal.addEventListener("abort", () => { + clearTimeout(timer); + haul.aborted += 1; + reject(new Error("aborted")); + }); + }); + +const STUBS = {}; +// 되돌리기 훅 — 사진첩(`_Profile_History`) 대신 모아 두고 시험이 부름 +const hooks = []; +STUBS["B05_Profile_UI_Profile_History"] = new Proxy( + { + onPageHistory: (entry) => (hooks.push(entry), () => undefined), + pageReplaying: () => false, + }, + { get: (target, key) => (key in target ? target[key] : () => undefined) }, +); +const cache = new Map(); +function loadTs(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 (CATALOG.isCatalogRequest(request)) return CATALOG; + const key = Object.keys(STUBS).find((name) => request.endsWith(name)); + if (key) return STUBS[key]; + if (request.startsWith("@config/")) return { API_BASE_URL: "http://fake" }; + if (request.startsWith("@util/")) + return loadTs(path.join(ROOT, "common_util", `${request.slice(6)}.ts`)); + 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); + return box.exports; +} +const load = (...parts) => loadTs(path.join(ROOT, ...parts)); +// 상세 가게 칸(472-5) — 실제는 상세 가게가 받을 때 채움 · 여기선 종단도가 내주는 저장 상세 그대로 +const slots = () => load("B06_Section", "B06_Section_Section_Canon.ts"); + +const sampler = load("common_util", "common_util_surface_sampler.ts"); +const bytes = fs.readFileSync(process.argv[3]); +const grid = sampler.parseDtmGrid( + bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.length), +); +const local = { grid, design: "las" }; + +STUBS["B05_Profile_Api_Replan"] = { + analysisTerrain: () => "las", + fetchRoutePlan: async () => ({ + planned: job.line, + curves: [], + min_radius_m: job.minRadius, + station_snap: false, + }), +}; +STUBS["B05_Profile_Api_Structures"] = { + fetchStructures: async () => ({ structures: [] }), + fetchStructureTypes: async () => job.types, +}; +STUBS["B05_Profile_Api_TerrainGrid"] = { + loadDesignTerrainGrid: async () => local, + groundStageDeps: () => ({ grid: () => local, remote: async () => [] }), +}; +STUBS["B04_PreProcess_Api_Fetch"] = { + fetchDetailPipePoints: async () => ({ + pipe_points: job.pipes.map((pipe) => ({ ...pipe, lonlat: [0, 0] })), + }), +}; +STUBS["B06_Section_UI_Standard_Panel"] = { + effectiveStandardCross: () => job.standard, + readRockBoundaryDefault: () => -0.5, +}; + +const pipeMod = load("A00_Common", "design", "logic", "design_pipeline.ts"); +const pageMod = load("A00_Common", "design", "design_pipeline_page.ts"); +const stationsMod = load("A00_Common", "design", "logic", "design_pipeline_stations.ts"); +const routeGround = load("B05_Profile", "logic", "B05_Profile_Pipeline_RouteGround.ts"); +const grade = load("B05_Profile", "logic", "B05_Profile_Pipeline_Grade.ts"); +const gradeGround = load("B05_Profile", "logic", "B05_Profile_Grade_Ground.ts"); +const detailMod = load("B05_Profile", "logic", "B05_Profile_Pipeline_Detail.ts"); +const alignment = load("B05_Profile", "logic", "B05_Profile_UI_Profile_Alignment.ts"); +const editMod = load("B05_Profile", "B05_Profile_UI_Profile_Edit.ts"); +const page = load("A00_Common", "b_page_state.ts"); + +const tick = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms)); +const runs = () => globalThis.__aisloPipeline?.runs ?? []; +async function settle(count) { + for (let i = 0; i < 400; i += 1) { + const last = runs()[runs().length - 1]; + if (runs().length >= count && last && last.outcome !== "running") return last; + await tick(5); + } + throw new Error("묶음이 끝나지 않음"); +} +const n = job.nodes.length; +const draftOf = (nodes) => ({ + nodes, + curveOn: Array(n).fill(true), + curveRadius: Array(n).fill(null), + curveLock: Array(n).fill(null), + curveArc: Array(n).fill(null), + stationSnap: false, +}); +const shift = (index, dx, dy) => + job.nodes.map((node, i) => (i === index ? [node[0] + dx, node[1] + dy] : node)); + +/** 저장 기준 — 저장 노선 지반 첫 계획선(관 측점 포함 · 서버 정책 그대로). */ +async function savedBaseOf() { + const seed = pipeMod.createDesignPipeline({ + stages: { + route: routeGround.createRouteStage({ + minRadiusM: () => job.minRadius, + savedLine: () => ({ line: job.line, curves: [] }), + }), + stations: stationsMod.createStationsStage({ + intervalM: job.interval, + types: () => job.types, + }), + ground: routeGround.createGroundStage({ grid: () => local, remote: async () => [] }), + }, + }); + await seed.start({ route: null, alignment: null, cross: null, pipes: job.pipes, structures: [] }); + const ground = seed.output("ground"); + seed.dispose(); + const samples = ground.longitudinal.chainageM.map((c, i) => ({ + chainage_m: c, + elevation_m: ground.longitudinal.z[i], + })); + const profile = gradeGround.groundProfile(samples); + return { + policy: job.policy, + onlyExplicitCurves: false, + basePvi: gradeGround.groundFollowingBasePvi({ + samples, + stations: ground.stations.map((s) => s.chainageM), + policy: job.policy, + }), + chainage: profile.chainage, + ground: profile.ground, + stations: ground.stations.map((s) => ({ + station_id: grade.stationIdOf(s.chainageM), + chainage_m: s.chainageM, + })), + }; +} + +const store = load("A00_Common", "design", "design_store.ts"); +// B05 오른쪽 횡단 판(365-3) — 그림 조각만 가짜 · 값 고르기는 진짜 +STUBS["b_svg_zoom_pan"] = { attachSvgZoomPan: () => undefined }; +STUBS["B05_Profile_UI_RouteEdit_Cross_Draw"] = { CROSS_PLOT_PAD: {}, summarizeCross: () => "" }; +STUBS["B05_Profile_UI_RouteEdit_Chrome"] = { sidePanelsOf: new WeakMap() }; // 판 양식(382-1) — 화면 밖 +// B06 카드 그림(393-2) — 화면 밖 · 판 값 고르기는 진짜 +STUBS["B05_Profile_UI_RouteEdit_Cross_Card"] = { + routeCrossSource: () => null, + routeCrossCard: () => null, +}; +const pane = load("B05_Profile", "B05_Profile_UI_RouteEdit_Cross.ts"); +const r3 = (value) => (typeof value === "number" ? Math.round(value * 1000) / 1000 : null); + +/** 묶음 새 노선 상세(카드가 그리는 것) — 측점 · 계획고 · 절 · 성토 면적. */ +function shownRows(P) { + const shown = pageMod.pipelineDetail(P); + return ( + shown && + shown.cross_sections.map((s) => [ + r3(s.chainage_m), + r3(s.design?.design_elevation_m), + r3(s.design?.cut_area_m2), + r3(s.design?.fill_area_m2), + ]) + ); +} + +async function run() { + const P = "proj-4725c"; + window.localStorage.setItem("frd_current_project_id", P); + const savedBase = await savedBaseOf(); + const shop = store.useDesignStore(P, null); + const restores = []; + const bridge = pageMod.routeDraftBridge( + P, + { + pipelineSource: () => ({ + base: savedBase, + edits: alignment.emptyEdits(), + detail: (slots().keepSavedDetail(P, 7, job.detail), job.detail), + routeId: 7, + }), + adoptPipeline: () => undefined, + redraw: () => undefined, + }, + { + stationIntervalM: job.interval, + holdDraft: (routeId, saved) => ( + slots().keepHeldDetail(P, routeId, saved), + async (stations) => { + restores.push(stations.length); + return "saved"; + } + ), + }, + ); + pageMod.pipelineEarthwork(P, { conversion: job.conversion }); + await settle(runs().length + 1); + const pipe = pageMod.pagePipeline(P); + const at = (list) => (list ?? []).map((p) => Math.round(p.chainage_m * 100) / 100); + const opened = { pipes: at(pipe.input("pipes")), store: shop.get("pipes") }; + // 노선 교점 끌기 — 관이 따라 옮겨짐(follow 가 가게 관을 씀) + bridge.edited(draftOf(shift(1, 8, -6))); + await settle(runs().length + 1); + await tick(20); + const drafted = { pipes: at(shop.get("pipes")), input: at(pipe.input("pipes")) }; + // ↶ — 사진첩: 세션을 그 걸음 값으로 바로 되씀(가게 알림 없음) → 훅(노선 편집기 버림 → 관 먹이기) + const mark = runs().length; + page.writeState("pipes", opened.store, P); + page.writeState("route-draft", null, P); + bridge.edited(null); + hooks.forEach((entry) => entry.restore?.("undo")); + for (let i = 0; i < 400 && !restores.length; i += 1) await tick(5); + await pipe.settled(); + await tick(30); + await pipe.settled(); + const after = runs().slice(mark); + console.log( + JSON.stringify({ + moved: JSON.stringify(drafted.pipes) !== JSON.stringify(opened.pipes), + runs: after.map((r) => [r.sources.join("+"), r.outcome, r.restoreWhy ?? ""]), + restores: restores.length, + pipes: { opened: opened.pipes, after: at(pipe.input("pipes")), store: shop.get("pipes") }, + routeDraft: shop.get("routeDraft"), + }), + ); + pageMod.disposePagePipeline(P); +} + +run() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/resources/tester/test_472_5c_drop_once.py b/resources/tester/test_472_5c_drop_once.py new file mode 100644 index 000000000..aa8f3556e --- /dev/null +++ b/resources/tester/test_472_5c_drop_once.py @@ -0,0 +1,79 @@ +"""472-5 덧 — 노선 초안(관이 따라 옮겨짐)을 ↶ 하면 차례 하나 · 값 하나. + +옛 흠: ↶ 가 노선 초안 버림 차례(조용 · 초안 전 상세로 되돌림)와 관 · 구조물 먹이기 +차례(되돌리기 훅) 둘을 띄움 → 버림이 밀리고 측점 · 상세 · 유토곡선이 엇갈림. 버림 차례가 +관 · 구조물 되돌림까지 실어 감(follow = 초안 전 값) — 훅은 버림 동안 안 먹임. +짝: `helper_472_5c_drop_once.cjs`(진짜 TS · 서버 창구만 가짜 · 틀 = 451). + + ./venv/Scripts/python.exe -m pytest resources/tester/test_472_5c_drop_once.py -q +""" + +from __future__ import annotations + +import json +import subprocess +import sys +import tempfile +from pathlib import Path + +import pytest + +HERE = Path(__file__).resolve().parent +if str(HERE) not in sys.path: + sys.path.insert(0, str(HERE)) + +import test_365_page_pipeline as page # noqa: E402 + +pytestmark = page.pytestmark + + +@pytest.fixture(scope="module") +def r() -> dict: + with tempfile.TemporaryDirectory() as folder: + path, grid = page._job(Path(folder)) + proc = subprocess.run( # noqa: S603 — 고정 실행 파일 + ["node", str(HERE / "helper_472_5c_drop_once.cjs"), str(path), str(grid)], + capture_output=True, + text=True, + encoding="utf-8", + timeout=180, + ) + assert proc.returncode == 0, proc.stderr + return json.loads(proc.stdout) + + +def test_되돌리면_차례_하나(r) -> None: + assert r["moved"] is True # 초안이 관을 옮김(시험이 follow 길을 거침) + assert r["runs"] == [["route", "done", "saved"]] # 버림 차례 하나가 되돌림까지 + assert r["restores"] == 1 + + +def test_관은_그_걸음_값(r) -> None: + assert r["pipes"]["after"] == r["pipes"]["opened"] + assert r["pipes"]["store"] is None + assert r["routeDraft"] is None + + +def _src(*parts: str) -> str: + return HERE.parents[1].joinpath(*parts).read_text(encoding="utf-8") + + +def test_버림_동안_그림_한_번() -> None: + """버림 시작 ~ 되돌림 · 저장 기준 맞춤 · 뒤 차례 끝까지 그리기 멈춤 → 풀 때 한 번.""" + page = _src("A00_Common", "design", "design_pipeline_page.ts") + assert "holdDraws(true); // 앞 걸음(초안) 그림 그대로" in page + assert "void releaseWhenQuiet();" in page + assert "adoptAfterDrop(); // 종단도 = 저장 기준" in page + profile = _src("A00_Common", "design", "design_profile.ts") + assert "if (drawHeld) return void (drawWanted = true);" in profile + # 저장 노선 셈의 편집 = 그 노선 것(노선 초안 미리보기 동안도) + assert ( + "store === preview && routeId !== null ? routeAlignment(routeId) : store.edits()" in profile + ) + + +def test_되돌림_갈아끼움_얹기_한_벌() -> None: + """되돌림 · 갈아끼움도 읽기와 같은 얹기 꼬리 · 버림 동안 낡음 다시 셈 안 띄움.""" + store = _src("B06_Section", "B06_Section_Section_Store.ts") + assert store.count("await withAdjustsAndAreas(") == 3 + assert "if (page.pipelineHolding?.(projectId)) return;" in store