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