f1ow 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +210 -0
- package/dist/assets/elbowWorker-CUBh1uET.js +1 -0
- package/dist/assets/exportWorker-hU9uNZXJ.js +8 -0
- package/dist/assets/syncWorker.worker-CnlpNZ3k.js +6 -0
- package/dist/components/Canvas/CanvasElement.d.ts +42 -0
- package/dist/components/Canvas/ConnectionPoints.d.ts +13 -0
- package/dist/components/Canvas/GridLayer.d.ts +13 -0
- package/dist/components/Canvas/LinearElementHandles.d.ts +17 -0
- package/dist/components/Canvas/SelectionBox.d.ts +12 -0
- package/dist/components/Canvas/SelectionTransformer.d.ts +7 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +23 -0
- package/dist/components/StylePanel/StylePanel.d.ts +7 -0
- package/dist/components/Toolbar/Toolbar.d.ts +9 -0
- package/dist/components/shapes/ArrowShape.d.ts +18 -0
- package/dist/components/shapes/DiamondShape.d.ts +24 -0
- package/dist/components/shapes/EllipseShape.d.ts +24 -0
- package/dist/components/shapes/FreeDrawShape.d.ts +24 -0
- package/dist/components/shapes/ImageShape.d.ts +24 -0
- package/dist/components/shapes/LineShape.d.ts +18 -0
- package/dist/components/shapes/RectangleShape.d.ts +24 -0
- package/dist/components/shapes/TextShape.d.ts +23 -0
- package/dist/constants/index.d.ts +44 -0
- package/dist/f1ow-canvas.js +37725 -0
- package/dist/f1ow-canvas.umd.cjs +371 -0
- package/dist/hooks/useEfficientZoom.d.ts +14 -0
- package/dist/hooks/useElbowShapeFingerprint.d.ts +21 -0
- package/dist/hooks/useElbowWorker.d.ts +23 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +7 -0
- package/dist/hooks/useProgressiveRender.d.ts +52 -0
- package/dist/hooks/useSpatialIndex.d.ts +9 -0
- package/dist/hooks/useViewportCulling.d.ts +13 -0
- package/dist/lib/FlowCanvas.d.ts +4 -0
- package/dist/lib/FlowCanvasProps.d.ts +154 -0
- package/dist/lib/index.d.ts +57 -0
- package/dist/store/useCanvasStore.d.ts +127 -0
- package/dist/store/useLinearEditStore.d.ts +25 -0
- package/dist/types/index.d.ts +257 -0
- package/dist/utils/alignment.d.ts +34 -0
- package/dist/utils/arrowheads.d.ts +20 -0
- package/dist/utils/camera.d.ts +63 -0
- package/dist/utils/clipboard.d.ts +4 -0
- package/dist/utils/clone.d.ts +29 -0
- package/dist/utils/connection.d.ts +122 -0
- package/dist/utils/crdtPrep.d.ts +97 -0
- package/dist/utils/curve.d.ts +51 -0
- package/dist/utils/elbow.d.ts +110 -0
- package/dist/utils/elbowWorkerManager.d.ts +53 -0
- package/dist/utils/export.d.ts +17 -0
- package/dist/utils/exportWorkerManager.d.ts +25 -0
- package/dist/utils/fractionalIndex.d.ts +51 -0
- package/dist/utils/geometry.d.ts +49 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/image.d.ts +52 -0
- package/dist/utils/performance.d.ts +65 -0
- package/dist/utils/roughness.d.ts +104 -0
- package/dist/utils/spatialIndex.d.ts +109 -0
- package/dist/utils/spatialSoA.d.ts +82 -0
- package/dist/workers/elbowWorker.d.ts +18 -0
- package/dist/workers/exportWorker.d.ts +18 -0
- package/package.json +80 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ArrowElement, LineElement, CanvasElement, SnapTarget } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: LineElement | ArrowElement;
|
|
5
|
+
/** All elements — needed for snap/binding detection on endpoint drag */
|
|
6
|
+
allElements: CanvasElement[];
|
|
7
|
+
/** Callback to update the element's points, position, bindings */
|
|
8
|
+
onPointsChange: (id: string, updates: Partial<LineElement | ArrowElement>) => void;
|
|
9
|
+
/** Callback for lightweight drag-move (no history) */
|
|
10
|
+
onPointDragMove?: (id: string, updates: Partial<LineElement | ArrowElement>) => void;
|
|
11
|
+
/** Callback when snap target changes during endpoint drag */
|
|
12
|
+
onSnapTargetChange?: (target: SnapTarget | null) => void;
|
|
13
|
+
/** Accent color */
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
box: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
} | null;
|
|
9
|
+
selectionColor?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface ContextMenuItem {
|
|
3
|
+
label: string;
|
|
4
|
+
shortcut?: string;
|
|
5
|
+
action: () => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
divider?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface ContextMenuProps {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
items: ContextMenuItem[];
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
theme: {
|
|
15
|
+
panelBg: string;
|
|
16
|
+
toolbarBorder: string;
|
|
17
|
+
textColor: string;
|
|
18
|
+
mutedTextColor: string;
|
|
19
|
+
activeToolColor: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
declare const _default: React.NamedExoticComponent<ContextMenuProps>;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ToolConfig } from '../../constants';
|
|
3
|
+
import { FlowCanvasTheme } from '../../lib/FlowCanvasProps';
|
|
4
|
+
interface Props {
|
|
5
|
+
visibleTools: ToolConfig[];
|
|
6
|
+
theme: FlowCanvasTheme;
|
|
7
|
+
}
|
|
8
|
+
declare const Toolbar: React.FC<Props>;
|
|
9
|
+
export default Toolbar;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ArrowElement, CanvasElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: ArrowElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
isEditing?: boolean;
|
|
7
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
8
|
+
isGrouped?: boolean;
|
|
9
|
+
onSelect: (id: string) => void;
|
|
10
|
+
onChange: (id: string, updates: Partial<ArrowElement>) => void;
|
|
11
|
+
onDragMove?: (id: string, updates: Partial<ArrowElement>) => void;
|
|
12
|
+
onDoubleClick?: (id: string) => void;
|
|
13
|
+
gridSnap?: number;
|
|
14
|
+
/** All elements — needed for elbow routing to resolve shape bboxes */
|
|
15
|
+
allElements?: CanvasElement[];
|
|
16
|
+
}
|
|
17
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DiamondElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: DiamondElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
7
|
+
isGrouped?: boolean;
|
|
8
|
+
onSelect: (id: string) => void;
|
|
9
|
+
onChange: (id: string, updates: Partial<DiamondElement>) => void;
|
|
10
|
+
onDragMove?: (id: string, updates: Partial<DiamondElement>) => void;
|
|
11
|
+
onDoubleClick?: (id: string) => void;
|
|
12
|
+
gridSnap?: number;
|
|
13
|
+
onDragSnap?: (id: string, bounds: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { EllipseElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: EllipseElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
7
|
+
isGrouped?: boolean;
|
|
8
|
+
onSelect: (id: string) => void;
|
|
9
|
+
onChange: (id: string, updates: Partial<EllipseElement>) => void;
|
|
10
|
+
onDragMove?: (id: string, updates: Partial<EllipseElement>) => void;
|
|
11
|
+
onDoubleClick?: (id: string) => void;
|
|
12
|
+
gridSnap?: number;
|
|
13
|
+
onDragSnap?: (id: string, bounds: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FreeDrawElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: FreeDrawElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
7
|
+
isGrouped?: boolean;
|
|
8
|
+
onSelect: (id: string) => void;
|
|
9
|
+
onChange: (id: string, updates: Partial<FreeDrawElement>) => void;
|
|
10
|
+
onDragMove?: (id: string, updates: Partial<FreeDrawElement>) => void;
|
|
11
|
+
onDoubleClick?: (id: string) => void;
|
|
12
|
+
gridSnap?: number;
|
|
13
|
+
onDragSnap?: (id: string, bounds: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ImageElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: ImageElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
7
|
+
isGrouped?: boolean;
|
|
8
|
+
onSelect: (id: string) => void;
|
|
9
|
+
onChange: (id: string, updates: Partial<ImageElement>) => void;
|
|
10
|
+
onDragMove?: (id: string, updates: Partial<ImageElement>) => void;
|
|
11
|
+
onDoubleClick?: (id: string) => void;
|
|
12
|
+
gridSnap?: number;
|
|
13
|
+
onDragSnap?: (id: string, bounds: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LineElement, CanvasElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: LineElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
isEditing?: boolean;
|
|
7
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
8
|
+
isGrouped?: boolean;
|
|
9
|
+
onSelect: (id: string) => void;
|
|
10
|
+
onChange: (id: string, updates: Partial<LineElement>) => void;
|
|
11
|
+
onDragMove?: (id: string, updates: Partial<LineElement>) => void;
|
|
12
|
+
onDoubleClick?: (id: string) => void;
|
|
13
|
+
gridSnap?: number;
|
|
14
|
+
/** All elements — needed for elbow routing to resolve shape bboxes */
|
|
15
|
+
allElements?: CanvasElement[];
|
|
16
|
+
}
|
|
17
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { RectangleElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: RectangleElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
7
|
+
isGrouped?: boolean;
|
|
8
|
+
onSelect: (id: string) => void;
|
|
9
|
+
onChange: (id: string, updates: Partial<RectangleElement>) => void;
|
|
10
|
+
onDragMove?: (id: string, updates: Partial<RectangleElement>) => void;
|
|
11
|
+
onDoubleClick?: (id: string) => void;
|
|
12
|
+
gridSnap?: number;
|
|
13
|
+
onDragSnap?: (id: string, bounds: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TextElement, CanvasElement } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
element: TextElement;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
/** When true, individual drag is disabled — the parent KonvaGroup handles dragging */
|
|
7
|
+
isGrouped?: boolean;
|
|
8
|
+
onSelect: (id: string) => void;
|
|
9
|
+
onChange: (id: string, updates: Partial<TextElement>) => void;
|
|
10
|
+
onDragMove?: (id: string, updates: Partial<TextElement>) => void;
|
|
11
|
+
/** If true, auto-opens the textarea editor immediately after mount */
|
|
12
|
+
autoEdit?: boolean;
|
|
13
|
+
/** Called to notify parent that text editing started */
|
|
14
|
+
onEditStart?: (id: string) => void;
|
|
15
|
+
/** Called to notify parent that text editing ended */
|
|
16
|
+
onEditEnd?: (id: string, isEmpty: boolean) => void;
|
|
17
|
+
/** All elements (for resolving containerId position) */
|
|
18
|
+
allElements?: CanvasElement[];
|
|
19
|
+
/** Grid snap size (0 or undefined = no snap) */
|
|
20
|
+
gridSnap?: number;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ElementStyle, ToolType, Arrowhead, LineType } from '../types';
|
|
2
|
+
export declare const DEFAULT_STYLE: ElementStyle;
|
|
3
|
+
export declare const STROKE_COLORS: string[];
|
|
4
|
+
export declare const FILL_COLORS: string[];
|
|
5
|
+
export declare const STROKE_WIDTHS: number[];
|
|
6
|
+
export interface ToolConfig {
|
|
7
|
+
type: ToolType;
|
|
8
|
+
label: string;
|
|
9
|
+
shortcut: string;
|
|
10
|
+
icon: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const TOOLS: ToolConfig[];
|
|
13
|
+
export declare const MIN_ZOOM = 0.1;
|
|
14
|
+
export declare const MAX_ZOOM = 5;
|
|
15
|
+
export declare const ZOOM_STEP = 0.1;
|
|
16
|
+
export declare const FONT_SIZES: number[];
|
|
17
|
+
export declare const FONT_FAMILIES: {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
21
|
+
export declare const SELECTION_SHADOW: {
|
|
22
|
+
readonly color: "#4f8df7";
|
|
23
|
+
readonly blur: 6;
|
|
24
|
+
readonly opacity: 0.5;
|
|
25
|
+
};
|
|
26
|
+
export declare const GRID_SIZE = 20;
|
|
27
|
+
export interface ArrowheadConfig {
|
|
28
|
+
type: Arrowhead | null;
|
|
29
|
+
label: string;
|
|
30
|
+
/** Small SVG-like preview character for UI */
|
|
31
|
+
preview: string;
|
|
32
|
+
}
|
|
33
|
+
export declare const ARROWHEAD_TYPES: ArrowheadConfig[];
|
|
34
|
+
export interface LineTypeConfig {
|
|
35
|
+
type: LineType;
|
|
36
|
+
label: string;
|
|
37
|
+
preview: string;
|
|
38
|
+
}
|
|
39
|
+
export declare const LINE_TYPES: LineTypeConfig[];
|
|
40
|
+
export interface RoughnessConfig {
|
|
41
|
+
value: number;
|
|
42
|
+
label: string;
|
|
43
|
+
}
|
|
44
|
+
export declare const ROUGHNESS_CONFIGS: RoughnessConfig[];
|