@jscad/json-deserializer 3.0.0-alpha.0 → 3.0.2-alpha.0
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 +15 -0
- package/LICENSE +1 -1
- package/dist/jscad-json-deserializer.es.js +3 -3
- package/dist/jscad-json-deserializer.min.js +3 -3
- package/package.json +5 -4
- package/rollup.config.js +1 -1
- package/src/index.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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
|
+
## [3.0.2-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@3.0.1-alpha.0...@jscad/json-deserializer@3.0.2-alpha.0) (2025-09-06)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @jscad/json-deserializer
|
|
9
|
+
|
|
10
|
+
## [3.0.1-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.23...@jscad/json-deserializer@3.0.1-alpha.0) (2025-01-03)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **io:** fix io after V3 refactoring ([7a12bbd](https://github.com/jscad/OpenJSCAD.org/commit/7a12bbdb7b4b3df792a4c5b3c8b30a6a985a48f0))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **modeling:** reworked exports to expose a flattened API ([8235238](https://github.com/jscad/OpenJSCAD.org/commit/8235238ad63d063f1e501478cae1208deb130a9c))
|
|
19
|
+
* **regl-renderer:** added rollup configuration to create ES6 bundle, adjusted imports and exports ([#1259](https://github.com/jscad/OpenJSCAD.org/issues/1259)) ([47a66bc](https://github.com/jscad/OpenJSCAD.org/commit/47a66bc07a137a748ce8571ea5d043ebaab9418d))
|
|
20
|
+
|
|
6
21
|
# [3.0.0-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.23...@jscad/json-deserializer@3.0.0-alpha.0) (2023-10-09)
|
|
7
22
|
|
|
8
23
|
### Bug Fixes
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
The MIT License (MIT)
|
|
3
3
|
|
|
4
|
-
Copyright (c) 2017-
|
|
4
|
+
Copyright (c) 2017-2025 JSCAD Organization
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Deserializer for JSCAD
|
|
3
3
|
* @module @jscad/json-deserializer
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.2-alpha.0
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* JSCAD Utility functions for arrays
|
|
9
9
|
* @module @jscad/array-utils
|
|
10
|
-
* @version 3.0.
|
|
10
|
+
* @version 3.0.1-alpha.0
|
|
11
11
|
* @license MIT
|
|
12
12
|
*/
|
|
13
|
-
const flatten=arr=>arr.reduce(((acc,val)=>Array.isArray(val)?acc.concat(flatten(val)):acc.concat(val)),[]),deserialize=(options,input)=>{const defaults={filename:"json",output:"script",version:"3.0.
|
|
13
|
+
const flatten=arr=>arr.reduce(((acc,val)=>Array.isArray(val)?acc.concat(flatten(val)):acc.concat(val)),[]),deserialize=(options,input)=>{const defaults={filename:"json",output:"script",version:"3.0.2-alpha.0",addMetaData:!0};options=Object.assign({},defaults,options),input=((stringOrArrayBuffer,defaultBinaryEncoding="utf-8")=>"string"==typeof stringOrArrayBuffer?stringOrArrayBuffer:new TextDecoder(defaultBinaryEncoding).decode(new Uint8Array(stringOrArrayBuffer)))(input);let objects=JSON.parse(input);var array;return objects=flatten((array=objects,Array.isArray(array)?array:null==array?[]:[array])),"script"===options.output?translate(options,objects):objects},translate=(options,objects)=>{const{addMetaData:addMetaData,filename:filename,version:version}=options;let script=addMetaData?`//\n// Produced by JSCAD IO Library : JSON Deserializer (${version})\n// date: ${new Date}\n// source: ${filename}\n//\n`:"";return script+=`\nconst { geometries } = require('@jscad/modeling')\n\nconst main = () => {\n const objects = [${translateToList(objects)} ]\n return objects\n}\n\n${translateToObjects(objects)}\n\nmodule.exports = { main }\n`,script},translateToList=objects=>objects.reduce(((script,object,index)=>script+` json${index},`),""),translateToObjects=objects=>objects.reduce(((script,object,index)=>script+translateToObject(object,index)),""),translateToObject=(object,index)=>`const json${index} = ${JSON.stringify(object)}\n`,mimeType="application/json";export{deserialize,mimeType};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* JSON Deserializer for JSCAD
|
|
3
3
|
* @module @jscad/json-deserializer
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.2-alpha.0
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
7
|
var global,factory;global=this,factory=function(exports){
|
|
8
8
|
/**
|
|
9
9
|
* JSCAD Utility functions for arrays
|
|
10
10
|
* @module @jscad/array-utils
|
|
11
|
-
* @version 3.0.
|
|
11
|
+
* @version 3.0.1-alpha.0
|
|
12
12
|
* @license MIT
|
|
13
13
|
*/
|
|
14
|
-
const flatten=arr=>arr.reduce(((acc,val)=>Array.isArray(val)?acc.concat(flatten(val)):acc.concat(val)),[]),translate=(options,objects)=>{const{addMetaData:addMetaData,filename:filename,version:version}=options;let script=addMetaData?`//\n// Produced by JSCAD IO Library : JSON Deserializer (${version})\n// date: ${new Date}\n// source: ${filename}\n//\n`:"";return script+=`\nconst { geometries } = require('@jscad/modeling')\n\nconst main = () => {\n const objects = [${translateToList(objects)} ]\n return objects\n}\n\n${translateToObjects(objects)}\n\nmodule.exports = { main }\n`,script},translateToList=objects=>objects.reduce(((script,object,index)=>script+` json${index},`),""),translateToObjects=objects=>objects.reduce(((script,object,index)=>script+translateToObject(object,index)),""),translateToObject=(object,index)=>`const json${index} = ${JSON.stringify(object)}\n`;exports.deserialize=(options,input)=>{const defaults={filename:"json",output:"script",version:"3.0.
|
|
14
|
+
const flatten=arr=>arr.reduce(((acc,val)=>Array.isArray(val)?acc.concat(flatten(val)):acc.concat(val)),[]),translate=(options,objects)=>{const{addMetaData:addMetaData,filename:filename,version:version}=options;let script=addMetaData?`//\n// Produced by JSCAD IO Library : JSON Deserializer (${version})\n// date: ${new Date}\n// source: ${filename}\n//\n`:"";return script+=`\nconst { geometries } = require('@jscad/modeling')\n\nconst main = () => {\n const objects = [${translateToList(objects)} ]\n return objects\n}\n\n${translateToObjects(objects)}\n\nmodule.exports = { main }\n`,script},translateToList=objects=>objects.reduce(((script,object,index)=>script+` json${index},`),""),translateToObjects=objects=>objects.reduce(((script,object,index)=>script+translateToObject(object,index)),""),translateToObject=(object,index)=>`const json${index} = ${JSON.stringify(object)}\n`;exports.deserialize=(options,input)=>{const defaults={filename:"json",output:"script",version:"3.0.2-alpha.0",addMetaData:!0};options=Object.assign({},defaults,options),input=((stringOrArrayBuffer,defaultBinaryEncoding="utf-8")=>"string"==typeof stringOrArrayBuffer?stringOrArrayBuffer:new TextDecoder(defaultBinaryEncoding).decode(new Uint8Array(stringOrArrayBuffer)))(input);let objects=JSON.parse(input);var array;return objects=flatten((array=objects,Array.isArray(array)?array:null==array?[]:[array])),"script"===options.output?translate(options,objects):objects},exports.mimeType="application/json",Object.defineProperty(exports,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).jscadJsonDeserializer={});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/json-deserializer",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2-alpha.0",
|
|
4
4
|
"description": "JSON Deserializer for JSCAD",
|
|
5
5
|
"homepage": "https://openjscad.xyz/",
|
|
6
6
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
@@ -33,10 +33,11 @@
|
|
|
33
33
|
],
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@jscad/array-utils": "3.0.
|
|
36
|
+
"@jscad/array-utils": "3.0.1-alpha.0",
|
|
37
|
+
"@jscad/io-utils": "3.0.2-alpha.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@jscad/modeling": "3.0.
|
|
40
|
+
"@jscad/modeling": "3.0.2-alpha.0",
|
|
40
41
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
41
42
|
"@rollup/plugin-terser": "^0.4.3",
|
|
42
43
|
"ava": "^4.3.3",
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"rollup-plugin-banner": "^0.2.1",
|
|
46
47
|
"rollup-plugin-version-injector": "^1.3.3"
|
|
47
48
|
},
|
|
48
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "ac80d1a7cb0a8efb21aff9193d4a8bccb6e31f1c"
|
|
49
50
|
}
|
package/rollup.config.js
CHANGED
|
@@ -22,6 +22,6 @@ export default {
|
|
|
22
22
|
nodeResolve(),
|
|
23
23
|
banner('<%= pkg.description %>\n@module <%= pkg.name %>\n@version <%= pkg.version %>\n@license <%= pkg.license %>'),
|
|
24
24
|
versionInjector({ injectInComments: { fileRegexp: /\.(html)$/ }, logLevel: 'warn' }),
|
|
25
|
-
terser({ compress: { module: true }, mangle: false, format: { comments: 'some'} })
|
|
25
|
+
terser({ compress: { module: true }, mangle: false, format: { comments: 'some' } })
|
|
26
26
|
]
|
|
27
27
|
}
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { flatten, toArray } from '@jscad/array-utils'
|
|
17
|
+
import { ensureString } from '@jscad/io-utils'
|
|
17
18
|
|
|
18
19
|
const version = '[VI]{version}[/VI]' // version is injected by rollup
|
|
19
20
|
|
|
@@ -38,6 +39,7 @@ const deserialize = (options, input) => {
|
|
|
38
39
|
options = Object.assign({}, defaults, options)
|
|
39
40
|
|
|
40
41
|
// convert the JSON notation into anonymous object(s)
|
|
42
|
+
input = ensureString(input);
|
|
41
43
|
let objects = JSON.parse(input)
|
|
42
44
|
|
|
43
45
|
// cleanup the objects
|