How to use the @jscad/core/code-loading/requireDesignUtilsFs.getDesignName function in @jscad/core

To help you get started, we’ve selected a few @jscad/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jscad / jscad-desktop / src / ui / design / reducers.js View on Github external
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})
}
github jscad / OpenJSCAD.org / packages / web / src / ui / flow / design.js View on Github external
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'] } })