@motiadev/workbench 0.6.1-beta.124 → 0.6.2-beta.125
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.d.ts +1 -1
- package/dist/middleware.js +20 -2
- package/dist/src/components/flow/node-organizer.js +39 -7
- package/dist/src/components/logs/log-level-dot.js +5 -5
- package/dist/src/hooks/use-update-handle-positions.js +2 -2
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/tsconfig.node.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/src/components/flow/hooks/use-organize-nodes.d.ts +0 -3
- package/dist/src/components/flow/hooks/use-organize-nodes.js +0 -43
package/dist/index.html
CHANGED
|
@@ -27,22 +27,6 @@
|
|
|
27
27
|
})
|
|
28
28
|
</script>
|
|
29
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' })
|
|
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
|
-
|
|
46
30
|
<script>
|
|
47
31
|
const importFile = async (path) => {
|
|
48
32
|
// Normalize the path for cross-platform compatibility
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Express } from 'express';
|
|
2
|
-
export declare const applyMiddleware: (app: Express) => Promise<void>;
|
|
2
|
+
export declare const applyMiddleware: (app: Express, port: number) => Promise<void>;
|
package/dist/middleware.js
CHANGED
|
@@ -18,7 +18,24 @@ const processCwdPlugin = () => {
|
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
const
|
|
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
|
+
};
|
|
38
|
+
const applyMiddleware = async (app, port) => {
|
|
22
39
|
const vite = await (0, vite_1.createServer)({
|
|
23
40
|
appType: 'spa',
|
|
24
41
|
root: __dirname,
|
|
@@ -26,6 +43,7 @@ const applyMiddleware = async (app) => {
|
|
|
26
43
|
middlewareMode: true,
|
|
27
44
|
allowedHosts: true,
|
|
28
45
|
host: true,
|
|
46
|
+
hmr: { port: 21678 + port },
|
|
29
47
|
fs: {
|
|
30
48
|
allow: [
|
|
31
49
|
__dirname, // workbench root
|
|
@@ -37,7 +55,7 @@ const applyMiddleware = async (app) => {
|
|
|
37
55
|
resolve: {
|
|
38
56
|
alias: { '@': path_1.default.resolve(__dirname, './src') },
|
|
39
57
|
},
|
|
40
|
-
plugins: [(0, plugin_react_1.default)(), processCwdPlugin()],
|
|
58
|
+
plugins: [(0, plugin_react_1.default)(), processCwdPlugin(), reoPlugin()],
|
|
41
59
|
});
|
|
42
60
|
app.use(vite.middlewares);
|
|
43
61
|
app.use('*', async (req, res, next) => {
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { useNodesInitialized, useReactFlow } from '@xyflow/react';
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
|
+
import dagre from 'dagre';
|
|
4
|
+
const organizeNodes = (nodes, edges) => {
|
|
5
|
+
const dagreGraph = new dagre.graphlib.Graph({ compound: true });
|
|
6
|
+
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
|
7
|
+
dagreGraph.setGraph({ rankdir: 'LR', ranksep: 80, nodesep: 60, edgesep: 20, ranker: 'tight-tree' });
|
|
8
|
+
nodes.forEach((node) => {
|
|
9
|
+
dagreGraph.setNode(node.id, { width: node.measured?.width, height: node.measured?.height });
|
|
10
|
+
});
|
|
11
|
+
edges.forEach((edge) => {
|
|
12
|
+
if (typeof edge.label === 'string') {
|
|
13
|
+
dagreGraph.setEdge(edge.source, edge.target, {
|
|
14
|
+
label: edge.label ?? '',
|
|
15
|
+
width: edge.label.length * 40, // Add width for the label
|
|
16
|
+
height: 30, // Add height for the label
|
|
17
|
+
labelpos: 'c', // Position label in center
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
dagreGraph.setEdge(edge.source, edge.target);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
dagre.layout(dagreGraph);
|
|
25
|
+
return nodes.map((node) => {
|
|
26
|
+
if (node.position.x !== 0 || node.position.y !== 0) {
|
|
27
|
+
return node;
|
|
28
|
+
}
|
|
29
|
+
const { x, y } = dagreGraph.node(node.id);
|
|
30
|
+
const position = {
|
|
31
|
+
x: x - (node.measured?.width ?? 0) / 2,
|
|
32
|
+
y: y - (node.measured?.height ?? 0) / 2,
|
|
33
|
+
};
|
|
34
|
+
return { ...node, position };
|
|
35
|
+
});
|
|
36
|
+
};
|
|
3
37
|
export const NodeOrganizer = ({ onInitialized }) => {
|
|
4
38
|
const { setNodes, getNodes, getEdges, fitView } = useReactFlow();
|
|
5
39
|
const nodesInitialized = useNodesInitialized();
|
|
@@ -7,14 +41,12 @@ export const NodeOrganizer = ({ onInitialized }) => {
|
|
|
7
41
|
useEffect(() => {
|
|
8
42
|
if (nodesInitialized && !initialized.current) {
|
|
9
43
|
initialized.current = true;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
44
|
+
const nodes = getNodes();
|
|
45
|
+
const edges = getEdges();
|
|
46
|
+
const organizedNodes = organizeNodes(nodes, edges);
|
|
47
|
+
setNodes(organizedNodes);
|
|
14
48
|
onInitialized();
|
|
15
|
-
setTimeout(
|
|
16
|
-
await fitView();
|
|
17
|
-
}, 1);
|
|
49
|
+
setTimeout(() => fitView(), 1);
|
|
18
50
|
}
|
|
19
51
|
}, [nodesInitialized, onInitialized, setNodes, getNodes, getEdges, fitView]);
|
|
20
52
|
return null;
|
|
@@ -4,11 +4,11 @@ const badgeVariants = cva('text-xs font-medium tracking-wide rounded-full h-[6px
|
|
|
4
4
|
variants: {
|
|
5
5
|
variant: {
|
|
6
6
|
info: 'bg-[#2862FE] outline-[#2862FE]/20',
|
|
7
|
-
trace: 'bg-
|
|
8
|
-
debug: 'bg-
|
|
9
|
-
error: 'bg-
|
|
10
|
-
fatal: 'bg-
|
|
11
|
-
warn: 'bg-
|
|
7
|
+
trace: 'bg-[#2862FE] outline-[#2862FE]/20',
|
|
8
|
+
debug: 'bg-[#2862FE] outline-[#2862FE]/20',
|
|
9
|
+
error: 'bg-[#E22A6D] outline-[#E22A6D]/20',
|
|
10
|
+
fatal: 'bg-[#E22A6D] outline-[#E22A6D]/20',
|
|
11
|
+
warn: 'bg-[#F59F0B] outline-[#F59F0B]/20',
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
});
|
|
@@ -2,8 +2,8 @@ import { Position, useReactFlow, useUpdateNodeInternals } from '@xyflow/react';
|
|
|
2
2
|
export const useHandlePositions = (data) => {
|
|
3
3
|
const reactFlow = useReactFlow();
|
|
4
4
|
const updateNodeInternals = useUpdateNodeInternals();
|
|
5
|
-
const sourcePosition = data.nodeConfig?.sourceHandlePosition === '
|
|
6
|
-
const targetPosition = data.nodeConfig?.targetHandlePosition === '
|
|
5
|
+
const sourcePosition = data.nodeConfig?.sourceHandlePosition === 'bottom' ? Position.Bottom : Position.Right;
|
|
6
|
+
const targetPosition = data.nodeConfig?.targetHandlePosition === 'top' ? Position.Top : Position.Left;
|
|
7
7
|
const updateSourcePosition = (position) => {
|
|
8
8
|
reactFlow.updateNode(data.id, {
|
|
9
9
|
data: { ...data, nodeConfig: { ...data.nodeConfig, sourceHandlePosition: position } },
|