refactor(web): split touch canvas adapters

This commit is contained in:
2026-04-01 11:09:26 +02:00
parent a4789d718b
commit 922394c56a
7 changed files with 114 additions and 58 deletions
+21 -6
View File
@@ -127,10 +127,6 @@ 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",
@@ -138,6 +134,21 @@ export const rules = [
],
forbidden: [],
},
{
file: "apps/web/src/hooks/timelineTouchAdapters.ts",
maxLines: 60,
required: [
{
pattern: /\bexport function createTouchMouseDownEvent\b/,
message: "timeline touch adapter helpers must keep touch-to-mouse adapter wiring centralized",
},
{
pattern: /\bexport function createTouchCanvasPointerEvent\b/,
message: "timeline touch adapter helpers must keep canvas pointer adapter wiring centralized",
},
],
forbidden: [],
},
{
file: "apps/web/src/hooks/timelineMultiSelect.ts",
maxLines: 90,
@@ -307,6 +318,10 @@ export const rules = [
pattern: /from "\.\/timelineTouch\.js"/,
message: "timeline drag must keep touch fallback and drag disambiguation delegated to the extracted helper module",
},
{
pattern: /from "\.\/timelineTouchAdapters\.js"/,
message: "timeline drag must keep touch pointer adapter wiring delegated to the extracted helper module",
},
{
pattern: /from "\.\/timelineMultiSelect\.js"/,
message: "timeline drag must keep multi-select rectangle lifecycle delegated to the extracted helper module",
@@ -354,8 +369,8 @@ export const rules = [
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: /as (?:unknown as )?React\.MouseEvent/,
message: "timeline drag must not re-inline synthetic touch pointer adapters",
},
{
pattern: /\bfunction (?:hasAllocationDateChange|shouldTreatAllocationDragAsClick|requiresAllocationFragmentExtraction|buildAllocationMovedSnapshot|reconcileOptimisticEntries)\b/,
+10 -2
View File
@@ -72,6 +72,7 @@ describe("architecture guardrails", () => {
const dragRule = rules.find((rule) => rule.file === "apps/web/src/hooks/useTimelineDrag.ts");
const livePreviewRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineLivePreview.ts");
const touchRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineTouch.ts");
const touchAdaptersRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineTouchAdapters.ts");
const multiSelectRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineMultiSelect.ts");
const rangeRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineRangeSelection.ts");
const optimisticRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineOptimisticAllocations.ts");
@@ -86,6 +87,7 @@ describe("architecture guardrails", () => {
assert.ok(dragRule);
assert.ok(livePreviewRule);
assert.ok(touchRule);
assert.ok(touchAdaptersRule);
assert.ok(multiSelectRule);
assert.ok(rangeRule);
assert.ok(optimisticRule);
@@ -100,6 +102,7 @@ describe("architecture guardrails", () => {
assert.deepEqual(evaluateRule(dragRule, "function clearLivePreview() {}\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 touch fallback and drag disambiguation delegated to the extracted helper module",
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep touch pointer adapter wiring 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",
@@ -118,10 +121,14 @@ 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",
]);
assert.deepEqual(evaluateRule(touchAdaptersRule, ""), [
"apps/web/src/hooks/timelineTouchAdapters.ts: missing guardrail anchor: timeline touch adapter helpers must keep touch-to-mouse adapter wiring centralized",
"apps/web/src/hooks/timelineTouchAdapters.ts: missing guardrail anchor: timeline touch adapter helpers must keep canvas pointer adapter wiring centralized",
]);
assert.deepEqual(evaluateRule(multiSelectRule, "export function createMultiSelectState() {}\n"), [
"apps/web/src/hooks/timelineMultiSelect.ts: missing guardrail anchor: timeline multi-select helpers must keep minimal-drag reset logic centralized",
"apps/web/src/hooks/timelineMultiSelect.ts: missing guardrail anchor: timeline multi-select helpers must keep right-click release completion centralized",
@@ -175,6 +182,7 @@ describe("architecture guardrails", () => {
),
[
"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 touch pointer adapter wiring 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",
@@ -184,7 +192,7 @@ describe("architecture guardrails", () => {
"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",
"apps/web/src/hooks/useTimelineDrag.ts: forbidden pattern matched: timeline drag must not re-inline synthetic touch pointer adapters",
],
);
});