Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const transformAmfToJscad = (options, entry) => {
// console.log('***** transformAmfToJscad',options,entry)
const deserialize = require('@jscad/io').amfDeSerializer.deserialize
const source = deserialize(entry.source, entry.name, options)
return createJscadEntry(entry, source)
}
var data = e.data
if ('cache' in data) {
r.cache = data.cache // forward cache (gMemFS) controls
}
if ('baseurl' in data) {
r.baseurl = data.baseurl
}
if ('filename' in data) {
r.filename = data.filename
if ('source' in data) {
var e = data.filename.toLowerCase().match(/\.(\w+)$/i)
e = RegExp.$1
const options = {version: data.version}
switch (e) {
case 'amf':
const deserializeAmf = require('@jscad/io').amfDeSerializer.deserialize
r.source = r.converted = deserializeAmf(data.source, data.filename, options)
break
case 'gcode':
const deserializeGcode = require('@jscad/io').gcodeDeSerializer.deserialize
r.source = r.converted = deserializeGcode(data.source, data.filename, options)
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 registerAmfExtension = (fs, _require) => {
const deserializer = require('@jscad/io').amfDeSerializer
_require.extensions['.amf'] = (module, filename) => {
const content = fs.readFileSync(filename, 'utf8')
const parsed = deserializer.deserialize(content, filename, { output: 'geometry' })
module.exports = parsed
}
}
const unRegisterAmfExtension = (fs, _require) => {
amf: data => require('@jscad/io').amfDeSerializer.deserialize(data.source, data.inputFile, options),
obj: data => require('@jscad/io').objDeSerializer.deserialize(data.source, data.inputFile, options),