From 126c2c8bc52c4ee7ada8d917570fa3f3a6a24009 Mon Sep 17 00:00:00 2001 From: Mark Moissette Date: Thu, 18 May 2017 15:14:06 +0200 Subject: [PATCH] chore(): set of changes for 0.6.0 release(2) (#258) * fix(imports): fixed openscad-openjscad translator imports * chore(CI): update versions to build against * docs(history): moved history to changelog file * chore(notes): removed dev notes * test(precision): adjusted precision of a few tests * docs(README): updated, cleaned up & fleshed out README * docs(README): more readme tweaks & fixes * docs(README): more readme tweaks * docs(README): fixed and fleshed out example, added links to live versions & code * docs(README): more fixes * docs(README): updated list of main maintainers * docs(CHANGELOG): added details about new release * refactor(): removed obsolete folder * chore(package name): adjusted package name for scope (@jscad): * changed in package.json * changed in README * fixes #261 --- .travis.yml | 4 +- CHANGELOG.md | 97 +++++++++++++++++++++++++ OpenJSCAD.org.wiki/Makefile | 10 --- OpenJSCAD.org.wiki/autoTOC | 22 ------ README.md | 136 ++++++++++++++++-------------------- package.json | 2 +- src/NOTES.md | 94 ------------------------- src/cli.js | 2 +- src/cli.test.js | 6 +- src/io/conversionWorker.js | 2 +- src/ui/editor.js | 2 +- 11 files changed, 166 insertions(+), 211 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 OpenJSCAD.org.wiki/Makefile delete mode 100755 OpenJSCAD.org.wiki/autoTOC delete mode 100644 src/NOTES.md diff --git a/.travis.yml b/.travis.yml index 6ea24dc71..29c3da5fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: - - "4.4" - - "6.9" + - "6" + - "7" sudo: false diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..fe3209840 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,97 @@ +# Change Log + +All notable changes to this project will be documented in this file. + +## 0.6.0 (2017-05-xx) +total rework of application and library structure: +- modular, smaller codebase (node.js modules) instead of monolithic files +- actual npm package, dependency managment now done correctly via package.json +- shared browser/Node.js code base +- split out CSG.js scad-api, formats handling etc to seperate repositories +- moved all repositories to the [jscad organization](https://github.com/jscad) +- default stl output is now in binary format (more efficient) +- lots more internal changes and improvements + +## 0.5.2 (2017-10-01) +updated documentation links by Z3 Dev, updated Ace editor to 1.2.4, fixed AMF export to set colors only when provided, enhanced Processor constructor to support Viewer options, added big.html to provide an example of using Processor and Viewer options, enhanced Processor to retain multiple returned objects, fixed difference() and intersection() functions for CAG by fischman + +## 0.5.1 (2016-06-27) +refactored AMF import and export, enhanced STL import by adding support for MM colors by Z3 Dev,added local storage by Robert Starkey + +## 0.5.0 (2016-05-01) + added SVG import and export, added options to Processor and View classes, allow more flexibility in HTML by Z3 Dev + +## 0.4.0 (2016-02-25) +refactored, functionality split up into more files, mostly done by Z3 Dev + +## 0.3.1 (2015-10-23) +including new parameter options by Z3 Dev + +## 0.3.0 (2015-07-02) + format.js (Stefan Baumann), and Blob.js/openjscad improved by Z3 Dev + +## 0.2.4 (2015-05-20) + renumbering, latest csg.js from http://joostn.github.com/OpenJsCad/ adapted + +## 0.024 (2015-04-08) + dev branch opened + +## 0.023 (2015-02-14) + bumping version based on openscad.js + +## 0.020 (2015-02-04) + browser window resizing done properly, thanks to Z3 devs via pull request + +## 0.019 (2015-01-07) + various pull requests from github merged again + +## 0.018 (2014-10-05) + various pull requests from github merged + +## 0.017 (2013-04-11) + alpha channel supported in color() and .setColor() + +## 0.016 (2013-04-07) + csg.js: solidFromSlices() and .setColor() on polygon level, and examples by Eduard Bespalov + +## 0.015 (2013-04-05) + rudimentary AMF export and import, web and cli + +## 0.014 (2013-04-03) + multiple files via drag & drop, developing locally + +## 0.013 (2013-04-01) + include() on web-online & drag & drop (but not off-line) and cli (server-side) + +## 0.012 (2013-03-20) + improved UI (slider from the left) + +## 0.011 (2013-03-28) + added support for rectangular_extrude(), rotate_extrude() and torus() + +## 0.010 (2013-03-22) + leave .scad file intact, and translate on-the-fly + +## 0.009 (2013-03-20) + OpenSCAD .scad syntax support included via [openscad-openjscad-translator](https://github.com/garyhodgson/openscad-openjscad-translator) module, on web and cli; and experimental .stl import support (binary & ascii) + +## 0.008 (2013-03-15) + circle(), square(), polygon() partially and linear_extrude() implemented (openscad-like) + +## 0.007 (2013-03-14) + integrating jQuery for new features; draggable hint window + +## 0.006 (2013-03-12) + included examples available in the web-frontend direct + +## 0.005 (2013-03-12) + supporting webgui parameters as of original OpenJsCad (see examples/example030.jscad) + +## 0.004 (2013-03-11) + openscad.js: many improvements, more OpenSCAD-like functions + +## 0.003 (2013-03-10) + solidify the functionality (few bug fixes) + +## 0.001 (2013-03-10) + initial version diff --git a/OpenJSCAD.org.wiki/Makefile b/OpenJSCAD.org.wiki/Makefile deleted file mode 100644 index 2c3351f40..000000000 --- a/OpenJSCAD.org.wiki/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -_Sidebar.md: User-Guide.md autoTOC Makefile - ./autoTOC < User-Guide.md > _Sidebar.md - -push:: - git remote set-url origin git@github.com:Spiritdude/OpenJSCAD.org.wiki.git - git push -u origin master - -pull:: - git remote set-url origin git@github.com:Spiritdude/OpenJSCAD.org.wiki.git - git pull -u origin master diff --git a/OpenJSCAD.org.wiki/autoTOC b/OpenJSCAD.org.wiki/autoTOC deleted file mode 100755 index 8fd28b82f..000000000 --- a/OpenJSCAD.org.wiki/autoTOC +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/perl - -print "#Table of Contents\n"; - -while(<>) { - chop; - if(/^(#+)\s*(\S.*)/) { - my($n) = length($1)-1; # -- right now ## is minimum, if you have a # only, remove '-1' - my($t) = $2; - for(my $i=0; $i<$n; $i++) { - print " "; - } - - # Web Browser & Command-Line Interface aka "Dual Use" - # web-browser--command-line-interface-aka-dual-use - $t =~ s/\s*$//; - my($l) = lc($t); - $l =~ s/[^\w -]//g; - $l =~ s/ /-/g; - print "* [$t](User-Guide#$l)\n"; - } -} diff --git a/README.md b/README.md index 6730d001c..ddde1b559 100644 --- a/README.md +++ b/README.md @@ -13,44 +13,47 @@ as well CLI (command-line interface) for server-side computations with NodeJS. ## Table of Contents -- [Installation](#installation) +- [Usage](#usage) +- [Documentation](#documentation) - [Contribute](#contribute) -- [Documentation](#Documentation) -- [Community](#Community) +- [Community](#community) - [License](#license) -- [Todo](#todo) -- [History](#History) -- [Screenshots](#Screenshots) -- [See also](#Also) +- [Screenshots](#screenshots) +- [See also](#see-also) -## Installation +## Usage ### Immediate Use (no installation) Go to *[OpenJSCAD.org](http://openjscad.org)* (Tested browsers include Chrome, Firefox, Opera, Safari) -### Use within a Web Site +### Use within a Web Site (pre built files) ``` cd base-directory-of-website git clone https://github.com/jscad/OpenJSCAD.org cd OpenJSCAD.org -NPM install + ``` And then access the contents via the URL of the web-site. + * index.html for the standard version + * viewer-minimal.html for the barebones viewer + * viewer-options.html for the 'all options' variant of the above -NOTE: The web-site may need configuration changes to allow access to the contents. +>NOTE: You might need configuration changes to allow access to the some of the contents (examples etc). ### Use as Command Line Interface (CLI) For CLI(command-line interface) use + ``` - npm install -g @jscad/OpenJSCAD.org + npm install -g @jscad/openjscad ``` -> Note: you need a recent , LTS version of [Node.js](http://nodejs.org/) > 6.x.x, -An easy way to install any Node.js version is to use [NVM](https://github.com/creationix/nvm) +> Note: you need a recent , LTS version of [Node.js](http://nodejs.org/) > 6.x.x +> An easy way to install any Node.js version is to use [NVM](https://github.com/creationix/nvm) +you can now turn the examples (or your own designs) into stl etc files as follows : ``` % cd examples/ % openjscad example005.jscad # -- creates example005.stl as default @@ -63,17 +66,17 @@ An easy way to install any Node.js version is to use [NVM](https://github.com/cr ### Use with Node Modules > Note: you need a recent , LTS version of Node.js > 6.x.x, -(see [here for more details](https://github.com/nodejs/LTS)) +[see here for more details](https://github.com/nodejs/LTS)) ``` -npm install --save @jscad/OpenJSCAD.org +npm install --save @jscad/openjscad ``` and then simply import and use openjscad: ```javascript -var jscad = require('openjscad') -var fs = require('fs') +const jscad = require('@jscad/openjscad') +const fs = require('fs') var script = `function main() { return [ @@ -105,17 +108,45 @@ fs.writeFileSync('torus.stl', outputData.asBuffer()) #### Module api -*compile(params, source)* - compile openjscad code and generates intermediate representation - ordering of parameters created with curying in mind +**compile(params, source)** + + compile OpenJsCad code and generates CSG representation + this returns a promise that gets resolved with the CSG object. + + (the ordering of parameters was created with currying in mind) + *params* the set of parameters to use - *source* the openjscad script we want to compile + *source* the OpenJsCad script we want to compile + + +**generateOutput(outputFormat, csgs)** + +generate output data from a CSG/CAG object or array of CSG/CAG objects -*generateOutput(outputFormat, csgs)* -generate output file from a CSG/CAG object or array of CSG/CAG objects *outputFormat* the output file format *csgs* the CSG/CAG object or array of CSG/CAG objects +>Note: for now you need to use outputData.asBuffer() to get a Node.js buffer for +writing to disk etc + + +### Use of the different modular components directly + +From version 0.6.0 onwards, almost all the individual parts of this project are available +directly as scoped NPM modules , and can be used independently from this repo. +The full list of these is available here: https://www.npmjs.com/org/jscad + +One example of what can be achieved with this can be found [here](https://esnextb.in/?gist=0a2ac2c4e189e27692ea964956a3a2e5) +This means you can : +- easilly create your own renderer for the CSG/Cag datastructures +- create custom UIs +- use the different parts in Node.js or the Browser +- cherry pick what formats you want to use for input/output without needing the +dependencies of **all** packages +- lots more ! + +This will be expanded upon in the future, and is the backbone of the newer, modular Jscad + ## Contribute OpenJSCAD.org is part of the JSCAD Organization, and is maintained by a group of volunteers. We welcome and encourage anyone to pitch in but please take a moment to read the following guidelines. @@ -149,62 +180,15 @@ to discuss with other user and developers. [The MIT License (MIT)](https://github.com/jscad/OpenJSCAD.org/blob/master/LICENSE) (unless specified otherwise) -## Todo - -- 3d primitive: torus() (done) -- OpenSCAD .scad support for both Web-GUI and CLI (done) -- include() for Web-GUI and CLI to include libraries and modules, support of multiple .jscad drag & drop with include() (done) -- save from built-in editor to local (done) -- complete 2D primitives and transformations (done) -- implementation of linear_extrude() rotate_extrude(), parameter compatible to OpenSCAD (done) -- example of platonic solids (in progress, requires include()) (done) -- simple 2D/3D text (done) -- 2d operation: hull() (done) -- processing/progress bar (0..100%), perhaps even visual progress seen in the model direct -- STL importer (done) & AMF importer / exporter -- integration into (RepRapCloud)[https://github.com/Spiritdude/RepRapCloud] as first stage of the workflow - -## History - -- 2016/04/29: 0.6.0: total rework of application and library structure -- 2016/10/01: 0.5.2: updated documentation links by Z3 Dev, updated Ace editor to 1.2.4, fixed AMF export to set colors only when provided, enhanced Processor constructor to support Viewer options, added big.html to provide an example of using Processor and Viewer options, enhanced Processor to retain multiple returned objects, fixed difference() and intersection() functions for CAG by fischman -- 2016/06/27: 0.5.1: refactored AMF import and export, enhanced STL import by adding support for MM colors by Z3 Dev,added local storage by Robert Starkey -- 2016/05/01: 0.5.0: added SVG import and export, added options to Processor and View classes, allow more flexibility in HTML by Z3 Dev -- 2016/02/25: 0.4.0: refactored, functionality split up into more files, mostly done by Z3 Dev -- 2015/10/23: 0.3.1: including new parameter options by Z3 Dev -- 2015/07/02: 0.3.0: format.js (Stefan Baumann), and Blob.js/openjscad improved by Z3 Dev -- 2015/05/20: 0.2.4: renumbering, latest csg.js from http://joostn.github.com/OpenJsCad/ adapted -- 2015/04/08: 0.024: dev branch opened -- 2015/02/14: 0.023: bumping version based on openscad.js -- 2015/02/04; 0.020: browser window resizing done properly, thanks to Z3 devs via pull request -- 2015/01/07: 0.019: various pull requests from github merged again -- 2014/10/05: 0.018: various pull requests from github merged -- 2013/04/11: 0.017: alpha channel supported in color() and .setColor() -- 2013/04/07: 0.016: csg.js: solidFromSlices() and .setColor() on polygon level, and examples by Eduard Bespalov -- 2013/04/05: 0.015: rudimentary AMF export and import, web and cli -- 2013/04/03: 0.014: multiple files via drag & drop, developing locally -- 2013/04/01: 0.013: include() on web-online & drag & drop (but not off-line) and cli (server-side) -- 2013/03/20: 0.012: improved UI (slider from the left) -- 2013/03/28: 0.011: added support for rectangular_extrude(), rotate_extrude() and torus() -- 2013/03/22: 0.010: leave .scad file intact, and translate on-the-fly -- 2013/03/20: 0.009: OpenSCAD .scad syntax support included via [openscad-openjscad-translator](https://github.com/garyhodgson/openscad-openjscad-translator) module, on web and cli; and experimental .stl import support (binary & ascii) -- 2013/03/15: 0.008: circle(), square(), polygon() partially and linear_extrude() implemented (openscad-like) -- 2013/03/14: 0.007: integrating jQuery for new features; draggable hint window -- 2013/03/12: 0.006: included examples available in the web-frontend direct -- 2013/03/12: 0.005: supporting webgui parameters as of original OpenJsCad (see examples/example030.jscad) -- 2013/03/11: 0.004: openscad.js: many improvements, more OpenSCAD-like functions -- 2013/03/10: 0.003: solidify the functionality (few bug fixes) -- 2013/03/10: 0.001: initial version - ## Screenshots -Simple JSCAD example (example000.jscad): +Simple JSCAD example ([logo.jscad](examples/logo.jscad)) [try it](http://openjscad.org/#examples/logo.jscad): -More sophisticated JSCAD example, fully object-oriented (OO) programmed with interactive parameters (example031.jscad): +More sophisticated JSCAD example, with functions dedicated to object generation and with interactive parameters ([gear.jscad](examples/gear.jscad)) [try it](http://openjscad.org/#examples/gear.jscad) : -Import of STL models: +Import of STL models ([frog-OwenCollins.stl](examples/frog-OwenCollins.stl)) [try it](http://openjscad.org/#examples/frog-OwenCollins.stl): Drag & drop a local file: @@ -217,10 +201,10 @@ Drag & drop multiple files (Chrome & Firefox) or a folder (Chrome): - [OpenJsCAD](http://joostn.github.com/OpenJsCad/), starting point of OpenJSCAD.org - [OpenSCAD.net](http://garyhodgson.github.com/openscad.net/), another place of inspiration, where the OpenSCAD translator was adapted from -- [CoffeeSCad](http://kaosat-dev.github.com/CoffeeSCad/), JavaScript simplified (no more {}), very active development +- [CoffeeSCad](http://kaosat-dev.github.com/CoffeeSCad/), JavaScript simplified (no more {}) (defunct) - [stl2pov](http://rsmith.home.xs4all.nl/software/py-stl-stl2pov.htmltool) to convert .stl to .pov, and then render via [PovRay.org](http://povray.org) - [P3D](https://github.com/D1plo1d/p3d) STL/AMF/OBJ viewer That's all for now, -Rene K. Mueller & JSCAD Organization +Rene K. Mueller, Jeff Gay, Mark Moissette & JSCAD Organization diff --git a/package.json b/package.json index 7a74a3401..ef287a671 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "openjscad", + "name": "@jscad/openjscad", "version": "0.6.0", "description": "", "repository": "https://github.com/Spiritdude/OpenJSCAD.org", diff --git a/src/NOTES.md b/src/NOTES.md deleted file mode 100644 index a2c54b581..000000000 --- a/src/NOTES.md +++ /dev/null @@ -1,94 +0,0 @@ -#what works and what does not - -##what does not : - -- global file cache: gMemFs : still trying to refactor it into a reuseable system, this is the last actual remain of the "globals" -- not entirely sure about the "REMOTE" functionality: should work , but needs testing -- some parts of drag & drop - -##What does : -- everything else ! - - UI - - examples - - all format handling in & out - - background & main worker - - new CLI & use as a node module - - installation of OpenJSCAD globally to enable using the openjscad command line tool IN A CLEAN manner - (no more need to hacks and manual install via make file) - - installation locally to use as module - - code sharing between web & module & CLI is complete - - openscad-openjscad-translator: updated & browserified - -#note on transpiling: ie convert from one flavor of JS to another: - -- the code now uses a lot of es6/es2015 features (NO fancy/ uncertain ones), which are getting -slowly put into browsers & node above 94 % in most browsers (https://kangax.github.io/compat-table/es6/) -- we want users with "older" browsers and node versions to be able to use feature -- so we 'transpile' ie transform the newer features into ones compatible with older platforms -- we also target two main "platforms" - * the web ,via workerify : we generate one single bundle (either 'live': ie regenerated as you change the code or pre bundled) : - * => OUTPUT IS A SINGLE file (index.js) see package.json 'build-web' or 'start-dev' commands - * node.js either CLI or modules : the 'dist' folder contains the transpiled version of the source code - * => OUTPUT IS a single file bundle for server side use : one for the CLI & one for the use as 'module' - -#file managment mind map - -On startup - urlParams => loadSomething - localStorage => loadSomething OR current code ??? - -Drag & drop: - => chrome only? - Observe file changes => reload - Observe folder changes => display ui with reload & autoreload button & toggle - - => saveScript :caches file name & source (BEFORE conversion) - - => walkFileTree - core of the drag'n'drop: - 1) walk the tree - 2) read the files (readFileAsync) - 3) re-render if there was a change (via readFileAsync) - - => parseFile - => saveScript (original name & source) - => uses conversionWorker - => after conversion - => putSourceInEditor - => saveScript - => gProcessor.setJsCad - - - => readFileAsync - => setCurrentFile: USED ONCE (set one file (the one dragged) or main.jscad) - => fileChanged: USED ONCE (update the dropzone visual & call the main parser) - => parseFile: USED ONCE - - => loadLocalFiles (when folders are not supported) - => readFileAsync - - => superviseAllFiles (file/folder watcher) - => readFileAsync OR walkFileTree - - => handleInputFiles - => loadLocalFiles - - => handleFileSelect - => walkFileTree OR loadLocalFiles - - - -DRAG & DROP entry points : - dropZone => - fileInput => - - -memFsCount ONLY incremented and compared and use in readFileAsync -memFsChanged ONLY used in readFileAsync AND superviseAllFiles - -conversionWorker - => DONE - -#imports thoughts - -importGeometry needs access to 'memFs' / local fs diff --git a/src/cli.js b/src/cli.js index 24c757121..2f7536069 100644 --- a/src/cli.js +++ b/src/cli.js @@ -66,7 +66,7 @@ let src = fs.readFileSync(inputFile, inputFile.match(/\.stl$/i) ? 'binary' : 'UT if(inputFormat === 'scad') { - var scadParser = require('openscad-openjscad-translator') // hardcoded is bad, but works + var scadParser = require('@jscad/openscad-openjscad-translator') // hardcoded is bad, but works src = scadParser.parse(src) // doing the magick src = '// producer: OpenJSCAD ' + version + '\n' + src src = '// source: ' + outputFile + '\n\n' + src diff --git a/src/cli.test.js b/src/cli.test.js index 3813473f6..7dbf5e7cc 100644 --- a/src/cli.test.js +++ b/src/cli.test.js @@ -113,7 +113,7 @@ test('openscad to stl (ascii)', t => { const cmd = `node ${jscadPath} ${inputPath} -o ${outputPath} -of stla` execSync(cmd, {stdio: [0, 1, 2]}) t.deepEqual(true, fs.existsSync(expPath)) - almostEquals(t, fs.statSync(outputPath).size, 515365, 2) + almostEquals(t, fs.statSync(outputPath).size, 515365, 100) }) test('openscad to stl(binary)', t => { @@ -140,7 +140,7 @@ test('openscad to amf', t => { const cmd = `node ${jscadPath} ${inputPath} -o ${outputPath} -of amf` execSync(cmd, {stdio: [0, 1, 2]}) t.deepEqual(true, fs.existsSync(expPath)) - almostEquals(t, fs.statSync(outputPath).size, 554963, 2) + almostEquals(t, fs.statSync(outputPath).size, 554963, 60) }) test('openscad to openjscad', t => { @@ -180,7 +180,7 @@ test('include support', t => { const cmd = `node ${jscadPath} ${inputPath} -o ${outputPath} -of stla` execSync(cmd, {stdio: [0, 1, 2]}) t.deepEqual(true, fs.existsSync(expPath)) - almostEquals(t, fs.statSync(outputPath).size, 19681, 2) + almostEquals(t, fs.statSync(outputPath).size, 19681, 60) }) test('include support, with sub folders', t => { diff --git a/src/io/conversionWorker.js b/src/io/conversionWorker.js index 43d0a66d3..5141ae4c8 100644 --- a/src/io/conversionWorker.js +++ b/src/io/conversionWorker.js @@ -61,7 +61,7 @@ module.exports = function (self) { if (!r.source.match(/^\/\/!OpenSCAD/i)) { r.source = '//!OpenSCAD\n' + data.source } - const openscadOpenJscadParser = require('openscad-openjscad-translator') + const openscadOpenJscadParser = require('@jscad/openscad-openjscad-translator') r.converted = openscadOpenJscadParser.parse(r.source) break case 'stl': diff --git a/src/ui/editor.js b/src/ui/editor.js index d3576a5e5..c157a0e2d 100644 --- a/src/ui/editor.js +++ b/src/ui/editor.js @@ -18,7 +18,7 @@ require('brace/mode/javascript') require('brace/mode/scad') require('brace/theme/chrome') -const openscadOpenJscadParser = require('openscad-openjscad-translator') +const openscadOpenJscadParser = require('@jscad/openscad-openjscad-translator') // See http://ace.ajax.org/#nav=howto function setUpEditor (divname, gProcessor) {