2020-11-13 16:42:32 +01:00
|
|
|
import ClientApp from "./components/ClientApp.svelte"
|
2020-11-24 10:31:54 +01:00
|
|
|
import { builderStore } from "./store"
|
2019-09-07 07:50:35 +02:00
|
|
|
|
2020-11-23 15:28:02 +01:00
|
|
|
let app
|
|
|
|
|
2020-11-13 16:42:32 +01:00
|
|
|
const loadBudibase = () => {
|
2020-11-24 10:31:54 +01:00
|
|
|
// Update builder store with any builder flags
|
|
|
|
builderStore.set({
|
|
|
|
inBuilder: !!window["##BUDIBASE_IN_BUILDER##"],
|
2021-01-07 15:53:56 +01:00
|
|
|
appId: window["##BUDIBASE_APP_ID##"],
|
2020-11-27 17:36:31 +01:00
|
|
|
layout: window["##BUDIBASE_PREVIEW_LAYOUT##"],
|
2020-11-24 10:31:54 +01:00
|
|
|
screen: window["##BUDIBASE_PREVIEW_SCREEN##"],
|
2020-11-30 13:11:50 +01:00
|
|
|
selectedComponentId: window["##BUDIBASE_SELECTED_COMPONENT_ID##"],
|
|
|
|
previewId: window["##BUDIBASE_PREVIEW_ID##"],
|
2021-01-06 11:16:21 +01:00
|
|
|
previewType: window["##BUDIBASE_PREVIEW_TYPE##"],
|
2020-05-29 15:06:10 +02:00
|
|
|
})
|
2020-11-24 10:31:54 +01:00
|
|
|
|
|
|
|
// Create app if one hasn't been created yet
|
|
|
|
if (!app) {
|
|
|
|
app = new ClientApp({
|
|
|
|
target: window.document.body,
|
|
|
|
})
|
|
|
|
}
|
2020-02-03 10:24:25 +01:00
|
|
|
}
|
|
|
|
|
2020-11-13 16:42:32 +01:00
|
|
|
// Attach to window so the HTML template can call this when it loads
|
|
|
|
window.loadBudibase = loadBudibase
|