@jscad/json-deserializer 2.0.26 → 3.0.0-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 +9 -177
- package/README.md +3 -1
- package/dist/jscad-json-deserializer.es.js +13 -0
- package/dist/jscad-json-deserializer.min.js +14 -0
- package/package.json +21 -11
- package/rollup.config.js +27 -0
- package/{index.js → src/index.js} +7 -14
- package/tests/instantiate.test.js +16 -16
- package/tests/translate.test.js +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,319 +3,175 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @jscad/json-deserializer
|
|
6
|
+
# [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)
|
|
9
7
|
|
|
8
|
+
### Bug Fixes
|
|
10
9
|
|
|
10
|
+
* **io:** fix io after V3 refactoring ([7a12bbd](https://github.com/jscad/OpenJSCAD.org/commit/7a12bbdb7b4b3df792a4c5b3c8b30a6a985a48f0))
|
|
11
11
|
|
|
12
|
+
### Features
|
|
12
13
|
|
|
14
|
+
* **modeling:** reworked exports to expose a flattened API ([8235238](https://github.com/jscad/OpenJSCAD.org/commit/8235238ad63d063f1e501478cae1208deb130a9c))
|
|
15
|
+
* **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))
|
|
13
16
|
|
|
14
|
-
## [2.0.
|
|
17
|
+
## [2.0.26](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.25...@jscad/json-deserializer@2.0.26) (2023-06-27)
|
|
15
18
|
|
|
16
19
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
17
20
|
|
|
21
|
+
## [2.0.25](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.24...@jscad/json-deserializer@2.0.25) (2023-04-30)
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
**Note:** Version bump only for package @jscad/json-deserializer
|
|
21
24
|
|
|
22
25
|
## [2.0.24](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.23...@jscad/json-deserializer@2.0.24) (2022-11-26)
|
|
23
26
|
|
|
24
27
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
29
|
## [2.0.23](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.22...@jscad/json-deserializer@2.0.23) (2022-08-21)
|
|
31
30
|
|
|
32
31
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
33
|
## [2.0.22](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.21...@jscad/json-deserializer@2.0.22) (2022-07-17)
|
|
39
34
|
|
|
40
35
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
37
|
## [2.0.21](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.20...@jscad/json-deserializer@2.0.21) (2022-06-12)
|
|
47
38
|
|
|
48
39
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
41
|
## [2.0.20](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.19...@jscad/json-deserializer@2.0.20) (2022-05-15)
|
|
55
42
|
|
|
56
43
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
57
44
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
45
|
## [2.0.19](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.18...@jscad/json-deserializer@2.0.19) (2022-04-24)
|
|
63
46
|
|
|
64
47
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
65
48
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
49
|
## [2.0.18](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.17...@jscad/json-deserializer@2.0.18) (2022-04-03)
|
|
71
50
|
|
|
72
51
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
73
52
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
53
|
## [2.0.17](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.16...@jscad/json-deserializer@2.0.17) (2022-04-03)
|
|
79
54
|
|
|
80
55
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
81
56
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
57
|
## [2.0.16](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.15...@jscad/json-deserializer@2.0.16) (2022-03-13)
|
|
87
58
|
|
|
88
59
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
89
60
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
61
|
## [2.0.15](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.14...@jscad/json-deserializer@2.0.15) (2022-03-06)
|
|
95
62
|
|
|
96
63
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
97
64
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
65
|
## [2.0.14](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.13...@jscad/json-deserializer@2.0.14) (2022-02-19)
|
|
103
66
|
|
|
104
67
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
105
68
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
69
|
## [2.0.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.12...@jscad/json-deserializer@2.0.13) (2021-12-26)
|
|
111
70
|
|
|
112
71
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
113
72
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
73
|
## [2.0.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.11...@jscad/json-deserializer@2.0.12) (2021-12-11)
|
|
119
74
|
|
|
120
75
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
121
76
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
77
|
## [2.0.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.10...@jscad/json-deserializer@2.0.11) (2021-11-07)
|
|
127
78
|
|
|
128
79
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
129
80
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
81
|
## [2.0.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.9...@jscad/json-deserializer@2.0.10) (2021-10-17)
|
|
135
82
|
|
|
136
83
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
137
84
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
85
|
## [2.0.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.8...@jscad/json-deserializer@2.0.9) (2021-10-04)
|
|
143
86
|
|
|
144
87
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
145
88
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
89
|
## [2.0.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.7...@jscad/json-deserializer@2.0.8) (2021-09-27)
|
|
151
90
|
|
|
152
91
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
153
92
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
93
|
## [2.0.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.6...@jscad/json-deserializer@2.0.7) (2021-09-09)
|
|
159
94
|
|
|
160
95
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
161
96
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
97
|
## [2.0.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.5...@jscad/json-deserializer@2.0.6) (2021-06-20)
|
|
167
98
|
|
|
168
99
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
169
100
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
101
|
## [2.0.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.4...@jscad/json-deserializer@2.0.5) (2021-06-11)
|
|
175
102
|
|
|
176
103
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
177
104
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
105
|
## [2.0.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.3...@jscad/json-deserializer@2.0.4) (2021-06-01)
|
|
183
106
|
|
|
184
107
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
185
108
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
109
|
## [2.0.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.2...@jscad/json-deserializer@2.0.3) (2021-04-20)
|
|
191
110
|
|
|
192
111
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
193
112
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
113
|
## [2.0.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.0...@jscad/json-deserializer@2.0.2) (2021-04-17)
|
|
199
114
|
|
|
200
|
-
|
|
201
115
|
### Bug Fixes
|
|
202
116
|
|
|
203
117
|
* **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
|
|
204
118
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
119
|
## [2.0.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.0...@jscad/json-deserializer@2.0.1) (2021-04-15)
|
|
210
120
|
|
|
211
|
-
|
|
212
121
|
### Bug Fixes
|
|
213
122
|
|
|
214
123
|
* **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
|
|
215
124
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
125
|
# [2.0.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.11...@jscad/json-deserializer@2.0.0) (2021-04-12)
|
|
221
126
|
|
|
222
127
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
223
128
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
129
|
# [2.0.0-alpha.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.10...@jscad/json-deserializer@2.0.0-alpha.11) (2021-03-07)
|
|
229
130
|
|
|
230
131
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
231
132
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
133
|
# [2.0.0-alpha.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.9...@jscad/json-deserializer@2.0.0-alpha.10) (2021-02-07)
|
|
237
134
|
|
|
238
135
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
239
136
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
137
|
# [2.0.0-alpha.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.8...@jscad/json-deserializer@2.0.0-alpha.9) (2021-01-02)
|
|
245
138
|
|
|
246
139
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
247
140
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
141
|
# [2.0.0-alpha.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.7...@jscad/json-deserializer@2.0.0-alpha.8) (2020-12-04)
|
|
253
142
|
|
|
254
143
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
255
144
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
145
|
# [2.0.0-alpha.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.6...@jscad/json-deserializer@2.0.0-alpha.7) (2020-11-07)
|
|
261
146
|
|
|
262
147
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
263
148
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
149
|
# [2.0.0-alpha.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.5...@jscad/json-deserializer@2.0.0-alpha.6) (2020-10-11)
|
|
269
150
|
|
|
270
|
-
|
|
271
151
|
### Bug Fixes
|
|
272
152
|
|
|
273
153
|
* **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
|
|
274
154
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
155
|
# [2.0.0-alpha.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.4...@jscad/json-deserializer@2.0.0-alpha.5) (2020-09-29)
|
|
280
156
|
|
|
281
157
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
282
158
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
159
|
# [2.0.0-alpha.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.3...@jscad/json-deserializer@2.0.0-alpha.4) (2020-09-28)
|
|
288
160
|
|
|
289
161
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
290
162
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
163
|
# [2.0.0-alpha.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.2...@jscad/json-deserializer@2.0.0-alpha.3) (2020-09-19)
|
|
296
164
|
|
|
297
165
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
298
166
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
167
|
# [2.0.0-alpha.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.1...@jscad/json-deserializer@2.0.0-alpha.2) (2020-09-08)
|
|
304
168
|
|
|
305
169
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
306
170
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
171
|
# [2.0.0-alpha.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-deserializer@2.0.0-alpha.0...@jscad/json-deserializer@2.0.0-alpha.1) (2020-08-19)
|
|
312
172
|
|
|
313
173
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
314
174
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
175
|
# 2.0.0-alpha.0 (2020-08-13)
|
|
320
176
|
|
|
321
177
|
### Features
|
|
@@ -323,60 +179,36 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
323
179
|
* **json-deserializer:** Upgrade/overhaul JSON Deserializer for V2
|
|
324
180
|
* **io:** change api to deserialize(options, source)
|
|
325
181
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
182
|
<a name="0.1.2"></a>
|
|
331
183
|
## [0.1.2](https://github.com/jscad/io/compare/@jscad/json-deserializer@0.1.1...@jscad/json-deserializer@0.1.2) (2018-09-02)
|
|
332
184
|
|
|
333
|
-
|
|
334
185
|
### Bug Fixes
|
|
335
186
|
|
|
336
187
|
* **svg deserializer:** fixed svg-deserializer to work with Inkscape files ([#72](https://github.com/jscad/io/issues/72)) ([f35ea5e](https://github.com/jscad/io/commit/f35ea5e))
|
|
337
188
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
189
|
<a name="0.1.1"></a>
|
|
342
190
|
## [0.1.1](https://github.com/jscad/io/compare/@jscad/json-deserializer@0.1.0...@jscad/json-deserializer@0.1.1) (2017-12-14)
|
|
343
191
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
192
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
348
193
|
|
|
349
194
|
<a name="0.1.0"></a>
|
|
350
195
|
# [0.1.0](https://github.com/jscad/io/compare/@jscad/json-deserializer@0.0.4...@jscad/json-deserializer@0.1.0) (2017-11-29)
|
|
351
196
|
|
|
352
|
-
|
|
353
197
|
### Features
|
|
354
198
|
|
|
355
199
|
* add support for a status callback for de/serialization progress ([#49](https://github.com/jscad/io/issues/49)) ([f457cdb](https://github.com/jscad/io/commit/f457cdb))
|
|
356
200
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
201
|
<a name="0.0.4"></a>
|
|
361
202
|
## [0.0.4](https://github.com/jscad/io/compare/@jscad/json-deserializer@0.0.3...@jscad/json-deserializer@0.0.4) (2017-11-04)
|
|
362
203
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
204
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
367
205
|
|
|
368
206
|
<a name="0.0.3"></a>
|
|
369
207
|
## [0.0.3](https://github.com/jscad/io/compare/@jscad/json-deserializer@0.0.2...@jscad/json-deserializer@0.0.3) (2017-10-10)
|
|
370
208
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
209
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
375
210
|
|
|
376
211
|
<a name="0.0.2"></a>
|
|
377
212
|
## 0.0.2 (2017-10-10)
|
|
378
213
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
214
|
**Note:** Version bump only for package @jscad/json-deserializer
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](https://github.com/jscad/OpenJSCAD.org/blob/master/LICENSE)
|
|
10
10
|
|
|
11
11
|
[](https://openjscad.nodebb.com/)
|
|
12
|
-
[](https://github.com/ghiscoding/lerna-lite)
|
|
13
13
|
[](https://standardjs.com)
|
|
14
14
|
|
|
15
15
|
[](https://opencollective.com/openjscad)
|
|
@@ -63,5 +63,7 @@ Small Note: If editing this README, please conform to the [standard-readme](http
|
|
|
63
63
|
|
|
64
64
|
## License
|
|
65
65
|
|
|
66
|
+
Copyright (c) JSCAD Organization
|
|
67
|
+
|
|
66
68
|
[The MIT License (MIT)](../../LICENSE)
|
|
67
69
|
(unless specified otherwise)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Deserializer for JSCAD
|
|
3
|
+
* @module @jscad/json-deserializer
|
|
4
|
+
* @version 3.0.0-alpha.0
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* JSCAD Utility functions for arrays
|
|
9
|
+
* @module @jscad/array-utils
|
|
10
|
+
* @version 3.0.0-alpha.0
|
|
11
|
+
* @license MIT
|
|
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.0-alpha.0",addMetaData:!0};options=Object.assign({},defaults,options);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};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Deserializer for JSCAD
|
|
3
|
+
* @module @jscad/json-deserializer
|
|
4
|
+
* @version 3.0.0-alpha.0
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
var global,factory;global=this,factory=function(exports){
|
|
8
|
+
/**
|
|
9
|
+
* JSCAD Utility functions for arrays
|
|
10
|
+
* @module @jscad/array-utils
|
|
11
|
+
* @version 3.0.0-alpha.0
|
|
12
|
+
* @license MIT
|
|
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.0-alpha.0",addMetaData:!0};options=Object.assign({},defaults,options);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,22 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/json-deserializer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"description": "JSON Deserializer for JSCAD",
|
|
5
5
|
"homepage": "https://openjscad.xyz/",
|
|
6
6
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
7
|
-
"
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"unpkg": "dist/jscad-json-deserializer.min.js",
|
|
10
|
+
"module": "dist/jscad-json-deserializer.es.js",
|
|
8
11
|
"scripts": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
12
|
+
"build": "rollup --config",
|
|
13
|
+
"coverage": "c8 --all --reporter=html --reporter=text pnpm test",
|
|
14
|
+
"test": "ava 'tests/*.test.js' --verbose --timeout 2m",
|
|
15
|
+
"version": "pnpm run build && git add dist"
|
|
11
16
|
},
|
|
12
17
|
"contributors": [
|
|
13
18
|
{
|
|
14
19
|
"name": "z3dev",
|
|
15
|
-
"url": "
|
|
20
|
+
"url": "https://github.com/z3dev"
|
|
16
21
|
},
|
|
17
22
|
{
|
|
18
23
|
"name": "Mark 'kaosat-dev' Moissette",
|
|
19
|
-
"url": "
|
|
24
|
+
"url": "https://github.com/kaosat-dev"
|
|
20
25
|
}
|
|
21
26
|
],
|
|
22
27
|
"keywords": [
|
|
@@ -28,12 +33,17 @@
|
|
|
28
33
|
],
|
|
29
34
|
"license": "MIT",
|
|
30
35
|
"dependencies": {
|
|
31
|
-
"@jscad/array-utils": "
|
|
36
|
+
"@jscad/array-utils": "3.0.0-alpha.0"
|
|
32
37
|
},
|
|
33
38
|
"devDependencies": {
|
|
34
|
-
"@jscad/modeling": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
39
|
+
"@jscad/modeling": "3.0.0-alpha.0",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
41
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
42
|
+
"ava": "^4.3.3",
|
|
43
|
+
"c8": "^8.0.0",
|
|
44
|
+
"rollup": "^2.79.1",
|
|
45
|
+
"rollup-plugin-banner": "^0.2.1",
|
|
46
|
+
"rollup-plugin-version-injector": "^1.3.3"
|
|
37
47
|
},
|
|
38
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3656d36ed9cd738ab884e86aae5a2ce08d52adf7"
|
|
39
49
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import banner from 'rollup-plugin-banner'
|
|
2
|
+
import versionInjector from 'rollup-plugin-version-injector'
|
|
3
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
4
|
+
import terser from '@rollup/plugin-terser'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
input: 'src/index.js',
|
|
8
|
+
|
|
9
|
+
output: [
|
|
10
|
+
{
|
|
11
|
+
file: 'dist/jscad-json-deserializer.min.js',
|
|
12
|
+
format: 'umd',
|
|
13
|
+
name: 'jscadJsonDeserializer'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
file: 'dist/jscad-json-deserializer.es.js',
|
|
17
|
+
format: 'es'
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
plugins: [
|
|
22
|
+
nodeResolve(),
|
|
23
|
+
banner('<%= pkg.description %>\n@module <%= pkg.name %>\n@version <%= pkg.version %>\n@license <%= pkg.license %>'),
|
|
24
|
+
versionInjector({ injectInComments: { fileRegexp: /\.(html)$/ }, logLevel: 'warn' }),
|
|
25
|
+
terser({ compress: { module: true }, mangle: false, format: { comments: 'some'} })
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
## License
|
|
3
|
-
|
|
4
|
-
Copyright (c) JSCAD Organization https://github.com/jscad
|
|
5
|
-
|
|
6
|
-
All code released under MIT license
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
1
|
// //////////////////////////////////////////
|
|
10
2
|
//
|
|
11
3
|
// JSON (JavaScript Object Notation) is a lightweight data-interchange format
|
|
@@ -15,14 +7,15 @@ All code released under MIT license
|
|
|
15
7
|
|
|
16
8
|
/**
|
|
17
9
|
* Deserializer of JSON data to JSCAD geometries.
|
|
10
|
+
* @see https://www.json.org
|
|
18
11
|
* @module io/json-deserializer
|
|
19
12
|
* @example
|
|
20
13
|
* const { deserializer, extension } = require('@jscad/json-deserializer')
|
|
21
14
|
*/
|
|
22
15
|
|
|
23
|
-
|
|
16
|
+
import { flatten, toArray } from '@jscad/array-utils'
|
|
24
17
|
|
|
25
|
-
const version =
|
|
18
|
+
const version = '[VI]{version}[/VI]' // version is injected by rollup
|
|
26
19
|
|
|
27
20
|
/**
|
|
28
21
|
* Deserialize the given JSON notation (string) into either a script or an array of geometry.
|
|
@@ -93,9 +86,9 @@ const translateToObjects = (objects) => objects.reduce((script, object, index) =
|
|
|
93
86
|
// NOTE: this implies that the original JSON was correct :)
|
|
94
87
|
const translateToObject = (object, index) => `const json${index} = ${JSON.stringify(object)}\n`
|
|
95
88
|
|
|
96
|
-
const
|
|
89
|
+
const mimeType = 'application/json'
|
|
97
90
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
export {
|
|
92
|
+
mimeType,
|
|
93
|
+
deserialize
|
|
101
94
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import test from 'ava'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { geom2, geom3, path2 } from '@jscad/modeling'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { deserialize } from '../src/index.js'
|
|
6
6
|
|
|
7
7
|
test('instantiate JSON notation to JSCAD geometries', (t) => {
|
|
8
|
-
let observed =
|
|
8
|
+
let observed = deserialize({ output: 'geometry', addMetaData: false }, json1)
|
|
9
9
|
t.is(observed.length, 1)
|
|
10
10
|
|
|
11
|
-
observed =
|
|
11
|
+
observed = deserialize({ filename: 'json2', output: 'geometry' }, json2)
|
|
12
12
|
t.is(observed.length, 1)
|
|
13
|
-
t.true(
|
|
13
|
+
t.true(geom3.isA(observed[0]))
|
|
14
14
|
|
|
15
|
-
observed =
|
|
15
|
+
observed = deserialize({ filename: 'json3', output: 'geometry' }, json3)
|
|
16
16
|
t.is(observed.length, 1)
|
|
17
|
-
t.true(
|
|
17
|
+
t.true(geom2.isA(observed[0]))
|
|
18
18
|
|
|
19
|
-
observed =
|
|
19
|
+
observed = deserialize({ filename: 'json4', output: 'geometry' }, json4)
|
|
20
20
|
t.is(observed.length, 1)
|
|
21
|
-
t.true(
|
|
21
|
+
t.true(path2.isA(observed[0]))
|
|
22
22
|
|
|
23
|
-
observed =
|
|
23
|
+
observed = deserialize({ filename: 'json5', output: 'geometry' }, json5)
|
|
24
24
|
t.is(observed.length, 2)
|
|
25
|
-
t.true(
|
|
26
|
-
t.true(
|
|
25
|
+
t.true(geom2.isA(observed[0]))
|
|
26
|
+
t.true(path2.isA(observed[1]))
|
|
27
27
|
|
|
28
|
-
observed =
|
|
28
|
+
observed = deserialize({ output: 'geometry', addMetaData: false }, json6)
|
|
29
29
|
t.is(observed.length, 1)
|
|
30
30
|
})
|
|
31
31
|
|
|
@@ -34,11 +34,11 @@ const json1 = '{}'
|
|
|
34
34
|
|
|
35
35
|
const json2 = '[{"polygons":[{"vertices":[[-15,-15,-15],[-15,-15,15],[-15,15,15],[-15,15,-15]],"plane":[-1,0,0,15]},{"vertices":[[15,-15,-15],[15,15,-15],[15,15,15],[15,-15,15]],"plane":[1,0,0,15]},{"vertices":[[-15,-15,-15],[15,-15,-15],[15,-15,15],[-15,-15,15]],"plane":[0,-1,0,15]},{"vertices":[[-15,15,-15],[-15,15,15],[15,15,15],[15,15,-15]],"plane":[0,1,0,15]},{"vertices":[[-15,-15,-15],[-15,15,-15],[15,15,-15],[15,-15,-15]],"plane":[0,0,-1,15]},{"vertices":[[-15,-15,15],[15,-15,15],[15,15,15],[-15,15,15]],"plane":[0,0,1,15]}],"isRetesselated":false,"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}]'
|
|
36
36
|
|
|
37
|
-
const json3 = '[{"
|
|
37
|
+
const json3 = '[{"outlines":[[[4.6193976402282715,-2.678784132003784],[5,0],[4.6193976402282715,2.678784132003784],[3.535533905029297,4.949747562408447],[1.9134172201156616,6.467156887054443],[3.0616169991140216e-16,7],[-1.9134172201156616,6.467156887054443],[-3.535533905029297,4.949747562408447],[-4.6193976402282715,2.678784132003784],[-5,8.572527703398379e-16],[-4.6193976402282715,-2.678784132003784],[-3.535533905029297,-4.949747562408447],[-1.9134172201156616,-6.467156887054443],[-9.184850467946473e-16,-7],[1.9134172201156616,-6.467156887054443],[3.535533905029297,-4.949747562408447]]],"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1],"name":"this is a name"}]'
|
|
38
38
|
|
|
39
39
|
const json4 = '[{"points":[[34.985713958740234,163.35238647460938],[49.39168167114258,179.00868225097656],[57.22199630737305,198.7909393310547],[57.43418502807617,220.06549072265625],[50,240]],"isClosed":false,"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1]}]'
|
|
40
40
|
|
|
41
|
-
const json5 = '[{"
|
|
41
|
+
const json5 = '[{"outlines":[[[4.6193976402282715,-2.678784132003784],[5,0],[4.6193976402282715,2.678784132003784],[3.535533905029297,4.949747562408447],[1.9134172201156616,6.467156887054443],[3.0616169991140216e-16,7],[-1.9134172201156616,6.467156887054443],[-3.535533905029297,4.949747562408447],[-4.6193976402282715,2.678784132003784],[-5,8.572527703398379e-16],[-3.535533905029297,-4.949747562408447],[-1.9134172201156616,-6.467156887054443],[-9.184850467946473e-16,-7],[1.9134172201156616,-6.467156887054443],[3.535533905029297,-4.949747562408447]]],"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1],"name":"this is a name"},{"points":[[34.985713958740234,163.35238647460938],[49.39168167114258,179.00868225097656],[57.22199630737305,198.7909393310547],[57.43418502807617,220.06549072265625],[50,240]],"isClosed":false,"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1]}]'
|
|
42
42
|
|
|
43
43
|
// non-JSCAD object
|
|
44
44
|
const json6 = '[{"statistics":[[34.985713958740234,163.35238647460938],[49.39168167114258,179.00868225097656],[57.22199630737305,198.7909393310547],[57.43418502807617,220.06549072265625],[50,240]],"average":123.456}]'
|
package/tests/translate.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import test from 'ava'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { deserialize } from '../src/index.js'
|
|
4
4
|
|
|
5
5
|
const countOf = (search, string) => {
|
|
6
6
|
let count = 0
|
|
@@ -13,27 +13,27 @@ const countOf = (search, string) => {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
test('translate JSON notation to JSCAD script', (t) => {
|
|
16
|
-
let observed =
|
|
16
|
+
let observed = deserialize({ output: 'script', addMetaData: false }, json1)
|
|
17
17
|
t.is(countOf('main', observed), 2)
|
|
18
18
|
t.is(countOf('const json', observed), 1)
|
|
19
19
|
|
|
20
|
-
observed =
|
|
20
|
+
observed = deserialize({ filename: 'json2', output: 'script', addMetaData: true }, json2)
|
|
21
21
|
t.is(countOf('main', observed), 2)
|
|
22
22
|
t.is(countOf('const json', observed), 1)
|
|
23
23
|
|
|
24
|
-
observed =
|
|
24
|
+
observed = deserialize({ filename: 'json3', output: 'script', addMetaData: true }, json3)
|
|
25
25
|
t.is(countOf('main', observed), 2)
|
|
26
26
|
t.is(countOf('const json', observed), 1)
|
|
27
27
|
|
|
28
|
-
observed =
|
|
28
|
+
observed = deserialize({ filename: 'json4', output: 'script', addMetaData: true }, json4)
|
|
29
29
|
t.is(countOf('main', observed), 2)
|
|
30
30
|
t.is(countOf('const json', observed), 1)
|
|
31
31
|
|
|
32
|
-
observed =
|
|
32
|
+
observed = deserialize({ filename: 'json5', output: 'script', addMetaData: false }, json5)
|
|
33
33
|
t.is(countOf('main', observed), 2)
|
|
34
34
|
t.is(countOf('const json', observed), 2)
|
|
35
35
|
|
|
36
|
-
observed =
|
|
36
|
+
observed = deserialize({ filename: 'json6', output: 'script', addMetaData: false }, json6)
|
|
37
37
|
t.is(countOf('main', observed), 2)
|
|
38
38
|
t.is(countOf('const json', observed), 1)
|
|
39
39
|
})
|
|
@@ -43,11 +43,11 @@ const json1 = '{}'
|
|
|
43
43
|
|
|
44
44
|
const json2 = '[{"polygons":[{"vertices":[[-15,-15,-15],[-15,-15,15],[-15,15,15],[-15,15,-15]],"plane":[-1,0,0,15]},{"vertices":[[15,-15,-15],[15,15,-15],[15,15,15],[15,-15,15]],"plane":[1,0,0,15]},{"vertices":[[-15,-15,-15],[15,-15,-15],[15,-15,15],[-15,-15,15]],"plane":[0,-1,0,15]},{"vertices":[[-15,15,-15],[-15,15,15],[15,15,15],[15,15,-15]],"plane":[0,1,0,15]},{"vertices":[[-15,-15,-15],[-15,15,-15],[15,15,-15],[15,-15,-15]],"plane":[0,0,-1,15]},{"vertices":[[-15,-15,15],[15,-15,15],[15,15,15],[-15,15,15]],"plane":[0,0,1,15]}],"isRetesselated":false,"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}]'
|
|
45
45
|
|
|
46
|
-
const json3 = '[{"
|
|
46
|
+
const json3 = '[{"outlines":[[[4.6193976402282715,-2.678784132003784],[5,0],[4.6193976402282715,2.678784132003784],[3.535533905029297,4.949747562408447],[1.9134172201156616,6.467156887054443],[3.0616169991140216e-16,7],[-1.9134172201156616,6.467156887054443],[-3.535533905029297,4.949747562408447],[-4.6193976402282715,2.678784132003784],[-5,8.572527703398379e-16],[-4.6193976402282715,-2.678784132003784],[-3.535533905029297,-4.949747562408447],[-1.9134172201156616,-6.467156887054443],[-9.184850467946473e-16,-7],[1.9134172201156616,-6.467156887054443],[3.535533905029297,-4.949747562408447]]],"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1],"name":"this is a name"}]'
|
|
47
47
|
|
|
48
48
|
const json4 = '[{"points":[[34.985713958740234,163.35238647460938],[49.39168167114258,179.00868225097656],[57.22199630737305,198.7909393310547],[57.43418502807617,220.06549072265625],[50,240]],"isClosed":false,"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1]}]'
|
|
49
49
|
|
|
50
|
-
const json5 = '[{"
|
|
50
|
+
const json5 = '[{"outlines":[[[4.6193976402282715,-2.678784132003784],[5,0],[4.6193976402282715,2.678784132003784],[3.535533905029297,4.949747562408447],[1.9134172201156616,6.467156887054443],[3.0616169991140216e-16,7],[-1.9134172201156616,6.467156887054443],[-3.535533905029297,4.949747562408447],[-4.6193976402282715,2.678784132003784],[-5,8.572527703398379e-16],[-4.6193976402282715,-2.678784132003784],[-3.535533905029297,-4.949747562408447],[-1.9134172201156616,-6.467156887054443],[-9.184850467946473e-16,-7],[1.9134172201156616,-6.467156887054443],[3.535533905029297,-4.949747562408447]]],"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1],"name":"this is a name"},{"points":[[34.985713958740234,163.35238647460938],[49.39168167114258,179.00868225097656],[57.22199630737305,198.7909393310547],[57.43418502807617,220.06549072265625],[50,240]],"isClosed":false,"transforms":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":[1,0,0,1]}]'
|
|
51
51
|
|
|
52
52
|
// non-JSCAD object
|
|
53
53
|
const json6 = '[{"statistics":[[34.985713958740234,163.35238647460938],[49.39168167114258,179.00868225097656],[57.22199630737305,198.7909393310547],[57.43418502807617,220.06549072265625],[50,240]],"average":123.456}]'
|