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-15 22:13:43 +02:00
|
|
|
import GraphInterface from "$lib/graph-interface";
|
2024-03-19 16:41:15 +01:00
|
|
|
import { MemoryRuntimeExecutor } from "$lib/runtime-executor";
|
2024-04-15 18:46:34 +02:00
|
|
|
import { 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-04-16 15:32:23 +02:00
|
|
|
import Viewer from "$lib/viewer/Viewer.svelte";
|
2024-04-18 18:39:24 +02:00
|
|
|
import Settings from "$lib/settings/Settings.svelte";
|
|
|
|
import { AppSettings, AppSettingTypes } from "$lib/settings/app-settings";
|
|
|
|
import { get, writable } from "svelte/store";
|
2024-04-18 00:02:50 +02: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-16 15:32:23 +02:00
|
|
|
let res: Int32Array;
|
2024-04-10 21:57:03 +02:00
|
|
|
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-18 18:39:24 +02:00
|
|
|
res = runtimeExecutor.execute(event.detail, get(settings?.graph?.settings));
|
2024-04-10 21:57:03 +02:00
|
|
|
time = performance.now() - a;
|
2024-04-18 00:02:50 +02:00
|
|
|
console.log({ res, time });
|
2024-04-10 15:40:01 +02:00
|
|
|
}
|
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-04-18 18:39:24 +02:00
|
|
|
|
|
|
|
let settings: Record<string, any> = {
|
|
|
|
general: {
|
|
|
|
id: "general",
|
|
|
|
icon: "i-tabler-settings",
|
|
|
|
settings: AppSettings,
|
|
|
|
definition: AppSettingTypes,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function handleSettings(
|
|
|
|
ev: CustomEvent<{
|
|
|
|
values: Record<string, unknown>;
|
|
|
|
types: Record<string, unknown>;
|
|
|
|
}>,
|
|
|
|
) {
|
|
|
|
settings = {
|
|
|
|
...settings,
|
|
|
|
graph: {
|
|
|
|
icon: "i-tabler-chart-bar",
|
|
|
|
id: "graph",
|
|
|
|
settings: writable(ev.detail.values),
|
|
|
|
definition: ev.detail.types,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2024-03-06 14:01:07 +01:00
|
|
|
</script>
|
|
|
|
|
2024-04-10 14:27:23 +02:00
|
|
|
<div class="wrapper">
|
2024-04-15 18:46:34 +02:00
|
|
|
<header>
|
|
|
|
header
|
|
|
|
<button
|
|
|
|
on:click={() => {
|
2024-04-18 14:10:08 +02:00
|
|
|
graph = templates.grid(15, 15);
|
2024-04-15 18:46:34 +02:00
|
|
|
}}>grid stress-test</button
|
|
|
|
>
|
|
|
|
</header>
|
2024-04-10 14:27:23 +02:00
|
|
|
<Grid.Row>
|
|
|
|
<Grid.Cell>
|
2024-04-16 15:32:23 +02:00
|
|
|
<Viewer result={res} />
|
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}
|
2024-04-18 18:39:24 +02:00
|
|
|
settings={settings?.graph?.settings}
|
|
|
|
on:settings={handleSettings}
|
2024-04-10 15:40:01 +02:00
|
|
|
on:result={handleResult}
|
|
|
|
on:save={handleSave}
|
|
|
|
/>
|
2024-04-18 18:39:24 +02:00
|
|
|
<Settings {settings}></Settings>
|
2024-04-10 15:40:01 +02:00
|
|
|
{/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;
|
|
|
|
}
|
|
|
|
|
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>
|