From e59f759ad6e8d7cebbff8ea4b3e65646c6388a66 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 29 Oct 2020 11:46:26 +0000 Subject: [PATCH] removing dead code --- .../src/builderStore/buildCodeForScreens.js | 33 -------------- .../src/builderStore/insertCodeMetadata.js | 17 ------- .../builder/src/builderStore/store/index.js | 45 ------------------- .../server/src/utilities/builder/buildPage.js | 3 -- .../src/utilities/builder/deleteCodeMeta.js | 9 ---- 5 files changed, 107 deletions(-) delete mode 100644 packages/builder/src/builderStore/buildCodeForScreens.js delete mode 100644 packages/builder/src/builderStore/insertCodeMetadata.js delete mode 100644 packages/server/src/utilities/builder/deleteCodeMeta.js diff --git a/packages/builder/src/builderStore/buildCodeForScreens.js b/packages/builder/src/builderStore/buildCodeForScreens.js deleted file mode 100644 index 69ef0d6e0b..0000000000 --- a/packages/builder/src/builderStore/buildCodeForScreens.js +++ /dev/null @@ -1,33 +0,0 @@ -const buildCodeForSingleScreen = screen => { - let code = "" - const walkProps = props => { - if (props._code && props._code.trim().length > 0) { - code += buildComponentCode(props) - } - - if (!props._children) return - - for (let child of props._children) { - walkProps(child) - } - } - - walkProps(screen.props) - - return code -} - -export const buildCodeForScreens = screens => { - let allfunctions = "" - for (let screen of screens) { - allfunctions += buildCodeForSingleScreen(screen) - } - - return `({ ${allfunctions} });` -} - -const buildComponentCode = componentProps => - `"${componentProps._id}" : (render, context, state, route) => { -${componentProps._code} -}, -` diff --git a/packages/builder/src/builderStore/insertCodeMetadata.js b/packages/builder/src/builderStore/insertCodeMetadata.js deleted file mode 100644 index 9093c4003d..0000000000 --- a/packages/builder/src/builderStore/insertCodeMetadata.js +++ /dev/null @@ -1,17 +0,0 @@ -export const insertCodeMetadata = props => { - if (props._code && props._code.length > 0) { - props._codeMeta = codeMetaData(props._code) - } - - if (!props._children || props._children.length === 0) return - - for (let child of props._children) { - insertCodeMetadata(child) - } -} - -const codeMetaData = code => { - return { - dependsOnStore: RegExp(/(state.)/g).test(code), - } -} diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 4e7b089f5e..ead1721896 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -11,9 +11,7 @@ import { getBuiltin, } from "components/userInterface/pagesParsing/createProps" import { fetchComponentLibDefinitions } from "../loadComponentLibraries" -import { buildCodeForScreens } from "../buildCodeForScreens" import { generate_screen_css } from "../generate_css" -import { insertCodeMetadata } from "../insertCodeMetadata" import analytics from "analytics" import { uuid } from "../uuid" import { @@ -60,15 +58,12 @@ export const getStore = () => { store.setCurrentPage = setCurrentPage(store) store.createLink = createLink(store) store.createScreen = createScreen(store) - store.addStylesheet = addStylesheet(store) - store.removeStylesheet = removeStylesheet(store) store.savePage = savePage(store) store.addChildComponent = addChildComponent(store) store.selectComponent = selectComponent(store) store.setComponentProp = setComponentProp(store) store.setPageOrScreenProp = setPageOrScreenProp(store) store.setComponentStyle = setComponentStyle(store) - store.setComponentCode = setComponentCode(store) store.setScreenType = setScreenType(store) store.getPathToComponent = getPathToComponent(store) store.addTemplatedComponent = addTemplatedComponent(store) @@ -258,7 +253,6 @@ const setCurrentScreen = store => screenName => { ) screen.props = safeProps s.currentComponentInfo = safeProps - setCurrentPageFunctions(s) return s }) } @@ -295,24 +289,6 @@ const savePage = store => async page => { }) } -const addStylesheet = store => stylesheet => { - store.update(s => { - s.pages.stylesheets.push(stylesheet) - _savePage(s) - return s - }) -} - -const removeStylesheet = store => stylesheet => { - store.update(state => { - state.pages.stylesheets = state.pages.stylesheets.filter( - s => s !== stylesheet - ) - _savePage(state) - return state - }) -} - const setCurrentPage = store => pageName => { store.update(state => { const current_screens = state.pages[pageName]._screens @@ -338,7 +314,6 @@ const setCurrentPage = store => pageName => { screen._css = generate_screen_css([screen.props]) } - setCurrentPageFunctions(state) return state }) } @@ -424,7 +399,6 @@ const addTemplatedComponent = store => props => { ) regenerateCssForCurrentScreen(state) - setCurrentPageFunctions(state) _saveCurrentPreviewItem(state) return state @@ -475,25 +449,6 @@ const setComponentStyle = store => (type, name, value) => { }) } -const setComponentCode = store => code => { - store.update(state => { - state.currentComponentInfo._code = code - - setCurrentPageFunctions(state) - // save without messing with the store - _saveScreenApi(state.currentPreviewItem, state) - - return state - }) -} - -const setCurrentPageFunctions = s => { - s.currentPageFunctions = buildPageCode(s.screens, s.pages[s.currentPageName]) - insertCodeMetadata(s.currentPreviewItem.props) -} - -const buildPageCode = (screens, page) => buildCodeForScreens([page, ...screens]) - const setScreenType = store => type => { store.update(state => { state.currentFrontEndType = type diff --git a/packages/server/src/utilities/builder/buildPage.js b/packages/server/src/utilities/builder/buildPage.js index 7db1299fa2..bf10828115 100644 --- a/packages/server/src/utilities/builder/buildPage.js +++ b/packages/server/src/utilities/builder/buildPage.js @@ -10,7 +10,6 @@ const { join, resolve } = require("../centralPath") const sqrl = require("squirrelly") const { convertCssToFiles } = require("./convertCssToFiles") const publicPath = require("./publicPath") -const deleteCodeMeta = require("./deleteCodeMeta") module.exports = async (config, appId, pageName, pkg) => { const appPath = appPackageFolder(config, appId) @@ -122,8 +121,6 @@ const savePageJson = async (appPath, pageName, pkg) => { delete pkg.page._screens } - deleteCodeMeta(pkg.page.props) - await writeJSON(pageFile, pkg.page, { spaces: 2, }) diff --git a/packages/server/src/utilities/builder/deleteCodeMeta.js b/packages/server/src/utilities/builder/deleteCodeMeta.js deleted file mode 100644 index 07a0bc0349..0000000000 --- a/packages/server/src/utilities/builder/deleteCodeMeta.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = props => { - if (props._codeMeta) { - delete props._codeMeta - } - - for (let child of props._children || []) { - module.exports(child) - } -}