From 12db4faff2e829338a13065b36c210924cbf07ff Mon Sep 17 00:00:00 2001 From: Thomas Plumpton Date: Sat, 5 Jul 2025 23:56:05 +0100 Subject: [PATCH 1/3] chore(graph): extracted CanvasRendered typing into types file --- .../Graph/strategies/Canvas/CanvasRenderer.ts | 33 ++---------------- .../modules/Graph/strategies/Canvas/types.ts | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/packages/library/src/modules/Graph/strategies/Canvas/CanvasRenderer.ts b/packages/library/src/modules/Graph/strategies/Canvas/CanvasRenderer.ts index 5cce0ffc..c66d68d3 100644 --- a/packages/library/src/modules/Graph/strategies/Canvas/CanvasRenderer.ts +++ b/packages/library/src/modules/Graph/strategies/Canvas/CanvasRenderer.ts @@ -1,40 +1,11 @@ import { Commit } from 'types/Commit' import { CommitNodeLocation, EdgeType, GraphData } from 'data' -import { CommitNodeColours, NodeTheme } from 'hooks/useTheme' +import { NodeTheme } from 'hooks/useTheme' import { NODE_BORDER_WIDTH, ROW_HEIGHT } from 'constants/constants' import { getMergeNodeInnerSize } from 'modules/Graph/utils/getMergeNodeInnerSize' import { GraphOrientation } from 'modules/Graph' import { getColumnBackgroundSize } from 'modules/Graph/utils/getColumnBackgroundSize' -import { MousePosition } from 'modules/Graph/strategies/Canvas/types' - -export interface CanvasRendererProps { - ctx: CanvasRenderingContext2D - commits: Commit[] - rowSpacing: number - graphData: GraphData - nodeSize: number - nodeTheme: NodeTheme - canvasHeight: number - canvasWidth: number - showTable: boolean - selectedCommitHash?: string - previewedCommitHash?: string - previewBackgroundColour: string - orientation: GraphOrientation - isIndexVisible: boolean - isServerSidePaginated: boolean - indexCommit?: Commit - headCommit?: Commit - getColours: GetCanvasRendererColoursFunction -} - -export type GetCanvasRendererColoursFunction = (columnIndex: number) => CanvasRenderersColours - -export interface CanvasRenderersColours { - commitNode: CommitNodeColours - selectedColumnBackgroundColour: string - indexCommitColour: string -} +import { CanvasRendererProps, GetCanvasRendererColoursFunction, MousePosition } from './types' export class CanvasRenderer { private readonly ctx: CanvasRenderingContext2D diff --git a/packages/library/src/modules/Graph/strategies/Canvas/types.ts b/packages/library/src/modules/Graph/strategies/Canvas/types.ts index d21595e1..621c7aa9 100644 --- a/packages/library/src/modules/Graph/strategies/Canvas/types.ts +++ b/packages/library/src/modules/Graph/strategies/Canvas/types.ts @@ -1,4 +1,38 @@ +import { Commit } from 'types/Commit' +import { GraphData } from 'data' +import { CommitNodeColours, NodeTheme } from 'hooks/useTheme' +import { GraphOrientation } from 'modules/Graph' + export interface MousePosition { x: number y: number +} + +export interface CanvasRendererProps { + ctx: CanvasRenderingContext2D + commits: Commit[] + rowSpacing: number + graphData: GraphData + nodeSize: number + nodeTheme: NodeTheme + canvasHeight: number + canvasWidth: number + showTable: boolean + selectedCommitHash?: string + previewedCommitHash?: string + previewBackgroundColour: string + orientation: GraphOrientation + isIndexVisible: boolean + isServerSidePaginated: boolean + indexCommit?: Commit + headCommit?: Commit + getColours: GetCanvasRendererColoursFunction +} + +export type GetCanvasRendererColoursFunction = (columnIndex: number) => CanvasRenderersColours + +export interface CanvasRenderersColours { + commitNode: CommitNodeColours + selectedColumnBackgroundColour: string + indexCommitColour: string } \ No newline at end of file From 8cca210453834842620a1f5c83512817490d3ec5 Mon Sep 17 00:00:00 2001 From: Thomas Plumpton Date: Sun, 6 Jul 2025 11:49:44 +0100 Subject: [PATCH 2/3] chore(graph): fixed bad exports in canvas renderer --- .../src/modules/Graph/strategies/Canvas/Canvas2DGraph.tsx | 2 +- packages/library/src/modules/Graph/strategies/Canvas/index.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/library/src/modules/Graph/strategies/Canvas/Canvas2DGraph.tsx b/packages/library/src/modules/Graph/strategies/Canvas/Canvas2DGraph.tsx index df12c2cb..c0e8468c 100644 --- a/packages/library/src/modules/Graph/strategies/Canvas/Canvas2DGraph.tsx +++ b/packages/library/src/modules/Graph/strategies/Canvas/Canvas2DGraph.tsx @@ -6,7 +6,7 @@ import { useTheme } from 'hooks/useTheme' import { CanvasRenderer, GetCanvasRendererColoursFunction -} from 'modules/Graph/strategies/Canvas/CanvasRenderer' +} from 'modules/Graph/strategies/Canvas' import { useSelectCommit } from 'hooks/useSelectCommit' import styles from './Canvas2DGraph.module.scss' diff --git a/packages/library/src/modules/Graph/strategies/Canvas/index.ts b/packages/library/src/modules/Graph/strategies/Canvas/index.ts index 044a7439..980489b2 100644 --- a/packages/library/src/modules/Graph/strategies/Canvas/index.ts +++ b/packages/library/src/modules/Graph/strategies/Canvas/index.ts @@ -1 +1,3 @@ -export * from './Canvas2DGraph' \ No newline at end of file +export * from './Canvas2DGraph' +export * from './CanvasRenderer' +export * from './types' \ No newline at end of file From 93ae2c124160524013df1aeda4219d952bfacc86 Mon Sep 17 00:00:00 2001 From: Thomas Plumpton Date: Sun, 6 Jul 2025 12:01:26 +0100 Subject: [PATCH 3/3] chore(graph): removed canvas strategy types from library exports --- packages/library/src/modules/Graph/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/library/src/modules/Graph/index.ts b/packages/library/src/modules/Graph/index.ts index c04c16e5..15e18800 100644 --- a/packages/library/src/modules/Graph/index.ts +++ b/packages/library/src/modules/Graph/index.ts @@ -1,7 +1,6 @@ export * from './types' export * from './GraphCanvas2D' -export * from './strategies/Canvas/types' export * from './GraphHTMLGrid' export * from './strategies/Grid/types' \ No newline at end of file