@taulabs/openrscad-engine 0.11.0-beta.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.
@@ -0,0 +1,997 @@
1
+ /* @ts-self-types="./openrscad.d.ts" */
2
+
3
+ /**
4
+ * One owned native 3D artifact plus the operational metadata needed by hosts.
5
+ */
6
+ export class ExportShape3DResult {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(ExportShape3DResult.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ ExportShape3DResultFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ ExportShape3DResultFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_exportshape3dresult_free(ptr, 0);
22
+ }
23
+ /**
24
+ * @returns {number}
25
+ */
26
+ get area() {
27
+ const ret = wasm.exportshape3dresult_area(this.__wbg_ptr);
28
+ return ret;
29
+ }
30
+ /**
31
+ * @returns {string}
32
+ */
33
+ get diagnostics() {
34
+ let deferred1_0;
35
+ let deferred1_1;
36
+ try {
37
+ const ret = wasm.exportshape3dresult_diagnostics(this.__wbg_ptr);
38
+ deferred1_0 = ret[0];
39
+ deferred1_1 = ret[1];
40
+ return getStringFromWasm0(ret[0], ret[1]);
41
+ } finally {
42
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
43
+ }
44
+ }
45
+ /**
46
+ * @returns {string}
47
+ */
48
+ get echo() {
49
+ let deferred1_0;
50
+ let deferred1_1;
51
+ try {
52
+ const ret = wasm.exportshape3dresult_echo(this.__wbg_ptr);
53
+ deferred1_0 = ret[0];
54
+ deferred1_1 = ret[1];
55
+ return getStringFromWasm0(ret[0], ret[1]);
56
+ } finally {
57
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
58
+ }
59
+ }
60
+ /**
61
+ * @returns {string}
62
+ */
63
+ get error() {
64
+ let deferred1_0;
65
+ let deferred1_1;
66
+ try {
67
+ const ret = wasm.exportshape3dresult_error(this.__wbg_ptr);
68
+ deferred1_0 = ret[0];
69
+ deferred1_1 = ret[1];
70
+ return getStringFromWasm0(ret[0], ret[1]);
71
+ } finally {
72
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
73
+ }
74
+ }
75
+ /**
76
+ * @returns {string}
77
+ */
78
+ get format() {
79
+ let deferred1_0;
80
+ let deferred1_1;
81
+ try {
82
+ const ret = wasm.exportshape3dresult_format(this.__wbg_ptr);
83
+ deferred1_0 = ret[0];
84
+ deferred1_1 = ret[1];
85
+ return getStringFromWasm0(ret[0], ret[1]);
86
+ } finally {
87
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
88
+ }
89
+ }
90
+ /**
91
+ * @returns {string}
92
+ */
93
+ get geom_errors() {
94
+ let deferred1_0;
95
+ let deferred1_1;
96
+ try {
97
+ const ret = wasm.exportshape3dresult_geom_errors(this.__wbg_ptr);
98
+ deferred1_0 = ret[0];
99
+ deferred1_1 = ret[1];
100
+ return getStringFromWasm0(ret[0], ret[1]);
101
+ } finally {
102
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
103
+ }
104
+ }
105
+ /**
106
+ * @returns {boolean}
107
+ */
108
+ get is_2d() {
109
+ const ret = wasm.exportshape3dresult_is_2d(this.__wbg_ptr);
110
+ return ret !== 0;
111
+ }
112
+ /**
113
+ * @returns {boolean}
114
+ */
115
+ get ok() {
116
+ const ret = wasm.exportshape3dresult_ok(this.__wbg_ptr);
117
+ return ret !== 0;
118
+ }
119
+ /**
120
+ * Transfer artifact ownership to JavaScript. A second call returns empty.
121
+ * @returns {Uint8Array}
122
+ */
123
+ take_bytes() {
124
+ const ret = wasm.exportshape3dresult_take_bytes(this.__wbg_ptr);
125
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
126
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
127
+ return v1;
128
+ }
129
+ /**
130
+ * @returns {number}
131
+ */
132
+ get triangle_count() {
133
+ const ret = wasm.exportshape3dresult_triangle_count(this.__wbg_ptr);
134
+ return ret >>> 0;
135
+ }
136
+ /**
137
+ * @returns {number}
138
+ */
139
+ get vertex_count() {
140
+ const ret = wasm.exportshape3dresult_vertex_count(this.__wbg_ptr);
141
+ return ret >>> 0;
142
+ }
143
+ /**
144
+ * @returns {string}
145
+ */
146
+ get viewport() {
147
+ let deferred1_0;
148
+ let deferred1_1;
149
+ try {
150
+ const ret = wasm.exportshape3dresult_viewport(this.__wbg_ptr);
151
+ deferred1_0 = ret[0];
152
+ deferred1_1 = ret[1];
153
+ return getStringFromWasm0(ret[0], ret[1]);
154
+ } finally {
155
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
156
+ }
157
+ }
158
+ /**
159
+ * @returns {number}
160
+ */
161
+ get volume() {
162
+ const ret = wasm.exportshape3dresult_volume(this.__wbg_ptr);
163
+ return ret;
164
+ }
165
+ /**
166
+ * @returns {string}
167
+ */
168
+ get warnings() {
169
+ let deferred1_0;
170
+ let deferred1_1;
171
+ try {
172
+ const ret = wasm.exportshape3dresult_warnings(this.__wbg_ptr);
173
+ deferred1_0 = ret[0];
174
+ deferred1_1 = ret[1];
175
+ return getStringFromWasm0(ret[0], ret[1]);
176
+ } finally {
177
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
178
+ }
179
+ }
180
+ }
181
+ if (Symbol.dispose) ExportShape3DResult.prototype[Symbol.dispose] = ExportShape3DResult.prototype.free;
182
+
183
+ /**
184
+ * The result of rendering a `.scad` source string.
185
+ *
186
+ * Mesh data is a non-indexed triangle soup with flat (per-face) normals:
187
+ * `positions` and `normals` both hold 9 floats per triangle.
188
+ */
189
+ export class RenderResult {
190
+ static __wrap(ptr) {
191
+ const obj = Object.create(RenderResult.prototype);
192
+ obj.__wbg_ptr = ptr;
193
+ RenderResultFinalization.register(obj, obj.__wbg_ptr, obj);
194
+ return obj;
195
+ }
196
+ __destroy_into_raw() {
197
+ const ptr = this.__wbg_ptr;
198
+ this.__wbg_ptr = 0;
199
+ RenderResultFinalization.unregister(this);
200
+ return ptr;
201
+ }
202
+ free() {
203
+ const ptr = this.__destroy_into_raw();
204
+ wasm.__wbg_renderresult_free(ptr, 0);
205
+ }
206
+ /**
207
+ * @returns {number}
208
+ */
209
+ get area() {
210
+ const ret = wasm.renderresult_area(this.__wbg_ptr);
211
+ return ret;
212
+ }
213
+ /**
214
+ * Structured diagnostics as a JSON array (`[{severity,message,start,end}]`),
215
+ * where start/end are byte offsets into the source, or -1 when unknown.
216
+ * @returns {string}
217
+ */
218
+ get diagnostics() {
219
+ let deferred1_0;
220
+ let deferred1_1;
221
+ try {
222
+ const ret = wasm.renderresult_diagnostics(this.__wbg_ptr);
223
+ deferred1_0 = ret[0];
224
+ deferred1_1 = ret[1];
225
+ return getStringFromWasm0(ret[0], ret[1]);
226
+ } finally {
227
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
228
+ }
229
+ }
230
+ /**
231
+ * Newline-joined `ECHO:` output.
232
+ * @returns {string}
233
+ */
234
+ get echo() {
235
+ let deferred1_0;
236
+ let deferred1_1;
237
+ try {
238
+ const ret = wasm.renderresult_echo(this.__wbg_ptr);
239
+ deferred1_0 = ret[0];
240
+ deferred1_1 = ret[1];
241
+ return getStringFromWasm0(ret[0], ret[1]);
242
+ } finally {
243
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
244
+ }
245
+ }
246
+ /**
247
+ * Error message, or empty string if the render succeeded.
248
+ * @returns {string}
249
+ */
250
+ get error() {
251
+ let deferred1_0;
252
+ let deferred1_1;
253
+ try {
254
+ const ret = wasm.renderresult_error(this.__wbg_ptr);
255
+ deferred1_0 = ret[0];
256
+ deferred1_1 = ret[1];
257
+ return getStringFromWasm0(ret[0], ret[1]);
258
+ } finally {
259
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
260
+ }
261
+ }
262
+ /**
263
+ * Newline-joined recoverable geometry errors (degraded render), or empty
264
+ * when the geometry is exact. See the field docs on `geom_errors`.
265
+ * @returns {string}
266
+ */
267
+ get geom_errors() {
268
+ let deferred1_0;
269
+ let deferred1_1;
270
+ try {
271
+ const ret = wasm.renderresult_geom_errors(this.__wbg_ptr);
272
+ deferred1_0 = ret[0];
273
+ deferred1_1 = ret[1];
274
+ return getStringFromWasm0(ret[0], ret[1]);
275
+ } finally {
276
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
277
+ }
278
+ }
279
+ /**
280
+ * Per-group ranges/colors as JSON (`[{start,count,color,mode}]`); empty `[]`
281
+ * when the model uses no display attributes.
282
+ * @returns {string}
283
+ */
284
+ get groups() {
285
+ let deferred1_0;
286
+ let deferred1_1;
287
+ try {
288
+ const ret = wasm.renderresult_groups(this.__wbg_ptr);
289
+ deferred1_0 = ret[0];
290
+ deferred1_1 = ret[1];
291
+ return getStringFromWasm0(ret[0], ret[1]);
292
+ } finally {
293
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
294
+ }
295
+ }
296
+ /**
297
+ * Whether the model is a 2D object (exportable to DXF/SVG) vs a 3D solid.
298
+ * @returns {boolean}
299
+ */
300
+ get is_2d() {
301
+ const ret = wasm.renderresult_is_2d(this.__wbg_ptr);
302
+ return ret !== 0;
303
+ }
304
+ /**
305
+ * Per-face normals (9 f32 per triangle) as a `Float32Array`.
306
+ * @returns {Float32Array}
307
+ */
308
+ get normals() {
309
+ const ret = wasm.renderresult_normals(this.__wbg_ptr);
310
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
311
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
312
+ return v1;
313
+ }
314
+ /**
315
+ * Whether the render succeeded (no error).
316
+ * @returns {boolean}
317
+ */
318
+ get ok() {
319
+ const ret = wasm.renderresult_ok(this.__wbg_ptr);
320
+ return ret !== 0;
321
+ }
322
+ /**
323
+ * Triangle-soup vertex positions (9 f32 per triangle) as a `Float32Array`.
324
+ * @returns {Float32Array}
325
+ */
326
+ get positions() {
327
+ const ret = wasm.renderresult_positions(this.__wbg_ptr);
328
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
329
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
330
+ return v1;
331
+ }
332
+ /**
333
+ * @returns {Float32Array}
334
+ */
335
+ get preview_normals() {
336
+ const ret = wasm.renderresult_preview_normals(this.__wbg_ptr);
337
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
338
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
339
+ return v1;
340
+ }
341
+ /**
342
+ * Preview triangle soup (concatenated colored groups); empty when the model
343
+ * uses no color/`#`/`%` (the viewer then uses `positions`).
344
+ * @returns {Float32Array}
345
+ */
346
+ get preview_positions() {
347
+ const ret = wasm.renderresult_preview_positions(this.__wbg_ptr);
348
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
349
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
350
+ return v1;
351
+ }
352
+ /**
353
+ * Per-group provenance ranges/span-stacks as JSON (`[{start,count,spans}]`);
354
+ * empty when the model has no pickable geometry.
355
+ * @returns {string}
356
+ */
357
+ get provenance() {
358
+ let deferred1_0;
359
+ let deferred1_1;
360
+ try {
361
+ const ret = wasm.renderresult_provenance(this.__wbg_ptr);
362
+ deferred1_0 = ret[0];
363
+ deferred1_1 = ret[1];
364
+ return getStringFromWasm0(ret[0], ret[1]);
365
+ } finally {
366
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
367
+ }
368
+ }
369
+ /**
370
+ * @returns {Float32Array}
371
+ */
372
+ get provenance_normals() {
373
+ const ret = wasm.renderresult_provenance_normals(this.__wbg_ptr);
374
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
375
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
376
+ return v1;
377
+ }
378
+ /**
379
+ * Provenance triangle soup (concatenated per-statement groups); empty only
380
+ * for models with no geometry.
381
+ * @returns {Float32Array}
382
+ */
383
+ get provenance_positions() {
384
+ const ret = wasm.renderresult_provenance_positions(this.__wbg_ptr);
385
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
386
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
387
+ return v1;
388
+ }
389
+ /**
390
+ * @returns {number}
391
+ */
392
+ get triangle_count() {
393
+ const ret = wasm.renderresult_triangle_count(this.__wbg_ptr);
394
+ return ret >>> 0;
395
+ }
396
+ /**
397
+ * @returns {number}
398
+ */
399
+ get vertex_count() {
400
+ const ret = wasm.renderresult_vertex_count(this.__wbg_ptr);
401
+ return ret >>> 0;
402
+ }
403
+ /**
404
+ * `$vp*` viewport variables as JSON, or empty when the source has no `$vp`.
405
+ * @returns {string}
406
+ */
407
+ get viewport() {
408
+ let deferred1_0;
409
+ let deferred1_1;
410
+ try {
411
+ const ret = wasm.renderresult_viewport(this.__wbg_ptr);
412
+ deferred1_0 = ret[0];
413
+ deferred1_1 = ret[1];
414
+ return getStringFromWasm0(ret[0], ret[1]);
415
+ } finally {
416
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
417
+ }
418
+ }
419
+ /**
420
+ * @returns {number}
421
+ */
422
+ get volume() {
423
+ const ret = wasm.renderresult_volume(this.__wbg_ptr);
424
+ return ret;
425
+ }
426
+ /**
427
+ * Newline-joined warnings.
428
+ * @returns {string}
429
+ */
430
+ get warnings() {
431
+ let deferred1_0;
432
+ let deferred1_1;
433
+ try {
434
+ const ret = wasm.renderresult_warnings(this.__wbg_ptr);
435
+ deferred1_0 = ret[0];
436
+ deferred1_1 = ret[1];
437
+ return getStringFromWasm0(ret[0], ret[1]);
438
+ } finally {
439
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
440
+ }
441
+ }
442
+ }
443
+ if (Symbol.dispose) RenderResult.prototype[Symbol.dispose] = RenderResult.prototype.free;
444
+
445
+ /**
446
+ * Drop the persistent geometry cache (e.g. when loading a new document).
447
+ */
448
+ export function clear_cache() {
449
+ wasm.clear_cache();
450
+ }
451
+
452
+ /**
453
+ * Render a 2D model and serialize it to DXF or SVG text. Returns an empty
454
+ * string if the model isn't 2D or fails to evaluate (the caller checks
455
+ * `RenderResult.is_2d` first). `format` is "dxf" or "svg".
456
+ * @param {string} source
457
+ * @param {string[]} names
458
+ * @param {string[]} values
459
+ * @param {string[]} file_names
460
+ * @param {string[]} file_contents
461
+ * @param {string[]} bin_names
462
+ * @param {string[]} bin_data
463
+ * @param {string[]} font_blobs
464
+ * @param {string} format
465
+ * @returns {string}
466
+ */
467
+ export function export_2d(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs, format) {
468
+ let deferred10_0;
469
+ let deferred10_1;
470
+ try {
471
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
472
+ const len0 = WASM_VECTOR_LEN;
473
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
474
+ const len1 = WASM_VECTOR_LEN;
475
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
476
+ const len2 = WASM_VECTOR_LEN;
477
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
478
+ const len3 = WASM_VECTOR_LEN;
479
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
480
+ const len4 = WASM_VECTOR_LEN;
481
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
482
+ const len5 = WASM_VECTOR_LEN;
483
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
484
+ const len6 = WASM_VECTOR_LEN;
485
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
486
+ const len7 = WASM_VECTOR_LEN;
487
+ const ptr8 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
488
+ const len8 = WASM_VECTOR_LEN;
489
+ const ret = wasm.export_2d(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8);
490
+ deferred10_0 = ret[0];
491
+ deferred10_1 = ret[1];
492
+ return getStringFromWasm0(ret[0], ret[1]);
493
+ } finally {
494
+ wasm.__wbindgen_free(deferred10_0, deferred10_1, 1);
495
+ }
496
+ }
497
+
498
+ /**
499
+ * Evaluate a 3D source and serialize it natively to one owned artifact.
500
+ * @param {string} source
501
+ * @param {string[]} names
502
+ * @param {string[]} values
503
+ * @param {string[]} file_names
504
+ * @param {string[]} file_contents
505
+ * @param {string[]} bin_names
506
+ * @param {string[]} bin_data
507
+ * @param {string[]} font_blobs
508
+ * @param {string} format
509
+ * @param {boolean} include_edges
510
+ * @param {number} source_unit_to_meters
511
+ * @param {string} coordinate_system
512
+ * @returns {ExportShape3DResult}
513
+ */
514
+ export function export_3d(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs, format, include_edges, source_unit_to_meters, coordinate_system) {
515
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
516
+ const len0 = WASM_VECTOR_LEN;
517
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
518
+ const len1 = WASM_VECTOR_LEN;
519
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
520
+ const len2 = WASM_VECTOR_LEN;
521
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
522
+ const len3 = WASM_VECTOR_LEN;
523
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
524
+ const len4 = WASM_VECTOR_LEN;
525
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
526
+ const len5 = WASM_VECTOR_LEN;
527
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
528
+ const len6 = WASM_VECTOR_LEN;
529
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
530
+ const len7 = WASM_VECTOR_LEN;
531
+ const ptr8 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
532
+ const len8 = WASM_VECTOR_LEN;
533
+ const ptr9 = passStringToWasm0(coordinate_system, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
534
+ const len9 = WASM_VECTOR_LEN;
535
+ const ret = wasm.export_3d(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8, include_edges, source_unit_to_meters, ptr9, len9);
536
+ return ExportShape3DResult.__wrap(ret);
537
+ }
538
+
539
+ /**
540
+ * The customizer parameter schema for a source string, as a JSON string
541
+ * (`{"params":[…]}`). The playground renders a control panel from this.
542
+ * @param {string} source
543
+ * @returns {string}
544
+ */
545
+ export function parameters(source) {
546
+ let deferred2_0;
547
+ let deferred2_1;
548
+ try {
549
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
550
+ const len0 = WASM_VECTOR_LEN;
551
+ const ret = wasm.parameters(ptr0, len0);
552
+ deferred2_0 = ret[0];
553
+ deferred2_1 = ret[1];
554
+ return getStringFromWasm0(ret[0], ret[1]);
555
+ } finally {
556
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
557
+ }
558
+ }
559
+
560
+ /**
561
+ * Run the full pipeline on a source string.
562
+ * @param {string} source
563
+ * @returns {RenderResult}
564
+ */
565
+ export function render(source) {
566
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
567
+ const len0 = WASM_VECTOR_LEN;
568
+ const ret = wasm.render(ptr0, len0);
569
+ return RenderResult.__wrap(ret);
570
+ }
571
+
572
+ /**
573
+ * Like [`render_with_files`], but renders the fast, **non-watertight** preview
574
+ * (see `openrscad_geom::render_preview_cached_diag`): unions are concatenated rather
575
+ * than run through the CSG kernel. Suitable for opaque on-screen display only —
576
+ * stats and export still use the exact path. Differences/intersections/hulls
577
+ * still resolve exactly, so holes and clips look correct.
578
+ * @param {string} source
579
+ * @param {string[]} names
580
+ * @param {string[]} values
581
+ * @param {string[]} file_names
582
+ * @param {string[]} file_contents
583
+ * @param {string[]} bin_names
584
+ * @param {string[]} bin_data
585
+ * @param {string[]} font_blobs
586
+ * @returns {RenderResult}
587
+ */
588
+ export function render_preview_with_files(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs) {
589
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
590
+ const len0 = WASM_VECTOR_LEN;
591
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
592
+ const len1 = WASM_VECTOR_LEN;
593
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
594
+ const len2 = WASM_VECTOR_LEN;
595
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
596
+ const len3 = WASM_VECTOR_LEN;
597
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
598
+ const len4 = WASM_VECTOR_LEN;
599
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
600
+ const len5 = WASM_VECTOR_LEN;
601
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
602
+ const len6 = WASM_VECTOR_LEN;
603
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
604
+ const len7 = WASM_VECTOR_LEN;
605
+ const ret = wasm.render_preview_with_files(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
606
+ return RenderResult.__wrap(ret);
607
+ }
608
+
609
+ /**
610
+ * Render a preview-semantics GLB for interactive viewers.
611
+ * @param {string} source
612
+ * @param {string[]} names
613
+ * @param {string[]} values
614
+ * @param {string[]} file_names
615
+ * @param {string[]} file_contents
616
+ * @param {string[]} bin_names
617
+ * @param {string[]} bin_data
618
+ * @param {string[]} font_blobs
619
+ * @param {boolean} include_edges
620
+ * @returns {ExportShape3DResult}
621
+ */
622
+ export function render_to_glb(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs, include_edges) {
623
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
624
+ const len0 = WASM_VECTOR_LEN;
625
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
626
+ const len1 = WASM_VECTOR_LEN;
627
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
628
+ const len2 = WASM_VECTOR_LEN;
629
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
630
+ const len3 = WASM_VECTOR_LEN;
631
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
632
+ const len4 = WASM_VECTOR_LEN;
633
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
634
+ const len5 = WASM_VECTOR_LEN;
635
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
636
+ const len6 = WASM_VECTOR_LEN;
637
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
638
+ const len7 = WASM_VECTOR_LEN;
639
+ const ret = wasm.render_to_glb(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, include_edges);
640
+ return ExportShape3DResult.__wrap(ret);
641
+ }
642
+
643
+ /**
644
+ * Like [`render_with_params`], but `include`/`use` resolve against an in-memory
645
+ * set of files (`file_names[i]` → `file_contents[i]`) — the playground's other
646
+ * files and/or a bundled library.
647
+ * @param {string} source
648
+ * @param {string[]} names
649
+ * @param {string[]} values
650
+ * @param {string[]} file_names
651
+ * @param {string[]} file_contents
652
+ * @param {string[]} bin_names
653
+ * @param {string[]} bin_data
654
+ * @param {string[]} font_blobs
655
+ * @returns {RenderResult}
656
+ */
657
+ export function render_with_files(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs) {
658
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
659
+ const len0 = WASM_VECTOR_LEN;
660
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
661
+ const len1 = WASM_VECTOR_LEN;
662
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
663
+ const len2 = WASM_VECTOR_LEN;
664
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
665
+ const len3 = WASM_VECTOR_LEN;
666
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
667
+ const len4 = WASM_VECTOR_LEN;
668
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
669
+ const len5 = WASM_VECTOR_LEN;
670
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
671
+ const len6 = WASM_VECTOR_LEN;
672
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
673
+ const len7 = WASM_VECTOR_LEN;
674
+ const ret = wasm.render_with_files(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
675
+ return RenderResult.__wrap(ret);
676
+ }
677
+
678
+ /**
679
+ * Like [`render`], but with customizer overrides supplied as parallel arrays:
680
+ * `names[i]` is a top-level parameter and `values[i]` its new value as a
681
+ * literal string (`"30"`, `"true"`, `"\"hi\""`, `"[1,2,3]"`).
682
+ * @param {string} source
683
+ * @param {string[]} names
684
+ * @param {string[]} values
685
+ * @returns {RenderResult}
686
+ */
687
+ export function render_with_params(source, names, values) {
688
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
689
+ const len0 = WASM_VECTOR_LEN;
690
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
691
+ const len1 = WASM_VECTOR_LEN;
692
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
693
+ const len2 = WASM_VECTOR_LEN;
694
+ const ret = wasm.render_with_params(ptr0, len0, ptr1, len1, ptr2, len2);
695
+ return RenderResult.__wrap(ret);
696
+ }
697
+
698
+ /**
699
+ * Initialize panic hook for readable errors in the browser console.
700
+ */
701
+ export function start() {
702
+ wasm.start();
703
+ }
704
+
705
+ /**
706
+ * Engine version string.
707
+ * @returns {string}
708
+ */
709
+ export function version() {
710
+ let deferred1_0;
711
+ let deferred1_1;
712
+ try {
713
+ const ret = wasm.version();
714
+ deferred1_0 = ret[0];
715
+ deferred1_1 = ret[1];
716
+ return getStringFromWasm0(ret[0], ret[1]);
717
+ } finally {
718
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
719
+ }
720
+ }
721
+ function __wbg_get_imports() {
722
+ const import0 = {
723
+ __proto__: null,
724
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
725
+ const obj = arg1;
726
+ const ret = typeof(obj) === 'string' ? obj : undefined;
727
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
728
+ var len1 = WASM_VECTOR_LEN;
729
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
730
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
731
+ },
732
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
733
+ throw new Error(getStringFromWasm0(arg0, arg1));
734
+ },
735
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
736
+ let deferred0_0;
737
+ let deferred0_1;
738
+ try {
739
+ deferred0_0 = arg0;
740
+ deferred0_1 = arg1;
741
+ console.error(getStringFromWasm0(arg0, arg1));
742
+ } finally {
743
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
744
+ }
745
+ },
746
+ __wbg_new_227d7c05414eb861: function() {
747
+ const ret = new Error();
748
+ return ret;
749
+ },
750
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
751
+ const ret = arg1.stack;
752
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
753
+ const len1 = WASM_VECTOR_LEN;
754
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
755
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
756
+ },
757
+ __wbindgen_init_externref_table: function() {
758
+ const table = wasm.__wbindgen_externrefs;
759
+ const offset = table.grow(4);
760
+ table.set(0, undefined);
761
+ table.set(offset + 0, undefined);
762
+ table.set(offset + 1, null);
763
+ table.set(offset + 2, true);
764
+ table.set(offset + 3, false);
765
+ },
766
+ };
767
+ return {
768
+ __proto__: null,
769
+ "./openrscad_bg.js": import0,
770
+ };
771
+ }
772
+
773
+ const ExportShape3DResultFinalization = (typeof FinalizationRegistry === 'undefined')
774
+ ? { register: () => {}, unregister: () => {} }
775
+ : new FinalizationRegistry(ptr => wasm.__wbg_exportshape3dresult_free(ptr, 1));
776
+ const RenderResultFinalization = (typeof FinalizationRegistry === 'undefined')
777
+ ? { register: () => {}, unregister: () => {} }
778
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderresult_free(ptr, 1));
779
+
780
+ function addToExternrefTable0(obj) {
781
+ const idx = wasm.__externref_table_alloc();
782
+ wasm.__wbindgen_externrefs.set(idx, obj);
783
+ return idx;
784
+ }
785
+
786
+ function getArrayF32FromWasm0(ptr, len) {
787
+ ptr = ptr >>> 0;
788
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
789
+ }
790
+
791
+ function getArrayU8FromWasm0(ptr, len) {
792
+ ptr = ptr >>> 0;
793
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
794
+ }
795
+
796
+ let cachedDataViewMemory0 = null;
797
+ function getDataViewMemory0() {
798
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
799
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
800
+ }
801
+ return cachedDataViewMemory0;
802
+ }
803
+
804
+ let cachedFloat32ArrayMemory0 = null;
805
+ function getFloat32ArrayMemory0() {
806
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
807
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
808
+ }
809
+ return cachedFloat32ArrayMemory0;
810
+ }
811
+
812
+ function getStringFromWasm0(ptr, len) {
813
+ return decodeText(ptr >>> 0, len);
814
+ }
815
+
816
+ let cachedUint8ArrayMemory0 = null;
817
+ function getUint8ArrayMemory0() {
818
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
819
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
820
+ }
821
+ return cachedUint8ArrayMemory0;
822
+ }
823
+
824
+ function isLikeNone(x) {
825
+ return x === undefined || x === null;
826
+ }
827
+
828
+ function passArrayJsValueToWasm0(array, malloc) {
829
+ const ptr = malloc(array.length * 4, 4) >>> 0;
830
+ for (let i = 0; i < array.length; i++) {
831
+ const add = addToExternrefTable0(array[i]);
832
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
833
+ }
834
+ WASM_VECTOR_LEN = array.length;
835
+ return ptr;
836
+ }
837
+
838
+ function passStringToWasm0(arg, malloc, realloc) {
839
+ if (realloc === undefined) {
840
+ const buf = cachedTextEncoder.encode(arg);
841
+ const ptr = malloc(buf.length, 1) >>> 0;
842
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
843
+ WASM_VECTOR_LEN = buf.length;
844
+ return ptr;
845
+ }
846
+
847
+ let len = arg.length;
848
+ let ptr = malloc(len, 1) >>> 0;
849
+
850
+ const mem = getUint8ArrayMemory0();
851
+
852
+ let offset = 0;
853
+
854
+ for (; offset < len; offset++) {
855
+ const code = arg.charCodeAt(offset);
856
+ if (code > 0x7F) break;
857
+ mem[ptr + offset] = code;
858
+ }
859
+ if (offset !== len) {
860
+ if (offset !== 0) {
861
+ arg = arg.slice(offset);
862
+ }
863
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
864
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
865
+ const ret = cachedTextEncoder.encodeInto(arg, view);
866
+
867
+ offset += ret.written;
868
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
869
+ }
870
+
871
+ WASM_VECTOR_LEN = offset;
872
+ return ptr;
873
+ }
874
+
875
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
876
+ cachedTextDecoder.decode();
877
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
878
+ let numBytesDecoded = 0;
879
+ function decodeText(ptr, len) {
880
+ numBytesDecoded += len;
881
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
882
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
883
+ cachedTextDecoder.decode();
884
+ numBytesDecoded = len;
885
+ }
886
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
887
+ }
888
+
889
+ const cachedTextEncoder = new TextEncoder();
890
+
891
+ if (!('encodeInto' in cachedTextEncoder)) {
892
+ cachedTextEncoder.encodeInto = function (arg, view) {
893
+ const buf = cachedTextEncoder.encode(arg);
894
+ view.set(buf);
895
+ return {
896
+ read: arg.length,
897
+ written: buf.length
898
+ };
899
+ };
900
+ }
901
+
902
+ let WASM_VECTOR_LEN = 0;
903
+
904
+ let wasmModule, wasmInstance, wasm;
905
+ function __wbg_finalize_init(instance, module) {
906
+ wasmInstance = instance;
907
+ wasm = instance.exports;
908
+ wasmModule = module;
909
+ cachedDataViewMemory0 = null;
910
+ cachedFloat32ArrayMemory0 = null;
911
+ cachedUint8ArrayMemory0 = null;
912
+ wasm.__wbindgen_start();
913
+ return wasm;
914
+ }
915
+
916
+ async function __wbg_load(module, imports) {
917
+ if (typeof Response === 'function' && module instanceof Response) {
918
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
919
+ try {
920
+ return await WebAssembly.instantiateStreaming(module, imports);
921
+ } catch (e) {
922
+ const validResponse = module.ok && expectedResponseType(module.type);
923
+
924
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
925
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
926
+
927
+ } else { throw e; }
928
+ }
929
+ }
930
+
931
+ const bytes = await module.arrayBuffer();
932
+ return await WebAssembly.instantiate(bytes, imports);
933
+ } else {
934
+ const instance = await WebAssembly.instantiate(module, imports);
935
+
936
+ if (instance instanceof WebAssembly.Instance) {
937
+ return { instance, module };
938
+ } else {
939
+ return instance;
940
+ }
941
+ }
942
+
943
+ function expectedResponseType(type) {
944
+ switch (type) {
945
+ case 'basic': case 'cors': case 'default': return true;
946
+ }
947
+ return false;
948
+ }
949
+ }
950
+
951
+ function initSync(module) {
952
+ if (wasm !== undefined) return wasm;
953
+
954
+
955
+ if (module !== undefined) {
956
+ if (Object.getPrototypeOf(module) === Object.prototype) {
957
+ ({module} = module)
958
+ } else {
959
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
960
+ }
961
+ }
962
+
963
+ const imports = __wbg_get_imports();
964
+ if (!(module instanceof WebAssembly.Module)) {
965
+ module = new WebAssembly.Module(module);
966
+ }
967
+ const instance = new WebAssembly.Instance(module, imports);
968
+ return __wbg_finalize_init(instance, module);
969
+ }
970
+
971
+ async function __wbg_init(module_or_path) {
972
+ if (wasm !== undefined) return wasm;
973
+
974
+
975
+ if (module_or_path !== undefined) {
976
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
977
+ ({module_or_path} = module_or_path)
978
+ } else {
979
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
980
+ }
981
+ }
982
+
983
+ if (module_or_path === undefined) {
984
+ module_or_path = new URL('openrscad_bg.wasm', import.meta.url);
985
+ }
986
+ const imports = __wbg_get_imports();
987
+
988
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
989
+ module_or_path = fetch(module_or_path);
990
+ }
991
+
992
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
993
+
994
+ return __wbg_finalize_init(instance, module);
995
+ }
996
+
997
+ export { initSync, __wbg_init as default };