@jscad/core 2.5.3 → 2.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.5.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/core@2.5.3...@jscad/core@2.5.4) (2022-02-19)
7
+
8
+ **Note:** Version bump only for package @jscad/core
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.5.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/core@2.5.2...@jscad/core@2.5.3) (2022-01-23)
7
15
 
8
16
 
@@ -26,7 +26,7 @@ var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defau
26
26
  },{}],8:[function(require,module,exports){
27
27
  module.exports={
28
28
  "name": "@jscad/core",
29
- "version": "2.5.3",
29
+ "version": "2.5.4",
30
30
  "description": "Core functionality for JSCAD Applications",
31
31
  "repository": "https://github.com/jscad/OpenJSCAD.org",
32
32
  "main": "src/index.js",
@@ -61,9 +61,9 @@ module.exports={
61
61
  "license": "MIT",
62
62
  "dependencies": {
63
63
  "@jscad/array-utils": "2.1.1",
64
- "@jscad/io": "2.2.3",
65
- "@jscad/io-utils": "2.0.12",
66
- "@jscad/modeling": "2.7.1",
64
+ "@jscad/io": "2.2.4",
65
+ "@jscad/io-utils": "2.0.13",
66
+ "@jscad/modeling": "2.7.2",
67
67
  "json5": "2.2.0",
68
68
  "strip-bom": "4.0.0"
69
69
  },
@@ -87,10 +87,10 @@ module.exports={rebuildGeometry:require("./rebuildGeometry"),rebuildGeometryCli:
87
87
  const isGeom2=require("@jscad/modeling").geometries.geom2.isA,isGeom3=require("@jscad/modeling").geometries.geom3.isA,isPath2=require("@jscad/modeling").geometries.path2.isA,{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),serializeSolids=require("./serializeSolids"),isResultGeometry=e=>!!(Array.isArray(e)&&e.length>0)&&e.reduce((e,i)=>e||isGeom3(i)||isGeom2(i)||isPath2(i),!1),instanciateDesign=(e,i,r)=>{const{serialize:s}=r;let t;const o=flatten(toArray(e.main(i)));if(isResultGeometry(o))return{solids:t=s?serializeSolids(o):o};throw new Error("bad output from script: expected geom3/geom2/path2 objects")};module.exports=instanciateDesign;
88
88
 
89
89
  },{"./serializeSolids":14,"@jscad/array-utils":889,"@jscad/modeling":585}],11:[function(require,module,exports){
90
- const loadDesign=require("../code-loading/loadDesign"),instanciateDesign=require("./instanciateDesign"),applyParameterDefinitions=require("../parameters/applyParameterDefinitions"),rebuildSolids=(e,a)=>{console.log("rebuildSolids",e);let{mainPath:i,apiMainPath:o,serialize:s,lookup:l,lookupCounts:n,parameterValues:t}=Object.assign({},{mainPath:"",apiMainPath:"@jscad/modeling",serialize:!1,lookup:null,lookupCounts:null,parameterValues:{}},e);const r=e.filesAndFolders,u=loadDesign(i,o,r,t);a(null,{type:"params",parameterDefaults:u.parameterValues,parameterDefinitions:u.parameterDefinitions}),t=applyParameterDefinitions(t,u.parameterDefinitions),t=Object.assign({},u.parameterValues,t);const p={lookup:l,lookupCounts:n,serialize:s},d=instanciateDesign(u.rootModule,t,p);a(null,{type:"solids",solids:d.solids,lookup:d.lookup,lookupCounts:d.lookupCounts})};module.exports=rebuildSolids;
90
+ const loadDesign=require("../code-loading/loadDesign"),instanciateDesign=require("./instanciateDesign"),applyParameterDefinitions=require("../parameters/applyParameterDefinitions"),rebuildSolids=(e,a)=>{let{mainPath:i,apiMainPath:o,serialize:s,lookup:l,lookupCounts:n,parameterValues:t}=Object.assign({},{mainPath:"",apiMainPath:"@jscad/modeling",serialize:!1,lookup:null,lookupCounts:null,parameterValues:{}},e);const r=e.filesAndFolders,p=loadDesign(i,o,r,t);a(null,{type:"params",parameterDefaults:p.parameterValues,parameterDefinitions:p.parameterDefinitions}),t=applyParameterDefinitions(t,p.parameterDefinitions),t=Object.assign({},p.parameterValues,t);const u={lookup:l,lookupCounts:n,serialize:s},d=instanciateDesign(p.rootModule,t,u);a(null,{type:"solids",solids:d.solids,lookup:d.lookup,lookupCounts:d.lookupCounts})};module.exports=rebuildSolids;
91
91
 
92
92
  },{"../code-loading/loadDesign":16,"../parameters/applyParameterDefinitions":27,"./instanciateDesign":10}],12:[function(require,module,exports){
93
- const path=require("path"),{toArray:toArray}=require("@jscad/array-utils"),requireDesignFromModule=require("../code-loading/requireDesignFromModule"),getAllParameterDefintionsAndValues=require("../parameters/getParameterDefinitionsAndValues"),makeWebRequire=require("../code-loading/webRequire"),rebuildSolids=e=>{let{apiMainPath:r,serialize:a,mainPath:i,parameterValues:s,useFakeFs:t}=Object.assign({},{apiMainPath:"@jscad/modeling",serialize:!1},e),u=require;if(t){const a=path.parse(i),s=`${a.name}.js`,t=`/${a.name}.js`,n=[{ext:"js",fullPath:t,name:s,source:e.source}];u=makeWebRequire(n,{apiMainPath:r}),i=t}const n=requireDesignFromModule(i,u),l=getAllParameterDefintionsAndValues(n,s);return toArray(n.main(l.parameterValues))};module.exports=rebuildSolids;
93
+ const path=require("path"),{toArray:toArray}=require("@jscad/array-utils"),requireDesignFromModule=require("../code-loading/requireDesignFromModule"),getAllParameterDefintionsAndValues=require("../parameters/getParameterDefinitionsAndValues"),makeWebRequire=require("../code-loading/webRequire"),rebuildSolids=e=>{let{apiMainPath:r,mainPath:a,parameterValues:i,useFakeFs:t}=Object.assign({},{apiMainPath:"@jscad/modeling"},e),s=require;if(t){const i=path.parse(a),t=`${i.name}.js`,u=`/${i.name}.js`,n=[{ext:"js",fullPath:u,name:t,source:e.source}];s=makeWebRequire(n,{apiMainPath:r}),a=u}const u=requireDesignFromModule(a,s),n=getAllParameterDefintionsAndValues(u,i);return toArray(u.main(n.parameterValues))};module.exports=rebuildSolids;
94
94
 
95
95
  },{"../code-loading/requireDesignFromModule":19,"../code-loading/webRequire":23,"../parameters/getParameterDefinitionsAndValues":28,"@jscad/array-utils":889,"path":4}],13:[function(require,module,exports){
96
96
  const rebuildGeometryWorker=e=>{const o=require("./rebuildGeometry");e.onmessage=function(r){if(r.data instanceof Object){const{data:t}=r;"generate"===t.cmd&&o(t,(o,r)=>e.postMessage(r))}}};module.exports=rebuildGeometryWorker;
@@ -123,7 +123,7 @@ const{deserializers:deserializers}=require("@jscad/io"),modulifyTransform=(e,r)=
123
123
  const validateDesignModule=n=>{if(!n)throw new Error("undefined root module passed !");if("function"==typeof n&&console.warn("please use named exports for your main() function ! auto updating"),!("main"in n))throw new Error("no main() function found in the input script")};module.exports=validateDesignModule;
124
124
 
125
125
  },{}],23:[function(require,module,exports){
126
- const path=require("path"),posix=path.posix?path.posix:path,getFileExtensionFromString=require("../utils/getFileExtensionFromString"),{combineParameterDefinitions:combineParameterDefinitions,getParameterDefinitionsFromSource:getParameterDefinitionsFromSource}=require("../parameters/getParameterDefinitionsFromSource"),findMatch=(e,r)=>{for(let t=0;t<r.length;t++){const n=r[t];if(e===n.fullPath||"/"+e===n.fullPath)return n;if(n.children){const r=findMatch(e,n.children);if(void 0!==r)return r}}},registerJsExtension=(e,r)=>{const t=require("strip-bom");r.extensions[".js"]=((r,n)=>{const i=e.readFileSync(n,"utf8");r._compile(t(i),n)})},registerJsonExtension=(e,r)=>{r.extensions[".json"]=((r,t)=>{const n=e.readFileSync(t,"utf8");r.exports=JSON.parse(n)})},makeWebRequire=(e,r)=>{const t={apiMainPath:"@jscad/modeling",fakeFs:require("./makeFakeFs")(e)},{apiMainPath:n,fakeFs:i}=Object.assign({},t,r),s="@jscad/modeling"===n?require("@jscad/modeling"):require(n),o={"@jscad/io":{exports:require("@jscad/io")},"@jscad/array-utils":{exports:require("@jscad/array-utils")},"@jscad/modeling":{exports:s},fs:{exports:i}},a={},l={},u=(r,t)=>{const n=o[t];if(n)return n.exports;r&&!t.startsWith("/")||(r="/");const i=r=>{let t=getFileExtensionFromString(r);t||(t="js",r+=".js"),t="."+t;const n=findMatch(r,e);if(!n)return null;if(n.children)return null;if(a[t]){if(l[r])return l[r];const e={exports:{},_compile:(r,t)=>{new Function("require","module",r)(u.bind(null,n.fullPath),e);const i=r.includes("@jscad-params")?getParameterDefinitionsFromSource(r,t):[],s=e.exports.getParameterDefinitions;e.exports.getParameterDefinitions=(()=>combineParameterDefinitions(i,s&&s()||[]))}};return a[t](e,n.fullPath),l[r]=e.exports}return null},s=r=>{if(!findMatch(r,e))return null;"/"===r&&(r="");let t=r+"/index.js",n=i(t);return n||((n=i(t=r+"/index.json"))||null)},c=r=>{let t,n=findMatch(r,e);if(!n)return null;if(!n.children)return null;if(n=findMatch(r+"/package.json",e)){const e=JSON.parse(n.source).main;if(e){const n=posix.normalize(r+"/"+e);return(t=i(n))?t:(t=s(n))||null}}return(t=s(r))||null};if(t.startsWith("./")||t.startsWith("/")||t.startsWith("../")){t=posix.normalize(posix.dirname(r)+posix.sep+t);let e=i(t);if(e)return e;if(e=c(t))return e;throw new Error(`Cannot find relative path to module ${t}`)}const f=((e,r)=>{const t=(e=>{const r=e.split("/"),t=[];for(let e=r.length-1;e>0;e--){if("node_modules"===r[e])continue;const n=posix.sep+posix.join(...r.slice(1,e+1),"node_modules");t.push(n)}return t})(r);for(let r=0;r<t.length;r++){const n=t[r],s=posix.join(n,e);let o=i(s);if(o)return o;if(o=c(s))return o}return null})(t,posix.dirname(r));if(f)return f;throw new Error(`Cannot find module ${t}`)},c=u.bind(null,"/");return c.extensions=a,c.resolve=(()=>{}),registerJsExtension(i,c),registerJsonExtension(i,c),c};module.exports=makeWebRequire;
126
+ const path=require("path"),posix=path.posix?path.posix:path,getFileExtensionFromString=require("../utils/getFileExtensionFromString"),{combineParameterDefinitions:combineParameterDefinitions,getParameterDefinitionsFromSource:getParameterDefinitionsFromSource}=require("../parameters/getParameterDefinitionsFromSource"),findMatch=(e,r)=>{for(let t=0;t<r.length;t++){const n=r[t];if(e===n.fullPath||"/"+e===n.fullPath)return n;if(n.children){const r=findMatch(e,n.children);if(void 0!==r)return r}}},registerJsExtension=(e,r)=>{const t=require("strip-bom");r.extensions[".js"]=((r,n)=>{const i=e.readFileSync(n,"utf8");r._compile(t(i),n)})},registerJsonExtension=(e,r)=>{r.extensions[".json"]=((r,t)=>{const n=e.readFileSync(t,"utf8");r.exports=JSON.parse(n)})},makeWebRequire=(e,r)=>{const t={apiMainPath:"@jscad/modeling",fakeFs:require("./makeFakeFs")(e)},{apiMainPath:n,fakeFs:i}=Object.assign({},t,r),s="@jscad/modeling"===n?require("@jscad/modeling"):require(n),o={"@jscad/io":{exports:require("@jscad/io")},"@jscad/array-utils":{exports:require("@jscad/array-utils")},"@jscad/modeling":{exports:s},fs:{exports:i}},a={},l={},u=(r,t)=>{const n=o[t];if(n)return n.exports;r&&!t.startsWith("/")||(r="/");const i=r=>{let t=getFileExtensionFromString(r);t||(t="js",r+=".js"),t="."+t;const n=findMatch(r,e);if(!n)return null;if(n.children)return null;if(a[t]){if(l[r])return l[r];const e={exports:{},_compile:(r,t)=>{new Function("require","module",r)(u.bind(null,n.fullPath),e);const i=r.includes("@jscad-params")?getParameterDefinitionsFromSource(r,t):[],s=e.exports.getParameterDefinitions;e.exports.getParameterDefinitions=(()=>combineParameterDefinitions(i,s&&s()||[]))}};return a[t](e,n.fullPath),l[r]=e.exports,l[r]}return null},s=r=>{if(!findMatch(r,e))return null;"/"===r&&(r="");let t=r+"/index.js",n=i(t);return n||((n=i(t=r+"/index.json"))||null)},c=r=>{let t,n=findMatch(r,e);if(!n)return null;if(!n.children)return null;if(n=findMatch(r+"/package.json",e)){const e=JSON.parse(n.source).main;if(e){const n=posix.normalize(r+"/"+e);return(t=i(n))?t:(t=s(n))||null}}return(t=s(r))||null};if(t.startsWith("./")||t.startsWith("/")||t.startsWith("../")){t=posix.normalize(posix.dirname(r)+posix.sep+t);let e=i(t);if(e)return e;if(e=c(t))return e;throw new Error(`Cannot find relative path to module ${t}`)}const f=((e,r)=>{const t=(e=>{const r=e.split("/"),t=[];for(let e=r.length-1;e>0;e--){if("node_modules"===r[e])continue;const n=posix.sep+posix.join(...r.slice(1,e+1),"node_modules");t.push(n)}return t})(r);for(let r=0;r<t.length;r++){const n=t[r],s=posix.join(n,e);let o=i(s);if(o)return o;if(o=c(s))return o}return null})(t,posix.dirname(r));if(f)return f;throw new Error(`Cannot find module ${t}`)},c=u.bind(null,"/");return c.extensions=a,c.resolve=(()=>{}),registerJsExtension(i,c),registerJsonExtension(i,c),c};module.exports=makeWebRequire;
127
127
 
128
128
  },{"../parameters/getParameterDefinitionsFromSource":29,"../utils/getFileExtensionFromString":33,"./makeFakeFs":17,"@jscad/array-utils":889,"@jscad/io":70,"@jscad/modeling":585,"path":4,"strip-bom":7}],24:[function(require,module,exports){
129
129
  module.exports={evaluation:require("./code-evaluation"),io:require("./io"),loading:require("./code-loading"),parameters:require("./parameters"),utils:require("./utils"),web:require("./web")};
@@ -182,7 +182,7 @@ const{flatten:flatten}=require("@jscad/array-utils"),{formats:formats}=require("
182
182
  },{"xmlchars/xml/1.0/ed5":38,"xmlchars/xml/1.1/ed2":39,"xmlchars/xmlns/1.0/ed3":40}],42:[function(require,module,exports){
183
183
  module.exports={
184
184
  "name": "@jscad/amf-deserializer",
185
- "version": "2.2.5",
185
+ "version": "2.2.6",
186
186
  "description": "AMF Deserializer for JSCAD",
187
187
  "repository": "https://github.com/jscad/OpenJSCAD.org/",
188
188
  "main": "src/index.js",
@@ -213,7 +213,7 @@ module.exports={
213
213
  ],
214
214
  "license": "MIT",
215
215
  "dependencies": {
216
- "@jscad/modeling": "2.7.1",
216
+ "@jscad/modeling": "2.7.2",
217
217
  "saxes": "5.0.1"
218
218
  },
219
219
  "devDependencies": {
@@ -270,7 +270,7 @@ const{geometries:geometries,maths:maths,primitives:primitives}=require("@jscad/m
270
270
  },{"./helpers":55,"@jscad/modeling":585}],58:[function(require,module,exports){
271
271
  module.exports={
272
272
  "name": "@jscad/dxf-deserializer",
273
- "version": "2.3.9",
273
+ "version": "2.3.10",
274
274
  "description": "DXF Deserializer for JSCAD",
275
275
  "repository": "https://github.com/jscad/OpenJSCAD.org",
276
276
  "main": "index.js",
@@ -297,7 +297,7 @@ module.exports={
297
297
  ],
298
298
  "license": "MIT",
299
299
  "dependencies": {
300
- "@jscad/modeling": "2.7.1"
300
+ "@jscad/modeling": "2.7.2"
301
301
  },
302
302
  "devDependencies": {
303
303
  "ava": "3.15.0",
@@ -322,7 +322,7 @@ class BinaryReader{constructor(t){this._buffer=t,this._pos=0}readInt8(){return t
322
322
 
323
323
  },{}],64:[function(require,module,exports){
324
324
  (function (Buffer){(function (){
325
- class Blob{constructor(e,t){if(t=t||{},this.size=0,this.type="",this.isClosed=!1,this.encoding="utf8",this.buffer=null,this.length=32e6,!e)return;if(!Array.isArray(e))return;let s,i;t.type&&(this.type=t.type.toLowerCase()),t.endings,t.encoding&&(this.encoding=t.encoding.toLowerCase()),t.length&&(this.length=t.length),this.buffer=Buffer.allocUnsafe(this.length);for(let t=0;t<e.length;t++)switch(typeof e[t]){case"string":s=this.buffer.write(e[t],this.size,this.encoding),this.size=this.size+s;break;case"object":if(i=e[t],Buffer.isBuffer(i),i instanceof ArrayBuffer){const e=new DataView(i);for(let t=0;t<i.byteLength;t++){const i=e.getUint8(t);s=this.buffer.writeUInt8(i,this.size,!1),this.size++}}}}asBuffer(){return this.buffer.slice(0,this.size)}arrayBuffer(){return this.buffer.slice(0,this.size)}slice(e,t,s){return e=e||0,t=t||this.size,s=s||"",new Blob}stream(){return null}text(){return""}close(){this.isClosed||(this.isClosed=!0)}toString(){return""}}module.exports=Blob;
325
+ class Blob{constructor(e,t){if(t=t||{},this.size=0,this.type="",this.isClosed=!1,this.encoding="utf8",this.buffer=null,this.length=32e6,!e)return;if(!Array.isArray(e))return;let s,i;t.type&&(this.type=t.type.toLowerCase()),t.endings,t.encoding&&(this.encoding=t.encoding.toLowerCase()),t.length&&(this.length=t.length),this.buffer=Buffer.allocUnsafe(this.length);for(let t=0;t<e.length;t++)switch(typeof e[t]){case"string":s=this.buffer.write(e[t],this.size,this.encoding),this.size=this.size+s;break;case"object":if((i=e[t])instanceof ArrayBuffer){const e=new DataView(i);for(let t=0;t<i.byteLength;t++){const i=e.getUint8(t);s=this.buffer.writeUInt8(i,this.size,!1),this.size++}}}}asBuffer(){return this.buffer.slice(0,this.size)}arrayBuffer(){return this.buffer.slice(0,this.size)}slice(e,t,s){return e=e||0,t=t||this.size,s=s||"",new Blob}stream(){return null}text(){return""}close(){this.isClosed||(this.isClosed=!0)}toString(){return""}}module.exports=Blob;
326
326
 
327
327
  }).call(this)}).call(this,require("buffer").Buffer)
328
328
  },{"buffer":2}],65:[function(require,module,exports){
@@ -352,7 +352,7 @@ const{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),version=req
352
352
  },{"./package.json":73,"@jscad/array-utils":889}],73:[function(require,module,exports){
353
353
  module.exports={
354
354
  "name": "@jscad/json-deserializer",
355
- "version": "2.0.13",
355
+ "version": "2.0.14",
356
356
  "description": "JSON Deserializer for JSCAD",
357
357
  "repository": "https://github.com/jscad/OpenJSCAD.org",
358
358
  "main": "index.js",
@@ -382,7 +382,7 @@ module.exports={
382
382
  "@jscad/array-utils": "2.1.1"
383
383
  },
384
384
  "devDependencies": {
385
- "@jscad/modeling": "2.7.1",
385
+ "@jscad/modeling": "2.7.2",
386
386
  "ava": "3.15.0",
387
387
  "nyc": "15.1.0"
388
388
  }
@@ -397,7 +397,7 @@ const{colors:colors,primitives:primitives}=require("@jscad/modeling"),version=re
397
397
  },{"./package.json":76,"@jscad/modeling":585}],76:[function(require,module,exports){
398
398
  module.exports={
399
399
  "name": "@jscad/obj-deserializer",
400
- "version": "2.0.12",
400
+ "version": "2.0.13",
401
401
  "description": "OBJ Deserializer for JSCAD",
402
402
  "repository": "https://github.com/jscad/OpenJSCAD.org",
403
403
  "main": "index.js",
@@ -428,7 +428,7 @@ module.exports={
428
428
  ],
429
429
  "license": "MIT",
430
430
  "dependencies": {
431
- "@jscad/modeling": "2.7.1"
431
+ "@jscad/modeling": "2.7.2"
432
432
  },
433
433
  "devDependencies": {
434
434
  "ava": "3.15.0",
@@ -445,7 +445,7 @@ const{maths:maths,primitives:primitives}=require("@jscad/modeling"),{BinaryReade
445
445
  },{"./package.json":79,"@jscad/io-utils":66,"@jscad/modeling":585}],79:[function(require,module,exports){
446
446
  module.exports={
447
447
  "name": "@jscad/stl-deserializer",
448
- "version": "2.1.9",
448
+ "version": "2.1.10",
449
449
  "description": "STL Deserializer for JSCAD",
450
450
  "repository": "https://github.com/jscad/OpenJSCAD.org",
451
451
  "main": "index.js",
@@ -476,8 +476,8 @@ module.exports={
476
476
  ],
477
477
  "license": "MIT",
478
478
  "dependencies": {
479
- "@jscad/io-utils": "2.0.12",
480
- "@jscad/modeling": "2.7.1"
479
+ "@jscad/io-utils": "2.0.13",
480
+ "@jscad/modeling": "2.7.2"
481
481
  },
482
482
  "devDependencies": {
483
483
  "ava": "3.15.0",
@@ -509,7 +509,7 @@ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{fla
509
509
  },{"xmlchars/xml/1.0/ed5":83,"xmlchars/xml/1.1/ed2":84,"xmlchars/xmlns/1.0/ed3":85}],87:[function(require,module,exports){
510
510
  module.exports={
511
511
  "name": "@jscad/svg-deserializer",
512
- "version": "2.4.5",
512
+ "version": "2.4.6",
513
513
  "description": "SVG Deserializer for JSCAD",
514
514
  "repository": "https://github.com/jscad/OpenJSCAD.org",
515
515
  "main": "src/index.js",
@@ -541,7 +541,7 @@ module.exports={
541
541
  "license": "MIT",
542
542
  "dependencies": {
543
543
  "@jscad/array-utils": "2.1.1",
544
- "@jscad/modeling": "2.7.1",
544
+ "@jscad/modeling": "2.7.2",
545
545
  "saxes": "5.0.1"
546
546
  },
547
547
  "devDependencies": {
@@ -569,7 +569,7 @@ const{svg2cagX:svg2cagX,svg2cagY:svg2cagY,cagLengthX:cagLengthX,cagLengthY:cagLe
569
569
  const{cagColor:cagColor,cssStyle:cssStyle,css2cag:css2cag}=require("./helpers"),{pxPmm:pxPmm}=require("./constants"),svgCore=(s,e)=>{"id"in e&&(s.id=e.id),"position"in e&&(s.position=e.position)},svgPresentation=(s,e)=>{if("display"in e&&(s.visible=e.display),"color"in e&&(s.fill=cagColor(e.color),s.stroke=s.fill),"opacity"in e&&(s.opacity=e.opacity),"fill"in e)s.fill=cagColor(e.fill);else{const t=cssStyle(e,"fill");t&&(s.fill=cagColor(t))}if("fill-opacity"in e&&(s.opacity=e["fill-opacity"]),"stroke-width"in e)s.strokeWidth=e["stroke-width"];else{const t=cssStyle(e,"stroke-width");t&&(s.strokeWidth=t)}if("stroke"in e)s.stroke=cagColor(e.stroke);else{const t=cssStyle(e,"stroke");t&&(s.stroke=cagColor(t))}"stroke-opacity"in e&&(s.strokeOpacity=e["stroke-opacity"])},svgTransformsRegExp=/\w+\(.+\)/i,svgTransforms=(s,e)=>{let t=null;if("transform"in e)t=e.transform;else{const s=cssStyle(e,"transform");s&&(t=s)}if(null!==t){s.transforms=[];let e=svgTransformsRegExp.exec(t);for(;null!==e;){const i=svgTransformsRegExp.lastIndex,n=t.indexOf(")")+1;let r=t.slice(i,n);const o=(r=r.trim()).slice(0,r.indexOf("("));let a,c=r.slice(r.indexOf("(")+1,r.indexOf(")")).trim();switch(c=c.indexOf(",")>0?c.split(","):c.split(" "),o){case"translate":1===c.length&&c.push(0),a={translate:[c[0],c[1]]},s.transforms.push(a);break;case"scale":1===c.length&&c.push(c[0]),a={scale:[c[0],c[1]]},s.transforms.push(a);break;case"rotate":a={rotate:c},s.transforms.push(a)}t=t.slice(n,t.length),e=svgTransformsRegExp.exec(t)}}},viewBoxRegExp=/([\d.-]+)[\s,]+([\d.-]+)[\s,]+([\d.-]+)[\s,]+([\d.-]+)/i,svgSvg=(s,{customPxPmm:e})=>{const t={type:"svg",x:0,y:0,width:"100%",height:"100%",strokeWidth:"1"};if(t.unitsPmm=[pxPmm,pxPmm],"pxpmm"in s&&(t.pxPmm=s.pxpmm,t.unitsPmm=[t.pxPmm,t.pxPmm]),"width"in s&&(t.width=s.width),"height"in s&&(t.height=s.height),"viewBox"in s){const i=s.viewBox.trim(),n=viewBoxRegExp.exec(i);if(null!==n&&(t.viewX=parseFloat(n[1]),t.viewY=parseFloat(n[2]),t.viewW=parseFloat(n[3]),t.viewH=parseFloat(n[4])),t.width.indexOf("%")<0){let s=css2cag(t.width,e);s=t.viewW/s,t.unitsPmm[0]=s}else{const s=t.unitsPmm[0]*(parseFloat(t.width)/100);t.unitsPmm[0]=s}if(t.height.indexOf("%")<0){let s=css2cag(t.height,pxPmm);s=t.viewH/s,t.unitsPmm[1]=s}else{const s=t.unitsPmm[1]*(parseFloat(t.height)/100);t.unitsPmm[1]=s}}else t.viewX=0,t.viewY=0,t.viewW=1920/t.unitsPmm[0],t.viewH=1080/t.unitsPmm[1];return t.viewP=Math.sqrt(t.viewW*t.viewW+t.viewH*t.viewH)/Math.SQRT2,svgCore(t,s),svgPresentation(t,s),t.objects=[],t},svgEllipse=s=>{const e={type:"ellipse",cx:"0",cy:"0",rx:"0",ry:"0"};return"cx"in s&&(e.cx=s.cx),"cy"in s&&(e.cy=s.cy),"rx"in s&&(e.rx=s.rx),"ry"in s&&(e.ry=s.ry),svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),e},svgLine=s=>{const e={type:"line",x1:"0",y1:"0",x2:"0",y2:"0"};return"x1"in s&&(e.x1=s.x1),"y1"in s&&(e.y1=s.y1),"x2"in s&&(e.x2=s.x2),"y2"in s&&(e.y2=s.y2),svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),e},svgListOfPoints=s=>{const e=[],t=/([\d\-+.]+)[\s,]+([\d\-+.]+)[\s,]*/i;s=s.trim();let i=t.exec(s);for(;null!==i;){let n=i[0];const r=t.lastIndex+n.length;n={x:i[1],y:i[2]},e.push(n),s=s.slice(r,s.length),i=t.exec(s)}return e},svgPolyline=s=>{const e={type:"polyline"};return svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),"points"in s&&(e.points=svgListOfPoints(s.points)),e},svgPolygon=s=>{const e={type:"polygon"};return svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),"points"in s&&(e.points=svgListOfPoints(s.points)),e},svgRect=s=>{const e={type:"rect",x:"0",y:"0",rx:"0",ry:"0",width:"0",height:"0"};return"x"in s&&(e.x=s.x),"y"in s&&(e.y=s.y),"rx"in s&&(e.rx=s.rx,"ry"in s||(e.ry=e.rx)),"ry"in s&&(e.ry=s.ry,"rx"in s||(e.rx=e.ry)),e.rx!==e.ry&&console.log("Warning: Unsupported RECT with rx and ry radius"),"width"in s&&(e.width=s.width),"height"in s&&(e.height=s.height),svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),e},svgCircle=s=>{const e={type:"circle",x:"0",y:"0",radius:"0"};return"cx"in s&&(e.x=s.cx),"cy"in s&&(e.y=s.cy),"r"in s&&(e.radius=s.r),svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),e},svgGroup=s=>{const e={type:"group"};if(svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),"x"in s||"y"in s){let t="0",i="0";"x"in s&&(t=s.x),"y"in s&&(i=s.y),"transforms"in e||(e.transforms=[]);const n={translate:[t,i]};e.transforms.push(n)}return e.objects=[],e},svgPath=s=>{const e={type:"path"};if(svgTransforms(e,s),svgCore(e,s),svgPresentation(e,s),e.commands=[],"d"in s){let t=null,i="",n=0;const r=s.d.length,o=s.position[1]-r-2;for(;n<r;){const r=s.d[n];switch(r){case"-":i.length>0&&(t.p.push(i),i=""),i+=r;break;case".":i.length>0&&i.indexOf(".")>=0&&(t.p.push(i),i=""),i+=r;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":i+=r;break;case"a":case"A":case"c":case"C":case"h":case"H":case"l":case"L":case"v":case"V":case"m":case"M":case"q":case"Q":case"s":case"S":case"t":case"T":case"z":case"Z":null!==t&&(i.length>0&&(t.p.push(i),i=""),e.commands.push(t)),t={c:r,p:[],pos:n+o};break;case",":case" ":case"\n":null!==t&&i.length>0&&(t.p.push(i),i="")}n++}n===r&&null!==t&&(i.length>0&&t.p.push(i),e.commands.push(t))}return e},svgUse=(s,{svgObjects:e})=>{const t={type:"group"};if(svgTransforms(t,s),svgCore(t,s),svgPresentation(t,s),"x"in s||"y"in s){let e="0",i="0";"x"in s&&(e=s.x),"y"in s&&(i=s.y),"transforms"in t||(t.transforms=[]);const n={translate:[e,i]};t.transforms.push(n)}if(t.objects=[],"xlink:href"in s){let i=s["xlink:href"];"#"===i[0]&&(i=i.slice(1,i.length)),void 0!==e[i]&&(i=e[i],i=JSON.parse(JSON.stringify(i)),t.objects.push(i))}return t};module.exports={svgCore:svgCore,svgPresentation:svgPresentation,svgSvg:svgSvg,svgRect:svgRect,svgCircle:svgCircle,svgEllipse:svgEllipse,svgLine:svgLine,svgPolyline:svgPolyline,svgPolygon:svgPolygon,svgGroup:svgGroup,svgPath:svgPath,svgUse:svgUse};
570
570
 
571
571
  },{"./constants":88,"./helpers":89}],94:[function(require,module,exports){
572
- const{geometries:geometries,maths:maths,measurements:measurements,utils:utils}=require("@jscad/modeling"),stringify=require("onml/lib/stringify"),version=require("./package.json").version,mimeType="image/svg+xml",serialize=(e,...t)=>{const s={unit:"mm",decimals:1e4,version:version,statusCallback:null};e=Object.assign({},s,e);const o=(t=utils.flatten(t)).filter(e=>geometries.geom2.isA(e)||geometries.path2.isA(e));if(0===o.length)throw new Error("only 2D geometries can be serialized to SVG");t.length!==o.length&&console.warn("some objects could not be serialized to SVG"),e.statusCallback&&e.statusCallback({progress:0});const r=getBounds(o);let n=0,l=0;r&&(n=Math.round((r[1][0]-r[0][0])*e.decimals)/e.decimals,l=Math.round((r[1][1]-r[0][1])*e.decimals)/e.decimals);let i=["svg",{width:n+e.unit,height:l+e.unit,viewBox:"0 0 "+n+" "+l,fill:"none","fill-rule":"evenodd","stroke-width":"0.1px",version:"1.1",baseProfile:"tiny",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}];r&&(i=i.concat(convertObjects(o,r,e)));const a=`<?xml version="1.0" encoding="UTF-8"?>\n\x3c!-- Created by JSCAD SVG Serializer --\x3e\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">\n${stringify(i,2)}`;return e.statusCallback&&e.statusCallback({progress:100}),[a]},getBounds=e=>{const t=measurements.measureBoundingBox(e);return 1===e.length?t:t.reduce((e,t)=>(maths.vec3.min(e[0],e[0],t[0]),maths.vec3.max(e[1],e[1],t[1]),e),[[0,0,0],[0,0,0]])},convertObjects=(e,t,s)=>{const o=0-t[0][0],r=0-t[1][1],n=[];return e.forEach((t,l)=>{s.statusCallback&&s.statusCallback({progress:100*l/e.length}),geometries.geom2.isA(t)&&n.push(convertGeom2(t,[o,r],s)),geometries.path2.isA(t)&&n.push(convertPaths([t],[o,r],s))}),n},reflect=(e,t,s,o)=>{const r=e-s,n=t-o;return e===s&&t===s?[e,t]:e===s?[e,o-n]:t===o?[s- -r,t]:[s- -r,o-n]},convertGeom2=(e,t,s)=>{const o=geometries.geom2.toOutlines(e).map(e=>geometries.path2.fromPoints({closed:!0},e));return s.color="black",e.color&&(s.color=convertColor(e.color)),s.id=null,e.id&&(s.id=e.id),s.class=null,e.class&&(s.class=e.class),convertToContinousPath(o,t,s)},convertToContinousPath=(e,t,s)=>{let o="";e.forEach(e=>o+=convertPath(e,t,s));const r={fill:s.color,d:o};return s.id&&(r.id=s.id),s.class&&(r.class=s.class),["g",["path",r]]},convertPaths=(e,t,s)=>e.reduce((e,o,r)=>(d={d:convertPath(o,t,s)},o.color&&(d.stroke=convertColor(o.color)),o.id&&(d.id=o.id),o.class&&(d.class=o.class),e.concat([["path",d]])),["g"]),convertPath=(e,t,s)=>{let o="";const r=e.points.length+(e.isClosed?1:0);for(let n=0;n<r;n++){let r=n;r>=e.points.length&&(r-=e.points.length);const l=e.points[r],i=[l[0]+t[0],l[1]+t[1]],a=reflect(i[0],i[1],0,0),c=Math.round(a[0]*s.decimals)/s.decimals,m=Math.round(a[1]*s.decimals)/s.decimals;o+=n>0?`L${c} ${m}`:`M${c} ${m}`}return o},convertColor=e=>`rgb(${255*e[0]},${255*e[1]},${255*e[2]},${255*e[3]})`;module.exports={serialize:serialize,mimeType:mimeType};
572
+ const{geometries:geometries,maths:maths,measurements:measurements,utils:utils}=require("@jscad/modeling"),stringify=require("onml/lib/stringify"),version=require("./package.json").version,mimeType="image/svg+xml",serialize=(e,...t)=>{const s={unit:"mm",decimals:1e4,version:version,statusCallback:null};e=Object.assign({},s,e);const o=(t=utils.flatten(t)).filter(e=>geometries.geom2.isA(e)||geometries.path2.isA(e));if(0===o.length)throw new Error("only 2D geometries can be serialized to SVG");t.length!==o.length&&console.warn("some objects could not be serialized to SVG"),e.statusCallback&&e.statusCallback({progress:0});const r=getBounds(o);let n=0,l=0;r&&(n=Math.round((r[1][0]-r[0][0])*e.decimals)/e.decimals,l=Math.round((r[1][1]-r[0][1])*e.decimals)/e.decimals);let i=["svg",{width:n+e.unit,height:l+e.unit,viewBox:"0 0 "+n+" "+l,fill:"none","fill-rule":"evenodd","stroke-width":"0.1px",version:"1.1",baseProfile:"tiny",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}];r&&(i=i.concat(convertObjects(o,r,e)));const a=`<?xml version="1.0" encoding="UTF-8"?>\n\x3c!-- Created by JSCAD SVG Serializer --\x3e\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">\n${stringify(i,2)}`;return e.statusCallback&&e.statusCallback({progress:100}),[a]},getBounds=e=>{const t=measurements.measureBoundingBox(e);return 1===e.length?t:t.reduce((e,t)=>(maths.vec3.min(e[0],e[0],t[0]),maths.vec3.max(e[1],e[1],t[1]),e),[[0,0,0],[0,0,0]])},convertObjects=(e,t,s)=>{const o=0-t[0][0],r=0-t[1][1],n=[];return e.forEach((t,l)=>{s.statusCallback&&s.statusCallback({progress:100*l/e.length}),geometries.geom2.isA(t)&&n.push(convertGeom2(t,[o,r],s)),geometries.path2.isA(t)&&n.push(convertPaths([t],[o,r],s))}),n},reflect=(e,t,s,o)=>{const r=e-s,n=t-o;return e===s&&t===s?[e,t]:e===s?[e,o-n]:t===o?[s- -r,t]:[s- -r,o-n]},convertGeom2=(e,t,s)=>{const o=geometries.geom2.toOutlines(e).map(e=>geometries.path2.fromPoints({closed:!0},e));return s.color="black",e.color&&(s.color=convertColor(e.color)),s.id=null,e.id&&(s.id=e.id),s.class=null,e.class&&(s.class=e.class),convertToContinousPath(o,t,s)},convertToContinousPath=(e,t,s)=>{let o="";e.forEach(e=>o+=convertPath(e,t,s));const r={fill:s.color,d:o};return s.id&&(r.id=s.id),s.class&&(r.class=s.class),["g",["path",r]]},convertPaths=(e,t,s)=>e.reduce((e,o,r)=>{const n={d:convertPath(o,t,s)};return o.color&&(n.stroke=convertColor(o.color)),o.id&&(n.id=o.id),o.class&&(n.class=o.class),e.concat([["path",n]])},["g"]),convertPath=(e,t,s)=>{let o="";const r=e.points.length+(e.isClosed?1:0);for(let n=0;n<r;n++){let r=n;r>=e.points.length&&(r-=e.points.length);const l=e.points[r],i=[l[0]+t[0],l[1]+t[1]],a=reflect(i[0],i[1],0,0),c=Math.round(a[0]*s.decimals)/s.decimals,m=Math.round(a[1]*s.decimals)/s.decimals;o+=n>0?`L${c} ${m}`:`M${c} ${m}`}return o},convertColor=e=>`rgb(${255*e[0]},${255*e[1]},${255*e[2]},${255*e[3]})`;module.exports={serialize:serialize,mimeType:mimeType};
573
573
 
574
574
  },{"./package.json":96,"@jscad/modeling":585,"onml/lib/stringify":95}],95:[function(require,module,exports){
575
575
  "use strict";function isObject(n){return n&&"[object Object]"===Object.prototype.toString.call(n)}function indenter(n){var t=" ".repeat(n);return function(n){var e,r=[];return"string"!=typeof n?n:1===(e=n.split("\n")).length?t+n:(e.forEach(function(n){""!==n.trim()?r.push(t+n):r.push(n)}),r.join("\n"))}}function clean(n){var t=n.split("\n"),e=[];return t.forEach(function(n){""!==n.trim()&&e.push(n)}),e.join("\n")}function stringify(n,t){var e="",r=function(n){return n};return t>0&&(e="\n",r=indenter(t)),function n(t){var i,o,c;return o="",c=!0,t.some(function(t,r,u){if(0===r)return i="<"+t,1===u.length||void 0;if(1===r){if(isObject(t))return Object.keys(t).forEach(function(n){i+=" "+n+'="'+t[n]+'"'}),2===u.length||void(i+=">");i+=">"}switch(typeof t){case"string":case"number":case"boolean":case"undefined":return void(o+=t+e)}c=!1,o+=n(t)})?i+"/>"+e:c?i+clean(o)+"</"+t[0]+">"+e:i+e+r(o)+"</"+t[0]+">"+e}(n)}module.exports=stringify;
@@ -577,7 +577,7 @@ const{geometries:geometries,maths:maths,measurements:measurements,utils:utils}=r
577
577
  },{}],96:[function(require,module,exports){
578
578
  module.exports={
579
579
  "name": "@jscad/svg-serializer",
580
- "version": "2.3.0",
580
+ "version": "2.3.1",
581
581
  "description": "SVG Serializer for JSCAD",
582
582
  "repository": "https://github.com/jscad/OpenJSCAD.org",
583
583
  "main": "index.js",
@@ -608,7 +608,7 @@ module.exports={
608
608
  ],
609
609
  "license": "MIT",
610
610
  "dependencies": {
611
- "@jscad/modeling": "2.7.1",
611
+ "@jscad/modeling": "2.7.2",
612
612
  "onml": "1.2.0"
613
613
  },
614
614
  "devDependencies": {
@@ -1772,7 +1772,7 @@ const radiusToSegments=(t,e,a)=>{const s=e>0?2*t*Math.PI/e:0,o=a>0?2*Math.PI/a:0
1772
1772
  },{"xmlchars/xml/1.0/ed5":477,"xmlchars/xml/1.1/ed2":478,"xmlchars/xmlns/1.0/ed3":479}],481:[function(require,module,exports){
1773
1773
  module.exports={
1774
1774
  "name": "@jscad/x3d-deserializer",
1775
- "version": "2.1.1",
1775
+ "version": "2.1.2",
1776
1776
  "description": "X3D Deserializer for JSCAD",
1777
1777
  "repository": "https://github.com/jscad/OpenJSCAD.org/",
1778
1778
  "main": "src/index.js",
@@ -1941,7 +1941,7 @@ const create=require("./create"),toSides=require("./toSides"),reverse=e=>{const
1941
1941
  const toCompactBinary=o=>{const t=o.sides,r=o.transforms;let n=[-1,-1,-1,-1];o.color&&(n=o.color);const e=new Float32Array(21+4*t.length);e[0]=0,e[1]=r[0],e[2]=r[1],e[3]=r[2],e[4]=r[3],e[5]=r[4],e[6]=r[5],e[7]=r[6],e[8]=r[7],e[9]=r[8],e[10]=r[9],e[11]=r[10],e[12]=r[11],e[13]=r[12],e[14]=r[13],e[15]=r[14],e[16]=r[15],e[17]=n[0],e[18]=n[1],e[19]=n[2],e[20]=n[3];for(let o=0;o<t.length;o++){const r=4*o+21,n=t[o][0],s=t[o][1];e[r+0]=n[0],e[r+1]=n[1],e[r+2]=s[0],e[r+3]=s[1]}return e};module.exports=toCompactBinary;
1942
1942
 
1943
1943
  },{}],526:[function(require,module,exports){
1944
- const vec2=require("../../maths/vec2"),toSides=require("./toSides"),toEdges=e=>{const t=[],s=e=>{const s=t.findIndex(t=>vec2.equals(t,e));return s<0?(t.push(e),e):t[s]},o=[];return e.forEach(e=>{o.push([s(e[0]),s(e[1])])}),o},toOutlines=e=>{const t=new Map;toEdges(toSides(e)).forEach(e=>{t.has(e[0])||t.set(e[0],[]),t.get(e[0]).push(e)});const s=[];for(;;){let e;for(const[s,o]of t){if(e=o.shift())break;t.delete(s)}if(void 0===e)break;const o=[],r=e[0],n=vec2.create();for(;;){o.push(e[0]);const s=e[1];if(s===r)break;const c=t.get(s);if(!c)throw new Error("the given geometry is not closed. verify proper construction");let i=-1;if(1===c.length)i=0;else{let t;const s=vec2.angleDegrees(vec2.subtract(n,e[1],e[0]));for(let e=0;e<c.length;e++){const o=c[e];let r=vec2.angleDegrees(vec2.subtract(n,o[1],o[0]))-s;r<-180&&(r+=360),r>=180&&(r-=360),(i<0||r>t)&&(i=e,t=r)}}const l=c[i];c.splice(i,1),0===c.length&&t.delete(s),e=l}o.length>0&&o.push(o.shift()),s.push(o)}return t.clear(),s};module.exports=toOutlines;
1944
+ const vec2=require("../../maths/vec2"),toSides=require("./toSides"),toEdges=e=>{const t={},s=e=>{const s=e.toString();return t[s]||(t[s]=e),t[s]};return e.map(e=>e.map(s))},toOutlines=e=>{const t=new Map;toEdges(toSides(e)).forEach(e=>{t.has(e[0])||t.set(e[0],[]),t.get(e[0]).push(e)});const s=[];for(;;){let e;for(const[s,o]of t){if(e=o.shift())break;t.delete(s)}if(void 0===e)break;const o=[],r=e[0],n=vec2.create();for(;;){o.push(e[0]);const s=e[1];if(s===r)break;const c=t.get(s);if(!c)throw new Error("the given geometry is not closed. verify proper construction");let i=-1;if(1===c.length)i=0;else{let t;const s=vec2.angleDegrees(vec2.subtract(n,e[1],e[0]));for(let e=0;e<c.length;e++){const o=c[e];let r=vec2.angleDegrees(vec2.subtract(n,o[1],o[0]))-s;r<-180&&(r+=360),r>=180&&(r-=360),(i<0||r>t)&&(i=e,t=r)}}const l=c[i];c.splice(i,1),0===c.length&&t.delete(s),e=l}o.length>0&&o.push(o.shift()),s.push(o)}return t.clear(),s};module.exports=toOutlines;
1945
1945
 
1946
1946
  },{"../../maths/vec2":683,"./toSides":528}],527:[function(require,module,exports){
1947
1947
  const toSides=require("./toSides"),toPoints=t=>{const o=toSides(t).map(t=>t[0]);return o.length>0&&o.push(o.shift()),o};module.exports=toPoints;
@@ -2244,7 +2244,7 @@ const create=()=>[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];module.exports=create;
2244
2244
  const equals=(e,s)=>e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]&&e[9]===s[9]&&e[10]===s[10]&&e[11]===s[11]&&e[12]===s[12]&&e[13]===s[13]&&e[14]===s[14]&&e[15]===s[15];module.exports=equals;
2245
2245
 
2246
2246
  },{}],627:[function(require,module,exports){
2247
- const identity=require("./identity"),{EPSILON:EPSILON}=require("./constants"),fromRotation=(t,e,i)=>{let[n,o,r]=i,s=Math.sqrt(n*n+o*o+r*r);if(Math.abs(s)<EPSILON)return identity(t);n*=s=1/s,o*=s,r*=s;const a=Math.sin(e),u=Math.cos(e),c=1-u;return t[0]=n*n*c+u,t[1]=o*n*c+r*a,t[2]=r*n*c-o*a,t[3]=0,t[4]=n*o*c-r*a,t[5]=o*o*c+u,t[6]=r*o*c+n*a,t[7]=0,t[8]=n*r*c+o*a,t[9]=o*r*c-n*a,t[10]=r*r*c+u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t};module.exports=fromRotation;
2247
+ const identity=require("./identity"),{EPSILON:EPSILON}=require("./constants"),fromRotation=(t,o,e)=>{let[i,n,r]=e,a=Math.hypot(i,n,r);if(Math.abs(a)<EPSILON)return identity(t);i*=a=1/a,n*=a,r*=a;const s=Math.sin(o),h=Math.cos(o),u=1-h;return t[0]=i*i*u+h,t[1]=n*i*u+r*s,t[2]=r*i*u-n*s,t[3]=0,t[4]=i*n*u-r*s,t[5]=n*n*u+h,t[6]=r*n*u+i*s,t[7]=0,t[8]=i*r*u+n*s,t[9]=n*r*u-i*s,t[10]=r*r*u+h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t};module.exports=fromRotation;
2248
2248
 
2249
2249
  },{"./constants":623,"./identity":636}],628:[function(require,module,exports){
2250
2250
  const fromScaling=(o,c)=>(o[0]=c[0],o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=c[1],o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=c[2],o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o);module.exports=fromScaling;
@@ -2295,7 +2295,7 @@ const mirrorByPlane=(r,o)=>{const[e,n,t,l]=o;return r[0]=1-2*e*e,r[1]=-2*n*e,r[2
2295
2295
  const multiply=(t,l,e)=>{const o=l[0],u=l[1],m=l[2],n=l[3],p=l[4],r=l[5],s=l[6],c=l[7],i=l[8],y=l[9],d=l[10],x=l[11],a=l[12],b=l[13],f=l[14],g=l[15];let h=e[0],j=e[1],k=e[2],q=e[3];return t[0]=h*o+j*p+k*i+q*a,t[1]=h*u+j*r+k*y+q*b,t[2]=h*m+j*s+k*d+q*f,t[3]=h*n+j*c+k*x+q*g,h=e[4],j=e[5],k=e[6],q=e[7],t[4]=h*o+j*p+k*i+q*a,t[5]=h*u+j*r+k*y+q*b,t[6]=h*m+j*s+k*d+q*f,t[7]=h*n+j*c+k*x+q*g,h=e[8],j=e[9],k=e[10],q=e[11],t[8]=h*o+j*p+k*i+q*a,t[9]=h*u+j*r+k*y+q*b,t[10]=h*m+j*s+k*d+q*f,t[11]=h*n+j*c+k*x+q*g,h=e[12],j=e[13],k=e[14],q=e[15],t[12]=h*o+j*p+k*i+q*a,t[13]=h*u+j*r+k*y+q*b,t[14]=h*m+j*s+k*d+q*f,t[15]=h*n+j*c+k*x+q*g,t};module.exports=multiply;
2296
2296
 
2297
2297
  },{}],644:[function(require,module,exports){
2298
- const copy=require("./copy"),rotate=(t,e,o,r)=>{let[a,s,c]=r,n=Math.sqrt(a*a+s*s+c*c);if(Math.abs(n)<1e-6)return copy(t,e);a*=n=1/n,s*=n,c*=n;const h=Math.sin(o),p=Math.cos(o),u=1-p,M=e[0],i=e[1],y=e[2],l=e[3],q=e[4],b=e[5],d=e[6],f=e[7],m=e[8],x=e[9],g=e[10],j=e[11],k=a*a*u+p,v=s*a*u+c*h,w=c*a*u-s*h,z=a*s*u-c*h,A=s*s*u+p,B=c*s*u+a*h,C=a*c*u+s*h,D=s*c*u-a*h,E=c*c*u+p;return t[0]=M*k+q*v+m*w,t[1]=i*k+b*v+x*w,t[2]=y*k+d*v+g*w,t[3]=l*k+f*v+j*w,t[4]=M*z+q*A+m*B,t[5]=i*z+b*A+x*B,t[6]=y*z+d*A+g*B,t[7]=l*z+f*A+j*B,t[8]=M*C+q*D+m*E,t[9]=i*C+b*D+x*E,t[10]=y*C+d*D+g*E,t[11]=l*C+f*D+j*E,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t};module.exports=rotate;
2298
+ const copy=require("./copy"),rotate=(t,o,e,r)=>{let[a,c,s]=r,h=Math.hypot(a,c,s);if(Math.abs(h)<1e-6)return copy(t,o);a*=h=1/h,c*=h,s*=h;const n=Math.sin(e),p=Math.cos(e),u=1-p,y=o[0],M=o[1],i=o[2],l=o[3],b=o[4],d=o[5],f=o[6],m=o[7],q=o[8],x=o[9],g=o[10],j=o[11],k=a*a*u+p,v=c*a*u+s*n,w=s*a*u-c*n,z=a*c*u-s*n,A=c*c*u+p,B=s*c*u+a*n,C=a*s*u+c*n,D=c*s*u-a*n,E=s*s*u+p;return t[0]=y*k+b*v+q*w,t[1]=M*k+d*v+x*w,t[2]=i*k+f*v+g*w,t[3]=l*k+m*v+j*w,t[4]=y*z+b*A+q*B,t[5]=M*z+d*A+x*B,t[6]=i*z+f*A+g*B,t[7]=l*z+m*A+j*B,t[8]=y*C+b*D+q*E,t[9]=M*C+d*D+x*E,t[10]=i*C+f*D+g*E,t[11]=l*C+m*D+j*E,o!==t&&(t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t};module.exports=rotate;
2299
2299
 
2300
2300
  },{"./copy":624}],645:[function(require,module,exports){
2301
2301
  const rotateX=(t,o,e)=>{const r=Math.sin(e),s=Math.cos(e),a=o[4],n=o[5],c=o[6],h=o[7],u=o[8],M=o[9],X=o[10],d=o[11];return o!==t&&(t[0]=o[0],t[1]=o[1],t[2]=o[2],t[3]=o[3],t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t[4]=a*s+u*r,t[5]=n*s+M*r,t[6]=c*s+X*r,t[7]=h*s+d*r,t[8]=u*s-a*r,t[9]=M*s-n*r,t[10]=X*s-c*r,t[11]=d*s-h*r,t};module.exports=rotateX;
@@ -2469,7 +2469,7 @@ const abs=(a,s)=>(a[0]=Math.abs(s[0]),a[1]=Math.abs(s[1]),a[2]=Math.abs(s[2]),a)
2469
2469
  const add=(d,o,a)=>(d[0]=o[0]+a[0],d[1]=o[1]+a[1],d[2]=o[2]+a[2],d);module.exports=add;
2470
2470
 
2471
2471
  },{}],702:[function(require,module,exports){
2472
- const dot=require("./dot"),angle=(t,a)=>{const o=t[0],e=t[1],r=t[2],n=a[0],s=a[1],h=a[2],M=Math.sqrt(o*o+e*e+r*r)*Math.sqrt(n*n+s*s+h*h),d=M&&dot(t,a)/M;return Math.acos(Math.min(Math.max(d,-1),1))};module.exports=angle;
2472
+ const dot=require("./dot"),angle=(t,o)=>{const a=t[0],e=t[1],h=t[2],n=o[0],r=o[1],M=o[2],d=Math.hypot(a,e,h)*Math.hypot(n,r,M),s=d&&dot(t,o)/d;return Math.acos(Math.min(Math.max(s,-1),1))};module.exports=angle;
2473
2473
 
2474
2474
  },{"./dot":709}],703:[function(require,module,exports){
2475
2475
  const create=require("./create"),clone=e=>{const r=create();return r[0]=e[0],r[1]=e[1],r[2]=e[2],r};module.exports=clone;
@@ -2937,7 +2937,7 @@ const{EPS:EPS}=require("../maths/constants"),vec2=require("../maths/vec2"),geom2
2937
2937
  const vec3=require("../maths/vec3"),geom3=require("../geometries/geom3"),poly3=require("../geometries/poly3"),{isGTE:isGTE,isNumberArray:isNumberArray}=require("./commonChecks"),ellipsoid=e=>{const{center:c,radius:a,segments:r,axes:s}=Object.assign({},{center:[0,0,0],radius:[1,1,1],segments:32,axes:[[1,0,0],[0,-1,0],[0,0,1]]},e);if(!isNumberArray(c,3))throw new Error("center must be an array of X, Y and Z values");if(!isNumberArray(a,3))throw new Error("radius must be an array of X, Y and Z values");if(!a.every(e=>e>0))throw new Error("radius values must be greater than zero");if(!isGTE(r,4))throw new Error("segments must be four or more");const t=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),s[0]),a[0]),v=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),s[1]),a[1]),o=vec3.scale(vec3.create(),vec3.normalize(vec3.create(),s[2]),a[2]),l=Math.round(r/4);let u;const d=[],i=vec3.create(),n=vec3.create();for(let e=0;e<=r;e++){const a=2*Math.PI*e/r,s=vec3.add(vec3.create(),vec3.scale(i,t,Math.cos(a)),vec3.scale(n,v,Math.sin(a)));if(e>0){let e,a;for(let r=0;r<=l;r++){const t=.5*Math.PI*r/l,v=Math.cos(t),m=Math.sin(t);if(r>0){let t,h=[];t=vec3.subtract(vec3.create(),vec3.scale(i,u,e),vec3.scale(n,o,a)),h.push(vec3.add(t,t,c)),t=vec3.subtract(vec3.create(),vec3.scale(i,s,e),vec3.scale(n,o,a)),h.push(vec3.add(t,t,c)),r<l&&(t=vec3.subtract(vec3.create(),vec3.scale(i,s,v),vec3.scale(n,o,m)),h.push(vec3.add(t,t,c))),t=vec3.subtract(vec3.create(),vec3.scale(i,u,v),vec3.scale(n,o,m)),h.push(vec3.add(t,t,c)),d.push(poly3.fromPoints(h)),h=[],t=vec3.add(vec3.create(),vec3.scale(i,u,e),vec3.scale(n,o,a)),h.push(vec3.add(vec3.create(),c,t)),t=vec3.add(t,vec3.scale(i,s,e),vec3.scale(n,o,a)),h.push(vec3.add(vec3.create(),c,t)),r<l&&(t=vec3.add(t,vec3.scale(i,s,v),vec3.scale(n,o,m)),h.push(vec3.add(vec3.create(),c,t))),t=vec3.add(t,vec3.scale(i,u,v),vec3.scale(n,o,m)),h.push(vec3.add(vec3.create(),c,t)),h.reverse(),d.push(poly3.fromPoints(h))}e=v,a=m}}u=s}return geom3.create(d)};module.exports=ellipsoid;
2938
2938
 
2939
2939
  },{"../geometries/geom3":536,"../geometries/poly3":573,"../maths/vec3":714,"./commonChecks":851}],858:[function(require,module,exports){
2940
- const mat4=require("../maths/mat4"),geom3=require("../geometries/geom3"),polyhedron=require("./polyhedron"),{isGT:isGT,isGTE:isGTE}=require("./commonChecks"),geodesicSphere=e=>{let{radius:r,frequency:t}=Object.assign({},{radius:1,frequency:6},e);if(!isGT(r,0))throw new Error("radius must be greater than zero");if(!isGTE(t,6))throw new Error("frequency must be six or more");t=Math.floor(t/6);const o=[[.850651,0,-.525731],[.850651,-0,.525731],[-.850651,-0,.525731],[-.850651,0,-.525731],[0,-.525731,.850651],[0,.525731,.850651],[0,.525731,-.850651],[0,-.525731,-.850651],[-.525731,-.850651,-0],[.525731,-.850651,-0],[.525731,.850651,0],[-.525731,.850651,0]],s=[[0,9,1],[1,10,0],[6,7,0],[10,6,0],[7,9,0],[5,1,4],[4,1,9],[5,10,1],[2,8,3],[3,11,2],[2,5,4],[4,8,2],[2,11,5],[3,7,6],[6,11,3],[8,7,3],[9,8,4],[11,10,5],[10,11,6],[8,9,7]],n=(e,r,t)=>{const o=e[0],s=e[1],n=e[2];let c=t;const a=[],f=[];for(let e=0;e<r;e++)for(let t=0;t<r-e;t++){const l=e/r,u=(e+1)/r,h=t/(r-e),m=(t+1)/(r-e),p=r-e-1?t/(r-e-1):1,g=[];g[0]=i(i(o,s,h),n,l),g[1]=i(i(o,s,m),n,l),g[2]=i(i(o,s,p),n,u);for(let e=0;e<3;e++){const r=Math.sqrt(g[e][0]*g[e][0]+g[e][1]*g[e][1]+g[e][2]*g[e][2]);for(let t=0;t<3;t++)g[e][t]/=r}if(a.push(g[0],g[1],g[2]),f.push([c,c+1,c+2]),c+=3,t<r-e-1){const h=r-e-1?(t+1)/(r-e-1):1;g[0]=i(i(o,s,m),n,l),g[1]=i(i(o,s,h),n,u),g[2]=i(i(o,s,p),n,u);for(let e=0;e<3;e++){const r=Math.sqrt(g[e][0]*g[e][0]+g[e][1]*g[e][1]+g[e][2]*g[e][2]);for(let t=0;t<3;t++)g[e][t]/=r}a.push(g[0],g[1],g[2]),f.push([c,c+1,c+2]),c+=3}}return{points:a,triangles:f,offset:c}},i=(e,r,t)=>{const o=1-t,s=[];for(let n=0;n<3;n++)s[n]=e[n]*o+r[n]*t;return s};let c=[],a=[],f=0;for(let e=0;e<s.length;e++){const r=n([o[s[e][0]],o[s[e][1]],o[s[e][2]]],t,f);c=c.concat(r.points),a=a.concat(r.triangles),f=r.offset}let l=polyhedron({points:c,faces:a,orientation:"inward"});return 1!==r&&(l=geom3.transform(mat4.fromScaling(mat4.create(),[r,r,r]),l)),l};module.exports=geodesicSphere;
2940
+ const mat4=require("../maths/mat4"),geom3=require("../geometries/geom3"),polyhedron=require("./polyhedron"),{isGT:isGT,isGTE:isGTE}=require("./commonChecks"),geodesicSphere=e=>{let{radius:t,frequency:r}=Object.assign({},{radius:1,frequency:6},e);if(!isGT(t,0))throw new Error("radius must be greater than zero");if(!isGTE(r,6))throw new Error("frequency must be six or more");r=Math.floor(r/6);const o=[[.850651,0,-.525731],[.850651,-0,.525731],[-.850651,-0,.525731],[-.850651,0,-.525731],[0,-.525731,.850651],[0,.525731,.850651],[0,.525731,-.850651],[0,-.525731,-.850651],[-.525731,-.850651,-0],[.525731,-.850651,-0],[.525731,.850651,0],[-.525731,.850651,0]],s=[[0,9,1],[1,10,0],[6,7,0],[10,6,0],[7,9,0],[5,1,4],[4,1,9],[5,10,1],[2,8,3],[3,11,2],[2,5,4],[4,8,2],[2,11,5],[3,7,6],[6,11,3],[8,7,3],[9,8,4],[11,10,5],[10,11,6],[8,9,7]],n=(e,t,r)=>{const o=e[0],s=e[1],n=e[2];let c=r;const a=[],f=[];for(let e=0;e<t;e++)for(let r=0;r<t-e;r++){const l=e/t,h=(e+1)/t,u=r/(t-e),m=(r+1)/(t-e),p=t-e-1?r/(t-e-1):1,g=[];g[0]=i(i(o,s,u),n,l),g[1]=i(i(o,s,m),n,l),g[2]=i(i(o,s,p),n,h);for(let e=0;e<3;e++){const t=Math.hypot(g[e][0],g[e][1],g[e][2]);for(let r=0;r<3;r++)g[e][r]/=t}if(a.push(g[0],g[1],g[2]),f.push([c,c+1,c+2]),c+=3,r<t-e-1){const u=t-e-1?(r+1)/(t-e-1):1;g[0]=i(i(o,s,m),n,l),g[1]=i(i(o,s,u),n,h),g[2]=i(i(o,s,p),n,h);for(let e=0;e<3;e++){const t=Math.hypot(g[e][0],g[e][1],g[e][2]);for(let r=0;r<3;r++)g[e][r]/=t}a.push(g[0],g[1],g[2]),f.push([c,c+1,c+2]),c+=3}}return{points:a,triangles:f,offset:c}},i=(e,t,r)=>{const o=1-r,s=[];for(let n=0;n<3;n++)s[n]=e[n]*o+t[n]*r;return s};let c=[],a=[],f=0;for(let e=0;e<s.length;e++){const t=n([o[s[e][0]],o[s[e][1]],o[s[e][2]]],r,f);c=c.concat(t.points),a=a.concat(t.triangles),f=t.offset}let l=polyhedron({points:c,faces:a,orientation:"inward"});return 1!==t&&(l=geom3.transform(mat4.fromScaling(mat4.create(),[t,t,t]),l)),l};module.exports=geodesicSphere;
2941
2941
 
2942
2942
  },{"../geometries/geom3":536,"../maths/mat4":637,"./commonChecks":851,"./polyhedron":862}],859:[function(require,module,exports){
2943
2943
  module.exports={arc:require("./arc"),circle:require("./circle"),cube:require("./cube"),cuboid:require("./cuboid"),cylinder:require("./cylinder"),cylinderElliptic:require("./cylinderElliptic"),ellipse:require("./ellipse"),ellipsoid:require("./ellipsoid"),geodesicSphere:require("./geodesicSphere"),line:require("./line"),polygon:require("./polygon"),polyhedron:require("./polyhedron"),rectangle:require("./rectangle"),roundedCuboid:require("./roundedCuboid"),roundedCylinder:require("./roundedCylinder"),roundedRectangle:require("./roundedRectangle"),sphere:require("./sphere"),square:require("./square"),star:require("./star"),torus:require("./torus"),triangle:require("./triangle")};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscad/core",
3
- "version": "2.5.3",
3
+ "version": "2.5.4",
4
4
  "description": "Core functionality for JSCAD Applications",
5
5
  "repository": "https://github.com/jscad/OpenJSCAD.org",
6
6
  "main": "src/index.js",
@@ -35,9 +35,9 @@
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
37
  "@jscad/array-utils": "2.1.1",
38
- "@jscad/io": "2.2.3",
39
- "@jscad/io-utils": "2.0.12",
40
- "@jscad/modeling": "2.7.1",
38
+ "@jscad/io": "2.2.4",
39
+ "@jscad/io-utils": "2.0.13",
40
+ "@jscad/modeling": "2.7.2",
41
41
  "json5": "2.2.0",
42
42
  "strip-bom": "4.0.0"
43
43
  },
@@ -52,5 +52,5 @@
52
52
  "url": "https://opencollective.com/openjscad",
53
53
  "logo": "https://opencollective.com/openjscad/logo.txt"
54
54
  },
55
- "gitHead": "95f05c5f11a53bff469a305d69b99f674dc7d6d3"
55
+ "gitHead": "b6c5675d2d9a292e0ba24896bf22d0e9dc5d4270"
56
56
  }
@@ -24,7 +24,6 @@ const applyParameterDefinitions = require('../parameters/applyParameterDefinitio
24
24
  * And transfering data back & forth is both complex (see transferables) and costly (time)
25
25
  **/
26
26
  const rebuildSolids = (data, callback) => {
27
- console.log('rebuildSolids',data)
28
27
  const defaults = {
29
28
  mainPath: '',
30
29
  apiMainPath: '@jscad/modeling',
@@ -47,7 +46,6 @@ const rebuildSolids = (data, callback) => {
47
46
  parameterDefaults: designData.parameterValues,
48
47
  parameterDefinitions: designData.parameterDefinitions
49
48
  })
50
- // console.warn(`loadDesignData`, new Date() - start)
51
49
  // make sure parameters are correct by applying parameter definitions
52
50
  // this might be redundant with ui-side logic, but it makes sure this core piece works regardless of ui
53
51
  parameterValues = applyParameterDefinitions(parameterValues, designData.parameterDefinitions)
@@ -59,7 +57,6 @@ const rebuildSolids = (data, callback) => {
59
57
  serialize
60
58
  }
61
59
  const solidsData = instanciateDesign(designData.rootModule, parameterValues, options)
62
- // console.warn(`instanciateDesign`, new Date() - start)
63
60
 
64
61
  // send back solids & any other metadata
65
62
  callback(null, {
@@ -7,10 +7,9 @@ const makeWebRequire = require('../code-loading/webRequire')
7
7
 
8
8
  const rebuildSolids = (data) => {
9
9
  const defaults = {
10
- apiMainPath: '@jscad/modeling',
11
- serialize: false
10
+ apiMainPath: '@jscad/modeling'
12
11
  }
13
- let { apiMainPath, serialize, mainPath, parameterValues, useFakeFs } = Object.assign({}, defaults, data)
12
+ let { apiMainPath, mainPath, parameterValues, useFakeFs } = Object.assign({}, defaults, data)
14
13
  // we need to update the source for our module
15
14
  let requireFn = require
16
15
 
@@ -11,7 +11,7 @@ const serializeSolids = (solids) => {
11
11
  // imcomplete support for transfering objects via web workers
12
12
 
13
13
  // NOTE: JSON.stringify was used at some point, but was removed because it was no longer needed
14
- // for postMessage JavaScript engines now use an optimized structured clone alg.
14
+ // for postMessage JavaScript engines now use an optimized structured clone alg.
15
15
  // which should be at least as fast as JSON.stringify
16
16
  solids = solids.map((object) => {
17
17
  // apply the transforms before serializing
@@ -23,5 +23,4 @@ const serializeSolids = (solids) => {
23
23
  return solids
24
24
  }
25
25
 
26
-
27
26
  module.exports = serializeSolids
@@ -1,4 +1,3 @@
1
- // loading
2
1
  const { registerAllExtensions } = require('../io/registerExtensions')
3
2
 
4
3
  const transformSources = require('./transformSources')
@@ -16,27 +15,6 @@ const getAllParameterDefintionsAndValues = require('../parameters/getParameterDe
16
15
  * @param {Object} parameterValuesOverride - the values to use to override the defaults for the current design
17
16
  */
18
17
  const loadDesign = (mainPath, apiMainPath, filesAndFolders, parameterValuesOverride) => {
19
- // console.log('***** loadDesign',mainPath)
20
- // the root script is the main entry point in a design
21
- // ie either the only file if there is only one
22
- // OR the file in the 'main' entry of package.js, index.js, main.js or <folderName>.js
23
-
24
- /*
25
- - if the script is a common.js file already
26
- > load as it is
27
- - if we have real require() access (CLI, desktop)
28
- use standard require() to load the rootScript
29
- - if we do NOT have real require() access (web)
30
- use fake require() to load the rootScript
31
- - if the script is NOT a common.js file (implicit imports)
32
- > add explicit api imports to the rootScript's source
33
- > add explicit exports ie module.exports {main, getParameterDefinitions}
34
- - if we have real require() access (CLI, desktop)
35
- use standard require() to load the rootScript
36
- - if we do NOT have real require() access (web)
37
- use fake require() to load the rootScript
38
- */
39
-
40
18
  // transform the source if passed non-javascript content, i.e. stl
41
19
  filesAndFolders = transformSources({ apiMainPath }, filesAndFolders)
42
20
 
@@ -52,8 +30,6 @@ const loadDesign = (mainPath, apiMainPath, filesAndFolders, parameterValuesOverr
52
30
  }
53
31
  ]
54
32
  }
55
- // console.log('filesAndFolders',filesAndFolders)
56
-
57
33
  const fakeFs = makeFakeFs(filesAndFolders)
58
34
 
59
35
  const webRequire = makeWebRequire(filesAndFolders, { apiMainPath })
@@ -64,8 +40,6 @@ const loadDesign = (mainPath, apiMainPath, filesAndFolders, parameterValuesOverr
64
40
  // find the root module
65
41
  let rootModule = webRequire(filesAndFolders[0].fullPath)
66
42
 
67
- // console.log('***** rootModule',rootModule)
68
-
69
43
  rootModule = normalizeDesignModule(rootModule)
70
44
 
71
45
  // rootModule SHOULD contain a main() entry and optionally a getParameterDefinitions entry
@@ -13,7 +13,6 @@ const makeFakeFs = (filesAndFolders) => {
13
13
  }
14
14
  }
15
15
  return undefined
16
- // return filesAndFolders
17
16
  }
18
17
 
19
18
  const statSync = (path) => {
@@ -27,16 +26,13 @@ const makeFakeFs = (filesAndFolders) => {
27
26
  statSync,
28
27
  existsSync: (path) => {
29
28
  const entry = findMatch(path)
30
- // console.log('does ', path, 'exist ?', entry !== undefined)
31
29
  return entry !== undefined
32
30
  },
33
31
  readdirSync: (path) => {
34
32
  const entry = findMatch(path)
35
33
  return entry.children.map((x) => x.name)
36
- // filesAndFolders
37
34
  },
38
35
  readDir: (path, callback) => {
39
- // console.log('readDir', path, callback)
40
36
  const entry = findMatch(path)
41
37
  callback(null, entry)
42
38
  },
@@ -48,7 +44,6 @@ const makeFakeFs = (filesAndFolders) => {
48
44
  if (!statSync(path).isFile()) {
49
45
  callback(new Error(`${entry} is not a file, cannot read`))
50
46
  } else {
51
- // console.log('readFile', path, entry)
52
47
  callback(null, entry.source)
53
48
  }
54
49
  },
@@ -60,7 +55,6 @@ const makeFakeFs = (filesAndFolders) => {
60
55
  if (!statSync(path).isFile()) {
61
56
  throw new Error(`${entry} is not a file, cannot read`)
62
57
  } else {
63
- // console.log('readFile sync', path, entry)
64
58
  return entry.source
65
59
  }
66
60
  }
@@ -4,7 +4,8 @@
4
4
  */
5
5
  const modulifySource = (source, apiMainPath) => {
6
6
  const getParamsString = source.includes('getParameterDefinitions')
7
- ? 'module.exports.getParameterDefinitions = getParameterDefinitions' : ''
7
+ ? 'module.exports.getParameterDefinitions = getParameterDefinitions'
8
+ : ''
8
9
  const updatedSource = `
9
10
  const {geom2, geom3, path2, pol2, poly3} = require('${apiMainPath}').geometries
10
11
 
@@ -3,9 +3,7 @@ const { deserializers } = require('@jscad/io')
3
3
  /*
4
4
  * Transform the entry into a ready-to-use module.
5
5
  */
6
- const modulifyTransform = (options, entry) => {
7
- return Object.assign({}, entry, { source: entry.source })
8
- }
6
+ const modulifyTransform = (options, entry) => Object.assign({}, entry, { source: entry.source })
9
7
 
10
8
  /*
11
9
  * Create a new entry for a script (JSCAD) from the given entry and source
@@ -24,8 +22,6 @@ const createJscadEntry = (entry, source) => {
24
22
  * Transforms are NOT applied to projects.
25
23
  */
26
24
  const transformSources = (options, filesAndFolders) => {
27
- // console.log('***** transformSources', options, filesAndFolders)
28
-
29
25
  if (filesAndFolders && filesAndFolders.length > 1) return filesAndFolders // skip projects
30
26
 
31
27
  const codeTransforms = {
@@ -106,12 +106,12 @@ const makeWebRequire = (filesAndFolders, options) => {
106
106
  if (entry.children) return null // directory
107
107
 
108
108
  if (extensions[baseExt]) {
109
- if(moduleCache[requirePath]) return moduleCache[requirePath]
109
+ if (moduleCache[requirePath]) return moduleCache[requirePath]
110
110
  // evaluate the content
111
111
  const matchingModule = {
112
112
  exports: {},
113
113
  _compile: (content, fileName) => {
114
- const moduleMakerFunction = new Function('require', 'module', content)
114
+ const moduleMakerFunction = new Function('require', 'module', content) // eslint-disable-line no-new-func
115
115
  moduleMakerFunction(_require.bind(null, entry.fullPath), matchingModule)
116
116
 
117
117
  const paramDefFromSource = content.includes('@jscad-params') ? getParameterDefinitionsFromSource(content, fileName) : []
@@ -123,7 +123,8 @@ const makeWebRequire = (filesAndFolders, options) => {
123
123
  }
124
124
  }
125
125
  extensions[baseExt](matchingModule, entry.fullPath)
126
- return moduleCache[requirePath] = matchingModule.exports
126
+ moduleCache[requirePath] = matchingModule.exports
127
+ return moduleCache[requirePath]
127
128
  }
128
129
  return null
129
130
  }
@@ -224,5 +224,5 @@ test('multiline error', (t) => {
224
224
  test('single line /* ...*/ ok', (t) => {
225
225
  t.deepEqual(getParameterDefinitionsFromSource(`function main({//@jscad-params
226
226
  /* group */
227
- width=14})`), [{type:'group', caption:'group', name:'_group_1'},...sampleParams2])
227
+ width=14})`), [{ type: 'group', caption: 'group', name: '_group_1' }, ...sampleParams2])
228
228
  })
@@ -13,14 +13,6 @@ const getParameterValuesFromUIControls = (paramControls, parameterDefinitions, o
13
13
  switch (control.paramType) {
14
14
  case 'choice':
15
15
  value = control.options[control.selectedIndex].value
16
- /* console.log('choice', control, control.paramName)
17
- // we try to match values against captions, then parse as numbers if applicable, then fallback to original value
18
- const valueIndex = !definition ? -1 : definition.captions.indexOf(value)
19
- const valueInDefinition = valueIndex > -1
20
- // const valueInDefintionCaptionsAndValue = valueInDefinition && definition.values.length >= valueIndex
21
- value = definition.values.length > 0 && isNumber(definition.values[0]) ? parseFloat(value) : value
22
- value = definition.values.length > 0 && typeof value === 'boolean' ? !!value : value
23
- console.log('foo', value) */
24
16
  break
25
17
  case 'float':
26
18
  case 'number':
@@ -63,7 +55,6 @@ const getParameterValuesFromUIControls = (paramControls, parameterDefinitions, o
63
55
  }
64
56
  }
65
57
  parameterValues[control.paramName] = value
66
- // console.log(control.paramName+":"+parameterValues[control.paramName])
67
58
  }
68
59
  return parameterValues
69
60
  }
@@ -30,8 +30,6 @@ const binaryMimetypes = {
30
30
  * @returns {Promise} new promise to read and convert the file
31
31
  */
32
32
  const readFileAsync = (file, fileMeta) => {
33
- // console.log('readFileAsync',file,fileMeta)
34
-
35
33
  const fullPath = file.fullPath ? file.fullPath : fileMeta.fullPath ? fileMeta.fullPath : ''
36
34
  const ext = getFileExtensionFromString(file.name)
37
35
  const mimetype = file.mimetype
@@ -43,7 +41,7 @@ const readFileAsync = (file, fileMeta) => {
43
41
  const result = event.target.result
44
42
  if (result.byteLength) {
45
43
  resolve({ name: file.name, ext, fullPath, mimetype, source: result })
46
- } else if (typeof(result) === 'string') {
44
+ } else if (typeof result === 'string') {
47
45
  resolve({ name: file.name, ext, fullPath, mimetype, source: result })
48
46
  }
49
47
  }
@@ -87,7 +85,6 @@ const isEmpty = (x) => x !== null && x !== undefined // skip empty items
87
85
  * @returns {Promise} one promise to resolve them all
88
86
  */
89
87
  const processEntries = (items) => {
90
- // console.log('processEntries',items)
91
88
  const results = pseudoArraytoArray(items.filter(isEmpty))
92
89
  .filter(isEmpty) // skip empty items
93
90
  .reduce((result, item) => {
@@ -117,7 +114,6 @@ const processEntries = (items) => {
117
114
  * @returns {Promise} new promise to read and process the file
118
115
  */
119
116
  const processFile = (fileItem) => {
120
- // console.log('processFile',fileItem)
121
117
  const promiseFile = new Promise((resolve, reject) => {
122
118
  fileItem.file(
123
119
  (fileData) => {
@@ -138,7 +134,6 @@ const processFile = (fileItem) => {
138
134
  * @returns {Promise} new promise to read and process the directory
139
135
  */
140
136
  const processDirectory = (directory) => {
141
- // console.log('processDirectory',directory)
142
137
  const promiseDirectory = new Promise((resolve, reject) => {
143
138
  if (directory.entries) {
144
139
  directory.entries.length ? processEntries(directory.entries).then(resolve) : resolve([])