refactor(react/svelte): simplify ssr usage

This commit is contained in:
moklick
2023-10-23 16:37:28 +02:00
parent f42f6314e2
commit 6de9bbc916
6 changed files with 70 additions and 28 deletions
+7 -4
View File
@@ -1,6 +1,6 @@
import { EdgePosition } from '../../types/edges';
import { ConnectionMode, OnError } from '../../types/general';
import { NodeBase, NodeHandleBounds } from '../../types/nodes';
import { NodeBase, NodeHandle, NodeHandleBounds } from '../../types/nodes';
import { Position, Rect, XYPosition } from '../../types/utils';
import { errorMessages, internalsSymbol } from '../../constants';
import { HandleElement } from '../../types';
@@ -59,19 +59,22 @@ export function getEdgePosition(params: GetEdgePositionParams): EdgePosition | n
};
}
function toHandleBounds(handles?: HandleElement[]) {
function toHandleBounds(handles?: NodeHandle[]) {
if (!handles) {
return null;
}
return handles.reduce<NodeHandleBounds>(
(res, item) => {
item.width = item.width || 1;
item.height = item.height || 1;
if (item.type === 'source') {
res.source?.push(item);
res.source?.push(item as HandleElement);
}
if (item.type === 'target') {
res.target?.push(item);
res.target?.push(item as HandleElement);
}
return res;
+1
View File
@@ -0,0 +1 @@
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;