taffy-js 0.2.5 → 0.2.7

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,2828 @@
1
+ let wasm;
2
+
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_externrefs.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function _assertClass(instance, klass) {
10
+ if (!(instance instanceof klass)) {
11
+ throw new Error(`expected instance of ${klass.name}`);
12
+ }
13
+ }
14
+
15
+ function debugString(val) {
16
+ // primitive types
17
+ const type = typeof val;
18
+ if (type == 'number' || type == 'boolean' || val == null) {
19
+ return `${val}`;
20
+ }
21
+ if (type == 'string') {
22
+ return `"${val}"`;
23
+ }
24
+ if (type == 'symbol') {
25
+ const description = val.description;
26
+ if (description == null) {
27
+ return 'Symbol';
28
+ } else {
29
+ return `Symbol(${description})`;
30
+ }
31
+ }
32
+ if (type == 'function') {
33
+ const name = val.name;
34
+ if (typeof name == 'string' && name.length > 0) {
35
+ return `Function(${name})`;
36
+ } else {
37
+ return 'Function';
38
+ }
39
+ }
40
+ // objects
41
+ if (Array.isArray(val)) {
42
+ const length = val.length;
43
+ let debug = '[';
44
+ if (length > 0) {
45
+ debug += debugString(val[0]);
46
+ }
47
+ for(let i = 1; i < length; i++) {
48
+ debug += ', ' + debugString(val[i]);
49
+ }
50
+ debug += ']';
51
+ return debug;
52
+ }
53
+ // Test for built-in
54
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
55
+ let className;
56
+ if (builtInMatches && builtInMatches.length > 1) {
57
+ className = builtInMatches[1];
58
+ } else {
59
+ // Failed to match the standard '[object ClassName]'
60
+ return toString.call(val);
61
+ }
62
+ if (className == 'Object') {
63
+ // we're a user defined class or Object
64
+ // JSON.stringify avoids problems with cycles, and is generally much
65
+ // easier than looping through ownProperties of `val`.
66
+ try {
67
+ return 'Object(' + JSON.stringify(val) + ')';
68
+ } catch (_) {
69
+ return 'Object';
70
+ }
71
+ }
72
+ // errors
73
+ if (val instanceof Error) {
74
+ return `${val.name}: ${val.message}\n${val.stack}`;
75
+ }
76
+ // TODO we could test for more things here, like `Set`s and `Map`s.
77
+ return className;
78
+ }
79
+
80
+ function getArrayJsValueFromWasm0(ptr, len) {
81
+ ptr = ptr >>> 0;
82
+ const mem = getDataViewMemory0();
83
+ const result = [];
84
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
85
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
86
+ }
87
+ wasm.__externref_drop_slice(ptr, len);
88
+ return result;
89
+ }
90
+
91
+ function getArrayU64FromWasm0(ptr, len) {
92
+ ptr = ptr >>> 0;
93
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
94
+ }
95
+
96
+ function getArrayU8FromWasm0(ptr, len) {
97
+ ptr = ptr >>> 0;
98
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
99
+ }
100
+
101
+ let cachedBigUint64ArrayMemory0 = null;
102
+ function getBigUint64ArrayMemory0() {
103
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
104
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
105
+ }
106
+ return cachedBigUint64ArrayMemory0;
107
+ }
108
+
109
+ let cachedDataViewMemory0 = null;
110
+ function getDataViewMemory0() {
111
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
112
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
113
+ }
114
+ return cachedDataViewMemory0;
115
+ }
116
+
117
+ function getStringFromWasm0(ptr, len) {
118
+ ptr = ptr >>> 0;
119
+ return decodeText(ptr, len);
120
+ }
121
+
122
+ let cachedUint8ArrayMemory0 = null;
123
+ function getUint8ArrayMemory0() {
124
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
125
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
126
+ }
127
+ return cachedUint8ArrayMemory0;
128
+ }
129
+
130
+ function handleError(f, args) {
131
+ try {
132
+ return f.apply(this, args);
133
+ } catch (e) {
134
+ const idx = addToExternrefTable0(e);
135
+ wasm.__wbindgen_exn_store(idx);
136
+ }
137
+ }
138
+
139
+ function isLikeNone(x) {
140
+ return x === undefined || x === null;
141
+ }
142
+
143
+ function passArray64ToWasm0(arg, malloc) {
144
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
145
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
146
+ WASM_VECTOR_LEN = arg.length;
147
+ return ptr;
148
+ }
149
+
150
+ function passStringToWasm0(arg, malloc, realloc) {
151
+ if (realloc === undefined) {
152
+ const buf = cachedTextEncoder.encode(arg);
153
+ const ptr = malloc(buf.length, 1) >>> 0;
154
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
155
+ WASM_VECTOR_LEN = buf.length;
156
+ return ptr;
157
+ }
158
+
159
+ let len = arg.length;
160
+ let ptr = malloc(len, 1) >>> 0;
161
+
162
+ const mem = getUint8ArrayMemory0();
163
+
164
+ let offset = 0;
165
+
166
+ for (; offset < len; offset++) {
167
+ const code = arg.charCodeAt(offset);
168
+ if (code > 0x7F) break;
169
+ mem[ptr + offset] = code;
170
+ }
171
+ if (offset !== len) {
172
+ if (offset !== 0) {
173
+ arg = arg.slice(offset);
174
+ }
175
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
176
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
177
+ const ret = cachedTextEncoder.encodeInto(arg, view);
178
+
179
+ offset += ret.written;
180
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
181
+ }
182
+
183
+ WASM_VECTOR_LEN = offset;
184
+ return ptr;
185
+ }
186
+
187
+ function takeFromExternrefTable0(idx) {
188
+ const value = wasm.__wbindgen_externrefs.get(idx);
189
+ wasm.__externref_table_dealloc(idx);
190
+ return value;
191
+ }
192
+
193
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
194
+ cachedTextDecoder.decode();
195
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
196
+ let numBytesDecoded = 0;
197
+ function decodeText(ptr, len) {
198
+ numBytesDecoded += len;
199
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
200
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
201
+ cachedTextDecoder.decode();
202
+ numBytesDecoded = len;
203
+ }
204
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
205
+ }
206
+
207
+ const cachedTextEncoder = new TextEncoder();
208
+
209
+ if (!('encodeInto' in cachedTextEncoder)) {
210
+ cachedTextEncoder.encodeInto = function (arg, view) {
211
+ const buf = cachedTextEncoder.encode(arg);
212
+ view.set(buf);
213
+ return {
214
+ read: arg.length,
215
+ written: buf.length
216
+ };
217
+ }
218
+ }
219
+
220
+ let WASM_VECTOR_LEN = 0;
221
+
222
+ const LayoutFinalization = (typeof FinalizationRegistry === 'undefined')
223
+ ? { register: () => {}, unregister: () => {} }
224
+ : new FinalizationRegistry(ptr => wasm.__wbg_layout_free(ptr >>> 0, 1));
225
+
226
+ const StyleFinalization = (typeof FinalizationRegistry === 'undefined')
227
+ ? { register: () => {}, unregister: () => {} }
228
+ : new FinalizationRegistry(ptr => wasm.__wbg_style_free(ptr >>> 0, 1));
229
+
230
+ const TaffyErrorFinalization = (typeof FinalizationRegistry === 'undefined')
231
+ ? { register: () => {}, unregister: () => {} }
232
+ : new FinalizationRegistry(ptr => wasm.__wbg_taffyerror_free(ptr >>> 0, 1));
233
+
234
+ const TaffyTreeFinalization = (typeof FinalizationRegistry === 'undefined')
235
+ ? { register: () => {}, unregister: () => {} }
236
+ : new FinalizationRegistry(ptr => wasm.__wbg_taffytree_free(ptr >>> 0, 1));
237
+
238
+ /**
239
+ * Multi-line content alignment enumeration
240
+ *
241
+ * Controls the distribution of space between and around content items along the cross axis
242
+ * in a multi-line flex container. This corresponds to the CSS `align-content` property.
243
+ *
244
+ * **Note**: This property only has effect when `flex-wrap` is set to `Wrap` or `WrapReverse`.
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * import { AlignContent, FlexWrap } from 'taffy-js';
249
+ *
250
+ * style.flexWrap = FlexWrap.Wrap;
251
+ * style.alignContent = AlignContent.SpaceBetween; // Distribute lines evenly
252
+ * ```
253
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
254
+ */
255
+ export const AlignContent = Object.freeze({
256
+ /**
257
+ * Lines packed toward the start of the cross axis
258
+ */
259
+ Start: 0, "0": "Start",
260
+ /**
261
+ * Lines packed toward the end of the cross axis
262
+ */
263
+ End: 1, "1": "End",
264
+ /**
265
+ * Lines packed toward the start of the flex container
266
+ */
267
+ FlexStart: 2, "2": "FlexStart",
268
+ /**
269
+ * Lines packed toward the end of the flex container
270
+ */
271
+ FlexEnd: 3, "3": "FlexEnd",
272
+ /**
273
+ * Lines centered within the container
274
+ */
275
+ Center: 4, "4": "Center",
276
+ /**
277
+ * Lines stretched to fill the container
278
+ */
279
+ Stretch: 5, "5": "Stretch",
280
+ /**
281
+ * Lines evenly distributed with first/last at edges
282
+ */
283
+ SpaceBetween: 6, "6": "SpaceBetween",
284
+ /**
285
+ * Lines evenly distributed with equal space around each
286
+ */
287
+ SpaceAround: 7, "7": "SpaceAround",
288
+ /**
289
+ * Lines evenly distributed with equal space between each
290
+ */
291
+ SpaceEvenly: 8, "8": "SpaceEvenly",
292
+ });
293
+
294
+ /**
295
+ * Cross-axis alignment enumeration for all children
296
+ *
297
+ * Defines the default alignment for all flex/grid items along the cross axis.
298
+ * This corresponds to the CSS `align-items` property.
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * import { AlignItems } from 'taffy-js';
303
+ *
304
+ * style.alignItems = AlignItems.Center; // Center items on cross axis
305
+ * style.alignItems = AlignItems.Stretch; // Stretch items to fill container
306
+ * ```
307
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
308
+ */
309
+ export const AlignItems = Object.freeze({
310
+ /**
311
+ * Items aligned to the start of the cross axis
312
+ */
313
+ Start: 0, "0": "Start",
314
+ /**
315
+ * Items aligned to the end of the cross axis
316
+ */
317
+ End: 1, "1": "End",
318
+ /**
319
+ * Items aligned to the start of the flex container
320
+ */
321
+ FlexStart: 2, "2": "FlexStart",
322
+ /**
323
+ * Items aligned to the end of the flex container
324
+ */
325
+ FlexEnd: 3, "3": "FlexEnd",
326
+ /**
327
+ * Items centered along the cross axis
328
+ */
329
+ Center: 4, "4": "Center",
330
+ /**
331
+ * Items aligned to their text baselines
332
+ */
333
+ Baseline: 5, "5": "Baseline",
334
+ /**
335
+ * Items stretched to fill the container
336
+ */
337
+ Stretch: 6, "6": "Stretch",
338
+ });
339
+
340
+ /**
341
+ * Cross-axis alignment enumeration for a single element
342
+ *
343
+ * Overrides the parent's `align-items` value for a specific child element.
344
+ * This corresponds to the CSS `align-self` property.
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * import { AlignSelf } from 'taffy-js';
349
+ *
350
+ * style.alignSelf = AlignSelf.Auto; // Use parent's align-items
351
+ * style.alignSelf = AlignSelf.Center; // Override to center this item
352
+ * ```
353
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
354
+ */
355
+ export const AlignSelf = Object.freeze({
356
+ /**
357
+ * Inherits the parent container's `align-items` value
358
+ */
359
+ Auto: 0, "0": "Auto",
360
+ /**
361
+ * Item aligned to the start of the cross axis
362
+ */
363
+ Start: 1, "1": "Start",
364
+ /**
365
+ * Item aligned to the end of the cross axis
366
+ */
367
+ End: 2, "2": "End",
368
+ /**
369
+ * Item aligned to the start of the flex container
370
+ */
371
+ FlexStart: 3, "3": "FlexStart",
372
+ /**
373
+ * Item aligned to the end of the flex container
374
+ */
375
+ FlexEnd: 4, "4": "FlexEnd",
376
+ /**
377
+ * Item centered along the cross axis
378
+ */
379
+ Center: 5, "5": "Center",
380
+ /**
381
+ * Item aligned to its text baseline
382
+ */
383
+ Baseline: 6, "6": "Baseline",
384
+ /**
385
+ * Item stretched to fill the container
386
+ */
387
+ Stretch: 7, "7": "Stretch",
388
+ });
389
+
390
+ /**
391
+ * Box sizing enumeration
392
+ *
393
+ * Controls how the total width and height of an element is calculated.
394
+ * This corresponds to the CSS `box-sizing` property.
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * import { BoxSizing } from 'taffy-js';
399
+ *
400
+ * style.boxSizing = BoxSizing.BorderBox; // Size includes padding and border
401
+ * style.boxSizing = BoxSizing.ContentBox; // Size is content only
402
+ * ```
403
+ * @enum {0 | 1}
404
+ */
405
+ export const BoxSizing = Object.freeze({
406
+ /**
407
+ * The width and height properties include padding and border
408
+ */
409
+ BorderBox: 0, "0": "BorderBox",
410
+ /**
411
+ * The width and height properties include only the content
412
+ */
413
+ ContentBox: 1, "1": "ContentBox",
414
+ });
415
+
416
+ /**
417
+ * Display mode enumeration
418
+ *
419
+ * Controls the layout algorithm type for an element. This corresponds to the CSS `display` property
420
+ * and determines how an element and its children are laid out.
421
+ *
422
+ * @example
423
+ * ```typescript
424
+ * import { Display } from 'taffy-js';
425
+ *
426
+ * style.display = Display.Flex; // Enable flexbox layout
427
+ * style.display = Display.Grid; // Enable grid layout
428
+ * style.display = Display.None; // Hide element from layout
429
+ * ```
430
+ * @enum {0 | 1 | 2 | 3}
431
+ */
432
+ export const Display = Object.freeze({
433
+ /**
434
+ * Block-level layout where element takes the full available width
435
+ */
436
+ Block: 0, "0": "Block",
437
+ /**
438
+ * Flexbox layout for one-dimensional item arrangement
439
+ */
440
+ Flex: 1, "1": "Flex",
441
+ /**
442
+ * CSS Grid layout for two-dimensional item arrangement
443
+ */
444
+ Grid: 2, "2": "Grid",
445
+ /**
446
+ * Element is removed from layout calculation entirely
447
+ */
448
+ None: 3, "3": "None",
449
+ });
450
+
451
+ /**
452
+ * Flex direction enumeration
453
+ *
454
+ * Defines the main axis direction for flex item layout. This corresponds to the CSS
455
+ * `flex-direction` property and determines how flex items are placed within the container.
456
+ *
457
+ * @example
458
+ * ```typescript
459
+ * import { FlexDirection } from 'taffy-js';
460
+ *
461
+ * style.flexDirection = FlexDirection.Row; // Horizontal, left to right
462
+ * style.flexDirection = FlexDirection.Column; // Vertical, top to bottom
463
+ * ```
464
+ * @enum {0 | 1 | 2 | 3}
465
+ */
466
+ export const FlexDirection = Object.freeze({
467
+ /**
468
+ * Main axis runs horizontally from left to right
469
+ */
470
+ Row: 0, "0": "Row",
471
+ /**
472
+ * Main axis runs vertically from top to bottom
473
+ */
474
+ Column: 1, "1": "Column",
475
+ /**
476
+ * Main axis runs horizontally from right to left
477
+ */
478
+ RowReverse: 2, "2": "RowReverse",
479
+ /**
480
+ * Main axis runs vertically from bottom to top
481
+ */
482
+ ColumnReverse: 3, "3": "ColumnReverse",
483
+ });
484
+
485
+ /**
486
+ * Flex wrap mode enumeration
487
+ *
488
+ * Controls whether flex items wrap onto multiple lines when they overflow the container.
489
+ * This corresponds to the CSS `flex-wrap` property.
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * import { FlexWrap } from 'taffy-js';
494
+ *
495
+ * style.flexWrap = FlexWrap.NoWrap; // All items on single line
496
+ * style.flexWrap = FlexWrap.Wrap; // Items wrap to new lines
497
+ * ```
498
+ * @enum {0 | 1 | 2}
499
+ */
500
+ export const FlexWrap = Object.freeze({
501
+ /**
502
+ * All flex items are placed on a single line
503
+ */
504
+ NoWrap: 0, "0": "NoWrap",
505
+ /**
506
+ * Flex items wrap onto multiple lines from top to bottom
507
+ */
508
+ Wrap: 1, "1": "Wrap",
509
+ /**
510
+ * Flex items wrap onto multiple lines from bottom to top
511
+ */
512
+ WrapReverse: 2, "2": "WrapReverse",
513
+ });
514
+
515
+ /**
516
+ * Main axis alignment enumeration
517
+ *
518
+ * Defines how flex items are aligned and spaced along the main axis.
519
+ * This corresponds to the CSS `justify-content` property.
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * import { JustifyContent } from 'taffy-js';
524
+ *
525
+ * style.justifyContent = JustifyContent.Center; // Center items
526
+ * style.justifyContent = JustifyContent.SpaceBetween; // Distribute evenly
527
+ * ```
528
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
529
+ */
530
+ export const JustifyContent = Object.freeze({
531
+ /**
532
+ * Items packed toward the start of the main axis
533
+ */
534
+ Start: 0, "0": "Start",
535
+ /**
536
+ * Items packed toward the end of the main axis
537
+ */
538
+ End: 1, "1": "End",
539
+ /**
540
+ * Items packed toward the start of the flex container
541
+ */
542
+ FlexStart: 2, "2": "FlexStart",
543
+ /**
544
+ * Items packed toward the end of the flex container
545
+ */
546
+ FlexEnd: 3, "3": "FlexEnd",
547
+ /**
548
+ * Items centered along the main axis
549
+ */
550
+ Center: 4, "4": "Center",
551
+ /**
552
+ * Items stretched along the main axis
553
+ */
554
+ Stretch: 5, "5": "Stretch",
555
+ /**
556
+ * Items evenly distributed with first/last at edges
557
+ */
558
+ SpaceBetween: 6, "6": "SpaceBetween",
559
+ /**
560
+ * Items evenly distributed with equal space around each
561
+ */
562
+ SpaceAround: 7, "7": "SpaceAround",
563
+ /**
564
+ * Items evenly distributed with equal space between each
565
+ */
566
+ SpaceEvenly: 8, "8": "SpaceEvenly",
567
+ });
568
+
569
+ /**
570
+ * Computed layout result containing position, size, and spacing values for a node.
571
+ *
572
+ * This class wraps the native [`taffy::Layout`] and provides read-only access
573
+ * to all computed layout values. All dimensions are in pixels.
574
+ *
575
+ * @example
576
+ * ```typescript
577
+ * const layout = tree.getLayout(node);
578
+ *
579
+ * console.log("Position:", layout.x, layout.y);
580
+ * console.log("Size:", layout.width, layout.height);
581
+ * console.log("Content:", layout.contentWidth, layout.contentHeight);
582
+ * console.log("Padding:", layout.paddingTop, layout.paddingRight, layout.paddingBottom, layout.paddingLeft);
583
+ * console.log("Border:", layout.borderTop, layout.borderRight, layout.borderBottom, layout.borderLeft);
584
+ * console.log("Margin:", layout.marginTop, layout.marginRight, layout.marginBottom, layout.marginLeft);
585
+ * console.log("Scrollbar:", layout.scrollbarWidth, layout.scrollbarHeight);
586
+ * console.log("Order:", layout.order);
587
+ * ```
588
+ */
589
+ export class Layout {
590
+ static __wrap(ptr) {
591
+ ptr = ptr >>> 0;
592
+ const obj = Object.create(Layout.prototype);
593
+ obj.__wbg_ptr = ptr;
594
+ LayoutFinalization.register(obj, obj.__wbg_ptr, obj);
595
+ return obj;
596
+ }
597
+ __destroy_into_raw() {
598
+ const ptr = this.__wbg_ptr;
599
+ this.__wbg_ptr = 0;
600
+ LayoutFinalization.unregister(this);
601
+ return ptr;
602
+ }
603
+ free() {
604
+ const ptr = this.__destroy_into_raw();
605
+ wasm.__wbg_layout_free(ptr, 0);
606
+ }
607
+ /**
608
+ * Gets the top border width
609
+ *
610
+ * @returns - The computed top border width in pixels
611
+ * @returns {number}
612
+ */
613
+ get borderTop() {
614
+ const ret = wasm.layout_borderTop(this.__wbg_ptr);
615
+ return ret;
616
+ }
617
+ /**
618
+ * Gets the top margin
619
+ *
620
+ * @returns - The computed top margin in pixels
621
+ * @returns {number}
622
+ */
623
+ get marginTop() {
624
+ const ret = wasm.layout_marginTop(this.__wbg_ptr);
625
+ return ret;
626
+ }
627
+ /**
628
+ * Gets the left border width
629
+ *
630
+ * @returns - The computed left border width in pixels
631
+ * @returns {number}
632
+ */
633
+ get borderLeft() {
634
+ const ret = wasm.layout_borderLeft(this.__wbg_ptr);
635
+ return ret;
636
+ }
637
+ /**
638
+ * Gets the left margin
639
+ *
640
+ * @returns - The computed left margin in pixels
641
+ * @returns {number}
642
+ */
643
+ get marginLeft() {
644
+ const ret = wasm.layout_marginLeft(this.__wbg_ptr);
645
+ return ret;
646
+ }
647
+ /**
648
+ * Gets the top padding
649
+ *
650
+ * @returns - The computed top padding in pixels
651
+ * @returns {number}
652
+ */
653
+ get paddingTop() {
654
+ const ret = wasm.layout_paddingTop(this.__wbg_ptr);
655
+ return ret;
656
+ }
657
+ /**
658
+ * Gets the right border width
659
+ *
660
+ * @returns - The computed right border width in pixels
661
+ * @returns {number}
662
+ */
663
+ get borderRight() {
664
+ const ret = wasm.layout_borderRight(this.__wbg_ptr);
665
+ return ret;
666
+ }
667
+ /**
668
+ * Gets the right margin
669
+ *
670
+ * @returns - The computed right margin in pixels
671
+ * @returns {number}
672
+ */
673
+ get marginRight() {
674
+ const ret = wasm.layout_marginRight(this.__wbg_ptr);
675
+ return ret;
676
+ }
677
+ /**
678
+ * Gets the left padding
679
+ *
680
+ * @returns - The computed left padding in pixels
681
+ * @returns {number}
682
+ */
683
+ get paddingLeft() {
684
+ const ret = wasm.layout_paddingLeft(this.__wbg_ptr);
685
+ return ret;
686
+ }
687
+ /**
688
+ * Gets the bottom border width
689
+ *
690
+ * @returns - The computed bottom border width in pixels
691
+ * @returns {number}
692
+ */
693
+ get borderBottom() {
694
+ const ret = wasm.layout_borderBottom(this.__wbg_ptr);
695
+ return ret;
696
+ }
697
+ /**
698
+ * Gets the width of the scrollable content
699
+ *
700
+ * If the node has overflow content, this represents the total
701
+ * width of all content (may exceed `width`).
702
+ *
703
+ * @returns - The content width in pixels
704
+ * @returns {number}
705
+ */
706
+ get contentWidth() {
707
+ const ret = wasm.layout_contentWidth(this.__wbg_ptr);
708
+ return ret;
709
+ }
710
+ /**
711
+ * Gets the bottom margin
712
+ *
713
+ * @returns - The computed bottom margin in pixels
714
+ * @returns {number}
715
+ */
716
+ get marginBottom() {
717
+ const ret = wasm.layout_marginBottom(this.__wbg_ptr);
718
+ return ret;
719
+ }
720
+ /**
721
+ * Gets the right padding
722
+ *
723
+ * @returns - The computed right padding in pixels
724
+ * @returns {number}
725
+ */
726
+ get paddingRight() {
727
+ const ret = wasm.layout_paddingRight(this.__wbg_ptr);
728
+ return ret;
729
+ }
730
+ /**
731
+ * Gets the height of the scrollable content
732
+ *
733
+ * If the node has overflow content, this represents the total
734
+ * height of all content (may exceed `height`).
735
+ *
736
+ * @returns - The content height in pixels
737
+ * @returns {number}
738
+ */
739
+ get contentHeight() {
740
+ const ret = wasm.layout_contentHeight(this.__wbg_ptr);
741
+ return ret;
742
+ }
743
+ /**
744
+ * Gets the bottom padding
745
+ *
746
+ * @returns - The computed bottom padding in pixels
747
+ * @returns {number}
748
+ */
749
+ get paddingBottom() {
750
+ const ret = wasm.layout_paddingBottom(this.__wbg_ptr);
751
+ return ret;
752
+ }
753
+ /**
754
+ * Gets the width of the vertical scrollbar
755
+ *
756
+ * When overflow is set to scroll, this indicates the space
757
+ * reserved for the vertical scrollbar.
758
+ *
759
+ * @returns - The scrollbar width in pixels (0 if no scrollbar)
760
+ * @returns {number}
761
+ */
762
+ get scrollbarWidth() {
763
+ const ret = wasm.layout_scrollbarWidth(this.__wbg_ptr);
764
+ return ret;
765
+ }
766
+ /**
767
+ * Gets the height of the horizontal scrollbar
768
+ *
769
+ * When overflow is set to scroll, this indicates the space
770
+ * reserved for the horizontal scrollbar.
771
+ *
772
+ * @returns - The scrollbar height in pixels (0 if no scrollbar)
773
+ * @returns {number}
774
+ */
775
+ get scrollbarHeight() {
776
+ const ret = wasm.layout_scrollbarHeight(this.__wbg_ptr);
777
+ return ret;
778
+ }
779
+ /**
780
+ * Gets the X coordinate of the node's top-left corner
781
+ *
782
+ * This value is relative to the node's parent. For the root node,
783
+ * this is always 0.
784
+ *
785
+ * @returns - The horizontal position in pixels
786
+ * @returns {number}
787
+ */
788
+ get x() {
789
+ const ret = wasm.layout_x(this.__wbg_ptr);
790
+ return ret;
791
+ }
792
+ /**
793
+ * Gets the Y coordinate of the node's top-left corner
794
+ *
795
+ * This value is relative to the node's parent. For the root node,
796
+ * this is always 0.
797
+ *
798
+ * @returns - The vertical position in pixels
799
+ * @returns {number}
800
+ */
801
+ get y() {
802
+ const ret = wasm.layout_y(this.__wbg_ptr);
803
+ return ret;
804
+ }
805
+ /**
806
+ * Gets the rendering order of the node
807
+ *
808
+ * This value determines the z-order for overlapping elements.
809
+ * Lower values are rendered first (behind higher values).
810
+ *
811
+ * @returns - The rendering order as an unsigned 32-bit integer
812
+ * @returns {number}
813
+ */
814
+ get order() {
815
+ const ret = wasm.layout_order(this.__wbg_ptr);
816
+ return ret >>> 0;
817
+ }
818
+ /**
819
+ * Gets the computed width of the node
820
+ *
821
+ * This is the final width after layout computation, including
822
+ * any constraints from min/max size or flex properties.
823
+ *
824
+ * @returns - The width in pixels
825
+ * @returns {number}
826
+ */
827
+ get width() {
828
+ const ret = wasm.layout_width(this.__wbg_ptr);
829
+ return ret;
830
+ }
831
+ /**
832
+ * Gets the computed height of the node
833
+ *
834
+ * This is the final height after layout computation, including
835
+ * any constraints from min/max size or flex properties.
836
+ *
837
+ * @returns - The height in pixels
838
+ * @returns {number}
839
+ */
840
+ get height() {
841
+ const ret = wasm.layout_height(this.__wbg_ptr);
842
+ return ret;
843
+ }
844
+ }
845
+ if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
846
+
847
+ /**
848
+ * Overflow handling enumeration
849
+ *
850
+ * Defines how content that exceeds the container boundaries is handled.
851
+ * This corresponds to the CSS `overflow` property.
852
+ *
853
+ * @example
854
+ * ```typescript
855
+ * import { Overflow } from 'taffy-js';
856
+ *
857
+ * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
858
+ * ```
859
+ * @enum {0 | 1 | 2 | 3}
860
+ */
861
+ export const Overflow = Object.freeze({
862
+ /**
863
+ * Content is not clipped and may render outside the container
864
+ */
865
+ Visible: 0, "0": "Visible",
866
+ /**
867
+ * Content is clipped at the container boundary
868
+ */
869
+ Hidden: 1, "1": "Hidden",
870
+ /**
871
+ * Always display scrollbars for scrollable content
872
+ */
873
+ Scroll: 2, "2": "Scroll",
874
+ /**
875
+ * Display scrollbars only when content overflows (internally maps to Scroll)
876
+ */
877
+ Auto: 3, "3": "Auto",
878
+ });
879
+
880
+ /**
881
+ * Position mode enumeration
882
+ *
883
+ * Controls how an element is positioned within its parent container.
884
+ * This corresponds to the CSS `position` property.
885
+ *
886
+ * @example
887
+ * ```typescript
888
+ * import { Position } from 'taffy-js';
889
+ *
890
+ * style.position = Position.Relative; // Normal document flow
891
+ * style.position = Position.Absolute; // Removed from flow, uses inset values
892
+ * ```
893
+ * @enum {0 | 1}
894
+ */
895
+ export const Position = Object.freeze({
896
+ /**
897
+ * Element participates in normal document flow
898
+ */
899
+ Relative: 0, "0": "Relative",
900
+ /**
901
+ * Element is positioned relative to its nearest positioned ancestor
902
+ */
903
+ Absolute: 1, "1": "Absolute",
904
+ });
905
+
906
+ /**
907
+ * CSS layout configuration for a node, including flexbox, sizing, spacing, and alignment properties.
908
+ *
909
+ * This class holds all CSS layout properties for a node. Create an instance with
910
+ * `new Style()` and configure properties before passing to `TaffyTree.newLeaf()`.
911
+ *
912
+ * @defaultValue
913
+ * When created, all properties are set to their CSS default values:
914
+ * - `display`: `Display.Block`
915
+ * - `position`: `Position.Relative`
916
+ * - `flexDirection`: `FlexDirection.Row`
917
+ * - `flexWrap`: `FlexWrap.NoWrap`
918
+ * - `flexGrow`: `0`
919
+ * - `flexShrink`: `1`
920
+ * - All alignment properties: `undefined` (use default behavior)
921
+ * - All dimensions: `"auto"`
922
+ * - All spacing: `0`
923
+ */
924
+ export class Style {
925
+ static __wrap(ptr) {
926
+ ptr = ptr >>> 0;
927
+ const obj = Object.create(Style.prototype);
928
+ obj.__wbg_ptr = ptr;
929
+ StyleFinalization.register(obj, obj.__wbg_ptr, obj);
930
+ return obj;
931
+ }
932
+ __destroy_into_raw() {
933
+ const ptr = this.__wbg_ptr;
934
+ this.__wbg_ptr = 0;
935
+ StyleFinalization.unregister(this);
936
+ return ptr;
937
+ }
938
+ free() {
939
+ const ptr = this.__destroy_into_raw();
940
+ wasm.__wbg_style_free(ptr, 0);
941
+ }
942
+ /**
943
+ * Gets the align-self property
944
+ *
945
+ * Overrides the parent's align-items for this specific element.
946
+ *
947
+ * @returns - The current [`AlignSelf`](JsAlignSelf) value (returns `Auto` if not set)
948
+ * @returns {AlignSelf | undefined}
949
+ */
950
+ get alignSelf() {
951
+ const ret = wasm.style_alignSelf(this.__wbg_ptr);
952
+ return ret === 8 ? undefined : ret;
953
+ }
954
+ /**
955
+ * Gets the box sizing mode
956
+ *
957
+ * Determines whether padding and border are included in dimensions.
958
+ *
959
+ * @returns - The current [`BoxSizing`](JsBoxSizing) value
960
+ *
961
+ * @defaultValue `BoxSizing.BorderBox`
962
+ * @returns {BoxSizing}
963
+ */
964
+ get boxSizing() {
965
+ const ret = wasm.style_boxSizing(this.__wbg_ptr);
966
+ return ret;
967
+ }
968
+ /**
969
+ * Gets the flex-basis
970
+ *
971
+ * The initial size of a flex item before growing/shrinking.
972
+ *
973
+ * @returns - A `Dimension` value (`number`, `\"{number}%\"`, or `\"auto\"`)
974
+ * @returns {Dimension}
975
+ */
976
+ get flexBasis() {
977
+ const ret = wasm.style_flexBasis(this.__wbg_ptr);
978
+ return ret;
979
+ }
980
+ /**
981
+ * Sets the border width
982
+ *
983
+ * @param val - A Rect object with LengthPercentage values
984
+ *
985
+ * @example
986
+ * ```typescript
987
+ * style.border = { left: 1, right: 1, top: 1, bottom: 1 };
988
+ * ```
989
+ * @param {Rect<LengthPercentage>} val
990
+ */
991
+ set border(val) {
992
+ wasm.style_set_border(this.__wbg_ptr, val);
993
+ }
994
+ /**
995
+ * Sets the margin
996
+ *
997
+ * @param val - A Rect object with LengthPercentageAuto values
998
+ *
999
+ * @example
1000
+ * ```typescript
1001
+ * style.margin = { left: 10, right: 10, top: 5, bottom: 5 };
1002
+ * ```
1003
+ * @param {Rect<LengthPercentageAuto>} val
1004
+ */
1005
+ set margin(val) {
1006
+ wasm.style_set_margin(this.__wbg_ptr, val);
1007
+ }
1008
+ /**
1009
+ * Gets the align-items property
1010
+ *
1011
+ * Defines the default alignment for all children on the cross axis.
1012
+ *
1013
+ * @returns - The current [`AlignItems`](JsAlignItems) value, or `undefined` if not set
1014
+ * @returns {AlignItems | undefined}
1015
+ */
1016
+ get alignItems() {
1017
+ const ret = wasm.style_alignItems(this.__wbg_ptr);
1018
+ return ret === 7 ? undefined : ret;
1019
+ }
1020
+ /**
1021
+ * Gets the flex shrink factor
1022
+ *
1023
+ * Determines how much the item shrinks relative to siblings when
1024
+ * there is insufficient space.
1025
+ *
1026
+ * @returns - The flex shrink factor (default: 1)
1027
+ * @returns {number}
1028
+ */
1029
+ get flexShrink() {
1030
+ const ret = wasm.style_flexShrink(this.__wbg_ptr);
1031
+ return ret;
1032
+ }
1033
+ /**
1034
+ * Sets the display mode
1035
+ *
1036
+ * @param val - The new display mode
1037
+ *
1038
+ *
1039
+ * @example
1040
+ *
1041
+ * ```typescript
1042
+ * style.display = Display.Flex;
1043
+ * ```
1044
+ * @param {Display} val
1045
+ */
1046
+ set display(val) {
1047
+ wasm.style_set_display(this.__wbg_ptr, val);
1048
+ }
1049
+ /**
1050
+ * Sets the padding
1051
+ *
1052
+ * @param val - A Rect object with LengthPercentage values
1053
+ *
1054
+ * @example
1055
+ * ```typescript
1056
+ * style.padding = { left: 20, right: 20, top: 10, bottom: 10 };
1057
+ * ```
1058
+ * @param {Rect<LengthPercentage>} val
1059
+ */
1060
+ set padding(val) {
1061
+ wasm.style_set_padding(this.__wbg_ptr, val);
1062
+ }
1063
+ /**
1064
+ * Gets the aspect ratio
1065
+ *
1066
+ * The ratio of width to height. Used to maintain proportions.
1067
+ *
1068
+ * @returns - The aspect ratio value, or `undefined` if not set
1069
+ * @returns {number | undefined}
1070
+ */
1071
+ get aspectRatio() {
1072
+ const ret = wasm.style_aspectRatio(this.__wbg_ptr);
1073
+ return ret === 0x100000001 ? undefined : ret;
1074
+ }
1075
+ /**
1076
+ * Sets the maximum size constraints
1077
+ *
1078
+ * @param val - A Size object with maximum Dimension values
1079
+ *
1080
+ * @example
1081
+ * ```typescript
1082
+ * style.maxSize = { width: "auto", height: 500 };
1083
+ * ```
1084
+ * @param {Size<Dimension>} val
1085
+ */
1086
+ set maxSize(val) {
1087
+ wasm.style_set_maxSize(this.__wbg_ptr, val);
1088
+ }
1089
+ /**
1090
+ * Sets the minimum size constraints
1091
+ *
1092
+ * @param val - A Size object with minimum Dimension values
1093
+ *
1094
+ * @example
1095
+ * ```typescript
1096
+ * style.minSize = { width: 100, height: "auto" };
1097
+ * ```
1098
+ * @param {Size<Dimension>} val
1099
+ */
1100
+ set minSize(val) {
1101
+ wasm.style_set_minSize(this.__wbg_ptr, val);
1102
+ }
1103
+ /**
1104
+ * Sets the overflow behavior
1105
+ *
1106
+ * @param val - An object with `x` and `y` overflow values
1107
+ *
1108
+ * @example
1109
+ * ```typescript
1110
+ * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
1111
+ * ```
1112
+ * @param {Point<Overflow>} val
1113
+ */
1114
+ set overflow(val) {
1115
+ wasm.style_set_overflow(this.__wbg_ptr, val);
1116
+ }
1117
+ /**
1118
+ * Sets the position mode
1119
+ *
1120
+ * @param val - The new position mode
1121
+ *
1122
+ *
1123
+ * @example
1124
+ *
1125
+ * ```typescript
1126
+ * style.position = Position.Absolute;
1127
+ * style.inset = { left: 10, top: 10, right: "auto", bottom: "auto" };
1128
+ * ```
1129
+ * @param {Position} val
1130
+ */
1131
+ set position(val) {
1132
+ wasm.style_set_position(this.__wbg_ptr, val);
1133
+ }
1134
+ /**
1135
+ * Gets the align-content property
1136
+ *
1137
+ * Controls distribution of space between lines in a multi-line flex container.
1138
+ *
1139
+ * @returns - The current [`AlignContent`](JsAlignContent) value, or `undefined` if not set
1140
+ * @returns {AlignContent | undefined}
1141
+ */
1142
+ get alignContent() {
1143
+ const ret = wasm.style_alignContent(this.__wbg_ptr);
1144
+ return ret === 9 ? undefined : ret;
1145
+ }
1146
+ /**
1147
+ * Sets the flex grow factor
1148
+ *
1149
+ * @param val - The new flex grow factor (must be >= 0)
1150
+ *
1151
+ * @example
1152
+ * ```typescript
1153
+ * style.flexGrow = 2;
1154
+ * ```
1155
+ * @param {number} val
1156
+ */
1157
+ set flexGrow(val) {
1158
+ wasm.style_set_flexGrow(this.__wbg_ptr, val);
1159
+ }
1160
+ /**
1161
+ * Sets the flex wrap mode
1162
+ *
1163
+ * @param val - The new flex wrap mode
1164
+ *
1165
+ *
1166
+ * @example
1167
+ *
1168
+ * ```typescript
1169
+ * style.flexWrap = FlexWrap.Wrap;
1170
+ * ```
1171
+ * @param {FlexWrap} val
1172
+ */
1173
+ set flexWrap(val) {
1174
+ wasm.style_set_flexWrap(this.__wbg_ptr, val);
1175
+ }
1176
+ /**
1177
+ * Gets the flex direction
1178
+ *
1179
+ * Defines the main axis direction for flex items.
1180
+ *
1181
+ * @returns - The current [`FlexDirection`](JsFlexDirection) value
1182
+ *
1183
+ * @defaultValue - `FlexDirection.Row`
1184
+ * @returns {FlexDirection}
1185
+ */
1186
+ get flexDirection() {
1187
+ const ret = wasm.style_flexDirection(this.__wbg_ptr);
1188
+ return ret;
1189
+ }
1190
+ /**
1191
+ * Sets the align-self property
1192
+ *
1193
+ * @param val - The new align-self value, or `undefined`/`Auto` to inherit from parent
1194
+ *
1195
+ * @example
1196
+ * ```typescript
1197
+ * style.alignSelf = AlignSelf.Stretch;
1198
+ * ```
1199
+ * @param {AlignSelf | undefined} val
1200
+ */
1201
+ set alignSelf(val) {
1202
+ wasm.style_set_alignSelf(this.__wbg_ptr, val);
1203
+ }
1204
+ /**
1205
+ * Sets the box sizing mode
1206
+ *
1207
+ * @param val - The new box sizing mode
1208
+ *
1209
+ * @example
1210
+ * ```typescript
1211
+ * style.boxSizing = BoxSizing.ContentBox;
1212
+ * ```
1213
+ * @param {BoxSizing} val
1214
+ */
1215
+ set boxSizing(val) {
1216
+ wasm.style_set_boxSizing(this.__wbg_ptr, val);
1217
+ }
1218
+ /**
1219
+ * Sets the flex-basis
1220
+ *
1221
+ * @param val - The initial size as a Dimension
1222
+ *
1223
+ * @example
1224
+ * ```typescript
1225
+ * style.flexBasis = 100;
1226
+ * ```
1227
+ * @param {Dimension} val
1228
+ */
1229
+ set flexBasis(val) {
1230
+ wasm.style_set_flexBasis(this.__wbg_ptr, val);
1231
+ }
1232
+ /**
1233
+ * Gets the justify-content property
1234
+ *
1235
+ * Defines alignment and spacing of items along the main axis.
1236
+ *
1237
+ * @returns - The current [`JustifyContent`](JsJustifyContent) value, or `undefined` if not set
1238
+ * @returns {JustifyContent | undefined}
1239
+ */
1240
+ get justifyContent() {
1241
+ const ret = wasm.style_justifyContent(this.__wbg_ptr);
1242
+ return ret === 9 ? undefined : ret;
1243
+ }
1244
+ /**
1245
+ * Sets the align-items property
1246
+ *
1247
+ * @param val - The new align-items value, or `undefined` to use default
1248
+ *
1249
+ * @example
1250
+ *
1251
+ * ```typescript
1252
+ * style.alignItems = AlignItems.Center;
1253
+ * ```
1254
+ * @param {AlignItems | undefined} val
1255
+ */
1256
+ set alignItems(val) {
1257
+ wasm.style_set_alignItems(this.__wbg_ptr, val);
1258
+ }
1259
+ /**
1260
+ * Sets the flex shrink factor
1261
+ *
1262
+ * @param val - The new flex shrink factor (must be >= 0)
1263
+ *
1264
+ * @example
1265
+ * ```typescript
1266
+ * style.flexShrink = 2;
1267
+ * ```
1268
+ * @param {number} val
1269
+ */
1270
+ set flexShrink(val) {
1271
+ wasm.style_set_flexShrink(this.__wbg_ptr, val);
1272
+ }
1273
+ /**
1274
+ * Sets the aspect ratio
1275
+ *
1276
+ * @param val - The new aspect ratio (width/height), or `undefined` to clear
1277
+ *
1278
+ * @example
1279
+ * ```typescript
1280
+ * style.aspectRatio = 16 / 9;
1281
+ * ```
1282
+ * @param {number | undefined} val
1283
+ */
1284
+ set aspectRatio(val) {
1285
+ wasm.style_set_aspectRatio(this.__wbg_ptr, val);
1286
+ }
1287
+ /**
1288
+ * Sets the align-content property
1289
+ *
1290
+ * @param val - The new align-content value, or `undefined` to use default
1291
+ *
1292
+ * @example
1293
+ * ```typescript
1294
+ * style.alignContent = AlignContent.SpaceBetween;
1295
+ * ```
1296
+ * @param {AlignContent | undefined} val
1297
+ */
1298
+ set alignContent(val) {
1299
+ wasm.style_set_alignContent(this.__wbg_ptr, val);
1300
+ }
1301
+ /**
1302
+ * Sets the flex direction
1303
+ *
1304
+ * @param val - The new flex direction
1305
+ *
1306
+ *
1307
+ * @example
1308
+ *
1309
+ * ```typescript
1310
+ * style.flexDirection = FlexDirection.Column;
1311
+ * ```
1312
+ * @param {FlexDirection} val
1313
+ */
1314
+ set flexDirection(val) {
1315
+ wasm.style_set_flexDirection(this.__wbg_ptr, val);
1316
+ }
1317
+ /**
1318
+ * Sets the justify-content property
1319
+ *
1320
+ * @param val - The new justify-content value, or `undefined` to use default
1321
+ *
1322
+ * @example
1323
+ * ```typescript
1324
+ * style.justifyContent = JustifyContent.Center;
1325
+ * ```
1326
+ * @param {JustifyContent | undefined} val
1327
+ */
1328
+ set justifyContent(val) {
1329
+ wasm.style_set_justifyContent(this.__wbg_ptr, val);
1330
+ }
1331
+ /**
1332
+ * Gets the gap
1333
+ *
1334
+ * Spacing between flex/grid items.
1335
+ *
1336
+ * @returns - A `Size<LengthPercentage>` with column (width) and row (height) gaps
1337
+ * @returns {Size<LengthPercentage>}
1338
+ */
1339
+ get gap() {
1340
+ const ret = wasm.style_gap(this.__wbg_ptr);
1341
+ return ret;
1342
+ }
1343
+ /**
1344
+ * Creates a new Style instance with default values
1345
+ *
1346
+ * @returns - A new `Style` object with all properties set to CSS defaults
1347
+ *
1348
+ * @example
1349
+ * ```typescript
1350
+ * const style = new Style();
1351
+ * console.log(style.display); // Display.Block
1352
+ * ```
1353
+ */
1354
+ constructor() {
1355
+ const ret = wasm.style_new();
1356
+ this.__wbg_ptr = ret >>> 0;
1357
+ StyleFinalization.register(this, this.__wbg_ptr, this);
1358
+ return this;
1359
+ }
1360
+ /**
1361
+ * Gets the size (width and height)
1362
+ *
1363
+ * @returns - A `Size<Dimension>` object with `width` and `height` properties
1364
+ * @returns {Size<Dimension>}
1365
+ */
1366
+ get size() {
1367
+ const ret = wasm.style_size(this.__wbg_ptr);
1368
+ return ret;
1369
+ }
1370
+ /**
1371
+ * Gets the inset
1372
+ *
1373
+ * Positioning offsets for absolutely positioned elements.
1374
+ *
1375
+ * @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom offsets
1376
+ * @returns {Rect<LengthPercentageAuto>}
1377
+ */
1378
+ get inset() {
1379
+ const ret = wasm.style_inset(this.__wbg_ptr);
1380
+ return ret;
1381
+ }
1382
+ /**
1383
+ * Gets the border width
1384
+ *
1385
+ * Width of the element's border on each side.
1386
+ *
1387
+ * @returns - A `Rect<LengthPercentage>` with left, right, top, bottom border widths
1388
+ * @returns {Rect<LengthPercentage>}
1389
+ */
1390
+ get border() {
1391
+ const ret = wasm.style_border(this.__wbg_ptr);
1392
+ return ret;
1393
+ }
1394
+ /**
1395
+ * Gets the margin
1396
+ *
1397
+ * Outer spacing around the element.
1398
+ *
1399
+ * @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom margins
1400
+ * @returns {Rect<LengthPercentageAuto>}
1401
+ */
1402
+ get margin() {
1403
+ const ret = wasm.style_margin(this.__wbg_ptr);
1404
+ return ret;
1405
+ }
1406
+ /**
1407
+ * Gets the display mode
1408
+ *
1409
+ * Determines the layout algorithm used for this element and its children.
1410
+ *
1411
+ * @returns - The current [`Display`](JsDisplay) value
1412
+ *
1413
+ * @defaultValue - `Display.Block`
1414
+ * @returns {Display}
1415
+ */
1416
+ get display() {
1417
+ const ret = wasm.style_display(this.__wbg_ptr);
1418
+ return ret;
1419
+ }
1420
+ /**
1421
+ * Gets the padding
1422
+ *
1423
+ * Inner spacing between the element's border and content.
1424
+ *
1425
+ * @returns - A `Rect<LengthPercentage>` with left, right, top, bottom padding
1426
+ * @returns {Rect<LengthPercentage>}
1427
+ */
1428
+ get padding() {
1429
+ const ret = wasm.style_padding(this.__wbg_ptr);
1430
+ return ret;
1431
+ }
1432
+ /**
1433
+ * Sets the gap
1434
+ *
1435
+ * @param val - A Size object with LengthPercentage gap values
1436
+ *
1437
+ * @example
1438
+ * ```typescript
1439
+ * style.gap = { width: 10, height: 10 };
1440
+ * ```
1441
+ * @param {Size<LengthPercentage>} val
1442
+ */
1443
+ set gap(val) {
1444
+ wasm.style_set_gap(this.__wbg_ptr, val);
1445
+ }
1446
+ /**
1447
+ * Gets the maximum size constraints
1448
+ *
1449
+ * @returns - A `Size<Dimension>` object with maximum width and height
1450
+ * @returns {Size<Dimension>}
1451
+ */
1452
+ get maxSize() {
1453
+ const ret = wasm.style_maxSize(this.__wbg_ptr);
1454
+ return ret;
1455
+ }
1456
+ /**
1457
+ * Gets the minimum size constraints
1458
+ *
1459
+ * @returns - A `Size<Dimension>` object with minimum width and height
1460
+ * @returns {Size<Dimension>}
1461
+ */
1462
+ get minSize() {
1463
+ const ret = wasm.style_minSize(this.__wbg_ptr);
1464
+ return ret;
1465
+ }
1466
+ /**
1467
+ * Gets the overflow behavior
1468
+ *
1469
+ * Controls how content that exceeds the container is handled.
1470
+ *
1471
+ * @returns - A `Point<Overflow>` with `x` and `y` overflow settings
1472
+ * @returns {Point<Overflow>}
1473
+ */
1474
+ get overflow() {
1475
+ const ret = wasm.style_overflow(this.__wbg_ptr);
1476
+ return ret;
1477
+ }
1478
+ /**
1479
+ * Gets the position mode
1480
+ *
1481
+ * Determines how the element is positioned within its parent.
1482
+ *
1483
+ * @returns - The current [`Position`](JsPosition) value
1484
+ *
1485
+ * @defaultValue - `Position.Relative`
1486
+ * @returns {Position}
1487
+ */
1488
+ get position() {
1489
+ const ret = wasm.style_position(this.__wbg_ptr);
1490
+ return ret;
1491
+ }
1492
+ /**
1493
+ * Sets the size (width and height)
1494
+ *
1495
+ * @param val - A Size object with Dimension values
1496
+ *
1497
+ * @example
1498
+ * ```typescript
1499
+ * style.size = { width: 200, height: "100%" };
1500
+ * ```
1501
+ * @param {Size<Dimension>} val
1502
+ */
1503
+ set size(val) {
1504
+ wasm.style_set_size(this.__wbg_ptr, val);
1505
+ }
1506
+ /**
1507
+ * Gets the flex grow factor
1508
+ *
1509
+ * Determines how much the item grows relative to siblings when
1510
+ * there is extra space available.
1511
+ *
1512
+ * @returns - The flex grow factor (default: 0)
1513
+ * @returns {number}
1514
+ */
1515
+ get flexGrow() {
1516
+ const ret = wasm.style_flexGrow(this.__wbg_ptr);
1517
+ return ret;
1518
+ }
1519
+ /**
1520
+ * Gets the flex wrap mode
1521
+ *
1522
+ * Controls whether flex items wrap to new lines.
1523
+ *
1524
+ * @returns - The current [`FlexWrap`](JsFlexWrap) value
1525
+ *
1526
+ * @defaultValue - `FlexWrap.NoWrap`
1527
+ * @returns {FlexWrap}
1528
+ */
1529
+ get flexWrap() {
1530
+ const ret = wasm.style_flexWrap(this.__wbg_ptr);
1531
+ return ret;
1532
+ }
1533
+ /**
1534
+ * Sets the inset
1535
+ *
1536
+ * @param val - A Rect object with LengthPercentageAuto offset values
1537
+ *
1538
+ * @example
1539
+ * ```typescript
1540
+ * style.position = Position.Absolute;
1541
+ * style.inset = { left: 0, top: 0, right: "auto", bottom: "auto" };
1542
+ * ```
1543
+ * @param {Rect<LengthPercentageAuto>} val
1544
+ */
1545
+ set inset(val) {
1546
+ wasm.style_set_inset(this.__wbg_ptr, val);
1547
+ }
1548
+ }
1549
+ if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
1550
+
1551
+ /**
1552
+ * Error class thrown when a Taffy operation fails, containing a human-readable error message.
1553
+ *
1554
+ * This class wraps the native [`taffy::TaffyError`] type and exposes it to JavaScript
1555
+ * with a readable error message. It is thrown as a JavaScript exception on failure.
1556
+ *
1557
+ * @example
1558
+ * ```typescript
1559
+ * try {
1560
+ * tree.remove(node);
1561
+ * } catch (e) {
1562
+ * if (e instanceof TaffyError) {
1563
+ * console.error(e.message);
1564
+ * }
1565
+ * }
1566
+ * ```
1567
+ *
1568
+ * @remarks
1569
+ * The underlying Taffy errors include:
1570
+ * - `InvalidInputNode`: Node ID doesn't exist in the tree
1571
+ * - `InvalidParentNode`: Specified parent node doesn't exist
1572
+ * - `ChildIndexOutOfBounds`: Child index exceeds available children
1573
+ */
1574
+ export class TaffyError {
1575
+ static __wrap(ptr) {
1576
+ ptr = ptr >>> 0;
1577
+ const obj = Object.create(TaffyError.prototype);
1578
+ obj.__wbg_ptr = ptr;
1579
+ TaffyErrorFinalization.register(obj, obj.__wbg_ptr, obj);
1580
+ return obj;
1581
+ }
1582
+ __destroy_into_raw() {
1583
+ const ptr = this.__wbg_ptr;
1584
+ this.__wbg_ptr = 0;
1585
+ TaffyErrorFinalization.unregister(this);
1586
+ return ptr;
1587
+ }
1588
+ free() {
1589
+ const ptr = this.__destroy_into_raw();
1590
+ wasm.__wbg_taffyerror_free(ptr, 0);
1591
+ }
1592
+ /**
1593
+ * Gets the human-readable error message
1594
+ *
1595
+ * @returns - A string describing what went wrong.
1596
+ *
1597
+ * @remarks
1598
+ * Examples:
1599
+ * - "Node with id 1234 is not present in the Taffy tree"
1600
+ * - "Index 5 is out of bounds for node with 3 children"
1601
+ * @returns {string}
1602
+ */
1603
+ get message() {
1604
+ let deferred1_0;
1605
+ let deferred1_1;
1606
+ try {
1607
+ const ret = wasm.taffyerror_message(this.__wbg_ptr);
1608
+ deferred1_0 = ret[0];
1609
+ deferred1_1 = ret[1];
1610
+ return getStringFromWasm0(ret[0], ret[1]);
1611
+ } finally {
1612
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1613
+ }
1614
+ }
1615
+ }
1616
+ if (Symbol.dispose) TaffyError.prototype[Symbol.dispose] = TaffyError.prototype.free;
1617
+
1618
+ /**
1619
+ * The main layout tree class for creating nodes, computing layouts, and managing a tree of styled elements.
1620
+ *
1621
+ * TaffyTree is the entry point for the Taffy layout engine. It manages
1622
+ * a tree of nodes and computes their layouts using CSS Flexbox and Grid algorithms.
1623
+ */
1624
+ export class TaffyTree {
1625
+ static __wrap(ptr) {
1626
+ ptr = ptr >>> 0;
1627
+ const obj = Object.create(TaffyTree.prototype);
1628
+ obj.__wbg_ptr = ptr;
1629
+ TaffyTreeFinalization.register(obj, obj.__wbg_ptr, obj);
1630
+ return obj;
1631
+ }
1632
+ __destroy_into_raw() {
1633
+ const ptr = this.__wbg_ptr;
1634
+ this.__wbg_ptr = 0;
1635
+ TaffyTreeFinalization.unregister(this);
1636
+ return ptr;
1637
+ }
1638
+ free() {
1639
+ const ptr = this.__destroy_into_raw();
1640
+ wasm.__wbg_taffytree_free(ptr, 0);
1641
+ }
1642
+ /**
1643
+ * Marks a node as dirty (requiring re-layout)
1644
+ *
1645
+ * Use this when a node's content has changed but its style hasn't.
1646
+ * For example, when text content changes and needs remeasuring.
1647
+ *
1648
+ * @param node - The node ID to mark dirty
1649
+ *
1650
+ * @throws `TaffyError` if the node does not exist
1651
+ *
1652
+ * @example
1653
+ * ```typescript
1654
+ * // After updating text content
1655
+ * tree.setNodeContext(nodeId, { text: "Updated text" });
1656
+ * tree.markDirty(nodeId);
1657
+ * tree.computeLayout(rootId, availableSpace);
1658
+ * ```
1659
+ * @param {bigint} node
1660
+ */
1661
+ markDirty(node) {
1662
+ const ret = wasm.taffytree_markDirty(this.__wbg_ptr, node);
1663
+ if (ret[1]) {
1664
+ throw takeFromExternrefTable0(ret[0]);
1665
+ }
1666
+ }
1667
+ /**
1668
+ * Prints the tree structure to the console (for debugging)
1669
+ *
1670
+ * Outputs a text representation of the tree structure starting from
1671
+ * the given node. Useful for debugging layout issues.
1672
+ *
1673
+ * @param node - The root node ID to print from
1674
+ *
1675
+ * @example
1676
+ * ```typescript
1677
+ * tree.printTree(rootId);
1678
+ * // Output appears in browser console
1679
+ * ```
1680
+ * @param {bigint} node
1681
+ */
1682
+ printTree(node) {
1683
+ wasm.taffytree_printTree(this.__wbg_ptr, node);
1684
+ }
1685
+ /**
1686
+ * Gets the number of children of a node
1687
+ *
1688
+ * @param parent - The parent node ID
1689
+ *
1690
+ * @returns - The number of direct children
1691
+ *
1692
+ * @throws `TaffyError` if the node does not exist
1693
+ *
1694
+ * @example
1695
+ * ```typescript
1696
+ * const count: number = tree.childCount(parentId);
1697
+ * ```
1698
+ * @param {bigint} parent
1699
+ * @returns {number}
1700
+ */
1701
+ childCount(parent) {
1702
+ const ret = wasm.taffytree_childCount(this.__wbg_ptr, parent);
1703
+ return ret >>> 0;
1704
+ }
1705
+ /**
1706
+ * Removes a specific child from a parent
1707
+ *
1708
+ * @param parent - The parent node ID
1709
+ * @param child - The child node ID to remove
1710
+ *
1711
+ * @returns - The removed child ID (`bigint`)
1712
+ *
1713
+ * @throws `TaffyError` if the parent or child node does not exist
1714
+ *
1715
+ * @example
1716
+ * ```typescript
1717
+ * tree.removeChild(parentId, childId);
1718
+ * ```
1719
+ * @param {bigint} parent
1720
+ * @param {bigint} child
1721
+ * @returns {bigint}
1722
+ */
1723
+ removeChild(parent, child) {
1724
+ const ret = wasm.taffytree_removeChild(this.__wbg_ptr, parent, child);
1725
+ if (ret[2]) {
1726
+ throw takeFromExternrefTable0(ret[1]);
1727
+ }
1728
+ return BigInt.asUintN(64, ret[0]);
1729
+ }
1730
+ /**
1731
+ * Replaces all children of a node
1732
+ *
1733
+ * Any existing children are removed and replaced with the new array.
1734
+ *
1735
+ * @param parent - The parent node ID
1736
+ * @param children - Array of new child node IDs
1737
+ *
1738
+ * @throws `TaffyError` if the parent node does not exist
1739
+ *
1740
+ * @example
1741
+ * ```typescript
1742
+ * const children = BigUint64Array.from([child1, child2, child3]);
1743
+ * tree.setChildren(parentId, children);
1744
+ * ```
1745
+ * @param {bigint} parent
1746
+ * @param {BigUint64Array} children
1747
+ */
1748
+ setChildren(parent, children) {
1749
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1750
+ const len0 = WASM_VECTOR_LEN;
1751
+ const ret = wasm.taffytree_setChildren(this.__wbg_ptr, parent, ptr0, len0);
1752
+ if (ret[1]) {
1753
+ throw takeFromExternrefTable0(ret[0]);
1754
+ }
1755
+ }
1756
+ /**
1757
+ * Creates a new TaffyTree with pre-allocated capacity
1758
+ *
1759
+ * Use this when you know approximately how many nodes will be in the tree.
1760
+ * This can improve performance by reducing memory reallocations.
1761
+ *
1762
+ * @param capacity - The number of nodes to pre-allocate space for
1763
+ *
1764
+ * @example
1765
+ * ```typescript
1766
+ * const tree: TaffyTree = TaffyTree.withCapacity(1000);
1767
+ * ```
1768
+ * @param {number} capacity
1769
+ * @returns {TaffyTree}
1770
+ */
1771
+ static withCapacity(capacity) {
1772
+ const ret = wasm.taffytree_withCapacity(capacity);
1773
+ return TaffyTree.__wrap(ret);
1774
+ }
1775
+ /**
1776
+ * Computes the layout for a subtree
1777
+ *
1778
+ * This is the main layout computation method. Call this on the root node
1779
+ * to compute layouts for all nodes in the tree.
1780
+ *
1781
+ * @param node - The root node ID to compute layout for
1782
+ * @param available_space - The available space constraints
1783
+ *
1784
+ * @example
1785
+ * ```typescript
1786
+ * // Fixed size container
1787
+ * { width: 800, height: 600 }
1788
+ *
1789
+ * // Flexible width, fixed height
1790
+ * { width: "MaxContent", height: 600 }
1791
+ *
1792
+ * // Minimum content size
1793
+ * { width: "MinContent", height: "MinContent" }
1794
+ * ```
1795
+ *
1796
+ * @throws `TaffyError` if the node does not exist or available space is invalid
1797
+ *
1798
+ * @example
1799
+ * ```typescript
1800
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
1801
+ * ```
1802
+ * @param {bigint} node
1803
+ * @param {Size<AvailableSpace>} available_space
1804
+ */
1805
+ computeLayout(node, available_space) {
1806
+ const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, available_space);
1807
+ if (ret[1]) {
1808
+ throw takeFromExternrefTable0(ret[0]);
1809
+ }
1810
+ }
1811
+ /**
1812
+ * Enables rounding of layout values to whole pixels
1813
+ *
1814
+ * When enabled (default), computed layout values like position and size
1815
+ * are rounded to the nearest integer. This prevents sub-pixel rendering
1816
+ * issues in most rendering contexts.
1817
+ *
1818
+ * @example
1819
+ * ```typescript
1820
+ * tree.enableRounding();
1821
+ * ```
1822
+ */
1823
+ enableRounding() {
1824
+ wasm.taffytree_enableRounding(this.__wbg_ptr);
1825
+ }
1826
+ /**
1827
+ * Disables rounding of layout values
1828
+ *
1829
+ * When disabled, computed layout values retain their fractional precision.
1830
+ * Use this when you need sub-pixel accuracy or when performing custom
1831
+ * rounding.
1832
+ *
1833
+ * @example
1834
+ * ```typescript
1835
+ * tree.disableRounding();
1836
+ * const layout = tree.getLayout(node);
1837
+ * console.log(layout.x);
1838
+ * ```
1839
+ */
1840
+ disableRounding() {
1841
+ wasm.taffytree_disableRounding(this.__wbg_ptr);
1842
+ }
1843
+ /**
1844
+ * Gets the context value for a node
1845
+ *
1846
+ * @param node - The node ID
1847
+ *
1848
+ * @returns - The attached context value, or `undefined` if none is set
1849
+ *
1850
+ * @example
1851
+ * ```typescript
1852
+ * interface Context { text: string };
1853
+ * const context = tree.getNodeContext(nodeId) as Context | undefined;
1854
+ * if (context) {
1855
+ * console.log(context.text);
1856
+ * }
1857
+ * ```
1858
+ * @param {bigint} node
1859
+ * @returns {any}
1860
+ */
1861
+ getNodeContext(node) {
1862
+ const ret = wasm.taffytree_getNodeContext(this.__wbg_ptr, node);
1863
+ if (ret[2]) {
1864
+ throw takeFromExternrefTable0(ret[1]);
1865
+ }
1866
+ return takeFromExternrefTable0(ret[0]);
1867
+ }
1868
+ /**
1869
+ * Sets a context value for a node
1870
+ *
1871
+ * The context can be any JavaScript value and is passed to the measure
1872
+ * function during layout computation.
1873
+ *
1874
+ * @param node - The node ID
1875
+ * @param context - Any JavaScript value to attach
1876
+ *
1877
+ * @throws `TaffyError` if the node does not exist
1878
+ *
1879
+ * @example
1880
+ * ```typescript
1881
+ * interface Context { text: string };
1882
+ * tree.setNodeContext(nodeId, { text: "Updated text" } as Context);
1883
+ * ```
1884
+ * @param {bigint} node
1885
+ * @param {any} context
1886
+ */
1887
+ setNodeContext(node, context) {
1888
+ const ret = wasm.taffytree_setNodeContext(this.__wbg_ptr, node, context);
1889
+ if (ret[1]) {
1890
+ throw takeFromExternrefTable0(ret[0]);
1891
+ }
1892
+ }
1893
+ /**
1894
+ * Gets the total number of nodes in the tree
1895
+ *
1896
+ * @returns - The total count of all nodes
1897
+ *
1898
+ * @example
1899
+ * ```typescript
1900
+ * const count: number = tree.totalNodeCount();
1901
+ * ```
1902
+ * @returns {number}
1903
+ */
1904
+ totalNodeCount() {
1905
+ const ret = wasm.taffytree_totalNodeCount(this.__wbg_ptr);
1906
+ return ret >>> 0;
1907
+ }
1908
+ /**
1909
+ * Gets the unrounded (fractional) layout for a node
1910
+ *
1911
+ * Returns the raw computed values before any rounding is applied.
1912
+ * Useful when you need sub-pixel precision.
1913
+ *
1914
+ * @param node - The node ID
1915
+ *
1916
+ * @returns - The unrounded `Layout`
1917
+ *
1918
+ * @example
1919
+ * ```typescript
1920
+ * const layout: Layout = tree.unroundedLayout(nodeId);
1921
+ * console.log(`Exact width: ${layout.width}`);
1922
+ * ```
1923
+ * @param {bigint} node
1924
+ * @returns {Layout}
1925
+ */
1926
+ unroundedLayout(node) {
1927
+ const ret = wasm.taffytree_unroundedLayout(this.__wbg_ptr, node);
1928
+ return Layout.__wrap(ret);
1929
+ }
1930
+ /**
1931
+ * Creates a new node with the given children
1932
+ *
1933
+ * Use this to create container nodes that have child elements.
1934
+ * The children must already exist in the tree.
1935
+ *
1936
+ * @param style - The style configuration for the node
1937
+ * @param children - Array of child node IDs (as BigUint64Array)
1938
+ *
1939
+ * @returns - The node ID (`bigint`)
1940
+ *
1941
+ * @throws `TaffyError` if the node cannot be created
1942
+ *
1943
+ * @example
1944
+ * ```typescript
1945
+ * const containerStyle = new Style();
1946
+ * containerStyle.display = Display.Flex;
1947
+ *
1948
+ * const child1: bigint = tree.newLeaf(new Style());
1949
+ * const child2: bigint = tree.newLeaf(new Style());
1950
+ *
1951
+ * const container: bigint = tree.newWithChildren(
1952
+ * containerStyle,
1953
+ * BigUint64Array.from([child1, child2])
1954
+ * );
1955
+ * ```
1956
+ * @param {Style} style
1957
+ * @param {BigUint64Array} children
1958
+ * @returns {bigint}
1959
+ */
1960
+ newWithChildren(style, children) {
1961
+ _assertClass(style, Style);
1962
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1963
+ const len0 = WASM_VECTOR_LEN;
1964
+ const ret = wasm.taffytree_newWithChildren(this.__wbg_ptr, style.__wbg_ptr, ptr0, len0);
1965
+ if (ret[2]) {
1966
+ throw takeFromExternrefTable0(ret[1]);
1967
+ }
1968
+ return BigInt.asUintN(64, ret[0]);
1969
+ }
1970
+ /**
1971
+ * Gets the child at a specific index
1972
+ *
1973
+ * @param parent - The parent node ID
1974
+ * @param index - The index of the child (0-based)
1975
+ *
1976
+ * @returns - The child node ID (`bigint`)
1977
+ *
1978
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
1979
+ *
1980
+ * @example
1981
+ * ```typescript
1982
+ * const firstChild: bigint = tree.getChildAtIndex(parentId, 0);
1983
+ * ```
1984
+ * @param {bigint} parent
1985
+ * @param {number} index
1986
+ * @returns {bigint}
1987
+ */
1988
+ getChildAtIndex(parent, index) {
1989
+ const ret = wasm.taffytree_getChildAtIndex(this.__wbg_ptr, parent, index);
1990
+ if (ret[2]) {
1991
+ throw takeFromExternrefTable0(ret[1]);
1992
+ }
1993
+ return BigInt.asUintN(64, ret[0]);
1994
+ }
1995
+ /**
1996
+ * Gets a mutable reference to the context value for a node
1997
+ *
1998
+ * In JavaScript, this behaves the same as `getNodeContext()` since
1999
+ * JavaScript objects are always passed by reference.
2000
+ *
2001
+ * @param node - The node ID
2002
+ *
2003
+ * @returns - The attached context value, or `undefined` if none is set
2004
+ * @param {bigint} node
2005
+ * @returns {any}
2006
+ */
2007
+ getNodeContextMut(node) {
2008
+ const ret = wasm.taffytree_getNodeContextMut(this.__wbg_ptr, node);
2009
+ if (ret[2]) {
2010
+ throw takeFromExternrefTable0(ret[1]);
2011
+ }
2012
+ return takeFromExternrefTable0(ret[0]);
2013
+ }
2014
+ /**
2015
+ * Inserts a child at a specific index
2016
+ *
2017
+ * @param parent - The parent node ID
2018
+ * @param index - The position to insert at (0-based)
2019
+ * @param child - The child node ID to insert
2020
+ *
2021
+ * @throws `TaffyError` if the parent or child node does not exist, or index is out of bounds
2022
+ *
2023
+ * @example
2024
+ * ```typescript
2025
+ * tree.insertChildAtIndex(parentId, 0, childId);
2026
+ * ```
2027
+ * @param {bigint} parent
2028
+ * @param {number} index
2029
+ * @param {bigint} child
2030
+ */
2031
+ insertChildAtIndex(parent, index, child) {
2032
+ const ret = wasm.taffytree_insertChildAtIndex(this.__wbg_ptr, parent, index, child);
2033
+ if (ret[1]) {
2034
+ throw takeFromExternrefTable0(ret[0]);
2035
+ }
2036
+ }
2037
+ /**
2038
+ * Creates a new leaf node with an attached context value
2039
+ *
2040
+ * The context can be any JavaScript value and is passed to the measure
2041
+ * function during layout computation. This is useful for storing
2042
+ * references to text content or other dynamic data.
2043
+ *
2044
+ * @param style - The style configuration for the node
2045
+ * @param context - Any JavaScript value to attach to the node
2046
+ * @returns - The node ID (`bigint`)
2047
+ * @throws `TaffyError` if the node cannot be created
2048
+ *
2049
+ * @example
2050
+ * ```typescript
2051
+ * interface TextContext { text: string; isBold: boolean; }
2052
+ *
2053
+ * const style = new Style();
2054
+ * const context: TextContext = { text: "Hello, World!", isBold: true };
2055
+ * const nodeId: bigint = tree.newLeafWithContext(style, context);
2056
+ * ```
2057
+ * @param {Style} style
2058
+ * @param {any} context
2059
+ * @returns {bigint}
2060
+ */
2061
+ newLeafWithContext(style, context) {
2062
+ _assertClass(style, Style);
2063
+ const ret = wasm.taffytree_newLeafWithContext(this.__wbg_ptr, style.__wbg_ptr, context);
2064
+ if (ret[2]) {
2065
+ throw takeFromExternrefTable0(ret[1]);
2066
+ }
2067
+ return BigInt.asUintN(64, ret[0]);
2068
+ }
2069
+ /**
2070
+ * Removes a child at a specific index
2071
+ *
2072
+ * @param parent - The parent node ID
2073
+ * @param index - The index of the child to remove (0-based)
2074
+ *
2075
+ * @returns - The removed child ID (`bigint`)
2076
+ *
2077
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2078
+ *
2079
+ * @example
2080
+ * ```typescript
2081
+ * const removedId: bigint = tree.removeChildAtIndex(parentId, 0);
2082
+ * ```
2083
+ * @param {bigint} parent
2084
+ * @param {number} index
2085
+ * @returns {bigint}
2086
+ */
2087
+ removeChildAtIndex(parent, index) {
2088
+ const ret = wasm.taffytree_removeChildAtIndex(this.__wbg_ptr, parent, index);
2089
+ if (ret[2]) {
2090
+ throw takeFromExternrefTable0(ret[1]);
2091
+ }
2092
+ return BigInt.asUintN(64, ret[0]);
2093
+ }
2094
+ /**
2095
+ * Removes a range of children
2096
+ *
2097
+ * Removes children from `start_index` (inclusive) to `end_index` (exclusive).
2098
+ *
2099
+ * @param parent - The parent node ID
2100
+ * @param start_index - Start of range (inclusive)
2101
+ * @param end_index - End of range (exclusive)
2102
+ *
2103
+ * @throws `TaffyError` if the parent node does not exist or range is invalid
2104
+ *
2105
+ * @example
2106
+ * ```typescript
2107
+ * tree.removeChildrenRange(parentId, 1, 3);
2108
+ * ```
2109
+ * @param {bigint} parent
2110
+ * @param {number} start_index
2111
+ * @param {number} end_index
2112
+ */
2113
+ removeChildrenRange(parent, start_index, end_index) {
2114
+ const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, start_index, end_index);
2115
+ if (ret[1]) {
2116
+ throw takeFromExternrefTable0(ret[0]);
2117
+ }
2118
+ }
2119
+ /**
2120
+ * Replaces a child at a specific index
2121
+ *
2122
+ * @param parent - The parent node ID
2123
+ * @param index - The index of the child to replace (0-based)
2124
+ * @param new_child - The new child node ID
2125
+ *
2126
+ * @returns - The replaced (old) child ID (`bigint`)
2127
+ *
2128
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2129
+ *
2130
+ * @example
2131
+ * ```typescript
2132
+ * const oldChildId: bigint = tree.replaceChildAtIndex(parentId, 1, newChildId);
2133
+ * ```
2134
+ * @param {bigint} parent
2135
+ * @param {number} index
2136
+ * @param {bigint} new_child
2137
+ * @returns {bigint}
2138
+ */
2139
+ replaceChildAtIndex(parent, index, new_child) {
2140
+ const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, new_child);
2141
+ if (ret[2]) {
2142
+ throw takeFromExternrefTable0(ret[1]);
2143
+ }
2144
+ return BigInt.asUintN(64, ret[0]);
2145
+ }
2146
+ /**
2147
+ * Computes layout with a custom measure function for leaf nodes
2148
+ *
2149
+ * Use this when you have leaf nodes with dynamic content (like text)
2150
+ * that needs to be measured during layout. The measure function is
2151
+ * called for each leaf node that needs measurement.
2152
+ *
2153
+ * @param node - The root node ID to compute layout for
2154
+ * @param available_space - The available space constraints
2155
+ * @param measure_func - A function that measures leaf node content
2156
+ *
2157
+ * @throws `TaffyError` if the node does not exist or available space is invalid
2158
+ *
2159
+ * @example
2160
+ * ```typescript
2161
+ * tree.computeLayoutWithMeasure(
2162
+ * rootId,
2163
+ * { width: 800, height: "MaxContent" },
2164
+ * (known, available, node, context, style) => {
2165
+ * if (context?.text) {
2166
+ * const measured = measureText(context.text, available.width);
2167
+ * return { width: measured.width, height: measured.height };
2168
+ * }
2169
+ * return { width: 0, height: 0 };
2170
+ * }
2171
+ * );
2172
+ * ```
2173
+ * @param {bigint} node
2174
+ * @param {Size<AvailableSpace>} available_space
2175
+ * @param {MeasureFunction} measure_func
2176
+ */
2177
+ computeLayoutWithMeasure(node, available_space, measure_func) {
2178
+ const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, available_space, measure_func);
2179
+ if (ret[1]) {
2180
+ throw takeFromExternrefTable0(ret[0]);
2181
+ }
2182
+ }
2183
+ /**
2184
+ * Gets context values for multiple nodes at once
2185
+ *
2186
+ * This is more efficient than calling `getNodeContext()` multiple times
2187
+ * when you need to access contexts for many nodes.
2188
+ *
2189
+ * @param children - Array of node IDs
2190
+ *
2191
+ * @returns - Array of context values (undefined for nodes without context)
2192
+ *
2193
+ * @example
2194
+ * ```typescript
2195
+ * const nodes = BigUint64Array.from([id1, id2]);
2196
+ * const contexts = tree.getDisjointNodeContextMut(nodes);
2197
+ * ```
2198
+ * @param {BigUint64Array} children
2199
+ * @returns {any[]}
2200
+ */
2201
+ getDisjointNodeContextMut(children) {
2202
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2203
+ const len0 = WASM_VECTOR_LEN;
2204
+ const ret = wasm.taffytree_getDisjointNodeContextMut(this.__wbg_ptr, ptr0, len0);
2205
+ if (ret[3]) {
2206
+ throw takeFromExternrefTable0(ret[2]);
2207
+ }
2208
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
2209
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2210
+ return v2;
2211
+ }
2212
+ /**
2213
+ * Creates a new empty TaffyTree
2214
+ *
2215
+ * The tree starts with no nodes. Use `newLeaf()` or `newWithChildren()`
2216
+ * to add nodes.
2217
+ *
2218
+ * @example
2219
+ * ```typescript
2220
+ * const tree: TaffyTree = new TaffyTree();
2221
+ * ```
2222
+ */
2223
+ constructor() {
2224
+ const ret = wasm.taffytree_new();
2225
+ this.__wbg_ptr = ret >>> 0;
2226
+ TaffyTreeFinalization.register(this, this.__wbg_ptr, this);
2227
+ return this;
2228
+ }
2229
+ /**
2230
+ * Removes all nodes from the tree
2231
+ *
2232
+ * This clears the entire tree, removing all nodes and their relationships.
2233
+ * Use this to reset the tree for reuse.
2234
+ *
2235
+ * @example
2236
+ * ```typescript
2237
+ * tree.clear();
2238
+ * console.log(tree.totalNodeCount());
2239
+ * ```
2240
+ */
2241
+ clear() {
2242
+ wasm.taffytree_clear(this.__wbg_ptr);
2243
+ }
2244
+ /**
2245
+ * Checks if a node is dirty (needs re-layout)
2246
+ *
2247
+ * A node is dirty if its style or content has changed since the last
2248
+ * layout computation.
2249
+ *
2250
+ * @param node - The node ID to check
2251
+ *
2252
+ * @returns - true if dirty, false otherwise
2253
+ *
2254
+ * @throws `TaffyError` if the node does not exist
2255
+ *
2256
+ * @example
2257
+ * ```typescript
2258
+ * if (tree.dirty(nodeId)) {
2259
+ * tree.computeLayout(rootId, availableSpace);
2260
+ * }
2261
+ * ```
2262
+ * @param {bigint} node
2263
+ * @returns {boolean}
2264
+ */
2265
+ dirty(node) {
2266
+ const ret = wasm.taffytree_dirty(this.__wbg_ptr, node);
2267
+ if (ret[2]) {
2268
+ throw takeFromExternrefTable0(ret[1]);
2269
+ }
2270
+ return ret[0] !== 0;
2271
+ }
2272
+ /**
2273
+ * Gets the style for a node
2274
+ *
2275
+ * @param node - The node ID
2276
+ *
2277
+ * @returns - The node's `Style`
2278
+ *
2279
+ * @throws `TaffyError` if the node does not exist
2280
+ *
2281
+ * @example
2282
+ * ```typescript
2283
+ * const style: Style = tree.getStyle(nodeId);
2284
+ * console.log('Flex grow:', style.flexGrow);
2285
+ * ```
2286
+ * @param {bigint} node
2287
+ * @returns {Style}
2288
+ */
2289
+ getStyle(node) {
2290
+ const ret = wasm.taffytree_getStyle(this.__wbg_ptr, node);
2291
+ if (ret[2]) {
2292
+ throw takeFromExternrefTable0(ret[1]);
2293
+ }
2294
+ return Style.__wrap(ret[0]);
2295
+ }
2296
+ /**
2297
+ * Gets the computed layout for a node
2298
+ *
2299
+ * Call this after `computeLayout()` to retrieve the computed position
2300
+ * and size for a node.
2301
+ *
2302
+ * @param node - The node ID
2303
+ *
2304
+ * @returns - The computed `Layout`
2305
+ *
2306
+ * @throws `TaffyError` if the node does not exist
2307
+ *
2308
+ * @example
2309
+ * ```typescript
2310
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
2311
+ * const layout: Layout = tree.getLayout(nodeId);
2312
+ * console.log(`Position: (${layout.x}, ${layout.y}), Size: ${layout.width}x${layout.height}`);
2313
+ * ```
2314
+ * @param {bigint} node
2315
+ * @returns {Layout}
2316
+ */
2317
+ getLayout(node) {
2318
+ const ret = wasm.taffytree_getLayout(this.__wbg_ptr, node);
2319
+ if (ret[2]) {
2320
+ throw takeFromExternrefTable0(ret[1]);
2321
+ }
2322
+ return Layout.__wrap(ret[0]);
2323
+ }
2324
+ /**
2325
+ * Gets the parent of a node
2326
+ *
2327
+ * @param child - The child node ID
2328
+ *
2329
+ * @returns - The parent node ID, or `undefined` if the node has no parent
2330
+ *
2331
+ * @example
2332
+ * ```typescript
2333
+ * const parentId: bigint | undefined = tree.parent(childId);
2334
+ * ```
2335
+ * @param {bigint} child
2336
+ * @returns {bigint | undefined}
2337
+ */
2338
+ parent(child) {
2339
+ const ret = wasm.taffytree_parent(this.__wbg_ptr, child);
2340
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
2341
+ }
2342
+ /**
2343
+ * Removes a node from the tree
2344
+ *
2345
+ * The node and all its descendants are removed. If the node has a parent,
2346
+ * it is automatically removed from the parent's children.
2347
+ *
2348
+ * @param node - The node ID to remove
2349
+ *
2350
+ * @returns - The removed node ID (`bigint`)
2351
+ *
2352
+ * @throws `TaffyError` if the node does not exist
2353
+ *
2354
+ * @example
2355
+ * ```typescript
2356
+ * try {
2357
+ * const removedId: bigint = tree.remove(nodeId);
2358
+ * } catch (e) {
2359
+ * console.error("Node doesn't exist");
2360
+ * }
2361
+ * ```
2362
+ * @param {bigint} node
2363
+ * @returns {bigint}
2364
+ */
2365
+ remove(node) {
2366
+ const ret = wasm.taffytree_remove(this.__wbg_ptr, node);
2367
+ if (ret[2]) {
2368
+ throw takeFromExternrefTable0(ret[1]);
2369
+ }
2370
+ return BigInt.asUintN(64, ret[0]);
2371
+ }
2372
+ /**
2373
+ * Gets all children of a node
2374
+ *
2375
+ * @param parent - The parent node ID
2376
+ *
2377
+ * @returns - Array of child node IDs (`BigUint64Array`)
2378
+ *
2379
+ * @throws `TaffyError` if the parent node does not exist
2380
+ *
2381
+ * @example
2382
+ * ```typescript
2383
+ * const children: BigUint64Array = tree.children(parentId);
2384
+ * ```
2385
+ * @param {bigint} parent
2386
+ * @returns {BigUint64Array}
2387
+ */
2388
+ children(parent) {
2389
+ const ret = wasm.taffytree_children(this.__wbg_ptr, parent);
2390
+ if (ret[3]) {
2391
+ throw takeFromExternrefTable0(ret[2]);
2392
+ }
2393
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
2394
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2395
+ return v1;
2396
+ }
2397
+ /**
2398
+ * Creates a new leaf node with the given style
2399
+ *
2400
+ * A leaf node has no children. Use this for elements that contain
2401
+ * content (like text) rather than other elements.
2402
+ *
2403
+ * @param style - The style configuration for the node
2404
+ * @returns - The node ID (`bigint`)
2405
+ * @throws `TaffyError` if the node cannot be created
2406
+ *
2407
+ * @example
2408
+ * ```typescript
2409
+ * const style = new Style();
2410
+ * style.size = { width: 100, height: 50 };
2411
+ * const nodeId: bigint = tree.newLeaf(style);
2412
+ * ```
2413
+ * @param {Style} style
2414
+ * @returns {bigint}
2415
+ */
2416
+ newLeaf(style) {
2417
+ _assertClass(style, Style);
2418
+ const ret = wasm.taffytree_newLeaf(this.__wbg_ptr, style.__wbg_ptr);
2419
+ if (ret[2]) {
2420
+ throw takeFromExternrefTable0(ret[1]);
2421
+ }
2422
+ return BigInt.asUintN(64, ret[0]);
2423
+ }
2424
+ /**
2425
+ * Appends a child node to a parent
2426
+ *
2427
+ * The child is added as the last child of the parent.
2428
+ *
2429
+ * @param parent - The parent node ID
2430
+ * @param child - The child node ID to add
2431
+ *
2432
+ * @throws `TaffyError` if the parent or child node does not exist
2433
+ *
2434
+ * @example
2435
+ * ```typescript
2436
+ * tree.addChild(parentId, childId);
2437
+ * ```
2438
+ * @param {bigint} parent
2439
+ * @param {bigint} child
2440
+ */
2441
+ addChild(parent, child) {
2442
+ const ret = wasm.taffytree_addChild(this.__wbg_ptr, parent, child);
2443
+ if (ret[1]) {
2444
+ throw takeFromExternrefTable0(ret[0]);
2445
+ }
2446
+ }
2447
+ /**
2448
+ * Sets the style for an existing node
2449
+ *
2450
+ * This replaces the node's current style with the provided one.
2451
+ * The node will be marked as dirty and require re-layout.
2452
+ *
2453
+ * @param node - The node ID
2454
+ * @param style - The new style configuration
2455
+ *
2456
+ * @throws `TaffyError` if the node does not exist
2457
+ *
2458
+ * @example
2459
+ * ```typescript
2460
+ * const newStyle = new Style();
2461
+ * newStyle.flexGrow = 2;
2462
+ * tree.setStyle(nodeId, newStyle);
2463
+ * ```
2464
+ * @param {bigint} node
2465
+ * @param {Style} style
2466
+ */
2467
+ setStyle(node, style) {
2468
+ _assertClass(style, Style);
2469
+ const ret = wasm.taffytree_setStyle(this.__wbg_ptr, node, style.__wbg_ptr);
2470
+ if (ret[1]) {
2471
+ throw takeFromExternrefTable0(ret[0]);
2472
+ }
2473
+ }
2474
+ }
2475
+ if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
2476
+
2477
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
2478
+
2479
+ async function __wbg_load(module, imports) {
2480
+ if (typeof Response === 'function' && module instanceof Response) {
2481
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2482
+ try {
2483
+ return await WebAssembly.instantiateStreaming(module, imports);
2484
+ } catch (e) {
2485
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
2486
+
2487
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2488
+ 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);
2489
+
2490
+ } else {
2491
+ throw e;
2492
+ }
2493
+ }
2494
+ }
2495
+
2496
+ const bytes = await module.arrayBuffer();
2497
+ return await WebAssembly.instantiate(bytes, imports);
2498
+ } else {
2499
+ const instance = await WebAssembly.instantiate(module, imports);
2500
+
2501
+ if (instance instanceof WebAssembly.Instance) {
2502
+ return { instance, module };
2503
+ } else {
2504
+ return instance;
2505
+ }
2506
+ }
2507
+ }
2508
+
2509
+ function __wbg_get_imports() {
2510
+ const imports = {};
2511
+ imports.wbg = {};
2512
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
2513
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2514
+ return ret;
2515
+ };
2516
+ imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
2517
+ const ret = Number(arg0);
2518
+ return ret;
2519
+ };
2520
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
2521
+ const ret = String(arg1);
2522
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2523
+ const len1 = WASM_VECTOR_LEN;
2524
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2525
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2526
+ };
2527
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
2528
+ const v = arg1;
2529
+ const ret = typeof(v) === 'bigint' ? v : undefined;
2530
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2531
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2532
+ };
2533
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
2534
+ const v = arg0;
2535
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2536
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2537
+ };
2538
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
2539
+ const ret = debugString(arg1);
2540
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2541
+ const len1 = WASM_VECTOR_LEN;
2542
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2543
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2544
+ };
2545
+ imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
2546
+ const ret = arg0 in arg1;
2547
+ return ret;
2548
+ };
2549
+ imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
2550
+ const ret = typeof(arg0) === 'bigint';
2551
+ return ret;
2552
+ };
2553
+ imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
2554
+ const ret = typeof(arg0) === 'function';
2555
+ return ret;
2556
+ };
2557
+ imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
2558
+ const ret = arg0 === null;
2559
+ return ret;
2560
+ };
2561
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
2562
+ const val = arg0;
2563
+ const ret = typeof(val) === 'object' && val !== null;
2564
+ return ret;
2565
+ };
2566
+ imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
2567
+ const ret = typeof(arg0) === 'string';
2568
+ return ret;
2569
+ };
2570
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
2571
+ const ret = arg0 === undefined;
2572
+ return ret;
2573
+ };
2574
+ imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
2575
+ const ret = arg0 === arg1;
2576
+ return ret;
2577
+ };
2578
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
2579
+ const ret = arg0 == arg1;
2580
+ return ret;
2581
+ };
2582
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
2583
+ const obj = arg1;
2584
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2585
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2586
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2587
+ };
2588
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
2589
+ const obj = arg1;
2590
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2591
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2592
+ var len1 = WASM_VECTOR_LEN;
2593
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2594
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2595
+ };
2596
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
2597
+ throw new Error(getStringFromWasm0(arg0, arg1));
2598
+ };
2599
+ imports.wbg.__wbg_apply_52e9ae668d017009 = function() { return handleError(function (arg0, arg1, arg2) {
2600
+ const ret = arg0.apply(arg1, arg2);
2601
+ return ret;
2602
+ }, arguments) };
2603
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
2604
+ const ret = arg0.call(arg1);
2605
+ return ret;
2606
+ }, arguments) };
2607
+ imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
2608
+ const ret = Object.entries(arg0);
2609
+ return ret;
2610
+ };
2611
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
2612
+ let deferred0_0;
2613
+ let deferred0_1;
2614
+ try {
2615
+ deferred0_0 = arg0;
2616
+ deferred0_1 = arg1;
2617
+ console.error(getStringFromWasm0(arg0, arg1));
2618
+ } finally {
2619
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2620
+ }
2621
+ };
2622
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
2623
+ const ret = arg0[arg1 >>> 0];
2624
+ return ret;
2625
+ };
2626
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
2627
+ const ret = Reflect.get(arg0, arg1);
2628
+ return ret;
2629
+ }, arguments) };
2630
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
2631
+ const ret = arg0[arg1];
2632
+ return ret;
2633
+ };
2634
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
2635
+ let result;
2636
+ try {
2637
+ result = arg0 instanceof ArrayBuffer;
2638
+ } catch (_) {
2639
+ result = false;
2640
+ }
2641
+ const ret = result;
2642
+ return ret;
2643
+ };
2644
+ imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
2645
+ let result;
2646
+ try {
2647
+ result = arg0 instanceof Map;
2648
+ } catch (_) {
2649
+ result = false;
2650
+ }
2651
+ const ret = result;
2652
+ return ret;
2653
+ };
2654
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
2655
+ let result;
2656
+ try {
2657
+ result = arg0 instanceof Uint8Array;
2658
+ } catch (_) {
2659
+ result = false;
2660
+ }
2661
+ const ret = result;
2662
+ return ret;
2663
+ };
2664
+ imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
2665
+ const ret = Array.isArray(arg0);
2666
+ return ret;
2667
+ };
2668
+ imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
2669
+ const ret = Number.isSafeInteger(arg0);
2670
+ return ret;
2671
+ };
2672
+ imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
2673
+ const ret = Symbol.iterator;
2674
+ return ret;
2675
+ };
2676
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
2677
+ const ret = arg0.length;
2678
+ return ret;
2679
+ };
2680
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
2681
+ const ret = arg0.length;
2682
+ return ret;
2683
+ };
2684
+ imports.wbg.__wbg_log_274c70cbdd825a00 = function(arg0, arg1) {
2685
+ console.log(getStringFromWasm0(arg0, arg1));
2686
+ };
2687
+ imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
2688
+ const ret = new Object();
2689
+ return ret;
2690
+ };
2691
+ imports.wbg.__wbg_new_25f239778d6112b9 = function() {
2692
+ const ret = new Array();
2693
+ return ret;
2694
+ };
2695
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
2696
+ const ret = new Uint8Array(arg0);
2697
+ return ret;
2698
+ };
2699
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
2700
+ const ret = new Error();
2701
+ return ret;
2702
+ };
2703
+ imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
2704
+ const ret = arg0.next;
2705
+ return ret;
2706
+ };
2707
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
2708
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
2709
+ };
2710
+ imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
2711
+ const ret = arg0.push(arg1);
2712
+ return ret;
2713
+ };
2714
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
2715
+ arg0[arg1] = arg2;
2716
+ };
2717
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
2718
+ const ret = arg1.stack;
2719
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2720
+ const len1 = WASM_VECTOR_LEN;
2721
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2722
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2723
+ };
2724
+ imports.wbg.__wbg_stringify_655a6390e1f5eb6b = function() { return handleError(function (arg0) {
2725
+ const ret = JSON.stringify(arg0);
2726
+ return ret;
2727
+ }, arguments) };
2728
+ imports.wbg.__wbg_style_new = function(arg0) {
2729
+ const ret = Style.__wrap(arg0);
2730
+ return ret;
2731
+ };
2732
+ imports.wbg.__wbg_taffyerror_new = function(arg0) {
2733
+ const ret = TaffyError.__wrap(arg0);
2734
+ return ret;
2735
+ };
2736
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
2737
+ // Cast intrinsic for `Ref(String) -> Externref`.
2738
+ const ret = getStringFromWasm0(arg0, arg1);
2739
+ return ret;
2740
+ };
2741
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
2742
+ // Cast intrinsic for `U64 -> Externref`.
2743
+ const ret = BigInt.asUintN(64, arg0);
2744
+ return ret;
2745
+ };
2746
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
2747
+ // Cast intrinsic for `I64 -> Externref`.
2748
+ const ret = arg0;
2749
+ return ret;
2750
+ };
2751
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
2752
+ // Cast intrinsic for `F64 -> Externref`.
2753
+ const ret = arg0;
2754
+ return ret;
2755
+ };
2756
+ imports.wbg.__wbindgen_init_externref_table = function() {
2757
+ const table = wasm.__wbindgen_externrefs;
2758
+ const offset = table.grow(4);
2759
+ table.set(0, undefined);
2760
+ table.set(offset + 0, undefined);
2761
+ table.set(offset + 1, null);
2762
+ table.set(offset + 2, true);
2763
+ table.set(offset + 3, false);
2764
+ };
2765
+
2766
+ return imports;
2767
+ }
2768
+
2769
+ function __wbg_finalize_init(instance, module) {
2770
+ wasm = instance.exports;
2771
+ __wbg_init.__wbindgen_wasm_module = module;
2772
+ cachedBigUint64ArrayMemory0 = null;
2773
+ cachedDataViewMemory0 = null;
2774
+ cachedUint8ArrayMemory0 = null;
2775
+
2776
+
2777
+ wasm.__wbindgen_start();
2778
+ return wasm;
2779
+ }
2780
+
2781
+ function initSync(module) {
2782
+ if (wasm !== undefined) return wasm;
2783
+
2784
+
2785
+ if (typeof module !== 'undefined') {
2786
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2787
+ ({module} = module)
2788
+ } else {
2789
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2790
+ }
2791
+ }
2792
+
2793
+ const imports = __wbg_get_imports();
2794
+ if (!(module instanceof WebAssembly.Module)) {
2795
+ module = new WebAssembly.Module(module);
2796
+ }
2797
+ const instance = new WebAssembly.Instance(module, imports);
2798
+ return __wbg_finalize_init(instance, module);
2799
+ }
2800
+
2801
+ async function __wbg_init(module_or_path) {
2802
+ if (wasm !== undefined) return wasm;
2803
+
2804
+
2805
+ if (typeof module_or_path !== 'undefined') {
2806
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2807
+ ({module_or_path} = module_or_path)
2808
+ } else {
2809
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2810
+ }
2811
+ }
2812
+
2813
+ if (typeof module_or_path === 'undefined') {
2814
+ module_or_path = new URL('taffy_wasm_bg.wasm', import.meta.url);
2815
+ }
2816
+ const imports = __wbg_get_imports();
2817
+
2818
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2819
+ module_or_path = fetch(module_or_path);
2820
+ }
2821
+
2822
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2823
+
2824
+ return __wbg_finalize_init(instance, module);
2825
+ }
2826
+
2827
+ export { initSync };
2828
+ export default __wbg_init;