ffmpeg-explorer/src/Graph.svelte

95 lines
1.8 KiB
Svelte
Raw Normal View History

2023-08-22 12:05:49 -04:00
<script>
2023-08-22 21:57:53 -04:00
import { nodes, edges, command } from "./stores.js";
import { SvelteFlow, Controls, Background, BackgroundVariant, MiniMap } from "@xyflow/svelte";
import Node from "./nodes/Node.svelte";
2023-08-22 13:12:24 -04:00
2023-08-22 21:57:53 -04:00
const nodeTypes = {
ffmpeg: Node,
};
2023-08-22 13:12:24 -04:00
2023-08-22 21:57:53 -04:00
console.log($nodes);
2023-08-22 12:05:49 -04:00
2023-08-22 21:57:53 -04:00
// const nodes = writable([
// {
// id: "1",
// type: "ffmpeg",
// data: { label: "test.mp4", inputs: [], outputs: ["v", "a"] },
// position: { x: 0, y: 0 },
// },
// {
// id: "2",
// type: "ffmpeg",
// data: { label: "filter", inputs: ["v"], outputs: ["v"] },
// position: { x: 0, y: 150 },
// },
// {
// id: "3",
// type: "ffmpeg",
// data: { label: "output.mp4", inputs: ["v", "a"], outputs: [] },
// position: { x: 100, y: 20 },
// },
// ]);
2023-08-22 12:05:49 -04:00
2023-08-22 21:57:53 -04:00
// same for edges
// const edges = writable([
// {
// id: "1-2",
// type: "default",
// source: "1",
// sourceHandle: "v_0",
// targetHandle: "v_0",
// target: "2",
// label: "Edge Text",
// },
// {
// id: "2-3",
// type: "default",
// source: "2",
// target: "3",
// sourceHandle: "v_0",
// targetHandle: "v_0",
// label: "Edge Text",
// },
// ]);
2023-08-22 12:05:49 -04:00
2023-08-22 21:57:53 -04:00
const defaultEdgeOptions = {
deletable: true,
};
2023-08-22 12:05:49 -04:00
2023-08-22 21:57:53 -04:00
function onEdgeUpdate(e) {
console.log(e);
2023-08-22 12:05:49 -04:00
}
2023-08-22 13:12:24 -04:00
2023-08-22 21:57:53 -04:00
function onEdgeUpdateStart(e) {
console.log(e);
}
2023-08-22 13:12:24 -04:00
2023-08-22 21:57:53 -04:00
function onEdgeUpdateEnd(e) {
console.log(e);
2023-08-22 12:05:49 -04:00
}
2023-08-22 21:57:53 -04:00
function onMoveStart(e) {
console.log(e);
}
function onConnect(e){
console.log('connect', e);
}
2023-08-22 12:05:49 -04:00
</script>
2023-08-22 21:57:53 -04:00
<div style="width: 900px; height: 500px;">
<SvelteFlow
{nodeTypes}
{nodes}
{edges}
snapGrid={[10, 10]}
fitView
>
<Controls />
<Background variant={BackgroundVariant.Dots} />
</SvelteFlow>
</div>
2023-08-22 12:05:49 -04:00
2023-08-22 13:12:24 -04:00
<div>
2023-08-22 21:57:53 -04:00
{JSON.stringify(command)}
2023-08-22 13:12:24 -04:00
</div>