Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const setDesignPath = (state, paths) => {
// console.log('setDesignPath')
const mainPath = getDesignEntryPoint(paths)
const filePath = paths[0]
const designName = getDesignName(paths)
const designPath = path.dirname(filePath)
const design = Object.assign({}, state.design, {
name: designName,
path: designPath,
mainPath
})
// we want the viewer to focus on new entities for our 'session' (until design change)
const viewer = Object.assign({}, state.viewer, {behaviours: {resetViewOn: ['new-entities']}})
return Object.assign({}, state, {busy: true, viewer, design})
}
setDesignContent: (state, payload) => {
console.log('design: set content', state, state.design, payload)
// all our available data (specific to web)
const { filesAndFolders } = payload
const makeFakeFs = require('@jscad/core/code-loading/makeFakeFs')
const fakeFs = makeFakeFs(filesAndFolders)
const rootPath = filesAndFolders[0].fullPath
const mainPath = getDesignEntryPoint(fakeFs, rootPath)
const designName = getDesignName(fakeFs, rootPath)
const designPath = path.dirname(rootPath)
console.log('BLAA', rootPath, designName, designPath)
let design = state.design
// to track computation time
const debug = Object.assign({ }, state.design.debug, { startTime: new Date() })
design = Object.assign({}, design, {
name: designName,
path: designPath,
mainPath,
filesAndFolders,
debug
})
const viewer = Object.assign({}, state.viewer, { behaviours: { resetViewOn: [''], zoomToFitOn: ['new-entities'] } })