Replace the Vue frontend with Svelte

This commit is contained in:
Keavon Chambers
2023-03-10 03:54:39 -08:00
parent e539e43483
commit 6e20ea538b
83 changed files with 10013 additions and 19687 deletions
+11 -5
View File
@@ -1,25 +1,31 @@
/* eslint-disable max-classes-per-file */
import { nextTick, reactive, readonly } from "vue";
import {tick} from "svelte";
import {writable} from "svelte/store";
import { type Editor } from "@/wasm-communication/editor";
import { UpdateNodeGraphVisibility } from "@/wasm-communication/messages";
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function createWorkspaceState(editor: Editor) {
const state = reactive({
const { subscribe, update } = writable({
nodeGraphVisible: false,
});
// Set up message subscriptions on creation
editor.subscriptions.subscribeJsMessage(UpdateNodeGraphVisibility, async (updateNodeGraphVisibility) => {
state.nodeGraphVisible = updateNodeGraphVisibility.visible;
update((state) => {
state.nodeGraphVisible = updateNodeGraphVisibility.visible;
return state;
});
// Update the viewport bounds
await nextTick();
await tick();
window.dispatchEvent(new Event("resize"));
});
return {
state: readonly(state) as typeof state,
subscribe,
};
}
export type WorkspaceState = ReturnType<typeof createWorkspaceState>;