@motiadev/workbench 0.5.11-beta.120-391598 → 0.5.11-beta.120-207545
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/dist/index.html +0 -16
- package/dist/middleware.js +18 -1
- package/dist/src/components/flow/flow-view.js +1 -1
- package/dist/src/components/flow/node-organizer.d.ts +4 -0
- package/dist/src/components/flow/node-organizer.js +43 -14
- package/dist/src/publicComponents/base-node/base-node.js +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/tsconfig.node.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/index.html
CHANGED
|
@@ -26,22 +26,6 @@
|
|
|
26
26
|
optOut: true,
|
|
27
27
|
})
|
|
28
28
|
</script>
|
|
29
|
-
|
|
30
|
-
<!-- Start of Reo Javascript -->
|
|
31
|
-
<script type="text/javascript">
|
|
32
|
-
!(function () {
|
|
33
|
-
var e, t, n
|
|
34
|
-
;(e = 'd8f0ce9cae8ae64'),
|
|
35
|
-
(t = function () {
|
|
36
|
-
Reo.init({ clientID: 'd8f0ce9cae8ae64', source: 'internal' })
|
|
37
|
-
}),
|
|
38
|
-
((n = document.createElement('script')).src = 'https://static.reo.dev/' + e + '/reo.js'),
|
|
39
|
-
(n.defer = !0),
|
|
40
|
-
(n.onload = t),
|
|
41
|
-
document.head.appendChild(n)
|
|
42
|
-
})()
|
|
43
|
-
</script>
|
|
44
|
-
<!-- End of Reo Javascript -->
|
|
45
29
|
|
|
46
30
|
<script>
|
|
47
31
|
const importFile = async (path) => {
|
package/dist/middleware.js
CHANGED
|
@@ -18,6 +18,23 @@ const processCwdPlugin = () => {
|
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
+
const reoPlugin = () => {
|
|
22
|
+
return {
|
|
23
|
+
name: 'html-transform',
|
|
24
|
+
transformIndexHtml(html) {
|
|
25
|
+
const isAnalyticsEnabled = process.env.MOTIA_ANALYTICS_DISABLED !== 'true';
|
|
26
|
+
if (!isAnalyticsEnabled) {
|
|
27
|
+
return html;
|
|
28
|
+
}
|
|
29
|
+
// inject before </head>
|
|
30
|
+
return html.replace('</head>', `
|
|
31
|
+
<script type="text/javascript">
|
|
32
|
+
!function(){var e,t,n;e="d8f0ce9cae8ae64",t=function(){Reo.init({clientID:"d8f0ce9cae8ae64", source: "internal"})},(n=document.createElement("script")).src="https://static.reo.dev/"+e+"/reo.js",n.defer=!0,n.onload=t,document.head.appendChild(n)}();
|
|
33
|
+
</script>
|
|
34
|
+
</head>`);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
21
38
|
const applyMiddleware = async (app, port) => {
|
|
22
39
|
const vite = await (0, vite_1.createServer)({
|
|
23
40
|
appType: 'spa',
|
|
@@ -38,7 +55,7 @@ const applyMiddleware = async (app, port) => {
|
|
|
38
55
|
resolve: {
|
|
39
56
|
alias: { '@': path_1.default.resolve(__dirname, './src') },
|
|
40
57
|
},
|
|
41
|
-
plugins: [(0, plugin_react_1.default)(), processCwdPlugin()],
|
|
58
|
+
plugins: [(0, plugin_react_1.default)(), processCwdPlugin(), reoPlugin()],
|
|
42
59
|
});
|
|
43
60
|
app.use(vite.middlewares);
|
|
44
61
|
app.use('*', async (req, res, next) => {
|
|
@@ -17,5 +17,5 @@ export const FlowView = ({ flow, flowConfig }) => {
|
|
|
17
17
|
if (!nodeTypes) {
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
|
-
return (_jsxs("div", { className: "w-full h-full relative", children: [!initialized && _jsx(FlowLoader, {}), _jsxs(ReactFlow, { nodes: nodes, edges: edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, onNodesChange: onNodesChangeHandler, onEdgesChange: onEdgesChange, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 50, size: 2, className: "
|
|
20
|
+
return (_jsxs("div", { className: "w-full h-full relative", children: [!initialized && _jsx(FlowLoader, {}), _jsxs(ReactFlow, { minZoom: 0.1, nodes: nodes, edges: edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, onNodesChange: onNodesChangeHandler, onEdgesChange: onEdgesChange, children: [_jsx(Background, { variant: BackgroundVariant.Dots, gap: 50, size: 2, className: "bg-canvas-background!" }), _jsx(NodeOrganizer, { onInitialized: onInitialized, nodes: nodes, edges: edges })] })] }));
|
|
21
21
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { EdgeData, NodeData } from '@/types/flow';
|
|
2
|
+
import { Edge, Node } from '@xyflow/react';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
type Props = {
|
|
3
5
|
onInitialized: () => void;
|
|
6
|
+
nodes: Node<NodeData>[];
|
|
7
|
+
edges: Edge<EdgeData>[];
|
|
4
8
|
};
|
|
5
9
|
export declare const NodeOrganizer: React.FC<Props>;
|
|
6
10
|
export {};
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { useNodesInitialized, useReactFlow } from '@xyflow/react';
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
3
2
|
import dagre from 'dagre';
|
|
3
|
+
import isEqual from 'fast-deep-equal';
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
4
5
|
const organizeNodes = (nodes, edges) => {
|
|
5
|
-
const dagreGraph = new dagre.graphlib.Graph({
|
|
6
|
+
const dagreGraph = new dagre.graphlib.Graph({ directed: true, compound: false, multigraph: false });
|
|
6
7
|
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
|
7
|
-
dagreGraph.setGraph({ rankdir: 'LR', ranksep:
|
|
8
|
+
dagreGraph.setGraph({ rankdir: 'LR', ranksep: 0, nodesep: 20, edgesep: 0 });
|
|
8
9
|
nodes.forEach((node) => {
|
|
9
|
-
|
|
10
|
+
if (node.position.x !== 0 || node.position.y !== 0) {
|
|
11
|
+
dagreGraph.setNode(node.id, {
|
|
12
|
+
width: node.measured?.width,
|
|
13
|
+
height: node.measured?.height,
|
|
14
|
+
x: node.position.x,
|
|
15
|
+
y: node.position.y,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
dagreGraph.setNode(node.id, {
|
|
20
|
+
width: node.measured?.width,
|
|
21
|
+
height: node.measured?.height,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
10
24
|
});
|
|
11
25
|
edges.forEach((edge) => {
|
|
12
26
|
if (typeof edge.label === 'string') {
|
|
@@ -34,20 +48,35 @@ const organizeNodes = (nodes, edges) => {
|
|
|
34
48
|
return { ...node, position };
|
|
35
49
|
});
|
|
36
50
|
};
|
|
37
|
-
export const NodeOrganizer = ({ onInitialized }) => {
|
|
51
|
+
export const NodeOrganizer = ({ onInitialized, nodes, edges }) => {
|
|
38
52
|
const { setNodes, getNodes, getEdges, fitView } = useReactFlow();
|
|
39
53
|
const nodesInitialized = useNodesInitialized();
|
|
40
54
|
const initialized = useRef(false);
|
|
55
|
+
const lastNodesRef = useRef([]);
|
|
56
|
+
const lastEdgesRef = useRef([]);
|
|
41
57
|
useEffect(() => {
|
|
42
|
-
if (nodesInitialized
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
if (nodesInitialized) {
|
|
59
|
+
if (isEqual(lastNodesRef.current, nodes) && isEqual(lastEdgesRef.current, edges)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
lastNodesRef.current = nodes;
|
|
63
|
+
lastEdgesRef.current = edges;
|
|
64
|
+
try {
|
|
65
|
+
const nodesToOrganize = nodes.some((node) => node.position.x === 0 && node.position.y === 0);
|
|
66
|
+
if (nodesToOrganize) {
|
|
67
|
+
const organizedNodes = organizeNodes(nodes, edges);
|
|
68
|
+
setNodes(organizedNodes);
|
|
69
|
+
}
|
|
70
|
+
if (!initialized.current) {
|
|
71
|
+
initialized.current = true;
|
|
72
|
+
onInitialized();
|
|
73
|
+
setTimeout(() => fitView(), 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('Error organizing nodes:', error);
|
|
78
|
+
}
|
|
50
79
|
}
|
|
51
|
-
}, [nodesInitialized, onInitialized, setNodes, getNodes, getEdges, fitView]);
|
|
80
|
+
}, [nodesInitialized, onInitialized, setNodes, getNodes, getEdges, fitView, nodes, edges]);
|
|
52
81
|
return null;
|
|
53
82
|
};
|
|
@@ -24,7 +24,7 @@ export const BaseNode = ({ title, variant, children, disableSourceHandle, disabl
|
|
|
24
24
|
}, [data.id, isOpen, fetchContent]);
|
|
25
25
|
return (_jsxs("div", { className: cn('p-1 rounded-lg max-w-[350px]', {
|
|
26
26
|
'bg-muted-foreground/20': isOpen,
|
|
27
|
-
}), children: [_jsx("div", { className: "rounded-lg bg-background border-1 border-muted-foreground/30 border-solid", "data-testid": `node-${title?.toLowerCase().replace(/ /g, '-')}`, children: _jsxs("div", { className: "group relative", children: [_jsx(NodeHeader, { text: title, variant: variant, className: "border-b-2 border-muted-foreground/10", children: _jsx("div", { className: "flex justify-end", children: _jsx(Button, { "data-testid": `open-code-preview-button-${title?.toLowerCase()}`, variant: "ghost", className: "h-5 p-0.5", onClick: () => setIsOpen(true), children: _jsx(ScanSearch, { className: "w-4 h-4" }) }) }) }), subtitle && _jsx("div", { className: "py-4 px-6 text-sm text-muted-foreground", children: subtitle }), children && (_jsx("div", { className: "p-2", children: _jsx("div", { className: cn('space-y-3 p-4 text-sm text-muted-foreground', {
|
|
27
|
+
}), children: [_jsx("div", { className: "rounded-lg dark:bg-[#222] bg-background border-1 border-muted-foreground/30 border-solid", "data-testid": `node-${title?.toLowerCase().replace(/ /g, '-')}`, children: _jsxs("div", { className: "group relative", children: [_jsx(NodeHeader, { text: title, variant: variant, className: "border-b-2 border-muted-foreground/10", children: _jsx("div", { className: "flex justify-end", children: _jsx(Button, { "data-testid": `open-code-preview-button-${title?.toLowerCase()}`, variant: "ghost", className: "h-5 p-0.5", onClick: () => setIsOpen(true), children: _jsx(ScanSearch, { className: "w-4 h-4" }) }) }) }), subtitle && _jsx("div", { className: "py-4 px-6 text-sm text-muted-foreground", children: subtitle }), children && (_jsx("div", { className: "p-2", children: _jsx("div", { className: cn('space-y-3 p-4 text-sm text-muted-foreground', {
|
|
28
28
|
'bg-card': variant !== 'noop',
|
|
29
29
|
}), children: children }) })), !disableTargetHandle && (_jsx(BaseHandle, { type: "target", position: targetPosition, onTogglePosition: toggleTargetPosition })), !disableSourceHandle && (_jsx(BaseHandle, { type: "source", position: sourcePosition, onTogglePosition: toggleSourcePosition }))] }) }), content && (_jsx(NodeSidebar, { features: features, content: content, title: title, subtitle: subtitle, variant: variant, language: language, isOpen: isOpen, onClose: () => setIsOpen(false) }))] }));
|
|
30
30
|
};
|