fix: rhwpDev 디버깅 툴킷 결함 수정 — paragraph 식별 + 다중 매치 (#449)#684
fix: rhwpDev 디버깅 툴킷 결함 수정 — paragraph 식별 + 다중 매치 (#449)#684oksure wants to merge 2 commits intoedwardkim:develfrom
Conversation
Issue edwardkim#449 cherry-pick 후 메인테이너 시각 판정에서 식별된 결함 두 건 수정: 1. paragraph 식별 부정확 (본문 vs 셀 내부 충돌) - getPageTextLayout runs의 parentParaIdx/controlIdx/cellIdx 필드를 활용하여 container context (body/cell[p,c,i]) 키 생성 - showAllIds에 container 컬럼 추가, 중복 제거 키에 포함 - findNearest 결과에 container 정보 포함 2. 다중 매치 미처리 - search(text)가 searchText를 반복 호출하여 모든 매치 수집 - SearchResult 단건 → SearchResult[] 배열 반환 - console.table로 전체 매치 목록 출력 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the rhwpDev debugging toolkit used by rhwp-studio to improve paragraph identification (body vs. cell-internal context) and to return/print all matches for document text searches, addressing follow-up defects found after cherry-picking #602.
Changes:
- Add
containercontext derived fromgetPageTextLayout()run metadata to disambiguate body paragraphs vs. cell-internal paragraphs inshowAllIds()/findNearest(). - Update
search(text)to collect and return all matches across the document (return type becomes an array). - Initialize the toolkit during app startup via
initRhwpDev(wasm).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| rhwp-studio/src/main.ts | Wires initRhwpDev(wasm) into the app initialization flow. |
| rhwp-studio/src/core/rhwp-dev.ts | Adds the window.rhwpDev toolkit implementation with container-aware IDs and multi-match search. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await loadWebFonts([]); // CSS @font-face 등록 + CRITICAL 폰트만 로드 | ||
| msg.textContent = 'WASM 로딩 중...'; | ||
| await wasm.initialize(); | ||
| initRhwpDev(wasm); |
| let layout: string; | ||
| try { | ||
| layout = (wasm as any).doc.getPageTextLayout(p); | ||
| } catch { continue; } | ||
| const data = JSON.parse(layout); |
| try { | ||
| layout = (wasm as any).doc.getPageTextLayout(page); | ||
| } catch { return null; } | ||
| const data = JSON.parse(layout); |
- initRhwpDev(wasm)을 import.meta.env.DEV 조건 안으로 이동하여 프로덕션 빌드에서 디버그 API 노출 방지 - showAllIds()의 JSON.parse(layout)을 try/catch 블록 안으로 이동 - findNearest()의 JSON.parse(layout)도 동일하게 에러 핸들링 추가 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Copilot 리뷰 피드백 반영 완료 (c72e5e5):
|
PR #684 cherry-pick 결과 영역에서 main.ts 영역의 initRhwpDev 영역 import 영역 중복 영역 발생 영역 — 본 환경 영역의 PR #602 영역 결과 (line 28 import + line 38-40 외부 호출 영역) 와 PR #684 영역의 c72e5e5 commit 영역 (initialize() 함수 안 DEV 게이트 영역 안 호출 영역) 영역 동시 영역 존재 영역 → TypeScript TS2300 영역 에러 영역. PR #684 의 본질 영역 정합 영역으로 line 38-40 영역 제거: - line 28 영역 import 영역 유지 (본 환경 PR #602 영역 결과) - line 38-40 영역의 외부 호출 영역 제거 (PR #684 의 의도 영역 — initialize() 안 DEV 게이트 영역 안 호출 영역만 활성 영역) - line 99-100 영역의 if (import.meta.env.DEV) { initRhwpDev(wasm); } 영역 유지 (PR #684 c72e5e5 영역 결과) 검증: - npm run build TypeScript 타입 체크 + dist 빌드 통과 (index-21tD9d3W.js 691,386) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR #684 의 search() 영역의 break 조건이 (!r || !r.found) 영역만 영역으로 영역, search_text_native 영역의 wrap-around 영역 동작 영역에서 무한 루프 영역 발생 영역 (마지막 매치 이후 → body_hits[0] + wrapped=true + found=true 반환 → break 안 됨 → 처음 매치부터 영역 반복). 옵션 B 정정 (작업지시자 결정): 1. SearchResult 인터페이스에 wrapped?: boolean 영역 추가 (본 환경 core/types.ts 영역 정합) 2. wrap-around 가드 영역 — r.wrapped = true 시 break 3. 반복 횟수 한계 영역 — MAX_MATCHES = 10000 (방어 영역, 실 사용 한도 충분) 4. 후진 가드 영역 — 다음 매치 위치가 직전 위치보다 앞이거나 같으면 break (sec/para/charOffset 비교) 검증: - npm run build TypeScript + Vite 빌드 통과 - 작업지시자 권위: aift.hwp 영역 등 다중 매치 영역 영역의 wrap-around 영역 발견 → 정정 영역 후속 영역 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR #684 처리 결과cherry-pick 머지 완료 (2 commits 단계별 보존 + 본 환경 정정 보강 2 commits). PR #684 close + Issue #449 close. 처리 옵션옵션 A — 2 commits 단계별 cherry-pick ( 본 환경 결정적 검증 (모두 통과)
본 환경 정정 보강 영역
|
PR #684 (Issue #449 후속 정정 — rhwpDev 디버깅 툴킷 결함 두 건) 처리 완료 후속 영역: - mydocs/pr/archives/pr_684_review.md (1차 검토 + 옵션 분석) - mydocs/pr/archives/pr_684_report.md (처리 결과 + 본 환경 정정 보강 + Chrome 웹 콘솔 검증) 처리 결과: - 옵션 A: 2 commits cherry-pick + 본 환경 정정 보강 2 commits - devel commits: 44d532e 본질 + 9792fee Copilot 반영 + f73177a main.ts 정정 + a1ea189 search() 가드 (옵션 B) - 메인테이너 Chrome 웹 콘솔 검증: findNearest 통과 + search 미정합 (Issue #692 후속) - PR #684 close + Issue #449 close + Issue #692 신규 등록 본 사이클 (5/7~5/8) PR 처리 누적: 15건
요약
PR #602 cherry-pick 후 메인테이너 시각 판정에서 식별된 결함 두 건을 수정합니다.
결함 #1: paragraph 식별 부정확 (본문 vs 셀 내부 충돌)
getPageTextLayout이 반환하는 runs의parentParaIdx/controlIdx/cellIdx필드를 활용하여 본문 paragraph와 셀 내부 paragraph를 구분합니다.containerKey(): body paragraphs →"body", cell-internal →"cell[p0,c0,i0]"형식showAllIds()출력에container컬럼 추가0:body:0:0≠0:cell[p0,c0,i0]:0:0findNearest()결과에도 container 정보 포함Before:
samples/aift.hwpparagraph 0 에서 본문 텍스트(" * 사업계획서...") 대신 셀 내부 텍스트("※ ") 표시After: 본문과 셀 내부가 별도 행으로 구분됨
결함 #2: 다중 매치 미처리
search(text)가searchText를 반복 호출하여 문서 전체의 모든 매치를 수집합니다.SearchResult→SearchResult[]console.table로 전체 매치 목록 출력console.warn변경 파일
rhwp-studio/src/core/rhwp-dev.ts— 신규 (PR feat: rhwpDev 디버깅 툴킷 — showAllIds / search / findNearest (closes #449) #602 기반 + 결함 수정)rhwp-studio/src/main.ts—initRhwpDev(wasm)호출 추가검증
cargo test --lib: 1066 passed, 0 failedcargo clippy -- -D warnings: clean관련 이슈
fixes #449 (후속 결함 영역)
PR #602 cherry-pick 이후의 후속 수정입니다.