da7339035f
* refactoring server for screens & page layout restructure * Disable API calls, UI placeholders. * buildPropsHierarchy is gone & screen has url * Recent changes. * router * router * updated git-ignore to reinclude server/utilities/builder * modified cli - budi new create new file structure * Fix uuid import. * prettier fixes * prettier fixes * prettier fixes * page/screen restructure.. broken tests * all tests passing at last * screen routing tests * Working screen editor and preview. * Render page previews to the screen. * Key input lists to ensure new array references when updating styles. * Ensure the iframe html and body fills the container. * Save screens via the API. * Get all save APIs almost working. * Write pages.json to disk. * Use correct API endpoint for saving styles. * Differentiate between saving properties of screens and pages. * Add required fields to default pages layouts. * Add _css default property to newly created screens. * Add default code property. * page layout / screens - app output * backend and fronend save seperately Co-authored-by: pngwn <pnda007@gmail.com>
81 lines
1.9 KiB
JavaScript
81 lines
1.9 KiB
JavaScript
import { createApp } from "./createApp"
|
|
import { trimSlash } from "./common/trimSlash"
|
|
import { builtins, builtinLibName } from "./render/builtinComponents"
|
|
|
|
export const loadBudibase = async ({
|
|
componentLibraries,
|
|
page,
|
|
screens,
|
|
window,
|
|
localStorage,
|
|
uiFunctions,
|
|
}) => {
|
|
const backendDefinition = window["##BUDIBASE_BACKEND_DEFINITION##"]
|
|
const frontendDefinition = window["##BUDIBASE_FRONTEND_DEFINITION##"]
|
|
const uiFunctionsFromWindow = window["##BUDIBASE_FRONTEND_FUNCTIONS##"]
|
|
uiFunctions = uiFunctionsFromWindow || uiFunctions
|
|
|
|
const userFromStorage = localStorage.getItem("budibase:user")
|
|
|
|
const user = userFromStorage
|
|
? JSON.parse(userFromStorage)
|
|
: {
|
|
name: "annonymous",
|
|
permissions: [],
|
|
isUser: false,
|
|
temp: false,
|
|
}
|
|
|
|
const rootPath =
|
|
frontendDefinition.appRootPath === ""
|
|
? ""
|
|
: "/" + trimSlash(frontendDefinition.appRootPath)
|
|
|
|
if (!componentLibraries) {
|
|
|
|
const componentLibraryUrl = lib => rootPath + "/" + trimSlash(lib)
|
|
componentLibraries = {}
|
|
|
|
for (let lib of frontendDefinition.componentLibraries) {
|
|
componentLibraries[lib.libName] = await import(
|
|
componentLibraryUrl(lib.importPath)
|
|
)
|
|
}
|
|
}
|
|
|
|
componentLibraries[builtinLibName] = builtins(window)
|
|
|
|
if (!page) {
|
|
page = frontendDefinition.page
|
|
}
|
|
|
|
if (!screens) {
|
|
screens = frontendDefinition.screens
|
|
}
|
|
|
|
const { initialisePage, screenStore, pageStore, routeTo, rootNode } = createApp(
|
|
window.document,
|
|
componentLibraries,
|
|
frontendDefinition,
|
|
backendDefinition,
|
|
user,
|
|
uiFunctions || {},
|
|
screens
|
|
)
|
|
|
|
const route = window.location
|
|
? window.location.pathname.replace(rootPath, "")
|
|
: "";
|
|
|
|
return {
|
|
rootNode: initialisePage(page, window.document.body, route),
|
|
screenStore,
|
|
pageStore,
|
|
routeTo,
|
|
rootNode
|
|
}
|
|
}
|
|
|
|
if (window) {
|
|
window.loadBudibase = loadBudibase
|
|
}
|