budibase/packages/client/src/index.js

32 lines
785 B
JavaScript
Raw Normal View History

import { createApp } from "./createApp";
2019-09-06 14:04:23 +02:00
2019-09-07 07:50:35 +02:00
2019-09-22 06:02:33 +02:00
export const loadBudibase = async (componentLibraries, props) => {
2019-09-22 06:02:33 +02:00
const appDefinition = window["##BUDIBASE_APPDEFINITION##"];
2019-09-22 06:02:33 +02:00
if(!componentLibraries) {
const componentLibraryUrl = (lib) => "./" + trimSlash(lib)
const trimSlash = (str) => str.replace(/^\/+|\/+$/g, '');
componentLibraries = {};
for(let lib of appDefinition.componentLibraries) {
componentLibraries[lib.libName] = await import(
componentLibraryUrl(lib.importPath));
}
}
2019-09-22 06:02:33 +02:00
if(!props) {
props = appDefinition.props;
}
const _app = createApp(componentLibraries);
_app.initialiseComponent(
props,
document.body);
2019-09-22 06:02:33 +02:00
};
window.loadBudibase = loadBudibase;