taffy-js 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/taffy_js.js CHANGED
@@ -77,6 +77,17 @@ function debugString(val) {
77
77
  return className;
78
78
  }
79
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
+
80
91
  function getArrayU64FromWasm0(ptr, len) {
81
92
  ptr = ptr >>> 0;
82
93
  return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
@@ -208,2213 +219,1295 @@ if (!('encodeInto' in cachedTextEncoder)) {
208
219
 
209
220
  let WASM_VECTOR_LEN = 0;
210
221
 
211
- const AvailableSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
212
- ? { register: () => {}, unregister: () => {} }
213
- : new FinalizationRegistry(ptr => wasm.__wbg_availablespace_free(ptr >>> 0, 1));
214
-
215
- const DimensionFinalization = (typeof FinalizationRegistry === 'undefined')
216
- ? { register: () => {}, unregister: () => {} }
217
- : new FinalizationRegistry(ptr => wasm.__wbg_dimension_free(ptr >>> 0, 1));
218
-
219
- const LayoutFinalization = (typeof FinalizationRegistry === 'undefined')
220
- ? { register: () => {}, unregister: () => {} }
221
- : new FinalizationRegistry(ptr => wasm.__wbg_layout_free(ptr >>> 0, 1));
222
-
223
- const LineFinalization = (typeof FinalizationRegistry === 'undefined')
224
- ? { register: () => {}, unregister: () => {} }
225
- : new FinalizationRegistry(ptr => wasm.__wbg_line_free(ptr >>> 0, 1));
226
-
227
- const PointFinalization = (typeof FinalizationRegistry === 'undefined')
228
- ? { register: () => {}, unregister: () => {} }
229
- : new FinalizationRegistry(ptr => wasm.__wbg_point_free(ptr >>> 0, 1));
230
-
231
- const RectFinalization = (typeof FinalizationRegistry === 'undefined')
232
- ? { register: () => {}, unregister: () => {} }
233
- : new FinalizationRegistry(ptr => wasm.__wbg_rect_free(ptr >>> 0, 1));
234
-
235
- const SizeFinalization = (typeof FinalizationRegistry === 'undefined')
236
- ? { register: () => {}, unregister: () => {} }
237
- : new FinalizationRegistry(ptr => wasm.__wbg_size_free(ptr >>> 0, 1));
238
-
239
222
  const StyleFinalization = (typeof FinalizationRegistry === 'undefined')
240
223
  ? { register: () => {}, unregister: () => {} }
241
224
  : new FinalizationRegistry(ptr => wasm.__wbg_style_free(ptr >>> 0, 1));
242
225
 
243
- const TaffyNodeFinalization = (typeof FinalizationRegistry === 'undefined')
244
- ? { register: () => {}, unregister: () => {} }
245
- : new FinalizationRegistry(ptr => wasm.__wbg_taffynode_free(ptr >>> 0, 1));
246
-
247
- const TrackDefinitionFinalization = (typeof FinalizationRegistry === 'undefined')
226
+ const TaffyTreeFinalization = (typeof FinalizationRegistry === 'undefined')
248
227
  ? { register: () => {}, unregister: () => {} }
249
- : new FinalizationRegistry(ptr => wasm.__wbg_trackdefinition_free(ptr >>> 0, 1));
228
+ : new FinalizationRegistry(ptr => wasm.__wbg_taffytree_free(ptr >>> 0, 1));
250
229
 
251
230
  /**
252
- * How lines of content are aligned along the cross axis when there is extra space.
231
+ * Multi-line content alignment enum (Align Content)
232
+ *
233
+ * Controls spacing distribution between lines in a multi-line flex container.
234
+ * Corresponds to CSS `align-content` property. Only effective when `flex-wrap: wrap`.
235
+ *
236
+ * # Variants
237
+ * - `SpaceBetween`: Lines evenly distributed, first/last lines flush with edges
238
+ * - `SpaceAround`: Equal space on both sides of each line
239
+ * - `SpaceEvenly`: All spacing completely equal
253
240
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
254
241
  */
255
242
  export const AlignContent = Object.freeze({
256
- /**
257
- * Lines are packed toward the start of the cross axis.
258
- */
259
243
  Start: 0, "0": "Start",
260
- /**
261
- * Lines are packed toward the end of the cross axis.
262
- */
263
244
  End: 1, "1": "End",
264
- /**
265
- * Lines are packed toward the start of the flex-direction cross axis.
266
- */
267
245
  FlexStart: 2, "2": "FlexStart",
268
- /**
269
- * Lines are packed toward the end of the flex-direction cross axis.
270
- */
271
246
  FlexEnd: 3, "3": "FlexEnd",
272
- /**
273
- * Lines are packed toward the center of the cross axis.
274
- */
275
247
  Center: 4, "4": "Center",
276
- /**
277
- * Lines are evenly distributed; the first line is at the start, the last at the end.
278
- */
279
- SpaceBetween: 5, "5": "SpaceBetween",
280
- /**
281
- * Lines are evenly distributed with equal space around them.
282
- */
283
- SpaceAround: 6, "6": "SpaceAround",
284
- /**
285
- * Lines are evenly distributed with equal space between them.
286
- */
287
- SpaceEvenly: 7, "7": "SpaceEvenly",
288
- /**
289
- * Lines are stretched to take up the remaining space.
290
- */
291
- Stretch: 8, "8": "Stretch",
248
+ Stretch: 5, "5": "Stretch",
249
+ SpaceBetween: 6, "6": "SpaceBetween",
250
+ SpaceAround: 7, "7": "SpaceAround",
251
+ SpaceEvenly: 8, "8": "SpaceEvenly",
292
252
  });
293
253
 
294
254
  /**
295
- * How items are aligned along the cross axis.
255
+ * Cross-axis alignment enum for children (Align Items)
256
+ *
257
+ * Defines how all children are aligned on the cross axis in a Flex/Grid container.
258
+ *
259
+ * # Variants
260
+ * - `Start/FlexStart`: Align to cross axis start
261
+ * - `End/FlexEnd`: Align to cross axis end
262
+ * - `Center`: Center alignment
263
+ * - `Baseline`: Baseline alignment (text baseline)
264
+ * - `Stretch`: Stretch to fill container
296
265
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
297
266
  */
298
267
  export const AlignItems = Object.freeze({
299
- /**
300
- * Items are aligned at the start of the cross axis.
301
- */
302
268
  Start: 0, "0": "Start",
303
- /**
304
- * Items are aligned at the end of the cross axis.
305
- */
306
269
  End: 1, "1": "End",
307
- /**
308
- * Items are aligned at the start of the flex-direction cross axis.
309
- */
310
270
  FlexStart: 2, "2": "FlexStart",
311
- /**
312
- * Items are aligned at the end of the flex-direction cross axis.
313
- */
314
271
  FlexEnd: 3, "3": "FlexEnd",
315
- /**
316
- * Items are aligned at the center of the cross axis.
317
- */
318
272
  Center: 4, "4": "Center",
319
- /**
320
- * Items are aligned based on their baselines.
321
- */
322
273
  Baseline: 5, "5": "Baseline",
323
- /**
324
- * Items are stretched to fill the container along the cross axis.
325
- */
326
274
  Stretch: 6, "6": "Stretch",
327
275
  });
328
276
 
329
277
  /**
330
- * How a single item is aligned along the cross axis, overriding `AlignItems`.
278
+ * Cross-axis alignment enum for single element (Align Self)
279
+ *
280
+ * Overrides parent's `align-items` for a single child element's cross-axis alignment.
281
+ *
282
+ * # Variants
283
+ * - `Auto`: Inherit parent's `align-items` value
284
+ * - Other values have same meaning as `AlignItems`
331
285
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
332
286
  */
333
287
  export const AlignSelf = Object.freeze({
334
- /**
335
- * Auto
336
- */
337
288
  Auto: 0, "0": "Auto",
338
- /**
339
- * items are aligned at the start of the cross axis.
340
- */
341
289
  Start: 1, "1": "Start",
342
- /**
343
- * Items are aligned at the end of the cross axis.
344
- */
345
290
  End: 2, "2": "End",
346
- /**
347
- * Items are aligned at the start of the flex-direction cross axis.
348
- */
349
291
  FlexStart: 3, "3": "FlexStart",
350
- /**
351
- * Items are aligned at the end of the flex-direction cross axis.
352
- */
353
292
  FlexEnd: 4, "4": "FlexEnd",
354
- /**
355
- * Items are aligned at the center of the cross axis.
356
- */
357
293
  Center: 5, "5": "Center",
358
- /**
359
- * Items are aligned based on their baselines.
360
- */
361
294
  Baseline: 6, "6": "Baseline",
362
- /**
363
- * Items are stretched to fill the container along the cross axis.
364
- */
365
295
  Stretch: 7, "7": "Stretch",
366
296
  });
367
297
 
368
298
  /**
369
- * The available space for layout computation.
370
- */
371
- export class AvailableSpace {
372
- __destroy_into_raw() {
373
- const ptr = this.__wbg_ptr;
374
- this.__wbg_ptr = 0;
375
- AvailableSpaceFinalization.unregister(this);
376
- return ptr;
377
- }
378
- free() {
379
- const ptr = this.__destroy_into_raw();
380
- wasm.__wbg_availablespace_free(ptr, 0);
381
- }
382
- /**
383
- * The available width (None means undefined/max-content).
384
- * @returns {number | undefined}
385
- */
386
- get width() {
387
- const ret = wasm.__wbg_get_availablespace_width(this.__wbg_ptr);
388
- return ret === 0x100000001 ? undefined : ret;
389
- }
390
- /**
391
- * The available width (None means undefined/max-content).
392
- * @param {number | null} [arg0]
393
- */
394
- set width(arg0) {
395
- wasm.__wbg_set_availablespace_width(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : Math.fround(arg0));
396
- }
397
- /**
398
- * The available height (None means undefined/max-content).
399
- * @returns {number | undefined}
400
- */
401
- get height() {
402
- const ret = wasm.__wbg_get_availablespace_height(this.__wbg_ptr);
403
- return ret === 0x100000001 ? undefined : ret;
404
- }
405
- /**
406
- * The available height (None means undefined/max-content).
407
- * @param {number | null} [arg0]
408
- */
409
- set height(arg0) {
410
- wasm.__wbg_set_availablespace_height(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : Math.fround(arg0));
411
- }
412
- }
413
- if (Symbol.dispose) AvailableSpace.prototype[Symbol.dispose] = AvailableSpace.prototype.free;
414
-
415
- /**
416
- * Represents a length value in CSS.
417
- * Represents a length value in CSS.
299
+ * Display mode enum
418
300
  *
419
- * This struct corresponds to a dimension value that can be specified in pixels, percentage, or auto.
420
- */
421
- export class Dimension {
422
- static __wrap(ptr) {
423
- ptr = ptr >>> 0;
424
- const obj = Object.create(Dimension.prototype);
425
- obj.__wbg_ptr = ptr;
426
- DimensionFinalization.register(obj, obj.__wbg_ptr, obj);
427
- return obj;
428
- }
429
- __destroy_into_raw() {
430
- const ptr = this.__wbg_ptr;
431
- this.__wbg_ptr = 0;
432
- DimensionFinalization.unregister(this);
433
- return ptr;
434
- }
435
- free() {
436
- const ptr = this.__destroy_into_raw();
437
- wasm.__wbg_dimension_free(ptr, 0);
438
- }
439
- /**
440
- * The numeric value of the dimension.
441
- * - For `Pixels`, this is the number of pixels.
442
- * - For `Percent`, this is the percentage value (0.0 to 100.0, or sometimes 0.0 to 1.0 depending on context, handled by internal logic).
443
- * - For `Auto`, this value is typically ignored.
444
- * @returns {number}
445
- */
446
- get value() {
447
- const ret = wasm.__wbg_get_dimension_value(this.__wbg_ptr);
448
- return ret;
449
- }
450
- /**
451
- * The numeric value of the dimension.
452
- * - For `Pixels`, this is the number of pixels.
453
- * - For `Percent`, this is the percentage value (0.0 to 100.0, or sometimes 0.0 to 1.0 depending on context, handled by internal logic).
454
- * - For `Auto`, this value is typically ignored.
455
- * @param {number} arg0
456
- */
457
- set value(arg0) {
458
- wasm.__wbg_set_dimension_value(this.__wbg_ptr, arg0);
459
- }
460
- /**
461
- * The unit of the dimension.
462
- * @returns {DimensionUnit}
463
- */
464
- get unit() {
465
- const ret = wasm.__wbg_get_dimension_unit(this.__wbg_ptr);
466
- return ret;
467
- }
468
- /**
469
- * The unit of the dimension.
470
- * @param {DimensionUnit} arg0
471
- */
472
- set unit(arg0) {
473
- wasm.__wbg_set_dimension_unit(this.__wbg_ptr, arg0);
474
- }
475
- }
476
- if (Symbol.dispose) Dimension.prototype[Symbol.dispose] = Dimension.prototype.free;
477
-
478
- /**
479
- * The unit of a dimension.
480
- * @enum {0 | 1 | 2}
481
- */
482
- export const DimensionUnit = Object.freeze({
483
- /**
484
- * The dimension is specified in logical pixels.
485
- */
486
- Pixels: 0, "0": "Pixels",
487
- /**
488
- * The dimension is specified as a percentage of the parent's size.
489
- */
490
- Percent: 1, "1": "Percent",
491
- /**
492
- * The dimension is determined automatically based on content or context.
493
- */
494
- Auto: 2, "2": "Auto",
495
- });
496
-
497
- /**
498
- * The display style of a node.
301
+ * Controls the layout algorithm type for an element. Corresponds to CSS `display` property.
302
+ *
303
+ * # Variants
304
+ * - `Block`: Block-level layout, element takes full width
305
+ * - `Flex`: Flexbox layout, one-dimensional layout model
306
+ * - `Grid`: CSS Grid layout, two-dimensional layout model
307
+ * - `None`: Hidden, element does not participate in layout calculation
499
308
  * @enum {0 | 1 | 2 | 3}
500
309
  */
501
310
  export const Display = Object.freeze({
502
- /**
503
- * The node is hidden and does not take up space.
504
- */
505
- None: 0, "0": "None",
506
- /**
507
- * The node behaves as a flex container.
508
- */
311
+ Block: 0, "0": "Block",
509
312
  Flex: 1, "1": "Flex",
510
- /**
511
- * The node behaves as a grid container.
512
- */
513
313
  Grid: 2, "2": "Grid",
514
- /**
515
- * The node behaves as a block element.
516
- */
517
- Block: 3, "3": "Block",
518
- });
519
-
520
- /**
521
- * Start and End are used for logical positioning (e.g. paddingStart).
522
- * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
523
- */
524
- export const Edge = Object.freeze({
525
- Left: 0, "0": "Left",
526
- Right: 1, "1": "Right",
527
- Top: 2, "2": "Top",
528
- Bottom: 3, "3": "Bottom",
529
- Start: 4, "4": "Start",
530
- End: 5, "5": "End",
531
- Horizontal: 6, "6": "Horizontal",
532
- Vertical: 7, "7": "Vertical",
533
- All: 8, "8": "All",
314
+ None: 3, "3": "None",
534
315
  });
535
316
 
536
317
  /**
537
- * The direction of the main axis for a flex container.
318
+ * Flex main axis direction enum
319
+ *
320
+ * Defines the direction children are laid out in a flex container. Corresponds to CSS `flex-direction` property.
321
+ *
322
+ * # Variants
323
+ * - `Row`: Horizontal direction, left to right (LTR mode)
324
+ * - `Column`: Vertical direction, top to bottom
325
+ * - `RowReverse`: Horizontal reverse, right to left
326
+ * - `ColumnReverse`: Vertical reverse, bottom to top
538
327
  * @enum {0 | 1 | 2 | 3}
539
328
  */
540
329
  export const FlexDirection = Object.freeze({
541
- /**
542
- * Items are placed horizontally from left to right.
543
- */
544
330
  Row: 0, "0": "Row",
545
- /**
546
- * Items are placed vertically from top to bottom.
547
- */
548
331
  Column: 1, "1": "Column",
549
- /**
550
- * Items are placed horizontally from right to left.
551
- */
552
332
  RowReverse: 2, "2": "RowReverse",
553
- /**
554
- * Items are placed vertically from bottom to top.
555
- */
556
333
  ColumnReverse: 3, "3": "ColumnReverse",
557
334
  });
558
335
 
559
336
  /**
560
- * Whether flex items are forced into a single line or can wrap onto multiple lines.
337
+ * Flex wrap mode enum
338
+ *
339
+ * Controls whether flex items wrap onto multiple lines. Corresponds to CSS `flex-wrap` property.
340
+ *
341
+ * # Variants
342
+ * - `NoWrap`: No wrapping, all items compressed into single line/column
343
+ * - `Wrap`: Automatic wrapping, items flow to next line when container overflows
344
+ * - `WrapReverse`: Reverse wrapping, new lines appear above or to the left
561
345
  * @enum {0 | 1 | 2}
562
346
  */
563
347
  export const FlexWrap = Object.freeze({
564
- /**
565
- * Items are forced into a single line.
566
- */
567
348
  NoWrap: 0, "0": "NoWrap",
568
- /**
569
- * Items wrap onto multiple lines.
570
- */
571
349
  Wrap: 1, "1": "Wrap",
572
- /**
573
- * Items wrap onto multiple lines in reverse order.
574
- */
575
350
  WrapReverse: 2, "2": "WrapReverse",
576
351
  });
577
352
 
578
353
  /**
579
- * Grid auto-placement algorithm controls how auto-placed items get flowed into the grid.
580
- * @enum {0 | 1 | 2 | 3}
354
+ * Main axis alignment enum (Justify Content)
355
+ *
356
+ * Defines alignment and spacing distribution of children along the main axis.
357
+ * Corresponds to CSS `justify-content` property.
358
+ *
359
+ * # Variants
360
+ * - `Start/FlexStart`: Align to main axis start
361
+ * - `End/FlexEnd`: Align to main axis end
362
+ * - `Center`: Center alignment
363
+ * - `SpaceBetween`: First and last items flush with edges, remaining space distributed evenly
364
+ * - `SpaceAround`: Equal space on both sides of each item
365
+ * - `SpaceEvenly`: All spacing completely equal
366
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
581
367
  */
582
- export const GridAutoFlow = Object.freeze({
583
- /**
584
- * Items are placed by filling each row in turn, adding new rows as necessary.
585
- */
586
- Row: 0, "0": "Row",
587
- /**
588
- * Items are placed by filling each column in turn, adding new columns as necessary.
589
- */
590
- Column: 1, "1": "Column",
591
- /**
592
- * Items are placed by filling each row, attempting to fill holes earlier in the grid.
593
- */
594
- RowDense: 2, "2": "RowDense",
595
- /**
596
- * Items are placed by filling each column, attempting to fill holes earlier in the grid.
597
- */
598
- ColumnDense: 3, "3": "ColumnDense",
368
+ export const JustifyContent = Object.freeze({
369
+ Start: 0, "0": "Start",
370
+ End: 1, "1": "End",
371
+ FlexStart: 2, "2": "FlexStart",
372
+ FlexEnd: 3, "3": "FlexEnd",
373
+ Center: 4, "4": "Center",
374
+ Stretch: 5, "5": "Stretch",
375
+ SpaceBetween: 6, "6": "SpaceBetween",
376
+ SpaceAround: 7, "7": "SpaceAround",
377
+ SpaceEvenly: 8, "8": "SpaceEvenly",
599
378
  });
600
379
 
601
380
  /**
602
- * @enum {0 | 1 | 2}
381
+ * Overflow handling enum
382
+ *
383
+ * Defines how content that overflows container boundaries is handled.
384
+ * Corresponds to CSS `overflow` property.
385
+ *
386
+ * # Variants
387
+ * - `Visible`: Content is not clipped
388
+ * - `Hidden`: Content is clipped, overflow hidden
389
+ * - `Scroll`: Always show scrollbars
390
+ * - `Auto`: Show scrollbars when needed (internally mapped to Scroll)
391
+ * @enum {0 | 1 | 2 | 3}
603
392
  */
604
- export const Gutter = Object.freeze({
605
- Column: 0, "0": "Column",
606
- Row: 1, "1": "Row",
607
- All: 2, "2": "All",
393
+ export const Overflow = Object.freeze({
394
+ Visible: 0, "0": "Visible",
395
+ Hidden: 1, "1": "Hidden",
396
+ Scroll: 2, "2": "Scroll",
397
+ Auto: 3, "3": "Auto",
608
398
  });
609
399
 
610
400
  /**
611
- * How items are distributed along the main axis.
612
- * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
401
+ * Position mode enum
402
+ *
403
+ * Controls element positioning method. Corresponds to CSS `position` property.
404
+ *
405
+ * # Variants
406
+ * - `Relative`: Relative positioning, element stays in normal document flow
407
+ * - `Absolute`: Absolute positioning, element removed from flow, positioned relative to nearest positioned ancestor
408
+ * @enum {0 | 1}
613
409
  */
614
- export const JustifyContent = Object.freeze({
615
- /**
616
- * Items are packed toward the start of the layout direction.
617
- */
618
- Start: 0, "0": "Start",
619
- /**
620
- * Items are packed toward the end of the layout direction.
621
- */
622
- End: 1, "1": "End",
623
- /**
624
- * Items are packed toward the start of the flex-direction.
625
- */
626
- FlexStart: 2, "2": "FlexStart",
627
- /**
628
- * Items are packed toward the end of the flex-direction.
629
- */
630
- FlexEnd: 3, "3": "FlexEnd",
631
- /**
632
- * Items are centered along the line.
633
- */
634
- Center: 4, "4": "Center",
635
- /**
636
- * Items are evenly distributed; the first item is at the start, the last at the end.
637
- */
638
- SpaceBetween: 5, "5": "SpaceBetween",
639
- /**
640
- * Items are evenly distributed with equal space around them.
641
- */
642
- SpaceAround: 6, "6": "SpaceAround",
643
- /**
644
- * Items are evenly distributed with equal space between them using the same gap at ends.
645
- */
646
- SpaceEvenly: 7, "7": "SpaceEvenly",
410
+ export const Position = Object.freeze({
411
+ Relative: 0, "0": "Relative",
412
+ Absolute: 1, "1": "Absolute",
647
413
  });
648
414
 
649
415
  /**
650
- * Represents the computed layout of a node.
416
+ * Node Style struct
417
+ *
418
+ * Configuration object containing all CSS layout properties.
419
+ * Access properties via getter/setter methods.
420
+ *
421
+ * # Supported Property Categories
422
+ *
423
+ * ## Layout Mode
424
+ * - `display`: Display mode (Flex/Grid/Block/None)
425
+ * - `position`: Position mode (Relative/Absolute)
426
+ *
427
+ * ## Flexbox Properties
428
+ * - `flex_direction`: Main axis direction
429
+ * - `flex_wrap`: Wrap behavior
430
+ * - `flex_grow`: Grow factor
431
+ * - `flex_shrink`: Shrink factor
432
+ * - `flex_basis`: Initial size
433
+ *
434
+ * ## Alignment Properties
435
+ * - `align_items`, `align_self`, `align_content`
436
+ * - `justify_content`
437
+ *
438
+ * ## Sizing Properties
439
+ * - `size`, `min_size`, `max_size`
440
+ * - `aspect_ratio`: Width-to-height ratio
651
441
  *
652
- * This struct contains the final position and size of a node after layout computation.
442
+ * ## Spacing Properties
443
+ * - `margin`, `padding`, `border`
444
+ * - `gap`: Gap between children
445
+ * - `inset`: Absolute positioning offsets
653
446
  */
654
- export class Layout {
447
+ export class Style {
655
448
  static __wrap(ptr) {
656
449
  ptr = ptr >>> 0;
657
- const obj = Object.create(Layout.prototype);
450
+ const obj = Object.create(Style.prototype);
658
451
  obj.__wbg_ptr = ptr;
659
- LayoutFinalization.register(obj, obj.__wbg_ptr, obj);
452
+ StyleFinalization.register(obj, obj.__wbg_ptr, obj);
660
453
  return obj;
661
454
  }
662
455
  __destroy_into_raw() {
663
456
  const ptr = this.__wbg_ptr;
664
457
  this.__wbg_ptr = 0;
665
- LayoutFinalization.unregister(this);
458
+ StyleFinalization.unregister(this);
666
459
  return ptr;
667
460
  }
668
461
  free() {
669
462
  const ptr = this.__destroy_into_raw();
670
- wasm.__wbg_layout_free(ptr, 0);
463
+ wasm.__wbg_style_free(ptr, 0);
671
464
  }
672
465
  /**
673
- * The absolute x-coordinate of the node relative to its parent.
674
- * @returns {number}
466
+ * Gets the align-self property. Overrides parent's align-items for this element.
467
+ * Returns AlignSelf.Auto if not explicitly set.
468
+ * @returns {AlignSelf | undefined}
469
+ */
470
+ get align_self() {
471
+ const ret = wasm.style_align_self(this.__wbg_ptr);
472
+ return ret === 8 ? undefined : ret;
473
+ }
474
+ /**
475
+ * Gets the flex-basis as a JsDimension (Length, Percent, or Auto).
476
+ * Flex-basis defines the initial main size before grow/shrink.
477
+ * @returns {any}
675
478
  */
676
- get x() {
677
- const ret = wasm.__wbg_get_dimension_value(this.__wbg_ptr);
479
+ get flex_basis() {
480
+ const ret = wasm.style_flex_basis(this.__wbg_ptr);
678
481
  return ret;
679
482
  }
680
483
  /**
681
- * The absolute x-coordinate of the node relative to its parent.
682
- * @param {number} arg0
484
+ * Sets the border width for all four edges.
485
+ * Accepts { left, right, top, bottom } with LengthPercentage values.
486
+ * @param {any} val
683
487
  */
684
- set x(arg0) {
685
- wasm.__wbg_set_dimension_value(this.__wbg_ptr, arg0);
488
+ set border(val) {
489
+ wasm.style_set_border(this.__wbg_ptr, val);
686
490
  }
687
491
  /**
688
- * The absolute y-coordinate of the node relative to its parent.
689
- * @returns {number}
492
+ * Sets the margin for all four edges.
493
+ * Accepts { left, right, top, bottom } with LengthPercentageAuto values.
494
+ * @param {any} val
690
495
  */
691
- get y() {
692
- const ret = wasm.__wbg_get_layout_y(this.__wbg_ptr);
693
- return ret;
496
+ set margin(val) {
497
+ wasm.style_set_margin(this.__wbg_ptr, val);
694
498
  }
695
499
  /**
696
- * The absolute y-coordinate of the node relative to its parent.
697
- * @param {number} arg0
500
+ * Gets the align-items property. Controls cross-axis alignment of children.
501
+ * @returns {AlignItems | undefined}
698
502
  */
699
- set y(arg0) {
700
- wasm.__wbg_set_layout_y(this.__wbg_ptr, arg0);
503
+ get align_items() {
504
+ const ret = wasm.style_align_items(this.__wbg_ptr);
505
+ return ret === 7 ? undefined : ret;
701
506
  }
702
507
  /**
703
- * The computed width of the node.
508
+ * Gets the flex shrink factor. Determines how much the item shrinks relative to siblings.
704
509
  * @returns {number}
705
510
  */
706
- get width() {
707
- const ret = wasm.__wbg_get_layout_width(this.__wbg_ptr);
511
+ get flex_shrink() {
512
+ const ret = wasm.style_flex_shrink(this.__wbg_ptr);
708
513
  return ret;
709
514
  }
710
515
  /**
711
- * The computed width of the node.
712
- * @param {number} arg0
516
+ * Sets the display mode. Controls which layout algorithm is used for children.
517
+ * - `Display.Block`: Block layout
518
+ * - `Display.Flex`: Flexbox layout
519
+ * - `Display.Grid`: CSS Grid layout
520
+ * - `Display.None`: Element is hidden and takes no space
521
+ * @param {Display} val
713
522
  */
714
- set width(arg0) {
715
- wasm.__wbg_set_layout_width(this.__wbg_ptr, arg0);
523
+ set display(val) {
524
+ wasm.style_set_display(this.__wbg_ptr, val);
716
525
  }
717
526
  /**
718
- * The computed height of the node.
719
- * @returns {number}
527
+ * Sets the padding for all four edges.
528
+ * Accepts { left, right, top, bottom } with LengthPercentage values.
529
+ * @param {any} val
720
530
  */
721
- get height() {
722
- const ret = wasm.__wbg_get_layout_height(this.__wbg_ptr);
723
- return ret;
531
+ set padding(val) {
532
+ wasm.style_set_padding(this.__wbg_ptr, val);
724
533
  }
725
534
  /**
726
- * The computed height of the node.
727
- * @param {number} arg0
535
+ * Gets the aspect ratio (width / height). Returns None if not set.
536
+ * @returns {number | undefined}
728
537
  */
729
- set height(arg0) {
730
- wasm.__wbg_set_layout_height(this.__wbg_ptr, arg0);
731
- }
732
- }
733
- if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
734
-
735
- /**
736
- * Represents a grid line placement (start and end).
737
- */
738
- export class Line {
739
- __destroy_into_raw() {
740
- const ptr = this.__wbg_ptr;
741
- this.__wbg_ptr = 0;
742
- LineFinalization.unregister(this);
743
- return ptr;
744
- }
745
- free() {
746
- const ptr = this.__destroy_into_raw();
747
- wasm.__wbg_line_free(ptr, 0);
748
- }
749
- /**
750
- * The start line index (1-based).
751
- * @returns {number | undefined}
752
- */
753
- get start() {
754
- const ret = wasm.__wbg_get_line_start(this.__wbg_ptr);
755
- return ret === 0xFFFFFF ? undefined : ret;
538
+ get aspect_ratio() {
539
+ const ret = wasm.style_aspect_ratio(this.__wbg_ptr);
540
+ return ret === 0x100000001 ? undefined : ret;
756
541
  }
757
542
  /**
758
- * The start line index (1-based).
759
- * @param {number | null} [arg0]
543
+ * Sets the maximum size constraints.
544
+ * @param {any} val
760
545
  */
761
- set start(arg0) {
762
- wasm.__wbg_set_line_start(this.__wbg_ptr, isLikeNone(arg0) ? 0xFFFFFF : arg0);
546
+ set max_size(val) {
547
+ wasm.style_set_max_size(this.__wbg_ptr, val);
763
548
  }
764
549
  /**
765
- * The end line index (1-based).
766
- * @returns {number | undefined}
550
+ * Sets the minimum size constraints.
551
+ * @param {any} val
767
552
  */
768
- get end() {
769
- const ret = wasm.__wbg_get_line_end(this.__wbg_ptr);
770
- return ret === 0xFFFFFF ? undefined : ret;
553
+ set min_size(val) {
554
+ wasm.style_set_min_size(this.__wbg_ptr, val);
771
555
  }
772
556
  /**
773
- * The end line index (1-based).
774
- * @param {number | null} [arg0]
557
+ * Sets the overflow behavior. Accepts {x: Overflow, y: Overflow}.
558
+ * @param {any} val
775
559
  */
776
- set end(arg0) {
777
- wasm.__wbg_set_line_end(this.__wbg_ptr, isLikeNone(arg0) ? 0xFFFFFF : arg0);
778
- }
779
- }
780
- if (Symbol.dispose) Line.prototype[Symbol.dispose] = Line.prototype.free;
781
-
782
- /**
783
- * Represents a point in 2D space.
784
- *
785
- * Typically used for coordinates like absolute positioning offsets.
786
- */
787
- export class Point {
788
- __destroy_into_raw() {
789
- const ptr = this.__wbg_ptr;
790
- this.__wbg_ptr = 0;
791
- PointFinalization.unregister(this);
792
- return ptr;
793
- }
794
- free() {
795
- const ptr = this.__destroy_into_raw();
796
- wasm.__wbg_point_free(ptr, 0);
560
+ set overflow(val) {
561
+ wasm.style_set_overflow(this.__wbg_ptr, val);
797
562
  }
798
563
  /**
799
- * The x-coordinate (horizontal).
800
- * @returns {number}
564
+ * Sets the position mode.
565
+ * - `Position.Relative`: Normal document flow
566
+ * - `Position.Absolute`: Removed from flow, positioned via inset properties
567
+ * @param {Position} val
801
568
  */
802
- get x() {
803
- const ret = wasm.__wbg_get_dimension_value(this.__wbg_ptr);
804
- return ret;
569
+ set position(val) {
570
+ wasm.style_set_position(this.__wbg_ptr, val);
805
571
  }
806
572
  /**
807
- * The x-coordinate (horizontal).
808
- * @param {number} arg0
809
- */
810
- set x(arg0) {
811
- wasm.__wbg_set_dimension_value(this.__wbg_ptr, arg0);
812
- }
813
- /**
814
- * The y-coordinate (vertical).
815
- * @returns {number}
573
+ * Gets the align-content property. Controls spacing between lines in multi-line flex.
574
+ * @returns {AlignContent | undefined}
816
575
  */
817
- get y() {
818
- const ret = wasm.__wbg_get_layout_y(this.__wbg_ptr);
819
- return ret;
576
+ get align_content() {
577
+ const ret = wasm.style_align_content(this.__wbg_ptr);
578
+ return ret === 9 ? undefined : ret;
820
579
  }
821
580
  /**
822
- * The y-coordinate (vertical).
823
- * @param {number} arg0
581
+ * Sets the flex grow factor. A value of 0 means the item won't grow.
582
+ * Higher values mean more growth relative to other items.
583
+ * @param {number} val
824
584
  */
825
- set y(arg0) {
826
- wasm.__wbg_set_layout_y(this.__wbg_ptr, arg0);
585
+ set flex_grow(val) {
586
+ wasm.style_set_flex_grow(this.__wbg_ptr, val);
827
587
  }
828
- }
829
- if (Symbol.dispose) Point.prototype[Symbol.dispose] = Point.prototype.free;
830
-
831
- /**
832
- * Positioning strategy for a node.
833
- * @enum {0 | 1 | 2}
834
- */
835
- export const Position = Object.freeze({
836
- /**
837
- * Relative to its normal position in the flow.
838
- */
839
- Static: 0, "0": "Static",
840
- /**
841
- * Relative to its normal position in the flow.
842
- */
843
- Relative: 1, "1": "Relative",
844
588
  /**
845
- * Removed from the flow and positioned relative to its containing block.
589
+ * Sets the flex wrap mode. Controls whether items wrap to new lines.
590
+ * @param {FlexWrap} val
846
591
  */
847
- Absolute: 2, "2": "Absolute",
848
- });
849
-
850
- /**
851
- * Represents a rectangle defined by its edges.
852
- *
853
- * Used for padding, margin, properties.
854
- */
855
- export class Rect {
856
- __destroy_into_raw() {
857
- const ptr = this.__wbg_ptr;
858
- this.__wbg_ptr = 0;
859
- RectFinalization.unregister(this);
860
- return ptr;
861
- }
862
- free() {
863
- const ptr = this.__destroy_into_raw();
864
- wasm.__wbg_rect_free(ptr, 0);
592
+ set flex_wrap(val) {
593
+ wasm.style_set_flex_wrap(this.__wbg_ptr, val);
865
594
  }
866
595
  /**
867
- * The left edge value.
868
- * @returns {number}
596
+ * Gets the flex direction (Row, Column, RowReverse, ColumnReverse).
597
+ * @returns {FlexDirection}
869
598
  */
870
- get left() {
871
- const ret = wasm.__wbg_get_dimension_value(this.__wbg_ptr);
599
+ get flex_direction() {
600
+ const ret = wasm.style_flex_direction(this.__wbg_ptr);
872
601
  return ret;
873
602
  }
874
603
  /**
875
- * The left edge value.
876
- * @param {number} arg0
604
+ * Sets the align-self property. Use AlignSelf.Auto to inherit from parent.
605
+ * @param {AlignSelf | null} [val]
877
606
  */
878
- set left(arg0) {
879
- wasm.__wbg_set_dimension_value(this.__wbg_ptr, arg0);
607
+ set align_self(val) {
608
+ wasm.style_set_align_self(this.__wbg_ptr, isLikeNone(val) ? 8 : val);
880
609
  }
881
610
  /**
882
- * The right edge value.
883
- * @returns {number}
611
+ * Sets the flex-basis. Accepts { Length: number } | { Percent: number } | "Auto".
612
+ * @param {any} val
884
613
  */
885
- get right() {
886
- const ret = wasm.__wbg_get_layout_y(this.__wbg_ptr);
887
- return ret;
614
+ set flex_basis(val) {
615
+ wasm.style_set_flex_basis(this.__wbg_ptr, val);
888
616
  }
889
617
  /**
890
- * The right edge value.
891
- * @param {number} arg0
618
+ * Gets the justify-content property. Controls main-axis alignment and spacing.
619
+ * @returns {JustifyContent | undefined}
892
620
  */
893
- set right(arg0) {
894
- wasm.__wbg_set_layout_y(this.__wbg_ptr, arg0);
621
+ get justify_content() {
622
+ const ret = wasm.style_justify_content(this.__wbg_ptr);
623
+ return ret === 9 ? undefined : ret;
895
624
  }
896
625
  /**
897
- * The top edge value.
898
- * @returns {number}
626
+ * Sets the align-items property. Affects all children's cross-axis alignment.
627
+ * @param {AlignItems | null} [val]
899
628
  */
900
- get top() {
901
- const ret = wasm.__wbg_get_layout_width(this.__wbg_ptr);
902
- return ret;
629
+ set align_items(val) {
630
+ wasm.style_set_align_items(this.__wbg_ptr, isLikeNone(val) ? 7 : val);
903
631
  }
904
632
  /**
905
- * The top edge value.
906
- * @param {number} arg0
633
+ * Sets the flex shrink factor. A value of 0 prevents shrinking.
634
+ * Default is 1.0 for flex items.
635
+ * @param {number} val
907
636
  */
908
- set top(arg0) {
909
- wasm.__wbg_set_layout_width(this.__wbg_ptr, arg0);
637
+ set flex_shrink(val) {
638
+ wasm.style_set_flex_shrink(this.__wbg_ptr, val);
910
639
  }
911
640
  /**
912
- * The bottom edge value.
913
- * @returns {number}
641
+ * Sets the aspect ratio. For example, 16/9 = 1.777... for widescreen.
642
+ * Set to None to remove the constraint.
643
+ * @param {number | null} [val]
914
644
  */
915
- get bottom() {
916
- const ret = wasm.__wbg_get_layout_height(this.__wbg_ptr);
917
- return ret;
645
+ set aspect_ratio(val) {
646
+ wasm.style_set_aspect_ratio(this.__wbg_ptr, isLikeNone(val) ? 0x100000001 : Math.fround(val));
918
647
  }
919
648
  /**
920
- * The bottom edge value.
921
- * @param {number} arg0
649
+ * Sets the align-content property. Only effective when flex-wrap is enabled.
650
+ * @param {AlignContent | null} [val]
922
651
  */
923
- set bottom(arg0) {
924
- wasm.__wbg_set_layout_height(this.__wbg_ptr, arg0);
925
- }
926
- }
927
- if (Symbol.dispose) Rect.prototype[Symbol.dispose] = Rect.prototype.free;
928
-
929
- /**
930
- * Represents a size in 2D space.
931
- *
932
- * Used for width and height dimensions.
933
- */
934
- export class Size {
935
- __destroy_into_raw() {
936
- const ptr = this.__wbg_ptr;
937
- this.__wbg_ptr = 0;
938
- SizeFinalization.unregister(this);
939
- return ptr;
940
- }
941
- free() {
942
- const ptr = this.__destroy_into_raw();
943
- wasm.__wbg_size_free(ptr, 0);
652
+ set align_content(val) {
653
+ wasm.style_set_align_content(this.__wbg_ptr, isLikeNone(val) ? 9 : val);
944
654
  }
945
655
  /**
946
- * The width dimension.
947
- * @returns {number}
656
+ * Sets the flex direction. Defines the main axis for flex item layout.
657
+ * @param {FlexDirection} val
948
658
  */
949
- get width() {
950
- const ret = wasm.__wbg_get_dimension_value(this.__wbg_ptr);
951
- return ret;
659
+ set flex_direction(val) {
660
+ wasm.style_set_flex_direction(this.__wbg_ptr, val);
952
661
  }
953
662
  /**
954
- * The width dimension.
955
- * @param {number} arg0
663
+ * Sets the justify-content property. Distributes space along the main axis.
664
+ * @param {JustifyContent | null} [val]
956
665
  */
957
- set width(arg0) {
958
- wasm.__wbg_set_dimension_value(this.__wbg_ptr, arg0);
666
+ set justify_content(val) {
667
+ wasm.style_set_justify_content(this.__wbg_ptr, isLikeNone(val) ? 9 : val);
959
668
  }
960
669
  /**
961
- * The height dimension.
962
- * @returns {number}
670
+ * Gets the gap between children as a JsSize<JsLengthPercentage>.
671
+ * Used in Flex and Grid layouts to add spacing between items.
672
+ * - width: column gap (horizontal spacing)
673
+ * - height: row gap (vertical spacing)
674
+ * @returns {any}
963
675
  */
964
- get height() {
965
- const ret = wasm.__wbg_get_layout_y(this.__wbg_ptr);
676
+ get gap() {
677
+ const ret = wasm.style_gap(this.__wbg_ptr);
966
678
  return ret;
967
679
  }
968
680
  /**
969
- * The height dimension.
970
- * @param {number} arg0
971
- */
972
- set height(arg0) {
973
- wasm.__wbg_set_layout_y(this.__wbg_ptr, arg0);
974
- }
975
- }
976
- if (Symbol.dispose) Size.prototype[Symbol.dispose] = Size.prototype.free;
977
-
978
- /**
979
- * Style values for a node.
980
- *
981
- * This struct aggregates all layout styles that can be applied to a node.
982
- * Optional fields allow partial updates or default values.
983
- */
984
- export class Style {
985
- __destroy_into_raw() {
986
- const ptr = this.__wbg_ptr;
987
- this.__wbg_ptr = 0;
988
- StyleFinalization.unregister(this);
989
- return ptr;
990
- }
991
- free() {
992
- const ptr = this.__destroy_into_raw();
993
- wasm.__wbg_style_free(ptr, 0);
994
- }
995
- /**
996
- * The display mode of the node (e.g. Flex, Grid, None).
997
- * @returns {Display | undefined}
998
- */
999
- get display() {
1000
- const ret = wasm.__wbg_get_style_display(this.__wbg_ptr);
1001
- return ret === 4 ? undefined : ret;
1002
- }
1003
- /**
1004
- * The display mode of the node (e.g. Flex, Grid, None).
1005
- * @param {Display | null} [arg0]
1006
- */
1007
- set display(arg0) {
1008
- wasm.__wbg_set_style_display(this.__wbg_ptr, isLikeNone(arg0) ? 4 : arg0);
1009
- }
1010
- /**
1011
- * The positioning strategy (e.g. Relative, Absolute).
1012
- * @returns {Position | undefined}
1013
- */
1014
- get position() {
1015
- const ret = wasm.__wbg_get_style_position(this.__wbg_ptr);
1016
- return ret === 3 ? undefined : ret;
1017
- }
1018
- /**
1019
- * The positioning strategy (e.g. Relative, Absolute).
1020
- * @param {Position | null} [arg0]
1021
- */
1022
- set position(arg0) {
1023
- wasm.__wbg_set_style_position(this.__wbg_ptr, isLikeNone(arg0) ? 3 : arg0);
1024
- }
1025
- /**
1026
- * The width of the node.
1027
- * @returns {Dimension | undefined}
1028
- */
1029
- get width() {
1030
- const ret = wasm.__wbg_get_style_width(this.__wbg_ptr);
1031
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1032
- }
1033
- /**
1034
- * The width of the node.
1035
- * @param {Dimension | null} [arg0]
1036
- */
1037
- set width(arg0) {
1038
- let ptr0 = 0;
1039
- if (!isLikeNone(arg0)) {
1040
- _assertClass(arg0, Dimension);
1041
- ptr0 = arg0.__destroy_into_raw();
1042
- }
1043
- wasm.__wbg_set_style_width(this.__wbg_ptr, ptr0);
1044
- }
1045
- /**
1046
- * The height of the node.
1047
- * @returns {Dimension | undefined}
1048
- */
1049
- get height() {
1050
- const ret = wasm.__wbg_get_style_height(this.__wbg_ptr);
1051
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1052
- }
1053
- /**
1054
- * The height of the node.
1055
- * @param {Dimension | null} [arg0]
1056
- */
1057
- set height(arg0) {
1058
- let ptr0 = 0;
1059
- if (!isLikeNone(arg0)) {
1060
- _assertClass(arg0, Dimension);
1061
- ptr0 = arg0.__destroy_into_raw();
1062
- }
1063
- wasm.__wbg_set_style_height(this.__wbg_ptr, ptr0);
1064
- }
1065
- /**
1066
- * The minimum width of the node.
1067
- * @returns {Dimension | undefined}
1068
- */
1069
- get min_width() {
1070
- const ret = wasm.__wbg_get_style_min_width(this.__wbg_ptr);
1071
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1072
- }
1073
- /**
1074
- * The minimum width of the node.
1075
- * @param {Dimension | null} [arg0]
1076
- */
1077
- set min_width(arg0) {
1078
- let ptr0 = 0;
1079
- if (!isLikeNone(arg0)) {
1080
- _assertClass(arg0, Dimension);
1081
- ptr0 = arg0.__destroy_into_raw();
1082
- }
1083
- wasm.__wbg_set_style_min_width(this.__wbg_ptr, ptr0);
1084
- }
1085
- /**
1086
- * The minimum height of the node.
1087
- * @returns {Dimension | undefined}
1088
- */
1089
- get min_height() {
1090
- const ret = wasm.__wbg_get_style_min_height(this.__wbg_ptr);
1091
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1092
- }
1093
- /**
1094
- * The minimum height of the node.
1095
- * @param {Dimension | null} [arg0]
1096
- */
1097
- set min_height(arg0) {
1098
- let ptr0 = 0;
1099
- if (!isLikeNone(arg0)) {
1100
- _assertClass(arg0, Dimension);
1101
- ptr0 = arg0.__destroy_into_raw();
1102
- }
1103
- wasm.__wbg_set_style_min_height(this.__wbg_ptr, ptr0);
1104
- }
1105
- /**
1106
- * The maximum width of the node.
1107
- * @returns {Dimension | undefined}
1108
- */
1109
- get max_width() {
1110
- const ret = wasm.__wbg_get_style_max_width(this.__wbg_ptr);
1111
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1112
- }
1113
- /**
1114
- * The maximum width of the node.
1115
- * @param {Dimension | null} [arg0]
1116
- */
1117
- set max_width(arg0) {
1118
- let ptr0 = 0;
1119
- if (!isLikeNone(arg0)) {
1120
- _assertClass(arg0, Dimension);
1121
- ptr0 = arg0.__destroy_into_raw();
1122
- }
1123
- wasm.__wbg_set_style_max_width(this.__wbg_ptr, ptr0);
1124
- }
1125
- /**
1126
- * The maximum height of the node.
1127
- * @returns {Dimension | undefined}
1128
- */
1129
- get max_height() {
1130
- const ret = wasm.__wbg_get_style_max_height(this.__wbg_ptr);
1131
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1132
- }
1133
- /**
1134
- * The maximum height of the node.
1135
- * @param {Dimension | null} [arg0]
1136
- */
1137
- set max_height(arg0) {
1138
- let ptr0 = 0;
1139
- if (!isLikeNone(arg0)) {
1140
- _assertClass(arg0, Dimension);
1141
- ptr0 = arg0.__destroy_into_raw();
1142
- }
1143
- wasm.__wbg_set_style_max_height(this.__wbg_ptr, ptr0);
1144
- }
1145
- /**
1146
- * The offset from the left edge (used with Position::Absolute/Relative).
1147
- * @returns {Dimension | undefined}
1148
- */
1149
- get left() {
1150
- const ret = wasm.__wbg_get_style_left(this.__wbg_ptr);
1151
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1152
- }
1153
- /**
1154
- * The offset from the left edge (used with Position::Absolute/Relative).
1155
- * @param {Dimension | null} [arg0]
1156
- */
1157
- set left(arg0) {
1158
- let ptr0 = 0;
1159
- if (!isLikeNone(arg0)) {
1160
- _assertClass(arg0, Dimension);
1161
- ptr0 = arg0.__destroy_into_raw();
1162
- }
1163
- wasm.__wbg_set_style_left(this.__wbg_ptr, ptr0);
1164
- }
1165
- /**
1166
- * The offset from the right edge.
1167
- * @returns {Dimension | undefined}
1168
- */
1169
- get right() {
1170
- const ret = wasm.__wbg_get_style_right(this.__wbg_ptr);
1171
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1172
- }
1173
- /**
1174
- * The offset from the right edge.
1175
- * @param {Dimension | null} [arg0]
1176
- */
1177
- set right(arg0) {
1178
- let ptr0 = 0;
1179
- if (!isLikeNone(arg0)) {
1180
- _assertClass(arg0, Dimension);
1181
- ptr0 = arg0.__destroy_into_raw();
1182
- }
1183
- wasm.__wbg_set_style_right(this.__wbg_ptr, ptr0);
1184
- }
1185
- /**
1186
- * The offset from the top edge.
1187
- * @returns {Dimension | undefined}
1188
- */
1189
- get top() {
1190
- const ret = wasm.__wbg_get_style_top(this.__wbg_ptr);
1191
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1192
- }
1193
- /**
1194
- * The offset from the top edge.
1195
- * @param {Dimension | null} [arg0]
1196
- */
1197
- set top(arg0) {
1198
- let ptr0 = 0;
1199
- if (!isLikeNone(arg0)) {
1200
- _assertClass(arg0, Dimension);
1201
- ptr0 = arg0.__destroy_into_raw();
1202
- }
1203
- wasm.__wbg_set_style_top(this.__wbg_ptr, ptr0);
1204
- }
1205
- /**
1206
- * The offset from the bottom edge.
1207
- * @returns {Dimension | undefined}
1208
- */
1209
- get bottom() {
1210
- const ret = wasm.__wbg_get_style_bottom(this.__wbg_ptr);
1211
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1212
- }
1213
- /**
1214
- * The offset from the bottom edge.
1215
- * @param {Dimension | null} [arg0]
1216
- */
1217
- set bottom(arg0) {
1218
- let ptr0 = 0;
1219
- if (!isLikeNone(arg0)) {
1220
- _assertClass(arg0, Dimension);
1221
- ptr0 = arg0.__destroy_into_raw();
1222
- }
1223
- wasm.__wbg_set_style_bottom(this.__wbg_ptr, ptr0);
1224
- }
1225
- /**
1226
- * The margin on the left side.
1227
- * @returns {Dimension | undefined}
1228
- */
1229
- get margin_left() {
1230
- const ret = wasm.__wbg_get_style_margin_left(this.__wbg_ptr);
1231
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1232
- }
1233
- /**
1234
- * The margin on the left side.
1235
- * @param {Dimension | null} [arg0]
1236
- */
1237
- set margin_left(arg0) {
1238
- let ptr0 = 0;
1239
- if (!isLikeNone(arg0)) {
1240
- _assertClass(arg0, Dimension);
1241
- ptr0 = arg0.__destroy_into_raw();
1242
- }
1243
- wasm.__wbg_set_style_margin_left(this.__wbg_ptr, ptr0);
1244
- }
1245
- /**
1246
- * The margin on the right side.
1247
- * @returns {Dimension | undefined}
1248
- */
1249
- get margin_right() {
1250
- const ret = wasm.__wbg_get_style_margin_right(this.__wbg_ptr);
1251
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1252
- }
1253
- /**
1254
- * The margin on the right side.
1255
- * @param {Dimension | null} [arg0]
1256
- */
1257
- set margin_right(arg0) {
1258
- let ptr0 = 0;
1259
- if (!isLikeNone(arg0)) {
1260
- _assertClass(arg0, Dimension);
1261
- ptr0 = arg0.__destroy_into_raw();
1262
- }
1263
- wasm.__wbg_set_style_margin_right(this.__wbg_ptr, ptr0);
1264
- }
1265
- /**
1266
- * The margin on the top side.
1267
- * @returns {Dimension | undefined}
1268
- */
1269
- get margin_top() {
1270
- const ret = wasm.__wbg_get_style_margin_top(this.__wbg_ptr);
1271
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1272
- }
1273
- /**
1274
- * The margin on the top side.
1275
- * @param {Dimension | null} [arg0]
1276
- */
1277
- set margin_top(arg0) {
1278
- let ptr0 = 0;
1279
- if (!isLikeNone(arg0)) {
1280
- _assertClass(arg0, Dimension);
1281
- ptr0 = arg0.__destroy_into_raw();
1282
- }
1283
- wasm.__wbg_set_style_margin_top(this.__wbg_ptr, ptr0);
1284
- }
1285
- /**
1286
- * The margin on the bottom side.
1287
- * @returns {Dimension | undefined}
1288
- */
1289
- get margin_bottom() {
1290
- const ret = wasm.__wbg_get_style_margin_bottom(this.__wbg_ptr);
1291
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1292
- }
1293
- /**
1294
- * The margin on the bottom side.
1295
- * @param {Dimension | null} [arg0]
1296
- */
1297
- set margin_bottom(arg0) {
1298
- let ptr0 = 0;
1299
- if (!isLikeNone(arg0)) {
1300
- _assertClass(arg0, Dimension);
1301
- ptr0 = arg0.__destroy_into_raw();
1302
- }
1303
- wasm.__wbg_set_style_margin_bottom(this.__wbg_ptr, ptr0);
681
+ * Creates a new Style instance with default values.
682
+ *
683
+ * All properties are initialized to their CSS default values:
684
+ * - display: Block
685
+ * - position: Relative
686
+ * - flex_direction: Row
687
+ * - All dimensions: Auto
688
+ * - All spacing (margin, padding, border): 0
689
+ *
690
+ * # Returns
691
+ * A new Style instance with default configuration.
692
+ *
693
+ * # Example
694
+ * ```javascript
695
+ * const style = new Style();
696
+ * style.display = Display.Flex;
697
+ * ```
698
+ */
699
+ constructor() {
700
+ const ret = wasm.style_new();
701
+ this.__wbg_ptr = ret >>> 0;
702
+ StyleFinalization.register(this, this.__wbg_ptr, this);
703
+ return this;
1304
704
  }
1305
705
  /**
1306
- * The padding on the left side.
1307
- * @returns {Dimension | undefined}
706
+ * Gets the size (width, height) as a JsSize<JsDimension>.
707
+ * Each dimension can be Length, Percent, or Auto.
708
+ * @returns {any}
1308
709
  */
1309
- get padding_left() {
1310
- const ret = wasm.__wbg_get_style_padding_left(this.__wbg_ptr);
1311
- return ret === 0 ? undefined : Dimension.__wrap(ret);
710
+ get size() {
711
+ const ret = wasm.style_size(this.__wbg_ptr);
712
+ return ret;
1312
713
  }
1313
714
  /**
1314
- * The padding on the left side.
1315
- * @param {Dimension | null} [arg0]
715
+ * Gets the inset (absolute positioning offsets) as a JsRect<JsLengthPercentageAuto>.
716
+ * Only effective when position is Absolute.
717
+ * Defines the distance from each edge of the containing block.
718
+ * @returns {any}
1316
719
  */
1317
- set padding_left(arg0) {
1318
- let ptr0 = 0;
1319
- if (!isLikeNone(arg0)) {
1320
- _assertClass(arg0, Dimension);
1321
- ptr0 = arg0.__destroy_into_raw();
1322
- }
1323
- wasm.__wbg_set_style_padding_left(this.__wbg_ptr, ptr0);
720
+ get inset() {
721
+ const ret = wasm.style_inset(this.__wbg_ptr);
722
+ return ret;
1324
723
  }
1325
724
  /**
1326
- * The padding on the right side.
1327
- * @returns {Dimension | undefined}
725
+ * Gets the border width as a JsRect<JsLengthPercentage>.
726
+ * Border width defines the thickness of element borders.
727
+ * Supports Length or Percent for each edge (not Auto).
728
+ * @returns {any}
1328
729
  */
1329
- get padding_right() {
1330
- const ret = wasm.__wbg_get_style_padding_right(this.__wbg_ptr);
1331
- return ret === 0 ? undefined : Dimension.__wrap(ret);
730
+ get border() {
731
+ const ret = wasm.style_border(this.__wbg_ptr);
732
+ return ret;
1332
733
  }
1333
734
  /**
1334
- * The padding on the right side.
1335
- * @param {Dimension | null} [arg0]
735
+ * Gets the margin as a JsRect<JsLengthPercentageAuto>.
736
+ * Margin is the outer spacing around the element's border.
737
+ * Supports Length, Percent, or Auto for each edge.
738
+ * @returns {any}
1336
739
  */
1337
- set padding_right(arg0) {
1338
- let ptr0 = 0;
1339
- if (!isLikeNone(arg0)) {
1340
- _assertClass(arg0, Dimension);
1341
- ptr0 = arg0.__destroy_into_raw();
1342
- }
1343
- wasm.__wbg_set_style_padding_right(this.__wbg_ptr, ptr0);
740
+ get margin() {
741
+ const ret = wasm.style_margin(this.__wbg_ptr);
742
+ return ret;
1344
743
  }
1345
744
  /**
1346
- * The padding on the top side.
1347
- * @returns {Dimension | undefined}
745
+ * Gets the display mode (Block, Flex, Grid, or None).
746
+ * @returns {Display}
1348
747
  */
1349
- get padding_top() {
1350
- const ret = wasm.__wbg_get_style_padding_top(this.__wbg_ptr);
1351
- return ret === 0 ? undefined : Dimension.__wrap(ret);
748
+ get display() {
749
+ const ret = wasm.style_display(this.__wbg_ptr);
750
+ return ret;
1352
751
  }
1353
752
  /**
1354
- * The padding on the top side.
1355
- * @param {Dimension | null} [arg0]
753
+ * Gets the padding as a JsRect<JsLengthPercentage>.
754
+ * Padding is the inner spacing between the border and content.
755
+ * Supports Length or Percent for each edge (not Auto).
756
+ * @returns {any}
1356
757
  */
1357
- set padding_top(arg0) {
1358
- let ptr0 = 0;
1359
- if (!isLikeNone(arg0)) {
1360
- _assertClass(arg0, Dimension);
1361
- ptr0 = arg0.__destroy_into_raw();
1362
- }
1363
- wasm.__wbg_set_style_padding_top(this.__wbg_ptr, ptr0);
758
+ get padding() {
759
+ const ret = wasm.style_padding(this.__wbg_ptr);
760
+ return ret;
1364
761
  }
1365
762
  /**
1366
- * The padding on the bottom side.
1367
- * @returns {Dimension | undefined}
763
+ * Sets the gap between children.
764
+ * Accepts { width: column_gap, height: row_gap } with LengthPercentage values.
765
+ * @param {any} val
1368
766
  */
1369
- get padding_bottom() {
1370
- const ret = wasm.__wbg_get_style_padding_bottom(this.__wbg_ptr);
1371
- return ret === 0 ? undefined : Dimension.__wrap(ret);
767
+ set gap(val) {
768
+ wasm.style_set_gap(this.__wbg_ptr, val);
1372
769
  }
1373
770
  /**
1374
- * The padding on the bottom side.
1375
- * @param {Dimension | null} [arg0]
771
+ * Gets the maximum size constraints as a JsSize<JsDimension>.
772
+ * Prevents the element from growing beyond these values.
773
+ * @returns {any}
1376
774
  */
1377
- set padding_bottom(arg0) {
1378
- let ptr0 = 0;
1379
- if (!isLikeNone(arg0)) {
1380
- _assertClass(arg0, Dimension);
1381
- ptr0 = arg0.__destroy_into_raw();
1382
- }
1383
- wasm.__wbg_set_style_padding_bottom(this.__wbg_ptr, ptr0);
775
+ get max_size() {
776
+ const ret = wasm.style_max_size(this.__wbg_ptr);
777
+ return ret;
1384
778
  }
1385
779
  /**
1386
- * The flex direction (e.g. Row, Column).
1387
- * @returns {FlexDirection | undefined}
780
+ * Gets the minimum size constraints as a JsSize<JsDimension>.
781
+ * Prevents the element from shrinking below these values.
782
+ * @returns {any}
1388
783
  */
1389
- get flex_direction() {
1390
- const ret = wasm.__wbg_get_style_flex_direction(this.__wbg_ptr);
1391
- return ret === 4 ? undefined : ret;
784
+ get min_size() {
785
+ const ret = wasm.style_min_size(this.__wbg_ptr);
786
+ return ret;
1392
787
  }
1393
788
  /**
1394
- * The flex direction (e.g. Row, Column).
1395
- * @param {FlexDirection | null} [arg0]
789
+ * Gets the overflow behavior as a JS object with {x, y} properties.
790
+ * @returns {any}
1396
791
  */
1397
- set flex_direction(arg0) {
1398
- wasm.__wbg_set_style_flex_direction(this.__wbg_ptr, isLikeNone(arg0) ? 4 : arg0);
792
+ get overflow() {
793
+ const ret = wasm.style_overflow(this.__wbg_ptr);
794
+ return ret;
1399
795
  }
1400
796
  /**
1401
- * Whether flex items should wrap.
1402
- * @returns {FlexWrap | undefined}
797
+ * Gets the position mode (Relative or Absolute).
798
+ * @returns {Position}
1403
799
  */
1404
- get flex_wrap() {
1405
- const ret = wasm.__wbg_get_style_flex_wrap(this.__wbg_ptr);
1406
- return ret === 3 ? undefined : ret;
800
+ get position() {
801
+ const ret = wasm.style_position(this.__wbg_ptr);
802
+ return ret;
1407
803
  }
1408
804
  /**
1409
- * Whether flex items should wrap.
1410
- * @param {FlexWrap | null} [arg0]
805
+ * Sets the size (width, height).
806
+ * Accepts { width: Dimension, height: Dimension } where Dimension is Length/Percent/Auto.
807
+ * Logs an error to console if parsing fails.
808
+ * @param {any} val
1411
809
  */
1412
- set flex_wrap(arg0) {
1413
- wasm.__wbg_set_style_flex_wrap(this.__wbg_ptr, isLikeNone(arg0) ? 3 : arg0);
810
+ set size(val) {
811
+ wasm.style_set_size(this.__wbg_ptr, val);
1414
812
  }
1415
813
  /**
1416
- * How much the item will grow relative to the rest of the flexible items.
1417
- * @returns {number | undefined}
814
+ * Gets the flex grow factor. Determines how much the item grows relative to siblings.
815
+ * @returns {number}
1418
816
  */
1419
817
  get flex_grow() {
1420
- const ret = wasm.__wbg_get_availablespace_width(this.__wbg_ptr);
1421
- return ret === 0x100000001 ? undefined : ret;
1422
- }
1423
- /**
1424
- * How much the item will grow relative to the rest of the flexible items.
1425
- * @param {number | null} [arg0]
1426
- */
1427
- set flex_grow(arg0) {
1428
- wasm.__wbg_set_availablespace_width(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : Math.fround(arg0));
1429
- }
1430
- /**
1431
- * How much the item will shrink relative to the rest of the flexible items.
1432
- * @returns {number | undefined}
1433
- */
1434
- get flex_shrink() {
1435
- const ret = wasm.__wbg_get_availablespace_height(this.__wbg_ptr);
1436
- return ret === 0x100000001 ? undefined : ret;
1437
- }
1438
- /**
1439
- * How much the item will shrink relative to the rest of the flexible items.
1440
- * @param {number | null} [arg0]
1441
- */
1442
- set flex_shrink(arg0) {
1443
- wasm.__wbg_set_availablespace_height(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : Math.fround(arg0));
1444
- }
1445
- /**
1446
- * The initial main size of a flex item.
1447
- * @returns {Dimension | undefined}
1448
- */
1449
- get flex_basis() {
1450
- const ret = wasm.__wbg_get_style_flex_basis(this.__wbg_ptr);
1451
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1452
- }
1453
- /**
1454
- * The initial main size of a flex item.
1455
- * @param {Dimension | null} [arg0]
1456
- */
1457
- set flex_basis(arg0) {
1458
- let ptr0 = 0;
1459
- if (!isLikeNone(arg0)) {
1460
- _assertClass(arg0, Dimension);
1461
- ptr0 = arg0.__destroy_into_raw();
1462
- }
1463
- wasm.__wbg_set_style_flex_basis(this.__wbg_ptr, ptr0);
1464
- }
1465
- /**
1466
- * How items are distributed along the main axis.
1467
- * @returns {JustifyContent | undefined}
1468
- */
1469
- get justify_content() {
1470
- const ret = wasm.__wbg_get_style_justify_content(this.__wbg_ptr);
1471
- return ret === 8 ? undefined : ret;
1472
- }
1473
- /**
1474
- * How items are distributed along the main axis.
1475
- * @param {JustifyContent | null} [arg0]
1476
- */
1477
- set justify_content(arg0) {
1478
- wasm.__wbg_set_style_justify_content(this.__wbg_ptr, isLikeNone(arg0) ? 8 : arg0);
1479
- }
1480
- /**
1481
- * How items are aligned along the cross axis.
1482
- * @returns {AlignItems | undefined}
1483
- */
1484
- get align_items() {
1485
- const ret = wasm.__wbg_get_style_align_items(this.__wbg_ptr);
1486
- return ret === 7 ? undefined : ret;
1487
- }
1488
- /**
1489
- * How items are aligned along the cross axis.
1490
- * @param {AlignItems | null} [arg0]
1491
- */
1492
- set align_items(arg0) {
1493
- wasm.__wbg_set_style_align_items(this.__wbg_ptr, isLikeNone(arg0) ? 7 : arg0);
1494
- }
1495
- /**
1496
- * How a single item is aligned along the cross axis.
1497
- * @returns {AlignSelf | undefined}
1498
- */
1499
- get align_self() {
1500
- const ret = wasm.__wbg_get_style_align_self(this.__wbg_ptr);
1501
- return ret === 8 ? undefined : ret;
1502
- }
1503
- /**
1504
- * How a single item is aligned along the cross axis.
1505
- * @param {AlignSelf | null} [arg0]
1506
- */
1507
- set align_self(arg0) {
1508
- wasm.__wbg_set_style_align_self(this.__wbg_ptr, isLikeNone(arg0) ? 8 : arg0);
1509
- }
1510
- /**
1511
- * How lines of content are aligned along the cross axis.
1512
- * @returns {AlignContent | undefined}
1513
- */
1514
- get align_content() {
1515
- const ret = wasm.__wbg_get_style_align_content(this.__wbg_ptr);
1516
- return ret === 9 ? undefined : ret;
1517
- }
1518
- /**
1519
- * How lines of content are aligned along the cross axis.
1520
- * @param {AlignContent | null} [arg0]
1521
- */
1522
- set align_content(arg0) {
1523
- wasm.__wbg_set_style_align_content(this.__wbg_ptr, isLikeNone(arg0) ? 9 : arg0);
1524
- }
1525
- /**
1526
- * The gap between rows (flex/grid).
1527
- * @returns {Dimension | undefined}
1528
- */
1529
- get row_gap() {
1530
- const ret = wasm.__wbg_get_style_row_gap(this.__wbg_ptr);
1531
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1532
- }
1533
- /**
1534
- * The gap between rows (flex/grid).
1535
- * @param {Dimension | null} [arg0]
1536
- */
1537
- set row_gap(arg0) {
1538
- let ptr0 = 0;
1539
- if (!isLikeNone(arg0)) {
1540
- _assertClass(arg0, Dimension);
1541
- ptr0 = arg0.__destroy_into_raw();
1542
- }
1543
- wasm.__wbg_set_style_row_gap(this.__wbg_ptr, ptr0);
1544
- }
1545
- /**
1546
- * The gap between columns (flex/grid).
1547
- * @returns {Dimension | undefined}
1548
- */
1549
- get column_gap() {
1550
- const ret = wasm.__wbg_get_style_column_gap(this.__wbg_ptr);
1551
- return ret === 0 ? undefined : Dimension.__wrap(ret);
1552
- }
1553
- /**
1554
- * The gap between columns (flex/grid).
1555
- * @param {Dimension | null} [arg0]
1556
- */
1557
- set column_gap(arg0) {
1558
- let ptr0 = 0;
1559
- if (!isLikeNone(arg0)) {
1560
- _assertClass(arg0, Dimension);
1561
- ptr0 = arg0.__destroy_into_raw();
1562
- }
1563
- wasm.__wbg_set_style_column_gap(this.__wbg_ptr, ptr0);
1564
- }
1565
- /**
1566
- * Algorithm for auto-placing items in the grid.
1567
- * @returns {GridAutoFlow | undefined}
1568
- */
1569
- get grid_auto_flow() {
1570
- const ret = wasm.__wbg_get_style_grid_auto_flow(this.__wbg_ptr);
1571
- return ret === 4 ? undefined : ret;
1572
- }
1573
- /**
1574
- * Algorithm for auto-placing items in the grid.
1575
- * @param {GridAutoFlow | null} [arg0]
1576
- */
1577
- set grid_auto_flow(arg0) {
1578
- wasm.__wbg_set_style_grid_auto_flow(this.__wbg_ptr, isLikeNone(arg0) ? 4 : arg0);
818
+ const ret = wasm.style_flex_grow(this.__wbg_ptr);
819
+ return ret;
1579
820
  }
1580
821
  /**
1581
- * Text alignment.
1582
- * @returns {TextAlign | undefined}
822
+ * Gets the flex wrap mode (NoWrap, Wrap, WrapReverse).
823
+ * @returns {FlexWrap}
1583
824
  */
1584
- get text_align() {
1585
- const ret = wasm.__wbg_get_style_text_align(this.__wbg_ptr);
1586
- return ret === 5 ? undefined : ret;
825
+ get flex_wrap() {
826
+ const ret = wasm.style_flex_wrap(this.__wbg_ptr);
827
+ return ret;
1587
828
  }
1588
829
  /**
1589
- * Text alignment.
1590
- * @param {TextAlign | null} [arg0]
830
+ * Sets the inset for absolute positioning.
831
+ * Accepts { left, right, top, bottom } with LengthPercentageAuto values.
832
+ * @param {any} val
1591
833
  */
1592
- set text_align(arg0) {
1593
- wasm.__wbg_set_style_text_align(this.__wbg_ptr, isLikeNone(arg0) ? 5 : arg0);
834
+ set inset(val) {
835
+ wasm.style_set_inset(this.__wbg_ptr, val);
1594
836
  }
1595
837
  }
1596
838
  if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
1597
839
 
1598
- export class TaffyNode {
840
+ /**
841
+ * Layout tree manager providing node creation, tree manipulation, and layout computation.
842
+ *
843
+ * This is the main entry point for the Taffy layout engine. It wraps the native
844
+ * `taffy::TaffyTree<JsValue>` to provide a JavaScript-friendly API.
845
+ *
846
+ * # Features
847
+ * - **Node Management**: Create, remove, and reorganize layout nodes
848
+ * - **Style Control**: Get/set styles for any node
849
+ * - **Layout Computation**: Run Flexbox/Grid/Block layout algorithms
850
+ * - **Custom Measurement**: Support for text measurement via callback functions
851
+ * - **Node Context**: Attach arbitrary JS data to nodes for custom logic
852
+ *
853
+ * # Example
854
+ * ```javascript
855
+ * const tree = new TaffyTree();
856
+ * const style = new Style();
857
+ * style.display = Display.Flex;
858
+ * const root = tree.newLeaf(style);
859
+ * tree.computeLayout(root, { width: { Definite: 800 }, height: { Definite: 600 } });
860
+ * const layout = tree.getLayout(root);
861
+ * ```
862
+ */
863
+ export class TaffyTree {
864
+ static __wrap(ptr) {
865
+ ptr = ptr >>> 0;
866
+ const obj = Object.create(TaffyTree.prototype);
867
+ obj.__wbg_ptr = ptr;
868
+ TaffyTreeFinalization.register(obj, obj.__wbg_ptr, obj);
869
+ return obj;
870
+ }
1599
871
  __destroy_into_raw() {
1600
872
  const ptr = this.__wbg_ptr;
1601
873
  this.__wbg_ptr = 0;
1602
- TaffyNodeFinalization.unregister(this);
874
+ TaffyTreeFinalization.unregister(this);
1603
875
  return ptr;
1604
876
  }
1605
877
  free() {
1606
878
  const ptr = this.__destroy_into_raw();
1607
- wasm.__wbg_taffynode_free(ptr, 0);
1608
- }
1609
- /**
1610
- * @returns {bigint}
1611
- */
1612
- get id() {
1613
- const ret = wasm.__wbg_get_taffynode_id(this.__wbg_ptr);
1614
- return BigInt.asUintN(64, ret);
1615
- }
1616
- /**
1617
- * @param {bigint} arg0
1618
- */
1619
- set id(arg0) {
1620
- wasm.__wbg_set_taffynode_id(this.__wbg_ptr, arg0);
879
+ wasm.__wbg_taffytree_free(ptr, 0);
1621
880
  }
1622
881
  /**
1623
- * @returns {Layout}
882
+ * Marks a node as dirty, requiring re-layout.
883
+ *
884
+ * Call this when a node's content changes (e.g., text content)
885
+ * but its style hasn't. Style changes automatically mark nodes dirty.
886
+ *
887
+ * # Arguments
888
+ * * `node` - The node ID to mark dirty.
889
+ * @param {bigint} node
1624
890
  */
1625
- getLayout() {
1626
- const ret = wasm.taffynode_getLayout(this.__wbg_ptr);
1627
- if (ret[2]) {
1628
- throw takeFromExternrefTable0(ret[1]);
1629
- }
1630
- return Layout.__wrap(ret[0]);
1631
- }
1632
- markDirty() {
1633
- const ret = wasm.taffynode_markDirty(this.__wbg_ptr);
891
+ markDirty(node) {
892
+ const ret = wasm.taffytree_markDirty(this.__wbg_ptr, node);
1634
893
  if (ret[1]) {
1635
894
  throw takeFromExternrefTable0(ret[0]);
1636
895
  }
1637
896
  }
1638
897
  /**
1639
- * @param {Edge} edge
1640
- * @param {number} value
898
+ * Prints the tree structure to the console (for debugging).
899
+ *
900
+ * # Arguments
901
+ * * `node` - The root node ID to start printing from.
902
+ * @param {bigint} node
1641
903
  */
1642
- setBorder(edge, value) {
1643
- const ret = wasm.taffynode_setBorder(this.__wbg_ptr, edge, value);
1644
- if (ret[1]) {
1645
- throw takeFromExternrefTable0(ret[0]);
1646
- }
1647
- }
1648
- /**
1649
- * @param {number} value
1650
- */
1651
- setHeight(value) {
1652
- const ret = wasm.taffynode_setHeight(this.__wbg_ptr, value);
1653
- if (ret[1]) {
1654
- throw takeFromExternrefTable0(ret[0]);
1655
- }
1656
- }
1657
- /**
1658
- * @param {Edge} edge
1659
- * @param {number} value
1660
- */
1661
- setMargin(edge, value) {
1662
- const ret = wasm.taffynode_setMargin(this.__wbg_ptr, edge, value);
1663
- if (ret[1]) {
1664
- throw takeFromExternrefTable0(ret[0]);
1665
- }
904
+ printTree(node) {
905
+ wasm.taffytree_printTree(this.__wbg_ptr, node);
1666
906
  }
1667
907
  /**
1668
- * @param {Display} display
1669
- */
1670
- setDisplay(display) {
1671
- const ret = wasm.taffynode_setDisplay(this.__wbg_ptr, display);
1672
- if (ret[1]) {
1673
- throw takeFromExternrefTable0(ret[0]);
1674
- }
1675
- }
1676
- /**
1677
- * @param {Edge} edge
1678
- * @param {number} value
1679
- */
1680
- setPadding(edge, value) {
1681
- const ret = wasm.taffynode_setPadding(this.__wbg_ptr, edge, value);
1682
- if (ret[1]) {
1683
- throw takeFromExternrefTable0(ret[0]);
1684
- }
1685
- }
1686
- /**
1687
- * @param {TaffyNode} child
1688
- * @param {number} index
908
+ * Gets the number of children of a node.
909
+ *
910
+ * # Arguments
911
+ * * `parent` - The parent node ID.
912
+ *
913
+ * # Returns
914
+ * The number of children.
915
+ * @param {bigint} parent
916
+ * @returns {number}
1689
917
  */
1690
- insertChild(child, index) {
1691
- _assertClass(child, TaffyNode);
1692
- const ret = wasm.taffynode_insertChild(this.__wbg_ptr, child.__wbg_ptr, index);
1693
- if (ret[1]) {
1694
- throw takeFromExternrefTable0(ret[0]);
1695
- }
1696
- }
1697
- /**
1698
- * @param {TaffyNode} child
918
+ childCount(parent) {
919
+ const ret = wasm.taffytree_childCount(this.__wbg_ptr, parent);
920
+ return ret >>> 0;
921
+ }
922
+ /**
923
+ * Removes a specific child from a parent.
924
+ *
925
+ * # Arguments
926
+ * * `parent` - The parent node ID.
927
+ * * `child` - The child node ID to remove.
928
+ *
929
+ * # Returns
930
+ * * `Ok(u64)` - The ID of the removed child.
931
+ * * `Err(JsValue)` - Error if parent or child doesn't exist.
932
+ * @param {bigint} parent
933
+ * @param {bigint} child
934
+ * @returns {bigint}
1699
935
  */
1700
- removeChild(child) {
1701
- _assertClass(child, TaffyNode);
1702
- const ret = wasm.taffynode_removeChild(this.__wbg_ptr, child.__wbg_ptr);
1703
- if (ret[1]) {
1704
- throw takeFromExternrefTable0(ret[0]);
936
+ removeChild(parent, child) {
937
+ const ret = wasm.taffytree_removeChild(this.__wbg_ptr, parent, child);
938
+ if (ret[2]) {
939
+ throw takeFromExternrefTable0(ret[1]);
1705
940
  }
941
+ return BigInt.asUintN(64, ret[0]);
1706
942
  }
1707
943
  /**
944
+ * Replaces all children of a node.
945
+ *
946
+ * Previous children are detached but not removed from the tree.
947
+ *
948
+ * # Arguments
949
+ * * `parent` - The parent node ID.
950
+ * * `children` - Array of new child node IDs.
951
+ * @param {bigint} parent
1708
952
  * @param {BigUint64Array} children
1709
953
  */
1710
- setChildren(children) {
954
+ setChildren(parent, children) {
1711
955
  const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1712
956
  const len0 = WASM_VECTOR_LEN;
1713
- const ret = wasm.taffynode_setChildren(this.__wbg_ptr, ptr0, len0);
1714
- if (ret[1]) {
1715
- throw takeFromExternrefTable0(ret[0]);
1716
- }
1717
- }
1718
- /**
1719
- * @param {number} value
1720
- */
1721
- setFlexGrow(value) {
1722
- const ret = wasm.taffynode_setFlexGrow(this.__wbg_ptr, value);
1723
- if (ret[1]) {
1724
- throw takeFromExternrefTable0(ret[0]);
1725
- }
1726
- }
1727
- /**
1728
- * @param {FlexWrap} wrap
1729
- */
1730
- setFlexWrap(wrap) {
1731
- const ret = wasm.taffynode_setFlexWrap(this.__wbg_ptr, wrap);
957
+ const ret = wasm.taffytree_setChildren(this.__wbg_ptr, parent, ptr0, len0);
1732
958
  if (ret[1]) {
1733
959
  throw takeFromExternrefTable0(ret[0]);
1734
960
  }
1735
961
  }
1736
962
  /**
1737
- * @param {number} value
963
+ * Creates a new TaffyTree with pre-allocated capacity.
964
+ *
965
+ * Use this when you know approximately how many nodes you'll create
966
+ * to avoid reallocation overhead.
967
+ *
968
+ * # Arguments
969
+ * * `capacity` - The number of nodes to pre-allocate space for.
970
+ *
971
+ * # Returns
972
+ * A new TaffyTree instance with pre-allocated capacity.
973
+ * @param {number} capacity
974
+ * @returns {TaffyTree}
975
+ */
976
+ static withCapacity(capacity) {
977
+ const ret = wasm.taffytree_withCapacity(capacity);
978
+ return TaffyTree.__wrap(ret);
979
+ }
980
+ /**
981
+ * Gets a child at a specific index.
982
+ *
983
+ * # Arguments
984
+ * * `parent` - The parent node ID.
985
+ * * `index` - The zero-based index.
986
+ *
987
+ * # Returns
988
+ * * `Ok(u64)` - The child node ID at the given index.
989
+ * * `Err(JsValue)` - Error if index is out of bounds.
990
+ * @param {bigint} parent
991
+ * @param {number} index
992
+ * @returns {bigint}
1738
993
  */
1739
- setMinWidth(value) {
1740
- const ret = wasm.taffynode_setMinWidth(this.__wbg_ptr, value);
1741
- if (ret[1]) {
1742
- throw takeFromExternrefTable0(ret[0]);
994
+ getChildAtIndex(parent, index) {
995
+ const ret = wasm.taffytree_getChildAtIndex(this.__wbg_ptr, parent, index);
996
+ if (ret[2]) {
997
+ throw takeFromExternrefTable0(ret[1]);
1743
998
  }
1744
- }
1745
- /**
999
+ return BigInt.asUintN(64, ret[0]);
1000
+ }
1001
+ /**
1002
+ * Computes the layout for a subtree.
1003
+ *
1004
+ * Runs the layout algorithm (Flexbox/Grid/Block) on the given node
1005
+ * and all its descendants. Results are cached and can be retrieved
1006
+ * with `getLayout()`.
1007
+ *
1008
+ * # Arguments
1009
+ * * `node` - The root node ID for layout computation.
1010
+ * * `available_space` - The available space constraint, e.g.:
1011
+ * `{ width: { Definite: 800 }, height: { Definite: 600 } }`
1012
+ *
1013
+ * Available space options per dimension:
1014
+ * - `{ Definite: number }` - A specific size in pixels
1015
+ * - `"MinContent"` - Use minimum content size
1016
+ * - `"MaxContent"` - Use maximum content size
1017
+ * @param {bigint} node
1746
1018
  * @param {any} available_space
1747
1019
  */
1748
- computeLayout(available_space) {
1749
- const ret = wasm.taffynode_computeLayout(this.__wbg_ptr, available_space);
1020
+ computeLayout(node, available_space) {
1021
+ const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, available_space);
1750
1022
  if (ret[1]) {
1751
1023
  throw takeFromExternrefTable0(ret[0]);
1752
1024
  }
1753
1025
  }
1754
1026
  /**
1755
- * @param {AlignSelf} align
1027
+ * Enables rounding of layout values to whole pixels.
1028
+ *
1029
+ * When enabled, all computed layout values (x, y, width, height) are
1030
+ * rounded to the nearest integer. This is the default behavior.
1756
1031
  */
1757
- setAlignSelf(align) {
1758
- const ret = wasm.taffynode_setAlignSelf(this.__wbg_ptr, align);
1759
- if (ret[1]) {
1760
- throw takeFromExternrefTable0(ret[0]);
1761
- }
1032
+ enableRounding() {
1033
+ wasm.taffytree_enableRounding(this.__wbg_ptr);
1762
1034
  }
1763
1035
  /**
1764
- * @param {number} value
1036
+ * Disables rounding of layout values.
1037
+ *
1038
+ * When disabled, layout values may have fractional pixel values.
1039
+ * Use `unroundedLayout()` to get the pre-rounding values.
1765
1040
  */
1766
- setFlexBasis(value) {
1767
- const ret = wasm.taffynode_setFlexBasis(this.__wbg_ptr, value);
1768
- if (ret[1]) {
1769
- throw takeFromExternrefTable0(ret[0]);
1770
- }
1041
+ disableRounding() {
1042
+ wasm.taffytree_disableRounding(this.__wbg_ptr);
1771
1043
  }
1772
1044
  /**
1773
- * @param {number} value
1774
- */
1775
- setMinHeight(value) {
1776
- const ret = wasm.taffynode_setMinHeight(this.__wbg_ptr, value);
1777
- if (ret[1]) {
1778
- throw takeFromExternrefTable0(ret[0]);
1779
- }
1780
- }
1781
- setWidthAuto() {
1782
- const ret = wasm.taffynode_setWidthAuto(this.__wbg_ptr);
1783
- if (ret[1]) {
1784
- throw takeFromExternrefTable0(ret[0]);
1785
- }
1786
- }
1787
- /**
1788
- * @param {AlignItems} align
1789
- */
1790
- setAlignItems(align) {
1791
- const ret = wasm.taffynode_setAlignItems(this.__wbg_ptr, align);
1792
- if (ret[1]) {
1793
- throw takeFromExternrefTable0(ret[0]);
1794
- }
1795
- }
1796
- /**
1797
- * @param {number} value
1798
- */
1799
- setFlexShrink(value) {
1800
- const ret = wasm.taffynode_setFlexShrink(this.__wbg_ptr, value);
1801
- if (ret[1]) {
1802
- throw takeFromExternrefTable0(ret[0]);
1803
- }
1804
- }
1805
- setHeightAuto() {
1806
- const ret = wasm.taffynode_setHeightAuto(this.__wbg_ptr);
1807
- if (ret[1]) {
1808
- throw takeFromExternrefTable0(ret[0]);
1809
- }
1810
- }
1811
- /**
1812
- * @param {Edge} edge
1813
- */
1814
- setMarginAuto(edge) {
1815
- const ret = wasm.taffynode_setMarginAuto(this.__wbg_ptr, edge);
1816
- if (ret[1]) {
1817
- throw takeFromExternrefTable0(ret[0]);
1818
- }
1819
- }
1820
- /**
1821
- * @param {Function} js_func
1822
- */
1823
- setMeasureFunc(js_func) {
1824
- const ret = wasm.taffynode_setMeasureFunc(this.__wbg_ptr, js_func);
1825
- if (ret[1]) {
1826
- throw takeFromExternrefTable0(ret[0]);
1827
- }
1828
- }
1829
- /**
1830
- * @param {Position} position
1831
- */
1832
- setPositionType(position) {
1833
- const ret = wasm.taffynode_setPositionType(this.__wbg_ptr, position);
1834
- if (ret[1]) {
1835
- throw takeFromExternrefTable0(ret[0]);
1836
- }
1837
- }
1838
- /**
1839
- * @param {number} value
1840
- */
1841
- setWidthPercent(value) {
1842
- const ret = wasm.taffynode_setWidthPercent(this.__wbg_ptr, value);
1843
- if (ret[1]) {
1844
- throw takeFromExternrefTable0(ret[0]);
1845
- }
1846
- }
1847
- /**
1848
- * @param {FlexDirection} direction
1849
- */
1850
- setFlexDirection(direction) {
1851
- const ret = wasm.taffynode_setFlexDirection(this.__wbg_ptr, direction);
1852
- if (ret[1]) {
1853
- throw takeFromExternrefTable0(ret[0]);
1854
- }
1855
- }
1856
- /**
1857
- * @param {number} value
1045
+ * Gets the context value for a node.
1046
+ *
1047
+ * # Arguments
1048
+ * * `node` - The node ID.
1049
+ *
1050
+ * # Returns
1051
+ * The context value, or `undefined` if not set.
1052
+ * @param {bigint} node
1053
+ * @returns {any}
1858
1054
  */
1859
- setHeightPercent(value) {
1860
- const ret = wasm.taffynode_setHeightPercent(this.__wbg_ptr, value);
1861
- if (ret[1]) {
1862
- throw takeFromExternrefTable0(ret[0]);
1863
- }
1864
- }
1865
- setFlexBasisAuto() {
1866
- const ret = wasm.taffynode_setFlexBasisAuto(this.__wbg_ptr);
1867
- if (ret[1]) {
1868
- throw takeFromExternrefTable0(ret[0]);
1055
+ getNodeContext(node) {
1056
+ const ret = wasm.taffytree_getNodeContext(this.__wbg_ptr, node);
1057
+ if (ret[2]) {
1058
+ throw takeFromExternrefTable0(ret[1]);
1869
1059
  }
1060
+ return takeFromExternrefTable0(ret[0]);
1870
1061
  }
1871
1062
  /**
1872
- * @param {JustifyContent} justify
1063
+ * Sets a context value for a node.
1064
+ *
1065
+ * Context values are passed to the measure function during layout.
1066
+ * Use this to attach data like text content or custom metadata.
1067
+ *
1068
+ * # Arguments
1069
+ * * `node` - The node ID.
1070
+ * * `context` - Any JavaScript value.
1071
+ * @param {bigint} node
1072
+ * @param {any} context
1873
1073
  */
1874
- setJustifyContent(justify) {
1875
- const ret = wasm.taffynode_setJustifyContent(this.__wbg_ptr, justify);
1074
+ setNodeContext(node, context) {
1075
+ const ret = wasm.taffytree_setNodeContext(this.__wbg_ptr, node, context);
1876
1076
  if (ret[1]) {
1877
1077
  throw takeFromExternrefTable0(ret[0]);
1878
1078
  }
1879
1079
  }
1880
1080
  /**
1881
- * @param {number} value
1081
+ * Gets the total number of nodes in the tree.
1082
+ *
1083
+ * # Returns
1084
+ * The count of all nodes (including removed nodes that haven't been reclaimed).
1085
+ * @returns {number}
1882
1086
  */
1883
- setMinWidthPercent(value) {
1884
- const ret = wasm.taffynode_setMinWidthPercent(this.__wbg_ptr, value);
1885
- if (ret[1]) {
1886
- throw takeFromExternrefTable0(ret[0]);
1887
- }
1888
- }
1889
- /**
1890
- * @param {number} value
1087
+ totalNodeCount() {
1088
+ const ret = wasm.taffytree_totalNodeCount(this.__wbg_ptr);
1089
+ return ret >>> 0;
1090
+ }
1091
+ /**
1092
+ * Gets the unrounded (fractional) layout for a node.
1093
+ *
1094
+ * Useful when you need sub-pixel precision.
1095
+ *
1096
+ * # Arguments
1097
+ * * `node` - The node ID to query.
1098
+ *
1099
+ * # Returns
1100
+ * A layout object with potentially fractional values.
1101
+ * @param {bigint} node
1102
+ * @returns {any}
1891
1103
  */
1892
- setFlexBasisPercent(value) {
1893
- const ret = wasm.taffynode_setFlexBasisPercent(this.__wbg_ptr, value);
1894
- if (ret[1]) {
1895
- throw takeFromExternrefTable0(ret[0]);
1104
+ unroundedLayout(node) {
1105
+ const ret = wasm.taffytree_unroundedLayout(this.__wbg_ptr, node);
1106
+ if (ret[2]) {
1107
+ throw takeFromExternrefTable0(ret[1]);
1896
1108
  }
1109
+ return takeFromExternrefTable0(ret[0]);
1897
1110
  }
1898
1111
  /**
1899
- * @param {number} value
1112
+ * Creates a new node with the given children.
1113
+ *
1114
+ * # Arguments
1115
+ * * `style` - The Style object to apply to this node.
1116
+ * * `children` - Array of child node IDs.
1117
+ *
1118
+ * # Returns
1119
+ * * `Ok(u64)` - The node ID of the newly created node.
1120
+ * * `Err(JsValue)` - Error message if creation fails.
1121
+ * @param {Style} style
1122
+ * @param {BigUint64Array} children
1123
+ * @returns {bigint}
1900
1124
  */
1901
- setMinHeightPercent(value) {
1902
- const ret = wasm.taffynode_setMinHeightPercent(this.__wbg_ptr, value);
1903
- if (ret[1]) {
1904
- throw takeFromExternrefTable0(ret[0]);
1125
+ newWithChildren(style, children) {
1126
+ _assertClass(style, Style);
1127
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1128
+ const len0 = WASM_VECTOR_LEN;
1129
+ const ret = wasm.taffytree_newWithChildren(this.__wbg_ptr, style.__wbg_ptr, ptr0, len0);
1130
+ if (ret[2]) {
1131
+ throw takeFromExternrefTable0(ret[1]);
1905
1132
  }
1133
+ return BigInt.asUintN(64, ret[0]);
1906
1134
  }
1907
1135
  /**
1908
- * @param {any} style
1136
+ * Gets a mutable reference to the context value for a node.
1137
+ *
1138
+ * Note: In WASM, this returns a clone since we can't return mutable references.
1139
+ *
1140
+ * # Arguments
1141
+ * * `node` - The node ID.
1142
+ *
1143
+ * # Returns
1144
+ * The context value, or `undefined` if not set.
1145
+ * @param {bigint} node
1146
+ * @returns {any}
1909
1147
  */
1910
- constructor(style) {
1911
- const ret = wasm.taffynode_new(style);
1148
+ getNodeContextMut(node) {
1149
+ const ret = wasm.taffytree_getNodeContextMut(this.__wbg_ptr, node);
1912
1150
  if (ret[2]) {
1913
1151
  throw takeFromExternrefTable0(ret[1]);
1914
1152
  }
1915
- this.__wbg_ptr = ret[0] >>> 0;
1916
- TaffyNodeFinalization.register(this, this.__wbg_ptr, this);
1917
- return this;
1153
+ return takeFromExternrefTable0(ret[0]);
1918
1154
  }
1919
- free() {
1920
- const ptr = this.__destroy_into_raw();
1921
- const ret = wasm.taffynode_free(ptr);
1155
+ /**
1156
+ * Inserts a child at a specific index.
1157
+ *
1158
+ * Existing children at and after the index are shifted right.
1159
+ *
1160
+ * # Arguments
1161
+ * * `parent` - The parent node ID.
1162
+ * * `index` - The zero-based index at which to insert.
1163
+ * * `child` - The child node ID to insert.
1164
+ * @param {bigint} parent
1165
+ * @param {number} index
1166
+ * @param {bigint} child
1167
+ */
1168
+ insertChildAtIndex(parent, index, child) {
1169
+ const ret = wasm.taffytree_insertChildAtIndex(this.__wbg_ptr, parent, index, child);
1922
1170
  if (ret[1]) {
1923
1171
  throw takeFromExternrefTable0(ret[0]);
1924
1172
  }
1925
1173
  }
1926
1174
  /**
1927
- * @returns {any}
1175
+ * Creates a new leaf node with an attached context value.
1176
+ *
1177
+ * The context can be any JavaScript value and is useful for associating
1178
+ * custom data (like text content) with a node for use in measure functions.
1179
+ *
1180
+ * # Arguments
1181
+ * * `style` - The Style object to apply to this node.
1182
+ * * `context` - Any JavaScript value to attach to this node.
1183
+ *
1184
+ * # Returns
1185
+ * * `Ok(u64)` - The node ID of the newly created node.
1186
+ * * `Err(JsValue)` - Error message if creation fails.
1187
+ * @param {Style} style
1188
+ * @param {any} context
1189
+ * @returns {bigint}
1928
1190
  */
1929
- style() {
1930
- const ret = wasm.taffynode_style(this.__wbg_ptr);
1191
+ newLeafWithContext(style, context) {
1192
+ _assertClass(style, Style);
1193
+ const ret = wasm.taffytree_newLeafWithContext(this.__wbg_ptr, style.__wbg_ptr, context);
1931
1194
  if (ret[2]) {
1932
1195
  throw takeFromExternrefTable0(ret[1]);
1933
1196
  }
1934
- return takeFromExternrefTable0(ret[0]);
1197
+ return BigInt.asUintN(64, ret[0]);
1935
1198
  }
1936
1199
  /**
1937
- * @param {Gutter} gutter
1938
- * @param {number} value
1200
+ * Removes a child at a specific index.
1201
+ *
1202
+ * # Arguments
1203
+ * * `parent` - The parent node ID.
1204
+ * * `index` - The zero-based index of the child to remove.
1205
+ *
1206
+ * # Returns
1207
+ * * `Ok(u64)` - The ID of the removed child.
1208
+ * * `Err(JsValue)` - Error if index is out of bounds.
1209
+ * @param {bigint} parent
1210
+ * @param {number} index
1211
+ * @returns {bigint}
1939
1212
  */
1940
- setGap(gutter, value) {
1941
- const ret = wasm.taffynode_setGap(this.__wbg_ptr, gutter, value);
1942
- if (ret[1]) {
1943
- throw takeFromExternrefTable0(ret[0]);
1213
+ removeChildAtIndex(parent, index) {
1214
+ const ret = wasm.taffytree_removeChildAtIndex(this.__wbg_ptr, parent, index);
1215
+ if (ret[2]) {
1216
+ throw takeFromExternrefTable0(ret[1]);
1944
1217
  }
1218
+ return BigInt.asUintN(64, ret[0]);
1945
1219
  }
1946
1220
  /**
1947
- * @param {TaffyNode} child
1221
+ * Removes a range of children from a parent.
1222
+ *
1223
+ * # Arguments
1224
+ * * `parent` - The parent node ID.
1225
+ * * `start` - The start index (inclusive).
1226
+ * * `end` - The end index (exclusive).
1227
+ * @param {bigint} parent
1228
+ * @param {number} start
1229
+ * @param {number} end
1948
1230
  */
1949
- addChild(child) {
1950
- _assertClass(child, TaffyNode);
1951
- const ret = wasm.taffynode_addChild(this.__wbg_ptr, child.__wbg_ptr);
1231
+ removeChildrenRange(parent, start, end) {
1232
+ const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, start, end);
1952
1233
  if (ret[1]) {
1953
1234
  throw takeFromExternrefTable0(ret[0]);
1954
1235
  }
1955
1236
  }
1956
1237
  /**
1957
- * @param {any} style
1238
+ * Replaces a child at a specific index with a new child.
1239
+ *
1240
+ * # Arguments
1241
+ * * `parent` - The parent node ID.
1242
+ * * `index` - The zero-based index of the child to replace.
1243
+ * * `child` - The new child node ID.
1244
+ *
1245
+ * # Returns
1246
+ * * `Ok(u64)` - The ID of the replaced (old) child.
1247
+ * * `Err(JsValue)` - Error if index is out of bounds.
1248
+ * @param {bigint} parent
1249
+ * @param {number} index
1250
+ * @param {bigint} child
1251
+ * @returns {bigint}
1958
1252
  */
1959
- set_style(style) {
1960
- const ret = wasm.taffynode_set_style(this.__wbg_ptr, style);
1961
- if (ret[1]) {
1962
- throw takeFromExternrefTable0(ret[0]);
1253
+ replaceChildAtIndex(parent, index, child) {
1254
+ const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, child);
1255
+ if (ret[2]) {
1256
+ throw takeFromExternrefTable0(ret[1]);
1963
1257
  }
1964
- }
1965
- /**
1966
- * @param {number} value
1258
+ return BigInt.asUintN(64, ret[0]);
1259
+ }
1260
+ /**
1261
+ * Computes layout with a custom measure function for leaf nodes.
1262
+ *
1263
+ * The measure function is called for leaf nodes to determine their
1264
+ * intrinsic size (e.g., for text measurement).
1265
+ *
1266
+ * # Arguments
1267
+ * * `node` - The root node ID for layout computation.
1268
+ * * `available_space` - The available space constraint.
1269
+ * * `measure_func` - A JavaScript function with signature:
1270
+ * `(knownDimensions, availableSpace, context) => { width, height }`
1271
+ *
1272
+ * The measure function receives:
1273
+ * - `knownDimensions`: `{ width: number | null, height: number | null }`
1274
+ * - `availableSpace`: `{ width: AvailableSpace, height: AvailableSpace }`
1275
+ * - `context`: The context value attached to the node (or undefined)
1276
+ *
1277
+ * And should return: `{ width: number, height: number }`
1278
+ * @param {bigint} node
1279
+ * @param {any} available_space
1280
+ * @param {Function} measure_func
1967
1281
  */
1968
- setWidth(value) {
1969
- const ret = wasm.taffynode_setWidth(this.__wbg_ptr, value);
1282
+ computeLayoutWithMeasure(node, available_space, measure_func) {
1283
+ const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, available_space, measure_func);
1970
1284
  if (ret[1]) {
1971
1285
  throw takeFromExternrefTable0(ret[0]);
1972
1286
  }
1973
1287
  }
1974
- }
1975
- if (Symbol.dispose) TaffyNode.prototype[Symbol.dispose] = TaffyNode.prototype.free;
1976
-
1977
- /**
1978
- * Text alignment within a node (mostly ignored in flex/grid layout but preserved for compatibility).
1979
- * @enum {0 | 1 | 2 | 3 | 4}
1980
- */
1981
- export const TextAlign = Object.freeze({
1982
- Auto: 0, "0": "Auto",
1983
- Left: 1, "1": "Left",
1984
- Right: 2, "2": "Right",
1985
- Center: 3, "3": "Center",
1986
- Justify: 4, "4": "Justify",
1987
- });
1988
-
1989
- /**
1990
- * Definition of a single grid track (row or column).
1991
- */
1992
- export class TrackDefinition {
1993
- __destroy_into_raw() {
1994
- const ptr = this.__wbg_ptr;
1995
- this.__wbg_ptr = 0;
1996
- TrackDefinitionFinalization.unregister(this);
1997
- return ptr;
1998
- }
1999
- free() {
2000
- const ptr = this.__destroy_into_raw();
2001
- wasm.__wbg_trackdefinition_free(ptr, 0);
2002
- }
2003
1288
  /**
2004
- * The numeric value of the track size.
2005
- * @returns {number}
1289
+ * Gets context values for multiple nodes at once.
1290
+ *
1291
+ * Useful for batch operations.
1292
+ *
1293
+ * # Arguments
1294
+ * * `children` - Array of node IDs to query.
1295
+ *
1296
+ * # Returns
1297
+ * Array of context values in the same order as input.
1298
+ * @param {BigUint64Array} children
1299
+ * @returns {any[]}
2006
1300
  */
2007
- get value() {
2008
- const ret = wasm.__wbg_get_dimension_value(this.__wbg_ptr);
2009
- return ret;
1301
+ getDisjointNodeContextMut(children) {
1302
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1303
+ const len0 = WASM_VECTOR_LEN;
1304
+ const ret = wasm.taffytree_getDisjointNodeContextMut(this.__wbg_ptr, ptr0, len0);
1305
+ if (ret[3]) {
1306
+ throw takeFromExternrefTable0(ret[2]);
1307
+ }
1308
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1309
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1310
+ return v2;
1311
+ }
1312
+ /**
1313
+ * Creates a new empty TaffyTree.
1314
+ *
1315
+ * This is the primary constructor. Initializes panic hook in debug builds
1316
+ * to provide better error messages in the browser console.
1317
+ *
1318
+ * # Returns
1319
+ * A new TaffyTree instance with no nodes.
1320
+ */
1321
+ constructor() {
1322
+ const ret = wasm.taffytree_new();
1323
+ this.__wbg_ptr = ret >>> 0;
1324
+ TaffyTreeFinalization.register(this, this.__wbg_ptr, this);
1325
+ return this;
2010
1326
  }
2011
1327
  /**
2012
- * The numeric value of the track size.
2013
- * @param {number} arg0
1328
+ * Removes all nodes from the tree.
1329
+ *
1330
+ * After calling this, the tree is empty and all previous node IDs are invalid.
2014
1331
  */
2015
- set value(arg0) {
2016
- wasm.__wbg_set_dimension_value(this.__wbg_ptr, arg0);
1332
+ clear() {
1333
+ wasm.taffytree_clear(this.__wbg_ptr);
2017
1334
  }
2018
1335
  /**
2019
- * The unit of the track size.
2020
- * @returns {TrackUnit}
1336
+ * Checks if a node is dirty (needs re-layout).
1337
+ *
1338
+ * # Arguments
1339
+ * * `node` - The node ID to check.
1340
+ *
1341
+ * # Returns
1342
+ * * `Ok(true)` - The node needs re-layout.
1343
+ * * `Ok(false)` - The node's layout is up-to-date.
1344
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1345
+ * @param {bigint} node
1346
+ * @returns {boolean}
2021
1347
  */
2022
- get unit() {
2023
- const ret = wasm.__wbg_get_trackdefinition_unit(this.__wbg_ptr);
2024
- return ret;
1348
+ dirty(node) {
1349
+ const ret = wasm.taffytree_dirty(this.__wbg_ptr, node);
1350
+ if (ret[2]) {
1351
+ throw takeFromExternrefTable0(ret[1]);
1352
+ }
1353
+ return ret[0] !== 0;
2025
1354
  }
2026
1355
  /**
2027
- * The unit of the track size.
2028
- * @param {TrackUnit} arg0
1356
+ * Gets the style for a node.
1357
+ *
1358
+ * # Arguments
1359
+ * * `node` - The node ID to query.
1360
+ *
1361
+ * # Returns
1362
+ * * `Ok(Style)` - A copy of the node's style.
1363
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1364
+ * @param {bigint} node
1365
+ * @returns {Style}
2029
1366
  */
2030
- set unit(arg0) {
2031
- wasm.__wbg_set_trackdefinition_unit(this.__wbg_ptr, arg0);
1367
+ getStyle(node) {
1368
+ const ret = wasm.taffytree_getStyle(this.__wbg_ptr, node);
1369
+ if (ret[2]) {
1370
+ throw takeFromExternrefTable0(ret[1]);
1371
+ }
1372
+ return Style.__wrap(ret[0]);
2032
1373
  }
2033
- }
2034
- if (Symbol.dispose) TrackDefinition.prototype[Symbol.dispose] = TrackDefinition.prototype.free;
2035
-
2036
- /**
2037
- * The unit for a grid track definition.
2038
- * @enum {0 | 1 | 2 | 3 | 4 | 5}
2039
- */
2040
- export const TrackUnit = Object.freeze({
2041
- /**
2042
- * The track size is specified in logical pixels.
2043
- */
2044
- Pixels: 0, "0": "Pixels",
2045
1374
  /**
2046
- * The track size is specified as a percentage of the container.
1375
+ * Gets the computed layout for a node.
1376
+ *
1377
+ * Must be called after `computeLayout()`.
1378
+ *
1379
+ * # Arguments
1380
+ * * `node` - The node ID to query.
1381
+ *
1382
+ * # Returns
1383
+ * A layout object: `{ order, size: {width, height}, location: {x, y}, ... }`
1384
+ * @param {bigint} node
1385
+ * @returns {any}
2047
1386
  */
2048
- Percent: 1, "1": "Percent",
1387
+ getLayout(node) {
1388
+ const ret = wasm.taffytree_getLayout(this.__wbg_ptr, node);
1389
+ if (ret[2]) {
1390
+ throw takeFromExternrefTable0(ret[1]);
1391
+ }
1392
+ return takeFromExternrefTable0(ret[0]);
1393
+ }
2049
1394
  /**
2050
- * The track size is a fraction of the remaining free space (fr unit).
1395
+ * Gets the parent of a node.
1396
+ *
1397
+ * # Arguments
1398
+ * * `child` - The child node ID.
1399
+ *
1400
+ * # Returns
1401
+ * * `Some(u64)` - The parent node ID.
1402
+ * * `None` - If the node has no parent (is a root).
1403
+ * @param {bigint} child
1404
+ * @returns {bigint | undefined}
1405
+ */
1406
+ parent(child) {
1407
+ const ret = wasm.taffytree_parent(this.__wbg_ptr, child);
1408
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
1409
+ }
1410
+ /**
1411
+ * Removes a node from the tree.
1412
+ *
1413
+ * The node is detached from its parent (if any) and removed from the tree.
1414
+ * Child nodes are NOT automatically removed.
1415
+ *
1416
+ * # Arguments
1417
+ * * `node` - The node ID to remove.
1418
+ *
1419
+ * # Returns
1420
+ * * `Ok(u64)` - The ID of the removed node.
1421
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1422
+ * @param {bigint} node
1423
+ * @returns {bigint}
2051
1424
  */
2052
- Fraction: 2, "2": "Fraction",
2053
- /**
2054
- * The track size is determined automatically.
1425
+ remove(node) {
1426
+ const ret = wasm.taffytree_remove(this.__wbg_ptr, node);
1427
+ if (ret[2]) {
1428
+ throw takeFromExternrefTable0(ret[1]);
1429
+ }
1430
+ return BigInt.asUintN(64, ret[0]);
1431
+ }
1432
+ /**
1433
+ * Gets all children of a node.
1434
+ *
1435
+ * # Arguments
1436
+ * * `parent` - The parent node ID.
1437
+ *
1438
+ * # Returns
1439
+ * * `Ok(Box<[u64]>)` - Array of child node IDs.
1440
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1441
+ * @param {bigint} parent
1442
+ * @returns {BigUint64Array}
1443
+ */
1444
+ children(parent) {
1445
+ const ret = wasm.taffytree_children(this.__wbg_ptr, parent);
1446
+ if (ret[3]) {
1447
+ throw takeFromExternrefTable0(ret[2]);
1448
+ }
1449
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
1450
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1451
+ return v1;
1452
+ }
1453
+ /**
1454
+ * Creates a new leaf node (no children) with the given style.
1455
+ *
1456
+ * # Arguments
1457
+ * * `style` - The Style object to apply to this node.
1458
+ *
1459
+ * # Returns
1460
+ * * `Ok(u64)` - The node ID of the newly created node.
1461
+ * * `Err(JsValue)` - Error message if creation fails.
1462
+ * @param {Style} style
1463
+ * @returns {bigint}
2055
1464
  */
2056
- Auto: 3, "3": "Auto",
1465
+ newLeaf(style) {
1466
+ _assertClass(style, Style);
1467
+ const ret = wasm.taffytree_newLeaf(this.__wbg_ptr, style.__wbg_ptr);
1468
+ if (ret[2]) {
1469
+ throw takeFromExternrefTable0(ret[1]);
1470
+ }
1471
+ return BigInt.asUintN(64, ret[0]);
1472
+ }
2057
1473
  /**
2058
- * The track size is the minimum size needed to fit the content.
1474
+ * Appends a child node to a parent.
1475
+ *
1476
+ * The child is added at the end of the parent's children list.
1477
+ *
1478
+ * # Arguments
1479
+ * * `parent` - The parent node ID.
1480
+ * * `child` - The child node ID to add.
1481
+ * @param {bigint} parent
1482
+ * @param {bigint} child
2059
1483
  */
2060
- MinContent: 4, "4": "MinContent",
1484
+ addChild(parent, child) {
1485
+ const ret = wasm.taffytree_addChild(this.__wbg_ptr, parent, child);
1486
+ if (ret[1]) {
1487
+ throw takeFromExternrefTable0(ret[0]);
1488
+ }
1489
+ }
2061
1490
  /**
2062
- * The track size is the maximum size needed to fit the content.
1491
+ * Sets the style for an existing node.
1492
+ *
1493
+ * This will mark the node and its ancestors as dirty, triggering
1494
+ * a re-layout on the next `computeLayout()` call.
1495
+ *
1496
+ * # Arguments
1497
+ * * `node` - The node ID to update.
1498
+ * * `style` - The new Style to apply.
1499
+ * @param {bigint} node
1500
+ * @param {Style} style
2063
1501
  */
2064
- MaxContent: 5, "5": "MaxContent",
2065
- });
2066
-
2067
- /**
2068
- * Adds a child node to a parent node.
2069
- *
2070
- * # Arguments
2071
- *
2072
- * * `parent` - The ID of the parent node.
2073
- * * `child` - The ID of the child node to add.
2074
- *
2075
- * # Errors
2076
- *
2077
- * Returns a `JsValue` error if the operation fails (e.g., recursive hierarchy).
2078
- * @param {bigint} parent
2079
- * @param {bigint} child
2080
- */
2081
- export function add_child(parent, child) {
2082
- const ret = wasm.add_child(parent, child);
2083
- if (ret[1]) {
2084
- throw takeFromExternrefTable0(ret[0]);
2085
- }
2086
- }
2087
-
2088
- /**
2089
- * Auto dimension constant
2090
- * @returns {Dimension}
2091
- */
2092
- export function auto() {
2093
- const ret = wasm.auto();
2094
- return Dimension.__wrap(ret);
2095
- }
2096
-
2097
- /**
2098
- * Clear all nodes from the layout tree.
2099
- *
2100
- * This removes all nodes and resets the tree to an empty state.
2101
- * Any existing node IDs become invalid after this call.
2102
- */
2103
- export function clear() {
2104
- const ret = wasm.clear();
2105
- if (ret[1]) {
2106
- throw takeFromExternrefTable0(ret[0]);
2107
- }
2108
- }
2109
-
2110
- /**
2111
- * Computes the layout for a tree starting from the specified root node.
2112
- *
2113
- * # Arguments
2114
- *
2115
- * * `root` - The ID of the root node of the tree to lay out.
2116
- * * `available_space` - The available space constraints for the layout.
2117
- *
2118
- * # Errors
2119
- *
2120
- * Returns a `JsValue` error if the layout computation fails.
2121
- * @param {bigint} root
2122
- * @param {any} available_space
2123
- */
2124
- export function compute_layout(root, available_space) {
2125
- const ret = wasm.compute_layout(root, available_space);
2126
- if (ret[1]) {
2127
- throw takeFromExternrefTable0(ret[0]);
2128
- }
2129
- }
2130
-
2131
- /**
2132
- * Helper function to create a dimension
2133
- * @param {number} value
2134
- * @param {DimensionUnit} unit
2135
- * @returns {Dimension}
2136
- */
2137
- export function dimension(value, unit) {
2138
- const ret = wasm.dimension(value, unit);
2139
- return Dimension.__wrap(ret);
2140
- }
2141
-
2142
- /**
2143
- * Retrieves the list of children IDs for a given node.
2144
- *
2145
- * # Arguments
2146
- *
2147
- * * `parent` - The ID of the parent node.
2148
- *
2149
- * # Returns
2150
- *
2151
- * A boxed array of child node IDs (`Box<[u32]>`).
2152
- *
2153
- * # Errors
2154
- *
2155
- * Returns a `JsValue` error if the node does not exist.
2156
- * @param {bigint} parent
2157
- * @returns {BigUint64Array}
2158
- */
2159
- export function get_children(parent) {
2160
- const ret = wasm.get_children(parent);
2161
- if (ret[3]) {
2162
- throw takeFromExternrefTable0(ret[2]);
2163
- }
2164
- var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
2165
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2166
- return v1;
2167
- }
2168
-
2169
- /**
2170
- * Retrieves the computed layout information for a specific node.
2171
- *
2172
- * # Arguments
2173
- *
2174
- * * `node` - The ID of the node to query.
2175
- *
2176
- * # Returns
2177
- *
2178
- * A `Layout` object containing the x, y, width, and height of the node.
2179
- *
2180
- * # Errors
2181
- *
2182
- * Returns a `JsValue` error if the node does not exist or layout information is unavailable.
2183
- * @param {bigint} node
2184
- * @returns {any}
2185
- */
2186
- export function get_layout(node) {
2187
- const ret = wasm.get_layout(node);
2188
- if (ret[2]) {
2189
- throw takeFromExternrefTable0(ret[1]);
2190
- }
2191
- return takeFromExternrefTable0(ret[0]);
2192
- }
2193
-
2194
- /**
2195
- * Retrieves the parent ID of a given node.
2196
- *
2197
- * # Arguments
2198
- *
2199
- * * `node` - The ID of the node to query.
2200
- *
2201
- * # Returns
2202
- *
2203
- * An `Option<u32>` containing the parent ID if it exists, or `None` if the node is a root or orphan.
2204
- *
2205
- * # Errors
2206
- *
2207
- * Returns a `JsValue` error if internal tree access fails.
2208
- * @param {bigint} node
2209
- * @returns {bigint | undefined}
2210
- */
2211
- export function get_parent(node) {
2212
- const ret = wasm.get_parent(node);
2213
- if (ret[3]) {
2214
- throw takeFromExternrefTable0(ret[2]);
2215
- }
2216
- return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
2217
- }
2218
-
2219
- /**
2220
- * Initialize the WASM module.
2221
- *
2222
- * This function is automatically called when the WASM module is loaded.
2223
- * It sets up the console error panic hook for better error messages in development.
2224
- */
2225
- export function init() {
2226
- wasm.init();
2227
- }
2228
-
2229
- /**
2230
- * Marks a node and its ancestors as dirty, requiring a layout re-computation.
2231
- *
2232
- * # Arguments
2233
- *
2234
- * * `node` - The ID of the node to mark dirty.
2235
- *
2236
- * # Errors
2237
- *
2238
- * Returns a `JsValue` error if the node does not exist.
2239
- * @param {bigint} node
2240
- */
2241
- export function mark_dirty(node) {
2242
- const ret = wasm.mark_dirty(node);
2243
- if (ret[1]) {
2244
- throw takeFromExternrefTable0(ret[0]);
2245
- }
2246
- }
2247
-
2248
- /**
2249
- * Creates a new leaf node with the specified style.
2250
- *
2251
- * # Arguments
2252
- *
2253
- * * `style` - The style object to apply to the new node.
2254
- *
2255
- * # Returns
2256
- *
2257
- * The ID of the created node as a `u32`.
2258
- *
2259
- * # Errors
2260
- *
2261
- * Returns a `JsValue` error if the style cannot be deserialized or if node creation fails.
2262
- * @param {any} style
2263
- * @returns {bigint}
2264
- */
2265
- export function new_leaf(style) {
2266
- const ret = wasm.new_leaf(style);
2267
- if (ret[2]) {
2268
- throw takeFromExternrefTable0(ret[1]);
2269
- }
2270
- return BigInt.asUintN(64, ret[0]);
2271
- }
2272
-
2273
- /**
2274
- * Creates a new node with children and the specified style.
2275
- *
2276
- * # Arguments
2277
- *
2278
- * * `style` - The style object to apply to the new node.
2279
- * * `children` - An array of child node IDs (`u32`) to attach to this node.
2280
- *
2281
- * # Returns
2282
- *
2283
- * The ID of the created node as a `u32`.
2284
- *
2285
- * # Errors
2286
- *
2287
- * Returns a `JsValue` error if the style cannot be deserialized or if node creation fails.
2288
- * @param {any} style
2289
- * @param {BigUint64Array} children
2290
- * @returns {bigint}
2291
- */
2292
- export function new_with_children(style, children) {
2293
- const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2294
- const len0 = WASM_VECTOR_LEN;
2295
- const ret = wasm.new_with_children(style, ptr0, len0);
2296
- if (ret[2]) {
2297
- throw takeFromExternrefTable0(ret[1]);
2298
- }
2299
- return BigInt.asUintN(64, ret[0]);
2300
- }
2301
-
2302
- /**
2303
- * Get the total number of nodes currently in the layout tree.
2304
- *
2305
- * # Returns
2306
- *
2307
- * The total count of all nodes in the tree.
2308
- * @returns {number}
2309
- */
2310
- export function node_count() {
2311
- const ret = wasm.node_count();
2312
- return ret >>> 0;
2313
- }
2314
-
2315
- /**
2316
- * Helper function to create a percent dimension
2317
- * @param {number} value
2318
- * @returns {Dimension}
2319
- */
2320
- export function percent(value) {
2321
- const ret = wasm.percent(value);
2322
- return Dimension.__wrap(ret);
2323
- }
2324
-
2325
- /**
2326
- * Helper function to create a pixel dimension
2327
- * @param {number} value
2328
- * @returns {Dimension}
2329
- */
2330
- export function px(value) {
2331
- const ret = wasm.px(value);
2332
- return Dimension.__wrap(ret);
2333
- }
2334
-
2335
- /**
2336
- * Removes a child node from a parent node.
2337
- *
2338
- * # Arguments
2339
- *
2340
- * * `parent` - The ID of the parent node.
2341
- * * `child` - The ID of the child node to remove.
2342
- *
2343
- * # Errors
2344
- *
2345
- * Returns a `JsValue` error if the child is not found in the parent.
2346
- * @param {bigint} parent
2347
- * @param {bigint} child
2348
- */
2349
- export function remove_child(parent, child) {
2350
- const ret = wasm.remove_child(parent, child);
2351
- if (ret[1]) {
2352
- throw takeFromExternrefTable0(ret[0]);
2353
- }
2354
- }
2355
-
2356
- /**
2357
- * Removes a node from the tree and frees its resources.
2358
- *
2359
- * # Arguments
2360
- *
2361
- * * `node` - The ID of the node to remove.
2362
- *
2363
- * # Errors
2364
- *
2365
- * Returns a `JsValue` error if the node does not exist or cannot be removed.
2366
- * @param {bigint} node
2367
- */
2368
- export function remove_node(node) {
2369
- const ret = wasm.remove_node(node);
2370
- if (ret[1]) {
2371
- throw takeFromExternrefTable0(ret[0]);
2372
- }
2373
- }
2374
-
2375
- /**
2376
- * Sets the children of a node, replacing any existing children.
2377
- *
2378
- * # Arguments
2379
- *
2380
- * * `parent` - The ID of the parent node.
2381
- * * `children` - An array of child node IDs to set.
2382
- *
2383
- * # Errors
2384
- *
2385
- * Returns a `JsValue` error if the operation fails.
2386
- * @param {bigint} parent
2387
- * @param {BigUint64Array} children
2388
- */
2389
- export function set_children(parent, children) {
2390
- const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2391
- const len0 = WASM_VECTOR_LEN;
2392
- const ret = wasm.set_children(parent, ptr0, len0);
2393
- if (ret[1]) {
2394
- throw takeFromExternrefTable0(ret[0]);
2395
- }
2396
- }
2397
-
2398
- /**
2399
- * Updates the style of an existing node.
2400
- *
2401
- * # Arguments
2402
- *
2403
- * * `node` - The ID of the node to update.
2404
- * * `style` - The new style object to apply.
2405
- *
2406
- * # Errors
2407
- *
2408
- * Returns a `JsValue` error if the style cannot be deserialized or if the node does not exist.
2409
- * @param {bigint} node
2410
- * @param {any} style
2411
- */
2412
- export function set_style(node, style) {
2413
- const ret = wasm.set_style(node, style);
2414
- if (ret[1]) {
2415
- throw takeFromExternrefTable0(ret[0]);
1502
+ setStyle(node, style) {
1503
+ _assertClass(style, Style);
1504
+ const ret = wasm.taffytree_setStyle(this.__wbg_ptr, node, style.__wbg_ptr);
1505
+ if (ret[1]) {
1506
+ throw takeFromExternrefTable0(ret[0]);
1507
+ }
2416
1508
  }
2417
1509
  }
1510
+ if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
2418
1511
 
2419
1512
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
2420
1513
 
@@ -2482,14 +1575,6 @@ function __wbg_get_imports() {
2482
1575
  const ret = arg0 in arg1;
2483
1576
  return ret;
2484
1577
  };
2485
- imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
2486
- const ret = typeof(arg0) === 'function';
2487
- return ret;
2488
- };
2489
- imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
2490
- const ret = arg0 === null;
2491
- return ret;
2492
- };
2493
1578
  imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
2494
1579
  const val = arg0;
2495
1580
  const ret = typeof(val) === 'object' && val !== null;
@@ -2524,18 +1609,10 @@ function __wbg_get_imports() {
2524
1609
  imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
2525
1610
  throw new Error(getStringFromWasm0(arg0, arg1));
2526
1611
  };
2527
- imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
2528
- const ret = arg0.call(arg1, arg2);
2529
- return ret;
2530
- }, arguments) };
2531
- imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
2532
- const ret = arg0.call(arg1);
1612
+ imports.wbg.__wbg_apply_52e9ae668d017009 = function() { return handleError(function (arg0, arg1, arg2) {
1613
+ const ret = arg0.apply(arg1, arg2);
2533
1614
  return ret;
2534
1615
  }, arguments) };
2535
- imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
2536
- const ret = arg0.done;
2537
- return ret;
2538
- };
2539
1616
  imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
2540
1617
  const ret = Object.entries(arg0);
2541
1618
  return ret;
@@ -2551,17 +1628,10 @@ function __wbg_get_imports() {
2551
1628
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2552
1629
  }
2553
1630
  };
2554
- imports.wbg.__wbg_error_7bc7d576a6aaf855 = function(arg0) {
2555
- console.error(arg0);
2556
- };
2557
1631
  imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
2558
1632
  const ret = arg0[arg1 >>> 0];
2559
1633
  return ret;
2560
1634
  };
2561
- imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
2562
- const ret = Reflect.get(arg0, arg1);
2563
- return ret;
2564
- }, arguments) };
2565
1635
  imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
2566
1636
  const ret = arg0[arg1];
2567
1637
  return ret;
@@ -2586,18 +1656,6 @@ function __wbg_get_imports() {
2586
1656
  const ret = result;
2587
1657
  return ret;
2588
1658
  };
2589
- imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
2590
- const ret = Array.isArray(arg0);
2591
- return ret;
2592
- };
2593
- imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
2594
- const ret = Number.isSafeInteger(arg0);
2595
- return ret;
2596
- };
2597
- imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
2598
- const ret = Symbol.iterator;
2599
- return ret;
2600
- };
2601
1659
  imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
2602
1660
  const ret = arg0.length;
2603
1661
  return ret;
@@ -2606,10 +1664,17 @@ function __wbg_get_imports() {
2606
1664
  const ret = arg0.length;
2607
1665
  return ret;
2608
1666
  };
1667
+ imports.wbg.__wbg_log_730ba2e365bddb50 = function(arg0, arg1) {
1668
+ console.log(getStringFromWasm0(arg0, arg1));
1669
+ };
2609
1670
  imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
2610
1671
  const ret = new Object();
2611
1672
  return ret;
2612
1673
  };
1674
+ imports.wbg.__wbg_new_25f239778d6112b9 = function() {
1675
+ const ret = new Array();
1676
+ return ret;
1677
+ };
2613
1678
  imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
2614
1679
  const ret = new Uint8Array(arg0);
2615
1680
  return ret;
@@ -2618,17 +1683,13 @@ function __wbg_get_imports() {
2618
1683
  const ret = new Error();
2619
1684
  return ret;
2620
1685
  };
2621
- imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
2622
- const ret = arg0.next;
2623
- return ret;
2624
- };
2625
- imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
2626
- const ret = arg0.next();
2627
- return ret;
2628
- }, arguments) };
2629
1686
  imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
2630
1687
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
2631
1688
  };
1689
+ imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
1690
+ const ret = arg0.push(arg1);
1691
+ return ret;
1692
+ };
2632
1693
  imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
2633
1694
  arg0[arg1] = arg2;
2634
1695
  };
@@ -2639,13 +1700,10 @@ function __wbg_get_imports() {
2639
1700
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2640
1701
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2641
1702
  };
2642
- imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
2643
- const ret = arg0.value;
1703
+ imports.wbg.__wbg_stringify_655a6390e1f5eb6b = function() { return handleError(function (arg0) {
1704
+ const ret = JSON.stringify(arg0);
2644
1705
  return ret;
2645
- };
2646
- imports.wbg.__wbg_warn_6e567d0d926ff881 = function(arg0) {
2647
- console.warn(arg0);
2648
- };
1706
+ }, arguments) };
2649
1707
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
2650
1708
  // Cast intrinsic for `Ref(String) -> Externref`.
2651
1709
  const ret = getStringFromWasm0(arg0, arg1);