How to use the @jscad/io.svgDeSerializer function in @jscad/io

To help you get started, we’ve selected a few @jscad/io 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 / OpenJSCAD.org / packages / core / code-loading / transformSources.js View on Github external
const transformSvgToJscad = (options, entry) => {
  // console.log('***** transformSvgToJscad',options,entry)
  const deserialize = require('@jscad/io').svgDeSerializer.deserialize
  const source = deserialize(entry.source, entry.name, options)
  return createJscadEntry(entry, source)
}
github jscad / OpenJSCAD.org / packages / web / src / io / conversionWorker.js View on Github external
}
              const openscadOpenJscadParser = require('@jscad/openscad-openjscad-translator')
              r.converted = openscadOpenJscadParser.parse(r.source)
              break
            case 'stl':
              const deserializeStl = require('@jscad/io').stlDeSerializer.deserialize
              r.source = r.converted = deserializeStl(data.source, data.filename, options)
              break
            case 'js':
              r.source = r.converted = data.source
              break
            case 'jscad':
              r.source = r.converted = data.source
              break
            case 'svg':
              const deserializeSvg = require('@jscad/io').svgDeSerializer.deserialize
              r.source = r.converted = deserializeSvg(data.source, data.filename, options)
              break
            case 'json':
              const deserializeJson = require('@jscad/io').jsonDeSerializer.deserialize
              r.source = r.converted = deserializeJson(data.source, data.filename, options)
              break
            default:
              r.source = r.converted = '// Invalid file type in conversion (' + e + ')'
              break
          }
        }
      }
    }
    postMessage(r)
  }
}
github jscad / OpenJSCAD.org / packages / core / io / registerExtensions.js View on Github external
const registerSvgExtension = (fs, _require) => {
  const deserializer = require('@jscad/io').svgDeSerializer
  _require.extensions['.svg'] = (module, filename) => {
    const content = fs.readFileSync(filename, 'utf8')
    const parsed = deserializer.deserialize(content, filename, { output: 'geometry' })
    module.exports = parsed
  }
}
const unRegisterSvgExtension = (fs, _require) => {
github jscad / OpenJSCAD.org / packages / cli / generateOutputData.js View on Github external
      svg: data => require('@jscad/io').svgDeSerializer.deserialize(data.source, data.inputFile, options),
      json: data => require('@jscad/io').jsonDeSerializer.deserialize(data.source, data.inputFile, options),