flowmolio
Version:
[](https://github.com/vladvlasov256/flowmolio/actions/workflows/test.yml) [](htt
99 lines (98 loc) • 2.5 kB
TypeScript
export declare enum ColorRole {
FILL = "fill",
STROKE = "stroke",
STOP_COLOR = "stop-color"
}
export interface SVGElementNode {
id: string;
originalId?: string;
tagName: string;
attributes: Record<string, string>;
children: SVGElementNode[];
isText: boolean;
isImage: boolean;
innerHTML?: string;
textContent?: string;
}
export interface Connection {
sourceNodeId: string;
sourceField: string;
targetNodeId: string;
}
export interface BaseComponent {
id: string;
}
/**
* Text rendering strategy for text layout components.
* - **Constrained** means the text width is limited to a specific value.
* - **Natural** means the text width is determined by its content without constraints.
*/
export type TextRenderingStrategy = {
width: {
type: 'constrained';
value: number;
} | {
type: 'natural';
};
horizontalAlignment: 'left' | 'center' | 'right';
offset: number;
};
export interface TextLayoutComponent extends BaseComponent {
type: 'text';
elementId: string;
renderingStrategy?: TextRenderingStrategy;
}
export interface ImageLayoutComponent extends BaseComponent {
type: 'image';
elementId: string;
}
export interface ColorReplacementComponent extends BaseComponent {
type: 'color';
color: string;
enabledRoles: {
[ColorRole.FILL]: boolean;
[ColorRole.STROKE]: boolean;
[ColorRole.STOP_COLOR]: boolean;
};
elementIds?: string[];
}
export type Component = TextLayoutComponent | ImageLayoutComponent | ColorReplacementComponent;
export type JSONValue = string | number | boolean | null | JSONValue[] | {
[key: string]: JSONValue;
};
export type DataSources = Record<string, JSONValue>;
export interface Layout {
svg: string;
connections: Connection[];
components: Component[];
}
export interface DataBindingContext {
svgTree: SVGElementNode;
connections: Connection[];
dataSources: DataSources;
components?: Component[];
}
export interface BlueprintNode {
id: string;
type?: string;
position: {
x: number;
y: number;
};
data: any;
[key: string]: any;
}
export interface BlueprintEdge {
id: string;
source: string;
target: string;
sourceHandle?: string | null;
targetHandle?: string | null;
data?: any;
[key: string]: any;
}
export interface Blueprint {
svg: string;
nodes: BlueprintNode[];
edges: BlueprintEdge[];
}