@jscad/json-serializer 2.0.30 → 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,430 +3,230 @@
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.0.30](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.29...@jscad/json-serializer@2.0.30) (2024-12-29)
7
-
8
- **Note:** Version bump only for package @jscad/json-serializer
9
-
10
-
11
-
12
-
13
-
14
- ## [2.0.29](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.28...@jscad/json-serializer@2.0.29) (2024-11-10)
15
-
16
- **Note:** Version bump only for package @jscad/json-serializer
17
-
18
-
19
-
20
-
21
-
22
- ## [2.0.28](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.27...@jscad/json-serializer@2.0.28) (2024-10-06)
23
-
24
- **Note:** Version bump only for package @jscad/json-serializer
25
-
26
-
27
-
28
-
29
-
30
- ## [2.0.27](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.26...@jscad/json-serializer@2.0.27) (2024-06-02)
31
-
32
- **Note:** Version bump only for package @jscad/json-serializer
33
-
6
+ ## [3.0.1-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.22...@jscad/json-serializer@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.0.26](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.25...@jscad/json-serializer@2.0.26) (2024-02-18)
14
+ * **modeling:** reworked exports to expose a flattened API ([8235238](https://github.com/jscad/OpenJSCAD.org/commit/8235238ad63d063f1e501478cae1208deb130a9c))
39
15
 
40
- **Note:** Version bump only for package @jscad/json-serializer
16
+ # [3.0.0-alpha.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.22...@jscad/json-serializer@3.0.0-alpha.0) (2023-10-09)
41
17
 
18
+ ### Bug Fixes
42
19
 
20
+ * **io:** fix io after V3 refactoring ([7a12bbd](https://github.com/jscad/OpenJSCAD.org/commit/7a12bbdb7b4b3df792a4c5b3c8b30a6a985a48f0))
43
21
 
22
+ ### Features
44
23
 
24
+ * **modeling:** reworked exports to expose a flattened API ([8235238](https://github.com/jscad/OpenJSCAD.org/commit/8235238ad63d063f1e501478cae1208deb130a9c))
45
25
 
46
26
  ## [2.0.25](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.24...@jscad/json-serializer@2.0.25) (2023-06-27)
47
27
 
48
28
  **Note:** Version bump only for package @jscad/json-serializer
49
29
 
50
-
51
-
52
-
53
-
54
30
  ## [2.0.24](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.23...@jscad/json-serializer@2.0.24) (2023-04-30)
55
31
 
56
32
  **Note:** Version bump only for package @jscad/json-serializer
57
33
 
58
-
59
-
60
-
61
-
62
34
  ## [2.0.23](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.22...@jscad/json-serializer@2.0.23) (2022-11-26)
63
35
 
64
36
  **Note:** Version bump only for package @jscad/json-serializer
65
37
 
66
-
67
-
68
-
69
-
70
38
  ## [2.0.22](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.21...@jscad/json-serializer@2.0.22) (2022-08-21)
71
39
 
72
40
  **Note:** Version bump only for package @jscad/json-serializer
73
41
 
74
-
75
-
76
-
77
-
78
42
  ## [2.0.21](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.20...@jscad/json-serializer@2.0.21) (2022-07-17)
79
43
 
80
44
  **Note:** Version bump only for package @jscad/json-serializer
81
45
 
82
-
83
-
84
-
85
-
86
46
  ## [2.0.20](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.19...@jscad/json-serializer@2.0.20) (2022-06-12)
87
47
 
88
48
  **Note:** Version bump only for package @jscad/json-serializer
89
49
 
90
-
91
-
92
-
93
-
94
50
  ## [2.0.19](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.18...@jscad/json-serializer@2.0.19) (2022-05-15)
95
51
 
96
52
  **Note:** Version bump only for package @jscad/json-serializer
97
53
 
98
-
99
-
100
-
101
-
102
54
  ## [2.0.18](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.17...@jscad/json-serializer@2.0.18) (2022-04-24)
103
55
 
104
56
  **Note:** Version bump only for package @jscad/json-serializer
105
57
 
106
-
107
-
108
-
109
-
110
58
  ## [2.0.17](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.16...@jscad/json-serializer@2.0.17) (2022-04-03)
111
59
 
112
60
  **Note:** Version bump only for package @jscad/json-serializer
113
61
 
114
-
115
-
116
-
117
-
118
62
  ## [2.0.16](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.15...@jscad/json-serializer@2.0.16) (2022-04-03)
119
63
 
120
64
  **Note:** Version bump only for package @jscad/json-serializer
121
65
 
122
-
123
-
124
-
125
-
126
66
  ## [2.0.15](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.14...@jscad/json-serializer@2.0.15) (2022-03-13)
127
67
 
128
68
  **Note:** Version bump only for package @jscad/json-serializer
129
69
 
130
-
131
-
132
-
133
-
134
70
  ## [2.0.14](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.13...@jscad/json-serializer@2.0.14) (2022-03-06)
135
71
 
136
72
  **Note:** Version bump only for package @jscad/json-serializer
137
73
 
138
-
139
-
140
-
141
-
142
74
  ## [2.0.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.12...@jscad/json-serializer@2.0.13) (2022-02-19)
143
75
 
144
76
  **Note:** Version bump only for package @jscad/json-serializer
145
77
 
146
-
147
-
148
-
149
-
150
78
  ## [2.0.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.11...@jscad/json-serializer@2.0.12) (2021-12-26)
151
79
 
152
80
  **Note:** Version bump only for package @jscad/json-serializer
153
81
 
154
-
155
-
156
-
157
-
158
82
  ## [2.0.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.10...@jscad/json-serializer@2.0.11) (2021-12-11)
159
83
 
160
84
  **Note:** Version bump only for package @jscad/json-serializer
161
85
 
162
-
163
-
164
-
165
-
166
86
  ## [2.0.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.9...@jscad/json-serializer@2.0.10) (2021-11-07)
167
87
 
168
88
  **Note:** Version bump only for package @jscad/json-serializer
169
89
 
170
-
171
-
172
-
173
-
174
90
  ## [2.0.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.8...@jscad/json-serializer@2.0.9) (2021-10-17)
175
91
 
176
92
  **Note:** Version bump only for package @jscad/json-serializer
177
93
 
178
-
179
-
180
-
181
-
182
94
  ## [2.0.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.7...@jscad/json-serializer@2.0.8) (2021-10-04)
183
95
 
184
96
  **Note:** Version bump only for package @jscad/json-serializer
185
97
 
186
-
187
-
188
-
189
-
190
98
  ## [2.0.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.6...@jscad/json-serializer@2.0.7) (2021-09-27)
191
99
 
192
100
  **Note:** Version bump only for package @jscad/json-serializer
193
101
 
194
-
195
-
196
-
197
-
198
102
  ## [2.0.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.5...@jscad/json-serializer@2.0.6) (2021-09-09)
199
103
 
200
-
201
104
  ### Bug Fixes
202
105
 
203
106
  * **web:** added open issues and discord community to help ([4ea1196](https://github.com/jscad/OpenJSCAD.org/commit/4ea11966af4b3ecbb5c1a3d53b7ac90c4cd349b1))
204
107
 
205
-
206
-
207
-
208
-
209
108
  ## [2.0.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.4...@jscad/json-serializer@2.0.5) (2021-06-20)
210
109
 
211
110
  **Note:** Version bump only for package @jscad/json-serializer
212
111
 
213
-
214
-
215
-
216
-
217
112
  ## [2.0.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.3...@jscad/json-serializer@2.0.4) (2021-06-11)
218
113
 
219
114
  **Note:** Version bump only for package @jscad/json-serializer
220
115
 
221
-
222
-
223
-
224
-
225
116
  ## [2.0.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.2...@jscad/json-serializer@2.0.3) (2021-06-01)
226
117
 
227
118
  **Note:** Version bump only for package @jscad/json-serializer
228
119
 
229
-
230
-
231
-
232
-
233
120
  ## [2.0.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.0...@jscad/json-serializer@2.0.2) (2021-04-20)
234
121
 
235
-
236
122
  ### Bug Fixes
237
123
 
238
124
  * **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
239
125
  * **io:** io revisited ([#714](https://github.com/jscad/OpenJSCAD.org/issues/714)) ([22f04f1](https://github.com/jscad/OpenJSCAD.org/commit/22f04f1b2894a82e24952655875e73b74727bf86))
240
126
 
241
-
242
-
243
-
244
-
245
127
  ## [2.0.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.0...@jscad/json-serializer@2.0.1) (2021-04-15)
246
128
 
247
-
248
129
  ### Bug Fixes
249
130
 
250
131
  * **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
251
132
  * **io:** io revisited ([#714](https://github.com/jscad/OpenJSCAD.org/issues/714)) ([22f04f1](https://github.com/jscad/OpenJSCAD.org/commit/22f04f1b2894a82e24952655875e73b74727bf86))
252
133
 
253
-
254
-
255
-
256
-
257
134
  # [2.0.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.11...@jscad/json-serializer@2.0.0) (2021-04-12)
258
135
 
259
136
  **Note:** Version bump only for package @jscad/json-serializer
260
137
 
261
-
262
-
263
-
264
-
265
138
  # [2.0.0-alpha.11](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.10...@jscad/json-serializer@2.0.0-alpha.11) (2021-03-07)
266
139
 
267
140
  **Note:** Version bump only for package @jscad/json-serializer
268
141
 
269
-
270
-
271
-
272
-
273
142
  # [2.0.0-alpha.10](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.9...@jscad/json-serializer@2.0.0-alpha.10) (2021-02-07)
274
143
 
275
144
  **Note:** Version bump only for package @jscad/json-serializer
276
145
 
277
-
278
-
279
-
280
-
281
146
  # [2.0.0-alpha.9](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.8...@jscad/json-serializer@2.0.0-alpha.9) (2021-01-02)
282
147
 
283
148
  **Note:** Version bump only for package @jscad/json-serializer
284
149
 
285
-
286
-
287
-
288
-
289
150
  # [2.0.0-alpha.8](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.7...@jscad/json-serializer@2.0.0-alpha.8) (2020-12-04)
290
151
 
291
152
  **Note:** Version bump only for package @jscad/json-serializer
292
153
 
293
-
294
-
295
-
296
-
297
154
  # [2.0.0-alpha.7](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.6...@jscad/json-serializer@2.0.0-alpha.7) (2020-11-07)
298
155
 
299
-
300
156
  ### Bug Fixes
301
157
 
302
158
  * **io:** io revisited ([#714](https://github.com/jscad/OpenJSCAD.org/issues/714)) ([22f04f1](https://github.com/jscad/OpenJSCAD.org/commit/22f04f1b2894a82e24952655875e73b74727bf86))
303
159
 
304
-
305
-
306
-
307
-
308
160
  # [2.0.0-alpha.6](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.5...@jscad/json-serializer@2.0.0-alpha.6) (2020-10-11)
309
161
 
310
-
311
162
  ### Bug Fixes
312
163
 
313
164
  * **all:** V2 : several fixes for modeling ([#705](https://github.com/jscad/OpenJSCAD.org/issues/705)) ([62017a4](https://github.com/jscad/OpenJSCAD.org/commit/62017a41214169d6e000f1e0c11aaefdd68e1097))
314
165
 
315
-
316
-
317
-
318
-
319
166
  # [2.0.0-alpha.5](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.4...@jscad/json-serializer@2.0.0-alpha.5) (2020-09-29)
320
167
 
321
168
  **Note:** Version bump only for package @jscad/json-serializer
322
169
 
323
-
324
-
325
-
326
-
327
170
  # [2.0.0-alpha.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.3...@jscad/json-serializer@2.0.0-alpha.4) (2020-09-28)
328
171
 
329
172
  **Note:** Version bump only for package @jscad/json-serializer
330
173
 
331
-
332
-
333
-
334
-
335
174
  # [2.0.0-alpha.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.2...@jscad/json-serializer@2.0.0-alpha.3) (2020-09-19)
336
175
 
337
176
  **Note:** Version bump only for package @jscad/json-serializer
338
177
 
339
-
340
-
341
-
342
-
343
178
  # [2.0.0-alpha.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.1...@jscad/json-serializer@2.0.0-alpha.2) (2020-09-08)
344
179
 
345
180
  **Note:** Version bump only for package @jscad/json-serializer
346
181
 
347
-
348
-
349
-
350
-
351
182
  # [2.0.0-alpha.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/json-serializer@2.0.0-alpha.0...@jscad/json-serializer@2.0.0-alpha.1) (2020-08-19)
352
183
 
353
184
  **Note:** Version bump only for package @jscad/json-serializer
354
185
 
355
-
356
-
357
-
358
-
359
186
  # 2.0.0-alpha.0 (2020-08-13)
360
187
 
361
188
  ### Features
362
189
 
363
190
  * **json-serializer:** Upgrade/overhaul JSON Serializer (#545)
364
191
 
365
-
366
-
367
-
368
-
369
192
  <a name="0.2.0"></a>
370
193
  # [0.2.0](https://github.com/jscad/io/compare/@jscad/json-serializer@0.1.2...@jscad/json-serializer@0.2.0) (2018-11-25)
371
194
 
372
195
  <a name="0.1.2"></a>
373
196
  ## [0.1.2](https://github.com/jscad/io/compare/@jscad/json-serializer@0.1.1...@jscad/json-serializer@0.1.2) (2018-09-02)
374
197
 
375
-
376
198
  ### Bug Fixes
377
199
 
378
200
  * **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))
379
201
 
380
-
381
-
382
-
383
202
  <a name="0.1.1"></a>
384
203
  ## [0.1.1](https://github.com/jscad/io/compare/@jscad/json-serializer@0.1.0...@jscad/json-serializer@0.1.1) (2017-12-14)
385
204
 
386
-
387
-
388
-
389
205
  **Note:** Version bump only for package @jscad/json-serializer
390
206
 
391
207
  <a name="0.1.0"></a>
392
208
  # [0.1.0](https://github.com/jscad/io/compare/@jscad/json-serializer@0.0.5...@jscad/json-serializer@0.1.0) (2017-11-29)
393
209
 
394
-
395
210
  ### Features
396
211
 
397
212
  * 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))
398
213
 
399
-
400
-
401
-
402
214
  <a name="0.0.5"></a>
403
215
  ## [0.0.5](https://github.com/jscad/io/compare/@jscad/json-serializer@0.0.4...@jscad/json-serializer@0.0.5) (2017-11-04)
404
216
 
405
-
406
-
407
-
408
217
  **Note:** Version bump only for package @jscad/json-serializer
409
218
 
410
219
  <a name="0.0.4"></a>
411
220
  ## [0.0.4](https://github.com/jscad/io/compare/@jscad/json-serializer@0.0.3...@jscad/json-serializer@0.0.4) (2017-10-30)
412
221
 
413
-
414
-
415
-
416
222
  **Note:** Version bump only for package @jscad/json-serializer
417
223
 
418
224
  <a name="0.0.3"></a>
419
225
  ## [0.0.3](https://github.com/jscad/io/compare/@jscad/json-serializer@0.0.2...@jscad/json-serializer@0.0.3) (2017-10-10)
420
226
 
421
-
422
-
423
-
424
227
  **Note:** Version bump only for package @jscad/json-serializer
425
228
 
426
229
  <a name="0.0.2"></a>
427
230
  ## 0.0.2 (2017-10-10)
428
231
 
429
-
430
-
431
-
432
232
  **Note:** Version bump only for package @jscad/json-serializer
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)
@@ -71,5 +71,7 @@ Small Note: If editing this README, please conform to the [standard-readme](http
71
71
 
72
72
  ## License
73
73
 
74
+ Copyright (c) JSCAD Organization
75
+
74
76
  [The MIT License (MIT)](./LICENSE)
75
77
  (unless specified otherwise)
@@ -0,0 +1,13 @@
1
+ /**
2
+ * JSON Serializer for JSCAD
3
+ * @module @jscad/json-serializer
4
+ * @version 3.0.1-alpha.0
5
+ * @license MIT
6
+ */
7
+ /**
8
+ * JSCAD Utility functions for arrays
9
+ * @module @jscad/array-utils
10
+ * @version 3.0.1-alpha.0
11
+ * @license MIT
12
+ */
13
+ const flatten=arr=>arr.reduce(((acc,val)=>Array.isArray(val)?acc.concat(flatten(val)):acc.concat(val)),[]),mimeType="application/json",replacer=(key,value)=>{switch(key){case"transforms":case"plane":return Array.from(value);case"points":case"vertices":return value.map((v=>Array.from(v)));case"outlines":return value.map((o=>o.map((v=>Array.from(v)))))}return value},serialize=(options,...objects)=>{options=Object.assign({},{statusCallback:null},options),objects=flatten(objects),options.statusCallback&&options.statusCallback({progress:0});const notation=JSON.stringify(objects,replacer);return options.statusCallback&&options.statusCallback({progress:100}),[notation]};export{mimeType,serialize};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * JSON Serializer for JSCAD
3
+ * @module @jscad/json-serializer
4
+ * @version 3.0.1-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.1-alpha.0
12
+ * @license MIT
13
+ */
14
+ const flatten=arr=>arr.reduce(((acc,val)=>Array.isArray(val)?acc.concat(flatten(val)):acc.concat(val)),[]),replacer=(key,value)=>{switch(key){case"transforms":case"plane":return Array.from(value);case"points":case"vertices":return value.map((v=>Array.from(v)));case"outlines":return value.map((o=>o.map((v=>Array.from(v)))))}return value};exports.mimeType="application/json",exports.serialize=(options,...objects)=>{options=Object.assign({},{statusCallback:null},options),objects=flatten(objects),options.statusCallback&&options.statusCallback({progress:0});const notation=JSON.stringify(objects,replacer);return options.statusCallback&&options.statusCallback({progress:100}),[notation]},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).jscadJsonSerializer={});
package/package.json CHANGED
@@ -1,22 +1,27 @@
1
1
  {
2
2
  "name": "@jscad/json-serializer",
3
- "version": "2.0.30",
3
+ "version": "3.0.1-alpha.0",
4
4
  "description": "JSON Serializer for JSCAD",
5
5
  "homepage": "https://openjscad.xyz/",
6
6
  "repository": "https://github.com/jscad/OpenJSCAD.org",
7
- "main": "index.js",
7
+ "type": "module",
8
+ "main": "src/index.js",
9
+ "unpkg": "dist/jscad-json-serializer.min.js",
10
+ "module": "dist/jscad-json-serializer.es.js",
8
11
  "scripts": {
9
- "coverage": "nyc --all --reporter=html --reporter=text npm test",
10
- "test": "ava 'tests/*.test.js' --verbose --timeout 2m"
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": "http://www.z3d.jp"
20
+ "url": "https://github.com/z3dev"
16
21
  },
17
22
  {
18
23
  "name": "Mark 'kaosat-dev' Moissette",
19
- "url": "http://kaosat.net"
24
+ "url": "https://github.com/kaosat-dev"
20
25
  }
21
26
  ],
22
27
  "keywords": [
@@ -28,11 +33,16 @@
28
33
  ],
29
34
  "license": "MIT",
30
35
  "dependencies": {
31
- "@jscad/modeling": "2.12.5"
36
+ "@jscad/array-utils": "3.0.1-alpha.0",
37
+ "@jscad/modeling": "3.0.1-alpha.0"
32
38
  },
33
39
  "devDependencies": {
34
- "ava": "3.15.0",
35
- "nyc": "15.1.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"
36
46
  },
37
- "gitHead": "d8010c4f1d70685404a510d604f8b6d5c362f93a"
47
+ "gitHead": "0660b5c1f1a5faf54d4cfae1cb85bb94182a8d32"
38
48
  }
@@ -0,0 +1,25 @@
1
+ import banner from 'rollup-plugin-banner'
2
+ import { nodeResolve } from '@rollup/plugin-node-resolve'
3
+ import terser from '@rollup/plugin-terser'
4
+
5
+ export default {
6
+ input: 'src/index.js',
7
+
8
+ output: [
9
+ {
10
+ file: 'dist/jscad-json-serializer.min.js',
11
+ format: 'umd',
12
+ name: 'jscadJsonSerializer'
13
+ },
14
+ {
15
+ file: 'dist/jscad-json-serializer.es.js',
16
+ format: 'es'
17
+ }
18
+ ],
19
+
20
+ plugins: [
21
+ nodeResolve(),
22
+ banner('<%= pkg.description %>\n@module <%= pkg.name %>\n@version <%= pkg.version %>\n@license <%= pkg.license %>'),
23
+ terser({ compress: { module: true }, mangle: false, format: { comments: 'some' } })
24
+ ]
25
+ }
@@ -1,21 +1,3 @@
1
- /*
2
- JSCAD Object to JSON Notation Serialization
3
-
4
- ## License
5
-
6
- Copyright (c) JSCAD Organization https://github.com/jscad
7
-
8
- All code released under MIT license
9
-
10
- Notes:
11
- 1) geom2 conversion to:
12
- JSON
13
- 2) geom3 conversion to:
14
- JSON
15
- 3) path2 conversion to:
16
- JSON
17
- */
18
-
19
1
  /**
20
2
  * Serializer of JSCAD geometries to JSON strings.
21
3
  * @module io/json-serializer
@@ -23,7 +5,9 @@ Notes:
23
5
  * const { serializer, mimeType } = require('@jscad/json-serializer')
24
6
  */
25
7
 
26
- const { utils } = require('@jscad/modeling')
8
+ import { flatten } from '@jscad/array-utils'
9
+
10
+ const mimeType = 'application/json'
27
11
 
28
12
  // Replace all typed arrays in geometries with standard Arrays
29
13
  // NOTE: 'this' in replacer is the object in which key was found
@@ -35,8 +19,8 @@ const replacer = (key, value) => {
35
19
  case 'points':
36
20
  case 'vertices':
37
21
  return value.map((v) => Array.from(v))
38
- case 'sides':
39
- return value.map((s) => [Array.from(s[0]), Array.from(s[1])])
22
+ case 'outlines':
23
+ return value.map((o) => o.map((v) => Array.from(v)))
40
24
  default:
41
25
  break
42
26
  }
@@ -50,7 +34,7 @@ const replacer = (key, value) => {
50
34
  * @returns {Array} serialized contents as JSON string
51
35
  * @alias module:io/json-serializer.serialize
52
36
  * @example
53
- * const geometry = primitives.cube()
37
+ * const geometry = cube()
54
38
  * const jsonData = serializer({}, geometry)
55
39
  */
56
40
  const serialize = (options, ...objects) => {
@@ -59,7 +43,7 @@ const serialize = (options, ...objects) => {
59
43
  }
60
44
  options = Object.assign({}, defaults, options)
61
45
 
62
- objects = utils.flatten(objects)
46
+ objects = flatten(objects)
63
47
 
64
48
  options.statusCallback && options.statusCallback({ progress: 0 })
65
49
 
@@ -70,9 +54,7 @@ const serialize = (options, ...objects) => {
70
54
  return [notation]
71
55
  }
72
56
 
73
- const mimeType = 'application/json'
74
-
75
- module.exports = {
76
- serialize,
77
- mimeType
57
+ export {
58
+ mimeType,
59
+ serialize
78
60
  }
@@ -1,8 +1,8 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { primitives } = require('@jscad/modeling')
3
+ import { circle, rectangle } from '@jscad/modeling'
4
4
 
5
- const { serialize } = require('../index.js')
5
+ import { serialize } from '../src/index.js'
6
6
 
7
7
  const countOf = (search, string) => {
8
8
  let count = 0
@@ -15,28 +15,28 @@ const countOf = (search, string) => {
15
15
  }
16
16
 
17
17
  test('2D geometry to JSON', (t) => {
18
- const geom1 = primitives.rectangle()
18
+ const geom1 = rectangle()
19
19
 
20
20
  const obs1 = serialize({}, geom1)
21
- t.is(countOf('sides', obs1[0]), 1)
21
+ t.is(countOf('outlines', obs1[0]), 1)
22
22
  t.is(countOf('transforms', obs1[0]), 1)
23
- t.is(countOf('[', obs1[0]), 15)
24
- t.is(countOf(']', obs1[0]), 15)
25
- t.is(countOf(',', obs1[0]), 31)
23
+ t.is(countOf('[', obs1[0]), 8)
24
+ t.is(countOf(']', obs1[0]), 8)
25
+ t.is(countOf(',', obs1[0]), 23)
26
26
 
27
- const geom2 = primitives.circle({ segments: 16 })
27
+ const geom2 = circle({ segments: 16 })
28
28
 
29
29
  const obs2 = serialize({}, geom2)
30
- t.is(countOf('sides', obs2[0]), 1)
30
+ t.is(countOf('outlines', obs2[0]), 1)
31
31
  t.is(countOf('transforms', obs2[0]), 1)
32
- t.is(countOf('[', obs2[0]), 51)
33
- t.is(countOf(']', obs2[0]), 51)
34
- t.is(countOf(',', obs2[0]), 79)
32
+ t.is(countOf('[', obs2[0]), 20)
33
+ t.is(countOf(']', obs2[0]), 20)
34
+ t.is(countOf(',', obs2[0]), 47)
35
35
 
36
36
  const obs3 = serialize({}, geom1, geom2)
37
- t.is(countOf('sides', obs3[0]), 2)
37
+ t.is(countOf('outlines', obs3[0]), 2)
38
38
  t.is(countOf('transforms', obs3[0]), 2)
39
- t.is(countOf('[', obs3[0]), 65)
40
- t.is(countOf(']', obs3[0]), 65)
41
- t.is(countOf(',', obs3[0]), 111)
39
+ t.is(countOf('[', obs3[0]), 27)
40
+ t.is(countOf(']', obs3[0]), 27)
41
+ t.is(countOf(',', obs3[0]), 71)
42
42
  })
@@ -1,8 +1,8 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { primitives } = require('@jscad/modeling')
3
+ import { cube, sphere } from '@jscad/modeling'
4
4
 
5
- const { serialize } = require('../index.js')
5
+ import { serialize } from '../src/index.js'
6
6
 
7
7
  const countOf = (search, string) => {
8
8
  let count = 0
@@ -15,7 +15,7 @@ const countOf = (search, string) => {
15
15
  }
16
16
 
17
17
  test('3D Geometry to JSON', (t) => {
18
- const geom1 = primitives.cube()
18
+ const geom1 = cube()
19
19
  const obs1 = serialize({}, geom1)
20
20
  t.is(countOf('polygons', obs1[0]), 1)
21
21
  t.is(countOf('transforms', obs1[0]), 1)
@@ -23,7 +23,7 @@ test('3D Geometry to JSON', (t) => {
23
23
  t.is(countOf(']', obs1[0]), 33)
24
24
  t.is(countOf(',', obs1[0]), 87)
25
25
 
26
- const geom2 = primitives.sphere({ segments: 12 })
26
+ const geom2 = sphere({ segments: 12 })
27
27
  const obs2 = serialize({}, geom2)
28
28
  t.is(countOf('polygons', obs2[0]), 1)
29
29
  t.is(countOf('transforms', obs2[0]), 1)
@@ -1,8 +1,8 @@
1
- const test = require('ava')
1
+ import test from 'ava'
2
2
 
3
- const { primitives } = require('@jscad/modeling')
3
+ import { arc } from '@jscad/modeling'
4
4
 
5
- const { serialize } = require('../index.js')
5
+ import { serialize } from '../src/index.js'
6
6
 
7
7
  const countOf = (search, string) => {
8
8
  let count = 0
@@ -15,7 +15,7 @@ const countOf = (search, string) => {
15
15
  }
16
16
 
17
17
  test('2D Path to JSON', (t) => {
18
- const path1 = primitives.arc({ center: [5, 5], endAngle: Math.PI / 4, segments: 16 })
18
+ const path1 = arc({ center: [5, 5], endAngle: Math.PI / 4, segments: 16 })
19
19
  const obs1 = serialize({}, path1)
20
20
  t.is(countOf('points', obs1[0]), 1)
21
21
  t.is(countOf('transforms', obs1[0]), 1)
@@ -23,7 +23,7 @@ test('2D Path to JSON', (t) => {
23
23
  t.is(countOf(']', obs1[0]), 7)
24
24
  t.is(countOf(',', obs1[0]), 24)
25
25
 
26
- const path2 = primitives.arc({ segments: 72 })
26
+ const path2 = arc({ segments: 72 })
27
27
  const obs2 = serialize({}, path2)
28
28
  t.is(countOf('points', obs2[0]), 1)
29
29
  t.is(countOf('transforms', obs2[0]), 1)