fix: Lint

This commit is contained in:
Mark Tolmacs
2025-10-21 21:03:45 +02:00
parent 27f4e55945
commit 9fa2f438b9

View File

@@ -98,7 +98,7 @@ import type {
const renderElbowArrowMidPointHighlight = ( const renderElbowArrowMidPointHighlight = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState appState: InteractiveCanvasAppState,
) => { ) => {
invariant(appState.selectedLinearElement, "selectedLinearElement is null"); invariant(appState.selectedLinearElement, "selectedLinearElement is null");
@@ -117,13 +117,13 @@ const renderElbowArrowMidPointHighlight = (
const renderLinearElementPointHighlight = ( const renderLinearElementPointHighlight = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
elementsMap: ElementsMap elementsMap: ElementsMap,
) => { ) => {
const { elementId, hoverPointIndex } = appState.selectedLinearElement!; const { elementId, hoverPointIndex } = appState.selectedLinearElement!;
if ( if (
appState.selectedLinearElement?.isEditing && appState.selectedLinearElement?.isEditing &&
appState.selectedLinearElement?.selectedPointsIndices?.includes( appState.selectedLinearElement?.selectedPointsIndices?.includes(
hoverPointIndex hoverPointIndex,
) )
) { ) {
return; return;
@@ -136,7 +136,7 @@ const renderLinearElementPointHighlight = (
const point = LinearElementEditor.getPointAtIndexGlobalCoordinates( const point = LinearElementEditor.getPointAtIndexGlobalCoordinates(
element, element,
hoverPointIndex, hoverPointIndex,
elementsMap elementsMap,
); );
context.save(); context.save();
context.translate(appState.scrollX, appState.scrollY); context.translate(appState.scrollX, appState.scrollY);
@@ -148,7 +148,7 @@ const renderLinearElementPointHighlight = (
const highlightPoint = <Point extends LocalPoint | GlobalPoint>( const highlightPoint = <Point extends LocalPoint | GlobalPoint>(
point: Point, point: Point,
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState appState: InteractiveCanvasAppState,
) => { ) => {
context.fillStyle = "rgba(105, 101, 219, 0.4)"; context.fillStyle = "rgba(105, 101, 219, 0.4)";
@@ -157,7 +157,7 @@ const highlightPoint = <Point extends LocalPoint | GlobalPoint>(
point[0], point[0],
point[1], point[1],
LinearElementEditor.POINT_HANDLE_SIZE / appState.zoom.value, LinearElementEditor.POINT_HANDLE_SIZE / appState.zoom.value,
false false,
); );
}; };
@@ -168,7 +168,7 @@ const renderSingleLinearPoint = <Point extends GlobalPoint | LocalPoint>(
radius: number, radius: number,
isSelected: boolean, isSelected: boolean,
isPhantomPoint: boolean, isPhantomPoint: boolean,
isOverlappingPoint: boolean isOverlappingPoint: boolean,
) => { ) => {
context.strokeStyle = "#5e5ad8"; context.strokeStyle = "#5e5ad8";
context.setLineDash([]); context.setLineDash([]);
@@ -187,7 +187,7 @@ const renderSingleLinearPoint = <Point extends GlobalPoint | LocalPoint>(
? radius * (appState.selectedLinearElement?.isEditing ? 1.5 : 2) ? radius * (appState.selectedLinearElement?.isEditing ? 1.5 : 2)
: radius) / appState.zoom.value, : radius) / appState.zoom.value,
!isPhantomPoint, !isPhantomPoint,
!isOverlappingPoint || isSelected !isOverlappingPoint || isSelected,
); );
}; };
@@ -198,7 +198,7 @@ const renderBindingHighlightForBindableElement = (
allElementsMap: NonDeletedSceneElementsMap, allElementsMap: NonDeletedSceneElementsMap,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
deltaTime: number, deltaTime: number,
state?: { runtime: number } state?: { runtime: number },
) => { ) => {
const countdownInProgress = const countdownInProgress =
app.state.bindMode === "orbit" && app.bindModeHandler !== null; app.state.bindMode === "orbit" && app.bindModeHandler !== null;
@@ -213,7 +213,7 @@ const renderBindingHighlightForBindableElement = (
if (enclosingFrame && isFrameLikeElement(enclosingFrame)) { if (enclosingFrame && isFrameLikeElement(enclosingFrame)) {
context.translate( context.translate(
enclosingFrame.x + appState.scrollX, enclosingFrame.x + appState.scrollX,
enclosingFrame.y + appState.scrollY enclosingFrame.y + appState.scrollY,
); );
context.beginPath(); context.beginPath();
@@ -224,7 +224,7 @@ const renderBindingHighlightForBindableElement = (
-1, -1,
enclosingFrame.width + 1, enclosingFrame.width + 1,
enclosingFrame.height + 1, enclosingFrame.height + 1,
FRAME_STYLE.radius / appState.zoom.value FRAME_STYLE.radius / appState.zoom.value,
); );
} else { } else {
context.rect(-1, -1, enclosingFrame.width + 1, enclosingFrame.height + 1); context.rect(-1, -1, enclosingFrame.width + 1, enclosingFrame.height + 1);
@@ -234,7 +234,7 @@ const renderBindingHighlightForBindableElement = (
context.translate( context.translate(
-(enclosingFrame.x + appState.scrollX), -(enclosingFrame.x + appState.scrollX),
-(enclosingFrame.y + appState.scrollY) -(enclosingFrame.y + appState.scrollY),
); );
} }
@@ -245,7 +245,7 @@ const renderBindingHighlightForBindableElement = (
context.translate( context.translate(
element.x + appState.scrollX, element.x + appState.scrollX,
element.y + appState.scrollY element.y + appState.scrollY,
); );
context.lineWidth = FRAME_STYLE.strokeWidth / appState.zoom.value; context.lineWidth = FRAME_STYLE.strokeWidth / appState.zoom.value;
@@ -261,7 +261,7 @@ const renderBindingHighlightForBindableElement = (
0, 0,
element.width, element.width,
element.height, element.height,
FRAME_STYLE.radius / appState.zoom.value FRAME_STYLE.radius / appState.zoom.value,
); );
context.stroke(); context.stroke();
context.closePath(); context.closePath();
@@ -284,7 +284,7 @@ const renderBindingHighlightForBindableElement = (
context.translate( context.translate(
element.x + appState.scrollX - offset, element.x + appState.scrollX - offset,
element.y + appState.scrollY - offset element.y + appState.scrollY - offset,
); );
context.lineWidth = context.lineWidth =
@@ -305,7 +305,7 @@ const renderBindingHighlightForBindableElement = (
(element.height + offset * 2) / 2, (element.height + offset * 2) / 2,
0, 0,
0, 0,
2 * Math.PI 2 * Math.PI,
); );
context.closePath(); context.closePath();
context.stroke(); context.stroke();
@@ -314,7 +314,7 @@ const renderBindingHighlightForBindableElement = (
{ {
const [segments, curves] = deconstructDiamondElement( const [segments, curves] = deconstructDiamondElement(
element, element,
offset offset,
); );
// Draw each line segment individually // Draw each line segment individually
@@ -322,11 +322,11 @@ const renderBindingHighlightForBindableElement = (
context.beginPath(); context.beginPath();
context.moveTo( context.moveTo(
segment[0][0] - element.x + offset, segment[0][0] - element.x + offset,
segment[0][1] - element.y + offset segment[0][1] - element.y + offset,
); );
context.lineTo( context.lineTo(
segment[1][0] - element.x + offset, segment[1][0] - element.x + offset,
segment[1][1] - element.y + offset segment[1][1] - element.y + offset,
); );
context.stroke(); context.stroke();
}); });
@@ -337,7 +337,7 @@ const renderBindingHighlightForBindableElement = (
context.beginPath(); context.beginPath();
context.moveTo( context.moveTo(
start[0] - element.x + offset, start[0] - element.x + offset,
start[1] - element.y + offset start[1] - element.y + offset,
); );
context.bezierCurveTo( context.bezierCurveTo(
control1[0] - element.x + offset, control1[0] - element.x + offset,
@@ -345,7 +345,7 @@ const renderBindingHighlightForBindableElement = (
control2[0] - element.x + offset, control2[0] - element.x + offset,
control2[1] - element.y + offset, control2[1] - element.y + offset,
end[0] - element.x + offset, end[0] - element.x + offset,
end[1] - element.y + offset end[1] - element.y + offset,
); );
context.stroke(); context.stroke();
}); });
@@ -356,7 +356,7 @@ const renderBindingHighlightForBindableElement = (
{ {
const [segments, curves] = deconstructRectanguloidElement( const [segments, curves] = deconstructRectanguloidElement(
element, element,
offset offset,
); );
// Draw each line segment individually // Draw each line segment individually
@@ -364,11 +364,11 @@ const renderBindingHighlightForBindableElement = (
context.beginPath(); context.beginPath();
context.moveTo( context.moveTo(
segment[0][0] - element.x + offset, segment[0][0] - element.x + offset,
segment[0][1] - element.y + offset segment[0][1] - element.y + offset,
); );
context.lineTo( context.lineTo(
segment[1][0] - element.x + offset, segment[1][0] - element.x + offset,
segment[1][1] - element.y + offset segment[1][1] - element.y + offset,
); );
context.stroke(); context.stroke();
}); });
@@ -379,7 +379,7 @@ const renderBindingHighlightForBindableElement = (
context.beginPath(); context.beginPath();
context.moveTo( context.moveTo(
start[0] - element.x + offset, start[0] - element.x + offset,
start[1] - element.y + offset start[1] - element.y + offset,
); );
context.bezierCurveTo( context.bezierCurveTo(
control1[0] - element.x + offset, control1[0] - element.x + offset,
@@ -387,7 +387,7 @@ const renderBindingHighlightForBindableElement = (
control2[0] - element.x + offset, control2[0] - element.x + offset,
control2[1] - element.y + offset, control2[1] - element.y + offset,
end[0] - element.x + offset, end[0] - element.x + offset,
end[1] - element.y + offset end[1] - element.y + offset,
); );
context.stroke(); context.stroke();
}); });
@@ -413,7 +413,7 @@ const renderBindingHighlightForBindableElement = (
context.save(); context.save();
context.translate( context.translate(
element.x + appState.scrollX, element.x + appState.scrollX,
element.y + appState.scrollY element.y + appState.scrollY,
); );
const PROGRESS_RATIO = (1 / BIND_MODE_TIMEOUT) * remainingTime; const PROGRESS_RATIO = (1 / BIND_MODE_TIMEOUT) * remainingTime;
@@ -431,7 +431,7 @@ const renderBindingHighlightForBindableElement = (
radius, radius,
0, 0,
0, 0,
2 * Math.PI 2 * Math.PI,
); );
context.stroke(); context.stroke();
@@ -445,7 +445,7 @@ const renderBindingHighlightForBindableElement = (
radius * (1 - opacity), radius * (1 - opacity),
0, 0,
0, 0,
2 * Math.PI 2 * Math.PI,
); );
context.fill(); context.fill();
@@ -475,7 +475,7 @@ type ElementSelectionBorder = {
const renderSelectionBorder = ( const renderSelectionBorder = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
elementProperties: ElementSelectionBorder elementProperties: ElementSelectionBorder,
) => { ) => {
const { const {
angle, angle,
@@ -521,7 +521,7 @@ const renderSelectionBorder = (
elementHeight + linePadding * 2, elementHeight + linePadding * 2,
cx, cx,
cy, cy,
angle angle,
); );
} }
context.restore(); context.restore();
@@ -531,7 +531,7 @@ const renderFrameHighlight = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
frame: NonDeleted<ExcalidrawFrameLikeElement>, frame: NonDeleted<ExcalidrawFrameLikeElement>,
elementsMap: ElementsMap elementsMap: ElementsMap,
) => { ) => {
const [x1, y1, x2, y2] = getElementAbsoluteCoords(frame, elementsMap); const [x1, y1, x2, y2] = getElementAbsoluteCoords(frame, elementsMap);
const width = x2 - x1; const width = x2 - x1;
@@ -552,7 +552,7 @@ const renderFrameHighlight = (
y1 + height / 2, y1 + height / 2,
frame.angle, frame.angle,
false, false,
FRAME_STYLE.radius / appState.zoom.value FRAME_STYLE.radius / appState.zoom.value,
); );
context.restore(); context.restore();
}; };
@@ -561,15 +561,15 @@ const renderElementsBoxHighlight = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
elements: NonDeleted<ExcalidrawElement>[], elements: NonDeleted<ExcalidrawElement>[],
config?: { colors?: string[]; dashed?: boolean } config?: { colors?: string[]; dashed?: boolean },
) => { ) => {
const { colors = ["rgb(0,118,255)"], dashed = false } = config || {}; const { colors = ["rgb(0,118,255)"], dashed = false } = config || {};
const individualElements = elements.filter( const individualElements = elements.filter(
(element) => element.groupIds.length === 0 (element) => element.groupIds.length === 0,
); );
const elementsInGroups = elements.filter( const elementsInGroups = elements.filter(
(element) => element.groupIds.length > 0 (element) => element.groupIds.length > 0,
); );
const getSelectionFromElements = (elements: ExcalidrawElement[]) => { const getSelectionFromElements = (elements: ExcalidrawElement[]) => {
@@ -598,10 +598,10 @@ const renderElementsBoxHighlight = (
.map(([id, isSelected]) => id) .map(([id, isSelected]) => id)
.map((groupId) => getSelectionForGroupId(groupId)) .map((groupId) => getSelectionForGroupId(groupId))
.concat( .concat(
individualElements.map((element) => getSelectionFromElements([element])) individualElements.map((element) => getSelectionFromElements([element])),
) )
.forEach((selection) => .forEach((selection) =>
renderSelectionBorder(context, appState, selection) renderSelectionBorder(context, appState, selection),
); );
}; };
@@ -609,7 +609,7 @@ const renderLinearPointHandles = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
element: NonDeleted<ExcalidrawLinearElement>, element: NonDeleted<ExcalidrawLinearElement>,
elementsMap: RenderableElementsMap elementsMap: RenderableElementsMap,
) => { ) => {
if (!appState.selectedLinearElement) { if (!appState.selectedLinearElement) {
return; return;
@@ -619,7 +619,7 @@ const renderLinearPointHandles = (
context.lineWidth = 1 / appState.zoom.value; context.lineWidth = 1 / appState.zoom.value;
const points: GlobalPoint[] = LinearElementEditor.getPointsGlobalCoordinates( const points: GlobalPoint[] = LinearElementEditor.getPointsGlobalCoordinates(
element, element,
elementsMap elementsMap,
); );
const { POINT_HANDLE_SIZE } = LinearElementEditor; const { POINT_HANDLE_SIZE } = LinearElementEditor;
@@ -641,7 +641,7 @@ const renderLinearPointHandles = (
pointsEqual( pointsEqual(
point, point,
idx === points.length - 1 ? points[0] : points[idx - 1], idx === points.length - 1 ? points[0] : points[idx - 1],
2 / appState.zoom.value 2 / appState.zoom.value,
); );
let isSelected = let isSelected =
@@ -668,7 +668,7 @@ const renderLinearPointHandles = (
radius, radius,
isSelected, isSelected,
false, false,
isOverlappingPoint isOverlappingPoint,
); );
}); });
@@ -683,7 +683,7 @@ const renderLinearPointHandles = (
points[idx + 1], points[idx + 1],
points[idx], points[idx],
idx, idx,
appState.zoom appState.zoom,
) )
) { ) {
renderSingleLinearPoint( renderSingleLinearPoint(
@@ -691,12 +691,12 @@ const renderLinearPointHandles = (
appState, appState,
pointFrom<GlobalPoint>( pointFrom<GlobalPoint>(
(p[0] + points[idx + 1][0]) / 2, (p[0] + points[idx + 1][0]) / 2,
(p[1] + points[idx + 1][1]) / 2 (p[1] + points[idx + 1][1]) / 2,
), ),
POINT_HANDLE_SIZE / 2, POINT_HANDLE_SIZE / 2,
false, false,
!fixedSegments.includes(idx + 1), !fixedSegments.includes(idx + 1),
false false,
); );
} }
}); });
@@ -704,11 +704,11 @@ const renderLinearPointHandles = (
const midPoints = LinearElementEditor.getEditorMidPoints( const midPoints = LinearElementEditor.getEditorMidPoints(
element, element,
elementsMap, elementsMap,
appState appState,
).filter( ).filter(
(midPoint, idx, midPoints): midPoint is GlobalPoint => (midPoint, idx, midPoints): midPoint is GlobalPoint =>
midPoint !== null && midPoint !== null &&
!(isElbowArrow(element) && (idx === 0 || idx === midPoints.length - 1)) !(isElbowArrow(element) && (idx === 0 || idx === midPoints.length - 1)),
); );
midPoints.forEach((segmentMidPoint) => { midPoints.forEach((segmentMidPoint) => {
@@ -720,7 +720,7 @@ const renderLinearPointHandles = (
POINT_HANDLE_SIZE / 2, POINT_HANDLE_SIZE / 2,
false, false,
true, true,
false false,
); );
} }
}); });
@@ -734,7 +734,7 @@ const renderTransformHandles = (
renderConfig: InteractiveCanvasRenderConfig, renderConfig: InteractiveCanvasRenderConfig,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
transformHandles: TransformHandles, transformHandles: TransformHandles,
angle: number angle: number,
): void => { ): void => {
Object.keys(transformHandles).forEach((key) => { Object.keys(transformHandles).forEach((key) => {
const transformHandle = transformHandles[key as TransformHandleType]; const transformHandle = transformHandles[key as TransformHandleType];
@@ -764,7 +764,7 @@ const renderTransformHandles = (
x + width / 2, x + width / 2,
y + height / 2, y + height / 2,
angle, angle,
true // fill before stroke true, // fill before stroke
); );
} }
context.restore(); context.restore();
@@ -777,11 +777,11 @@ const renderCropHandles = (
renderConfig: InteractiveCanvasRenderConfig, renderConfig: InteractiveCanvasRenderConfig,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
croppingElement: ExcalidrawImageElement, croppingElement: ExcalidrawImageElement,
elementsMap: ElementsMap elementsMap: ElementsMap,
): void => { ): void => {
const [x1, y1, , , cx, cy] = getElementAbsoluteCoords( const [x1, y1, , , cx, cy] = getElementAbsoluteCoords(
croppingElement, croppingElement,
elementsMap elementsMap,
); );
const LINE_WIDTH = 3; const LINE_WIDTH = 3;
@@ -795,11 +795,11 @@ const renderCropHandles = (
const HORIZONTAL_LINE_LENGTH = Math.min( const HORIZONTAL_LINE_LENGTH = Math.min(
LINE_LENGTH / appState.zoom.value, LINE_LENGTH / appState.zoom.value,
HALF_WIDTH HALF_WIDTH,
); );
const VERTICAL_LINE_LENGTH = Math.min( const VERTICAL_LINE_LENGTH = Math.min(
LINE_LENGTH / appState.zoom.value, LINE_LENGTH / appState.zoom.value,
HALF_HEIGHT HALF_HEIGHT,
); );
context.save(); context.save();
@@ -813,7 +813,7 @@ const renderCropHandles = (
[number, number], [number, number],
[number, number], [number, number],
[number, number], [number, number],
[number, number] [number, number],
] ]
> = [ > = [
[ [
@@ -881,7 +881,7 @@ const renderTextBox = (
text: NonDeleted<ExcalidrawTextElement>, text: NonDeleted<ExcalidrawTextElement>,
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
selectionColor: InteractiveCanvasRenderConfig["selectionColor"] selectionColor: InteractiveCanvasRenderConfig["selectionColor"],
) => { ) => {
context.save(); context.save();
const padding = (DEFAULT_TRANSFORM_HANDLE_SPACING * 2) / appState.zoom.value; const padding = (DEFAULT_TRANSFORM_HANDLE_SPACING * 2) / appState.zoom.value;
@@ -924,7 +924,7 @@ const _renderInteractiveScene = ({
const [normalizedWidth, normalizedHeight] = getNormalizedCanvasDimensions( const [normalizedWidth, normalizedHeight] = getNormalizedCanvasDimensions(
canvas, canvas,
scale scale,
); );
let nextAnimationState = animationState; let nextAnimationState = animationState;
@@ -961,7 +961,7 @@ const _renderInteractiveScene = ({
context, context,
appState, appState,
editingLinearElement, editingLinearElement,
elementsMap elementsMap,
); );
} }
@@ -972,7 +972,7 @@ const _renderInteractiveScene = ({
appState.selectionElement, appState.selectionElement,
context, context,
appState, appState,
renderConfig.selectionColor renderConfig.selectionColor,
); );
} catch (error: any) { } catch (error: any) {
console.error(error); console.error(error);
@@ -991,7 +991,7 @@ const _renderInteractiveScene = ({
textElement, textElement,
context, context,
appState, appState,
renderConfig.selectionColor renderConfig.selectionColor,
); );
} }
} }
@@ -1006,7 +1006,7 @@ const _renderInteractiveScene = ({
allElementsMap, allElementsMap,
appState, appState,
deltaTime, deltaTime,
animationState?.bindingHighlight animationState?.bindingHighlight,
), ),
}; };
} else { } else {
@@ -1021,7 +1021,7 @@ const _renderInteractiveScene = ({
context, context,
appState, appState,
appState.frameToHighlight, appState.frameToHighlight,
elementsMap elementsMap,
); );
} }
@@ -1041,7 +1041,7 @@ const _renderInteractiveScene = ({
} }
const isFrameSelected = selectedElements.some((element) => const isFrameSelected = selectedElements.some((element) =>
isFrameLikeElement(element) isFrameLikeElement(element),
); );
// Getting the element using LinearElementEditor during collab mismatches version - being one head of visible elements due to // Getting the element using LinearElementEditor during collab mismatches version - being one head of visible elements due to
@@ -1056,7 +1056,7 @@ const _renderInteractiveScene = ({
context, context,
appState, appState,
selectedElements[0] as NonDeleted<ExcalidrawLinearElement>, selectedElements[0] as NonDeleted<ExcalidrawLinearElement>,
elementsMap elementsMap,
); );
} }
@@ -1065,7 +1065,7 @@ const _renderInteractiveScene = ({
if (appState.selectedLinearElement) { if (appState.selectedLinearElement) {
const editor = appState.selectedLinearElement; const editor = appState.selectedLinearElement;
const firstSelectedLinear = selectedElements.find( const firstSelectedLinear = selectedElements.find(
(el) => el.id === editor.elementId // Don't forget bound text elements! (el) => el.id === editor.elementId, // Don't forget bound text elements!
); );
if (editor.segmentMidPointHoveredCoords) { if (editor.segmentMidPointHoveredCoords) {
@@ -1100,7 +1100,7 @@ const _renderInteractiveScene = ({
context, context,
appState, appState,
selectedElements[0] as ExcalidrawLinearElement, selectedElements[0] as ExcalidrawLinearElement,
elementsMap elementsMap,
); );
} }
const selectionColor = renderConfig.selectionColor || oc.black; const selectionColor = renderConfig.selectionColor || oc.black;
@@ -1114,7 +1114,7 @@ const _renderInteractiveScene = ({
for (const element of elementsMap.values()) { for (const element of elementsMap.values()) {
const selectionColors = []; const selectionColors = [];
const remoteClients = renderConfig.remoteSelectedElementIds.get( const remoteClients = renderConfig.remoteSelectedElementIds.get(
element.id element.id,
); );
if ( if (
!( !(
@@ -1139,10 +1139,10 @@ const _renderInteractiveScene = ({
...remoteClients.map((socketId) => { ...remoteClients.map((socketId) => {
const background = getClientColor( const background = getClientColor(
socketId, socketId,
appState.collaborators.get(socketId) appState.collaborators.get(socketId),
); );
return background; return background;
}) }),
); );
} }
} }
@@ -1151,7 +1151,7 @@ const _renderInteractiveScene = ({
const [x1, y1, x2, y2, cx, cy] = getElementAbsoluteCoords( const [x1, y1, x2, y2, cx, cy] = getElementAbsoluteCoords(
element, element,
elementsMap, elementsMap,
true true,
); );
selections.push({ selections.push({
angle: element.angle, angle: element.angle,
@@ -1204,7 +1204,7 @@ const _renderInteractiveScene = ({
} }
selections.forEach((selection) => selections.forEach((selection) =>
renderSelectionBorder(context, appState, selection) renderSelectionBorder(context, appState, selection),
); );
} }
// Paint resize transformHandles // Paint resize transformHandles
@@ -1218,7 +1218,7 @@ const _renderInteractiveScene = ({
appState.zoom, appState.zoom,
elementsMap, elementsMap,
"mouse", // when we render we don't know which pointer type so use mouse, "mouse", // when we render we don't know which pointer type so use mouse,
getOmitSidesForDevice(device) getOmitSidesForDevice(device),
); );
if ( if (
!appState.viewModeEnabled && !appState.viewModeEnabled &&
@@ -1233,7 +1233,7 @@ const _renderInteractiveScene = ({
renderConfig, renderConfig,
appState, appState,
transformHandles, transformHandles,
selectedElements[0].angle selectedElements[0].angle,
); );
} }
@@ -1246,7 +1246,7 @@ const _renderInteractiveScene = ({
renderConfig, renderConfig,
appState, appState,
croppingElement, croppingElement,
elementsMap elementsMap,
); );
} }
} }
@@ -1272,7 +1272,7 @@ const _renderInteractiveScene = ({
y2 - y1 + dashedLinePadding * 2, y2 - y1 + dashedLinePadding * 2,
(x1 + x2) / 2, (x1 + x2) / 2,
(y1 + y2) / 2, (y1 + y2) / 2,
0 0,
); );
context.lineWidth = lineWidth; context.lineWidth = lineWidth;
context.setLineDash(initialLineDash); context.setLineDash(initialLineDash);
@@ -1283,7 +1283,7 @@ const _renderInteractiveScene = ({
"mouse", "mouse",
isFrameSelected isFrameSelected
? { ...getOmitSidesForDevice(device), rotation: true } ? { ...getOmitSidesForDevice(device), rotation: true }
: getOmitSidesForDevice(device) : getOmitSidesForDevice(device),
); );
if (selectedElements.some((element) => !element.locked)) { if (selectedElements.some((element) => !element.locked)) {
renderTransformHandles( renderTransformHandles(
@@ -1291,7 +1291,7 @@ const _renderInteractiveScene = ({
renderConfig, renderConfig,
appState, appState,
transformHandles, transformHandles,
0 0,
); );
} }
} }
@@ -1305,7 +1305,7 @@ const _renderInteractiveScene = ({
const [elementX1, elementY1, , , cx, cy] = getElementAbsoluteCoords( const [elementX1, elementY1, , , cx, cy] = getElementAbsoluteCoords(
element, element,
elementsMap, elementsMap,
true true,
); );
context.save(); context.save();
@@ -1333,7 +1333,7 @@ const _renderInteractiveScene = ({
elementX1 + matchedLine.offsetX / zoomFactor - cx, elementX1 + matchedLine.offsetX / zoomFactor - cx,
elementY1 + matchedLine.offsetY / zoomFactor - cy, elementY1 + matchedLine.offsetY / zoomFactor - cy,
matchedLine.width / zoomFactor, matchedLine.width / zoomFactor,
matchedLine.height / zoomFactor matchedLine.height / zoomFactor,
); );
}); });
@@ -1360,7 +1360,7 @@ const _renderInteractiveScene = ({
elementsMap, elementsMap,
normalizedWidth, normalizedWidth,
normalizedHeight, normalizedHeight,
appState appState,
); );
context.save(); context.save();
@@ -1374,7 +1374,7 @@ const _renderInteractiveScene = ({
scrollBar.y, scrollBar.y,
scrollBar.width, scrollBar.width,
scrollBar.height, scrollBar.height,
SCROLLBAR_WIDTH / 2 SCROLLBAR_WIDTH / 2,
); );
} }
}); });
@@ -1395,7 +1395,7 @@ export const renderInteractiveSceneThrottled = throttleRAF(
const ret = _renderInteractiveScene(config); const ret = _renderInteractiveScene(config);
config.callback?.(ret); config.callback?.(ret);
}, },
{ trailing: true } { trailing: true },
); );
/** /**
@@ -1404,10 +1404,10 @@ export const renderInteractiveSceneThrottled = throttleRAF(
*/ */
export const renderInteractiveScene = < export const renderInteractiveScene = <
U extends typeof _renderInteractiveScene, U extends typeof _renderInteractiveScene,
T extends boolean = false T extends boolean = false,
>( >(
renderConfig: InteractiveSceneRenderConfig, renderConfig: InteractiveSceneRenderConfig,
throttle?: T throttle?: T,
): T extends true ? void : ReturnType<U> => { ): T extends true ? void : ReturnType<U> => {
if (throttle) { if (throttle) {
renderInteractiveSceneThrottled(renderConfig); renderInteractiveSceneThrottled(renderConfig);