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