@jscad/json-deserializer 2.0.25 → 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 +11 -171
- 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,311 +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
|
|
|
23
|
+
**Note:** Version bump only for package @jscad/json-deserializer
|
|
19
24
|
|
|
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)
|
|
20
26
|
|
|
27
|
+
**Note:** Version bump only for package @jscad/json-deserializer
|
|
21
28
|
|
|
22
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)
|
|
23
30
|
|
|
24
31
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
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)
|
|
31
34
|
|
|
32
35
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
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)
|
|
39
38
|
|
|
40
39
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
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)
|
|
47
42
|
|
|
48
43
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
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)
|
|
55
46
|
|
|
56
47
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
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)
|
|
63
50
|
|
|
64
51
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
65
52
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
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)
|
|
71
54
|
|
|
72
55
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
73
56
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
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)
|
|
79
58
|
|
|
80
59
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
81
60
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
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)
|
|
87
62
|
|
|
88
63
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
89
64
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
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)
|
|
95
66
|
|
|
96
67
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
97
68
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
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)
|
|
103
70
|
|
|
104
71
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
105
72
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
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)
|
|
111
74
|
|
|
112
75
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
113
76
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
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)
|
|
119
78
|
|
|
120
79
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
121
80
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
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)
|
|
127
82
|
|
|
128
83
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
129
84
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
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)
|
|
135
86
|
|
|
136
87
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
137
88
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
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)
|
|
143
90
|
|
|
144
91
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
145
92
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
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)
|
|
151
94
|
|
|
152
95
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
153
96
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
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)
|
|
159
98
|
|
|
160
99
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
161
100
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
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)
|
|
167
102
|
|
|
168
103
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
169
104
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
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)
|
|
175
106
|
|
|
176
107
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
177
108
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
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)
|
|
183
110
|
|
|
184
111
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
185
112
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
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)
|
|
191
114
|
|
|
192
|
-
|
|
193
115
|
### Bug Fixes
|
|
194
116
|
|
|
195
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))
|
|
196
118
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
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)
|
|
202
120
|
|
|
203
|
-
|
|
204
121
|
### Bug Fixes
|
|
205
122
|
|
|
206
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))
|
|
207
124
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
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)
|
|
213
126
|
|
|
214
127
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
215
128
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
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)
|
|
221
130
|
|
|
222
131
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
223
132
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
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)
|
|
229
134
|
|
|
230
135
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
231
136
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
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)
|
|
237
138
|
|
|
238
139
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
239
140
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
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)
|
|
245
142
|
|
|
246
143
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
247
144
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
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)
|
|
253
146
|
|
|
254
147
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
255
148
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
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)
|
|
261
150
|
|
|
262
|
-
|
|
263
151
|
### Bug Fixes
|
|
264
152
|
|
|
265
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))
|
|
266
154
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
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)
|
|
272
156
|
|
|
273
157
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
274
158
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
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)
|
|
280
160
|
|
|
281
161
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
282
162
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
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)
|
|
288
164
|
|
|
289
165
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
290
166
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
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)
|
|
296
168
|
|
|
297
169
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
298
170
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
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)
|
|
304
172
|
|
|
305
173
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
306
174
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
175
|
# 2.0.0-alpha.0 (2020-08-13)
|
|
312
176
|
|
|
313
177
|
### Features
|
|
@@ -315,60 +179,36 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
315
179
|
* **json-deserializer:** Upgrade/overhaul JSON Deserializer for V2
|
|
316
180
|
* **io:** change api to deserialize(options, source)
|
|
317
181
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
182
|
<a name="0.1.2"></a>
|
|
323
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)
|
|
324
184
|
|
|
325
|
-
|
|
326
185
|
### Bug Fixes
|
|
327
186
|
|
|
328
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))
|
|
329
188
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
189
|
<a name="0.1.1"></a>
|
|
334
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)
|
|
335
191
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
192
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
340
193
|
|
|
341
194
|
<a name="0.1.0"></a>
|
|
342
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)
|
|
343
196
|
|
|
344
|
-
|
|
345
197
|
### Features
|
|
346
198
|
|
|
347
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))
|
|
348
200
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
201
|
<a name="0.0.4"></a>
|
|
353
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)
|
|
354
203
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
204
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
359
205
|
|
|
360
206
|
<a name="0.0.3"></a>
|
|
361
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)
|
|
362
208
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
209
|
**Note:** Version bump only for package @jscad/json-deserializer
|
|
367
210
|
|
|
368
211
|
<a name="0.0.2"></a>
|
|
369
212
|
## 0.0.2 (2017-10-10)
|
|
370
213
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
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}]'
|