@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,914 @@
1
+ /* @ts-self-types="./openrscad.d.ts" */
2
+
3
+ /**
4
+ * One owned native 3D artifact plus the operational metadata needed by hosts.
5
+ */
6
+ 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
+ exports.ExportShape3DResult = ExportShape3DResult;
183
+
184
+ /**
185
+ * The result of rendering a `.scad` source string.
186
+ *
187
+ * Mesh data is a non-indexed triangle soup with flat (per-face) normals:
188
+ * `positions` and `normals` both hold 9 floats per triangle.
189
+ */
190
+ class RenderResult {
191
+ static __wrap(ptr) {
192
+ const obj = Object.create(RenderResult.prototype);
193
+ obj.__wbg_ptr = ptr;
194
+ RenderResultFinalization.register(obj, obj.__wbg_ptr, obj);
195
+ return obj;
196
+ }
197
+ __destroy_into_raw() {
198
+ const ptr = this.__wbg_ptr;
199
+ this.__wbg_ptr = 0;
200
+ RenderResultFinalization.unregister(this);
201
+ return ptr;
202
+ }
203
+ free() {
204
+ const ptr = this.__destroy_into_raw();
205
+ wasm.__wbg_renderresult_free(ptr, 0);
206
+ }
207
+ /**
208
+ * @returns {number}
209
+ */
210
+ get area() {
211
+ const ret = wasm.renderresult_area(this.__wbg_ptr);
212
+ return ret;
213
+ }
214
+ /**
215
+ * Structured diagnostics as a JSON array (`[{severity,message,start,end}]`),
216
+ * where start/end are byte offsets into the source, or -1 when unknown.
217
+ * @returns {string}
218
+ */
219
+ get diagnostics() {
220
+ let deferred1_0;
221
+ let deferred1_1;
222
+ try {
223
+ const ret = wasm.renderresult_diagnostics(this.__wbg_ptr);
224
+ deferred1_0 = ret[0];
225
+ deferred1_1 = ret[1];
226
+ return getStringFromWasm0(ret[0], ret[1]);
227
+ } finally {
228
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
229
+ }
230
+ }
231
+ /**
232
+ * Newline-joined `ECHO:` output.
233
+ * @returns {string}
234
+ */
235
+ get echo() {
236
+ let deferred1_0;
237
+ let deferred1_1;
238
+ try {
239
+ const ret = wasm.renderresult_echo(this.__wbg_ptr);
240
+ deferred1_0 = ret[0];
241
+ deferred1_1 = ret[1];
242
+ return getStringFromWasm0(ret[0], ret[1]);
243
+ } finally {
244
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
245
+ }
246
+ }
247
+ /**
248
+ * Error message, or empty string if the render succeeded.
249
+ * @returns {string}
250
+ */
251
+ get error() {
252
+ let deferred1_0;
253
+ let deferred1_1;
254
+ try {
255
+ const ret = wasm.renderresult_error(this.__wbg_ptr);
256
+ deferred1_0 = ret[0];
257
+ deferred1_1 = ret[1];
258
+ return getStringFromWasm0(ret[0], ret[1]);
259
+ } finally {
260
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
261
+ }
262
+ }
263
+ /**
264
+ * Newline-joined recoverable geometry errors (degraded render), or empty
265
+ * when the geometry is exact. See the field docs on `geom_errors`.
266
+ * @returns {string}
267
+ */
268
+ get geom_errors() {
269
+ let deferred1_0;
270
+ let deferred1_1;
271
+ try {
272
+ const ret = wasm.renderresult_geom_errors(this.__wbg_ptr);
273
+ deferred1_0 = ret[0];
274
+ deferred1_1 = ret[1];
275
+ return getStringFromWasm0(ret[0], ret[1]);
276
+ } finally {
277
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
278
+ }
279
+ }
280
+ /**
281
+ * Per-group ranges/colors as JSON (`[{start,count,color,mode}]`); empty `[]`
282
+ * when the model uses no display attributes.
283
+ * @returns {string}
284
+ */
285
+ get groups() {
286
+ let deferred1_0;
287
+ let deferred1_1;
288
+ try {
289
+ const ret = wasm.renderresult_groups(this.__wbg_ptr);
290
+ deferred1_0 = ret[0];
291
+ deferred1_1 = ret[1];
292
+ return getStringFromWasm0(ret[0], ret[1]);
293
+ } finally {
294
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
295
+ }
296
+ }
297
+ /**
298
+ * Whether the model is a 2D object (exportable to DXF/SVG) vs a 3D solid.
299
+ * @returns {boolean}
300
+ */
301
+ get is_2d() {
302
+ const ret = wasm.renderresult_is_2d(this.__wbg_ptr);
303
+ return ret !== 0;
304
+ }
305
+ /**
306
+ * Per-face normals (9 f32 per triangle) as a `Float32Array`.
307
+ * @returns {Float32Array}
308
+ */
309
+ get normals() {
310
+ const ret = wasm.renderresult_normals(this.__wbg_ptr);
311
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
312
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
313
+ return v1;
314
+ }
315
+ /**
316
+ * Whether the render succeeded (no error).
317
+ * @returns {boolean}
318
+ */
319
+ get ok() {
320
+ const ret = wasm.renderresult_ok(this.__wbg_ptr);
321
+ return ret !== 0;
322
+ }
323
+ /**
324
+ * Triangle-soup vertex positions (9 f32 per triangle) as a `Float32Array`.
325
+ * @returns {Float32Array}
326
+ */
327
+ get positions() {
328
+ const ret = wasm.renderresult_positions(this.__wbg_ptr);
329
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
330
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
331
+ return v1;
332
+ }
333
+ /**
334
+ * @returns {Float32Array}
335
+ */
336
+ get preview_normals() {
337
+ const ret = wasm.renderresult_preview_normals(this.__wbg_ptr);
338
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
339
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
340
+ return v1;
341
+ }
342
+ /**
343
+ * Preview triangle soup (concatenated colored groups); empty when the model
344
+ * uses no color/`#`/`%` (the viewer then uses `positions`).
345
+ * @returns {Float32Array}
346
+ */
347
+ get preview_positions() {
348
+ const ret = wasm.renderresult_preview_positions(this.__wbg_ptr);
349
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
350
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
351
+ return v1;
352
+ }
353
+ /**
354
+ * Per-group provenance ranges/span-stacks as JSON (`[{start,count,spans}]`);
355
+ * empty when the model has no pickable geometry.
356
+ * @returns {string}
357
+ */
358
+ get provenance() {
359
+ let deferred1_0;
360
+ let deferred1_1;
361
+ try {
362
+ const ret = wasm.renderresult_provenance(this.__wbg_ptr);
363
+ deferred1_0 = ret[0];
364
+ deferred1_1 = ret[1];
365
+ return getStringFromWasm0(ret[0], ret[1]);
366
+ } finally {
367
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
368
+ }
369
+ }
370
+ /**
371
+ * @returns {Float32Array}
372
+ */
373
+ get provenance_normals() {
374
+ const ret = wasm.renderresult_provenance_normals(this.__wbg_ptr);
375
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
376
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
377
+ return v1;
378
+ }
379
+ /**
380
+ * Provenance triangle soup (concatenated per-statement groups); empty only
381
+ * for models with no geometry.
382
+ * @returns {Float32Array}
383
+ */
384
+ get provenance_positions() {
385
+ const ret = wasm.renderresult_provenance_positions(this.__wbg_ptr);
386
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
387
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
388
+ return v1;
389
+ }
390
+ /**
391
+ * @returns {number}
392
+ */
393
+ get triangle_count() {
394
+ const ret = wasm.renderresult_triangle_count(this.__wbg_ptr);
395
+ return ret >>> 0;
396
+ }
397
+ /**
398
+ * @returns {number}
399
+ */
400
+ get vertex_count() {
401
+ const ret = wasm.renderresult_vertex_count(this.__wbg_ptr);
402
+ return ret >>> 0;
403
+ }
404
+ /**
405
+ * `$vp*` viewport variables as JSON, or empty when the source has no `$vp`.
406
+ * @returns {string}
407
+ */
408
+ get viewport() {
409
+ let deferred1_0;
410
+ let deferred1_1;
411
+ try {
412
+ const ret = wasm.renderresult_viewport(this.__wbg_ptr);
413
+ deferred1_0 = ret[0];
414
+ deferred1_1 = ret[1];
415
+ return getStringFromWasm0(ret[0], ret[1]);
416
+ } finally {
417
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
418
+ }
419
+ }
420
+ /**
421
+ * @returns {number}
422
+ */
423
+ get volume() {
424
+ const ret = wasm.renderresult_volume(this.__wbg_ptr);
425
+ return ret;
426
+ }
427
+ /**
428
+ * Newline-joined warnings.
429
+ * @returns {string}
430
+ */
431
+ get warnings() {
432
+ let deferred1_0;
433
+ let deferred1_1;
434
+ try {
435
+ const ret = wasm.renderresult_warnings(this.__wbg_ptr);
436
+ deferred1_0 = ret[0];
437
+ deferred1_1 = ret[1];
438
+ return getStringFromWasm0(ret[0], ret[1]);
439
+ } finally {
440
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
441
+ }
442
+ }
443
+ }
444
+ if (Symbol.dispose) RenderResult.prototype[Symbol.dispose] = RenderResult.prototype.free;
445
+ exports.RenderResult = RenderResult;
446
+
447
+ /**
448
+ * Drop the persistent geometry cache (e.g. when loading a new document).
449
+ */
450
+ function clear_cache() {
451
+ wasm.clear_cache();
452
+ }
453
+ exports.clear_cache = clear_cache;
454
+
455
+ /**
456
+ * Render a 2D model and serialize it to DXF or SVG text. Returns an empty
457
+ * string if the model isn't 2D or fails to evaluate (the caller checks
458
+ * `RenderResult.is_2d` first). `format` is "dxf" or "svg".
459
+ * @param {string} source
460
+ * @param {string[]} names
461
+ * @param {string[]} values
462
+ * @param {string[]} file_names
463
+ * @param {string[]} file_contents
464
+ * @param {string[]} bin_names
465
+ * @param {string[]} bin_data
466
+ * @param {string[]} font_blobs
467
+ * @param {string} format
468
+ * @returns {string}
469
+ */
470
+ function export_2d(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs, format) {
471
+ let deferred10_0;
472
+ let deferred10_1;
473
+ try {
474
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
475
+ const len0 = WASM_VECTOR_LEN;
476
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
477
+ const len1 = WASM_VECTOR_LEN;
478
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
479
+ const len2 = WASM_VECTOR_LEN;
480
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
481
+ const len3 = WASM_VECTOR_LEN;
482
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
483
+ const len4 = WASM_VECTOR_LEN;
484
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
485
+ const len5 = WASM_VECTOR_LEN;
486
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
487
+ const len6 = WASM_VECTOR_LEN;
488
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
489
+ const len7 = WASM_VECTOR_LEN;
490
+ const ptr8 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
491
+ const len8 = WASM_VECTOR_LEN;
492
+ const ret = wasm.export_2d(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8);
493
+ deferred10_0 = ret[0];
494
+ deferred10_1 = ret[1];
495
+ return getStringFromWasm0(ret[0], ret[1]);
496
+ } finally {
497
+ wasm.__wbindgen_free(deferred10_0, deferred10_1, 1);
498
+ }
499
+ }
500
+ exports.export_2d = export_2d;
501
+
502
+ /**
503
+ * Evaluate a 3D source and serialize it natively to one owned artifact.
504
+ * @param {string} source
505
+ * @param {string[]} names
506
+ * @param {string[]} values
507
+ * @param {string[]} file_names
508
+ * @param {string[]} file_contents
509
+ * @param {string[]} bin_names
510
+ * @param {string[]} bin_data
511
+ * @param {string[]} font_blobs
512
+ * @param {string} format
513
+ * @param {boolean} include_edges
514
+ * @param {number} source_unit_to_meters
515
+ * @param {string} coordinate_system
516
+ * @returns {ExportShape3DResult}
517
+ */
518
+ 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) {
519
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
520
+ const len0 = WASM_VECTOR_LEN;
521
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
522
+ const len1 = WASM_VECTOR_LEN;
523
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
524
+ const len2 = WASM_VECTOR_LEN;
525
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
526
+ const len3 = WASM_VECTOR_LEN;
527
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
528
+ const len4 = WASM_VECTOR_LEN;
529
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
530
+ const len5 = WASM_VECTOR_LEN;
531
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
532
+ const len6 = WASM_VECTOR_LEN;
533
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
534
+ const len7 = WASM_VECTOR_LEN;
535
+ const ptr8 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
536
+ const len8 = WASM_VECTOR_LEN;
537
+ const ptr9 = passStringToWasm0(coordinate_system, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
538
+ const len9 = WASM_VECTOR_LEN;
539
+ 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);
540
+ return ExportShape3DResult.__wrap(ret);
541
+ }
542
+ exports.export_3d = export_3d;
543
+
544
+ /**
545
+ * The customizer parameter schema for a source string, as a JSON string
546
+ * (`{"params":[…]}`). The playground renders a control panel from this.
547
+ * @param {string} source
548
+ * @returns {string}
549
+ */
550
+ function parameters(source) {
551
+ let deferred2_0;
552
+ let deferred2_1;
553
+ try {
554
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
555
+ const len0 = WASM_VECTOR_LEN;
556
+ const ret = wasm.parameters(ptr0, len0);
557
+ deferred2_0 = ret[0];
558
+ deferred2_1 = ret[1];
559
+ return getStringFromWasm0(ret[0], ret[1]);
560
+ } finally {
561
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
562
+ }
563
+ }
564
+ exports.parameters = parameters;
565
+
566
+ /**
567
+ * Run the full pipeline on a source string.
568
+ * @param {string} source
569
+ * @returns {RenderResult}
570
+ */
571
+ function render(source) {
572
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
573
+ const len0 = WASM_VECTOR_LEN;
574
+ const ret = wasm.render(ptr0, len0);
575
+ return RenderResult.__wrap(ret);
576
+ }
577
+ exports.render = render;
578
+
579
+ /**
580
+ * Like [`render_with_files`], but renders the fast, **non-watertight** preview
581
+ * (see `openrscad_geom::render_preview_cached_diag`): unions are concatenated rather
582
+ * than run through the CSG kernel. Suitable for opaque on-screen display only —
583
+ * stats and export still use the exact path. Differences/intersections/hulls
584
+ * still resolve exactly, so holes and clips look correct.
585
+ * @param {string} source
586
+ * @param {string[]} names
587
+ * @param {string[]} values
588
+ * @param {string[]} file_names
589
+ * @param {string[]} file_contents
590
+ * @param {string[]} bin_names
591
+ * @param {string[]} bin_data
592
+ * @param {string[]} font_blobs
593
+ * @returns {RenderResult}
594
+ */
595
+ function render_preview_with_files(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs) {
596
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
597
+ const len0 = WASM_VECTOR_LEN;
598
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
599
+ const len1 = WASM_VECTOR_LEN;
600
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
601
+ const len2 = WASM_VECTOR_LEN;
602
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
603
+ const len3 = WASM_VECTOR_LEN;
604
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
605
+ const len4 = WASM_VECTOR_LEN;
606
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
607
+ const len5 = WASM_VECTOR_LEN;
608
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
609
+ const len6 = WASM_VECTOR_LEN;
610
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
611
+ const len7 = WASM_VECTOR_LEN;
612
+ const ret = wasm.render_preview_with_files(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
613
+ return RenderResult.__wrap(ret);
614
+ }
615
+ exports.render_preview_with_files = render_preview_with_files;
616
+
617
+ /**
618
+ * Render a preview-semantics GLB for interactive viewers.
619
+ * @param {string} source
620
+ * @param {string[]} names
621
+ * @param {string[]} values
622
+ * @param {string[]} file_names
623
+ * @param {string[]} file_contents
624
+ * @param {string[]} bin_names
625
+ * @param {string[]} bin_data
626
+ * @param {string[]} font_blobs
627
+ * @param {boolean} include_edges
628
+ * @returns {ExportShape3DResult}
629
+ */
630
+ function render_to_glb(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs, include_edges) {
631
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
632
+ const len0 = WASM_VECTOR_LEN;
633
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
634
+ const len1 = WASM_VECTOR_LEN;
635
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
636
+ const len2 = WASM_VECTOR_LEN;
637
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
638
+ const len3 = WASM_VECTOR_LEN;
639
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
640
+ const len4 = WASM_VECTOR_LEN;
641
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
642
+ const len5 = WASM_VECTOR_LEN;
643
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
644
+ const len6 = WASM_VECTOR_LEN;
645
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
646
+ const len7 = WASM_VECTOR_LEN;
647
+ const ret = wasm.render_to_glb(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, include_edges);
648
+ return ExportShape3DResult.__wrap(ret);
649
+ }
650
+ exports.render_to_glb = render_to_glb;
651
+
652
+ /**
653
+ * Like [`render_with_params`], but `include`/`use` resolve against an in-memory
654
+ * set of files (`file_names[i]` → `file_contents[i]`) — the playground's other
655
+ * files and/or a bundled library.
656
+ * @param {string} source
657
+ * @param {string[]} names
658
+ * @param {string[]} values
659
+ * @param {string[]} file_names
660
+ * @param {string[]} file_contents
661
+ * @param {string[]} bin_names
662
+ * @param {string[]} bin_data
663
+ * @param {string[]} font_blobs
664
+ * @returns {RenderResult}
665
+ */
666
+ function render_with_files(source, names, values, file_names, file_contents, bin_names, bin_data, font_blobs) {
667
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
668
+ const len0 = WASM_VECTOR_LEN;
669
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
670
+ const len1 = WASM_VECTOR_LEN;
671
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
672
+ const len2 = WASM_VECTOR_LEN;
673
+ const ptr3 = passArrayJsValueToWasm0(file_names, wasm.__wbindgen_malloc);
674
+ const len3 = WASM_VECTOR_LEN;
675
+ const ptr4 = passArrayJsValueToWasm0(file_contents, wasm.__wbindgen_malloc);
676
+ const len4 = WASM_VECTOR_LEN;
677
+ const ptr5 = passArrayJsValueToWasm0(bin_names, wasm.__wbindgen_malloc);
678
+ const len5 = WASM_VECTOR_LEN;
679
+ const ptr6 = passArrayJsValueToWasm0(bin_data, wasm.__wbindgen_malloc);
680
+ const len6 = WASM_VECTOR_LEN;
681
+ const ptr7 = passArrayJsValueToWasm0(font_blobs, wasm.__wbindgen_malloc);
682
+ const len7 = WASM_VECTOR_LEN;
683
+ const ret = wasm.render_with_files(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
684
+ return RenderResult.__wrap(ret);
685
+ }
686
+ exports.render_with_files = render_with_files;
687
+
688
+ /**
689
+ * Like [`render`], but with customizer overrides supplied as parallel arrays:
690
+ * `names[i]` is a top-level parameter and `values[i]` its new value as a
691
+ * literal string (`"30"`, `"true"`, `"\"hi\""`, `"[1,2,3]"`).
692
+ * @param {string} source
693
+ * @param {string[]} names
694
+ * @param {string[]} values
695
+ * @returns {RenderResult}
696
+ */
697
+ function render_with_params(source, names, values) {
698
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
699
+ const len0 = WASM_VECTOR_LEN;
700
+ const ptr1 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
701
+ const len1 = WASM_VECTOR_LEN;
702
+ const ptr2 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
703
+ const len2 = WASM_VECTOR_LEN;
704
+ const ret = wasm.render_with_params(ptr0, len0, ptr1, len1, ptr2, len2);
705
+ return RenderResult.__wrap(ret);
706
+ }
707
+ exports.render_with_params = render_with_params;
708
+
709
+ /**
710
+ * Initialize panic hook for readable errors in the browser console.
711
+ */
712
+ function start() {
713
+ wasm.start();
714
+ }
715
+ exports.start = start;
716
+
717
+ /**
718
+ * Engine version string.
719
+ * @returns {string}
720
+ */
721
+ function version() {
722
+ let deferred1_0;
723
+ let deferred1_1;
724
+ try {
725
+ const ret = wasm.version();
726
+ deferred1_0 = ret[0];
727
+ deferred1_1 = ret[1];
728
+ return getStringFromWasm0(ret[0], ret[1]);
729
+ } finally {
730
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
731
+ }
732
+ }
733
+ exports.version = version;
734
+ function __wbg_get_imports() {
735
+ const import0 = {
736
+ __proto__: null,
737
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
738
+ const obj = arg1;
739
+ const ret = typeof(obj) === 'string' ? obj : undefined;
740
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
741
+ var len1 = WASM_VECTOR_LEN;
742
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
743
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
744
+ },
745
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
746
+ throw new Error(getStringFromWasm0(arg0, arg1));
747
+ },
748
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
749
+ let deferred0_0;
750
+ let deferred0_1;
751
+ try {
752
+ deferred0_0 = arg0;
753
+ deferred0_1 = arg1;
754
+ console.error(getStringFromWasm0(arg0, arg1));
755
+ } finally {
756
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
757
+ }
758
+ },
759
+ __wbg_new_227d7c05414eb861: function() {
760
+ const ret = new Error();
761
+ return ret;
762
+ },
763
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
764
+ const ret = arg1.stack;
765
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
766
+ const len1 = WASM_VECTOR_LEN;
767
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
768
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
769
+ },
770
+ __wbindgen_init_externref_table: function() {
771
+ const table = wasm.__wbindgen_externrefs;
772
+ const offset = table.grow(4);
773
+ table.set(0, undefined);
774
+ table.set(offset + 0, undefined);
775
+ table.set(offset + 1, null);
776
+ table.set(offset + 2, true);
777
+ table.set(offset + 3, false);
778
+ },
779
+ };
780
+ return {
781
+ __proto__: null,
782
+ "./openrscad_bg.js": import0,
783
+ };
784
+ }
785
+
786
+ const ExportShape3DResultFinalization = (typeof FinalizationRegistry === 'undefined')
787
+ ? { register: () => {}, unregister: () => {} }
788
+ : new FinalizationRegistry(ptr => wasm.__wbg_exportshape3dresult_free(ptr, 1));
789
+ const RenderResultFinalization = (typeof FinalizationRegistry === 'undefined')
790
+ ? { register: () => {}, unregister: () => {} }
791
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderresult_free(ptr, 1));
792
+
793
+ function addToExternrefTable0(obj) {
794
+ const idx = wasm.__externref_table_alloc();
795
+ wasm.__wbindgen_externrefs.set(idx, obj);
796
+ return idx;
797
+ }
798
+
799
+ function getArrayF32FromWasm0(ptr, len) {
800
+ ptr = ptr >>> 0;
801
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
802
+ }
803
+
804
+ function getArrayU8FromWasm0(ptr, len) {
805
+ ptr = ptr >>> 0;
806
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
807
+ }
808
+
809
+ let cachedDataViewMemory0 = null;
810
+ function getDataViewMemory0() {
811
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
812
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
813
+ }
814
+ return cachedDataViewMemory0;
815
+ }
816
+
817
+ let cachedFloat32ArrayMemory0 = null;
818
+ function getFloat32ArrayMemory0() {
819
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
820
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
821
+ }
822
+ return cachedFloat32ArrayMemory0;
823
+ }
824
+
825
+ function getStringFromWasm0(ptr, len) {
826
+ return decodeText(ptr >>> 0, len);
827
+ }
828
+
829
+ let cachedUint8ArrayMemory0 = null;
830
+ function getUint8ArrayMemory0() {
831
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
832
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
833
+ }
834
+ return cachedUint8ArrayMemory0;
835
+ }
836
+
837
+ function isLikeNone(x) {
838
+ return x === undefined || x === null;
839
+ }
840
+
841
+ function passArrayJsValueToWasm0(array, malloc) {
842
+ const ptr = malloc(array.length * 4, 4) >>> 0;
843
+ for (let i = 0; i < array.length; i++) {
844
+ const add = addToExternrefTable0(array[i]);
845
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
846
+ }
847
+ WASM_VECTOR_LEN = array.length;
848
+ return ptr;
849
+ }
850
+
851
+ function passStringToWasm0(arg, malloc, realloc) {
852
+ if (realloc === undefined) {
853
+ const buf = cachedTextEncoder.encode(arg);
854
+ const ptr = malloc(buf.length, 1) >>> 0;
855
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
856
+ WASM_VECTOR_LEN = buf.length;
857
+ return ptr;
858
+ }
859
+
860
+ let len = arg.length;
861
+ let ptr = malloc(len, 1) >>> 0;
862
+
863
+ const mem = getUint8ArrayMemory0();
864
+
865
+ let offset = 0;
866
+
867
+ for (; offset < len; offset++) {
868
+ const code = arg.charCodeAt(offset);
869
+ if (code > 0x7F) break;
870
+ mem[ptr + offset] = code;
871
+ }
872
+ if (offset !== len) {
873
+ if (offset !== 0) {
874
+ arg = arg.slice(offset);
875
+ }
876
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
877
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
878
+ const ret = cachedTextEncoder.encodeInto(arg, view);
879
+
880
+ offset += ret.written;
881
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
882
+ }
883
+
884
+ WASM_VECTOR_LEN = offset;
885
+ return ptr;
886
+ }
887
+
888
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
889
+ cachedTextDecoder.decode();
890
+ function decodeText(ptr, len) {
891
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
892
+ }
893
+
894
+ const cachedTextEncoder = new TextEncoder();
895
+
896
+ if (!('encodeInto' in cachedTextEncoder)) {
897
+ cachedTextEncoder.encodeInto = function (arg, view) {
898
+ const buf = cachedTextEncoder.encode(arg);
899
+ view.set(buf);
900
+ return {
901
+ read: arg.length,
902
+ written: buf.length
903
+ };
904
+ };
905
+ }
906
+
907
+ let WASM_VECTOR_LEN = 0;
908
+
909
+ const wasmPath = `${__dirname}/openrscad_bg.wasm`;
910
+ const wasmBytes = require('fs').readFileSync(wasmPath);
911
+ const wasmModule = new WebAssembly.Module(wasmBytes);
912
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
913
+ let wasm = wasmInstance.exports;
914
+ wasm.__wbindgen_start();