@jscad/io 2.4.11 → 3.0.1-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 CHANGED
@@ -3,591 +3,333 @@
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
- ## [2.4.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.10...@jscad/io@2.4.11) (2024-12-29)
7
-
8
- **Note:** Version bump only for package @jscad/io
9
-
10
-
11
-
12
-
13
-
14
- ## [2.4.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.9...@jscad/io@2.4.10) (2024-11-10)
15
-
16
- **Note:** Version bump only for package @jscad/io
17
-
18
-
19
-
20
-
21
-
22
- ## [2.4.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.8...@jscad/io@2.4.9) (2024-10-06)
23
-
24
- **Note:** Version bump only for package @jscad/io
25
-
26
-
27
-
28
-
29
-
30
- ## [2.4.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.7...@jscad/io@2.4.8) (2024-06-02)
31
-
32
- **Note:** Version bump only for package @jscad/io
33
-
6
+ ## [3.0.1-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.3...@jscad/io@3.0.1-alpha.0) (2025-01-03)
34
7
 
8
+ ### Bug Fixes
35
9
 
10
+ * **io:** fix io after V3 refactoring ([7a12bbd](https://github.com/jscad/OpenJSCAD.org/commit/7a12bbdb7b4b3df792a4c5b3c8b30a6a985a48f0))
36
11
 
12
+ ### Features
37
13
 
38
- ## [2.4.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.6...@jscad/io@2.4.7) (2024-02-18)
14
+ * **3mf-deserializer:** initial version of 3MF deserializer and tests ([b22a27f](https://github.com/jscad/OpenJSCAD.org/commit/b22a27fa14c4f42b9160553cdd7b3c126ac72459))
15
+ * **cli:** reworked logic to use new io package exports and functions ([#1199](https://github.com/jscad/OpenJSCAD.org/issues/1199)) ([71a3d27](https://github.com/jscad/OpenJSCAD.org/commit/71a3d27a4cf416b1a9fea57a1fe40f5cfdaa905c))
16
+ * **modeling:** reworked exports to expose a flattened API ([8235238](https://github.com/jscad/OpenJSCAD.org/commit/8235238ad63d063f1e501478cae1208deb130a9c))
17
+ * **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))
39
18
 
40
- **Note:** Version bump only for package @jscad/io
19
+ # [3.0.0-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.3...@jscad/io@3.0.0-alpha.0) (2023-10-09)
41
20
 
21
+ ### Bug Fixes
42
22
 
23
+ * **io:** fix io after V3 refactoring ([7a12bbd](https://github.com/jscad/OpenJSCAD.org/commit/7a12bbdb7b4b3df792a4c5b3c8b30a6a985a48f0))
43
24
 
25
+ ### Features
44
26
 
27
+ * **3mf-deserializer:** initial version of 3MF deserializer and tests ([b22a27f](https://github.com/jscad/OpenJSCAD.org/commit/b22a27fa14c4f42b9160553cdd7b3c126ac72459))
28
+ * **cli:** reworked logic to use new io package exports and functions ([#1199](https://github.com/jscad/OpenJSCAD.org/issues/1199)) ([71a3d27](https://github.com/jscad/OpenJSCAD.org/commit/71a3d27a4cf416b1a9fea57a1fe40f5cfdaa905c))
29
+ * **modeling:** reworked exports to expose a flattened API ([8235238](https://github.com/jscad/OpenJSCAD.org/commit/8235238ad63d063f1e501478cae1208deb130a9c))
30
+ * **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))
45
31
 
46
32
  ## [2.4.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.5...@jscad/io@2.4.6) (2023-06-27)
47
33
 
48
34
  **Note:** Version bump only for package @jscad/io
49
35
 
50
-
51
-
52
-
53
-
54
36
  ## [2.4.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.4...@jscad/io@2.4.5) (2023-04-30)
55
37
 
56
38
  **Note:** Version bump only for package @jscad/io
57
39
 
58
-
59
-
60
-
61
-
62
40
  ## [2.4.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.3...@jscad/io@2.4.4) (2022-11-26)
63
41
 
64
42
  **Note:** Version bump only for package @jscad/io
65
43
 
66
-
67
-
68
-
69
-
70
44
  ## [2.4.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.2...@jscad/io@2.4.3) (2022-09-23)
71
45
 
72
46
  **Note:** Version bump only for package @jscad/io
73
47
 
74
-
75
-
76
-
77
-
78
48
  ## [2.4.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.1...@jscad/io@2.4.2) (2022-08-21)
79
49
 
80
50
  **Note:** Version bump only for package @jscad/io
81
51
 
82
-
83
-
84
-
85
-
86
52
  ## [2.4.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.4.0...@jscad/io@2.4.1) (2022-07-17)
87
53
 
88
54
  **Note:** Version bump only for package @jscad/io
89
55
 
90
-
91
-
92
-
93
-
94
56
  # [2.4.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.3.3...@jscad/io@2.4.0) (2022-06-12)
95
57
 
96
-
97
58
  ### Features
98
59
 
99
60
  * **x3d-serializer:** enhanced to convert 2D geometry and path to X3D Polyline2D ([#1091](https://github.com/jscad/OpenJSCAD.org/issues/1091)) ([4f763a8](https://github.com/jscad/OpenJSCAD.org/commit/4f763a8def39f3b0454f2079f3c1fd7da52dd880))
100
61
 
101
-
102
-
103
-
104
-
105
62
  ## [2.3.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.3.2...@jscad/io@2.3.3) (2022-05-15)
106
63
 
107
64
  **Note:** Version bump only for package @jscad/io
108
65
 
109
-
110
-
111
-
112
-
113
66
  ## [2.3.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.3.1...@jscad/io@2.3.2) (2022-04-24)
114
67
 
115
68
  **Note:** Version bump only for package @jscad/io
116
69
 
117
-
118
-
119
-
120
-
121
70
  ## [2.3.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.3.0...@jscad/io@2.3.1) (2022-04-03)
122
71
 
123
72
  **Note:** Version bump only for package @jscad/io
124
73
 
125
-
126
-
127
-
128
-
129
74
  # [2.3.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.2.6...@jscad/io@2.3.0) (2022-04-03)
130
75
 
131
-
132
76
  ### Features
133
77
 
134
78
  * **3mf-serializer:** new serializer from JSCAD geometry to 3MF packages ([6b51aed](https://github.com/jscad/OpenJSCAD.org/commit/6b51aed63ee40674822a04ced773564552689763))
135
79
 
136
-
137
-
138
-
139
-
140
80
  ## [2.2.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.2.5...@jscad/io@2.2.6) (2022-03-13)
141
81
 
142
82
  **Note:** Version bump only for package @jscad/io
143
83
 
144
-
145
-
146
-
147
-
148
84
  ## [2.2.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.2.4...@jscad/io@2.2.5) (2022-03-06)
149
85
 
150
86
  **Note:** Version bump only for package @jscad/io
151
87
 
152
-
153
-
154
-
155
-
156
88
  ## [2.2.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.2.3...@jscad/io@2.2.4) (2022-02-19)
157
89
 
158
90
  **Note:** Version bump only for package @jscad/io
159
91
 
160
-
161
-
162
-
163
-
164
92
  ## [2.2.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.2.2...@jscad/io@2.2.3) (2022-01-23)
165
93
 
166
94
  **Note:** Version bump only for package @jscad/io
167
95
 
168
-
169
-
170
-
171
-
172
96
  ## [2.2.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.2.1...@jscad/io@2.2.2) (2021-12-26)
173
97
 
174
98
  **Note:** Version bump only for package @jscad/io
175
99
 
176
-
177
-
178
-
179
-
180
100
  ## [2.2.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.2.0...@jscad/io@2.2.1) (2021-12-11)
181
101
 
182
102
  **Note:** Version bump only for package @jscad/io
183
103
 
184
-
185
-
186
-
187
-
188
104
  # [2.2.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.1.0...@jscad/io@2.2.0) (2021-11-07)
189
105
 
190
-
191
106
  ### Features
192
107
 
193
108
  * **io:** new serializer for OBJ ([#942](https://github.com/jscad/OpenJSCAD.org/issues/942)) ([baaae18](https://github.com/jscad/OpenJSCAD.org/commit/baaae18ad55252ec71b074bd85dea7d137a22eb8))
194
109
 
195
-
196
-
197
-
198
-
199
110
  # [2.1.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.9...@jscad/io@2.1.0) (2021-10-17)
200
111
 
201
-
202
112
  ### Features
203
113
 
204
114
  * **io:** added registration of x3d-deserializer ([57aee3f](https://github.com/jscad/OpenJSCAD.org/commit/57aee3fee0626e8dd13bd89ea4a6a5f3f108bd54))
205
115
 
206
-
207
-
208
-
209
-
210
116
  ## [2.0.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.8...@jscad/io@2.0.9) (2021-10-04)
211
117
 
212
118
  **Note:** Version bump only for package @jscad/io
213
119
 
214
-
215
-
216
-
217
-
218
120
  ## [2.0.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.7...@jscad/io@2.0.8) (2021-09-27)
219
121
 
220
122
  **Note:** Version bump only for package @jscad/io
221
123
 
222
-
223
-
224
-
225
-
226
124
  ## [2.0.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.6...@jscad/io@2.0.7) (2021-09-09)
227
125
 
228
126
  **Note:** Version bump only for package @jscad/io
229
127
 
230
-
231
-
232
-
233
-
234
128
  ## [2.0.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.5...@jscad/io@2.0.6) (2021-06-20)
235
129
 
236
130
  **Note:** Version bump only for package @jscad/io
237
131
 
238
-
239
-
240
-
241
-
242
132
  ## [2.0.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.4...@jscad/io@2.0.5) (2021-06-11)
243
133
 
244
-
245
134
  ### Bug Fixes
246
135
 
247
136
  * **io:** corrected assembly of serialization options in generateOutputData ([c57d8da](https://github.com/jscad/OpenJSCAD.org/commit/c57d8daa23db27992bc0c09137d1df51c2f039e8))
248
137
 
249
-
250
-
251
-
252
-
253
138
  ## [2.0.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.3...@jscad/io@2.0.4) (2021-06-01)
254
139
 
255
140
  **Note:** Version bump only for package @jscad/io
256
141
 
257
-
258
-
259
-
260
-
261
142
  ## [2.0.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.2...@jscad/io@2.0.3) (2021-04-20)
262
143
 
263
144
  **Note:** Version bump only for package @jscad/io
264
145
 
265
-
266
-
267
-
268
-
269
146
  ## [2.0.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.0...@jscad/io@2.0.2) (2021-04-17)
270
147
 
271
-
272
148
  ### Bug Fixes
273
149
 
274
150
  * **all:** fix json import ([#675](https://github.com/jscad/OpenJSCAD.org/issues/675)) ([05caf60](https://github.com/jscad/OpenJSCAD.org/commit/05caf60efc3f090313b3e0bddcc0b4f94de67c78))
275
151
  * **io:** io revisited ([#714](https://github.com/jscad/OpenJSCAD.org/issues/714)) ([22f04f1](https://github.com/jscad/OpenJSCAD.org/commit/22f04f1b2894a82e24952655875e73b74727bf86))
276
152
 
277
-
278
-
279
-
280
-
281
153
  ## [2.0.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.0...@jscad/io@2.0.1) (2021-04-15)
282
154
 
283
-
284
155
  ### Bug Fixes
285
156
 
286
157
  * **all:** fix json import ([#675](https://github.com/jscad/OpenJSCAD.org/issues/675)) ([05caf60](https://github.com/jscad/OpenJSCAD.org/commit/05caf60efc3f090313b3e0bddcc0b4f94de67c78))
287
158
  * **io:** io revisited ([#714](https://github.com/jscad/OpenJSCAD.org/issues/714)) ([22f04f1](https://github.com/jscad/OpenJSCAD.org/commit/22f04f1b2894a82e24952655875e73b74727bf86))
288
159
 
289
-
290
-
291
-
292
-
293
160
  # [2.0.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.13...@jscad/io@2.0.0) (2021-04-12)
294
161
 
295
162
  **Note:** Version bump only for package @jscad/io
296
163
 
297
-
298
-
299
-
300
-
301
164
  # [2.0.0-alpha.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.12...@jscad/io@2.0.0-alpha.13) (2021-03-07)
302
165
 
303
166
  **Note:** Version bump only for package @jscad/io
304
167
 
305
-
306
-
307
-
308
-
309
168
  # [2.0.0-alpha.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.11...@jscad/io@2.0.0-alpha.12) (2021-02-07)
310
169
 
311
170
  **Note:** Version bump only for package @jscad/io
312
171
 
313
-
314
-
315
-
316
-
317
172
  # [2.0.0-alpha.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.10...@jscad/io@2.0.0-alpha.11) (2021-01-02)
318
173
 
319
174
  **Note:** Version bump only for package @jscad/io
320
175
 
321
-
322
-
323
-
324
-
325
176
  # [2.0.0-alpha.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.9...@jscad/io@2.0.0-alpha.10) (2020-12-04)
326
177
 
327
178
  **Note:** Version bump only for package @jscad/io
328
179
 
329
-
330
-
331
-
332
-
333
180
  # [2.0.0-alpha.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io@2.0.0-alpha.8...@jscad/io@2.0.0-alpha.9) (2020-11-07)
334
181
 
335
-
336
182
  ### Bug Fixes
337
183
 
338
184
  * **io:** io revisited ([#714](https://github.com/jscad/OpenJSCAD.org/issues/714)) ([22f04f1](https://github.com/jscad/OpenJSCAD.org/commit/22f04f1b2894a82e24952655875e73b74727bf86))
339
185
 
340
-
341
-
342
-
343
-
344
186
  # [2.0.0-alpha.8](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.7...@jscad/io@2.0.0-alpha.8) (2020-10-24)
345
187
 
346
188
  **Note:** Version bump only for package @jscad/io
347
189
 
348
-
349
-
350
-
351
-
352
190
  # [2.0.0-alpha.7](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.6...@jscad/io@2.0.0-alpha.7) (2020-10-11)
353
191
 
354
192
  **Note:** Version bump only for package @jscad/io
355
193
 
356
-
357
-
358
-
359
-
360
194
  # [2.0.0-alpha.6](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.5...@jscad/io@2.0.0-alpha.6) (2020-09-29)
361
195
 
362
196
  **Note:** Version bump only for package @jscad/io
363
197
 
364
-
365
-
366
-
367
-
368
198
  # [2.0.0-alpha.5](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.4...@jscad/io@2.0.0-alpha.5) (2020-09-28)
369
199
 
370
200
  **Note:** Version bump only for package @jscad/io
371
201
 
372
-
373
-
374
-
375
-
376
202
  # [2.0.0-alpha.4](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.3...@jscad/io@2.0.0-alpha.4) (2020-09-19)
377
203
 
378
-
379
204
  ### Bug Fixes
380
205
 
381
206
  * **all:** fix json import ([#675](https://github.com/jscad/io/issues/675)) ([05caf60](https://github.com/jscad/io/commit/05caf60efc3f090313b3e0bddcc0b4f94de67c78))
382
207
 
383
-
384
-
385
-
386
-
387
208
  # [2.0.0-alpha.3](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.2...@jscad/io@2.0.0-alpha.3) (2020-09-08)
388
209
 
389
210
  **Note:** Version bump only for package @jscad/io
390
211
 
391
-
392
-
393
-
394
-
395
212
  # [2.0.0-alpha.2](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.1...@jscad/io@2.0.0-alpha.2) (2020-09-02)
396
213
 
397
214
  **Note:** Version bump only for package @jscad/io
398
215
 
399
-
400
-
401
-
402
-
403
216
  # [2.0.0-alpha.1](https://github.com/jscad/io/compare/@jscad/io@2.0.0-alpha.0...@jscad/io@2.0.0-alpha.1) (2020-08-19)
404
217
 
405
218
  **Note:** Version bump only for package @jscad/io
406
219
 
407
-
408
-
409
-
410
-
411
220
  # 2.0.0-alpha.0 (2020-08-13)
412
221
 
413
222
  ### Features
414
223
 
415
224
  * **io:** merge IO packages into main repository (#436)
416
225
 
417
-
418
-
419
-
420
-
421
226
  <a name="0.5.0"></a>
422
227
  # [0.5.0](https://github.com/jscad/io/compare/@jscad/io@0.4.8...@jscad/io@0.5.0) (2018-11-25)
423
228
 
424
-
425
229
  ### Features
426
230
 
427
231
  * **scad-deserializer:** added old openscad-openjscad-translator to the packages ([#75](https://github.com/jscad/io/issues/75)) ([0a20323](https://github.com/jscad/io/commit/0a20323))
428
232
 
429
-
430
-
431
-
432
233
  <a name="0.4.8"></a>
433
234
  ## [0.4.8](https://github.com/jscad/io/compare/@jscad/io@0.4.7...@jscad/io@0.4.8) (2018-11-22)
434
235
 
435
-
436
-
437
-
438
236
  **Note:** Version bump only for package @jscad/io
439
237
 
440
238
  <a name="0.4.7"></a>
441
239
  ## [0.4.7](https://github.com/jscad/io/compare/@jscad/io@0.4.6...@jscad/io@0.4.7) (2018-09-02)
442
240
 
443
-
444
-
445
-
446
241
  **Note:** Version bump only for package @jscad/io
447
242
 
448
243
  <a name="0.4.6"></a>
449
244
  ## [0.4.6](https://github.com/jscad/io/compare/@jscad/io@0.4.5...@jscad/io@0.4.6) (2018-06-11)
450
245
 
451
-
452
-
453
-
454
246
  **Note:** Version bump only for package @jscad/io
455
247
 
456
248
  <a name="0.4.5"></a>
457
249
  ## [0.4.5](https://github.com/jscad/io/compare/@jscad/io@0.4.4...@jscad/io@0.4.5) (2018-05-24)
458
250
 
459
-
460
-
461
-
462
251
  **Note:** Version bump only for package @jscad/io
463
252
 
464
253
  <a name="0.4.4"></a>
465
254
  ## [0.4.4](https://github.com/jscad/io/compare/@jscad/io@0.4.3...@jscad/io@0.4.4) (2018-04-07)
466
255
 
467
-
468
-
469
-
470
256
  **Note:** Version bump only for package @jscad/io
471
257
 
472
258
  <a name="0.4.3"></a>
473
259
  ## [0.4.3](https://github.com/jscad/io/compare/@jscad/io@0.4.2...@jscad/io@0.4.3) (2018-04-01)
474
260
 
475
-
476
-
477
-
478
261
  **Note:** Version bump only for package @jscad/io
479
262
 
480
263
  <a name="0.4.2"></a>
481
264
  ## [0.4.2](https://github.com/jscad/io/compare/@jscad/io@0.4.1...@jscad/io@0.4.2) (2018-04-01)
482
265
 
483
-
484
-
485
-
486
266
  **Note:** Version bump only for package @jscad/io
487
267
 
488
268
  <a name="0.4.1"></a>
489
269
  ## [0.4.1](https://github.com/jscad/io/compare/@jscad/io@0.4.0...@jscad/io@0.4.1) (2018-03-15)
490
270
 
491
-
492
-
493
-
494
271
  **Note:** Version bump only for package @jscad/io
495
272
 
496
273
  <a name="0.4.0"></a>
497
274
  # [0.4.0](https://github.com/jscad/io/compare/@jscad/io@0.3.12...@jscad/io@0.4.0) (2018-02-24)
498
275
 
499
-
500
276
  ### Features
501
277
 
502
278
  * **DXF Deserializer:** Adds dxf deserializer and all associated code ([ae4a6c0](https://github.com/jscad/io/commit/ae4a6c0)), closes [#10](https://github.com/jscad/io/issues/10)
503
279
 
504
-
505
-
506
-
507
280
  <a name="0.3.12"></a>
508
281
  ## [0.3.12](https://github.com/jscad/io/compare/@jscad/io@0.3.11...@jscad/io@0.3.12) (2017-12-14)
509
282
 
510
-
511
-
512
-
513
283
  **Note:** Version bump only for package @jscad/io
514
284
 
515
285
  <a name="0.3.11"></a>
516
286
  ## [0.3.11](https://github.com/jscad/io/compare/@jscad/io@0.3.10...@jscad/io@0.3.11) (2017-12-14)
517
287
 
518
-
519
-
520
-
521
288
  **Note:** Version bump only for package @jscad/io
522
289
 
523
290
  <a name="0.3.10"></a>
524
291
  ## [0.3.10](https://github.com/jscad/io/compare/@jscad/io@0.3.9...@jscad/io@0.3.10) (2017-11-29)
525
292
 
526
-
527
-
528
-
529
293
  **Note:** Version bump only for package @jscad/io
530
294
 
531
295
  <a name="0.3.9"></a>
532
296
  ## [0.3.9](https://github.com/jscad/io/compare/@jscad/io@0.3.8...@jscad/io@0.3.9) (2017-11-20)
533
297
 
534
-
535
-
536
-
537
298
  **Note:** Version bump only for package @jscad/io
538
299
 
539
300
  <a name="0.3.8"></a>
540
301
  ## [0.3.8](https://github.com/jscad/io/compare/@jscad/io@0.3.7...@jscad/io@0.3.8) (2017-11-14)
541
302
 
542
-
543
-
544
-
545
303
  **Note:** Version bump only for package @jscad/io
546
304
 
547
305
  <a name="0.3.7"></a>
548
306
  ## [0.3.7](https://github.com/jscad/io/compare/@jscad/io@0.3.6...@jscad/io@0.3.7) (2017-11-04)
549
307
 
550
-
551
-
552
-
553
308
  **Note:** Version bump only for package @jscad/io
554
309
 
555
310
  <a name="0.3.6"></a>
556
311
  ## [0.3.6](https://github.com/jscad/io/compare/@jscad/io@0.3.5...@jscad/io@0.3.6) (2017-11-04)
557
312
 
558
-
559
-
560
-
561
313
  **Note:** Version bump only for package @jscad/io
562
314
 
563
315
  <a name="0.3.5"></a>
564
316
  ## [0.3.5](https://github.com/jscad/io/compare/@jscad/io@0.3.4...@jscad/io@0.3.5) (2017-10-30)
565
317
 
566
-
567
-
568
-
569
318
  **Note:** Version bump only for package @jscad/io
570
319
 
571
320
  <a name="0.3.4"></a>
572
321
  ## [0.3.4](https://github.com/jscad/io/compare/@jscad/io@0.3.3...@jscad/io@0.3.4) (2017-10-15)
573
322
 
574
-
575
-
576
-
577
323
  **Note:** Version bump only for package @jscad/io
578
324
 
579
325
  <a name="0.3.3"></a>
580
326
  ## [0.3.3](https://github.com/jscad/io/compare/@jscad/io@0.3.2...@jscad/io@0.3.3) (2017-10-10)
581
327
 
582
-
583
-
584
-
585
328
  **Note:** Version bump only for package @jscad/io
586
329
 
587
330
  <a name="0.3.2"></a>
588
331
  ## 0.3.2 (2017-10-10)
589
332
 
590
-
591
333
  ### Bug Fixes
592
334
 
593
335
  * **io:** fixed bad version numbers for svg de/serializers ([#28](https://github.com/jscad/io/issues/28)) ([60d239c](https://github.com/jscad/io/commit/60d239c))
package/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  The MIT License (MIT)
3
3
 
4
- Copyright (c) 2017-2024 JSCAD Organization
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
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![License](https://img.shields.io/github/license/jscad/OpenJSCAD.org)](https://github.com/jscad/OpenJSCAD.org/blob/master/LICENSE)
10
10
 
11
11
  [![User Group](https://img.shields.io/badge/maintained%20by-user%20group-blue)](https://openjscad.nodebb.com/)
12
- [![Lerna](https://img.shields.io/badge/maintained%20with-lerna-blue)](https://lerna.js.org/)
12
+ [![lerna--lite](https://img.shields.io/badge/maintained%20with-lerna--lite-e137ff)](https://github.com/ghiscoding/lerna-lite)
13
13
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-blue)](https://standardjs.com)
14
14
 
15
15
  [![Backers](https://img.shields.io/opencollective/backers/openjscad)](https://opencollective.com/openjscad)
@@ -26,20 +26,19 @@ This package is a metapackage and includes all the input/output format handling
26
26
  ie: file data => JSCAD code or JSCAD geometry
27
27
 
28
28
  Following formats are supported as inputs
29
- - [AMF](../amf-deserializer)
30
29
  - [DXF](../dxf-deserializer)
31
30
  - [JSON](../json-deserializer)
32
31
  - [OBJ](../obj-deserializer)
33
32
  - [STL (binary, ASCII)](../stl-deserializer)
34
33
  - [SVG](../svg-deserializer)
35
34
  - [X3D](../x3d-deserializer)
35
+ - [3MF](../3mf-deserializer)
36
36
 
37
37
  ### Outputs/ Serializers
38
38
 
39
39
  ie: geometry => blob
40
40
 
41
41
  Following formats are supported as outputs
42
- - [AMF](../amf-serializer)
43
42
  - [DXF](../dxf-serializer)
44
43
  - [JSON](../json-serializer)
45
44
  - [OBJ](../obj-serializer)
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@jscad/io",
3
- "version": "2.4.11",
3
+ "version": "3.0.1-alpha.0",
4
4
  "description": "Meta Package for JSCAD IO Packages",
5
5
  "homepage": "https://openjscad.xyz/",
6
6
  "repository": "https://github.com/jscad/OpenJSCAD.org",
7
- "main": "index.js",
8
- "scripts": {},
7
+ "main": "src/index.js",
8
+ "type": "module",
9
+ "scripts": {
10
+ "coverage": "c8 --all --reporter=html --reporter=text npm test",
11
+ "test": "ava --verbose --timeout 2m './tests/*.test.js'"
12
+ },
9
13
  "contributors": [
10
14
  {
11
15
  "name": "Rene K. Mueller",
12
- "url": "http://renekmueller.com"
16
+ "url": "https://github.com/Spiritdude"
13
17
  },
14
18
  {
15
19
  "name": "z3dev",
@@ -17,7 +21,7 @@
17
21
  },
18
22
  {
19
23
  "name": "Mark 'kaosat-dev' Moissette",
20
- "url": "http://kaosat.net"
24
+ "url": "https://github.com/kaosat-dev"
21
25
  }
22
26
  ],
23
27
  "keywords": [
@@ -30,24 +34,27 @@
30
34
  ],
31
35
  "license": "MIT",
32
36
  "dependencies": {
33
- "@jscad/3mf-serializer": "2.1.14",
34
- "@jscad/amf-deserializer": "2.3.10",
35
- "@jscad/amf-serializer": "2.1.20",
36
- "@jscad/array-utils": "2.1.4",
37
- "@jscad/dxf-deserializer": "2.3.27",
38
- "@jscad/dxf-serializer": "2.1.20",
39
- "@jscad/io-utils": "2.0.30",
40
- "@jscad/json-deserializer": "2.0.31",
41
- "@jscad/json-serializer": "2.0.30",
42
- "@jscad/modeling": "2.12.5",
43
- "@jscad/obj-deserializer": "2.0.30",
44
- "@jscad/obj-serializer": "2.1.20",
45
- "@jscad/stl-deserializer": "2.1.27",
46
- "@jscad/stl-serializer": "2.1.20",
47
- "@jscad/svg-deserializer": "2.5.11",
48
- "@jscad/svg-serializer": "2.3.18",
49
- "@jscad/x3d-deserializer": "2.2.10",
50
- "@jscad/x3d-serializer": "2.4.10"
37
+ "@jscad/3mf-deserializer": "3.0.1-alpha.0",
38
+ "@jscad/3mf-serializer": "3.0.1-alpha.0",
39
+ "@jscad/array-utils": "3.0.1-alpha.0",
40
+ "@jscad/dxf-deserializer": "3.0.1-alpha.0",
41
+ "@jscad/dxf-serializer": "3.0.1-alpha.0",
42
+ "@jscad/io-utils": "3.0.1-alpha.0",
43
+ "@jscad/json-deserializer": "3.0.1-alpha.0",
44
+ "@jscad/json-serializer": "3.0.1-alpha.0",
45
+ "@jscad/modeling": "3.0.1-alpha.0",
46
+ "@jscad/obj-deserializer": "3.0.1-alpha.0",
47
+ "@jscad/obj-serializer": "3.0.1-alpha.0",
48
+ "@jscad/stl-deserializer": "3.0.1-alpha.0",
49
+ "@jscad/stl-serializer": "3.0.1-alpha.0",
50
+ "@jscad/svg-deserializer": "3.0.1-alpha.0",
51
+ "@jscad/svg-serializer": "3.0.1-alpha.0",
52
+ "@jscad/x3d-deserializer": "3.0.1-alpha.0",
53
+ "@jscad/x3d-serializer": "3.0.1-alpha.0"
54
+ },
55
+ "devDependencies": {
56
+ "ava": "^4.3.3",
57
+ "c8": "^8.0.0"
51
58
  },
52
- "gitHead": "d8010c4f1d70685404a510d604f8b6d5c362f93a"
59
+ "gitHead": "0660b5c1f1a5faf54d4cfae1cb85bb94182a8d32"
53
60
  }
@@ -0,0 +1,61 @@
1
+ import { deserializers } from './deserializers.js'
2
+
3
+ /*
4
+ * Transform the source into ES6 javascript
5
+ */
6
+
7
+ // no transform required, just pass through the source
8
+ const nullTransform = (options, source) => source
9
+
10
+ // TODO : how to transform CommonJS code?
11
+ const transformers = {
12
+ 'application/javascript': nullTransform
13
+ }
14
+
15
+ /**
16
+ * Deserialize the given source as per the given mimeType.
17
+ * Options can be provided to over-ride or suppliment the defaults used during deserialization.
18
+ * Options must include 'output' as either 'script' or 'geometry'.
19
+ * @param {Object} options - options used during deserializing
20
+ * @param {String} mimeType - MIME type of the file
21
+ * @param {String} source - the contents of the file
22
+ * @return {[objects]|string} a list of objects (geometry) or a string (script)
23
+ *
24
+ * @example
25
+ * const mimetype = getMimeType('svg')
26
+ * const myobjects = deserialize({output: 'geometry', target: 'path2'}, mimetype, source)
27
+ */
28
+ export const deserialize = (options, mimeType, source) => {
29
+ // commonly used defaults from the deserializers
30
+ const defaults = {
31
+ addMetaData: true,
32
+ segments: 32
33
+ }
34
+ options = Object.assign({}, defaults, options)
35
+
36
+ if (options.output) {
37
+ if (options.output === 'script') {
38
+ // transform souce code if possible
39
+ if (mimeType in transformers) {
40
+ const transformer = transformers[mimeType]
41
+ return transformer(options, source)
42
+ }
43
+ // deserialize know formats if possible
44
+ if (mimeType in deserializers) {
45
+ const deserializer = deserializers[mimeType]
46
+ return deserializer(options, source)
47
+ }
48
+ throw new Error(`Unknown mime type (${mimeType})`)
49
+ }
50
+
51
+ if (options.output === 'geometry') {
52
+ // deserialize know formats if possible
53
+ if (mimeType in deserializers) {
54
+ const deserializer = deserializers[mimeType]
55
+ return deserializer(options, source)
56
+ }
57
+ throw new Error(`Unknown mime type (${mimeType})`)
58
+ }
59
+ }
60
+ throw new Error(`Unknown output option (${options.output}), only 'script' or 'geometry' allowed`)
61
+ }
@@ -0,0 +1,16 @@
1
+ import * as mf3DeSerializer from '@jscad/3mf-deserializer'
2
+ import * as dxfDeSerializer from '@jscad/dxf-deserializer'
3
+ import * as jsonDeSerializer from '@jscad/json-deserializer'
4
+ import * as objDeSerializer from '@jscad/obj-deserializer'
5
+ import * as stlDeSerializer from '@jscad/stl-deserializer'
6
+ import * as svgDeSerializer from '@jscad/svg-deserializer'
7
+ import * as x3dDeSerializer from '@jscad/x3d-deserializer'
8
+
9
+ export const deserializers = {}
10
+ deserializers[mf3DeSerializer.mimeType] = mf3DeSerializer.deserialize
11
+ deserializers[dxfDeSerializer.mimeType] = dxfDeSerializer.deserialize
12
+ deserializers[jsonDeSerializer.mimeType] = jsonDeSerializer.deserialize
13
+ deserializers[objDeSerializer.mimeType] = objDeSerializer.deserialize
14
+ deserializers[stlDeSerializer.mimeType] = stlDeSerializer.deserialize
15
+ deserializers[svgDeSerializer.mimeType] = svgDeSerializer.deserialize
16
+ deserializers[x3dDeSerializer.mimeType] = x3dDeSerializer.deserialize
@@ -1,13 +1,14 @@
1
- const { geometries } = require('@jscad/modeling')
1
+ import { geom2, geom3, path2 } from '@jscad/modeling'
2
2
 
3
3
  // handled format descriptions
4
- // note: order is important as regular expressions are created from extentions
5
- const formats = {
4
+ // note: order is important as regular expressions are created from extensions
5
+ // see https://www.iana.org/assignments/media-types/media-types.xhtml
6
+ export const supportedFormats = {
6
7
  stl: {
7
8
  displayName: 'STL (Binary)',
8
9
  description: 'STereoLithography, Binary',
9
10
  extension: 'stl',
10
- mimetype: 'application/sla',
11
+ mimetype: 'model/stl',
11
12
  deserializable: true,
12
13
  convertGeom3: false,
13
14
  convertGeom2: false
@@ -16,7 +17,7 @@ const formats = {
16
17
  displayName: 'STL (ASCII)',
17
18
  description: 'STereoLithography, ASCII',
18
19
  extension: 'stl',
19
- mimetype: 'application/sla',
20
+ mimetype: 'model/stl',
20
21
  deserializable: false, // just once
21
22
  convertGeom3: true,
22
23
  convertGeom2: false
@@ -25,25 +26,16 @@ const formats = {
25
26
  displayName: 'STL (Binary)',
26
27
  description: 'STereoLithography, Binary',
27
28
  extension: 'stl',
28
- mimetype: 'application/sla',
29
+ mimetype: 'model/stl',
29
30
  deserializable: false, // just once
30
31
  convertGeom3: true,
31
32
  convertGeom2: false
32
33
  },
33
- amf: {
34
- displayName: 'AMF (experimental)',
35
- description: 'Additive Manufacturing File Format',
36
- extension: 'amf',
37
- mimetype: 'application/amf+xml',
38
- deserializable: true,
39
- convertGeom3: true,
40
- convertGeom2: false
41
- },
42
34
  dxf: {
43
35
  displayName: 'DXF (ASCII)',
44
36
  description: 'AutoCAD Drawing Exchange Format',
45
37
  extension: 'dxf',
46
- mimetype: 'application/dxf',
38
+ mimetype: 'image/vnd.dxf',
47
39
  deserializable: true,
48
40
  convertGeom3: true,
49
41
  convertGeom2: true
@@ -79,7 +71,7 @@ const formats = {
79
71
  displayName: 'OBJ',
80
72
  description: 'Wavefront OBJ File',
81
73
  extension: 'obj',
82
- mimetype: 'text/plain',
74
+ mimetype: 'model/obj',
83
75
  deserializable: true,
84
76
  convertGeom3: true,
85
77
  convertGeom2: false
@@ -107,42 +99,26 @@ const formats = {
107
99
  description: '3D Manufacturing Format',
108
100
  extension: '3mf',
109
101
  mimetype: 'model/3mf',
110
- deserializable: false,
102
+ deserializable: true,
111
103
  convertGeom3: true,
112
104
  convertGeom2: false
113
105
  }
114
106
  }
115
107
 
116
- // handled input formats that can be converted to jscad code
117
- const conversionFormats = [
118
- // 3D file formats
119
- 'amf',
120
- 'js',
121
- 'jscad',
122
- 'obj',
123
- 'scad',
124
- 'stl',
125
- 'dxf',
126
- // 2D file formats
127
- 'svg',
128
- 'ttf',
129
- 'woff'
130
- ]
131
-
132
- const supportedFormatsForObjects = (objects) => {
108
+ export const supportedFormatsForObjects = (objects) => {
133
109
  const objectFormats = []
134
110
  let found3Dsolid = false
135
111
  let found2Dsolid = false
136
112
  for (let i = 0; i < objects.length; i++) {
137
- if (geometries.geom3.isA(objects[i])) { found3Dsolid = true }
138
- if (geometries.geom2.isA(objects[i]) || geometries.path2.isA(objects[i])) { found2Dsolid = true }
113
+ if (geom3.isA(objects[i])) { found3Dsolid = true }
114
+ if (geom2.isA(objects[i]) || path2.isA(objects[i])) { found2Dsolid = true }
139
115
  }
140
- for (const format in formats) {
141
- if (found3Dsolid && formats[format].convertGeom3 === true) {
116
+ for (const format in supportedFormats) {
117
+ if (found3Dsolid && supportedFormats[format].convertGeom3 === true) {
142
118
  objectFormats[objectFormats.length] = format
143
119
  continue // only add once
144
120
  }
145
- if (found2Dsolid && formats[format].convertGeom2 === true) {
121
+ if (found2Dsolid && supportedFormats[format].convertGeom2 === true) {
146
122
  objectFormats[objectFormats.length] = format
147
123
  }
148
124
  }
@@ -150,12 +126,12 @@ const supportedFormatsForObjects = (objects) => {
150
126
  }
151
127
 
152
128
  // Return a list of extensions as used by the serializers
153
- const supportedOutputExtensions = () => {
129
+ export const supportedOutputExtensions = () => {
154
130
  const supported = []
155
- for (const format in formats) {
156
- if (formats[format].convertGeom3 === true || formats[format].convertGeom2 === true) {
157
- if (supported.indexOf(formats[format].extension) < 0) {
158
- supported.push(formats[format].extension)
131
+ for (const format in supportedFormats) {
132
+ if (supportedFormats[format].convertGeom3 === true || supportedFormats[format].convertGeom2 === true) {
133
+ if (supported.indexOf(supportedFormats[format].extension) < 0) {
134
+ supported.push(supportedFormats[format].extension)
159
135
  }
160
136
  }
161
137
  }
@@ -163,10 +139,10 @@ const supportedOutputExtensions = () => {
163
139
  }
164
140
 
165
141
  // Return a list of formats as used by the serializers
166
- const supportedOutputFormats = () => {
142
+ export const supportedOutputFormats = () => {
167
143
  const supported = []
168
- for (const format in formats) {
169
- if (formats[format].convertGeom3 === true || formats[format].convertGeom2 === true) {
144
+ for (const format in supportedFormats) {
145
+ if (supportedFormats[format].convertGeom3 === true || supportedFormats[format].convertGeom2 === true) {
170
146
  supported.push(format)
171
147
  }
172
148
  }
@@ -175,21 +151,29 @@ const supportedOutputFormats = () => {
175
151
 
176
152
  // Return a list of file extensions as used by the deserializers
177
153
  // See also code-loading/transfromSources.js
178
- const supportedInputExtensions = () => {
154
+ export const supportedInputExtensions = () => {
179
155
  const supported = []
180
- for (const format in formats) {
181
- if (formats[format].deserializable === true) {
182
- supported.push(formats[format].extension)
156
+ for (const format in supportedFormats) {
157
+ if (supportedFormats[format].deserializable === true) {
158
+ supported.push(supportedFormats[format].extension)
183
159
  }
184
160
  }
185
161
  return supported
186
162
  }
187
163
 
188
- module.exports = {
189
- formats,
190
- conversionFormats,
191
- supportedInputExtensions,
192
- supportedOutputExtensions,
193
- supportedOutputFormats,
194
- supportedFormatsForObjects
164
+ export const getMimeType = (extension) => {
165
+ for (const format in supportedFormats) {
166
+ const meta = supportedFormats[format]
167
+ if (meta.extension === extension) return meta.mimetype
168
+ if (format === extension) return meta.mimetype
169
+ }
170
+ return null
171
+ }
172
+
173
+ export const getExtension = (mimeType) => {
174
+ for (const format in supportedFormats) {
175
+ const meta = supportedFormats[format]
176
+ if (meta.mimetype === mimeType) return meta.extension
177
+ }
178
+ return null
195
179
  }
package/src/index.js ADDED
@@ -0,0 +1,14 @@
1
+ export { deserialize } from './deserialize.js'
2
+ export { deserializers } from './deserializers.js'
3
+
4
+ export { serialize } from './serialize.js'
5
+ export { serializers } from './serializers.js'
6
+
7
+ export {
8
+ supportedFormats,
9
+ getMimeType,
10
+ supportedInputExtensions,
11
+ supportedOutputExtensions,
12
+ supportedOutputFormats,
13
+ supportedFormatsForObjects
14
+ } from './formats.js'
@@ -1,16 +1,17 @@
1
+ import { toArray } from '@jscad/array-utils'
1
2
 
2
- const { toArray } = require('@jscad/array-utils')
3
- const { formats } = require('./formats')
4
- const amfSerializer = require('@jscad/amf-serializer')
5
- const dxfSerializer = require('@jscad/dxf-serializer')
6
- const jsonSerializer = require('@jscad/json-serializer')
7
- const objSerializer = require('@jscad/obj-serializer')
8
- const stlSerializer = require('@jscad/stl-serializer')
9
- const svgSerializer = require('@jscad/svg-serializer')
10
- const x3dSerializer = require('@jscad/x3d-serializer')
11
- const m3fSerializer = require('@jscad/3mf-serializer') // UG javascript doesn't allow names with leading #
3
+ import * as amfSerializer from '@jscad/amf-serializer'
4
+ import * as dxfSerializer from '@jscad/dxf-serializer'
5
+ import * as jsonSerializer from '@jscad/json-serializer'
6
+ import * as objSerializer from '@jscad/obj-serializer'
7
+ import * as stlSerializer from '@jscad/stl-serializer'
8
+ import * as svgSerializer from '@jscad/svg-serializer'
9
+ import * as x3dSerializer from '@jscad/x3d-serializer'
10
+ import * as m3fSerializer from '@jscad/3mf-serializer' // UG javascript doesn't allow names with leading #
12
11
 
13
- const prepareOutput = (objects, params) => {
12
+ import { supportedFormats } from './formats.js'
13
+
14
+ export const prepareOutput = (objects, params) => {
14
15
  const defaults = {
15
16
  format: undefined,
16
17
  version: '0.0.0'
@@ -38,11 +39,11 @@ const prepareOutput = (objects, params) => {
38
39
  '3mf': m3fSerializer, // Geom3 to 3MF
39
40
  json: jsonSerializer, // Geom3 or Geom2 to JSON
40
41
  js: {
41
- mimeType: formats.js.mimetype,
42
+ mimeType: supportedFormats.js.mimetype,
42
43
  serialize: (options, objects) => toArray(objects) // js , pass through
43
44
  },
44
45
  jscad: {
45
- mimeType: formats.jscad.mimetype,
46
+ mimeType: supportedFormats.jscad.mimetype,
46
47
  serialize: (options, objects) => toArray(objects) // jscad , pass through
47
48
  },
48
49
  undefined: () => {
@@ -54,5 +55,3 @@ const prepareOutput = (objects, params) => {
54
55
  const mimeType = outputFormatHandlers[format].mimeType
55
56
  return { data, mimeType }
56
57
  }
57
-
58
- module.exports = prepareOutput
@@ -0,0 +1,35 @@
1
+ import { flatten } from '@jscad/array-utils'
2
+
3
+ import { serializers } from './serializers.js'
4
+
5
+ /**
6
+ * Serialize the given objects as per the given mimeType into the external format.
7
+ * Options can be provided to over-ride or suppliment the defaults used during serialization.
8
+ * See each serializer package for available options.
9
+ * @param {Object} options - options used during deserializing
10
+ * @param {String} mimeType - MIME type of the file
11
+ * @param {Object} objects - one or more objects of which to serialize
12
+ * @return {Object} an object containing the serialize data as well as mime type
13
+ *
14
+ * @example
15
+ * const mimetype = getMimeType('svg')
16
+ * const shapes = [primitives.cirlce(), primitives.star()]
17
+ * const output = serialize({units: 'inches'}, mimetype, shapes)
18
+ */
19
+ export const serialize = (options, mimeType, ...objects) => {
20
+ const defaults = {
21
+ unit: 'mm',
22
+ statusCallback: null
23
+ }
24
+ options = Object.assign({}, defaults, options)
25
+
26
+ objects = flatten(objects)
27
+
28
+ if (mimeType in serializers) {
29
+ const serializer = serializers[mimeType]
30
+ const data = serializer(options, ...objects)
31
+ return { data, mimeType }
32
+ } else {
33
+ throw new Error(`Unknown mime type (${mimeType})`)
34
+ }
35
+ }
@@ -0,0 +1,21 @@
1
+ import * as mf3Serializer from '@jscad/3mf-serializer'
2
+ import * as dxfSerializer from '@jscad/dxf-serializer'
3
+ import * as jsonSerializer from '@jscad/json-serializer'
4
+ import * as objSerializer from '@jscad/obj-serializer'
5
+ import * as stlSerializer from '@jscad/stl-serializer'
6
+ import * as svgSerializer from '@jscad/svg-serializer'
7
+ import * as x3dSerializer from '@jscad/x3d-serializer'
8
+
9
+ // default serializer
10
+ const defaultSerialize = (options, ...objects) => objects
11
+
12
+ export const serializers = {}
13
+ serializers[mf3Serializer.mimeType] = mf3Serializer.serialize
14
+ serializers[dxfSerializer.mimeType] = dxfSerializer.serialize
15
+ serializers[jsonSerializer.mimeType] = jsonSerializer.serialize
16
+ serializers[objSerializer.mimeType] = objSerializer.serialize
17
+ serializers[stlSerializer.mimeType] = stlSerializer.serialize
18
+ serializers[svgSerializer.mimeType] = svgSerializer.serialize
19
+ serializers[x3dSerializer.mimeType] = x3dSerializer.serialize
20
+
21
+ serializers['application/javascript'] = defaultSerialize
@@ -0,0 +1,45 @@
1
+ import test from 'ava'
2
+
3
+ import { countOf } from '../../test/helpers/countOf.js'
4
+
5
+ import { deserialize, getMimeType } from '../src/index.js'
6
+
7
+ test('deserialize svg (simple) to objects', (t) => {
8
+ const mimeType = 'image/svg+xml'
9
+ const objects = deserialize({ output: 'geometry' }, mimeType, source1)
10
+ const expected1 = [{
11
+ isClosed: false,
12
+ points: [[3, -3], [4, -2], [0, 0]],
13
+ transforms: [
14
+ 1, 0, 0, 0,
15
+ 0, 1, 0, 0,
16
+ 0, 0, 1, 0,
17
+ 0, 0, 0, 1
18
+ ]
19
+ }]
20
+ t.deepEqual(expected1, objects)
21
+ })
22
+
23
+ test('deserialize svg (simple) to script', (t) => {
24
+ const mimeType = getMimeType('svg')
25
+ const script = deserialize({ output: 'script', addMetaData: false }, mimeType, source1)
26
+ t.is(countOf('main(params)', script), 1)
27
+ t.is(countOf('path2', script), 3)
28
+ })
29
+
30
+ const source1 = `<?xml version="1.0" encoding="UTF-8"?>
31
+ <!-- Created by JSCAD SVG Serializer -->
32
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
33
+ <svg width="4mm" height="3mm" viewBox="0 0 4 3" fill="none" fill-rule="evenodd" stroke-width="0.1px" version="1.1" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
34
+ <g>
35
+ <path d="M3 3L4 2L0 0"/>
36
+ </g>
37
+ </svg>
38
+ `
39
+
40
+ test('deserialize JS code to JS code', (t) => {
41
+ const mimeType = 'application/javascript'
42
+ const code = 'const a - 1;'
43
+ const script = deserialize({ output: 'script', addMetaData: false }, mimeType, code)
44
+ t.deepEqual(script, code)
45
+ })
@@ -0,0 +1,37 @@
1
+ import test from 'ava'
2
+
3
+ import { line } from '@jscad/modeling'
4
+
5
+ import { serialize } from '../src/index.js'
6
+
7
+ test('serialize 2D path (simple) objects to svg', (t) => {
8
+ const mimeType = 'image/svg+xml'
9
+ // simple open path
10
+ const object1 = line([[0, 0], [1, 1], [-3, 3]])
11
+ const observed = serialize({}, mimeType, object1)
12
+ t.deepEqual(observed, expected1)
13
+ })
14
+
15
+ const expected1 = {
16
+ data: [`<?xml version="1.0" encoding="UTF-8"?>
17
+ <!-- Created by JSCAD SVG Serializer -->
18
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
19
+ <svg width="4mm" height="3mm" viewBox="0 0 4 3" fill="none" fill-rule="evenodd" stroke-width="0.1px" version="1.1" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
20
+ <g>
21
+ <path d="M3 3L4 2L0 0"/>
22
+ </g>
23
+ </svg>
24
+ `],
25
+ mimeType: 'image/svg+xml'
26
+ }
27
+
28
+ test('serialize JS code to JS code', (t) => {
29
+ const mimeType = 'application/javascript'
30
+ const code = 'const a - 1;'
31
+ const observed = serialize({}, mimeType, code)
32
+ const expected = {
33
+ data: [code],
34
+ mimeType: 'application/javascript'
35
+ }
36
+ t.deepEqual(observed, expected)
37
+ })
package/deserializers.js DELETED
@@ -1,19 +0,0 @@
1
- const amfDeSerializer = require('@jscad/amf-deserializer')
2
- const dxfDeSerializer = require('@jscad/dxf-deserializer')
3
- const jsonDeSerializer = require('@jscad/json-deserializer')
4
- const objDeSerializer = require('@jscad/obj-deserializer')
5
- // const scadDeSerializer = require('@jscad/scad-deserializer') //FIXME: upgrade, fix before re-enabling
6
- const stlDeSerializer = require('@jscad/stl-deserializer')
7
- const svgDeSerializer = require('@jscad/svg-deserializer')
8
- const x3dDeSerializer = require('@jscad/x3d-deserializer')
9
-
10
- const deserializers = {}
11
- deserializers[amfDeSerializer.extension] = amfDeSerializer.deserialize
12
- deserializers[dxfDeSerializer.extension] = dxfDeSerializer.deserialize
13
- deserializers[jsonDeSerializer.extension] = jsonDeSerializer.deserialize
14
- deserializers[objDeSerializer.extension] = objDeSerializer.deserialize
15
- deserializers[stlDeSerializer.extension] = stlDeSerializer.deserialize
16
- deserializers[svgDeSerializer.extension] = svgDeSerializer.deserialize
17
- deserializers[x3dDeSerializer.extension] = x3dDeSerializer.deserialize
18
-
19
- module.exports = deserializers
package/index.js DELETED
@@ -1,31 +0,0 @@
1
- const { makeBlob, convertToBlob } = require('@jscad/io-utils')
2
-
3
- const amfSerializer = require('@jscad/amf-serializer')
4
- const dxfSerializer = require('@jscad/dxf-serializer')
5
- const jsonSerializer = require('@jscad/json-serializer')
6
- const objSerializer = require('@jscad/obj-serializer')
7
- const stlSerializer = require('@jscad/stl-serializer')
8
- const svgSerializer = require('@jscad/svg-serializer')
9
- const x3dSerializer = require('@jscad/x3d-serializer')
10
- const m3fSerializer = require('@jscad/3mf-serializer')
11
-
12
- const prepareOutput = require('./prepareOutput')
13
- const deserializers = require('./deserializers')
14
-
15
- const solidsAsBlob = (solids, params) => convertToBlob(prepareOutput(solids, params))
16
-
17
- module.exports = {
18
- makeBlob,
19
- solidsAsBlob,
20
-
21
- amfSerializer,
22
- dxfSerializer,
23
- jsonSerializer,
24
- objSerializer,
25
- stlSerializer,
26
- svgSerializer,
27
- x3dSerializer,
28
- m3fSerializer, // UG javascript doesn't allow names with leading digit
29
-
30
- deserializers
31
- }