- 새 A00_Common/input_prefs.ts(INPUT_PREFS_KEY · DEFAULT_INPUT_PREFS · inputPrefs · wheelIn · wheelEventIn · 의존 없음) - 등록표 input-prefs(pref · global) 한 줄 - touch_bridge wheelZoomsIn · b_svg_zoom_pan · B04 3D 카메라 · M02 DF 그림 · M02 노무 그림 · 돋보기 · 시트 배선 - M02 그림 · 시트 · 돋보기 기본 방향 = 당김(지금과 반대) - 시험: test_input_prefs 새로 · 돋보기 · 266 · 244-8 헬퍼가 읽기 층을 불러옴 · 돋보기 부호 당김 기본 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QfHKQs7J3hQELKMWQMUJEy
64 lines
2.7 KiB
JavaScript
64 lines
2.7 KiB
JavaScript
/* PLAN 332-1 단위검증 헬퍼 — 휠 방향 읽기 층(`A00_Common/input_prefs.ts`) · 손가락 다리(`touch_bridge.ts`)
|
|
* · 등록표 키(`b_page_state.ts`)를 그 자리에서 트랜스파일해 Node 로 돌림. 가짜 localStorage 로 설정을 바꿔 봄.
|
|
* 결과 = 표준출력 JSON 한 벌. 짝 = `test_input_prefs.py`. */
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const A00 = path.join(ROOT, "A00_Common");
|
|
function load(file) {
|
|
const js = ts.transpileModule(fs.readFileSync(file, "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const box = { exports: {} };
|
|
const req = (p) => (p === "./input_prefs" ? prefs : {});
|
|
new Function("exports", "module", "require", js)(box.exports, box, req);
|
|
return box.exports;
|
|
}
|
|
|
|
const out = {};
|
|
// ① Node(저장소 없음) — 불러올 때 window 를 안 만지고 기본값
|
|
const prefs = load(path.join(A00, "input_prefs.ts"));
|
|
const bridge = load(path.join(A00, "touch_bridge.ts"));
|
|
const page = load(path.join(A00, "b_page_state.ts"));
|
|
const sample = () => ({
|
|
prefs: prefs.inputPrefs(),
|
|
pull: prefs.wheelIn(100),
|
|
push: prefs.wheelIn(-100),
|
|
mouseCtrl: prefs.wheelEventIn({ ctrlKey: true, deltaY: 100 }),
|
|
padSpread: prefs.wheelEventIn({ ctrlKey: true, deltaY: -3.5 }),
|
|
padPinch: prefs.wheelEventIn({ ctrlKey: true, deltaY: 3.5 }),
|
|
fingerSpread: prefs.wheelEventIn({ ctrlKey: true, deltaY: -9.5 }, true),
|
|
bridgePull: bridge.wheelZoomsIn({ ctrlKey: false, deltaY: 100 }),
|
|
});
|
|
out.node = { key: prefs.INPUT_PREFS_KEY, default: prefs.DEFAULT_INPUT_PREFS, ...sample() };
|
|
out.registryKey = page.stateKey("input-prefs");
|
|
out.registryEntry = page.STATE_REGISTRY["input-prefs"];
|
|
|
|
// ② 브라우저 저장소 흉내 — 값을 바꾸면 다음 부름부터 바로 따름
|
|
const store = new Map();
|
|
globalThis.localStorage = {
|
|
getItem: (k) => (store.has(k) ? store.get(k) : null),
|
|
setItem: (k, v) => store.set(k, String(v)),
|
|
removeItem: (k) => store.delete(k),
|
|
};
|
|
const set = (v) => store.set(prefs.INPUT_PREFS_KEY, v);
|
|
set(JSON.stringify({ wheelZoom: "push", cadAliases: { line: ["ll", 3], ARC: [] } }));
|
|
out.push = sample();
|
|
set("{깨짐");
|
|
out.broken = sample();
|
|
set(JSON.stringify({ wheelZoom: "sideways" }));
|
|
out.unknown = sample();
|
|
store.delete(prefs.INPUT_PREFS_KEY);
|
|
out.empty = sample();
|
|
// ③ 불러오는 동안 저장소가 던지는 브라우저(사생활 보호) — 기본값
|
|
globalThis.localStorage = {
|
|
getItem: () => {
|
|
throw new Error("blocked");
|
|
},
|
|
};
|
|
out.blocked = sample();
|
|
|
|
process.stdout.write(JSON.stringify(out));
|