mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-26 08:08:13 +08:00
Replace the Vue frontend with Svelte
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user