refactor(web): centralize touch mouse adapters

This commit is contained in:
2026-04-01 10:43:38 +02:00
parent eda8722d83
commit 0ab1374853
5 changed files with 82 additions and 30 deletions
@@ -127,6 +127,10 @@ export const rules = [
pattern: /\bexport function getTouchPoint\b/,
message: "timeline touch helpers must keep touch coordinate fallback centralized",
},
{
pattern: /\bexport function createTouchMouseDownEvent\b/,
message: "timeline touch helpers must keep touch-to-mouse adapter wiring centralized",
},
{
pattern: /\bexport function resolveTouchDragDecision\b/,
message: "timeline touch helpers must keep scroll-vs-drag disambiguation centralized",
@@ -330,6 +334,10 @@ export const rules = [
pattern: /\bfunction toClientX\b/,
message: "timeline drag must not re-inline touch coordinate fallback helpers",
},
{
pattern: /as unknown as React\.MouseEvent/,
message: "timeline drag must not re-inline synthetic touch mouse-down adapters",
},
{
pattern: /\bfunction (?:hasAllocationDateChange|shouldTreatAllocationDragAsClick|requiresAllocationFragmentExtraction|buildAllocationMovedSnapshot|reconcileOptimisticEntries)\b/,
message: "timeline drag must not re-inline extracted optimistic or allocation finalize helper implementations",
@@ -116,6 +116,7 @@ describe("architecture guardrails", () => {
]);
assert.deepEqual(evaluateRule(touchRule, "export function getTouchPoint() {}\n"), [
"apps/web/src/hooks/timelineTouch.ts: missing guardrail anchor: timeline touch helpers must keep touch-to-mouse adapter wiring centralized",
"apps/web/src/hooks/timelineTouch.ts: missing guardrail anchor: timeline touch helpers must keep scroll-vs-drag disambiguation centralized",
]);
@@ -158,5 +159,25 @@ describe("architecture guardrails", () => {
assert.deepEqual(evaluateRule(projectDragRule, "export function createProjectDragState() {}\n"), [
"apps/web/src/hooks/timelineProjectDrag.ts: missing guardrail anchor: timeline project drag helpers must keep no-op project-shift mutation gating centralized",
]);
assert.deepEqual(
evaluateRule(
dragRule,
'import { getTouchPoint } from "./timelineTouch.js";\nconst e = {} as unknown as React.MouseEvent;\n',
),
[
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep live preview behavior delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep multi-select rectangle lifecycle delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep range preview and finalization delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep optimistic allocation reconciliation delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag completion rules delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation click and mutation plan derivation delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep document mouse listener lifecycle delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation multi-drag rules delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation drag bootstrap delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep project drag bootstrap and mutation gating delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: forbidden pattern matched: timeline drag must not re-inline synthetic touch mouse-down adapters",
],
);
});
});