2020-11-04 18:09:45 +01:00
|
|
|
import { getFrontendStore } from "./store/frontend"
|
2020-03-20 19:47:01 +01:00
|
|
|
import { getBackendUiStore } from "./store/backend"
|
2020-09-21 14:49:34 +02:00
|
|
|
import { getAutomationStore } from "./store/automation/"
|
2020-10-30 14:23:49 +01:00
|
|
|
import { getThemeStore } from "./store/theme"
|
2020-11-05 18:47:27 +01:00
|
|
|
import { derived } from "svelte/store"
|
2020-09-29 16:26:56 +02:00
|
|
|
import analytics from "analytics"
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-11-04 18:09:45 +01:00
|
|
|
export const store = getFrontendStore()
|
2020-03-20 19:47:01 +01:00
|
|
|
export const backendUiStore = getBackendUiStore()
|
2020-09-21 14:49:34 +02:00
|
|
|
export const automationStore = getAutomationStore()
|
2020-10-30 14:23:49 +01:00
|
|
|
export const themeStore = getThemeStore()
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-11-24 19:11:34 +01:00
|
|
|
export const currentAsset = derived(store, $store => {
|
2020-12-01 17:22:06 +01:00
|
|
|
const layout = $store.layouts
|
|
|
|
? $store.layouts.find(layout => layout._id === $store.currentAssetId)
|
|
|
|
: null
|
2020-11-24 19:11:34 +01:00
|
|
|
if (layout) {
|
|
|
|
return layout
|
2020-11-05 18:47:27 +01:00
|
|
|
}
|
2020-12-01 17:22:06 +01:00
|
|
|
const screen = $store.screens
|
|
|
|
? $store.screens.find(screen => screen._id === $store.currentAssetId)
|
|
|
|
: null
|
2020-11-24 19:11:34 +01:00
|
|
|
if (screen) {
|
|
|
|
return screen
|
2020-11-05 18:47:27 +01:00
|
|
|
}
|
2020-11-24 19:11:34 +01:00
|
|
|
return null
|
|
|
|
})
|
|
|
|
|
|
|
|
export const currentAssetName = derived(store, () => {
|
|
|
|
return currentAsset.name
|
|
|
|
})
|
|
|
|
|
|
|
|
// leave this as before for consistency
|
|
|
|
export const allScreens = derived(store, $store => {
|
|
|
|
return $store.screens
|
2020-11-05 18:47:27 +01:00
|
|
|
})
|
|
|
|
|
2020-11-25 18:56:09 +01:00
|
|
|
export const mainLayout = derived(store, $store => {
|
2020-12-01 17:22:06 +01:00
|
|
|
return $store.layouts?.find(
|
|
|
|
layout => layout.props?._id === "private-master-layout"
|
|
|
|
)
|
2020-11-05 18:47:27 +01:00
|
|
|
})
|
|
|
|
|
2019-07-13 11:35:57 +02:00
|
|
|
export const initialise = async () => {
|
2020-02-03 10:24:25 +01:00
|
|
|
try {
|
2020-10-12 22:35:10 +02:00
|
|
|
await analytics.activate()
|
2020-09-29 16:26:56 +02:00
|
|
|
analytics.captureEvent("Builder Started")
|
2020-02-03 10:24:25 +01:00
|
|
|
} catch (err) {
|
|
|
|
console.log(err)
|
|
|
|
}
|
2020-05-07 11:53:34 +02:00
|
|
|
}
|