taffy-js 0.2.10 → 0.2.12

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/pkg/taffy_wasm.js CHANGED
@@ -245,8 +245,9 @@ const TaffyTreeFinalization = (typeof FinalizationRegistry === 'undefined')
245
245
  *
246
246
  * @example
247
247
  * ```typescript
248
- * import { AlignContent, FlexWrap } from 'taffy-js';
248
+ * import { Style, AlignContent, FlexWrap } from 'taffy-js';
249
249
  *
250
+ * const style = new Style();
250
251
  * style.flexWrap = FlexWrap.Wrap;
251
252
  * style.alignContent = AlignContent.SpaceBetween; // Distribute lines evenly
252
253
  * ```
@@ -299,8 +300,9 @@ export const AlignContent = Object.freeze({
299
300
  *
300
301
  * @example
301
302
  * ```typescript
302
- * import { AlignItems } from 'taffy-js';
303
+ * import { Style, AlignItems } from 'taffy-js';
303
304
  *
305
+ * const style = new Style();
304
306
  * style.alignItems = AlignItems.Center; // Center items on cross axis
305
307
  * style.alignItems = AlignItems.Stretch; // Stretch items to fill container
306
308
  * ```
@@ -345,8 +347,9 @@ export const AlignItems = Object.freeze({
345
347
  *
346
348
  * @example
347
349
  * ```typescript
348
- * import { AlignSelf } from 'taffy-js';
350
+ * import { Style, AlignSelf } from 'taffy-js';
349
351
  *
352
+ * const style = new Style();
350
353
  * style.alignSelf = AlignSelf.Auto; // Use parent's align-items
351
354
  * style.alignSelf = AlignSelf.Center; // Override to center this item
352
355
  * ```
@@ -395,8 +398,9 @@ export const AlignSelf = Object.freeze({
395
398
  *
396
399
  * @example
397
400
  * ```typescript
398
- * import { BoxSizing } from 'taffy-js';
401
+ * import { Style, BoxSizing } from 'taffy-js';
399
402
  *
403
+ * const style = new Style();
400
404
  * style.boxSizing = BoxSizing.BorderBox; // Size includes padding and border
401
405
  * style.boxSizing = BoxSizing.ContentBox; // Size is content only
402
406
  * ```
@@ -421,8 +425,9 @@ export const BoxSizing = Object.freeze({
421
425
  *
422
426
  * @example
423
427
  * ```typescript
424
- * import { Display } from 'taffy-js';
428
+ * import { Style, Display } from 'taffy-js';
425
429
  *
430
+ * const style = new Style();
426
431
  * style.display = Display.Flex; // Enable flexbox layout
427
432
  * style.display = Display.Grid; // Enable grid layout
428
433
  * style.display = Display.None; // Hide element from layout
@@ -456,8 +461,9 @@ export const Display = Object.freeze({
456
461
  *
457
462
  * @example
458
463
  * ```typescript
459
- * import { FlexDirection } from 'taffy-js';
464
+ * import { Style, FlexDirection } from 'taffy-js';
460
465
  *
466
+ * const style = new Style();
461
467
  * style.flexDirection = FlexDirection.Row; // Horizontal, left to right
462
468
  * style.flexDirection = FlexDirection.Column; // Vertical, top to bottom
463
469
  * ```
@@ -490,8 +496,9 @@ export const FlexDirection = Object.freeze({
490
496
  *
491
497
  * @example
492
498
  * ```typescript
493
- * import { FlexWrap } from 'taffy-js';
499
+ * import { Style, FlexWrap } from 'taffy-js';
494
500
  *
501
+ * const style = new Style();
495
502
  * style.flexWrap = FlexWrap.NoWrap; // All items on single line
496
503
  * style.flexWrap = FlexWrap.Wrap; // Items wrap to new lines
497
504
  * ```
@@ -512,6 +519,42 @@ export const FlexWrap = Object.freeze({
512
519
  WrapReverse: 2, "2": "WrapReverse",
513
520
  });
514
521
 
522
+ /**
523
+ * Grid auto flow enumeration
524
+ *
525
+ * Controls whether grid items are placed row-wise or column-wise, and whether
526
+ * the sparse or dense packing algorithm is used.
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * import { Style, GridAutoFlow } from 'taffy-js';
531
+ *
532
+ * const style = new Style();
533
+ * style.gridAutoFlow = GridAutoFlow.Row; // Fill rows first
534
+ * style.gridAutoFlow = GridAutoFlow.Column; // Fill columns first
535
+ * style.gridAutoFlow = GridAutoFlow.RowDense; // Fill rows, pack densely
536
+ * ```
537
+ * @enum {0 | 1 | 2 | 3}
538
+ */
539
+ export const GridAutoFlow = Object.freeze({
540
+ /**
541
+ * Items are placed by filling each row in turn, adding new rows as necessary
542
+ */
543
+ Row: 0, "0": "Row",
544
+ /**
545
+ * Items are placed by filling each column in turn, adding new columns as necessary
546
+ */
547
+ Column: 1, "1": "Column",
548
+ /**
549
+ * Combines `Row` with the dense packing algorithm
550
+ */
551
+ RowDense: 2, "2": "RowDense",
552
+ /**
553
+ * Combines `Column` with the dense packing algorithm
554
+ */
555
+ ColumnDense: 3, "3": "ColumnDense",
556
+ });
557
+
515
558
  /**
516
559
  * Main axis alignment enumeration
517
560
  *
@@ -520,8 +563,9 @@ export const FlexWrap = Object.freeze({
520
563
  *
521
564
  * @example
522
565
  * ```typescript
523
- * import { JustifyContent } from 'taffy-js';
566
+ * import { Style, JustifyContent } from 'taffy-js';
524
567
  *
568
+ * const style = new Style();
525
569
  * style.justifyContent = JustifyContent.Center; // Center items
526
570
  * style.justifyContent = JustifyContent.SpaceBetween; // Distribute evenly
527
571
  * ```
@@ -574,6 +618,11 @@ export const JustifyContent = Object.freeze({
574
618
  *
575
619
  * @example
576
620
  * ```typescript
621
+ * const tree = new TaffyTree();
622
+ * const rootId = tree.newLeaf(new Style());
623
+ * const node = rootId;
624
+ *
625
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
577
626
  * const layout = tree.getLayout(node);
578
627
  *
579
628
  * console.log("Position:", layout.x, layout.y);
@@ -852,8 +901,9 @@ if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
852
901
  *
853
902
  * @example
854
903
  * ```typescript
855
- * import { Overflow } from 'taffy-js';
904
+ * import { Style, Overflow } from 'taffy-js';
856
905
  *
906
+ * const style = new Style();
857
907
  * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
858
908
  * ```
859
909
  * @enum {0 | 1 | 2 | 3}
@@ -885,8 +935,9 @@ export const Overflow = Object.freeze({
885
935
  *
886
936
  * @example
887
937
  * ```typescript
888
- * import { Position } from 'taffy-js';
938
+ * import { Style, Position } from 'taffy-js';
889
939
  *
940
+ * const style = new Style();
890
941
  * style.position = Position.Relative; // Normal document flow
891
942
  * style.position = Position.Absolute; // Removed from flow, uses inset values
892
943
  * ```
@@ -984,6 +1035,7 @@ export class Style {
984
1035
  *
985
1036
  * @example
986
1037
  * ```typescript
1038
+ * const style = new Style();
987
1039
  * style.border = { left: 1, right: 1, top: 1, bottom: 1 };
988
1040
  * ```
989
1041
  * @param {Rect<LengthPercentage>} val
@@ -998,6 +1050,7 @@ export class Style {
998
1050
  *
999
1051
  * @example
1000
1052
  * ```typescript
1053
+ * const style = new Style();
1001
1054
  * style.margin = { left: 10, right: 10, top: 5, bottom: 5 };
1002
1055
  * ```
1003
1056
  * @param {Rect<LengthPercentageAuto>} val
@@ -1005,6 +1058,20 @@ export class Style {
1005
1058
  set margin(val) {
1006
1059
  wasm.style_set_margin(this.__wbg_ptr, val);
1007
1060
  }
1061
+ /**
1062
+ * Gets the text-align property
1063
+ *
1064
+ * Used by block layout to implement legacy text alignment behavior.
1065
+ *
1066
+ * @returns - The current [`TextAlign`](JsTextAlign) value
1067
+ *
1068
+ * @defaultValue - `TextAlign.Auto`
1069
+ * @returns {TextAlign}
1070
+ */
1071
+ get textAlign() {
1072
+ const ret = wasm.style_textAlign(this.__wbg_ptr);
1073
+ return ret;
1074
+ }
1008
1075
  /**
1009
1076
  * Gets the align-items property
1010
1077
  *
@@ -1030,6 +1097,19 @@ export class Style {
1030
1097
  const ret = wasm.style_flexShrink(this.__wbg_ptr);
1031
1098
  return ret;
1032
1099
  }
1100
+ /**
1101
+ * Gets the grid-column property
1102
+ *
1103
+ * Defines which column in the grid the item should start and end at.
1104
+ * Corresponds to CSS `grid-column` shorthand.
1105
+ *
1106
+ * @returns - A `Line<GridPlacement>` with start and end placements
1107
+ * @returns {Line<GridPlacement>}
1108
+ */
1109
+ get gridColumn() {
1110
+ const ret = wasm.style_gridColumn(this.__wbg_ptr);
1111
+ return ret;
1112
+ }
1033
1113
  /**
1034
1114
  * Sets the display mode
1035
1115
  *
@@ -1038,6 +1118,7 @@ export class Style {
1038
1118
  *
1039
1119
  * @example
1040
1120
  * ```typescript
1121
+ * const style = new Style();
1041
1122
  * style.display = Display.Flex;
1042
1123
  * ```
1043
1124
  * @param {Display} val
@@ -1052,6 +1133,7 @@ export class Style {
1052
1133
  *
1053
1134
  * @example
1054
1135
  * ```typescript
1136
+ * const style = new Style();
1055
1137
  * style.padding = { left: 20, right: 20, top: 10, bottom: 10 };
1056
1138
  * ```
1057
1139
  * @param {Rect<LengthPercentage>} val
@@ -1071,6 +1153,37 @@ export class Style {
1071
1153
  const ret = wasm.style_aspectRatio(this.__wbg_ptr);
1072
1154
  return ret === 0x100000001 ? undefined : ret;
1073
1155
  }
1156
+ /**
1157
+ * Gets the justify-self property
1158
+ *
1159
+ * Overrides the parent's justify-items for this specific element in the inline axis.
1160
+ *
1161
+ * @returns - The current [`AlignSelf`](JsAlignSelf) value (returns `Auto` if not set)
1162
+ * @returns {AlignSelf | undefined}
1163
+ */
1164
+ get justifySelf() {
1165
+ const ret = wasm.style_justifySelf(this.__wbg_ptr);
1166
+ return ret === 8 ? undefined : ret;
1167
+ }
1168
+ /**
1169
+ * Sets the grid-row property
1170
+ *
1171
+ * @param val - A Line object with start and end GridPlacement values
1172
+ *
1173
+ * @example
1174
+ * ```typescript
1175
+ * const style = new Style();
1176
+ * style.display = Display.Grid;
1177
+ * // CSS: grid-row: 1 / 3
1178
+ * style.gridRow = { start: 1, end: 3 };
1179
+ * // CSS: grid-row: 2 / span 2
1180
+ * style.gridRow = { start: 2, end: { span: 2 } };
1181
+ * ```
1182
+ * @param {Line<GridPlacement>} val
1183
+ */
1184
+ set gridRow(val) {
1185
+ wasm.style_set_gridRow(this.__wbg_ptr, val);
1186
+ }
1074
1187
  /**
1075
1188
  * Sets the maximum size constraints
1076
1189
  *
@@ -1078,6 +1191,7 @@ export class Style {
1078
1191
  *
1079
1192
  * @example
1080
1193
  * ```typescript
1194
+ * const style = new Style();
1081
1195
  * style.maxSize = { width: "auto", height: 500 };
1082
1196
  * ```
1083
1197
  * @param {Size<Dimension>} val
@@ -1092,6 +1206,7 @@ export class Style {
1092
1206
  *
1093
1207
  * @example
1094
1208
  * ```typescript
1209
+ * const style = new Style();
1095
1210
  * style.minSize = { width: 100, height: "auto" };
1096
1211
  * ```
1097
1212
  * @param {Size<Dimension>} val
@@ -1106,6 +1221,7 @@ export class Style {
1106
1221
  *
1107
1222
  * @example
1108
1223
  * ```typescript
1224
+ * const style = new Style();
1109
1225
  * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
1110
1226
  * ```
1111
1227
  * @param {Point<Overflow>} val
@@ -1121,6 +1237,7 @@ export class Style {
1121
1237
  *
1122
1238
  * @example
1123
1239
  * ```typescript
1240
+ * const style = new Style();
1124
1241
  * style.position = Position.Absolute;
1125
1242
  * style.inset = { left: 10, top: 10, right: "auto", bottom: "auto" };
1126
1243
  * ```
@@ -1141,6 +1258,33 @@ export class Style {
1141
1258
  const ret = wasm.style_alignContent(this.__wbg_ptr);
1142
1259
  return ret === 9 ? undefined : ret;
1143
1260
  }
1261
+ /**
1262
+ * Gets whether this item is a table
1263
+ *
1264
+ * Table children are handled specially in block layout.
1265
+ *
1266
+ * @returns - Whether the item is treated as a table
1267
+ *
1268
+ * @defaultValue - `false`
1269
+ * @returns {boolean}
1270
+ */
1271
+ get itemIsTable() {
1272
+ const ret = wasm.style_itemIsTable(this.__wbg_ptr);
1273
+ return ret !== 0;
1274
+ }
1275
+ /**
1276
+ * Gets the justify-items property
1277
+ *
1278
+ * Defines the default justify-self for all children in the inline axis.
1279
+ * This is primarily used for CSS Grid layout.
1280
+ *
1281
+ * @returns - The current [`AlignItems`](JsAlignItems) value, or `undefined` if not set
1282
+ * @returns {AlignItems | undefined}
1283
+ */
1284
+ get justifyItems() {
1285
+ const ret = wasm.style_justifyItems(this.__wbg_ptr);
1286
+ return ret === 7 ? undefined : ret;
1287
+ }
1144
1288
  /**
1145
1289
  * Sets the flex grow factor
1146
1290
  *
@@ -1148,6 +1292,7 @@ export class Style {
1148
1292
  *
1149
1293
  * @example
1150
1294
  * ```typescript
1295
+ * const style = new Style();
1151
1296
  * style.flexGrow = 2;
1152
1297
  * ```
1153
1298
  * @param {number} val
@@ -1163,6 +1308,7 @@ export class Style {
1163
1308
  *
1164
1309
  * @example
1165
1310
  * ```typescript
1311
+ * const style = new Style();
1166
1312
  * style.flexWrap = FlexWrap.Wrap;
1167
1313
  * ```
1168
1314
  * @param {FlexWrap} val
@@ -1184,6 +1330,32 @@ export class Style {
1184
1330
  const ret = wasm.style_flexDirection(this.__wbg_ptr);
1185
1331
  return ret;
1186
1332
  }
1333
+ /**
1334
+ * Gets the grid-auto-flow property
1335
+ *
1336
+ * Controls how auto-placed items are inserted into the grid.
1337
+ *
1338
+ * @returns - The current [`GridAutoFlow`](JsGridAutoFlow) value
1339
+ *
1340
+ * @defaultValue - `GridAutoFlow.Row`
1341
+ * @returns {GridAutoFlow}
1342
+ */
1343
+ get gridAutoFlow() {
1344
+ const ret = wasm.style_gridAutoFlow(this.__wbg_ptr);
1345
+ return ret;
1346
+ }
1347
+ /**
1348
+ * Gets the grid-auto-rows property
1349
+ *
1350
+ * Defines the size of implicitly created rows.
1351
+ *
1352
+ * @returns - An array of track sizing functions
1353
+ * @returns {TrackSizingFunction[]}
1354
+ */
1355
+ get gridAutoRows() {
1356
+ const ret = wasm.style_gridAutoRows(this.__wbg_ptr);
1357
+ return ret;
1358
+ }
1187
1359
  /**
1188
1360
  * Sets the align-self property
1189
1361
  *
@@ -1191,6 +1363,7 @@ export class Style {
1191
1363
  *
1192
1364
  * @example
1193
1365
  * ```typescript
1366
+ * const style = new Style();
1194
1367
  * style.alignSelf = AlignSelf.Stretch;
1195
1368
  * ```
1196
1369
  * @param {AlignSelf | undefined} val
@@ -1205,6 +1378,7 @@ export class Style {
1205
1378
  *
1206
1379
  * @example
1207
1380
  * ```typescript
1381
+ * const style = new Style();
1208
1382
  * style.boxSizing = BoxSizing.ContentBox;
1209
1383
  * ```
1210
1384
  * @param {BoxSizing} val
@@ -1219,6 +1393,7 @@ export class Style {
1219
1393
  *
1220
1394
  * @example
1221
1395
  * ```typescript
1396
+ * const style = new Style();
1222
1397
  * style.flexBasis = 100;
1223
1398
  * ```
1224
1399
  * @param {Dimension} val
@@ -1226,6 +1401,21 @@ export class Style {
1226
1401
  set flexBasis(val) {
1227
1402
  wasm.style_set_flexBasis(this.__wbg_ptr, val);
1228
1403
  }
1404
+ /**
1405
+ * Sets the text-align property
1406
+ *
1407
+ * @param val - The new text-align value
1408
+ *
1409
+ * @example
1410
+ * ```typescript
1411
+ * const style = new Style();
1412
+ * style.textAlign = TextAlign.LegacyCenter;
1413
+ * ```
1414
+ * @param {TextAlign} val
1415
+ */
1416
+ set textAlign(val) {
1417
+ wasm.style_set_textAlign(this.__wbg_ptr, val);
1418
+ }
1229
1419
  /**
1230
1420
  * Gets the justify-content property
1231
1421
  *
@@ -1238,6 +1428,20 @@ export class Style {
1238
1428
  const ret = wasm.style_justifyContent(this.__wbg_ptr);
1239
1429
  return ret === 9 ? undefined : ret;
1240
1430
  }
1431
+ /**
1432
+ * Gets the scrollbar width
1433
+ *
1434
+ * The width of the scrollbar gutter when `overflow` is set to `Scroll`.
1435
+ *
1436
+ * @returns - The scrollbar width in pixels
1437
+ *
1438
+ * @defaultValue - `0`
1439
+ * @returns {number}
1440
+ */
1441
+ get scrollbarWidth() {
1442
+ const ret = wasm.style_scrollbarWidth(this.__wbg_ptr);
1443
+ return ret;
1444
+ }
1241
1445
  /**
1242
1446
  * Sets the align-items property
1243
1447
  *
@@ -1245,6 +1449,7 @@ export class Style {
1245
1449
  *
1246
1450
  * @example
1247
1451
  * ```typescript
1452
+ * const style = new Style();
1248
1453
  * style.alignItems = AlignItems.Center;
1249
1454
  * ```
1250
1455
  * @param {AlignItems | undefined} val
@@ -1259,6 +1464,7 @@ export class Style {
1259
1464
  *
1260
1465
  * @example
1261
1466
  * ```typescript
1467
+ * const style = new Style();
1262
1468
  * style.flexShrink = 2;
1263
1469
  * ```
1264
1470
  * @param {number} val
@@ -1266,6 +1472,39 @@ export class Style {
1266
1472
  set flexShrink(val) {
1267
1473
  wasm.style_set_flexShrink(this.__wbg_ptr, val);
1268
1474
  }
1475
+ /**
1476
+ * Sets the grid-column property
1477
+ *
1478
+ * @param val - A Line object with start and end GridPlacement values
1479
+ *
1480
+ * @example
1481
+ * ```typescript
1482
+ * const style = new Style();
1483
+ * style.display = Display.Grid;
1484
+ * // CSS: grid-column: 1 / 4
1485
+ * style.gridColumn = { start: 1, end: 4 };
1486
+ * // CSS: grid-column: auto / span 3
1487
+ * style.gridColumn = { start: "auto", end: { span: 3 } };
1488
+ * ```
1489
+ * @param {Line<GridPlacement>} val
1490
+ */
1491
+ set gridColumn(val) {
1492
+ wasm.style_set_gridColumn(this.__wbg_ptr, val);
1493
+ }
1494
+ /**
1495
+ * Gets whether this item is a replaced element
1496
+ *
1497
+ * Replaced elements have special sizing behavior (e.g., `<img>`, `<video>`).
1498
+ *
1499
+ * @returns - Whether the item is a replaced element
1500
+ *
1501
+ * @defaultValue - `false`
1502
+ * @returns {boolean}
1503
+ */
1504
+ get itemIsReplaced() {
1505
+ const ret = wasm.style_itemIsReplaced(this.__wbg_ptr);
1506
+ return ret !== 0;
1507
+ }
1269
1508
  /**
1270
1509
  * Sets the aspect ratio
1271
1510
  *
@@ -1273,6 +1512,7 @@ export class Style {
1273
1512
  *
1274
1513
  * @example
1275
1514
  * ```typescript
1515
+ * const style = new Style();
1276
1516
  * style.aspectRatio = 16 / 9;
1277
1517
  * ```
1278
1518
  * @param {number | undefined} val
@@ -1280,6 +1520,33 @@ export class Style {
1280
1520
  set aspectRatio(val) {
1281
1521
  wasm.style_set_aspectRatio(this.__wbg_ptr, val);
1282
1522
  }
1523
+ /**
1524
+ * Sets the justify-self property
1525
+ *
1526
+ * @param val - The new justify-self value, or `undefined`/`Auto` to inherit from parent
1527
+ *
1528
+ * @example
1529
+ * ```typescript
1530
+ * const style = new Style();
1531
+ * style.justifySelf = AlignSelf.End;
1532
+ * ```
1533
+ * @param {AlignSelf | undefined} val
1534
+ */
1535
+ set justifySelf(val) {
1536
+ wasm.style_set_justifySelf(this.__wbg_ptr, val);
1537
+ }
1538
+ /**
1539
+ * Gets the grid-auto-columns property
1540
+ *
1541
+ * Defines the size of implicitly created columns.
1542
+ *
1543
+ * @returns - An array of track sizing functions
1544
+ * @returns {TrackSizingFunction[]}
1545
+ */
1546
+ get gridAutoColumns() {
1547
+ const ret = wasm.style_gridAutoColumns(this.__wbg_ptr);
1548
+ return ret;
1549
+ }
1283
1550
  /**
1284
1551
  * Sets the align-content property
1285
1552
  *
@@ -1287,6 +1554,7 @@ export class Style {
1287
1554
  *
1288
1555
  * @example
1289
1556
  * ```typescript
1557
+ * const style = new Style();
1290
1558
  * style.alignContent = AlignContent.SpaceBetween;
1291
1559
  * ```
1292
1560
  * @param {AlignContent | undefined} val
@@ -1294,6 +1562,43 @@ export class Style {
1294
1562
  set alignContent(val) {
1295
1563
  wasm.style_set_alignContent(this.__wbg_ptr, val);
1296
1564
  }
1565
+ /**
1566
+ * Sets whether this item is a table
1567
+ *
1568
+ * @param val - Whether the item should be treated as a table
1569
+ * @param {boolean} val
1570
+ */
1571
+ set itemIsTable(val) {
1572
+ wasm.style_set_itemIsTable(this.__wbg_ptr, val);
1573
+ }
1574
+ /**
1575
+ * Sets the justify-items property
1576
+ *
1577
+ * @param val - The new justify-items value, or `undefined` to use default
1578
+ *
1579
+ * @example
1580
+ * ```typescript
1581
+ * const style = new Style();
1582
+ * style.display = Display.Grid;
1583
+ * style.justifyItems = AlignItems.Center;
1584
+ * ```
1585
+ * @param {AlignItems | undefined} val
1586
+ */
1587
+ set justifyItems(val) {
1588
+ wasm.style_set_justifyItems(this.__wbg_ptr, val);
1589
+ }
1590
+ /**
1591
+ * Gets the grid-template-rows property
1592
+ *
1593
+ * Defines the track sizing functions (heights) of the grid rows.
1594
+ *
1595
+ * @returns - An array of `GridTrack` values
1596
+ * @returns {GridTemplateComponent[]}
1597
+ */
1598
+ get gridTemplateRows() {
1599
+ const ret = wasm.style_gridTemplateRows(this.__wbg_ptr);
1600
+ return ret;
1601
+ }
1297
1602
  /**
1298
1603
  * Sets the flex direction
1299
1604
  *
@@ -1302,6 +1607,7 @@ export class Style {
1302
1607
  *
1303
1608
  * @example
1304
1609
  * ```typescript
1610
+ * const style = new Style();
1305
1611
  * style.flexDirection = FlexDirection.Column;
1306
1612
  * ```
1307
1613
  * @param {FlexDirection} val
@@ -1309,6 +1615,50 @@ export class Style {
1309
1615
  set flexDirection(val) {
1310
1616
  wasm.style_set_flexDirection(this.__wbg_ptr, val);
1311
1617
  }
1618
+ /**
1619
+ * Sets the grid-auto-flow property
1620
+ *
1621
+ * @param val - The new grid-auto-flow value
1622
+ *
1623
+ * @example
1624
+ * ```typescript
1625
+ * const style = new Style();
1626
+ * style.display = Display.Grid;
1627
+ * style.gridAutoFlow = GridAutoFlow.Column;
1628
+ * ```
1629
+ * @param {GridAutoFlow} val
1630
+ */
1631
+ set gridAutoFlow(val) {
1632
+ wasm.style_set_gridAutoFlow(this.__wbg_ptr, val);
1633
+ }
1634
+ /**
1635
+ * Sets the grid-auto-rows property
1636
+ *
1637
+ * @param val - An array of track sizing functions for implicit rows
1638
+ *
1639
+ * @example
1640
+ * ```typescript
1641
+ * const style = new Style();
1642
+ * style.display = Display.Grid;
1643
+ * style.gridAutoRows = [{ min: "auto", max: "auto" }];
1644
+ * ```
1645
+ * @param {TrackSizingFunction[]} val
1646
+ */
1647
+ set gridAutoRows(val) {
1648
+ wasm.style_set_gridAutoRows(this.__wbg_ptr, val);
1649
+ }
1650
+ /**
1651
+ * Gets the grid-template-areas property
1652
+ *
1653
+ * Defines named grid areas that can be referenced by grid items.
1654
+ *
1655
+ * @returns - An array of `GridArea` values
1656
+ * @returns {GridTemplateArea[]}
1657
+ */
1658
+ get gridTemplateAreas() {
1659
+ const ret = wasm.style_gridTemplateAreas(this.__wbg_ptr);
1660
+ return ret;
1661
+ }
1312
1662
  /**
1313
1663
  * Sets the justify-content property
1314
1664
  *
@@ -1316,6 +1666,7 @@ export class Style {
1316
1666
  *
1317
1667
  * @example
1318
1668
  * ```typescript
1669
+ * const style = new Style();
1319
1670
  * style.justifyContent = JustifyContent.Center;
1320
1671
  * ```
1321
1672
  * @param {JustifyContent | undefined} val
@@ -1323,6 +1674,154 @@ export class Style {
1323
1674
  set justifyContent(val) {
1324
1675
  wasm.style_set_justifyContent(this.__wbg_ptr, val);
1325
1676
  }
1677
+ /**
1678
+ * Sets the scrollbar width
1679
+ *
1680
+ * @param val - The scrollbar width in pixels
1681
+ *
1682
+ * @example
1683
+ * ```typescript
1684
+ * const style = new Style();
1685
+ * style.overflow = { x: Overflow.Scroll, y: Overflow.Scroll };
1686
+ * style.scrollbarWidth = 15;
1687
+ * ```
1688
+ * @param {number} val
1689
+ */
1690
+ set scrollbarWidth(val) {
1691
+ wasm.style_set_scrollbarWidth(this.__wbg_ptr, val);
1692
+ }
1693
+ /**
1694
+ * Sets whether this item is a replaced element
1695
+ *
1696
+ * @param val - Whether the item should be treated as a replaced element
1697
+ * @param {boolean} val
1698
+ */
1699
+ set itemIsReplaced(val) {
1700
+ wasm.style_set_itemIsReplaced(this.__wbg_ptr, val);
1701
+ }
1702
+ /**
1703
+ * Gets the grid-template-columns property
1704
+ *
1705
+ * Defines the track sizing functions (widths) of the grid columns.
1706
+ *
1707
+ * @returns - An array of `GridTrack` values
1708
+ * @returns {GridTemplateComponent[]}
1709
+ */
1710
+ get gridTemplateColumns() {
1711
+ const ret = wasm.style_gridTemplateColumns(this.__wbg_ptr);
1712
+ return ret;
1713
+ }
1714
+ /**
1715
+ * Sets the grid-auto-columns property
1716
+ *
1717
+ * @param val - An array of track sizing functions for implicit columns
1718
+ * @param {TrackSizingFunction[]} val
1719
+ */
1720
+ set gridAutoColumns(val) {
1721
+ wasm.style_set_gridAutoColumns(this.__wbg_ptr, val);
1722
+ }
1723
+ /**
1724
+ * Sets the grid-template-rows property
1725
+ *
1726
+ * @param val - An array of GridTrack objects
1727
+ * @param {GridTemplateComponent[]} val
1728
+ */
1729
+ set gridTemplateRows(val) {
1730
+ wasm.style_set_gridTemplateRows(this.__wbg_ptr, val);
1731
+ }
1732
+ /**
1733
+ * Gets the grid-template-row-names property
1734
+ *
1735
+ * Defines the named lines between the rows.
1736
+ *
1737
+ * @returns - An array of arrays of line names
1738
+ * @returns {string[][]}
1739
+ */
1740
+ get gridTemplateRowNames() {
1741
+ const ret = wasm.style_gridTemplateRowNames(this.__wbg_ptr);
1742
+ return ret;
1743
+ }
1744
+ /**
1745
+ * Sets the grid-template-areas property
1746
+ *
1747
+ * @param val - An array of named grid area definitions
1748
+ *
1749
+ * @example
1750
+ * ```typescript
1751
+ * const style = new Style();
1752
+ * style.display = Display.Grid;
1753
+ * style.gridTemplateAreas = [
1754
+ * { name: "header", rowStart: 1, rowEnd: 2, columnStart: 1, columnEnd: 4 },
1755
+ * { name: "main", rowStart: 2, rowEnd: 4, columnStart: 2, columnEnd: 4 }
1756
+ * ];
1757
+ * ```
1758
+ * @param {GridTemplateArea[]} val
1759
+ */
1760
+ set gridTemplateAreas(val) {
1761
+ wasm.style_set_gridTemplateAreas(this.__wbg_ptr, val);
1762
+ }
1763
+ /**
1764
+ * Sets the grid-template-columns property
1765
+ *
1766
+ * @param val - An array of GridTrack objects
1767
+ *
1768
+ * @example
1769
+ * ```typescript
1770
+ * const style = new Style();
1771
+ * style.display = Display.Grid;
1772
+ * style.gridTemplateColumns = [
1773
+ * { min: 200, max: 200 },
1774
+ * { min: "auto", max: "1fr" },
1775
+ * { min: "auto", max: "1fr" }
1776
+ * ];
1777
+ * ```
1778
+ * @param {GridTemplateComponent[]} val
1779
+ */
1780
+ set gridTemplateColumns(val) {
1781
+ wasm.style_set_gridTemplateColumns(this.__wbg_ptr, val);
1782
+ }
1783
+ /**
1784
+ * Gets the grid-template-column-names property
1785
+ *
1786
+ * Defines the named lines between the columns.
1787
+ *
1788
+ * @returns - An array of arrays of line names
1789
+ * @returns {string[][]}
1790
+ */
1791
+ get gridTemplateColumnNames() {
1792
+ const ret = wasm.style_gridTemplateColumnNames(this.__wbg_ptr);
1793
+ return ret;
1794
+ }
1795
+ /**
1796
+ * Sets the grid-template-row-names property
1797
+ *
1798
+ * @param val - An array of arrays of line names
1799
+ *
1800
+ * @example
1801
+ * ```typescript
1802
+ * const style = new Style();
1803
+ * style.gridTemplateRowNames = [["header-start"], ["header-end", "main-start"], ["main-end"]];
1804
+ * ```
1805
+ * @param {string[][]} val
1806
+ */
1807
+ set gridTemplateRowNames(val) {
1808
+ wasm.style_set_gridTemplateRowNames(this.__wbg_ptr, val);
1809
+ }
1810
+ /**
1811
+ * Sets the grid-template-column-names property
1812
+ *
1813
+ * @param val - An array of arrays of line names
1814
+ *
1815
+ * @example
1816
+ * ```typescript
1817
+ * const style = new Style();
1818
+ * style.gridTemplateColumnNames = [["sidebar-start"], ["sidebar-end", "main-start"], ["main-end"]];
1819
+ * ```
1820
+ * @param {string[][]} val
1821
+ */
1822
+ set gridTemplateColumnNames(val) {
1823
+ wasm.style_set_gridTemplateColumnNames(this.__wbg_ptr, val);
1824
+ }
1326
1825
  /**
1327
1826
  * Gets the gap
1328
1827
  *
@@ -1431,6 +1930,7 @@ export class Style {
1431
1930
  *
1432
1931
  * @example
1433
1932
  * ```typescript
1933
+ * const style = new Style();
1434
1934
  * style.gap = { width: 10, height: 10 };
1435
1935
  * ```
1436
1936
  * @param {Size<LengthPercentage>} val
@@ -1438,6 +1938,19 @@ export class Style {
1438
1938
  set gap(val) {
1439
1939
  wasm.style_set_gap(this.__wbg_ptr, val);
1440
1940
  }
1941
+ /**
1942
+ * Gets the grid-row property
1943
+ *
1944
+ * Defines which row in the grid the item should start and end at.
1945
+ * Corresponds to CSS `grid-row` shorthand.
1946
+ *
1947
+ * @returns - A `Line<GridPlacement>` with start and end placements
1948
+ * @returns {Line<GridPlacement>}
1949
+ */
1950
+ get gridRow() {
1951
+ const ret = wasm.style_gridRow(this.__wbg_ptr);
1952
+ return ret;
1953
+ }
1441
1954
  /**
1442
1955
  * Gets the maximum size constraints
1443
1956
  *
@@ -1491,6 +2004,7 @@ export class Style {
1491
2004
  *
1492
2005
  * @example
1493
2006
  * ```typescript
2007
+ * const style = new Style();
1494
2008
  * style.size = { width: 200, height: "100%" };
1495
2009
  * ```
1496
2010
  * @param {Size<Dimension>} val
@@ -1532,6 +2046,7 @@ export class Style {
1532
2046
  *
1533
2047
  * @example
1534
2048
  * ```typescript
2049
+ * const style = new Style();
1535
2050
  * style.position = Position.Absolute;
1536
2051
  * style.inset = { left: 0, top: 0, right: "auto", bottom: "auto" };
1537
2052
  * ```
@@ -1552,6 +2067,8 @@ if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
1552
2067
  * @example
1553
2068
  * ```typescript
1554
2069
  * try {
2070
+ * const tree = new TaffyTree();
2071
+ * const node = tree.newLeaf(new Style());
1555
2072
  * tree.remove(node);
1556
2073
  * } catch (e) {
1557
2074
  * if (e instanceof TaffyError) {
@@ -1646,6 +2163,11 @@ export class TaffyTree {
1646
2163
  *
1647
2164
  * @example
1648
2165
  * ```typescript
2166
+ * const tree = new TaffyTree();
2167
+ * const rootId = tree.newLeaf(new Style());
2168
+ * const nodeId = rootId;
2169
+ * const availableSpace = { width: 100, height: 100 };
2170
+ *
1649
2171
  * // After updating text content
1650
2172
  * tree.setNodeContext(nodeId, { text: "Updated text" });
1651
2173
  * tree.markDirty(nodeId);
@@ -1669,6 +2191,8 @@ export class TaffyTree {
1669
2191
  *
1670
2192
  * @example
1671
2193
  * ```typescript
2194
+ * const tree = new TaffyTree();
2195
+ * const rootId = tree.newLeaf(new Style());
1672
2196
  * tree.printTree(rootId);
1673
2197
  * // Output appears in browser console
1674
2198
  * ```
@@ -1688,6 +2212,8 @@ export class TaffyTree {
1688
2212
  *
1689
2213
  * @example
1690
2214
  * ```typescript
2215
+ * const tree = new TaffyTree();
2216
+ * const parentId = tree.newLeaf(new Style());
1691
2217
  * const count: number = tree.childCount(parentId);
1692
2218
  * ```
1693
2219
  * @param {bigint} parent
@@ -1709,6 +2235,10 @@ export class TaffyTree {
1709
2235
  *
1710
2236
  * @example
1711
2237
  * ```typescript
2238
+ * const tree = new TaffyTree();
2239
+ * const parentId = tree.newLeaf(new Style());
2240
+ * const childId = tree.newLeaf(new Style());
2241
+ * tree.addChild(parentId, childId);
1712
2242
  * tree.removeChild(parentId, childId);
1713
2243
  * ```
1714
2244
  * @param {bigint} parent
@@ -1734,6 +2264,11 @@ export class TaffyTree {
1734
2264
  *
1735
2265
  * @example
1736
2266
  * ```typescript
2267
+ * const tree = new TaffyTree();
2268
+ * const parentId = tree.newLeaf(new Style());
2269
+ * const child1 = tree.newLeaf(new Style());
2270
+ * const child2 = tree.newLeaf(new Style());
2271
+ * const child3 = tree.newLeaf(new Style());
1737
2272
  * const children = BigUint64Array.from([child1, child2, child3]);
1738
2273
  * tree.setChildren(parentId, children);
1739
2274
  * ```
@@ -1774,31 +2309,36 @@ export class TaffyTree {
1774
2309
  * to compute layouts for all nodes in the tree.
1775
2310
  *
1776
2311
  * @param node - The root node ID to compute layout for
1777
- * @param available_space - The available space constraints
2312
+ * @param availableSpace - The available space constraints
1778
2313
  *
1779
2314
  * @example
1780
2315
  * ```typescript
2316
+ * const tree = new TaffyTree();
2317
+ * const rootId = tree.newLeaf(new Style());
2318
+ *
1781
2319
  * // Fixed size container
1782
- * { width: 800, height: 600 }
2320
+ * tree.computeLayout(rootId, { width: 800, height: 600 });
1783
2321
  *
1784
2322
  * // Flexible width, fixed height
1785
- * { width: "maxContent", height: 600 }
2323
+ * tree.computeLayout(rootId, { width: "max-content", height: 600 });
1786
2324
  *
1787
2325
  * // Minimum content size
1788
- * { width: "minContent", height: "minContent" }
2326
+ * tree.computeLayout(rootId, { width: "min-content", height: "min-content" });
1789
2327
  * ```
1790
2328
  *
1791
2329
  * @throws `TaffyError` if the node does not exist or available space is invalid
1792
2330
  *
1793
2331
  * @example
1794
2332
  * ```typescript
2333
+ * const tree = new TaffyTree();
2334
+ * const rootId = tree.newLeaf(new Style());
1795
2335
  * tree.computeLayout(rootId, { width: 800, height: 600 });
1796
2336
  * ```
1797
2337
  * @param {bigint} node
1798
- * @param {Size<AvailableSpace>} available_space
2338
+ * @param {Size<AvailableSpace>} availableSpace
1799
2339
  */
1800
- computeLayout(node, available_space) {
1801
- const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, available_space);
2340
+ computeLayout(node, availableSpace) {
2341
+ const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, availableSpace);
1802
2342
  if (ret[1]) {
1803
2343
  throw takeFromExternrefTable0(ret[0]);
1804
2344
  }
@@ -1812,6 +2352,7 @@ export class TaffyTree {
1812
2352
  *
1813
2353
  * @example
1814
2354
  * ```typescript
2355
+ * const tree = new TaffyTree();
1815
2356
  * tree.enableRounding();
1816
2357
  * ```
1817
2358
  */
@@ -1827,6 +2368,8 @@ export class TaffyTree {
1827
2368
  *
1828
2369
  * @example
1829
2370
  * ```typescript
2371
+ * const tree = new TaffyTree();
2372
+ * const node = tree.newLeaf(new Style());
1830
2373
  * tree.disableRounding();
1831
2374
  * const layout = tree.getLayout(node);
1832
2375
  * console.log(layout.x);
@@ -1844,6 +2387,8 @@ export class TaffyTree {
1844
2387
  *
1845
2388
  * @example
1846
2389
  * ```typescript
2390
+ * const tree = new TaffyTree();
2391
+ * const nodeId = tree.newLeaf(new Style());
1847
2392
  * interface Context { text: string };
1848
2393
  * const context = tree.getNodeContext(nodeId) as Context | undefined;
1849
2394
  * if (context) {
@@ -1873,6 +2418,8 @@ export class TaffyTree {
1873
2418
  *
1874
2419
  * @example
1875
2420
  * ```typescript
2421
+ * const tree = new TaffyTree();
2422
+ * const nodeId = tree.newLeaf(new Style());
1876
2423
  * interface Context { text: string };
1877
2424
  * tree.setNodeContext(nodeId, { text: "Updated text" } as Context);
1878
2425
  * ```
@@ -1892,6 +2439,7 @@ export class TaffyTree {
1892
2439
  *
1893
2440
  * @example
1894
2441
  * ```typescript
2442
+ * const tree = new TaffyTree();
1895
2443
  * const count: number = tree.totalNodeCount();
1896
2444
  * ```
1897
2445
  * @returns {number}
@@ -1912,6 +2460,8 @@ export class TaffyTree {
1912
2460
  *
1913
2461
  * @example
1914
2462
  * ```typescript
2463
+ * const tree = new TaffyTree();
2464
+ * const nodeId = tree.newLeaf(new Style());
1915
2465
  * const layout: Layout = tree.unroundedLayout(nodeId);
1916
2466
  * console.log(`Exact width: ${layout.width}`);
1917
2467
  * ```
@@ -1937,6 +2487,7 @@ export class TaffyTree {
1937
2487
  *
1938
2488
  * @example
1939
2489
  * ```typescript
2490
+ * const tree = new TaffyTree();
1940
2491
  * const containerStyle = new Style();
1941
2492
  * containerStyle.display = Display.Flex;
1942
2493
  *
@@ -1974,6 +2525,10 @@ export class TaffyTree {
1974
2525
  *
1975
2526
  * @example
1976
2527
  * ```typescript
2528
+ * const tree = new TaffyTree();
2529
+ * const parentId = tree.newLeaf(new Style());
2530
+ * const childId = tree.newLeaf(new Style());
2531
+ * tree.addChild(parentId, childId);
1977
2532
  * const firstChild: bigint = tree.getChildAtIndex(parentId, 0);
1978
2533
  * ```
1979
2534
  * @param {bigint} parent
@@ -1987,6 +2542,28 @@ export class TaffyTree {
1987
2542
  }
1988
2543
  return BigInt.asUintN(64, ret[0]);
1989
2544
  }
2545
+ /**
2546
+ * Gets detailed layout information for grid layouts
2547
+ *
2548
+ * @note
2549
+ * This method is only available when the `detailed_layout_info`
2550
+ * feature is enabled.
2551
+ *
2552
+ * @param node - The node ID
2553
+ *
2554
+ * @returns - Detailed grid info or "None" for non-grid nodes
2555
+ *
2556
+ * @throws `TaffyError` if the node does not exist
2557
+ * @param {bigint} node
2558
+ * @returns {any}
2559
+ */
2560
+ detailedLayoutInfo(node) {
2561
+ const ret = wasm.taffytree_detailedLayoutInfo(this.__wbg_ptr, node);
2562
+ if (ret[2]) {
2563
+ throw takeFromExternrefTable0(ret[1]);
2564
+ }
2565
+ return takeFromExternrefTable0(ret[0]);
2566
+ }
1990
2567
  /**
1991
2568
  * Gets a mutable reference to the context value for a node
1992
2569
  *
@@ -2017,6 +2594,9 @@ export class TaffyTree {
2017
2594
  *
2018
2595
  * @example
2019
2596
  * ```typescript
2597
+ * const tree = new TaffyTree();
2598
+ * const parentId = tree.newLeaf(new Style());
2599
+ * const childId = tree.newLeaf(new Style());
2020
2600
  * tree.insertChildAtIndex(parentId, 0, childId);
2021
2601
  * ```
2022
2602
  * @param {bigint} parent
@@ -2045,6 +2625,7 @@ export class TaffyTree {
2045
2625
  * ```typescript
2046
2626
  * interface TextContext { text: string; isBold: boolean; }
2047
2627
  *
2628
+ * const tree = new TaffyTree();
2048
2629
  * const style = new Style();
2049
2630
  * const context: TextContext = { text: "Hello, World!", isBold: true };
2050
2631
  * const nodeId: bigint = tree.newLeafWithContext(style, context);
@@ -2073,6 +2654,10 @@ export class TaffyTree {
2073
2654
  *
2074
2655
  * @example
2075
2656
  * ```typescript
2657
+ * const tree = new TaffyTree();
2658
+ * const parentId = tree.newLeaf(new Style());
2659
+ * const childId = tree.newLeaf(new Style());
2660
+ * tree.addChild(parentId, childId);
2076
2661
  * const removedId: bigint = tree.removeChildAtIndex(parentId, 0);
2077
2662
  * ```
2078
2663
  * @param {bigint} parent
@@ -2092,21 +2677,28 @@ export class TaffyTree {
2092
2677
  * Removes children from `start_index` (inclusive) to `end_index` (exclusive).
2093
2678
  *
2094
2679
  * @param parent - The parent node ID
2095
- * @param start_index - Start of range (inclusive)
2096
- * @param end_index - End of range (exclusive)
2680
+ * @param startIndex - Start of range (inclusive)
2681
+ * @param endIndex - End of range (exclusive)
2097
2682
  *
2098
2683
  * @throws `TaffyError` if the parent node does not exist or range is invalid
2099
2684
  *
2100
2685
  * @example
2101
2686
  * ```typescript
2687
+ * const tree = new TaffyTree();
2688
+ * const parentId = tree.newLeaf(new Style());
2689
+ * const child1 = tree.newLeaf(new Style());
2690
+ * const child2 = tree.newLeaf(new Style());
2691
+ * const child3 = tree.newLeaf(new Style());
2692
+ * tree.setChildren(parentId, BigUint64Array.from([child1, child2, child3]));
2693
+ *
2102
2694
  * tree.removeChildrenRange(parentId, 1, 3);
2103
2695
  * ```
2104
2696
  * @param {bigint} parent
2105
- * @param {number} start_index
2106
- * @param {number} end_index
2697
+ * @param {number} startIndex
2698
+ * @param {number} endIndex
2107
2699
  */
2108
- removeChildrenRange(parent, start_index, end_index) {
2109
- const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, start_index, end_index);
2700
+ removeChildrenRange(parent, startIndex, endIndex) {
2701
+ const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, startIndex, endIndex);
2110
2702
  if (ret[1]) {
2111
2703
  throw takeFromExternrefTable0(ret[0]);
2112
2704
  }
@@ -2116,7 +2708,7 @@ export class TaffyTree {
2116
2708
  *
2117
2709
  * @param parent - The parent node ID
2118
2710
  * @param index - The index of the child to replace (0-based)
2119
- * @param new_child - The new child node ID
2711
+ * @param newChild - The new child node ID
2120
2712
  *
2121
2713
  * @returns - The replaced (old) child ID (`bigint`)
2122
2714
  *
@@ -2124,15 +2716,23 @@ export class TaffyTree {
2124
2716
  *
2125
2717
  * @example
2126
2718
  * ```typescript
2719
+ * const tree = new TaffyTree();
2720
+ * const parentId = tree.newLeaf(new Style());
2721
+ * const oldChild = tree.newLeaf(new Style());
2722
+ * const newChildId = tree.newLeaf(new Style());
2723
+ * tree.addChild(parentId, oldChild);
2724
+ * const child = tree.newLeaf(new Style()); // filler child at index 0 if needed, but index 1 implies 2 children
2725
+ * tree.insertChildAtIndex(parentId, 0, child);
2726
+ *
2127
2727
  * const oldChildId: bigint = tree.replaceChildAtIndex(parentId, 1, newChildId);
2128
2728
  * ```
2129
2729
  * @param {bigint} parent
2130
2730
  * @param {number} index
2131
- * @param {bigint} new_child
2731
+ * @param {bigint} newChild
2132
2732
  * @returns {bigint}
2133
2733
  */
2134
- replaceChildAtIndex(parent, index, new_child) {
2135
- const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, new_child);
2734
+ replaceChildAtIndex(parent, index, newChild) {
2735
+ const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, newChild);
2136
2736
  if (ret[2]) {
2137
2737
  throw takeFromExternrefTable0(ret[1]);
2138
2738
  }
@@ -2146,19 +2746,24 @@ export class TaffyTree {
2146
2746
  * called for each leaf node that needs measurement.
2147
2747
  *
2148
2748
  * @param node - The root node ID to compute layout for
2149
- * @param available_space - The available space constraints
2150
- * @param measure_func - A function that measures leaf node content
2749
+ * @param availableSpace - The available space constraints
2750
+ * @param measureFunc - A function that measures leaf node content
2151
2751
  *
2152
2752
  * @throws `TaffyError` if the node does not exist or available space is invalid
2153
2753
  *
2154
2754
  * @example
2155
2755
  * ```typescript
2756
+ * const tree = new TaffyTree();
2757
+ * const rootId = tree.newLeaf(new Style());
2758
+ *
2759
+ * const measureText = (text: string, width: number) => ({ width: 0, height: 0 });
2760
+ *
2156
2761
  * tree.computeLayoutWithMeasure(
2157
2762
  * rootId,
2158
- * { width: 800, height: "maxContent" },
2763
+ * { width: 800, height: "max-content" },
2159
2764
  * (known, available, node, context, style) => {
2160
2765
  * if (context?.text) {
2161
- * const measured = measureText(context.text, available.width);
2766
+ * const measured = measureText(context.text, available.width as number);
2162
2767
  * return { width: measured.width, height: measured.height };
2163
2768
  * }
2164
2769
  * return { width: 0, height: 0 };
@@ -2166,11 +2771,11 @@ export class TaffyTree {
2166
2771
  * );
2167
2772
  * ```
2168
2773
  * @param {bigint} node
2169
- * @param {Size<AvailableSpace>} available_space
2170
- * @param {MeasureFunction} measure_func
2774
+ * @param {Size<AvailableSpace>} availableSpace
2775
+ * @param {MeasureFunction} measureFunc
2171
2776
  */
2172
- computeLayoutWithMeasure(node, available_space, measure_func) {
2173
- const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, available_space, measure_func);
2777
+ computeLayoutWithMeasure(node, availableSpace, measureFunc) {
2778
+ const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, availableSpace, measureFunc);
2174
2779
  if (ret[1]) {
2175
2780
  throw takeFromExternrefTable0(ret[0]);
2176
2781
  }
@@ -2187,6 +2792,9 @@ export class TaffyTree {
2187
2792
  *
2188
2793
  * @example
2189
2794
  * ```typescript
2795
+ * const tree = new TaffyTree();
2796
+ * const id1 = tree.newLeaf(new Style());
2797
+ * const id2 = tree.newLeaf(new Style());
2190
2798
  * const nodes = BigUint64Array.from([id1, id2]);
2191
2799
  * const contexts = tree.getDisjointNodeContextMut(nodes);
2192
2800
  * ```
@@ -2229,6 +2837,7 @@ export class TaffyTree {
2229
2837
  *
2230
2838
  * @example
2231
2839
  * ```typescript
2840
+ * const tree = new TaffyTree();
2232
2841
  * tree.clear();
2233
2842
  * console.log(tree.totalNodeCount());
2234
2843
  * ```
@@ -2250,6 +2859,11 @@ export class TaffyTree {
2250
2859
  *
2251
2860
  * @example
2252
2861
  * ```typescript
2862
+ * const tree = new TaffyTree();
2863
+ * const rootId = tree.newLeaf(new Style());
2864
+ * const nodeId = rootId;
2865
+ * const availableSpace = { width: 100, height: 100 };
2866
+ *
2253
2867
  * if (tree.dirty(nodeId)) {
2254
2868
  * tree.computeLayout(rootId, availableSpace);
2255
2869
  * }
@@ -2275,6 +2889,8 @@ export class TaffyTree {
2275
2889
  *
2276
2890
  * @example
2277
2891
  * ```typescript
2892
+ * const tree = new TaffyTree();
2893
+ * const nodeId = tree.newLeaf(new Style());
2278
2894
  * const style: Style = tree.getStyle(nodeId);
2279
2895
  * console.log('Flex grow:', style.flexGrow);
2280
2896
  * ```
@@ -2302,6 +2918,12 @@ export class TaffyTree {
2302
2918
  *
2303
2919
  * @example
2304
2920
  * ```typescript
2921
+ * const tree = new TaffyTree();
2922
+ * const style = new Style();
2923
+ * style.size = { width: 100, height: 100 };
2924
+ * const rootId = tree.newLeaf(style);
2925
+ * const nodeId = rootId;
2926
+ *
2305
2927
  * tree.computeLayout(rootId, { width: 800, height: 600 });
2306
2928
  * const layout: Layout = tree.getLayout(nodeId);
2307
2929
  * console.log(`Position: (${layout.x}, ${layout.y}), Size: ${layout.width}x${layout.height}`);
@@ -2325,7 +2947,11 @@ export class TaffyTree {
2325
2947
  *
2326
2948
  * @example
2327
2949
  * ```typescript
2328
- * const parentId: bigint | undefined = tree.parent(childId);
2950
+ * const tree = new TaffyTree();
2951
+ * const parentId = tree.newLeaf(new Style());
2952
+ * const childId = tree.newLeaf(new Style());
2953
+ * tree.addChild(parentId, childId);
2954
+ * const parent: bigint | undefined = tree.parent(childId);
2329
2955
  * ```
2330
2956
  * @param {bigint} child
2331
2957
  * @returns {bigint | undefined}
@@ -2348,6 +2974,8 @@ export class TaffyTree {
2348
2974
  *
2349
2975
  * @example
2350
2976
  * ```typescript
2977
+ * const tree = new TaffyTree();
2978
+ * const nodeId = tree.newLeaf(new Style());
2351
2979
  * try {
2352
2980
  * const removedId: bigint = tree.remove(nodeId);
2353
2981
  * } catch (e) {
@@ -2375,6 +3003,8 @@ export class TaffyTree {
2375
3003
  *
2376
3004
  * @example
2377
3005
  * ```typescript
3006
+ * const tree = new TaffyTree();
3007
+ * const parentId = tree.newLeaf(new Style());
2378
3008
  * const children: BigUint64Array = tree.children(parentId);
2379
3009
  * ```
2380
3010
  * @param {bigint} parent
@@ -2401,6 +3031,7 @@ export class TaffyTree {
2401
3031
  *
2402
3032
  * @example
2403
3033
  * ```typescript
3034
+ * const tree = new TaffyTree();
2404
3035
  * const style = new Style();
2405
3036
  * style.size = { width: 100, height: 50 };
2406
3037
  * const nodeId: bigint = tree.newLeaf(style);
@@ -2428,6 +3059,9 @@ export class TaffyTree {
2428
3059
  *
2429
3060
  * @example
2430
3061
  * ```typescript
3062
+ * const tree = new TaffyTree();
3063
+ * const parentId = tree.newLeaf(new Style());
3064
+ * const childId = tree.newLeaf(new Style());
2431
3065
  * tree.addChild(parentId, childId);
2432
3066
  * ```
2433
3067
  * @param {bigint} parent
@@ -2452,6 +3086,8 @@ export class TaffyTree {
2452
3086
  *
2453
3087
  * @example
2454
3088
  * ```typescript
3089
+ * const tree = new TaffyTree();
3090
+ * const nodeId = tree.newLeaf(new Style());
2455
3091
  * const newStyle = new Style();
2456
3092
  * newStyle.flexGrow = 2;
2457
3093
  * tree.setStyle(nodeId, newStyle);
@@ -2469,6 +3105,40 @@ export class TaffyTree {
2469
3105
  }
2470
3106
  if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
2471
3107
 
3108
+ /**
3109
+ * Text alignment enumeration (for block layout)
3110
+ *
3111
+ * Used by block layout to implement the legacy behaviour of `<center>` and
3112
+ * `<div align="left | right | center">`.
3113
+ *
3114
+ * @example
3115
+ * ```typescript
3116
+ * import { Style, TextAlign } from 'taffy-js';
3117
+ *
3118
+ * const style = new Style();
3119
+ * style.textAlign = TextAlign.LegacyCenter; // Center block children
3120
+ * ```
3121
+ * @enum {0 | 1 | 2 | 3}
3122
+ */
3123
+ export const TextAlign = Object.freeze({
3124
+ /**
3125
+ * No special legacy text align behaviour
3126
+ */
3127
+ Auto: 0, "0": "Auto",
3128
+ /**
3129
+ * Corresponds to `-webkit-left` or `-moz-left` in browsers
3130
+ */
3131
+ LegacyLeft: 1, "1": "LegacyLeft",
3132
+ /**
3133
+ * Corresponds to `-webkit-right` or `-moz-right` in browsers
3134
+ */
3135
+ LegacyRight: 2, "2": "LegacyRight",
3136
+ /**
3137
+ * Corresponds to `-webkit-center` or `-moz-center` in browsers
3138
+ */
3139
+ LegacyCenter: 3, "3": "LegacyCenter",
3140
+ });
3141
+
2472
3142
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
2473
3143
 
2474
3144
  async function __wbg_load(module, imports) {
@@ -2595,6 +3265,10 @@ function __wbg_get_imports() {
2595
3265
  const ret = arg0.call(arg1);
2596
3266
  return ret;
2597
3267
  }, arguments) };
3268
+ imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
3269
+ const ret = arg0.done;
3270
+ return ret;
3271
+ };
2598
3272
  imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
2599
3273
  const ret = Object.entries(arg0);
2600
3274
  return ret;
@@ -2610,6 +3284,10 @@ function __wbg_get_imports() {
2610
3284
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2611
3285
  }
2612
3286
  };
3287
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
3288
+ const ret = arg0[arg1 >>> 0];
3289
+ return ret;
3290
+ };
2613
3291
  imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
2614
3292
  const ret = Reflect.get(arg0, arg1);
2615
3293
  return ret;
@@ -2668,7 +3346,7 @@ function __wbg_get_imports() {
2668
3346
  const ret = arg0.length;
2669
3347
  return ret;
2670
3348
  };
2671
- imports.wbg.__wbg_log_24bf1f6bcbf6c87b = function(arg0, arg1) {
3349
+ imports.wbg.__wbg_log_725a3bd25b473a36 = function(arg0, arg1) {
2672
3350
  console.log(getStringFromWasm0(arg0, arg1));
2673
3351
  };
2674
3352
  imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
@@ -2691,6 +3369,10 @@ function __wbg_get_imports() {
2691
3369
  const ret = arg0.next;
2692
3370
  return ret;
2693
3371
  };
3372
+ imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
3373
+ const ret = arg0.next();
3374
+ return ret;
3375
+ }, arguments) };
2694
3376
  imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
2695
3377
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
2696
3378
  };
@@ -2701,6 +3383,9 @@ function __wbg_get_imports() {
2701
3383
  imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
2702
3384
  arg0[arg1] = arg2;
2703
3385
  };
3386
+ imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
3387
+ arg0[arg1 >>> 0] = arg2;
3388
+ };
2704
3389
  imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
2705
3390
  const ret = arg1.stack;
2706
3391
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -2720,6 +3405,10 @@ function __wbg_get_imports() {
2720
3405
  const ret = TaffyError.__wrap(arg0);
2721
3406
  return ret;
2722
3407
  };
3408
+ imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
3409
+ const ret = arg0.value;
3410
+ return ret;
3411
+ };
2723
3412
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
2724
3413
  // Cast intrinsic for `Ref(String) -> Externref`.
2725
3414
  const ret = getStringFromWasm0(arg0, arg1);