feat: implement workspaces

This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent cc96739c38
commit cd817b7f53
153 changed files with 8970 additions and 1191 deletions
+32
View File
@@ -0,0 +1,32 @@
import useState from './state'
import useActions from './actions'
import useGetters from './getters'
import { FlowHooksOn, FlowOptions, State, Store } from '~/types'
export default (preloadedState?: FlowOptions): Store => {
const state: State = useState(preloadedState)
const reactiveState = reactive(state)
const getters = useGetters(reactiveState)
const actions = useActions(reactiveState, getters)
const hooksOn: FlowHooksOn = <any>{}
Object.entries(reactiveState.hooks).forEach(([n, h]) => {
const name = `on${n.charAt(0).toUpperCase() + n.slice(1)}`
hooksOn[<keyof FlowHooksOn>name] = h.on as any
})
actions.setState(reactiveState)
if (preloadedState) {
if (preloadedState.modelValue) actions.setElements(preloadedState.modelValue)
if (preloadedState.nodes) actions.setNodes(preloadedState.nodes)
if (preloadedState.edges) actions.setEdges(preloadedState.edges)
}
return {
state: reactiveState,
actions,
getters,
hooksOn,
...toRefs(reactiveState),
...getters,
...actions,
} as unknown as Store
}