taffy-layout 0.1.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,3504 @@
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 { Style, AlignContent, FlexWrap } from 'taffy-layout';
249
+ *
250
+ * const style = new Style();
251
+ * style.flexWrap = FlexWrap.Wrap;
252
+ * style.alignContent = AlignContent.SpaceBetween; // Distribute lines evenly
253
+ * ```
254
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
255
+ */
256
+ export const AlignContent = Object.freeze({
257
+ /**
258
+ * Lines packed toward the start of the cross axis
259
+ */
260
+ Start: 0, "0": "Start",
261
+ /**
262
+ * Lines packed toward the end of the cross axis
263
+ */
264
+ End: 1, "1": "End",
265
+ /**
266
+ * Lines packed toward the start of the flex container
267
+ */
268
+ FlexStart: 2, "2": "FlexStart",
269
+ /**
270
+ * Lines packed toward the end of the flex container
271
+ */
272
+ FlexEnd: 3, "3": "FlexEnd",
273
+ /**
274
+ * Lines centered within the container
275
+ */
276
+ Center: 4, "4": "Center",
277
+ /**
278
+ * Lines stretched to fill the container
279
+ */
280
+ Stretch: 5, "5": "Stretch",
281
+ /**
282
+ * Lines evenly distributed with first/last at edges
283
+ */
284
+ SpaceBetween: 6, "6": "SpaceBetween",
285
+ /**
286
+ * Lines evenly distributed with equal space around each
287
+ */
288
+ SpaceAround: 7, "7": "SpaceAround",
289
+ /**
290
+ * Lines evenly distributed with equal space between each
291
+ */
292
+ SpaceEvenly: 8, "8": "SpaceEvenly",
293
+ });
294
+
295
+ /**
296
+ * Cross-axis alignment enumeration for all children
297
+ *
298
+ * Defines the default alignment for all flex/grid items along the cross axis.
299
+ * This corresponds to the CSS `align-items` property.
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * import { Style, AlignItems } from 'taffy-layout';
304
+ *
305
+ * const style = new Style();
306
+ * style.alignItems = AlignItems.Center; // Center items on cross axis
307
+ * style.alignItems = AlignItems.Stretch; // Stretch items to fill container
308
+ * ```
309
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
310
+ */
311
+ export const AlignItems = Object.freeze({
312
+ /**
313
+ * Items aligned to the start of the cross axis
314
+ */
315
+ Start: 0, "0": "Start",
316
+ /**
317
+ * Items aligned to the end of the cross axis
318
+ */
319
+ End: 1, "1": "End",
320
+ /**
321
+ * Items aligned to the start of the flex container
322
+ */
323
+ FlexStart: 2, "2": "FlexStart",
324
+ /**
325
+ * Items aligned to the end of the flex container
326
+ */
327
+ FlexEnd: 3, "3": "FlexEnd",
328
+ /**
329
+ * Items centered along the cross axis
330
+ */
331
+ Center: 4, "4": "Center",
332
+ /**
333
+ * Items aligned to their text baselines
334
+ */
335
+ Baseline: 5, "5": "Baseline",
336
+ /**
337
+ * Items stretched to fill the container
338
+ */
339
+ Stretch: 6, "6": "Stretch",
340
+ });
341
+
342
+ /**
343
+ * Cross-axis alignment enumeration for a single element
344
+ *
345
+ * Overrides the parent's `align-items` value for a specific child element.
346
+ * This corresponds to the CSS `align-self` property.
347
+ *
348
+ * @example
349
+ * ```typescript
350
+ * import { Style, AlignSelf } from 'taffy-layout';
351
+ *
352
+ * const style = new Style();
353
+ * style.alignSelf = AlignSelf.Auto; // Use parent's align-items
354
+ * style.alignSelf = AlignSelf.Center; // Override to center this item
355
+ * ```
356
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
357
+ */
358
+ export const AlignSelf = Object.freeze({
359
+ /**
360
+ * Inherits the parent container's `align-items` value
361
+ */
362
+ Auto: 0, "0": "Auto",
363
+ /**
364
+ * Item aligned to the start of the cross axis
365
+ */
366
+ Start: 1, "1": "Start",
367
+ /**
368
+ * Item aligned to the end of the cross axis
369
+ */
370
+ End: 2, "2": "End",
371
+ /**
372
+ * Item aligned to the start of the flex container
373
+ */
374
+ FlexStart: 3, "3": "FlexStart",
375
+ /**
376
+ * Item aligned to the end of the flex container
377
+ */
378
+ FlexEnd: 4, "4": "FlexEnd",
379
+ /**
380
+ * Item centered along the cross axis
381
+ */
382
+ Center: 5, "5": "Center",
383
+ /**
384
+ * Item aligned to its text baseline
385
+ */
386
+ Baseline: 6, "6": "Baseline",
387
+ /**
388
+ * Item stretched to fill the container
389
+ */
390
+ Stretch: 7, "7": "Stretch",
391
+ });
392
+
393
+ /**
394
+ * Box sizing enumeration
395
+ *
396
+ * Controls how the total width and height of an element is calculated.
397
+ * This corresponds to the CSS `box-sizing` property.
398
+ *
399
+ * @example
400
+ * ```typescript
401
+ * import { Style, BoxSizing } from 'taffy-layout';
402
+ *
403
+ * const style = new Style();
404
+ * style.boxSizing = BoxSizing.BorderBox; // Size includes padding and border
405
+ * style.boxSizing = BoxSizing.ContentBox; // Size is content only
406
+ * ```
407
+ * @enum {0 | 1}
408
+ */
409
+ export const BoxSizing = Object.freeze({
410
+ /**
411
+ * The width and height properties include padding and border
412
+ */
413
+ BorderBox: 0, "0": "BorderBox",
414
+ /**
415
+ * The width and height properties include only the content
416
+ */
417
+ ContentBox: 1, "1": "ContentBox",
418
+ });
419
+
420
+ /**
421
+ * Display mode enumeration
422
+ *
423
+ * Controls the layout algorithm type for an element. This corresponds to the CSS `display` property
424
+ * and determines how an element and its children are laid out.
425
+ *
426
+ * @example
427
+ * ```typescript
428
+ * import { Style, Display } from 'taffy-layout';
429
+ *
430
+ * const style = new Style();
431
+ * style.display = Display.Flex; // Enable flexbox layout
432
+ * style.display = Display.Grid; // Enable grid layout
433
+ * style.display = Display.None; // Hide element from layout
434
+ * ```
435
+ * @enum {0 | 1 | 2 | 3}
436
+ */
437
+ export const Display = Object.freeze({
438
+ /**
439
+ * Block-level layout where element takes the full available width
440
+ */
441
+ Block: 0, "0": "Block",
442
+ /**
443
+ * Flexbox layout for one-dimensional item arrangement
444
+ */
445
+ Flex: 1, "1": "Flex",
446
+ /**
447
+ * CSS Grid layout for two-dimensional item arrangement
448
+ */
449
+ Grid: 2, "2": "Grid",
450
+ /**
451
+ * Element is removed from layout calculation entirely
452
+ */
453
+ None: 3, "3": "None",
454
+ });
455
+
456
+ /**
457
+ * Flex direction enumeration
458
+ *
459
+ * Defines the main axis direction for flex item layout. This corresponds to the CSS
460
+ * `flex-direction` property and determines how flex items are placed within the container.
461
+ *
462
+ * @example
463
+ * ```typescript
464
+ * import { Style, FlexDirection } from 'taffy-layout';
465
+ *
466
+ * const style = new Style();
467
+ * style.flexDirection = FlexDirection.Row; // Horizontal, left to right
468
+ * style.flexDirection = FlexDirection.Column; // Vertical, top to bottom
469
+ * ```
470
+ * @enum {0 | 1 | 2 | 3}
471
+ */
472
+ export const FlexDirection = Object.freeze({
473
+ /**
474
+ * Main axis runs horizontally from left to right
475
+ */
476
+ Row: 0, "0": "Row",
477
+ /**
478
+ * Main axis runs vertically from top to bottom
479
+ */
480
+ Column: 1, "1": "Column",
481
+ /**
482
+ * Main axis runs horizontally from right to left
483
+ */
484
+ RowReverse: 2, "2": "RowReverse",
485
+ /**
486
+ * Main axis runs vertically from bottom to top
487
+ */
488
+ ColumnReverse: 3, "3": "ColumnReverse",
489
+ });
490
+
491
+ /**
492
+ * Flex wrap mode enumeration
493
+ *
494
+ * Controls whether flex items wrap onto multiple lines when they overflow the container.
495
+ * This corresponds to the CSS `flex-wrap` property.
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * import { Style, FlexWrap } from 'taffy-layout';
500
+ *
501
+ * const style = new Style();
502
+ * style.flexWrap = FlexWrap.NoWrap; // All items on single line
503
+ * style.flexWrap = FlexWrap.Wrap; // Items wrap to new lines
504
+ * ```
505
+ * @enum {0 | 1 | 2}
506
+ */
507
+ export const FlexWrap = Object.freeze({
508
+ /**
509
+ * All flex items are placed on a single line
510
+ */
511
+ NoWrap: 0, "0": "NoWrap",
512
+ /**
513
+ * Flex items wrap onto multiple lines from top to bottom
514
+ */
515
+ Wrap: 1, "1": "Wrap",
516
+ /**
517
+ * Flex items wrap onto multiple lines from bottom to top
518
+ */
519
+ WrapReverse: 2, "2": "WrapReverse",
520
+ });
521
+
522
+ /**
523
+ * Grid auto flow enumeration
524
+ *
525
+ * Controls whether grid items are placed row-wise or column-wise, and whether
526
+ * the sparse or dense packing algorithm is used.
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * import { Style, GridAutoFlow } from 'taffy-layout';
531
+ *
532
+ * const style = new Style();
533
+ * style.gridAutoFlow = GridAutoFlow.Row; // Fill rows first
534
+ * style.gridAutoFlow = GridAutoFlow.Column; // Fill columns first
535
+ * style.gridAutoFlow = GridAutoFlow.RowDense; // Fill rows, pack densely
536
+ * ```
537
+ * @enum {0 | 1 | 2 | 3}
538
+ */
539
+ export const GridAutoFlow = Object.freeze({
540
+ /**
541
+ * Items are placed by filling each row in turn, adding new rows as necessary
542
+ */
543
+ Row: 0, "0": "Row",
544
+ /**
545
+ * Items are placed by filling each column in turn, adding new columns as necessary
546
+ */
547
+ Column: 1, "1": "Column",
548
+ /**
549
+ * Combines `Row` with the dense packing algorithm
550
+ */
551
+ RowDense: 2, "2": "RowDense",
552
+ /**
553
+ * Combines `Column` with the dense packing algorithm
554
+ */
555
+ ColumnDense: 3, "3": "ColumnDense",
556
+ });
557
+
558
+ /**
559
+ * Main axis alignment enumeration
560
+ *
561
+ * Defines how flex items are aligned and spaced along the main axis.
562
+ * This corresponds to the CSS `justify-content` property.
563
+ *
564
+ * @example
565
+ * ```typescript
566
+ * import { Style, JustifyContent } from 'taffy-layout';
567
+ *
568
+ * const style = new Style();
569
+ * style.justifyContent = JustifyContent.Center; // Center items
570
+ * style.justifyContent = JustifyContent.SpaceBetween; // Distribute evenly
571
+ * ```
572
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
573
+ */
574
+ export const JustifyContent = Object.freeze({
575
+ /**
576
+ * Items packed toward the start of the main axis
577
+ */
578
+ Start: 0, "0": "Start",
579
+ /**
580
+ * Items packed toward the end of the main axis
581
+ */
582
+ End: 1, "1": "End",
583
+ /**
584
+ * Items packed toward the start of the flex container
585
+ */
586
+ FlexStart: 2, "2": "FlexStart",
587
+ /**
588
+ * Items packed toward the end of the flex container
589
+ */
590
+ FlexEnd: 3, "3": "FlexEnd",
591
+ /**
592
+ * Items centered along the main axis
593
+ */
594
+ Center: 4, "4": "Center",
595
+ /**
596
+ * Items stretched along the main axis
597
+ */
598
+ Stretch: 5, "5": "Stretch",
599
+ /**
600
+ * Items evenly distributed with first/last at edges
601
+ */
602
+ SpaceBetween: 6, "6": "SpaceBetween",
603
+ /**
604
+ * Items evenly distributed with equal space around each
605
+ */
606
+ SpaceAround: 7, "7": "SpaceAround",
607
+ /**
608
+ * Items evenly distributed with equal space between each
609
+ */
610
+ SpaceEvenly: 8, "8": "SpaceEvenly",
611
+ });
612
+
613
+ /**
614
+ * Computed layout result containing position, size, and spacing values for a node.
615
+ *
616
+ * This class wraps the native [`taffy::Layout`] and provides read-only access
617
+ * to all computed layout values. All dimensions are in pixels.
618
+ *
619
+ * @example
620
+ * ```typescript
621
+ * const tree = new TaffyTree();
622
+ * const rootId = tree.newLeaf(new Style());
623
+ * const node = rootId;
624
+ *
625
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
626
+ * const layout = tree.getLayout(node);
627
+ *
628
+ * console.log("Position:", layout.x, layout.y);
629
+ * console.log("Size:", layout.width, layout.height);
630
+ * console.log("Content:", layout.contentWidth, layout.contentHeight);
631
+ * console.log("Padding:", layout.paddingTop, layout.paddingRight, layout.paddingBottom, layout.paddingLeft);
632
+ * console.log("Border:", layout.borderTop, layout.borderRight, layout.borderBottom, layout.borderLeft);
633
+ * console.log("Margin:", layout.marginTop, layout.marginRight, layout.marginBottom, layout.marginLeft);
634
+ * console.log("Scrollbar:", layout.scrollbarWidth, layout.scrollbarHeight);
635
+ * console.log("Order:", layout.order);
636
+ * ```
637
+ */
638
+ export class Layout {
639
+ static __wrap(ptr) {
640
+ ptr = ptr >>> 0;
641
+ const obj = Object.create(Layout.prototype);
642
+ obj.__wbg_ptr = ptr;
643
+ LayoutFinalization.register(obj, obj.__wbg_ptr, obj);
644
+ return obj;
645
+ }
646
+ __destroy_into_raw() {
647
+ const ptr = this.__wbg_ptr;
648
+ this.__wbg_ptr = 0;
649
+ LayoutFinalization.unregister(this);
650
+ return ptr;
651
+ }
652
+ free() {
653
+ const ptr = this.__destroy_into_raw();
654
+ wasm.__wbg_layout_free(ptr, 0);
655
+ }
656
+ /**
657
+ * Gets the top border width
658
+ *
659
+ * @returns - The computed top border width in pixels
660
+ * @returns {number}
661
+ */
662
+ get borderTop() {
663
+ const ret = wasm.layout_borderTop(this.__wbg_ptr);
664
+ return ret;
665
+ }
666
+ /**
667
+ * Gets the top margin
668
+ *
669
+ * @returns - The computed top margin in pixels
670
+ * @returns {number}
671
+ */
672
+ get marginTop() {
673
+ const ret = wasm.layout_marginTop(this.__wbg_ptr);
674
+ return ret;
675
+ }
676
+ /**
677
+ * Gets the left border width
678
+ *
679
+ * @returns - The computed left border width in pixels
680
+ * @returns {number}
681
+ */
682
+ get borderLeft() {
683
+ const ret = wasm.layout_borderLeft(this.__wbg_ptr);
684
+ return ret;
685
+ }
686
+ /**
687
+ * Gets the left margin
688
+ *
689
+ * @returns - The computed left margin in pixels
690
+ * @returns {number}
691
+ */
692
+ get marginLeft() {
693
+ const ret = wasm.layout_marginLeft(this.__wbg_ptr);
694
+ return ret;
695
+ }
696
+ /**
697
+ * Gets the top padding
698
+ *
699
+ * @returns - The computed top padding in pixels
700
+ * @returns {number}
701
+ */
702
+ get paddingTop() {
703
+ const ret = wasm.layout_paddingTop(this.__wbg_ptr);
704
+ return ret;
705
+ }
706
+ /**
707
+ * Gets the right border width
708
+ *
709
+ * @returns - The computed right border width in pixels
710
+ * @returns {number}
711
+ */
712
+ get borderRight() {
713
+ const ret = wasm.layout_borderRight(this.__wbg_ptr);
714
+ return ret;
715
+ }
716
+ /**
717
+ * Gets the right margin
718
+ *
719
+ * @returns - The computed right margin in pixels
720
+ * @returns {number}
721
+ */
722
+ get marginRight() {
723
+ const ret = wasm.layout_marginRight(this.__wbg_ptr);
724
+ return ret;
725
+ }
726
+ /**
727
+ * Gets the left padding
728
+ *
729
+ * @returns - The computed left padding in pixels
730
+ * @returns {number}
731
+ */
732
+ get paddingLeft() {
733
+ const ret = wasm.layout_paddingLeft(this.__wbg_ptr);
734
+ return ret;
735
+ }
736
+ /**
737
+ * Gets the bottom border width
738
+ *
739
+ * @returns - The computed bottom border width in pixels
740
+ * @returns {number}
741
+ */
742
+ get borderBottom() {
743
+ const ret = wasm.layout_borderBottom(this.__wbg_ptr);
744
+ return ret;
745
+ }
746
+ /**
747
+ * Gets the width of the scrollable content
748
+ *
749
+ * If the node has overflow content, this represents the total
750
+ * width of all content (may exceed `width`).
751
+ *
752
+ * @returns - The content width in pixels
753
+ * @returns {number}
754
+ */
755
+ get contentWidth() {
756
+ const ret = wasm.layout_contentWidth(this.__wbg_ptr);
757
+ return ret;
758
+ }
759
+ /**
760
+ * Gets the bottom margin
761
+ *
762
+ * @returns - The computed bottom margin in pixels
763
+ * @returns {number}
764
+ */
765
+ get marginBottom() {
766
+ const ret = wasm.layout_marginBottom(this.__wbg_ptr);
767
+ return ret;
768
+ }
769
+ /**
770
+ * Gets the right padding
771
+ *
772
+ * @returns - The computed right padding in pixels
773
+ * @returns {number}
774
+ */
775
+ get paddingRight() {
776
+ const ret = wasm.layout_paddingRight(this.__wbg_ptr);
777
+ return ret;
778
+ }
779
+ /**
780
+ * Gets the height of the scrollable content
781
+ *
782
+ * If the node has overflow content, this represents the total
783
+ * height of all content (may exceed `height`).
784
+ *
785
+ * @returns - The content height in pixels
786
+ * @returns {number}
787
+ */
788
+ get contentHeight() {
789
+ const ret = wasm.layout_contentHeight(this.__wbg_ptr);
790
+ return ret;
791
+ }
792
+ /**
793
+ * Gets the bottom padding
794
+ *
795
+ * @returns - The computed bottom padding in pixels
796
+ * @returns {number}
797
+ */
798
+ get paddingBottom() {
799
+ const ret = wasm.layout_paddingBottom(this.__wbg_ptr);
800
+ return ret;
801
+ }
802
+ /**
803
+ * Gets the width of the vertical scrollbar
804
+ *
805
+ * When overflow is set to scroll, this indicates the space
806
+ * reserved for the vertical scrollbar.
807
+ *
808
+ * @returns - The scrollbar width in pixels (0 if no scrollbar)
809
+ * @returns {number}
810
+ */
811
+ get scrollbarWidth() {
812
+ const ret = wasm.layout_scrollbarWidth(this.__wbg_ptr);
813
+ return ret;
814
+ }
815
+ /**
816
+ * Gets the height of the horizontal scrollbar
817
+ *
818
+ * When overflow is set to scroll, this indicates the space
819
+ * reserved for the horizontal scrollbar.
820
+ *
821
+ * @returns - The scrollbar height in pixels (0 if no scrollbar)
822
+ * @returns {number}
823
+ */
824
+ get scrollbarHeight() {
825
+ const ret = wasm.layout_scrollbarHeight(this.__wbg_ptr);
826
+ return ret;
827
+ }
828
+ /**
829
+ * Gets the X coordinate of the node's top-left corner
830
+ *
831
+ * This value is relative to the node's parent. For the root node,
832
+ * this is always 0.
833
+ *
834
+ * @returns - The horizontal position in pixels
835
+ * @returns {number}
836
+ */
837
+ get x() {
838
+ const ret = wasm.layout_x(this.__wbg_ptr);
839
+ return ret;
840
+ }
841
+ /**
842
+ * Gets the Y coordinate of the node's top-left corner
843
+ *
844
+ * This value is relative to the node's parent. For the root node,
845
+ * this is always 0.
846
+ *
847
+ * @returns - The vertical position in pixels
848
+ * @returns {number}
849
+ */
850
+ get y() {
851
+ const ret = wasm.layout_y(this.__wbg_ptr);
852
+ return ret;
853
+ }
854
+ /**
855
+ * Gets the rendering order of the node
856
+ *
857
+ * This value determines the z-order for overlapping elements.
858
+ * Lower values are rendered first (behind higher values).
859
+ *
860
+ * @returns - The rendering order as an unsigned 32-bit integer
861
+ * @returns {number}
862
+ */
863
+ get order() {
864
+ const ret = wasm.layout_order(this.__wbg_ptr);
865
+ return ret >>> 0;
866
+ }
867
+ /**
868
+ * Gets the computed width of the node
869
+ *
870
+ * This is the final width after layout computation, including
871
+ * any constraints from min/max size or flex properties.
872
+ *
873
+ * @returns - The width in pixels
874
+ * @returns {number}
875
+ */
876
+ get width() {
877
+ const ret = wasm.layout_width(this.__wbg_ptr);
878
+ return ret;
879
+ }
880
+ /**
881
+ * Gets the computed height of the node
882
+ *
883
+ * This is the final height after layout computation, including
884
+ * any constraints from min/max size or flex properties.
885
+ *
886
+ * @returns - The height in pixels
887
+ * @returns {number}
888
+ */
889
+ get height() {
890
+ const ret = wasm.layout_height(this.__wbg_ptr);
891
+ return ret;
892
+ }
893
+ }
894
+ if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
895
+
896
+ /**
897
+ * Overflow handling enumeration
898
+ *
899
+ * Defines how content that exceeds the container boundaries is handled.
900
+ * This corresponds to the CSS `overflow` property.
901
+ *
902
+ * @example
903
+ * ```typescript
904
+ * import { Style, Overflow } from 'taffy-layout';
905
+ *
906
+ * const style = new Style();
907
+ * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
908
+ * ```
909
+ * @enum {0 | 1 | 2 | 3}
910
+ */
911
+ export const Overflow = Object.freeze({
912
+ /**
913
+ * Content is not clipped and may render outside the container
914
+ */
915
+ Visible: 0, "0": "Visible",
916
+ /**
917
+ * Content is clipped at the container boundary, but unlike Hidden, this forbids all scrolling
918
+ */
919
+ Clip: 1, "1": "Clip",
920
+ /**
921
+ * Content is clipped at the container boundary
922
+ */
923
+ Hidden: 2, "2": "Hidden",
924
+ /**
925
+ * Always display scrollbars for scrollable content
926
+ */
927
+ Scroll: 3, "3": "Scroll",
928
+ });
929
+
930
+ /**
931
+ * Position mode enumeration
932
+ *
933
+ * Controls how an element is positioned within its parent container.
934
+ * This corresponds to the CSS `position` property.
935
+ *
936
+ * @example
937
+ * ```typescript
938
+ * import { Style, Position } from 'taffy-layout';
939
+ *
940
+ * const style = new Style();
941
+ * style.position = Position.Relative; // Normal document flow
942
+ * style.position = Position.Absolute; // Removed from flow, uses inset values
943
+ * ```
944
+ * @enum {0 | 1}
945
+ */
946
+ export const Position = Object.freeze({
947
+ /**
948
+ * Element participates in normal document flow
949
+ */
950
+ Relative: 0, "0": "Relative",
951
+ /**
952
+ * Element is positioned relative to its nearest positioned ancestor
953
+ */
954
+ Absolute: 1, "1": "Absolute",
955
+ });
956
+
957
+ /**
958
+ * CSS layout configuration for a node, including flexbox, sizing, spacing, and alignment properties.
959
+ *
960
+ * This class holds all CSS layout properties for a node. Create an instance with
961
+ * `new Style()` and configure properties before passing to `TaffyTree.newLeaf()`.
962
+ *
963
+ * @defaultValue
964
+ * When created, all properties are set to their CSS default values:
965
+ * - `display`: `Display.Block`
966
+ * - `position`: `Position.Relative`
967
+ * - `flexDirection`: `FlexDirection.Row`
968
+ * - `flexWrap`: `FlexWrap.NoWrap`
969
+ * - `flexGrow`: `0`
970
+ * - `flexShrink`: `1`
971
+ * - All alignment properties: `undefined` (use default behavior)
972
+ * - All dimensions: `"auto"`
973
+ * - All spacing: `0`
974
+ */
975
+ export class Style {
976
+ static __wrap(ptr) {
977
+ ptr = ptr >>> 0;
978
+ const obj = Object.create(Style.prototype);
979
+ obj.__wbg_ptr = ptr;
980
+ StyleFinalization.register(obj, obj.__wbg_ptr, obj);
981
+ return obj;
982
+ }
983
+ __destroy_into_raw() {
984
+ const ptr = this.__wbg_ptr;
985
+ this.__wbg_ptr = 0;
986
+ StyleFinalization.unregister(this);
987
+ return ptr;
988
+ }
989
+ free() {
990
+ const ptr = this.__destroy_into_raw();
991
+ wasm.__wbg_style_free(ptr, 0);
992
+ }
993
+ /**
994
+ * Gets the align-self property
995
+ *
996
+ * Overrides the parent's align-items for this specific element.
997
+ *
998
+ * @returns - The current [`AlignSelf`](JsAlignSelf) value (returns `Auto` if not set)
999
+ * @returns {AlignSelf | undefined}
1000
+ */
1001
+ get alignSelf() {
1002
+ const ret = wasm.style_alignSelf(this.__wbg_ptr);
1003
+ return ret === 8 ? undefined : ret;
1004
+ }
1005
+ /**
1006
+ * Gets the box sizing mode
1007
+ *
1008
+ * Determines whether padding and border are included in dimensions.
1009
+ *
1010
+ * @returns - The current [`BoxSizing`](JsBoxSizing) value
1011
+ *
1012
+ * @defaultValue `BoxSizing.BorderBox`
1013
+ * @returns {BoxSizing}
1014
+ */
1015
+ get boxSizing() {
1016
+ const ret = wasm.style_boxSizing(this.__wbg_ptr);
1017
+ return ret;
1018
+ }
1019
+ /**
1020
+ * Gets the flex-basis
1021
+ *
1022
+ * The initial size of a flex item before growing/shrinking.
1023
+ *
1024
+ * @returns - A `Dimension` value (`number`, `\"{number}%\"`, or `\"auto\"`)
1025
+ * @returns {Dimension}
1026
+ */
1027
+ get flexBasis() {
1028
+ const ret = wasm.style_flexBasis(this.__wbg_ptr);
1029
+ return ret;
1030
+ }
1031
+ /**
1032
+ * Sets the border width
1033
+ *
1034
+ * @param val - A Rect object with LengthPercentage values
1035
+ *
1036
+ * @example
1037
+ * ```typescript
1038
+ * const style = new Style();
1039
+ * style.border = { left: 1, right: 1, top: 1, bottom: 1 };
1040
+ * ```
1041
+ * @param {Rect<LengthPercentage>} val
1042
+ */
1043
+ set border(val) {
1044
+ wasm.style_set_border(this.__wbg_ptr, val);
1045
+ }
1046
+ /**
1047
+ * Sets the margin
1048
+ *
1049
+ * @param val - A Rect object with LengthPercentageAuto values
1050
+ *
1051
+ * @example
1052
+ * ```typescript
1053
+ * const style = new Style();
1054
+ * style.margin = { left: 10, right: 10, top: 5, bottom: 5 };
1055
+ * ```
1056
+ * @param {Rect<LengthPercentageAuto>} val
1057
+ */
1058
+ set margin(val) {
1059
+ wasm.style_set_margin(this.__wbg_ptr, val);
1060
+ }
1061
+ /**
1062
+ * Gets the text-align property
1063
+ *
1064
+ * Used by block layout to implement legacy text alignment behavior.
1065
+ *
1066
+ * @returns - The current [`TextAlign`](JsTextAlign) value
1067
+ *
1068
+ * @defaultValue - `TextAlign.Auto`
1069
+ * @returns {TextAlign}
1070
+ */
1071
+ get textAlign() {
1072
+ const ret = wasm.style_textAlign(this.__wbg_ptr);
1073
+ return ret;
1074
+ }
1075
+ /**
1076
+ * Gets the align-items property
1077
+ *
1078
+ * Defines the default alignment for all children on the cross axis.
1079
+ *
1080
+ * @returns - The current [`AlignItems`](JsAlignItems) value, or `undefined` if not set
1081
+ * @returns {AlignItems | undefined}
1082
+ */
1083
+ get alignItems() {
1084
+ const ret = wasm.style_alignItems(this.__wbg_ptr);
1085
+ return ret === 7 ? undefined : ret;
1086
+ }
1087
+ /**
1088
+ * Gets the flex shrink factor
1089
+ *
1090
+ * Determines how much the item shrinks relative to siblings when
1091
+ * there is insufficient space.
1092
+ *
1093
+ * @returns - The flex shrink factor (default: 1)
1094
+ * @returns {number}
1095
+ */
1096
+ get flexShrink() {
1097
+ const ret = wasm.style_flexShrink(this.__wbg_ptr);
1098
+ return ret;
1099
+ }
1100
+ /**
1101
+ * Gets the grid-column property
1102
+ *
1103
+ * Defines which column in the grid the item should start and end at.
1104
+ * Corresponds to CSS `grid-column` shorthand.
1105
+ *
1106
+ * @returns - A `Line<GridPlacement>` with start and end placements
1107
+ * @returns {Line<GridPlacement>}
1108
+ */
1109
+ get gridColumn() {
1110
+ const ret = wasm.style_gridColumn(this.__wbg_ptr);
1111
+ return ret;
1112
+ }
1113
+ /**
1114
+ * Sets the display mode
1115
+ *
1116
+ * @param val - The new display mode
1117
+ *
1118
+ *
1119
+ * @example
1120
+ * ```typescript
1121
+ * const style = new Style();
1122
+ * style.display = Display.Flex;
1123
+ * ```
1124
+ * @param {Display} val
1125
+ */
1126
+ set display(val) {
1127
+ wasm.style_set_display(this.__wbg_ptr, val);
1128
+ }
1129
+ /**
1130
+ * Sets the padding
1131
+ *
1132
+ * @param val - A Rect object with LengthPercentage values
1133
+ *
1134
+ * @example
1135
+ * ```typescript
1136
+ * const style = new Style();
1137
+ * style.padding = { left: 20, right: 20, top: 10, bottom: 10 };
1138
+ * ```
1139
+ * @param {Rect<LengthPercentage>} val
1140
+ */
1141
+ set padding(val) {
1142
+ wasm.style_set_padding(this.__wbg_ptr, val);
1143
+ }
1144
+ /**
1145
+ * Gets the aspect ratio
1146
+ *
1147
+ * The ratio of width to height. Used to maintain proportions.
1148
+ *
1149
+ * @returns - The aspect ratio value, or `undefined` if not set
1150
+ * @returns {number | undefined}
1151
+ */
1152
+ get aspectRatio() {
1153
+ const ret = wasm.style_aspectRatio(this.__wbg_ptr);
1154
+ return ret === 0x100000001 ? undefined : ret;
1155
+ }
1156
+ /**
1157
+ * Gets the justify-self property
1158
+ *
1159
+ * Overrides the parent's justify-items for this specific element in the inline axis.
1160
+ *
1161
+ * @returns - The current [`AlignSelf`](JsAlignSelf) value (returns `Auto` if not set)
1162
+ * @returns {AlignSelf | undefined}
1163
+ */
1164
+ get justifySelf() {
1165
+ const ret = wasm.style_justifySelf(this.__wbg_ptr);
1166
+ return ret === 8 ? undefined : ret;
1167
+ }
1168
+ /**
1169
+ * Sets the grid-row property
1170
+ *
1171
+ * @param val - A Line object with start and end GridPlacement values
1172
+ *
1173
+ * @example
1174
+ * ```typescript
1175
+ * const style = new Style();
1176
+ * style.display = Display.Grid;
1177
+ * // CSS: grid-row: 1 / 3
1178
+ * style.gridRow = { start: 1, end: 3 };
1179
+ * // CSS: grid-row: 2 / span 2
1180
+ * style.gridRow = { start: 2, end: { span: 2 } };
1181
+ * ```
1182
+ * @param {Line<GridPlacement>} val
1183
+ */
1184
+ set gridRow(val) {
1185
+ wasm.style_set_gridRow(this.__wbg_ptr, val);
1186
+ }
1187
+ /**
1188
+ * Sets the maximum size constraints
1189
+ *
1190
+ * @param val - A Size object with maximum Dimension values
1191
+ *
1192
+ * @example
1193
+ * ```typescript
1194
+ * const style = new Style();
1195
+ * style.maxSize = { width: "auto", height: 500 };
1196
+ * ```
1197
+ * @param {Size<Dimension>} val
1198
+ */
1199
+ set maxSize(val) {
1200
+ wasm.style_set_maxSize(this.__wbg_ptr, val);
1201
+ }
1202
+ /**
1203
+ * Sets the minimum size constraints
1204
+ *
1205
+ * @param val - A Size object with minimum Dimension values
1206
+ *
1207
+ * @example
1208
+ * ```typescript
1209
+ * const style = new Style();
1210
+ * style.minSize = { width: 100, height: "auto" };
1211
+ * ```
1212
+ * @param {Size<Dimension>} val
1213
+ */
1214
+ set minSize(val) {
1215
+ wasm.style_set_minSize(this.__wbg_ptr, val);
1216
+ }
1217
+ /**
1218
+ * Sets the overflow behavior
1219
+ *
1220
+ * @param val - An object with `x` and `y` overflow values
1221
+ *
1222
+ * @example
1223
+ * ```typescript
1224
+ * const style = new Style();
1225
+ * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
1226
+ * ```
1227
+ * @param {Point<Overflow>} val
1228
+ */
1229
+ set overflow(val) {
1230
+ wasm.style_set_overflow(this.__wbg_ptr, val);
1231
+ }
1232
+ /**
1233
+ * Sets the position mode
1234
+ *
1235
+ * @param val - The new position mode
1236
+ *
1237
+ *
1238
+ * @example
1239
+ * ```typescript
1240
+ * const style = new Style();
1241
+ * style.position = Position.Absolute;
1242
+ * style.inset = { left: 10, top: 10, right: "auto", bottom: "auto" };
1243
+ * ```
1244
+ * @param {Position} val
1245
+ */
1246
+ set position(val) {
1247
+ wasm.style_set_position(this.__wbg_ptr, val);
1248
+ }
1249
+ /**
1250
+ * Gets the align-content property
1251
+ *
1252
+ * Controls distribution of space between lines in a multi-line flex container.
1253
+ *
1254
+ * @returns - The current [`AlignContent`](JsAlignContent) value, or `undefined` if not set
1255
+ * @returns {AlignContent | undefined}
1256
+ */
1257
+ get alignContent() {
1258
+ const ret = wasm.style_alignContent(this.__wbg_ptr);
1259
+ return ret === 9 ? undefined : ret;
1260
+ }
1261
+ /**
1262
+ * Gets whether this item is a table
1263
+ *
1264
+ * Table children are handled specially in block layout.
1265
+ *
1266
+ * @returns - Whether the item is treated as a table
1267
+ *
1268
+ * @defaultValue - `false`
1269
+ * @returns {boolean}
1270
+ */
1271
+ get itemIsTable() {
1272
+ const ret = wasm.style_itemIsTable(this.__wbg_ptr);
1273
+ return ret !== 0;
1274
+ }
1275
+ /**
1276
+ * Gets the justify-items property
1277
+ *
1278
+ * Defines the default justify-self for all children in the inline axis.
1279
+ * This is primarily used for CSS Grid layout.
1280
+ *
1281
+ * @returns - The current [`AlignItems`](JsAlignItems) value, or `undefined` if not set
1282
+ * @returns {AlignItems | undefined}
1283
+ */
1284
+ get justifyItems() {
1285
+ const ret = wasm.style_justifyItems(this.__wbg_ptr);
1286
+ return ret === 7 ? undefined : ret;
1287
+ }
1288
+ /**
1289
+ * Sets the flex grow factor
1290
+ *
1291
+ * @param val - The new flex grow factor (must be >= 0)
1292
+ *
1293
+ * @example
1294
+ * ```typescript
1295
+ * const style = new Style();
1296
+ * style.flexGrow = 2;
1297
+ * ```
1298
+ * @param {number} val
1299
+ */
1300
+ set flexGrow(val) {
1301
+ wasm.style_set_flexGrow(this.__wbg_ptr, val);
1302
+ }
1303
+ /**
1304
+ * Sets the flex wrap mode
1305
+ *
1306
+ * @param val - The new flex wrap mode
1307
+ *
1308
+ *
1309
+ * @example
1310
+ * ```typescript
1311
+ * const style = new Style();
1312
+ * style.flexWrap = FlexWrap.Wrap;
1313
+ * ```
1314
+ * @param {FlexWrap} val
1315
+ */
1316
+ set flexWrap(val) {
1317
+ wasm.style_set_flexWrap(this.__wbg_ptr, val);
1318
+ }
1319
+ /**
1320
+ * Gets the flex direction
1321
+ *
1322
+ * Defines the main axis direction for flex items.
1323
+ *
1324
+ * @returns - The current [`FlexDirection`](JsFlexDirection) value
1325
+ *
1326
+ * @defaultValue - `FlexDirection.Row`
1327
+ * @returns {FlexDirection}
1328
+ */
1329
+ get flexDirection() {
1330
+ const ret = wasm.style_flexDirection(this.__wbg_ptr);
1331
+ return ret;
1332
+ }
1333
+ /**
1334
+ * Gets the grid-auto-flow property
1335
+ *
1336
+ * Controls how auto-placed items are inserted into the grid.
1337
+ *
1338
+ * @returns - The current [`GridAutoFlow`](JsGridAutoFlow) value
1339
+ *
1340
+ * @defaultValue - `GridAutoFlow.Row`
1341
+ * @returns {GridAutoFlow}
1342
+ */
1343
+ get gridAutoFlow() {
1344
+ const ret = wasm.style_gridAutoFlow(this.__wbg_ptr);
1345
+ return ret;
1346
+ }
1347
+ /**
1348
+ * Gets the grid-auto-rows property
1349
+ *
1350
+ * Defines the size of implicitly created rows.
1351
+ *
1352
+ * @returns - An array of track sizing functions
1353
+ * @returns {TrackSizingFunction[]}
1354
+ */
1355
+ get gridAutoRows() {
1356
+ const ret = wasm.style_gridAutoRows(this.__wbg_ptr);
1357
+ return ret;
1358
+ }
1359
+ /**
1360
+ * Sets the align-self property
1361
+ *
1362
+ * @param val - The new align-self value, or `undefined`/`Auto` to inherit from parent
1363
+ *
1364
+ * @example
1365
+ * ```typescript
1366
+ * const style = new Style();
1367
+ * style.alignSelf = AlignSelf.Stretch;
1368
+ * ```
1369
+ * @param {AlignSelf | undefined} val
1370
+ */
1371
+ set alignSelf(val) {
1372
+ wasm.style_set_alignSelf(this.__wbg_ptr, val);
1373
+ }
1374
+ /**
1375
+ * Sets the box sizing mode
1376
+ *
1377
+ * @param val - The new box sizing mode
1378
+ *
1379
+ * @example
1380
+ * ```typescript
1381
+ * const style = new Style();
1382
+ * style.boxSizing = BoxSizing.ContentBox;
1383
+ * ```
1384
+ * @param {BoxSizing} val
1385
+ */
1386
+ set boxSizing(val) {
1387
+ wasm.style_set_boxSizing(this.__wbg_ptr, val);
1388
+ }
1389
+ /**
1390
+ * Sets the flex-basis
1391
+ *
1392
+ * @param val - The initial size as a Dimension
1393
+ *
1394
+ * @example
1395
+ * ```typescript
1396
+ * const style = new Style();
1397
+ * style.flexBasis = 100;
1398
+ * ```
1399
+ * @param {Dimension} val
1400
+ */
1401
+ set flexBasis(val) {
1402
+ wasm.style_set_flexBasis(this.__wbg_ptr, val);
1403
+ }
1404
+ /**
1405
+ * Sets the text-align property
1406
+ *
1407
+ * @param val - The new text-align value
1408
+ *
1409
+ * @example
1410
+ * ```typescript
1411
+ * const style = new Style();
1412
+ * style.textAlign = TextAlign.LegacyCenter;
1413
+ * ```
1414
+ * @param {TextAlign} val
1415
+ */
1416
+ set textAlign(val) {
1417
+ wasm.style_set_textAlign(this.__wbg_ptr, val);
1418
+ }
1419
+ /**
1420
+ * Gets the justify-content property
1421
+ *
1422
+ * Defines alignment and spacing of items along the main axis.
1423
+ *
1424
+ * @returns - The current [`JustifyContent`](JsJustifyContent) value, or `undefined` if not set
1425
+ * @returns {JustifyContent | undefined}
1426
+ */
1427
+ get justifyContent() {
1428
+ const ret = wasm.style_justifyContent(this.__wbg_ptr);
1429
+ return ret === 9 ? undefined : ret;
1430
+ }
1431
+ /**
1432
+ * Gets the scrollbar width
1433
+ *
1434
+ * The width of the scrollbar gutter when `overflow` is set to `Scroll`.
1435
+ *
1436
+ * @returns - The scrollbar width in pixels
1437
+ *
1438
+ * @defaultValue - `0`
1439
+ * @returns {number}
1440
+ */
1441
+ get scrollbarWidth() {
1442
+ const ret = wasm.style_scrollbarWidth(this.__wbg_ptr);
1443
+ return ret;
1444
+ }
1445
+ /**
1446
+ * Sets the align-items property
1447
+ *
1448
+ * @param val - The new align-items value, or `undefined` to use default
1449
+ *
1450
+ * @example
1451
+ * ```typescript
1452
+ * const style = new Style();
1453
+ * style.alignItems = AlignItems.Center;
1454
+ * ```
1455
+ * @param {AlignItems | undefined} val
1456
+ */
1457
+ set alignItems(val) {
1458
+ wasm.style_set_alignItems(this.__wbg_ptr, val);
1459
+ }
1460
+ /**
1461
+ * Sets the flex shrink factor
1462
+ *
1463
+ * @param val - The new flex shrink factor (must be >= 0)
1464
+ *
1465
+ * @example
1466
+ * ```typescript
1467
+ * const style = new Style();
1468
+ * style.flexShrink = 2;
1469
+ * ```
1470
+ * @param {number} val
1471
+ */
1472
+ set flexShrink(val) {
1473
+ wasm.style_set_flexShrink(this.__wbg_ptr, val);
1474
+ }
1475
+ /**
1476
+ * Sets the grid-column property
1477
+ *
1478
+ * @param val - A Line object with start and end GridPlacement values
1479
+ *
1480
+ * @example
1481
+ * ```typescript
1482
+ * const style = new Style();
1483
+ * style.display = Display.Grid;
1484
+ * // CSS: grid-column: 1 / 4
1485
+ * style.gridColumn = { start: 1, end: 4 };
1486
+ * // CSS: grid-column: auto / span 3
1487
+ * style.gridColumn = { start: "auto", end: { span: 3 } };
1488
+ * ```
1489
+ * @param {Line<GridPlacement>} val
1490
+ */
1491
+ set gridColumn(val) {
1492
+ wasm.style_set_gridColumn(this.__wbg_ptr, val);
1493
+ }
1494
+ /**
1495
+ * Gets whether this item is a replaced element
1496
+ *
1497
+ * Replaced elements have special sizing behavior (e.g., `<img>`, `<video>`).
1498
+ *
1499
+ * @returns - Whether the item is a replaced element
1500
+ *
1501
+ * @defaultValue - `false`
1502
+ * @returns {boolean}
1503
+ */
1504
+ get itemIsReplaced() {
1505
+ const ret = wasm.style_itemIsReplaced(this.__wbg_ptr);
1506
+ return ret !== 0;
1507
+ }
1508
+ /**
1509
+ * Sets the aspect ratio
1510
+ *
1511
+ * @param val - The new aspect ratio (width/height), or `undefined` to clear
1512
+ *
1513
+ * @example
1514
+ * ```typescript
1515
+ * const style = new Style();
1516
+ * style.aspectRatio = 16 / 9;
1517
+ * ```
1518
+ * @param {number | undefined} val
1519
+ */
1520
+ set aspectRatio(val) {
1521
+ wasm.style_set_aspectRatio(this.__wbg_ptr, val);
1522
+ }
1523
+ /**
1524
+ * Sets the justify-self property
1525
+ *
1526
+ * @param val - The new justify-self value, or `undefined`/`Auto` to inherit from parent
1527
+ *
1528
+ * @example
1529
+ * ```typescript
1530
+ * const style = new Style();
1531
+ * style.justifySelf = AlignSelf.End;
1532
+ * ```
1533
+ * @param {AlignSelf | undefined} val
1534
+ */
1535
+ set justifySelf(val) {
1536
+ wasm.style_set_justifySelf(this.__wbg_ptr, val);
1537
+ }
1538
+ /**
1539
+ * Gets the grid-auto-columns property
1540
+ *
1541
+ * Defines the size of implicitly created columns.
1542
+ *
1543
+ * @returns - An array of track sizing functions
1544
+ * @returns {TrackSizingFunction[]}
1545
+ */
1546
+ get gridAutoColumns() {
1547
+ const ret = wasm.style_gridAutoColumns(this.__wbg_ptr);
1548
+ return ret;
1549
+ }
1550
+ /**
1551
+ * Sets the align-content property
1552
+ *
1553
+ * @param val - The new align-content value, or `undefined` to use default
1554
+ *
1555
+ * @example
1556
+ * ```typescript
1557
+ * const style = new Style();
1558
+ * style.alignContent = AlignContent.SpaceBetween;
1559
+ * ```
1560
+ * @param {AlignContent | undefined} val
1561
+ */
1562
+ set alignContent(val) {
1563
+ wasm.style_set_alignContent(this.__wbg_ptr, val);
1564
+ }
1565
+ /**
1566
+ * Sets whether this item is a table
1567
+ *
1568
+ * @param val - Whether the item should be treated as a table
1569
+ * @param {boolean} val
1570
+ */
1571
+ set itemIsTable(val) {
1572
+ wasm.style_set_itemIsTable(this.__wbg_ptr, val);
1573
+ }
1574
+ /**
1575
+ * Sets the justify-items property
1576
+ *
1577
+ * @param val - The new justify-items value, or `undefined` to use default
1578
+ *
1579
+ * @example
1580
+ * ```typescript
1581
+ * const style = new Style();
1582
+ * style.display = Display.Grid;
1583
+ * style.justifyItems = AlignItems.Center;
1584
+ * ```
1585
+ * @param {AlignItems | undefined} val
1586
+ */
1587
+ set justifyItems(val) {
1588
+ wasm.style_set_justifyItems(this.__wbg_ptr, val);
1589
+ }
1590
+ /**
1591
+ * Gets the grid-template-rows property
1592
+ *
1593
+ * Defines the track sizing functions (heights) of the grid rows.
1594
+ *
1595
+ * @returns - An array of `GridTrack` values
1596
+ * @returns {GridTemplateComponent[]}
1597
+ */
1598
+ get gridTemplateRows() {
1599
+ const ret = wasm.style_gridTemplateRows(this.__wbg_ptr);
1600
+ return ret;
1601
+ }
1602
+ /**
1603
+ * Sets the flex direction
1604
+ *
1605
+ * @param val - The new flex direction
1606
+ *
1607
+ *
1608
+ * @example
1609
+ * ```typescript
1610
+ * const style = new Style();
1611
+ * style.flexDirection = FlexDirection.Column;
1612
+ * ```
1613
+ * @param {FlexDirection} val
1614
+ */
1615
+ set flexDirection(val) {
1616
+ wasm.style_set_flexDirection(this.__wbg_ptr, val);
1617
+ }
1618
+ /**
1619
+ * Sets the grid-auto-flow property
1620
+ *
1621
+ * @param val - The new grid-auto-flow value
1622
+ *
1623
+ * @example
1624
+ * ```typescript
1625
+ * const style = new Style();
1626
+ * style.display = Display.Grid;
1627
+ * style.gridAutoFlow = GridAutoFlow.Column;
1628
+ * ```
1629
+ * @param {GridAutoFlow} val
1630
+ */
1631
+ set gridAutoFlow(val) {
1632
+ wasm.style_set_gridAutoFlow(this.__wbg_ptr, val);
1633
+ }
1634
+ /**
1635
+ * Sets the grid-auto-rows property
1636
+ *
1637
+ * @param val - An array of track sizing functions for implicit rows
1638
+ *
1639
+ * @example
1640
+ * ```typescript
1641
+ * const style = new Style();
1642
+ * style.display = Display.Grid;
1643
+ * style.gridAutoRows = [{ min: "auto", max: "auto" }];
1644
+ * ```
1645
+ * @param {TrackSizingFunction[]} val
1646
+ */
1647
+ set gridAutoRows(val) {
1648
+ wasm.style_set_gridAutoRows(this.__wbg_ptr, val);
1649
+ }
1650
+ /**
1651
+ * Gets the grid-template-areas property
1652
+ *
1653
+ * Defines named grid areas that can be referenced by grid items.
1654
+ *
1655
+ * @returns - An array of `GridArea` values
1656
+ * @returns {GridTemplateArea[]}
1657
+ */
1658
+ get gridTemplateAreas() {
1659
+ const ret = wasm.style_gridTemplateAreas(this.__wbg_ptr);
1660
+ return ret;
1661
+ }
1662
+ /**
1663
+ * Sets the justify-content property
1664
+ *
1665
+ * @param val - The new justify-content value, or `undefined` to use default
1666
+ *
1667
+ * @example
1668
+ * ```typescript
1669
+ * const style = new Style();
1670
+ * style.justifyContent = JustifyContent.Center;
1671
+ * ```
1672
+ * @param {JustifyContent | undefined} val
1673
+ */
1674
+ set justifyContent(val) {
1675
+ wasm.style_set_justifyContent(this.__wbg_ptr, val);
1676
+ }
1677
+ /**
1678
+ * Sets the scrollbar width
1679
+ *
1680
+ * @param val - The scrollbar width in pixels
1681
+ *
1682
+ * @example
1683
+ * ```typescript
1684
+ * const style = new Style();
1685
+ * style.overflow = { x: Overflow.Scroll, y: Overflow.Scroll };
1686
+ * style.scrollbarWidth = 15;
1687
+ * ```
1688
+ * @param {number} val
1689
+ */
1690
+ set scrollbarWidth(val) {
1691
+ wasm.style_set_scrollbarWidth(this.__wbg_ptr, val);
1692
+ }
1693
+ /**
1694
+ * Sets whether this item is a replaced element
1695
+ *
1696
+ * @param val - Whether the item should be treated as a replaced element
1697
+ * @param {boolean} val
1698
+ */
1699
+ set itemIsReplaced(val) {
1700
+ wasm.style_set_itemIsReplaced(this.__wbg_ptr, val);
1701
+ }
1702
+ /**
1703
+ * Gets the grid-template-columns property
1704
+ *
1705
+ * Defines the track sizing functions (widths) of the grid columns.
1706
+ *
1707
+ * @returns - An array of `GridTrack` values
1708
+ * @returns {GridTemplateComponent[]}
1709
+ */
1710
+ get gridTemplateColumns() {
1711
+ const ret = wasm.style_gridTemplateColumns(this.__wbg_ptr);
1712
+ return ret;
1713
+ }
1714
+ /**
1715
+ * Sets the grid-auto-columns property
1716
+ *
1717
+ * @param val - An array of track sizing functions for implicit columns
1718
+ * @param {TrackSizingFunction[]} val
1719
+ */
1720
+ set gridAutoColumns(val) {
1721
+ wasm.style_set_gridAutoColumns(this.__wbg_ptr, val);
1722
+ }
1723
+ /**
1724
+ * Sets the grid-template-rows property
1725
+ *
1726
+ * @param val - An array of GridTrack objects
1727
+ * @param {GridTemplateComponent[]} val
1728
+ */
1729
+ set gridTemplateRows(val) {
1730
+ wasm.style_set_gridTemplateRows(this.__wbg_ptr, val);
1731
+ }
1732
+ /**
1733
+ * Gets the grid-template-row-names property
1734
+ *
1735
+ * Defines the named lines between the rows.
1736
+ *
1737
+ * @returns - An array of arrays of line names
1738
+ * @returns {string[][]}
1739
+ */
1740
+ get gridTemplateRowNames() {
1741
+ const ret = wasm.style_gridTemplateRowNames(this.__wbg_ptr);
1742
+ return ret;
1743
+ }
1744
+ /**
1745
+ * Sets the grid-template-areas property
1746
+ *
1747
+ * @param val - An array of named grid area definitions
1748
+ *
1749
+ * @example
1750
+ * ```typescript
1751
+ * const style = new Style();
1752
+ * style.display = Display.Grid;
1753
+ * style.gridTemplateAreas = [
1754
+ * { name: "header", rowStart: 1, rowEnd: 2, columnStart: 1, columnEnd: 4 },
1755
+ * { name: "main", rowStart: 2, rowEnd: 4, columnStart: 2, columnEnd: 4 }
1756
+ * ];
1757
+ * ```
1758
+ * @param {GridTemplateArea[]} val
1759
+ */
1760
+ set gridTemplateAreas(val) {
1761
+ wasm.style_set_gridTemplateAreas(this.__wbg_ptr, val);
1762
+ }
1763
+ /**
1764
+ * Sets the grid-template-columns property
1765
+ *
1766
+ * @param val - An array of GridTrack objects
1767
+ *
1768
+ * @example
1769
+ * ```typescript
1770
+ * const style = new Style();
1771
+ * style.display = Display.Grid;
1772
+ * style.gridTemplateColumns = [
1773
+ * { min: 200, max: 200 },
1774
+ * { min: "auto", max: "1fr" },
1775
+ * { min: "auto", max: "1fr" }
1776
+ * ];
1777
+ * ```
1778
+ * @param {GridTemplateComponent[]} val
1779
+ */
1780
+ set gridTemplateColumns(val) {
1781
+ wasm.style_set_gridTemplateColumns(this.__wbg_ptr, val);
1782
+ }
1783
+ /**
1784
+ * Gets the grid-template-column-names property
1785
+ *
1786
+ * Defines the named lines between the columns.
1787
+ *
1788
+ * @returns - An array of arrays of line names
1789
+ * @returns {string[][]}
1790
+ */
1791
+ get gridTemplateColumnNames() {
1792
+ const ret = wasm.style_gridTemplateColumnNames(this.__wbg_ptr);
1793
+ return ret;
1794
+ }
1795
+ /**
1796
+ * Sets the grid-template-row-names property
1797
+ *
1798
+ * @param val - An array of arrays of line names
1799
+ *
1800
+ * @example
1801
+ * ```typescript
1802
+ * const style = new Style();
1803
+ * style.gridTemplateRowNames = [["header-start"], ["header-end", "main-start"], ["main-end"]];
1804
+ * ```
1805
+ * @param {string[][]} val
1806
+ */
1807
+ set gridTemplateRowNames(val) {
1808
+ wasm.style_set_gridTemplateRowNames(this.__wbg_ptr, val);
1809
+ }
1810
+ /**
1811
+ * Sets the grid-template-column-names property
1812
+ *
1813
+ * @param val - An array of arrays of line names
1814
+ *
1815
+ * @example
1816
+ * ```typescript
1817
+ * const style = new Style();
1818
+ * style.gridTemplateColumnNames = [["sidebar-start"], ["sidebar-end", "main-start"], ["main-end"]];
1819
+ * ```
1820
+ * @param {string[][]} val
1821
+ */
1822
+ set gridTemplateColumnNames(val) {
1823
+ wasm.style_set_gridTemplateColumnNames(this.__wbg_ptr, val);
1824
+ }
1825
+ /**
1826
+ * Gets the gap
1827
+ *
1828
+ * Spacing between flex/grid items.
1829
+ *
1830
+ * @returns - A `Size<LengthPercentage>` with column (width) and row (height) gaps
1831
+ * @returns {Size<LengthPercentage>}
1832
+ */
1833
+ get gap() {
1834
+ const ret = wasm.style_gap(this.__wbg_ptr);
1835
+ return ret;
1836
+ }
1837
+ /**
1838
+ * Creates a new Style instance with default values
1839
+ *
1840
+ * @returns - A new `Style` object with all properties set to CSS defaults
1841
+ *
1842
+ * @example
1843
+ * ```typescript
1844
+ * const style = new Style();
1845
+ * console.log(style.display); // Display.Block
1846
+ * ```
1847
+ */
1848
+ constructor() {
1849
+ const ret = wasm.style_new();
1850
+ this.__wbg_ptr = ret >>> 0;
1851
+ StyleFinalization.register(this, this.__wbg_ptr, this);
1852
+ return this;
1853
+ }
1854
+ /**
1855
+ * Gets the size (width and height)
1856
+ *
1857
+ * @returns - A `Size<Dimension>` object with `width` and `height` properties
1858
+ * @returns {Size<Dimension>}
1859
+ */
1860
+ get size() {
1861
+ const ret = wasm.style_size(this.__wbg_ptr);
1862
+ return ret;
1863
+ }
1864
+ /**
1865
+ * Gets the inset
1866
+ *
1867
+ * Positioning offsets for absolutely positioned elements.
1868
+ *
1869
+ * @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom offsets
1870
+ * @returns {Rect<LengthPercentageAuto>}
1871
+ */
1872
+ get inset() {
1873
+ const ret = wasm.style_inset(this.__wbg_ptr);
1874
+ return ret;
1875
+ }
1876
+ /**
1877
+ * Gets the border width
1878
+ *
1879
+ * Width of the element's border on each side.
1880
+ *
1881
+ * @returns - A `Rect<LengthPercentage>` with left, right, top, bottom border widths
1882
+ * @returns {Rect<LengthPercentage>}
1883
+ */
1884
+ get border() {
1885
+ const ret = wasm.style_border(this.__wbg_ptr);
1886
+ return ret;
1887
+ }
1888
+ /**
1889
+ * Gets the margin
1890
+ *
1891
+ * Outer spacing around the element.
1892
+ *
1893
+ * @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom margins
1894
+ * @returns {Rect<LengthPercentageAuto>}
1895
+ */
1896
+ get margin() {
1897
+ const ret = wasm.style_margin(this.__wbg_ptr);
1898
+ return ret;
1899
+ }
1900
+ /**
1901
+ * Gets the display mode
1902
+ *
1903
+ * Determines the layout algorithm used for this element and its children.
1904
+ *
1905
+ * @returns - The current [`Display`](JsDisplay) value
1906
+ *
1907
+ * @defaultValue - `Display.Block`
1908
+ * @returns {Display}
1909
+ */
1910
+ get display() {
1911
+ const ret = wasm.style_display(this.__wbg_ptr);
1912
+ return ret;
1913
+ }
1914
+ /**
1915
+ * Gets the padding
1916
+ *
1917
+ * Inner spacing between the element's border and content.
1918
+ *
1919
+ * @returns - A `Rect<LengthPercentage>` with left, right, top, bottom padding
1920
+ * @returns {Rect<LengthPercentage>}
1921
+ */
1922
+ get padding() {
1923
+ const ret = wasm.style_padding(this.__wbg_ptr);
1924
+ return ret;
1925
+ }
1926
+ /**
1927
+ * Sets the gap
1928
+ *
1929
+ * @param val - A Size object with LengthPercentage gap values
1930
+ *
1931
+ * @example
1932
+ * ```typescript
1933
+ * const style = new Style();
1934
+ * style.gap = { width: 10, height: 10 };
1935
+ * ```
1936
+ * @param {Size<LengthPercentage>} val
1937
+ */
1938
+ set gap(val) {
1939
+ wasm.style_set_gap(this.__wbg_ptr, val);
1940
+ }
1941
+ /**
1942
+ * Gets the grid-row property
1943
+ *
1944
+ * Defines which row in the grid the item should start and end at.
1945
+ * Corresponds to CSS `grid-row` shorthand.
1946
+ *
1947
+ * @returns - A `Line<GridPlacement>` with start and end placements
1948
+ * @returns {Line<GridPlacement>}
1949
+ */
1950
+ get gridRow() {
1951
+ const ret = wasm.style_gridRow(this.__wbg_ptr);
1952
+ return ret;
1953
+ }
1954
+ /**
1955
+ * Gets the maximum size constraints
1956
+ *
1957
+ * @returns - A `Size<Dimension>` object with maximum width and height
1958
+ * @returns {Size<Dimension>}
1959
+ */
1960
+ get maxSize() {
1961
+ const ret = wasm.style_maxSize(this.__wbg_ptr);
1962
+ return ret;
1963
+ }
1964
+ /**
1965
+ * Gets the minimum size constraints
1966
+ *
1967
+ * @returns - A `Size<Dimension>` object with minimum width and height
1968
+ * @returns {Size<Dimension>}
1969
+ */
1970
+ get minSize() {
1971
+ const ret = wasm.style_minSize(this.__wbg_ptr);
1972
+ return ret;
1973
+ }
1974
+ /**
1975
+ * Gets the overflow behavior
1976
+ *
1977
+ * Controls how content that exceeds the container is handled.
1978
+ *
1979
+ * @returns - A `Point<Overflow>` with `x` and `y` overflow settings
1980
+ * @returns {Point<Overflow>}
1981
+ */
1982
+ get overflow() {
1983
+ const ret = wasm.style_overflow(this.__wbg_ptr);
1984
+ return ret;
1985
+ }
1986
+ /**
1987
+ * Gets the position mode
1988
+ *
1989
+ * Determines how the element is positioned within its parent.
1990
+ *
1991
+ * @returns - The current [`Position`](JsPosition) value
1992
+ *
1993
+ * @defaultValue - `Position.Relative`
1994
+ * @returns {Position}
1995
+ */
1996
+ get position() {
1997
+ const ret = wasm.style_position(this.__wbg_ptr);
1998
+ return ret;
1999
+ }
2000
+ /**
2001
+ * Sets the size (width and height)
2002
+ *
2003
+ * @param val - A Size object with Dimension values
2004
+ *
2005
+ * @example
2006
+ * ```typescript
2007
+ * const style = new Style();
2008
+ * style.size = { width: 200, height: "100%" };
2009
+ * ```
2010
+ * @param {Size<Dimension>} val
2011
+ */
2012
+ set size(val) {
2013
+ wasm.style_set_size(this.__wbg_ptr, val);
2014
+ }
2015
+ /**
2016
+ * Gets the flex grow factor
2017
+ *
2018
+ * Determines how much the item grows relative to siblings when
2019
+ * there is extra space available.
2020
+ *
2021
+ * @returns - The flex grow factor (default: 0)
2022
+ * @returns {number}
2023
+ */
2024
+ get flexGrow() {
2025
+ const ret = wasm.style_flexGrow(this.__wbg_ptr);
2026
+ return ret;
2027
+ }
2028
+ /**
2029
+ * Gets the flex wrap mode
2030
+ *
2031
+ * Controls whether flex items wrap to new lines.
2032
+ *
2033
+ * @returns - The current [`FlexWrap`](JsFlexWrap) value
2034
+ *
2035
+ * @defaultValue - `FlexWrap.NoWrap`
2036
+ * @returns {FlexWrap}
2037
+ */
2038
+ get flexWrap() {
2039
+ const ret = wasm.style_flexWrap(this.__wbg_ptr);
2040
+ return ret;
2041
+ }
2042
+ /**
2043
+ * Sets the inset
2044
+ *
2045
+ * @param val - A Rect object with LengthPercentageAuto offset values
2046
+ *
2047
+ * @example
2048
+ * ```typescript
2049
+ * const style = new Style();
2050
+ * style.position = Position.Absolute;
2051
+ * style.inset = { left: 0, top: 0, right: "auto", bottom: "auto" };
2052
+ * ```
2053
+ * @param {Rect<LengthPercentageAuto>} val
2054
+ */
2055
+ set inset(val) {
2056
+ wasm.style_set_inset(this.__wbg_ptr, val);
2057
+ }
2058
+ }
2059
+ if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
2060
+
2061
+ /**
2062
+ * Error class thrown when a Taffy operation fails, containing a human-readable error message.
2063
+ *
2064
+ * This class wraps the native [`taffy::TaffyError`] type and exposes it to JavaScript
2065
+ * with a readable error message. It is thrown as a JavaScript exception on failure.
2066
+ *
2067
+ * @example
2068
+ * ```typescript
2069
+ * try {
2070
+ * const tree = new TaffyTree();
2071
+ * const node = tree.newLeaf(new Style());
2072
+ * tree.remove(node);
2073
+ * } catch (e) {
2074
+ * if (e instanceof TaffyError) {
2075
+ * console.error(e.message);
2076
+ * }
2077
+ * }
2078
+ * ```
2079
+ *
2080
+ * @remarks
2081
+ * The underlying Taffy errors include:
2082
+ * - `InvalidInputNode`: Node ID doesn't exist in the tree
2083
+ * - `InvalidParentNode`: Specified parent node doesn't exist
2084
+ * - `ChildIndexOutOfBounds`: Child index exceeds available children
2085
+ */
2086
+ export class TaffyError {
2087
+ static __wrap(ptr) {
2088
+ ptr = ptr >>> 0;
2089
+ const obj = Object.create(TaffyError.prototype);
2090
+ obj.__wbg_ptr = ptr;
2091
+ TaffyErrorFinalization.register(obj, obj.__wbg_ptr, obj);
2092
+ return obj;
2093
+ }
2094
+ __destroy_into_raw() {
2095
+ const ptr = this.__wbg_ptr;
2096
+ this.__wbg_ptr = 0;
2097
+ TaffyErrorFinalization.unregister(this);
2098
+ return ptr;
2099
+ }
2100
+ free() {
2101
+ const ptr = this.__destroy_into_raw();
2102
+ wasm.__wbg_taffyerror_free(ptr, 0);
2103
+ }
2104
+ /**
2105
+ * Gets the human-readable error message
2106
+ *
2107
+ * @returns - A string describing what went wrong.
2108
+ *
2109
+ * @remarks
2110
+ * Examples:
2111
+ * - "Node with id 1234 is not present in the Taffy tree"
2112
+ * - "Index 5 is out of bounds for node with 3 children"
2113
+ * @returns {string}
2114
+ */
2115
+ get message() {
2116
+ let deferred1_0;
2117
+ let deferred1_1;
2118
+ try {
2119
+ const ret = wasm.taffyerror_message(this.__wbg_ptr);
2120
+ deferred1_0 = ret[0];
2121
+ deferred1_1 = ret[1];
2122
+ return getStringFromWasm0(ret[0], ret[1]);
2123
+ } finally {
2124
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2125
+ }
2126
+ }
2127
+ }
2128
+ if (Symbol.dispose) TaffyError.prototype[Symbol.dispose] = TaffyError.prototype.free;
2129
+
2130
+ /**
2131
+ * The main layout tree class for creating nodes, computing layouts, and managing a tree of styled elements.
2132
+ *
2133
+ * TaffyTree is the entry point for the Taffy layout engine. It manages
2134
+ * a tree of nodes and computes their layouts using CSS Flexbox and Grid algorithms.
2135
+ */
2136
+ export class TaffyTree {
2137
+ static __wrap(ptr) {
2138
+ ptr = ptr >>> 0;
2139
+ const obj = Object.create(TaffyTree.prototype);
2140
+ obj.__wbg_ptr = ptr;
2141
+ TaffyTreeFinalization.register(obj, obj.__wbg_ptr, obj);
2142
+ return obj;
2143
+ }
2144
+ __destroy_into_raw() {
2145
+ const ptr = this.__wbg_ptr;
2146
+ this.__wbg_ptr = 0;
2147
+ TaffyTreeFinalization.unregister(this);
2148
+ return ptr;
2149
+ }
2150
+ free() {
2151
+ const ptr = this.__destroy_into_raw();
2152
+ wasm.__wbg_taffytree_free(ptr, 0);
2153
+ }
2154
+ /**
2155
+ * Marks a node as dirty (requiring re-layout)
2156
+ *
2157
+ * Use this when a node's content has changed but its style hasn't.
2158
+ * For example, when text content changes and needs remeasuring.
2159
+ *
2160
+ * @param node - The node ID to mark dirty
2161
+ *
2162
+ * @throws `TaffyError` if the node does not exist
2163
+ *
2164
+ * @example
2165
+ * ```typescript
2166
+ * const tree = new TaffyTree();
2167
+ * const rootId = tree.newLeaf(new Style());
2168
+ * const nodeId = rootId;
2169
+ * const availableSpace = { width: 100, height: 100 };
2170
+ *
2171
+ * // After updating text content
2172
+ * tree.setNodeContext(nodeId, { text: "Updated text" });
2173
+ * tree.markDirty(nodeId);
2174
+ * tree.computeLayout(rootId, availableSpace);
2175
+ * ```
2176
+ * @param {bigint} node
2177
+ */
2178
+ markDirty(node) {
2179
+ const ret = wasm.taffytree_markDirty(this.__wbg_ptr, node);
2180
+ if (ret[1]) {
2181
+ throw takeFromExternrefTable0(ret[0]);
2182
+ }
2183
+ }
2184
+ /**
2185
+ * Prints the tree structure to the console (for debugging)
2186
+ *
2187
+ * Outputs a text representation of the tree structure starting from
2188
+ * the given node. Useful for debugging layout issues.
2189
+ *
2190
+ * @param node - The root node ID to print from
2191
+ *
2192
+ * @example
2193
+ * ```typescript
2194
+ * const tree = new TaffyTree();
2195
+ * const rootId = tree.newLeaf(new Style());
2196
+ * tree.printTree(rootId);
2197
+ * // Output appears in browser console
2198
+ * ```
2199
+ * @param {bigint} node
2200
+ */
2201
+ printTree(node) {
2202
+ wasm.taffytree_printTree(this.__wbg_ptr, node);
2203
+ }
2204
+ /**
2205
+ * Gets the number of children of a node
2206
+ *
2207
+ * @param parent - The parent node ID
2208
+ *
2209
+ * @returns - The number of direct children
2210
+ *
2211
+ * @throws `TaffyError` if the node does not exist
2212
+ *
2213
+ * @example
2214
+ * ```typescript
2215
+ * const tree = new TaffyTree();
2216
+ * const parentId = tree.newLeaf(new Style());
2217
+ * const count: number = tree.childCount(parentId);
2218
+ * ```
2219
+ * @param {bigint} parent
2220
+ * @returns {number}
2221
+ */
2222
+ childCount(parent) {
2223
+ const ret = wasm.taffytree_childCount(this.__wbg_ptr, parent);
2224
+ return ret >>> 0;
2225
+ }
2226
+ /**
2227
+ * Removes a specific child from a parent
2228
+ *
2229
+ * @param parent - The parent node ID
2230
+ * @param child - The child node ID to remove
2231
+ *
2232
+ * @returns - The removed child ID (`bigint`)
2233
+ *
2234
+ * @throws `TaffyError` if the parent or child node does not exist
2235
+ *
2236
+ * @example
2237
+ * ```typescript
2238
+ * const tree = new TaffyTree();
2239
+ * const parentId = tree.newLeaf(new Style());
2240
+ * const childId = tree.newLeaf(new Style());
2241
+ * tree.addChild(parentId, childId);
2242
+ * tree.removeChild(parentId, childId);
2243
+ * ```
2244
+ * @param {bigint} parent
2245
+ * @param {bigint} child
2246
+ * @returns {bigint}
2247
+ */
2248
+ removeChild(parent, child) {
2249
+ const ret = wasm.taffytree_removeChild(this.__wbg_ptr, parent, child);
2250
+ if (ret[2]) {
2251
+ throw takeFromExternrefTable0(ret[1]);
2252
+ }
2253
+ return BigInt.asUintN(64, ret[0]);
2254
+ }
2255
+ /**
2256
+ * Replaces all children of a node
2257
+ *
2258
+ * Any existing children are removed and replaced with the new array.
2259
+ *
2260
+ * @param parent - The parent node ID
2261
+ * @param children - Array of new child node IDs
2262
+ *
2263
+ * @throws `TaffyError` if the parent node does not exist
2264
+ *
2265
+ * @example
2266
+ * ```typescript
2267
+ * const tree = new TaffyTree();
2268
+ * const parentId = tree.newLeaf(new Style());
2269
+ * const child1 = tree.newLeaf(new Style());
2270
+ * const child2 = tree.newLeaf(new Style());
2271
+ * const child3 = tree.newLeaf(new Style());
2272
+ * const children = BigUint64Array.from([child1, child2, child3]);
2273
+ * tree.setChildren(parentId, children);
2274
+ * ```
2275
+ * @param {bigint} parent
2276
+ * @param {BigUint64Array} children
2277
+ */
2278
+ setChildren(parent, children) {
2279
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2280
+ const len0 = WASM_VECTOR_LEN;
2281
+ const ret = wasm.taffytree_setChildren(this.__wbg_ptr, parent, ptr0, len0);
2282
+ if (ret[1]) {
2283
+ throw takeFromExternrefTable0(ret[0]);
2284
+ }
2285
+ }
2286
+ /**
2287
+ * Creates a new TaffyTree with pre-allocated capacity
2288
+ *
2289
+ * Use this when you know approximately how many nodes will be in the tree.
2290
+ * This can improve performance by reducing memory reallocations.
2291
+ *
2292
+ * @param capacity - The number of nodes to pre-allocate space for
2293
+ *
2294
+ * @example
2295
+ * ```typescript
2296
+ * const tree: TaffyTree = TaffyTree.withCapacity(1000);
2297
+ * ```
2298
+ * @param {number} capacity
2299
+ * @returns {TaffyTree}
2300
+ */
2301
+ static withCapacity(capacity) {
2302
+ const ret = wasm.taffytree_withCapacity(capacity);
2303
+ return TaffyTree.__wrap(ret);
2304
+ }
2305
+ /**
2306
+ * Computes the layout for a subtree
2307
+ *
2308
+ * This is the main layout computation method. Call this on the root node
2309
+ * to compute layouts for all nodes in the tree.
2310
+ *
2311
+ * @param node - The root node ID to compute layout for
2312
+ * @param availableSpace - The available space constraints
2313
+ *
2314
+ * @example
2315
+ * ```typescript
2316
+ * const tree = new TaffyTree();
2317
+ * const rootId = tree.newLeaf(new Style());
2318
+ *
2319
+ * // Fixed size container
2320
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
2321
+ *
2322
+ * // Flexible width, fixed height
2323
+ * tree.computeLayout(rootId, { width: "max-content", height: 600 });
2324
+ *
2325
+ * // Minimum content size
2326
+ * tree.computeLayout(rootId, { width: "min-content", height: "min-content" });
2327
+ * ```
2328
+ *
2329
+ * @throws `TaffyError` if the node does not exist or available space is invalid
2330
+ *
2331
+ * @example
2332
+ * ```typescript
2333
+ * const tree = new TaffyTree();
2334
+ * const rootId = tree.newLeaf(new Style());
2335
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
2336
+ * ```
2337
+ * @param {bigint} node
2338
+ * @param {Size<AvailableSpace>} availableSpace
2339
+ */
2340
+ computeLayout(node, availableSpace) {
2341
+ const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, availableSpace);
2342
+ if (ret[1]) {
2343
+ throw takeFromExternrefTable0(ret[0]);
2344
+ }
2345
+ }
2346
+ /**
2347
+ * Enables rounding of layout values to whole pixels
2348
+ *
2349
+ * When enabled (default), computed layout values like position and size
2350
+ * are rounded to the nearest integer. This prevents sub-pixel rendering
2351
+ * issues in most rendering contexts.
2352
+ *
2353
+ * @example
2354
+ * ```typescript
2355
+ * const tree = new TaffyTree();
2356
+ * tree.enableRounding();
2357
+ * ```
2358
+ */
2359
+ enableRounding() {
2360
+ wasm.taffytree_enableRounding(this.__wbg_ptr);
2361
+ }
2362
+ /**
2363
+ * Disables rounding of layout values
2364
+ *
2365
+ * When disabled, computed layout values retain their fractional precision.
2366
+ * Use this when you need sub-pixel accuracy or when performing custom
2367
+ * rounding.
2368
+ *
2369
+ * @example
2370
+ * ```typescript
2371
+ * const tree = new TaffyTree();
2372
+ * const node = tree.newLeaf(new Style());
2373
+ * tree.disableRounding();
2374
+ * const layout = tree.getLayout(node);
2375
+ * console.log(layout.x);
2376
+ * ```
2377
+ */
2378
+ disableRounding() {
2379
+ wasm.taffytree_disableRounding(this.__wbg_ptr);
2380
+ }
2381
+ /**
2382
+ * Gets the context value for a node
2383
+ *
2384
+ * @param node - The node ID
2385
+ *
2386
+ * @returns - The attached context value, or `undefined` if none is set
2387
+ *
2388
+ * @example
2389
+ * ```typescript
2390
+ * const tree = new TaffyTree();
2391
+ * const nodeId = tree.newLeaf(new Style());
2392
+ * interface Context { text: string };
2393
+ * const context = tree.getNodeContext(nodeId) as Context | undefined;
2394
+ * if (context) {
2395
+ * console.log(context.text);
2396
+ * }
2397
+ * ```
2398
+ * @param {bigint} node
2399
+ * @returns {any}
2400
+ */
2401
+ getNodeContext(node) {
2402
+ const ret = wasm.taffytree_getNodeContext(this.__wbg_ptr, node);
2403
+ if (ret[2]) {
2404
+ throw takeFromExternrefTable0(ret[1]);
2405
+ }
2406
+ return takeFromExternrefTable0(ret[0]);
2407
+ }
2408
+ /**
2409
+ * Sets a context value for a node
2410
+ *
2411
+ * The context can be any JavaScript value and is passed to the measure
2412
+ * function during layout computation.
2413
+ *
2414
+ * @param node - The node ID
2415
+ * @param context - Any JavaScript value to attach
2416
+ *
2417
+ * @throws `TaffyError` if the node does not exist
2418
+ *
2419
+ * @example
2420
+ * ```typescript
2421
+ * const tree = new TaffyTree();
2422
+ * const nodeId = tree.newLeaf(new Style());
2423
+ * interface Context { text: string };
2424
+ * tree.setNodeContext(nodeId, { text: "Updated text" } as Context);
2425
+ * ```
2426
+ * @param {bigint} node
2427
+ * @param {any} context
2428
+ */
2429
+ setNodeContext(node, context) {
2430
+ const ret = wasm.taffytree_setNodeContext(this.__wbg_ptr, node, context);
2431
+ if (ret[1]) {
2432
+ throw takeFromExternrefTable0(ret[0]);
2433
+ }
2434
+ }
2435
+ /**
2436
+ * Gets the total number of nodes in the tree
2437
+ *
2438
+ * @returns - The total count of all nodes
2439
+ *
2440
+ * @example
2441
+ * ```typescript
2442
+ * const tree = new TaffyTree();
2443
+ * const count: number = tree.totalNodeCount();
2444
+ * ```
2445
+ * @returns {number}
2446
+ */
2447
+ totalNodeCount() {
2448
+ const ret = wasm.taffytree_totalNodeCount(this.__wbg_ptr);
2449
+ return ret >>> 0;
2450
+ }
2451
+ /**
2452
+ * Gets the unrounded (fractional) layout for a node
2453
+ *
2454
+ * Returns the raw computed values before any rounding is applied.
2455
+ * Useful when you need sub-pixel precision.
2456
+ *
2457
+ * @param node - The node ID
2458
+ *
2459
+ * @returns - The unrounded `Layout`
2460
+ *
2461
+ * @example
2462
+ * ```typescript
2463
+ * const tree = new TaffyTree();
2464
+ * const nodeId = tree.newLeaf(new Style());
2465
+ * const layout: Layout = tree.unroundedLayout(nodeId);
2466
+ * console.log(`Exact width: ${layout.width}`);
2467
+ * ```
2468
+ * @param {bigint} node
2469
+ * @returns {Layout}
2470
+ */
2471
+ unroundedLayout(node) {
2472
+ const ret = wasm.taffytree_unroundedLayout(this.__wbg_ptr, node);
2473
+ return Layout.__wrap(ret);
2474
+ }
2475
+ /**
2476
+ * Creates a new node with the given children
2477
+ *
2478
+ * Use this to create container nodes that have child elements.
2479
+ * The children must already exist in the tree.
2480
+ *
2481
+ * @param style - The style configuration for the node
2482
+ * @param children - Array of child node IDs (as BigUint64Array)
2483
+ *
2484
+ * @returns - The node ID (`bigint`)
2485
+ *
2486
+ * @throws `TaffyError` if the node cannot be created
2487
+ *
2488
+ * @example
2489
+ * ```typescript
2490
+ * const tree = new TaffyTree();
2491
+ * const containerStyle = new Style();
2492
+ * containerStyle.display = Display.Flex;
2493
+ *
2494
+ * const child1: bigint = tree.newLeaf(new Style());
2495
+ * const child2: bigint = tree.newLeaf(new Style());
2496
+ *
2497
+ * const container: bigint = tree.newWithChildren(
2498
+ * containerStyle,
2499
+ * BigUint64Array.from([child1, child2])
2500
+ * );
2501
+ * ```
2502
+ * @param {Style} style
2503
+ * @param {BigUint64Array} children
2504
+ * @returns {bigint}
2505
+ */
2506
+ newWithChildren(style, children) {
2507
+ _assertClass(style, Style);
2508
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2509
+ const len0 = WASM_VECTOR_LEN;
2510
+ const ret = wasm.taffytree_newWithChildren(this.__wbg_ptr, style.__wbg_ptr, ptr0, len0);
2511
+ if (ret[2]) {
2512
+ throw takeFromExternrefTable0(ret[1]);
2513
+ }
2514
+ return BigInt.asUintN(64, ret[0]);
2515
+ }
2516
+ /**
2517
+ * Gets the child at a specific index
2518
+ *
2519
+ * @param parent - The parent node ID
2520
+ * @param index - The index of the child (0-based)
2521
+ *
2522
+ * @returns - The child node ID (`bigint`)
2523
+ *
2524
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2525
+ *
2526
+ * @example
2527
+ * ```typescript
2528
+ * const tree = new TaffyTree();
2529
+ * const parentId = tree.newLeaf(new Style());
2530
+ * const childId = tree.newLeaf(new Style());
2531
+ * tree.addChild(parentId, childId);
2532
+ * const firstChild: bigint = tree.getChildAtIndex(parentId, 0);
2533
+ * ```
2534
+ * @param {bigint} parent
2535
+ * @param {number} index
2536
+ * @returns {bigint}
2537
+ */
2538
+ getChildAtIndex(parent, index) {
2539
+ const ret = wasm.taffytree_getChildAtIndex(this.__wbg_ptr, parent, index);
2540
+ if (ret[2]) {
2541
+ throw takeFromExternrefTable0(ret[1]);
2542
+ }
2543
+ return BigInt.asUintN(64, ret[0]);
2544
+ }
2545
+ /**
2546
+ * Gets detailed layout information for grid layouts
2547
+ *
2548
+ * @note
2549
+ * This method is only available when the `detailed_layout_info`
2550
+ * feature is enabled.
2551
+ *
2552
+ * @param node - The node ID
2553
+ *
2554
+ * @returns - Detailed grid info or "None" for non-grid nodes
2555
+ *
2556
+ * @throws `TaffyError` if the node does not exist
2557
+ * @param {bigint} node
2558
+ * @returns {any}
2559
+ */
2560
+ detailedLayoutInfo(node) {
2561
+ const ret = wasm.taffytree_detailedLayoutInfo(this.__wbg_ptr, node);
2562
+ if (ret[2]) {
2563
+ throw takeFromExternrefTable0(ret[1]);
2564
+ }
2565
+ return takeFromExternrefTable0(ret[0]);
2566
+ }
2567
+ /**
2568
+ * Gets a mutable reference to the context value for a node
2569
+ *
2570
+ * In JavaScript, this behaves the same as `getNodeContext()` since
2571
+ * JavaScript objects are always passed by reference.
2572
+ *
2573
+ * @param node - The node ID
2574
+ *
2575
+ * @returns - The attached context value, or `undefined` if none is set
2576
+ * @param {bigint} node
2577
+ * @returns {any}
2578
+ */
2579
+ getNodeContextMut(node) {
2580
+ const ret = wasm.taffytree_getNodeContextMut(this.__wbg_ptr, node);
2581
+ if (ret[2]) {
2582
+ throw takeFromExternrefTable0(ret[1]);
2583
+ }
2584
+ return takeFromExternrefTable0(ret[0]);
2585
+ }
2586
+ /**
2587
+ * Inserts a child at a specific index
2588
+ *
2589
+ * @param parent - The parent node ID
2590
+ * @param index - The position to insert at (0-based)
2591
+ * @param child - The child node ID to insert
2592
+ *
2593
+ * @throws `TaffyError` if the parent or child node does not exist, or index is out of bounds
2594
+ *
2595
+ * @example
2596
+ * ```typescript
2597
+ * const tree = new TaffyTree();
2598
+ * const parentId = tree.newLeaf(new Style());
2599
+ * const childId = tree.newLeaf(new Style());
2600
+ * tree.insertChildAtIndex(parentId, 0, childId);
2601
+ * ```
2602
+ * @param {bigint} parent
2603
+ * @param {number} index
2604
+ * @param {bigint} child
2605
+ */
2606
+ insertChildAtIndex(parent, index, child) {
2607
+ const ret = wasm.taffytree_insertChildAtIndex(this.__wbg_ptr, parent, index, child);
2608
+ if (ret[1]) {
2609
+ throw takeFromExternrefTable0(ret[0]);
2610
+ }
2611
+ }
2612
+ /**
2613
+ * Creates a new leaf node with an attached context value
2614
+ *
2615
+ * The context can be any JavaScript value and is passed to the measure
2616
+ * function during layout computation. This is useful for storing
2617
+ * references to text content or other dynamic data.
2618
+ *
2619
+ * @param style - The style configuration for the node
2620
+ * @param context - Any JavaScript value to attach to the node
2621
+ * @returns - The node ID (`bigint`)
2622
+ * @throws `TaffyError` if the node cannot be created
2623
+ *
2624
+ * @example
2625
+ * ```typescript
2626
+ * interface TextContext { text: string; isBold: boolean; }
2627
+ *
2628
+ * const tree = new TaffyTree();
2629
+ * const style = new Style();
2630
+ * const context: TextContext = { text: "Hello, World!", isBold: true };
2631
+ * const nodeId: bigint = tree.newLeafWithContext(style, context);
2632
+ * ```
2633
+ * @param {Style} style
2634
+ * @param {any} context
2635
+ * @returns {bigint}
2636
+ */
2637
+ newLeafWithContext(style, context) {
2638
+ _assertClass(style, Style);
2639
+ const ret = wasm.taffytree_newLeafWithContext(this.__wbg_ptr, style.__wbg_ptr, context);
2640
+ if (ret[2]) {
2641
+ throw takeFromExternrefTable0(ret[1]);
2642
+ }
2643
+ return BigInt.asUintN(64, ret[0]);
2644
+ }
2645
+ /**
2646
+ * Removes a child at a specific index
2647
+ *
2648
+ * @param parent - The parent node ID
2649
+ * @param index - The index of the child to remove (0-based)
2650
+ *
2651
+ * @returns - The removed child ID (`bigint`)
2652
+ *
2653
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2654
+ *
2655
+ * @example
2656
+ * ```typescript
2657
+ * const tree = new TaffyTree();
2658
+ * const parentId = tree.newLeaf(new Style());
2659
+ * const childId = tree.newLeaf(new Style());
2660
+ * tree.addChild(parentId, childId);
2661
+ * const removedId: bigint = tree.removeChildAtIndex(parentId, 0);
2662
+ * ```
2663
+ * @param {bigint} parent
2664
+ * @param {number} index
2665
+ * @returns {bigint}
2666
+ */
2667
+ removeChildAtIndex(parent, index) {
2668
+ const ret = wasm.taffytree_removeChildAtIndex(this.__wbg_ptr, parent, index);
2669
+ if (ret[2]) {
2670
+ throw takeFromExternrefTable0(ret[1]);
2671
+ }
2672
+ return BigInt.asUintN(64, ret[0]);
2673
+ }
2674
+ /**
2675
+ * Removes a range of children
2676
+ *
2677
+ * Removes children from `start_index` (inclusive) to `end_index` (exclusive).
2678
+ *
2679
+ * @param parent - The parent node ID
2680
+ * @param startIndex - Start of range (inclusive)
2681
+ * @param endIndex - End of range (exclusive)
2682
+ *
2683
+ * @throws `TaffyError` if the parent node does not exist or range is invalid
2684
+ *
2685
+ * @example
2686
+ * ```typescript
2687
+ * const tree = new TaffyTree();
2688
+ * const parentId = tree.newLeaf(new Style());
2689
+ * const child1 = tree.newLeaf(new Style());
2690
+ * const child2 = tree.newLeaf(new Style());
2691
+ * const child3 = tree.newLeaf(new Style());
2692
+ * tree.setChildren(parentId, BigUint64Array.from([child1, child2, child3]));
2693
+ *
2694
+ * tree.removeChildrenRange(parentId, 1, 3);
2695
+ * ```
2696
+ * @param {bigint} parent
2697
+ * @param {number} startIndex
2698
+ * @param {number} endIndex
2699
+ */
2700
+ removeChildrenRange(parent, startIndex, endIndex) {
2701
+ const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, startIndex, endIndex);
2702
+ if (ret[1]) {
2703
+ throw takeFromExternrefTable0(ret[0]);
2704
+ }
2705
+ }
2706
+ /**
2707
+ * Replaces a child at a specific index
2708
+ *
2709
+ * @param parent - The parent node ID
2710
+ * @param index - The index of the child to replace (0-based)
2711
+ * @param newChild - The new child node ID
2712
+ *
2713
+ * @returns - The replaced (old) child ID (`bigint`)
2714
+ *
2715
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2716
+ *
2717
+ * @example
2718
+ * ```typescript
2719
+ * const tree = new TaffyTree();
2720
+ * const parentId = tree.newLeaf(new Style());
2721
+ * const oldChild = tree.newLeaf(new Style());
2722
+ * const newChildId = tree.newLeaf(new Style());
2723
+ * tree.addChild(parentId, oldChild);
2724
+ * const child = tree.newLeaf(new Style()); // filler child at index 0 if needed, but index 1 implies 2 children
2725
+ * tree.insertChildAtIndex(parentId, 0, child);
2726
+ *
2727
+ * const oldChildId: bigint = tree.replaceChildAtIndex(parentId, 1, newChildId);
2728
+ * ```
2729
+ * @param {bigint} parent
2730
+ * @param {number} index
2731
+ * @param {bigint} newChild
2732
+ * @returns {bigint}
2733
+ */
2734
+ replaceChildAtIndex(parent, index, newChild) {
2735
+ const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, newChild);
2736
+ if (ret[2]) {
2737
+ throw takeFromExternrefTable0(ret[1]);
2738
+ }
2739
+ return BigInt.asUintN(64, ret[0]);
2740
+ }
2741
+ /**
2742
+ * Computes layout with a custom measure function for leaf nodes
2743
+ *
2744
+ * Use this when you have leaf nodes with dynamic content (like text)
2745
+ * that needs to be measured during layout. The measure function is
2746
+ * called for each leaf node that needs measurement.
2747
+ *
2748
+ * @param node - The root node ID to compute layout for
2749
+ * @param availableSpace - The available space constraints
2750
+ * @param measureFunc - A function that measures leaf node content
2751
+ *
2752
+ * @throws `TaffyError` if the node does not exist or available space is invalid
2753
+ *
2754
+ * @example
2755
+ * ```typescript
2756
+ * const tree = new TaffyTree();
2757
+ * const rootId = tree.newLeaf(new Style());
2758
+ *
2759
+ * const measureText = (text: string, width: number) => ({ width: 0, height: 0 });
2760
+ *
2761
+ * tree.computeLayoutWithMeasure(
2762
+ * rootId,
2763
+ * { width: 800, height: "max-content" },
2764
+ * (known, available, node, context, style) => {
2765
+ * if (context?.text) {
2766
+ * const measured = measureText(context.text, available.width as number);
2767
+ * return { width: measured.width, height: measured.height };
2768
+ * }
2769
+ * return { width: 0, height: 0 };
2770
+ * }
2771
+ * );
2772
+ * ```
2773
+ * @param {bigint} node
2774
+ * @param {Size<AvailableSpace>} availableSpace
2775
+ * @param {MeasureFunction} measureFunc
2776
+ */
2777
+ computeLayoutWithMeasure(node, availableSpace, measureFunc) {
2778
+ const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, availableSpace, measureFunc);
2779
+ if (ret[1]) {
2780
+ throw takeFromExternrefTable0(ret[0]);
2781
+ }
2782
+ }
2783
+ /**
2784
+ * Gets context values for multiple nodes at once
2785
+ *
2786
+ * This is more efficient than calling `getNodeContext()` multiple times
2787
+ * when you need to access contexts for many nodes.
2788
+ *
2789
+ * @param children - Array of node IDs
2790
+ *
2791
+ * @returns - Array of context values (undefined for nodes without context)
2792
+ *
2793
+ * @example
2794
+ * ```typescript
2795
+ * const tree = new TaffyTree();
2796
+ * const id1 = tree.newLeaf(new Style());
2797
+ * const id2 = tree.newLeaf(new Style());
2798
+ * const nodes = BigUint64Array.from([id1, id2]);
2799
+ * const contexts = tree.getDisjointNodeContextMut(nodes);
2800
+ * ```
2801
+ * @param {BigUint64Array} children
2802
+ * @returns {any[]}
2803
+ */
2804
+ getDisjointNodeContextMut(children) {
2805
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2806
+ const len0 = WASM_VECTOR_LEN;
2807
+ const ret = wasm.taffytree_getDisjointNodeContextMut(this.__wbg_ptr, ptr0, len0);
2808
+ if (ret[3]) {
2809
+ throw takeFromExternrefTable0(ret[2]);
2810
+ }
2811
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
2812
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2813
+ return v2;
2814
+ }
2815
+ /**
2816
+ * Creates a new empty TaffyTree
2817
+ *
2818
+ * The tree starts with no nodes. Use `newLeaf()` or `newWithChildren()`
2819
+ * to add nodes.
2820
+ *
2821
+ * @example
2822
+ * ```typescript
2823
+ * const tree: TaffyTree = new TaffyTree();
2824
+ * ```
2825
+ */
2826
+ constructor() {
2827
+ const ret = wasm.taffytree_new();
2828
+ this.__wbg_ptr = ret >>> 0;
2829
+ TaffyTreeFinalization.register(this, this.__wbg_ptr, this);
2830
+ return this;
2831
+ }
2832
+ /**
2833
+ * Removes all nodes from the tree
2834
+ *
2835
+ * This clears the entire tree, removing all nodes and their relationships.
2836
+ * Use this to reset the tree for reuse.
2837
+ *
2838
+ * @example
2839
+ * ```typescript
2840
+ * const tree = new TaffyTree();
2841
+ * tree.clear();
2842
+ * console.log(tree.totalNodeCount());
2843
+ * ```
2844
+ */
2845
+ clear() {
2846
+ wasm.taffytree_clear(this.__wbg_ptr);
2847
+ }
2848
+ /**
2849
+ * Checks if a node is dirty (needs re-layout)
2850
+ *
2851
+ * A node is dirty if its style or content has changed since the last
2852
+ * layout computation.
2853
+ *
2854
+ * @param node - The node ID to check
2855
+ *
2856
+ * @returns - true if dirty, false otherwise
2857
+ *
2858
+ * @throws `TaffyError` if the node does not exist
2859
+ *
2860
+ * @example
2861
+ * ```typescript
2862
+ * const tree = new TaffyTree();
2863
+ * const rootId = tree.newLeaf(new Style());
2864
+ * const nodeId = rootId;
2865
+ * const availableSpace = { width: 100, height: 100 };
2866
+ *
2867
+ * if (tree.dirty(nodeId)) {
2868
+ * tree.computeLayout(rootId, availableSpace);
2869
+ * }
2870
+ * ```
2871
+ * @param {bigint} node
2872
+ * @returns {boolean}
2873
+ */
2874
+ dirty(node) {
2875
+ const ret = wasm.taffytree_dirty(this.__wbg_ptr, node);
2876
+ if (ret[2]) {
2877
+ throw takeFromExternrefTable0(ret[1]);
2878
+ }
2879
+ return ret[0] !== 0;
2880
+ }
2881
+ /**
2882
+ * Gets the style for a node
2883
+ *
2884
+ * @param node - The node ID
2885
+ *
2886
+ * @returns - The node's `Style`
2887
+ *
2888
+ * @throws `TaffyError` if the node does not exist
2889
+ *
2890
+ * @example
2891
+ * ```typescript
2892
+ * const tree = new TaffyTree();
2893
+ * const nodeId = tree.newLeaf(new Style());
2894
+ * const style: Style = tree.getStyle(nodeId);
2895
+ * console.log('Flex grow:', style.flexGrow);
2896
+ * ```
2897
+ * @param {bigint} node
2898
+ * @returns {Style}
2899
+ */
2900
+ getStyle(node) {
2901
+ const ret = wasm.taffytree_getStyle(this.__wbg_ptr, node);
2902
+ if (ret[2]) {
2903
+ throw takeFromExternrefTable0(ret[1]);
2904
+ }
2905
+ return Style.__wrap(ret[0]);
2906
+ }
2907
+ /**
2908
+ * Gets the computed layout for a node
2909
+ *
2910
+ * Call this after `computeLayout()` to retrieve the computed position
2911
+ * and size for a node.
2912
+ *
2913
+ * @param node - The node ID
2914
+ *
2915
+ * @returns - The computed `Layout`
2916
+ *
2917
+ * @throws `TaffyError` if the node does not exist
2918
+ *
2919
+ * @example
2920
+ * ```typescript
2921
+ * const tree = new TaffyTree();
2922
+ * const style = new Style();
2923
+ * style.size = { width: 100, height: 100 };
2924
+ * const rootId = tree.newLeaf(style);
2925
+ * const nodeId = rootId;
2926
+ *
2927
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
2928
+ * const layout: Layout = tree.getLayout(nodeId);
2929
+ * console.log(`Position: (${layout.x}, ${layout.y}), Size: ${layout.width}x${layout.height}`);
2930
+ * ```
2931
+ * @param {bigint} node
2932
+ * @returns {Layout}
2933
+ */
2934
+ getLayout(node) {
2935
+ const ret = wasm.taffytree_getLayout(this.__wbg_ptr, node);
2936
+ if (ret[2]) {
2937
+ throw takeFromExternrefTable0(ret[1]);
2938
+ }
2939
+ return Layout.__wrap(ret[0]);
2940
+ }
2941
+ /**
2942
+ * Gets the parent of a node
2943
+ *
2944
+ * @param child - The child node ID
2945
+ *
2946
+ * @returns - The parent node ID, or `undefined` if the node has no parent
2947
+ *
2948
+ * @example
2949
+ * ```typescript
2950
+ * const tree = new TaffyTree();
2951
+ * const parentId = tree.newLeaf(new Style());
2952
+ * const childId = tree.newLeaf(new Style());
2953
+ * tree.addChild(parentId, childId);
2954
+ * const parent: bigint | undefined = tree.parent(childId);
2955
+ * ```
2956
+ * @param {bigint} child
2957
+ * @returns {bigint | undefined}
2958
+ */
2959
+ parent(child) {
2960
+ const ret = wasm.taffytree_parent(this.__wbg_ptr, child);
2961
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
2962
+ }
2963
+ /**
2964
+ * Removes a node from the tree
2965
+ *
2966
+ * The node and all its descendants are removed. If the node has a parent,
2967
+ * it is automatically removed from the parent's children.
2968
+ *
2969
+ * @param node - The node ID to remove
2970
+ *
2971
+ * @returns - The removed node ID (`bigint`)
2972
+ *
2973
+ * @throws `TaffyError` if the node does not exist
2974
+ *
2975
+ * @example
2976
+ * ```typescript
2977
+ * const tree = new TaffyTree();
2978
+ * const nodeId = tree.newLeaf(new Style());
2979
+ * try {
2980
+ * const removedId: bigint = tree.remove(nodeId);
2981
+ * } catch (e) {
2982
+ * console.error("Node doesn't exist");
2983
+ * }
2984
+ * ```
2985
+ * @param {bigint} node
2986
+ * @returns {bigint}
2987
+ */
2988
+ remove(node) {
2989
+ const ret = wasm.taffytree_remove(this.__wbg_ptr, node);
2990
+ if (ret[2]) {
2991
+ throw takeFromExternrefTable0(ret[1]);
2992
+ }
2993
+ return BigInt.asUintN(64, ret[0]);
2994
+ }
2995
+ /**
2996
+ * Gets all children of a node
2997
+ *
2998
+ * @param parent - The parent node ID
2999
+ *
3000
+ * @returns - Array of child node IDs (`BigUint64Array`)
3001
+ *
3002
+ * @throws `TaffyError` if the parent node does not exist
3003
+ *
3004
+ * @example
3005
+ * ```typescript
3006
+ * const tree = new TaffyTree();
3007
+ * const parentId = tree.newLeaf(new Style());
3008
+ * const children: BigUint64Array = tree.children(parentId);
3009
+ * ```
3010
+ * @param {bigint} parent
3011
+ * @returns {BigUint64Array}
3012
+ */
3013
+ children(parent) {
3014
+ const ret = wasm.taffytree_children(this.__wbg_ptr, parent);
3015
+ if (ret[3]) {
3016
+ throw takeFromExternrefTable0(ret[2]);
3017
+ }
3018
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
3019
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3020
+ return v1;
3021
+ }
3022
+ /**
3023
+ * Creates a new leaf node with the given style
3024
+ *
3025
+ * A leaf node has no children. Use this for elements that contain
3026
+ * content (like text) rather than other elements.
3027
+ *
3028
+ * @param style - The style configuration for the node
3029
+ * @returns - The node ID (`bigint`)
3030
+ * @throws `TaffyError` if the node cannot be created
3031
+ *
3032
+ * @example
3033
+ * ```typescript
3034
+ * const tree = new TaffyTree();
3035
+ * const style = new Style();
3036
+ * style.size = { width: 100, height: 50 };
3037
+ * const nodeId: bigint = tree.newLeaf(style);
3038
+ * ```
3039
+ * @param {Style} style
3040
+ * @returns {bigint}
3041
+ */
3042
+ newLeaf(style) {
3043
+ _assertClass(style, Style);
3044
+ const ret = wasm.taffytree_newLeaf(this.__wbg_ptr, style.__wbg_ptr);
3045
+ if (ret[2]) {
3046
+ throw takeFromExternrefTable0(ret[1]);
3047
+ }
3048
+ return BigInt.asUintN(64, ret[0]);
3049
+ }
3050
+ /**
3051
+ * Appends a child node to a parent
3052
+ *
3053
+ * The child is added as the last child of the parent.
3054
+ *
3055
+ * @param parent - The parent node ID
3056
+ * @param child - The child node ID to add
3057
+ *
3058
+ * @throws `TaffyError` if the parent or child node does not exist
3059
+ *
3060
+ * @example
3061
+ * ```typescript
3062
+ * const tree = new TaffyTree();
3063
+ * const parentId = tree.newLeaf(new Style());
3064
+ * const childId = tree.newLeaf(new Style());
3065
+ * tree.addChild(parentId, childId);
3066
+ * ```
3067
+ * @param {bigint} parent
3068
+ * @param {bigint} child
3069
+ */
3070
+ addChild(parent, child) {
3071
+ const ret = wasm.taffytree_addChild(this.__wbg_ptr, parent, child);
3072
+ if (ret[1]) {
3073
+ throw takeFromExternrefTable0(ret[0]);
3074
+ }
3075
+ }
3076
+ /**
3077
+ * Sets the style for an existing node
3078
+ *
3079
+ * This replaces the node's current style with the provided one.
3080
+ * The node will be marked as dirty and require re-layout.
3081
+ *
3082
+ * @param node - The node ID
3083
+ * @param style - The new style configuration
3084
+ *
3085
+ * @throws `TaffyError` if the node does not exist
3086
+ *
3087
+ * @example
3088
+ * ```typescript
3089
+ * const tree = new TaffyTree();
3090
+ * const nodeId = tree.newLeaf(new Style());
3091
+ * const newStyle = new Style();
3092
+ * newStyle.flexGrow = 2;
3093
+ * tree.setStyle(nodeId, newStyle);
3094
+ * ```
3095
+ * @param {bigint} node
3096
+ * @param {Style} style
3097
+ */
3098
+ setStyle(node, style) {
3099
+ _assertClass(style, Style);
3100
+ const ret = wasm.taffytree_setStyle(this.__wbg_ptr, node, style.__wbg_ptr);
3101
+ if (ret[1]) {
3102
+ throw takeFromExternrefTable0(ret[0]);
3103
+ }
3104
+ }
3105
+ }
3106
+ if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
3107
+
3108
+ /**
3109
+ * Text alignment enumeration (for block layout)
3110
+ *
3111
+ * Used by block layout to implement the legacy behaviour of `<center>` and
3112
+ * `<div align="left | right | center">`.
3113
+ *
3114
+ * @example
3115
+ * ```typescript
3116
+ * import { Style, TextAlign } from 'taffy-layout';
3117
+ *
3118
+ * const style = new Style();
3119
+ * style.textAlign = TextAlign.LegacyCenter; // Center block children
3120
+ * ```
3121
+ * @enum {0 | 1 | 2 | 3}
3122
+ */
3123
+ export const TextAlign = Object.freeze({
3124
+ /**
3125
+ * No special legacy text align behaviour
3126
+ */
3127
+ Auto: 0, "0": "Auto",
3128
+ /**
3129
+ * Corresponds to `-webkit-left` or `-moz-left` in browsers
3130
+ */
3131
+ LegacyLeft: 1, "1": "LegacyLeft",
3132
+ /**
3133
+ * Corresponds to `-webkit-right` or `-moz-right` in browsers
3134
+ */
3135
+ LegacyRight: 2, "2": "LegacyRight",
3136
+ /**
3137
+ * Corresponds to `-webkit-center` or `-moz-center` in browsers
3138
+ */
3139
+ LegacyCenter: 3, "3": "LegacyCenter",
3140
+ });
3141
+
3142
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
3143
+
3144
+ async function __wbg_load(module, imports) {
3145
+ if (typeof Response === 'function' && module instanceof Response) {
3146
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
3147
+ try {
3148
+ return await WebAssembly.instantiateStreaming(module, imports);
3149
+ } catch (e) {
3150
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
3151
+
3152
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
3153
+ 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);
3154
+
3155
+ } else {
3156
+ throw e;
3157
+ }
3158
+ }
3159
+ }
3160
+
3161
+ const bytes = await module.arrayBuffer();
3162
+ return await WebAssembly.instantiate(bytes, imports);
3163
+ } else {
3164
+ const instance = await WebAssembly.instantiate(module, imports);
3165
+
3166
+ if (instance instanceof WebAssembly.Instance) {
3167
+ return { instance, module };
3168
+ } else {
3169
+ return instance;
3170
+ }
3171
+ }
3172
+ }
3173
+
3174
+ function __wbg_get_imports() {
3175
+ const imports = {};
3176
+ imports.wbg = {};
3177
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
3178
+ const ret = Error(getStringFromWasm0(arg0, arg1));
3179
+ return ret;
3180
+ };
3181
+ imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
3182
+ const ret = Number(arg0);
3183
+ return ret;
3184
+ };
3185
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
3186
+ const ret = String(arg1);
3187
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3188
+ const len1 = WASM_VECTOR_LEN;
3189
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3190
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3191
+ };
3192
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
3193
+ const v = arg1;
3194
+ const ret = typeof(v) === 'bigint' ? v : undefined;
3195
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
3196
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
3197
+ };
3198
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
3199
+ const v = arg0;
3200
+ const ret = typeof(v) === 'boolean' ? v : undefined;
3201
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
3202
+ };
3203
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
3204
+ const ret = debugString(arg1);
3205
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3206
+ const len1 = WASM_VECTOR_LEN;
3207
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3208
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3209
+ };
3210
+ imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
3211
+ const ret = arg0 in arg1;
3212
+ return ret;
3213
+ };
3214
+ imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
3215
+ const ret = typeof(arg0) === 'bigint';
3216
+ return ret;
3217
+ };
3218
+ imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
3219
+ const ret = typeof(arg0) === 'function';
3220
+ return ret;
3221
+ };
3222
+ imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
3223
+ const ret = arg0 === null;
3224
+ return ret;
3225
+ };
3226
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
3227
+ const val = arg0;
3228
+ const ret = typeof(val) === 'object' && val !== null;
3229
+ return ret;
3230
+ };
3231
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
3232
+ const ret = arg0 === undefined;
3233
+ return ret;
3234
+ };
3235
+ imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
3236
+ const ret = arg0 === arg1;
3237
+ return ret;
3238
+ };
3239
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
3240
+ const ret = arg0 == arg1;
3241
+ return ret;
3242
+ };
3243
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
3244
+ const obj = arg1;
3245
+ const ret = typeof(obj) === 'number' ? obj : undefined;
3246
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
3247
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
3248
+ };
3249
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
3250
+ const obj = arg1;
3251
+ const ret = typeof(obj) === 'string' ? obj : undefined;
3252
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3253
+ var len1 = WASM_VECTOR_LEN;
3254
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3255
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3256
+ };
3257
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
3258
+ throw new Error(getStringFromWasm0(arg0, arg1));
3259
+ };
3260
+ imports.wbg.__wbg_apply_52e9ae668d017009 = function() { return handleError(function (arg0, arg1, arg2) {
3261
+ const ret = arg0.apply(arg1, arg2);
3262
+ return ret;
3263
+ }, arguments) };
3264
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
3265
+ const ret = arg0.call(arg1);
3266
+ return ret;
3267
+ }, arguments) };
3268
+ imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
3269
+ const ret = arg0.done;
3270
+ return ret;
3271
+ };
3272
+ imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
3273
+ const ret = Object.entries(arg0);
3274
+ return ret;
3275
+ };
3276
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
3277
+ let deferred0_0;
3278
+ let deferred0_1;
3279
+ try {
3280
+ deferred0_0 = arg0;
3281
+ deferred0_1 = arg1;
3282
+ console.error(getStringFromWasm0(arg0, arg1));
3283
+ } finally {
3284
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
3285
+ }
3286
+ };
3287
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
3288
+ const ret = arg0[arg1 >>> 0];
3289
+ return ret;
3290
+ };
3291
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
3292
+ const ret = Reflect.get(arg0, arg1);
3293
+ return ret;
3294
+ }, arguments) };
3295
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
3296
+ const ret = arg0[arg1];
3297
+ return ret;
3298
+ };
3299
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
3300
+ let result;
3301
+ try {
3302
+ result = arg0 instanceof ArrayBuffer;
3303
+ } catch (_) {
3304
+ result = false;
3305
+ }
3306
+ const ret = result;
3307
+ return ret;
3308
+ };
3309
+ imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
3310
+ let result;
3311
+ try {
3312
+ result = arg0 instanceof Map;
3313
+ } catch (_) {
3314
+ result = false;
3315
+ }
3316
+ const ret = result;
3317
+ return ret;
3318
+ };
3319
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
3320
+ let result;
3321
+ try {
3322
+ result = arg0 instanceof Uint8Array;
3323
+ } catch (_) {
3324
+ result = false;
3325
+ }
3326
+ const ret = result;
3327
+ return ret;
3328
+ };
3329
+ imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
3330
+ const ret = Array.isArray(arg0);
3331
+ return ret;
3332
+ };
3333
+ imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
3334
+ const ret = Number.isSafeInteger(arg0);
3335
+ return ret;
3336
+ };
3337
+ imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
3338
+ const ret = Symbol.iterator;
3339
+ return ret;
3340
+ };
3341
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
3342
+ const ret = arg0.length;
3343
+ return ret;
3344
+ };
3345
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
3346
+ const ret = arg0.length;
3347
+ return ret;
3348
+ };
3349
+ imports.wbg.__wbg_log_725a3bd25b473a36 = function(arg0, arg1) {
3350
+ console.log(getStringFromWasm0(arg0, arg1));
3351
+ };
3352
+ imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
3353
+ const ret = new Object();
3354
+ return ret;
3355
+ };
3356
+ imports.wbg.__wbg_new_25f239778d6112b9 = function() {
3357
+ const ret = new Array();
3358
+ return ret;
3359
+ };
3360
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
3361
+ const ret = new Uint8Array(arg0);
3362
+ return ret;
3363
+ };
3364
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
3365
+ const ret = new Error();
3366
+ return ret;
3367
+ };
3368
+ imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
3369
+ const ret = arg0.next;
3370
+ return ret;
3371
+ };
3372
+ imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
3373
+ const ret = arg0.next();
3374
+ return ret;
3375
+ }, arguments) };
3376
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
3377
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
3378
+ };
3379
+ imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
3380
+ const ret = arg0.push(arg1);
3381
+ return ret;
3382
+ };
3383
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
3384
+ arg0[arg1] = arg2;
3385
+ };
3386
+ imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
3387
+ arg0[arg1 >>> 0] = arg2;
3388
+ };
3389
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
3390
+ const ret = arg1.stack;
3391
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3392
+ const len1 = WASM_VECTOR_LEN;
3393
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3394
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3395
+ };
3396
+ imports.wbg.__wbg_stringify_655a6390e1f5eb6b = function() { return handleError(function (arg0) {
3397
+ const ret = JSON.stringify(arg0);
3398
+ return ret;
3399
+ }, arguments) };
3400
+ imports.wbg.__wbg_style_new = function(arg0) {
3401
+ const ret = Style.__wrap(arg0);
3402
+ return ret;
3403
+ };
3404
+ imports.wbg.__wbg_taffyerror_new = function(arg0) {
3405
+ const ret = TaffyError.__wrap(arg0);
3406
+ return ret;
3407
+ };
3408
+ imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
3409
+ const ret = arg0.value;
3410
+ return ret;
3411
+ };
3412
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
3413
+ // Cast intrinsic for `Ref(String) -> Externref`.
3414
+ const ret = getStringFromWasm0(arg0, arg1);
3415
+ return ret;
3416
+ };
3417
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
3418
+ // Cast intrinsic for `U64 -> Externref`.
3419
+ const ret = BigInt.asUintN(64, arg0);
3420
+ return ret;
3421
+ };
3422
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
3423
+ // Cast intrinsic for `I64 -> Externref`.
3424
+ const ret = arg0;
3425
+ return ret;
3426
+ };
3427
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
3428
+ // Cast intrinsic for `F64 -> Externref`.
3429
+ const ret = arg0;
3430
+ return ret;
3431
+ };
3432
+ imports.wbg.__wbindgen_init_externref_table = function() {
3433
+ const table = wasm.__wbindgen_externrefs;
3434
+ const offset = table.grow(4);
3435
+ table.set(0, undefined);
3436
+ table.set(offset + 0, undefined);
3437
+ table.set(offset + 1, null);
3438
+ table.set(offset + 2, true);
3439
+ table.set(offset + 3, false);
3440
+ };
3441
+
3442
+ return imports;
3443
+ }
3444
+
3445
+ function __wbg_finalize_init(instance, module) {
3446
+ wasm = instance.exports;
3447
+ __wbg_init.__wbindgen_wasm_module = module;
3448
+ cachedBigUint64ArrayMemory0 = null;
3449
+ cachedDataViewMemory0 = null;
3450
+ cachedUint8ArrayMemory0 = null;
3451
+
3452
+
3453
+ wasm.__wbindgen_start();
3454
+ return wasm;
3455
+ }
3456
+
3457
+ function initSync(module) {
3458
+ if (wasm !== undefined) return wasm;
3459
+
3460
+
3461
+ if (typeof module !== 'undefined') {
3462
+ if (Object.getPrototypeOf(module) === Object.prototype) {
3463
+ ({module} = module)
3464
+ } else {
3465
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
3466
+ }
3467
+ }
3468
+
3469
+ const imports = __wbg_get_imports();
3470
+ if (!(module instanceof WebAssembly.Module)) {
3471
+ module = new WebAssembly.Module(module);
3472
+ }
3473
+ const instance = new WebAssembly.Instance(module, imports);
3474
+ return __wbg_finalize_init(instance, module);
3475
+ }
3476
+
3477
+ async function __wbg_init(module_or_path) {
3478
+ if (wasm !== undefined) return wasm;
3479
+
3480
+
3481
+ if (typeof module_or_path !== 'undefined') {
3482
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
3483
+ ({module_or_path} = module_or_path)
3484
+ } else {
3485
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
3486
+ }
3487
+ }
3488
+
3489
+ if (typeof module_or_path === 'undefined') {
3490
+ module_or_path = new URL('taffy_wasm_bg.wasm', import.meta.url);
3491
+ }
3492
+ const imports = __wbg_get_imports();
3493
+
3494
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
3495
+ module_or_path = fetch(module_or_path);
3496
+ }
3497
+
3498
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
3499
+
3500
+ return __wbg_finalize_init(instance, module);
3501
+ }
3502
+
3503
+ export { initSync };
3504
+ export default __wbg_init;