jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.65k stars 514 forks source link

feat(io): rework io package to incorporate 'core' serialize and deserialize functions #1187

Closed z3dev closed 1 year ago

z3dev commented 1 year ago

These changes rework the 'io' package to expose to new functions; deserialize() and serialize(). Previously, these functions were mashed into CLI / CORE / WEB packages as different functions returning different things. These are part of the new building blocks for applications.

Test suites were added to make sure the new functions work as expected.

In support of the new function, the deserializers and serializers have been modified to export mimeType and de/serialize functions. By using mimeType, users can quickly convert to any desired format.

An additional utility function was added to assist users to find the correct mime type using an extension; getMimeType()

All Submissions:

z3dev commented 1 year ago

@platypii please review. this is part of the reorg of packages. io needs to stand alone, and provide both serialize and deserialize functionality. previously, these functions were mashed into CLI and CORE code. these changes try to expose an easy API to do the same, via one package; io

z3dev commented 1 year ago

@hrgdavor please review. i'm wondering if the new deserialize() and serialize() functions will help with the new WEB UI. i hope so. all feedback is welcome.

z3dev commented 1 year ago

@platypii what do you think about moving this to another namespace? i've been wondering how to reorg the current 'core' package, and think that some smaller packages for parameters, fake file system, loading, io, etc. should be created.

this 'io' package really feels like 'core-io' now, creating the glue between APPS and IO libraries

z3dev commented 1 year ago

As far as moving to another package, I don't have a strong opinion on that. I've never really liked "core" because it's not clear exactly what that means. I think the serialize/deserialize makes sense in IO package. I don't want to have a million tiny packages, I think its better to have a couple well defined standalone packages. 🤷‍♂️

Ok. Let me ask this... are any functions in io-utils out of place? I think some of those would be better inside this package. And make io-utils retain with only common utility functions.

z3dev commented 1 year ago

@hrgdavor @platypii please review again

the getExtension(mimeType) function was added

several mime types were corrected to match those of the IANA media types, which has replaced mime types in the exchange of data.

https://www.iana.org/assignments/media-types/media-types.xhtml