feat(svelte): ssr

This commit is contained in:
moklick
2023-10-05 17:27:53 +02:00
parent 1c791811a9
commit f37a2d9a19
10 changed files with 111 additions and 59 deletions
+24 -4
View File
@@ -29,8 +29,18 @@ import { getDerivedConnectionProps } from './derived-connection-props';
export const key = Symbol();
export function createStore(): SvelteFlowStore {
const store = getInitialStore();
export function createStore({
nodes,
edges,
width,
height
}: {
nodes?: Node[];
edges?: Edge[];
width?: number;
height?: number;
}): SvelteFlowStore {
const store = getInitialStore({ nodes, edges, width, height });
function setNodeTypes(nodeTypes: NodeTypes) {
store.nodeTypes.set({
@@ -333,8 +343,18 @@ export function useStore(): SvelteFlowStore {
return store.getStore();
}
export function createStoreContext() {
const store = createStore();
export function createStoreContext({
nodes,
edges,
width,
height
}: {
nodes?: Node[];
edges?: Edge[];
width?: number;
height?: number;
}) {
const store = createStore({ nodes, edges, width, height });
setContext(key, {
getStore: () => store