/* 273-1 종단 고름 → 화면 밖이면 가운데로 — 진짜 `createSelectionReveal`(design_profile_viewport.ts)을 * 가짜 스크롤러로 돌림. 표준출력 JSON 한 벌. */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const ROOT = path.join(__dirname, "..", ".."); const js = ts.transpileModule( fs.readFileSync(path.join(ROOT, "A00_Common/design/design_profile_viewport.ts"), "utf8"), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 } }, ).outputText; const box = { exports: {} }; const stubs = { "../../B05_Profile/B05_Profile_UI_Profile_Wheel": { attachWheelHorizontalScroll: () => {} }, "@util/common_util_chart_ywindow": { needsFullRedraw: () => false }, "@util/common_util_view_window": { viewOf: () => globalThis }, }; new Function("exports", "module", "require", js)(box.exports, box, (name) => { if (!stubs[name]) throw new Error(`stub 없음: ${name}`); return stubs[name]; }); /** 폭 700 스크롤러 — 고른 선은 내용 좌표 `lineAt`(없으면 null). */ function scroller(lineAt) { const body = { scrollLeft: 0, clientWidth: 700, line: lineAt, getBoundingClientRect: () => ({ left: 0, width: 700 }), querySelector(selector) { if (this.line === null || !selector.includes("--selected")) return null; const x = this.line - this.scrollLeft; return { getBoundingClientRect: () => ({ left: x - 1, width: 2 }) }; }, }; return body; } const out = {}; const far = scroller(3000); const reveal = box.exports.createSelectionReveal(far); reveal("a"); out.far = far.scrollLeft; // 3000 - 350 far.scrollLeft = 100; // 사용자가 옮겨 봄 reveal("a"); // 같은 고름 다시 칠함 out.same = far.scrollLeft; const near = scroller(400); box.exports.createSelectionReveal(near)("b"); out.near = near.scrollLeft; // 보이는 자리 — 안 밂 const late = scroller(null); const revealLate = box.exports.createSelectionReveal(late); revealLate("c"); // 아직 안 그려짐 late.line = 2000; revealLate("c"); // 그린 뒤 같은 고름 — 이제 밂 out.late = late.scrollLeft; process.stdout.write(JSON.stringify(out));