2024-03-06 14:01:07 +01:00
|
|
|
<script lang="ts">
|
2024-04-10 14:27:23 +02:00
|
|
|
import Grid from "$lib/grid";
|
2024-04-10 21:57:03 +02:00
|
|
|
import GraphInterface from "@nodes/graph-interface";
|
2024-03-19 16:41:15 +01:00
|
|
|
import { MemoryRuntimeExecutor } from "$lib/runtime-executor";
|
2024-04-05 18:03:23 +02:00
|
|
|
import { MemoryNodeRegistry, RemoteNodeRegistry } from "$lib/node-registry";
|
2024-04-10 15:40:01 +02:00
|
|
|
import * as templates from "$lib/graph-templates";
|
2024-04-10 21:57:03 +02:00
|
|
|
import type { Graph } from "@nodes/types";
|
2024-03-06 18:31:06 +01:00
|
|
|
|
2024-04-10 14:27:23 +02:00
|
|
|
const nodeRegistry = new RemoteNodeRegistry("http://localhost:3001");
|
2024-03-19 16:41:15 +01:00
|
|
|
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
|
|
|
|
2024-04-10 21:57:03 +02:00
|
|
|
let res = "2";
|
|
|
|
let time = 0;
|
2024-03-19 16:56:42 +01:00
|
|
|
|
2024-04-10 15:40:01 +02:00
|
|
|
let graph = localStorage.getItem("graph")
|
|
|
|
? JSON.parse(localStorage.getItem("graph")!)
|
|
|
|
: templates.grid(3, 3);
|
2024-03-19 16:56:42 +01:00
|
|
|
|
2024-04-10 21:57:03 +02:00
|
|
|
function handleResult(event: CustomEvent<Graph>) {
|
|
|
|
let a = performance.now();
|
2024-04-10 15:40:01 +02:00
|
|
|
res = runtimeExecutor.execute(event.detail);
|
2024-04-10 21:57:03 +02:00
|
|
|
time = performance.now() - a;
|
2024-04-10 15:40:01 +02:00
|
|
|
console.log(res);
|
|
|
|
}
|
2024-03-06 18:31:06 +01:00
|
|
|
|
2024-04-10 21:57:03 +02:00
|
|
|
function handleSave(event: CustomEvent<Graph>) {
|
2024-04-10 15:40:01 +02:00
|
|
|
localStorage.setItem("graph", JSON.stringify(event.detail));
|
|
|
|
}
|
2024-03-06 14:01:07 +01:00
|
|
|
</script>
|
|
|
|
|
2024-04-10 14:27:23 +02:00
|
|
|
<div class="wrapper">
|
|
|
|
<header>header</header>
|
|
|
|
<Grid.Row>
|
|
|
|
<Grid.Cell>
|
2024-04-10 21:57:03 +02:00
|
|
|
result: {res}
|
|
|
|
<br />
|
|
|
|
time: {time}ms
|
2024-04-10 15:40:01 +02:00
|
|
|
</Grid.Cell>
|
|
|
|
<Grid.Cell>
|
|
|
|
{#key graph}
|
2024-04-10 21:57:03 +02:00
|
|
|
<GraphInterface
|
2024-04-10 15:40:01 +02:00
|
|
|
registry={nodeRegistry}
|
|
|
|
{graph}
|
|
|
|
on:result={handleResult}
|
|
|
|
on:save={handleSave}
|
|
|
|
/>
|
|
|
|
{/key}
|
2024-04-10 14:27:23 +02:00
|
|
|
</Grid.Cell>
|
|
|
|
</Grid.Row>
|
2024-03-06 14:01:07 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2024-04-10 14:27:23 +02:00
|
|
|
header {
|
|
|
|
border-bottom: solid thin white;
|
2024-03-06 14:01:07 +01:00
|
|
|
}
|
|
|
|
|
2024-03-20 02:17:58 +01:00
|
|
|
.wrapper {
|
2024-04-10 14:27:23 +02:00
|
|
|
height: 100vh;
|
|
|
|
width: 100vw;
|
|
|
|
color: white;
|
|
|
|
display: grid;
|
|
|
|
grid-template-rows: 50px 1fr;
|
|
|
|
}
|
|
|
|
|
|
|
|
.details-wrapper {
|
2024-04-10 15:40:01 +02:00
|
|
|
position: fixed;
|
2024-03-20 02:17:58 +01:00
|
|
|
z-index: 100;
|
2024-04-10 15:40:01 +02:00
|
|
|
bottom: 10px;
|
|
|
|
right: 10px;
|
2024-03-20 02:17:58 +01:00
|
|
|
}
|
|
|
|
|
2024-03-06 14:01:07 +01:00
|
|
|
:global(html) {
|
|
|
|
background: rgb(13, 19, 32);
|
|
|
|
background: linear-gradient(
|
|
|
|
180deg,
|
|
|
|
rgba(13, 19, 32, 1) 0%,
|
|
|
|
rgba(8, 12, 21, 1) 100%
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(body) {
|
|
|
|
margin: 0;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
</style>
|