refactor: how the keymap gets to the viewer
This commit is contained in:
parent
e575974872
commit
1d203c687c
@ -79,7 +79,6 @@
|
|||||||
|
|
||||||
$: if ($colors.outline) {
|
$: if ($colors.outline) {
|
||||||
lineColor.copyLinearToSRGB($colors.outline);
|
lineColor.copyLinearToSRGB($colors.outline);
|
||||||
console.log("lineColor", lineColor);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
import type { Graph, NodeRegistry } from "@nodes/types";
|
import type { Graph, NodeRegistry } from "@nodes/types";
|
||||||
import GraphEl from "./Graph.svelte";
|
import GraphEl from "./Graph.svelte";
|
||||||
import { GraphManager } from "../graph-manager.js";
|
import { GraphManager } from "../graph-manager.js";
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher, setContext } from "svelte";
|
||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import { debounce } from "$lib/helpers";
|
import { debounce } from "$lib/helpers";
|
||||||
|
import { createKeyMap } from "$lib/helpers/createKeyMap";
|
||||||
|
|
||||||
export let registry: NodeRegistry;
|
export let registry: NodeRegistry;
|
||||||
export let graph: Graph;
|
export let graph: Graph;
|
||||||
@ -14,6 +15,9 @@
|
|||||||
|
|
||||||
export const status = manager.status;
|
export const status = manager.status;
|
||||||
|
|
||||||
|
export const keymap = createKeyMap([]);
|
||||||
|
setContext("keymap", keymap);
|
||||||
|
|
||||||
const updateSettings = debounce((s) => {
|
const updateSettings = debounce((s) => {
|
||||||
manager.setSettings(s);
|
manager.setSettings(s);
|
||||||
}, 200);
|
}, 200);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { createKeyMap } from "$lib/helpers/createKeyMap";
|
import type { createKeyMap } from "$lib/helpers/createKeyMap";
|
||||||
import { getContext } from "svelte";
|
|
||||||
|
|
||||||
const { keys } = getContext<ReturnType<typeof createKeyMap>>("keymap");
|
export let keymap: ReturnType<typeof createKeyMap>;
|
||||||
|
const keys = keymap.keys;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
0
app/src/lib/settings/NodeStore.svelte
Normal file
0
app/src/lib/settings/NodeStore.svelte
Normal file
@ -21,7 +21,9 @@
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
$: keys = panels
|
$: keys = panels
|
||||||
? (Object.keys(panels) as unknown as (keyof typeof panels)[])
|
? (Object.keys(panels) as unknown as (keyof typeof panels)[]).filter(
|
||||||
|
(key) => !!panels[key]?.id,
|
||||||
|
)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
function setActivePanel(panel: keyof typeof panels | false) {
|
function setActivePanel(panel: keyof typeof panels | false) {
|
||||||
@ -83,7 +85,7 @@
|
|||||||
{#if panels[$activePanel]?.component}
|
{#if panels[$activePanel]?.component}
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={panels[$activePanel].component}
|
this={panels[$activePanel].component}
|
||||||
{...panels[$activePanel]}
|
{...panels[$activePanel]?.props}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
import { AppSettings, AppSettingTypes } from "$lib/settings/app-settings";
|
import { AppSettings, AppSettingTypes } from "$lib/settings/app-settings";
|
||||||
import { get, writable, type Writable } from "svelte/store";
|
import { get, writable, type Writable } from "svelte/store";
|
||||||
import Keymap from "$lib/settings/Keymap.svelte";
|
import Keymap from "$lib/settings/Keymap.svelte";
|
||||||
import { createKeyMap } from "$lib/helpers/createKeyMap";
|
import type { createKeyMap } from "$lib/helpers/createKeyMap";
|
||||||
import { setContext } from "svelte";
|
|
||||||
|
|
||||||
const nodeRegistry = new RemoteNodeRegistry("http://localhost:3001");
|
const nodeRegistry = new RemoteNodeRegistry("http://localhost:3001");
|
||||||
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
||||||
@ -24,6 +23,8 @@
|
|||||||
|
|
||||||
let managerStatus: Writable<"loading" | "error" | "idle">;
|
let managerStatus: Writable<"loading" | "error" | "idle">;
|
||||||
|
|
||||||
|
let keymap: ReturnType<typeof createKeyMap>;
|
||||||
|
|
||||||
function handleResult(event: CustomEvent<Graph>) {
|
function handleResult(event: CustomEvent<Graph>) {
|
||||||
res = runtimeExecutor.execute(event.detail, get(settings?.graph?.settings));
|
res = runtimeExecutor.execute(event.detail, get(settings?.graph?.settings));
|
||||||
}
|
}
|
||||||
@ -32,10 +33,6 @@
|
|||||||
localStorage.setItem("graph", JSON.stringify(event.detail));
|
localStorage.setItem("graph", JSON.stringify(event.detail));
|
||||||
}
|
}
|
||||||
|
|
||||||
const keyMap = createKeyMap([]);
|
|
||||||
|
|
||||||
setContext("keymap", keyMap);
|
|
||||||
|
|
||||||
let settings: Record<string, any> = {
|
let settings: Record<string, any> = {
|
||||||
general: {
|
general: {
|
||||||
id: "general",
|
id: "general",
|
||||||
@ -43,13 +40,21 @@
|
|||||||
settings: AppSettings,
|
settings: AppSettings,
|
||||||
definition: AppSettingTypes,
|
definition: AppSettingTypes,
|
||||||
},
|
},
|
||||||
|
shortcuts: {},
|
||||||
graph: {},
|
graph: {},
|
||||||
shortcuts: {
|
};
|
||||||
|
|
||||||
|
$: if (keymap) {
|
||||||
|
settings.shortcuts = {
|
||||||
id: "shortcuts",
|
id: "shortcuts",
|
||||||
icon: "i-tabler-keyboard",
|
icon: "i-tabler-keyboard",
|
||||||
|
props: { keymap },
|
||||||
component: Keymap,
|
component: Keymap,
|
||||||
},
|
};
|
||||||
};
|
|
||||||
|
settings = settings;
|
||||||
|
console.log({ settings });
|
||||||
|
}
|
||||||
|
|
||||||
function handleSettings(
|
function handleSettings(
|
||||||
ev: CustomEvent<{
|
ev: CustomEvent<{
|
||||||
@ -88,6 +93,7 @@
|
|||||||
<GraphInterface
|
<GraphInterface
|
||||||
registry={nodeRegistry}
|
registry={nodeRegistry}
|
||||||
{graph}
|
{graph}
|
||||||
|
bind:keymap
|
||||||
bind:status={managerStatus}
|
bind:status={managerStatus}
|
||||||
settings={settings?.graph?.settings}
|
settings={settings?.graph?.settings}
|
||||||
on:settings={handleSettings}
|
on:settings={handleSettings}
|
||||||
|
Loading…
Reference in New Issue
Block a user