Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const transformStlToJscad = (options, entry) => {
// console.log('***** transformStlToJscad',options,entry)
const deserialize = require('@jscad/io').stlDeSerializer.deserialize
const source = deserialize(entry.source, entry.name, options)
return createJscadEntry(entry, source)
}
break
case 'obj':
const deserializeObj = require('@jscad/io').objDeSerializer.deserialize
r.source = r.converted = deserializeObj(data.source, data.filename, options)
break
case 'scad':
// importScripts(r.baseurl + 'js/lib/csg.js', r.baseurl + 'js/openjscad.js', r.baseurl + 'js/openscad.js', r.baseurl + 'js/lib/underscore.js', r.baseurl + 'js/lib/openscad-openjscad-translator.js')
r.source = data.source
if (!r.source.match(/^\/\/!OpenSCAD/i)) {
r.source = '//!OpenSCAD\n' + data.source
}
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
const registerStlExtension = (fs, _require) => {
const deserializer = require('@jscad/io').stlDeSerializer
_require.extensions['.stl'] = (module, filename) => {
const content = fs.readFileSync(filename, 'utf8')
const parsed = deserializer.deserialize(content, filename, { output: 'geometry' })
module.exports = parsed
}
}
const unRegisterStlExtension = (fs, _require) => {
stl: data => require('@jscad/io').stlDeSerializer.deserialize(data.source, data.inputFile, options),
svg: data => require('@jscad/io').svgDeSerializer.deserialize(data.source, data.inputFile, options),