removing dead code
This commit is contained in:
parent
752d4c1ae0
commit
e59f759ad6
|
@ -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}
|
||||
},
|
||||
`
|
|
@ -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),
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
module.exports = props => {
|
||||
if (props._codeMeta) {
|
||||
delete props._codeMeta
|
||||
}
|
||||
|
||||
for (let child of props._children || []) {
|
||||
module.exports(child)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue