refactor(web): extract touch event forwarding
This commit is contained in:
@@ -149,6 +149,33 @@ export const rules = [
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/timelineTouchEvents.ts",
|
||||
maxLines: 80,
|
||||
required: [
|
||||
{
|
||||
pattern: /\bexport function forwardTouchStartAsMouseDown\b/,
|
||||
message: "timeline touch event helpers must keep touch-start forwarding centralized",
|
||||
},
|
||||
{
|
||||
pattern: /\bexport function forwardCanvasTouchMove\b/,
|
||||
message: "timeline touch event helpers must keep touch-move forwarding centralized",
|
||||
},
|
||||
{
|
||||
pattern: /\bexport function forwardCanvasTouchEnd\b/,
|
||||
message: "timeline touch event helpers must keep touch-end forwarding centralized",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineTouch\.js"/,
|
||||
message: "timeline touch event helpers must keep touch policy delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineTouchAdapters\.js"/,
|
||||
message: "timeline touch event helpers must keep touch adapter wiring delegated to the extracted helper module",
|
||||
},
|
||||
],
|
||||
forbidden: [],
|
||||
},
|
||||
{
|
||||
file: "apps/web/src/hooks/timelineMultiSelect.ts",
|
||||
maxLines: 90,
|
||||
@@ -404,12 +431,8 @@ export const rules = [
|
||||
message: "timeline drag must keep live preview behavior delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
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 "\.\/timelineTouchEvents\.js"/,
|
||||
message: "timeline drag must keep touch event forwarding delegated to the extracted helper module",
|
||||
},
|
||||
{
|
||||
pattern: /from "\.\/timelineMultiSelect\.js"/,
|
||||
@@ -474,12 +497,8 @@ export const rules = [
|
||||
message: "timeline drag must not re-inline live preview helper implementations",
|
||||
},
|
||||
{
|
||||
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 pointer adapters",
|
||||
pattern: /\b(?:getTouchPoint|resolveTouchDragDecision|createTouchCanvasPointerEvent|createTouchMouseDownEvent)\b/,
|
||||
message: "timeline drag must not re-inline extracted touch event forwarding dependencies",
|
||||
},
|
||||
{
|
||||
pattern: /\bfunction (?:hasAllocationDateChange|shouldTreatAllocationDragAsClick|requiresAllocationFragmentExtraction|buildAllocationMovedSnapshot|reconcileOptimisticEntries)\b/,
|
||||
|
||||
@@ -73,6 +73,7 @@ describe("architecture guardrails", () => {
|
||||
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 touchEventsRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineTouchEvents.ts");
|
||||
const multiSelectRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineMultiSelect.ts");
|
||||
const multiSelectSessionRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineMultiSelectSession.ts");
|
||||
const rangeRule = rules.find((rule) => rule.file === "apps/web/src/hooks/timelineRangeSelection.ts");
|
||||
@@ -99,6 +100,7 @@ describe("architecture guardrails", () => {
|
||||
assert.ok(livePreviewRule);
|
||||
assert.ok(touchRule);
|
||||
assert.ok(touchAdaptersRule);
|
||||
assert.ok(touchEventsRule);
|
||||
assert.ok(multiSelectRule);
|
||||
assert.ok(multiSelectSessionRule);
|
||||
assert.ok(rangeRule);
|
||||
@@ -119,8 +121,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 touch event forwarding 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 multi-select document session wiring 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",
|
||||
@@ -152,6 +153,14 @@ describe("architecture guardrails", () => {
|
||||
"apps/web/src/hooks/timelineTouchAdapters.ts: missing guardrail anchor: timeline touch adapter helpers must keep canvas pointer adapter wiring centralized",
|
||||
]);
|
||||
|
||||
assert.deepEqual(evaluateRule(touchEventsRule, ""), [
|
||||
"apps/web/src/hooks/timelineTouchEvents.ts: missing guardrail anchor: timeline touch event helpers must keep touch-start forwarding centralized",
|
||||
"apps/web/src/hooks/timelineTouchEvents.ts: missing guardrail anchor: timeline touch event helpers must keep touch-move forwarding centralized",
|
||||
"apps/web/src/hooks/timelineTouchEvents.ts: missing guardrail anchor: timeline touch event helpers must keep touch-end forwarding centralized",
|
||||
"apps/web/src/hooks/timelineTouchEvents.ts: missing guardrail anchor: timeline touch event helpers must keep touch policy delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/timelineTouchEvents.ts: missing guardrail anchor: timeline touch event helpers must keep touch adapter wiring delegated to the extracted helper module",
|
||||
]);
|
||||
|
||||
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",
|
||||
@@ -231,11 +240,11 @@ describe("architecture guardrails", () => {
|
||||
assert.deepEqual(
|
||||
evaluateRule(
|
||||
dragRule,
|
||||
'import { getTouchPoint } from "./timelineTouch.js";\nconst e = {} as unknown as React.MouseEvent;\n',
|
||||
'import { getTouchPoint } from "./timelineTouch.js";\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 pointer adapter wiring delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep touch event forwarding 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 multi-select document session wiring 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",
|
||||
@@ -250,7 +259,7 @@ describe("architecture guardrails", () => {
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: missing guardrail anchor: timeline drag must keep allocation release side effects 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: missing guardrail anchor: timeline drag must keep project drag document session wiring delegated to the extracted helper module",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: forbidden pattern matched: timeline drag must not re-inline synthetic touch pointer adapters",
|
||||
"apps/web/src/hooks/useTimelineDrag.ts: forbidden pattern matched: timeline drag must not re-inline extracted touch event forwarding dependencies",
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user