working on client lib

This commit is contained in:
michael shanks 2019-09-06 13:04:23 +01:00
parent 53287779f2
commit e383c03435
23 changed files with 483 additions and 7347 deletions

View File

@ -9,7 +9,6 @@ import nodeglobals from 'rollup-plugin-node-globals';
import copy from 'rollup-plugin-copy';
import browsersync from "rollup-plugin-browsersync";
import proxy from "http-proxy-middleware";
import corePackageJson from "../core/package.json";
const target = 'http://localhost:4001';
const _builderProxy = proxy('/_builder', {
@ -48,15 +47,6 @@ const coreExternal = [
"@nx-js/compiler-util"
];
const globals = {
"lodash/fp": "fp",
lodash: "_",
lunr: "lunr",
"safe-buffer": "safe_buffer",
shortid:"shortid",
"@nx-js/compiler-util":"compiler_util"
}
export default {
input: 'src/main.js',
output: {
@ -64,13 +54,7 @@ export default {
format: 'iife',
name: 'app',
file: `${outputpath}/bundle.js`
//globals
},
/*external: [
"lodash", "lodash/fp", "date-fns",
"lunr", "safe-buffer", "shortid",
"@nx-js/compiler-util"
],*/
plugins: [
copy({
targets: [

View File

@ -17,4 +17,4 @@ export const loadLib = async (appName, lib, allLibs) => {
}
export const makeLibraryUrl = (appName, lib) =>
`/_builder/api/${appName}/componentlibrary?lib=${encodeURI(lib)}`
`/${appName}/componentlibrary?lib=${encodeURI(lib)}`

6
packages/client/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.DS_Store
node_modules
package-lock.json
yarn.lock
release/
dist/

View File

@ -1,4 +1,4 @@
{
module.exports = ({
"presets": ["@babel/preset-env"],
"sourceMaps": "inline",
"retainLines": true,
@ -9,4 +9,4 @@
}
]
]
}
});

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,55 @@
{
"name": "budibase-client-library",
"name": "budibase-builder",
"version": "0.0.1",
"description": "Client library for talking to budibase web server",
"main": "index.js",
"license": "AGPL-3.0",
"scripts": {
"build": "rollup -c",
"test": "jest"
},
"jest": {
"globals": {
"GLOBALS": {
"client": "web"
}
},
"testURL": "http://jest-breaks-if-this-does-not-exist",
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/internals/mocks/fileMock.js",
"\\.(css|less|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"js"
],
"moduleDirectories": [
"node_modules"
],
"transform": {
"^.+js$": "babel-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?!svelte).+\\.js$"
]
},
"dependencies": {
"@nx-js/compiler-util": "^2.0.0",
"date-fns": "^1.29.0",
"lodash": "^4.17.15",
"lunr": "^2.3.5",
"shortid": "^2.2.8",
"svelte": "^3.9.2"
},
"keywords": [
"budibase"
],
"author": "Michael Shanks",
"license": "MPL-2.0",
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"babel-jest": "^23.6.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"cross-env": "^5.1.4",
"@babel/core": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/runtime": "^7.5.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"regenerator-runtime": "^0.11.1",
"rollup": "^1.12.0",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-local-resolve": "^1.0.7",
"rollup-plugin-node-resolve": "^5.0.0"
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^4.0.4"
}
}

View File

@ -0,0 +1,58 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import builtins from 'rollup-plugin-node-builtins';
import nodeglobals from 'rollup-plugin-node-globals';
import { terser } from 'rollup-plugin-terser';
const lodash_fp_exports = [
"find", "isUndefined", "split",
"last", "union", "reduce",
"cloneDeep", "some"];
const lodash_exports = [
"flow","reduce", "constant", "head", "isEmpty",
"tail", "findIndex", "startsWith",
"join", "dropRight", "takeRight",
"trim", "split", "includes", "replace",
"isArray", "isString", "isInteger",
"isDate", "toNumber", "isUndefined",
"isNull", "isNaN"];
const coreExternal = [
"lodash", "lodash/fp", "date-fns",
"lunr", "safe-buffer", "shortid",
"@nx-js/compiler-util"
];
export default {
input: 'src/index.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: `./dist/budibase-client.js`
},
plugins: [
resolve({
preferBuiltins:true,
browser:true,
dedupe: importee => {
return coreExternal.includes(importee);
}
}),
commonjs({
namedExports: {
"lodash/fp": lodash_fp_exports,
"lodash":lodash_exports,
"shortid": ["generate"]
}
}),
builtins(),
nodeglobals(),
terser()
],
watch: {
clearScreen: false
}
};

View File

@ -0,0 +1,5 @@
export {
$
} from "../../../core/src/common";

View File

@ -0,0 +1,3 @@
import { initialise } from "./initialise";
initialise();

View File

@ -0,0 +1,35 @@
import { writable } from "svelte/store";
import { initialiseComponent } from "./initialiseComponent";
export const initialise = async (document, appDefinition, pageDefinition) => {
for(let stylesheet of pageDefinition.stylesheets) {
addStylesheet(document, stylesheet);
}
const componentLibraries = {};
for(let lib of appDefinition.componentLibraries) {
componentLibraries[lib] = await import(
componentLibraryUrl(lib, appDefinition.appRootPath));
}
const store = writable({});
initialiseComponent(allComponents, componentLibraries, store)(
appDefinition.rootProps,
document.body);
}
const componentLibraryUrl = (lib, rootUrlPath) =>
`${rootPath}/api/componentlibrary?lib=${encodeURI(lib)}`
const addStylesheet = (document, url) => {
const head = document.head;
const link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = url;
head.appendChild(link);
}

View File

@ -0,0 +1,51 @@
import {
find,
isUndefined,
split,
last
} from "lodash/fp";
import { $ } from "./core/common";
export const initialiseComponent = (allComponents, componentLibraries, store) => (props, htmlElement) => {
const rootComponent = getRootComponent(
props._component, allComponents);
const _app = {
initialiseComponent: initialiseComponent(allComponents, componentLibraries, store),
store
};
const {componentName, libName} = splitName(
rootComponent.name);
new (componentLibraries[libName][componentName])({
target: htmlElement,
props: {...props, _app}
});
}
const getRootComponent = (componentName, allComponents) => {
const component = find(c => c.name === componentName)(allComponents);
if(isRootComponent(component)) return component;
return getRootComponent(component.inherits, allComponents);
}
const isRootComponent = c => isUndefined(c.inherits);
const splitName = fullname => {
const componentName = $(fullname, [
split("/"),
last
]);
const libName =fullname.substring(
0, fullname.length - componentName.length - 1);
return {libName, componentName};
}

View File

@ -1,43 +1,43 @@
main.svelte-j8mzr7{height:100%;width:100%;font-family:"Lato", Helvetica, Arial, sans-serif}
.root.svelte-fkeby9{height:100%;width:100%;display:flex;flex-direction:column}.top-nav.svelte-fkeby9{flex:0 0 auto;height:25px;background:white;border-style:solid;border-width:0px 0px 1px 0px;border-color:var(--lightslate);padding:5px;width:100%}.content.svelte-fkeby9{flex:1 1 auto;width:100%;height:100px}.content.svelte-fkeby9>div.svelte-fkeby9{height:100%;width:100%}.topnavitem.svelte-fkeby9{cursor:pointer;color:var(--slate);padding:0px 15px}.topnavitem.svelte-fkeby9:hover{color:var(--secondary75)}.active.svelte-fkeby9{color:var(--secondary100)}
.root.svelte-e4n7zy{position:fixed;margin:0 auto;text-align:center;top:20%;width:100%}.inner.svelte-e4n7zy{display:inline-block;margin:auto}.logo.svelte-e4n7zy{width:300px;margin-bottom:40px}.root.svelte-e4n7zy .option{width:250px}.app-link.svelte-e4n7zy{margin-top:10px;display:block}
.root.svelte-q8uz1n{height:100%;display:flex}.content.svelte-q8uz1n{flex:1 1 auto;height:100%;background-color:var(--white);margin:0}.nav.svelte-q8uz1n{flex:0 1 auto;width:300px;height:100%}
.root.svelte-fkeby9{height:100%;width:100%;display:flex;flex-direction:column}.top-nav.svelte-fkeby9{flex:0 0 auto;height:25px;background:white;border-style:solid;border-width:0px 0px 1px 0px;border-color:var(--lightslate);padding:5px;width:100%}.content.svelte-fkeby9{flex:1 1 auto;width:100%;height:100px}.content.svelte-fkeby9>div.svelte-fkeby9{height:100%;width:100%}.topnavitem.svelte-fkeby9{cursor:pointer;color:var(--slate);padding:0px 15px}.topnavitem.svelte-fkeby9:hover{color:var(--secondary75)}.active.svelte-fkeby9{color:var(--secondary100)}
button.svelte-bxuckr{border-style:none;background-color:rgba(0,0,0,0);cursor:pointer;outline:none}button.svelte-bxuckr:hover{color:var(--hovercolor)}button.svelte-bxuckr:active{outline:none}
.border-normal.svelte-7rfkdx{border-radius:var(--borderradiusall)}.border-left.svelte-7rfkdx{border-radius:var(--borderradius) 0 0 var(--borderradius)}.border-right.svelte-7rfkdx{border-radius:0 var(--borderradius) var(--borderradius) 0}.border-middle.svelte-7rfkdx{border-radius:0}button.svelte-7rfkdx{border-style:solid;padding:7px 15px;cursor:pointer}.primary.svelte-7rfkdx{background-color:var(--primary100);border-color:var(--primary100);color:var(--white)}.primary.svelte-7rfkdx:hover{background-color:var(--primary75);border-color:var(--primary75)}.primary.svelte-7rfkdx:active{background-color:var(--primarydark);border-color:var(--primarydark)}.primary-outline.svelte-7rfkdx{background-color:var(--white);border-color:var(--primary100);color:var(--primary100)}.primary-outline.svelte-7rfkdx:hover{background-color:var(--primary10)}.primary-outline.svelte-7rfkdx:pressed{background-color:var(--primary25)}.secondary.svelte-7rfkdx{background-color:var(--secondary100);border-color:var(--secondary100);color:var(--white)}.secondary.svelte-7rfkdx:hover{background-color:var(--secondary75);border-color:var(--secondary75)}.secondary.svelte-7rfkdx:pressed{background-color:var(--secondarydark);border-color:var(--secondarydark)}.secondary-outline.svelte-7rfkdx{background-color:var(--white);border-color:var(--secondary100);color:var(--secondary100)}.secondary-outline.svelte-7rfkdx:hover{background-color:var(--secondary10)}.secondary-outline.svelte-7rfkdx:pressed{background-color:var(--secondary25)}.success.svelte-7rfkdx{background-color:var(--success100);border-color:var(--success100);color:var(--white)}.success.svelte-7rfkdx:hover{background-color:var(--success75);border-color:var(--success75)}.success.svelte-7rfkdx:pressed{background-color:var(--successdark);border-color:var(--successdark)}.success-outline.svelte-7rfkdx{background-color:var(--white);border-color:var(--success100);color:var(--success100)}.success-outline.svelte-7rfkdx:hover{background-color:var(--success10)}.success-outline.svelte-7rfkdx:pressed{background-color:var(--success25)}.deletion.svelte-7rfkdx{background-color:var(--deletion100);border-color:var(--deletion100);color:var(--white)}.deletion.svelte-7rfkdx:hover{background-color:var(--deletion75);border-color:var(--deletion75)}.deletion.svelte-7rfkdx:pressed{background-color:var(--deletiondark);border-color:var(--deletiondark)}.deletion-outline.svelte-7rfkdx{background-color:var(--white);border-color:var(--deletion100);color:var(--deletion100)}.deletion-outline.svelte-7rfkdx:hover{background-color:var(--deletion10)}.deletion-outline.svelte-7rfkdx:pressed{background-color:var(--deletion25)}
.root.svelte-q8uz1n{height:100%;display:flex}.content.svelte-q8uz1n{flex:1 1 auto;height:100%;background-color:var(--white);margin:0}.nav.svelte-q8uz1n{flex:0 1 auto;width:300px;height:100%}
.root.svelte-1dih19s{display:grid;grid-template-columns:[uiNav] 250px [preview] auto [properties] 300px;height:100%;width:100%}.ui-nav.svelte-1dih19s{grid-column-start:uiNav;background-color:var(--primary10);height:100%}.properties-pane.svelte-1dih19s{grid-column-start:properties;background-color:var(--primary10);height:100%}.pages-list-container.svelte-1dih19s{padding-top:20px}.nav-group-header.svelte-1dih19s{font-size:10pt;padding-left:10px}.nav-items-container.svelte-1dih19s{padding-top:10px}.nav-group-header.svelte-1dih19s{display:grid;grid-template-columns:[icon] auto [title] 1fr [button] auto;padding:10px 2px 0px 7px}.nav-group-header.svelte-1dih19s>div.svelte-1dih19s:nth-child(1){padding:0px 7px 0px 0px;vertical-align:bottom;grid-column-start:icon;margin-right:5px}.nav-group-header.svelte-1dih19s>span.svelte-1dih19s:nth-child(2){margin-left:5px;vertical-align:bottom;grid-column-start:title;margin-top:auto}.nav-group-header.svelte-1dih19s>div.svelte-1dih19s:nth-child(3){vertical-align:bottom;grid-column-start:button;cursor:pointer;color:var(--slate)}.nav-group-header.svelte-1dih19s>div.svelte-1dih19s:nth-child(3):hover{color:var(--primary75)}
h4.svelte-o0id5a{margin-top:20px}
.root.svelte-apja7r{height:100%;position:relative}.actions-header.svelte-apja7r{flex:0 1 auto}.node-view.svelte-apja7r{overflow-y:auto;flex:1 1 auto}
.root.svelte-zy9ybu{height:100%;background-color:var(--primary10)}.items-root.svelte-zy9ybu{display:flex;flex-direction:column;max-height:100%;height:10px}.hierarchy.svelte-zy9ybu{flex:1 1 auto}.hierarchy-title-row.svelte-zy9ybu{padding:15px 7px;font-size:12pt;display:flex;font-weight:bold}.hierarchy-title.svelte-zy9ybu{flex:auto 1 1}.space-filler.svelte-zy9ybu{flex:1 1 auto}
.root.svelte-1qmjs65{padding:10px}.edit-button.svelte-1qmjs65{cursor:pointer;color:var(--white)}tr.svelte-1qmjs65:hover .edit-button.svelte-1qmjs65{color:var(--secondary75)}
.root.svelte-183dehm{height:100%;border-style:solid;border-color:var(--lightslate);border-width:0px 0px 0px 1px}.padding.svelte-183dehm{padding:0px 5px 0px 10px}.title.svelte-183dehm{background-color:white;padding:3px;display:grid;grid-template-columns:[name] 1fr [actions] auto}.title.svelte-183dehm>div.svelte-183dehm:nth-child(1){grid-column-start:name;color:var(--secondary100)}.title.svelte-183dehm>div.svelte-183dehm:nth-child(2){grid-column-start:actions}.section-header.svelte-183dehm{font-style:italic;color:var(--slate);border-style:solid;border-color:var(--lightslate);border-width:0px 0px 1px 0px}.section-header.svelte-183dehm{vertical-align:middle;margin-top:20px}
.root.svelte-ffb307{padding-bottom:10px;padding-left:10px;font-size:16px;color:var(--secondary50)}.hierarchy-item.svelte-ffb307{cursor:pointer;padding:5px 0px}.hierarchy-item.svelte-ffb307:hover{color:var(--secondary75)}.component.svelte-ffb307{margin-left:5px}.selected.svelte-ffb307{color:var(--primary100)}.title.svelte-ffb307{margin-left:10px}
h1.svelte-2ukyrk{font-size:1.2em}
.section-container.svelte-1t0x31f{padding:15px;border-style:dotted;border-width:1px;border-color:var(--lightslate);border-radius:2px}.section-container.svelte-1t0x31f:nth-child(1){margin-bottom:15px}.row-text.svelte-1t0x31f{margin-right:15px;color:var(--primary100)}input.svelte-1t0x31f{margin-right:15px}p.svelte-1t0x31f>span.svelte-1t0x31f{margin-left:30px}.header.svelte-1t0x31f{display:grid;grid-template-columns:[title] 1fr [icon] auto}.header.svelte-1t0x31f>div.svelte-1t0x31f:nth-child(1){grid-column-start:title}.header.svelte-1t0x31f>div.svelte-1t0x31f:nth-child(2){grid-column-start:icon}
.component-preview.svelte-1jir83x{display:grid;grid-template-rows:[top] 1fr [middle] auto [bottom] 1fr;grid-template-columns:[left] 1fr [middle] auto [right] 1fr;grid-column-start:preview;height:100%}.component-container.svelte-1jir83x{grid-row-start:middle;grid-column-start:middle}
.root.svelte-zzs4qg{padding:10px}
.root.svelte-1cnqtw{color:var(--secondary50)}.hierarchy-item.svelte-1cnqtw{cursor:pointer;padding:5px 0px}.hierarchy-item.svelte-1cnqtw:hover{color:var(--secondary75)}.component.svelte-1cnqtw{margin-left:5px}.currentfolder.svelte-1cnqtw{color:var(--secondary100)}.selected.svelte-1cnqtw{color:var(--primary100)}.title.svelte-1cnqtw{margin-left:10px}
.root.svelte-kswv5p{height:100%;padding:15px}.fields-table.svelte-kswv5p{margin:10px;border-collapse:collapse}.add-field-button.svelte-kswv5p{margin-left:15px;cursor:pointer}.edit-button.svelte-kswv5p{cursor:pointer;color:var(--white)}.edit-button.svelte-kswv5p:hover{color:var(--secondary75)}th.svelte-kswv5p{text-align:left}td.svelte-kswv5p{padding:5px 30px 5px 0px;margin:0}thead.svelte-kswv5p>tr.svelte-kswv5p{border-width:0px 0px 1px 0px;border-style:solid;border-color:var(--secondary75);margin-bottom:20px}tbody.svelte-kswv5p>tr.svelte-kswv5p{border-width:0px 0px 1px 0px;border-style:solid;border-color:var(--primary10)}tbody.svelte-kswv5p>tr.svelte-kswv5p:hover{background-color:var(--primary10)}tbody.svelte-kswv5p>tr:hover .edit-button.svelte-kswv5p{color:var(--secondary75)}.index-container.svelte-kswv5p{border-style:solid;border-width:0 0 1px 0;border-color:var(--secondary25);padding:10px;margin-bottom:5px}.index-label.svelte-kswv5p{color:var(--slate)}.index-name.svelte-kswv5p{font-weight:bold;color:var(--primary100)}.index-container.svelte-kswv5p code.svelte-kswv5p{margin:0;display:inline;background-color:var(--primary10);color:var(--secondary100);padding:3px}.index-field-row.svelte-kswv5p{margin-top:7px}
.root.svelte-1q40nqm{display:block;font-size:13pt;width:100%;cursor:pointer}.title.svelte-1q40nqm{font:var(--bodytext);padding-top:10px;padding-right:5px;padding-bottom:10px;color:var(--secondary100)}.title.svelte-1q40nqm:hover{background-color:var(--secondary10)}
.root.svelte-pq2tmv{height:100%;padding:15px}.allowed-records.svelte-pq2tmv{margin:20px 0px}.allowed-records.svelte-pq2tmv>span.svelte-pq2tmv{margin-right:30px}
.root.svelte-1bn4xbe{display:block;font-size:12pt;width:100%;cursor:pointer}.title.svelte-1bn4xbe{padding-top:5px;padding-right:5px;padding-bottom:5px;color:var(--secondary100)}.title.svelte-1bn4xbe:hover{background-color:var(--secondary10)}.active.svelte-1bn4xbe{background-color:var(--primary10)}
.dropdown-background.svelte-179p8ge{position:fixed;top:0;left:0;width:100vw;height:100vh}.root.svelte-179p8ge{cursor:pointer;z-index:1}.dropdown-content.svelte-179p8ge{position:absolute;background-color:var(--white);min-width:160px;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);z-index:1;font-weight:normal;border-style:solid;border-width:1px;border-color:var(--secondary10)}.dropdown-content.svelte-179p8ge:not(:focus){display:none}.action-row.svelte-179p8ge{padding:7px 10px;cursor:pointer}.action-row.svelte-179p8ge:hover{background-color:var(--primary100);color:var(--white)}
.root.svelte-183dehm{height:100%;border-style:solid;border-color:var(--lightslate);border-width:0px 0px 0px 1px}.padding.svelte-183dehm{padding:0px 5px 0px 10px}.title.svelte-183dehm{background-color:white;padding:3px;display:grid;grid-template-columns:[name] 1fr [actions] auto}.title.svelte-183dehm>div.svelte-183dehm:nth-child(1){grid-column-start:name;color:var(--secondary100)}.title.svelte-183dehm>div.svelte-183dehm:nth-child(2){grid-column-start:actions}.section-header.svelte-183dehm{font-style:italic;color:var(--slate);border-style:solid;border-color:var(--lightslate);border-width:0px 0px 1px 0px}.section-header.svelte-183dehm{vertical-align:middle;margin-top:20px}
h1.svelte-2ukyrk{font-size:1.2em}
.root.svelte-ffb307{padding-bottom:10px;padding-left:10px;font-size:16px;color:var(--secondary50)}.hierarchy-item.svelte-ffb307{cursor:pointer;padding:5px 0px}.hierarchy-item.svelte-ffb307:hover{color:var(--secondary75)}.component.svelte-ffb307{margin-left:5px}.selected.svelte-ffb307{color:var(--primary100)}.title.svelte-ffb307{margin-left:10px}
.section-container.svelte-1t0x31f{padding:15px;border-style:dotted;border-width:1px;border-color:var(--lightslate);border-radius:2px}.section-container.svelte-1t0x31f:nth-child(1){margin-bottom:15px}.row-text.svelte-1t0x31f{margin-right:15px;color:var(--primary100)}input.svelte-1t0x31f{margin-right:15px}p.svelte-1t0x31f>span.svelte-1t0x31f{margin-left:30px}.header.svelte-1t0x31f{display:grid;grid-template-columns:[title] 1fr [icon] auto}.header.svelte-1t0x31f>div.svelte-1t0x31f:nth-child(1){grid-column-start:title}.header.svelte-1t0x31f>div.svelte-1t0x31f:nth-child(2){grid-column-start:icon}
.root.svelte-1ersoxu{padding:15px}.help-text.svelte-1ersoxu{color:var(--slate);font-size:10pt}
.component-preview.svelte-1jir83x{display:grid;grid-template-rows:[top] 1fr [middle] auto [bottom] 1fr;grid-template-columns:[left] 1fr [middle] auto [right] 1fr;grid-column-start:preview;height:100%}.component-container.svelte-1jir83x{grid-row-start:middle;grid-column-start:middle}
.root.svelte-zy9ybu{height:100%;background-color:var(--primary10)}.items-root.svelte-zy9ybu{display:flex;flex-direction:column;max-height:100%;height:10px}.hierarchy.svelte-zy9ybu{flex:1 1 auto}.hierarchy-title-row.svelte-zy9ybu{padding:15px 7px;font-size:12pt;display:flex;font-weight:bold}.hierarchy-title.svelte-zy9ybu{flex:auto 1 1}.space-filler.svelte-zy9ybu{flex:1 1 auto}
.root.svelte-apja7r{height:100%;position:relative}.actions-header.svelte-apja7r{flex:0 1 auto}.node-view.svelte-apja7r{overflow-y:auto;flex:1 1 auto}
.root.svelte-1qmjs65{padding:10px}.edit-button.svelte-1qmjs65{cursor:pointer;color:var(--white)}tr.svelte-1qmjs65:hover .edit-button.svelte-1qmjs65{color:var(--secondary75)}
.root.svelte-zzs4qg{padding:10px}
.root.svelte-d6wwkb{display:flex}.root.svelte-d6wwkb:last-child{border-radius:0 var(--borderradius) var(--borderradius) 0}.root.svelte-d6wwkb:first-child{border-radius:var(--borderradius) 0 0 var(--borderradius)}.root.svelte-d6wwkb:not(:first-child):not(:last-child){border-radius:0}
.info-text.svelte-um9cf7{font-size:0.8em;color:var(--slate)}
.nav-item.svelte-1y614ns{padding:7px;font-size:12pt;font-weight:bold;cursor:pointer;flex:0 0 auto}.nav-item.svelte-1y614ns:hover{background-color:var(--primary10)}.active.svelte-1y614ns{background-color:var(--primary10)}
.root.svelte-1tilbnf{padding:5px;top:0;width:100%}
.component.svelte-13tuzj8{padding:5px;border-style:solid;border-width:0 0 1px 0;border-color:var(--lightslate);cursor:pointer}.component.svelte-13tuzj8:hover{background-color:var(--primary10)}.component.svelte-13tuzj8>.title.svelte-13tuzj8{font-size:13pt;color:var(--secondary100)}.component.svelte-13tuzj8>.description.svelte-13tuzj8{font-size:10pt;color:var(--primary75);font-style:italic}
.edit-button.svelte-9z4fqi{cursor:pointer;color:var(--white)}tr.svelte-9z4fqi:hover .edit-button.svelte-9z4fqi{color:var(--secondary75)}
.root.svelte-1sxai5n{font-size:10pt}.padding.svelte-1sxai5n{padding:0 10px}.inherited-title.svelte-1sxai5n{margin-top:40px;display:grid;grid-template-columns:[name] 1fr [actions] auto;border-style:solid;border-width:0px 0px 1px 0px;border-color:var(--lightslate);font-style:italic}.inherited-title.svelte-1sxai5n>div.svelte-1sxai5n:nth-child(1){grid-column-start:name;color:var(--slate)}.inherited-title.svelte-1sxai5n>div.svelte-1sxai5n:nth-child(2){grid-column-start:actions;color:var(--secondary100)}
.title.svelte-1pp53c5{padding:3px;background-color:white;color:var(--secondary100);border-style:solid;border-width:1px 0 0 0;border-color:var(--lightslate)}.title.svelte-1pp53c5>span.svelte-1pp53c5{margin-left:10px}
.root.svelte-1sxai5n{font-size:10pt}.padding.svelte-1sxai5n{padding:0 10px}.inherited-title.svelte-1sxai5n{margin-top:40px;display:grid;grid-template-columns:[name] 1fr [actions] auto;border-style:solid;border-width:0px 0px 1px 0px;border-color:var(--lightslate);font-style:italic}.inherited-title.svelte-1sxai5n>div.svelte-1sxai5n:nth-child(1){grid-column-start:name;color:var(--slate)}.inherited-title.svelte-1sxai5n>div.svelte-1sxai5n:nth-child(2){grid-column-start:actions;color:var(--secondary100)}
.component.svelte-13tuzj8{padding:5px;border-style:solid;border-width:0 0 1px 0;border-color:var(--lightslate);cursor:pointer}.component.svelte-13tuzj8:hover{background-color:var(--primary10)}.component.svelte-13tuzj8>.title.svelte-13tuzj8{font-size:13pt;color:var(--secondary100)}.component.svelte-13tuzj8>.description.svelte-13tuzj8{font-size:10pt;color:var(--primary75);font-style:italic}
.root.svelte-1bn4xbe{display:block;font-size:12pt;width:100%;cursor:pointer}.title.svelte-1bn4xbe{padding-top:5px;padding-right:5px;padding-bottom:5px;color:var(--secondary100)}.title.svelte-1bn4xbe:hover{background-color:var(--secondary10)}.active.svelte-1bn4xbe{background-color:var(--primary10)}
.nav-item.svelte-1y614ns{padding:7px;font-size:12pt;font-weight:bold;cursor:pointer;flex:0 0 auto}.nav-item.svelte-1y614ns:hover{background-color:var(--primary10)}.active.svelte-1y614ns{background-color:var(--primary10)}
.dropdown-background.svelte-179p8ge{position:fixed;top:0;left:0;width:100vw;height:100vh}.root.svelte-179p8ge{cursor:pointer;z-index:1}.dropdown-content.svelte-179p8ge{position:absolute;background-color:var(--white);min-width:160px;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);z-index:1;font-weight:normal;border-style:solid;border-width:1px;border-color:var(--secondary10)}.dropdown-content.svelte-179p8ge:not(:focus){display:none}.action-row.svelte-179p8ge{padding:7px 10px;cursor:pointer}.action-row.svelte-179p8ge:hover{background-color:var(--primary100);color:var(--white)}
.root.svelte-1tilbnf{padding:5px;top:0;width:100%}
.root.svelte-1q40nqm{display:block;font-size:13pt;width:100%;cursor:pointer}.title.svelte-1q40nqm{font:var(--bodytext);padding-top:10px;padding-right:5px;padding-bottom:10px;color:var(--secondary100)}.title.svelte-1q40nqm:hover{background-color:var(--secondary10)}
.root.svelte-pq2tmv{height:100%;padding:15px}.allowed-records.svelte-pq2tmv{margin:20px 0px}.allowed-records.svelte-pq2tmv>span.svelte-pq2tmv{margin-right:30px}
.root.svelte-kswv5p{height:100%;padding:15px}.fields-table.svelte-kswv5p{margin:10px;border-collapse:collapse}.add-field-button.svelte-kswv5p{margin-left:15px;cursor:pointer}.edit-button.svelte-kswv5p{cursor:pointer;color:var(--white)}.edit-button.svelte-kswv5p:hover{color:var(--secondary75)}th.svelte-kswv5p{text-align:left}td.svelte-kswv5p{padding:5px 30px 5px 0px;margin:0}thead.svelte-kswv5p>tr.svelte-kswv5p{border-width:0px 0px 1px 0px;border-style:solid;border-color:var(--secondary75);margin-bottom:20px}tbody.svelte-kswv5p>tr.svelte-kswv5p{border-width:0px 0px 1px 0px;border-style:solid;border-color:var(--primary10)}tbody.svelte-kswv5p>tr.svelte-kswv5p:hover{background-color:var(--primary10)}tbody.svelte-kswv5p>tr:hover .edit-button.svelte-kswv5p{color:var(--secondary75)}.index-container.svelte-kswv5p{border-style:solid;border-width:0 0 1px 0;border-color:var(--secondary25);padding:10px;margin-bottom:5px}.index-label.svelte-kswv5p{color:var(--slate)}.index-name.svelte-kswv5p{font-weight:bold;color:var(--primary100)}.index-container.svelte-kswv5p code.svelte-kswv5p{margin:0;display:inline;background-color:var(--primary10);color:var(--secondary100);padding:3px}.index-field-row.svelte-kswv5p{margin-top:7px}
.edit-button.svelte-neetem{cursor:pointer;color:var(--white)}tr.svelte-neetem:hover .edit-button.svelte-neetem{color:var(--secondary75)}
textarea.svelte-1ooq0hh{padding:3px;background:var(--darkslate);color:var(--white);font-family:'Courier New', Courier, monospace;width:95%;height:100px}
input.svelte-66516k{margin-right:7px}
.error-container.svelte-jwy920{padding:10px;border-style:solid;border-color:var(--deletion100);border-radius:var(--borderradiusall);background:var(--deletion75)}.error-row.svelte-jwy920{padding:5px 0px}
.root.svelte-woqcuf{display:grid;grid-template-columns:[name] 1fr [actions] auto}.root.svelte-woqcuf>div.svelte-woqcuf:nth-child(1){grid-column-start:name;color:var(--secondary50)}.root.svelte-woqcuf>div.svelte-woqcuf:nth-child(2){grid-column-start:actions}.selectedname.svelte-woqcuf{font-weight:bold;color:var(--secondary)}
.edit-button.svelte-9z4fqi{cursor:pointer;color:var(--white)}tr.svelte-9z4fqi:hover .edit-button.svelte-9z4fqi{color:var(--secondary75)}
.root.svelte-w5on8s{padding:3px 5px 7px 10px;border-style:dotted;border-width:0 0 1px 0;border-color:var(--primary25)}
input.svelte-66516k{margin-right:7px}
.root.svelte-woqcuf{display:grid;grid-template-columns:[name] 1fr [actions] auto}.root.svelte-woqcuf>div.svelte-woqcuf:nth-child(1){grid-column-start:name;color:var(--secondary50)}.root.svelte-woqcuf>div.svelte-woqcuf:nth-child(2){grid-column-start:actions}.selectedname.svelte-woqcuf{font-weight:bold;color:var(--secondary)}
.error-container.svelte-jwy920{padding:10px;border-style:solid;border-color:var(--deletion100);border-radius:var(--borderradiusall);background:var(--deletion75)}.error-row.svelte-jwy920{padding:5px 0px}
textarea.svelte-1ooq0hh{padding:3px;background:var(--darkslate);color:var(--white);font-family:'Courier New', Courier, monospace;width:95%;height:100px}
.root.svelte-bv289q{padding:10px}.option-container.svelte-bv289q{border-style:dotted;border-width:1px;border-color:var(--primary75);padding:3px;margin-right:5px}
.addelement-container.svelte-jliz3p{cursor:pointer;padding:3px 0px;text-align:center}.addelement-container.svelte-jliz3p:hover{background-color:var(--primary25)}.item-container.svelte-jliz3p{padding-left:3px;background:var(--secondary10)}
textarea.svelte-1wfv4cc{width:300px;height:200px}
.root.svelte-1ersoxu{padding:15px}.help-text.svelte-1ersoxu{color:var(--slate);font-size:10pt}
/*# sourceMappingURL=bundle.css.map */

File diff suppressed because one or more lines are too long

View File

@ -31455,7 +31455,7 @@
/******/ });
});
//# sourceMappingURL=feather.js.map
});
var feather$1 = unwrapExports(feather);

View File

@ -10,6 +10,7 @@ module.exports = () => ({
latestPackagesFolder: "appPackages",
extraMasterPlugins: {},
dev:true,
customizeMaster: appDefinition => appDefinition
customizeMaster: appDefinition => appDefinition,
useAppRootPath: true
})

View File

@ -27,6 +27,13 @@ module.exports = () => ({
customizeMaster: appDefinition => appDefinition,
// false for production - serves builder if true
dev:false
dev:false,
// flags whethers your apps should make server requests to '/<your app name>/<the route>'
// should only be set to true if you are routed via a domain, and are rewriting
// the "your.domain.com" to "/<your app name>"
useAppRootPath: false
})

View File

@ -12,7 +12,7 @@ const {
saveDerivedComponent,
renameDerivedComponent,
deleteDerivedComponent,
getComponentLibraryPath
componentLibraryInfo
} = require("../utilities/builder");
const builderPath = resolve(__dirname, "../builder");
@ -161,12 +161,12 @@ module.exports = (config, app) => {
}
}
})
.get("/_builder/api/:appname/componentlibrary", async (ctx) => {
const {appPath, libPath} = await getComponentLibraryPath(
.get("/:appname/componentlibrary", async (ctx) => {
const info = await componentLibraryInfo(
config,
ctx.params.appname,
ctx.query.lib);
await send(ctx, libPath, { root: appPath });
await send(ctx, info.libDir, { root: info.components._lib });
})
.post("/_builder/api/:appname/derivedcomponent", async (ctx) => {
await saveDerivedComponent(

View File

@ -22,6 +22,7 @@
"koa-session": "^5.12.0",
"koa-static": "^5.0.0",
"lodash": "^4.17.13",
"squirrelly": "^7.5.0",
"tar-fs": "^2.0.0",
"uuid": "^3.3.2",
"yargs": "^13.2.4"

View File

@ -0,0 +1,111 @@
const {
appPackageFolder
} = require("../createAppPackage");
const { componentLibraryInfo } = require("./componentLibraryInfo");
const {
stat, ensureDir, pathExists,
constants, copyFile, writeFile,
readFile
} = require("fs-extra");
const { join } = require("path");
const sqrl = require('squirrelly');
module.exports = async (config, appname, pageName, pages, appdefinition) => {
const appPath = appPackageFolder(config, appname);
await buildClientAppDefinition(
config, appname,
appdefinition, componentLibraries,
appPath, appRootPath)
await buildIndexHtml(
config, appname, appPath,
pageName, pages);
await copyClientLib(appPath);
}
const publicPath = async appPath => join(appPath, "public");
const rootPath = (config, appname) => config.useAppRootPath ? `/${appname}` : "";
const copyClientLib = async appPath => {
var sourcepath = require.resolve("budibase-client",{
basedir: appPath
});
var destPath = join(publicPath(appPath), "budibase-client.js");
await copyFile(sourcepath, destPath, constants.COPYFILE_FICLONE);
}
const buildIndexHtml = async (config, appname, appPath, pageName, pages) => {
const appPublicPath = publicPath(appPath);
const appRootPath = rootPath(config, appname);
const stylesheetUrl = s =>
s.indexOf('http://') === 0 || s.indexOf('https://') === 0
? s
: `/${rootPath(config, appname)}/${s}`;
const templateObj = {
title = pages[pageName].index.title || "Budibase App",
favicon = `${appRootPath}/${pages[pageName].index.favicon || "/assets/favicon.png"}`,
stylesheets = pages.stylesheets.map(stylesheetUrl),
appRootPath
}
const indexHtmlTemplate = await readFile(
resolve(__dirname, "index.template.html"));
const indexHtmlPath = join(appPublicPath, "index.html");
await writeFile(
indexHtmlPath,
sqrl.Render(indexHtmlTemplate, templateObj),
{flag:"w+"});
}
const buildClientAppDefinition = async (config, appname, appdefinition, pages, appPath) => {
const componentLibraries = [];
const appPublicPath = publicPath(appPath);
const appRootPath = rootPath(config, appname);
for(let lib of pages.componentLibraries) {
const info = await componentLibraryInfo(appPath, lib);
const source = join(info.libDir, info.components._lib);
const destDir = join(appPublicPath, "lib", info.libDir.replace(appPath, ""));
await ensureDir(destDir);
const destPath = join(destDir, info.components._lib);
componentLibraries.push(destPath);
let shouldCopy = !(await pathExists(destPath));
if(!shouldCopy) {
const destStat = await stat(destPath);
const sourceStat = await stat(source);
shouldCopy = destStat.ctimeMs !== sourceStat.ctimeMs;
}
if(shouldCopy) {
await copyFile(source, destPath, constants.COPYFILE_FICLONE);
}
}
const filename = join(appPublicPath, "clientAppDefinition.js");
await writeFile(filename,
`window['##BUDIBASE_APPDEFINITION##'] = {
hierarchy: ${JSON.stringify(appdefinition.hierarchy)},
componentLibraries: ${JSON.stringify(componentLibraries)},
appRootPath: '${appRootPath}'
}`);
}

View File

@ -0,0 +1,37 @@
const {
readJSON, exists
} = require("fs-extra");
const { resolve } = require("path");
const getLibDir = (appPath, libname) => require.resolve(libname, {
basedir: appPath
});
const getComponentsFilepath = libPath =>
resolve(libPath, "components.json");
module.exports.componentsFilepath = (appPath, libname) =>
getComponentsFilepath(getLibDir(appPath, libname));
module.exports.componentLibraryInfo = async (appPath, libname) => {
const libDir = getLibDir(appPath, libname);
const componentsPath = getComponentsFilepath(libDir);
if(!await exists(componentsPath)) {
const e = new Error(`could not find components definition file at ${componentsPath}`);
e.statusCode = 404;
throw e;
}
try {
return ({
components: await readJSON(componentsPath),
libDir,
componentsPath
});
} catch(e) {
const err = `could not parse JSON - ${componentsPath} : ${e.message}`;
throw new Error(err);
}
}

View File

@ -1,12 +1,11 @@
const {
appPackageFolder,
appsFolder
} = require("./createAppPackage");
} = require("../createAppPackage");
const {
readJSON,
writeJSON,
readdir,
exists,
stat,
ensureDir,
rename,
@ -14,7 +13,6 @@ const {
rmdir
} = require("fs-extra");
const {
resolve,
join,
dirname
} = require("path");
@ -22,12 +20,13 @@ const { $ } = require("budibase-core").common;
const {
keys,
reduce,
some,
keyBy,
filter
} = require("lodash/fp");
const {merge} = require("lodash");
const { componentLibraryInfo } = require("./componentLibraryInfo");
module.exports.getPackageForBuilder = async (config, appname) => {
const appPath = appPackageFolder(config, appname);
@ -108,42 +107,14 @@ module.exports.deleteDerivedComponent = async (config, appname, name) => {
}
}
module.exports.getComponentLibraryPath = async (config, appname, libname) => {
const appPath = appPackageFolder(config, appname);
const components = await getComponentsFile(appPath, libname);
return ({
appPath,
libPath:join(libname, components._lib.path)
});
}
module.exports.componentLibraryInfo = componentLibraryInfo;
const getComponentsFile = async (appPath, libname) => {
const isRelative = some(c => c === libname.substring(0,1))
("./~\\".split(""));
const componentsPath = isRelative
? resolve(appPath, libname, "components.json")
: resolve(libname, "components.json");
if(!await exists(componentsPath)) {
const e = new Error(`could not find components definition file at ${componentsPath}`);
e.statusCode = 404;
throw e;
}
try {
return await readJSON(componentsPath);
} catch(e) {
const err = `could not parse JSON - ${componentsPath} : ${e.message}`;
throw new Error(err);
}
}
const getRootComponents = async (appPath, pages ,lib) => {
const componentsInLibrary = async (libname) => {
const components = await getComponentsFile(appPath, libname);
const { components } = await componentLibraryInfo(appPath, libname);
return $(components, [
keys,

View File

@ -0,0 +1,22 @@
<!doctype html>
<html>
<head>
<meta charset='utf8'>
<meta name='viewport' content='width=device-width'>
<title>{{ title }}</title>
<link rel='icon' type='image/png' href='{{ favicon }}'>
{{ each(stylesheets) }}
<link rel='stylesheet' href='{{ @this }}'>
{{ /each }}
<script src='{{ appRootPath }}/budibase-client.js'></script>
</head>
<body id="app">
<script src='{{ appRootPath }}/clientAppDefinition.js'></script>
</body>
</html>

View File

@ -3572,6 +3572,11 @@ split-string@^3.0.1, split-string@^3.0.2:
dependencies:
extend-shallow "^3.0.0"
squirrelly@^7.5.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/squirrelly/-/squirrelly-7.5.0.tgz#76b42e2771639433bff3e60fd66aa6b04f25e8d0"
integrity sha512-7GtawPwwkVPnG9hqfQRjrziHxWLHAoJ3tlYvhmSayDNoovIufIQXRF0G/QA8sUTCSPzzSBkPSN0CuTlcvE7Dow==
sshpk@^1.7.0:
version "1.16.1"
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877"