Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public-hoist-pattern[]=vite
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"lint": "npm -w packages/studio run lint",
"lint:fix": "npm -w packages/studio run lint:fix",
"type-check": "tsc --noEmit"
},
"devDependencies": {
"vite": "8.0.14"
}
}
2 changes: 1 addition & 1 deletion packages/studio/src/canvas/RpaNodeAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import type { Node, Edge } from '@reactflow/core';
import type { RpaNode, RpaEdge } from '@rpaforge/domain-model';
import type { RpaNode, RpaEdge } from '../types/domain-model';

export function rpaNodeToReactFlowNode<D = unknown>(rpaNode: RpaNode<D>): Node<D> {
return {
Expand Down
8 changes: 4 additions & 4 deletions packages/studio/src/components/Common/MermaidPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useState, useCallback, useRef, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { FaTimes, FaDownload, FaCopy, FaCode, FaImage } from 'react-icons/fa';
import type { RpaNode, RpaEdge } from '@rpaforge/domain-model';
import type { Node, Edge } from '@reactflow/core';
import { useForcedColors, useResolvedTheme } from '../../hooks/useTheme';

interface MermaidPreviewProps {
isOpen: boolean;
onClose: () => void;
nodes: RpaNode[];
edges: RpaEdge[];
nodes: Node[];
edges: Edge[];
title?: string;
}

Expand All @@ -20,7 +20,7 @@ function sanitizeLabel(label: string): string {
return label.replace(/"/g, "'").replace(/\n/g, ' ').replace(/[()]/g, '');
}

function getNodeLabel(node: RpaNode): string {
function getNodeLabel(node: Node): string {
const blockData = node.data?.blockData as { type?: string; condition?: string; itemVariable?: string; activityId?: string; variableName?: string } | undefined;
if (!blockData) {
return String(node.data?.label || 'Node');
Expand Down
2 changes: 1 addition & 1 deletion packages/studio/src/hooks/useFileOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export const useFileOperations = (): UseFileOperationsResult => {
return false;
}

const loaded = loadProcess(diagram.metadata, diagram.nodes, diagram.edges);
const loaded = loadProcess(diagram.metadata, diagram.nodes as ProcessNode[], diagram.edges);
if (!loaded) {
setLastError('Failed to load diagram: exactly one Start node is required.');
return false;
Expand Down
3 changes: 2 additions & 1 deletion packages/studio/src/hooks/useProcess.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback } from 'react';
import type { RpaNode, RpaEdge } from '@rpaforge/domain-model';
import type { RpaNode, RpaEdge } from '../types/domain-model';
import type { Edge } from '@reactflow/core';
import { useBlockStore, type ProcessNodeData, type ProcessNode, normalizeNode, createStartBlockNode } from '../stores/blockStore';
import { useHistoryStore } from '../stores/historyStore';
import { useSelectionStore } from '../stores/selectionStore';
Expand Down
20 changes: 20 additions & 0 deletions packages/studio/src/types/domain-model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Re-export domain model types for studio
* Bridge to @rpaforge/domain-model package during build
*/

export type RpaNode<D = unknown> = {
id: string;
type?: string;
data: D;
position?: { x: number; y: number };
width?: number | null;
height?: number | null;
};

export type RpaEdge = {
id: string;
source: string;
target: string;
handle?: string | null;
};
14 changes: 4 additions & 10 deletions packages/studio/src/utils/fileUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ describe('fileUtils diagram round-trip', () => {
id: 'edge-1',
source: 'start-1',
target: 'node-2',
sourceHandle: 'true',
targetHandle: 'input',
type: 'custom',
data: { type: 'true', animated: false },
style: { stroke: '#22C55E', strokeWidth: 2, strokeDasharray: '5,5' },
handle: 'true',
},
],
{
Expand All @@ -53,11 +49,9 @@ describe('fileUtils diagram round-trip', () => {
expect(result.success).toBe(true);
expect(result.diagram?.edges[0]).toMatchObject({
id: 'edge-1',
sourceHandle: 'true',
targetHandle: 'input',
type: 'custom',
data: { type: 'true', animated: false },
style: { stroke: '#22C55E', strokeWidth: 2, strokeDasharray: '5,5' },
source: 'start-1',
target: 'node-2',
handle: 'true',
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/studio/src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RpaNode, RpaEdge } from '@rpaforge/domain-model';
import type { RpaNode, RpaEdge } from '../types/domain-model';
import type { ProcessNodeData, ProcessMetadata } from '../stores/processStore';
import type { DiagramDocument, ProjectConfig } from '../stores/diagramStore';
import type { ProcessVariable } from '../stores/variableStore';
Expand Down
8 changes: 5 additions & 3 deletions packages/studio/src/utils/mermaidGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { RpaNode, RpaEdge } from '@rpaforge/domain-model';
import type { RpaNode, RpaEdge } from '../types/domain-model';
import type { BlockData, IfBlockData, WhileBlockData, ForEachBlockData, SwitchBlockData } from '../types/blocks';

type NodeData = { blockData?: BlockData; label?: string };

interface MermaidNode {
id: string;
label: string;
Expand All @@ -16,7 +18,7 @@ function sanitizeLabel(label: string): string {
return label.replace(/"/g, "'").replace(/\n/g, ' ').replace(/[()]/g, '');
}

function getNodeLabel(node: RpaNode): string {
function getNodeLabel(node: RpaNode<NodeData>): string {
const blockData = node.data?.blockData as BlockData;
if (!blockData) {
return node.data?.label || node.id || 'Node';
Expand Down Expand Up @@ -118,7 +120,7 @@ function buildGraph(edges: RpaEdge[]): Map<string, RpaEdge[]> {
return graph;
}

export function diagramToMermaid(nodes: RpaNode[], edges: RpaEdge[]): string {
export function diagramToMermaid(nodes: RpaNode<NodeData>[], edges: RpaEdge[]): string {
if (nodes.length === 0) {
return 'flowchart TD\n empty(No nodes in diagram)';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/studio/src/utils/templateLoader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RpaNode, RpaEdge } from '@rpaforge/domain-model';
import type { Node, Edge } from '@reactflow/core';
import type { ProcessMetadata, ProcessNodeData } from '../stores/processStore';
import type { DiagramType } from '../stores/diagramStore';
import type { BlockData, BlockType } from '../types/blocks';
Expand Down
8 changes: 8 additions & 0 deletions packages/studio/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference types="vite/client" />

declare const __APP_VERSION__: string;

declare module '*.css' {
const content: Record<string, string>;
export default content;
}
1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ onlyBuiltDependencies:
- electron
- esbuild
- "@parcel/watcher"
- electron-winstaller
Loading