2020-11-14 04:42:32 +13:00
|
|
|
import ClientApp from "./components/ClientApp.svelte"
|
2021-09-01 22:41:48 +12:00
|
|
|
import { builderStore, appStore } from "./stores"
|
|
|
|
import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
|
|
|
|
|
|
|
|
// Initialise spectrum icons
|
|
|
|
loadSpectrumIcons()
|
2019-09-07 17:50:35 +12:00
|
|
|
|
2020-11-24 03:28:02 +13:00
|
|
|
let app
|
|
|
|
|
2020-11-14 04:42:32 +13:00
|
|
|
const loadBudibase = () => {
|
2020-11-24 22:31:54 +13:00
|
|
|
// Update builder store with any builder flags
|
|
|
|
builderStore.set({
|
|
|
|
inBuilder: !!window["##BUDIBASE_IN_BUILDER##"],
|
2020-11-28 05:36:31 +13:00
|
|
|
layout: window["##BUDIBASE_PREVIEW_LAYOUT##"],
|
2020-11-24 22:31:54 +13:00
|
|
|
screen: window["##BUDIBASE_PREVIEW_SCREEN##"],
|
2020-12-01 01:11:50 +13:00
|
|
|
selectedComponentId: window["##BUDIBASE_SELECTED_COMPONENT_ID##"],
|
|
|
|
previewId: window["##BUDIBASE_PREVIEW_ID##"],
|
2021-01-06 23:16:21 +13:00
|
|
|
previewType: window["##BUDIBASE_PREVIEW_TYPE##"],
|
2021-06-28 23:55:11 +12:00
|
|
|
theme: window["##BUDIBASE_PREVIEW_THEME##"],
|
2020-05-30 01:06:10 +12:00
|
|
|
})
|
2020-11-24 22:31:54 +13:00
|
|
|
|
2021-07-01 07:35:02 +12:00
|
|
|
// Set app ID - this window flag is set by both the preview and the real
|
|
|
|
// server rendered app HTML
|
|
|
|
appStore.actions.setAppID(window["##BUDIBASE_APP_ID##"])
|
|
|
|
|
2020-11-24 22:31:54 +13:00
|
|
|
// Create app if one hasn't been created yet
|
|
|
|
if (!app) {
|
|
|
|
app = new ClientApp({
|
|
|
|
target: window.document.body,
|
|
|
|
})
|
|
|
|
}
|
2020-02-03 22:24:25 +13:00
|
|
|
}
|
|
|
|
|
2020-11-14 04:42:32 +13:00
|
|
|
// Attach to window so the HTML template can call this when it loads
|
|
|
|
window.loadBudibase = loadBudibase
|