taffy-js 0.2.11 → 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/README.md +62 -336
- package/package.json +3 -2
- package/pkg/README.md +62 -336
- package/pkg/package.json +1 -1
- package/pkg/taffy_wasm.d.ts +284 -73
- package/pkg/taffy_wasm.js +228 -79
- package/pkg/taffy_wasm_bg.wasm +0 -0
- package/pkg/taffy_wasm_bg.wasm.d.ts +1 -0
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
|
* ```
|
|
@@ -520,8 +527,9 @@ export const FlexWrap = Object.freeze({
|
|
|
520
527
|
*
|
|
521
528
|
* @example
|
|
522
529
|
* ```typescript
|
|
523
|
-
* import { GridAutoFlow } from 'taffy-js';
|
|
530
|
+
* import { Style, GridAutoFlow } from 'taffy-js';
|
|
524
531
|
*
|
|
532
|
+
* const style = new Style();
|
|
525
533
|
* style.gridAutoFlow = GridAutoFlow.Row; // Fill rows first
|
|
526
534
|
* style.gridAutoFlow = GridAutoFlow.Column; // Fill columns first
|
|
527
535
|
* style.gridAutoFlow = GridAutoFlow.RowDense; // Fill rows, pack densely
|
|
@@ -555,8 +563,9 @@ export const GridAutoFlow = Object.freeze({
|
|
|
555
563
|
*
|
|
556
564
|
* @example
|
|
557
565
|
* ```typescript
|
|
558
|
-
* import { JustifyContent } from 'taffy-js';
|
|
566
|
+
* import { Style, JustifyContent } from 'taffy-js';
|
|
559
567
|
*
|
|
568
|
+
* const style = new Style();
|
|
560
569
|
* style.justifyContent = JustifyContent.Center; // Center items
|
|
561
570
|
* style.justifyContent = JustifyContent.SpaceBetween; // Distribute evenly
|
|
562
571
|
* ```
|
|
@@ -609,6 +618,11 @@ export const JustifyContent = Object.freeze({
|
|
|
609
618
|
*
|
|
610
619
|
* @example
|
|
611
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 });
|
|
612
626
|
* const layout = tree.getLayout(node);
|
|
613
627
|
*
|
|
614
628
|
* console.log("Position:", layout.x, layout.y);
|
|
@@ -887,8 +901,9 @@ if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
|
|
|
887
901
|
*
|
|
888
902
|
* @example
|
|
889
903
|
* ```typescript
|
|
890
|
-
* import { Overflow } from 'taffy-js';
|
|
904
|
+
* import { Style, Overflow } from 'taffy-js';
|
|
891
905
|
*
|
|
906
|
+
* const style = new Style();
|
|
892
907
|
* style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
|
|
893
908
|
* ```
|
|
894
909
|
* @enum {0 | 1 | 2 | 3}
|
|
@@ -920,8 +935,9 @@ export const Overflow = Object.freeze({
|
|
|
920
935
|
*
|
|
921
936
|
* @example
|
|
922
937
|
* ```typescript
|
|
923
|
-
* import { Position } from 'taffy-js';
|
|
938
|
+
* import { Style, Position } from 'taffy-js';
|
|
924
939
|
*
|
|
940
|
+
* const style = new Style();
|
|
925
941
|
* style.position = Position.Relative; // Normal document flow
|
|
926
942
|
* style.position = Position.Absolute; // Removed from flow, uses inset values
|
|
927
943
|
* ```
|
|
@@ -1019,6 +1035,7 @@ export class Style {
|
|
|
1019
1035
|
*
|
|
1020
1036
|
* @example
|
|
1021
1037
|
* ```typescript
|
|
1038
|
+
* const style = new Style();
|
|
1022
1039
|
* style.border = { left: 1, right: 1, top: 1, bottom: 1 };
|
|
1023
1040
|
* ```
|
|
1024
1041
|
* @param {Rect<LengthPercentage>} val
|
|
@@ -1033,6 +1050,7 @@ export class Style {
|
|
|
1033
1050
|
*
|
|
1034
1051
|
* @example
|
|
1035
1052
|
* ```typescript
|
|
1053
|
+
* const style = new Style();
|
|
1036
1054
|
* style.margin = { left: 10, right: 10, top: 5, bottom: 5 };
|
|
1037
1055
|
* ```
|
|
1038
1056
|
* @param {Rect<LengthPercentageAuto>} val
|
|
@@ -1100,6 +1118,7 @@ export class Style {
|
|
|
1100
1118
|
*
|
|
1101
1119
|
* @example
|
|
1102
1120
|
* ```typescript
|
|
1121
|
+
* const style = new Style();
|
|
1103
1122
|
* style.display = Display.Flex;
|
|
1104
1123
|
* ```
|
|
1105
1124
|
* @param {Display} val
|
|
@@ -1114,6 +1133,7 @@ export class Style {
|
|
|
1114
1133
|
*
|
|
1115
1134
|
* @example
|
|
1116
1135
|
* ```typescript
|
|
1136
|
+
* const style = new Style();
|
|
1117
1137
|
* style.padding = { left: 20, right: 20, top: 10, bottom: 10 };
|
|
1118
1138
|
* ```
|
|
1119
1139
|
* @param {Rect<LengthPercentage>} val
|
|
@@ -1152,6 +1172,7 @@ export class Style {
|
|
|
1152
1172
|
*
|
|
1153
1173
|
* @example
|
|
1154
1174
|
* ```typescript
|
|
1175
|
+
* const style = new Style();
|
|
1155
1176
|
* style.display = Display.Grid;
|
|
1156
1177
|
* // CSS: grid-row: 1 / 3
|
|
1157
1178
|
* style.gridRow = { start: 1, end: 3 };
|
|
@@ -1170,6 +1191,7 @@ export class Style {
|
|
|
1170
1191
|
*
|
|
1171
1192
|
* @example
|
|
1172
1193
|
* ```typescript
|
|
1194
|
+
* const style = new Style();
|
|
1173
1195
|
* style.maxSize = { width: "auto", height: 500 };
|
|
1174
1196
|
* ```
|
|
1175
1197
|
* @param {Size<Dimension>} val
|
|
@@ -1184,6 +1206,7 @@ export class Style {
|
|
|
1184
1206
|
*
|
|
1185
1207
|
* @example
|
|
1186
1208
|
* ```typescript
|
|
1209
|
+
* const style = new Style();
|
|
1187
1210
|
* style.minSize = { width: 100, height: "auto" };
|
|
1188
1211
|
* ```
|
|
1189
1212
|
* @param {Size<Dimension>} val
|
|
@@ -1198,6 +1221,7 @@ export class Style {
|
|
|
1198
1221
|
*
|
|
1199
1222
|
* @example
|
|
1200
1223
|
* ```typescript
|
|
1224
|
+
* const style = new Style();
|
|
1201
1225
|
* style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
|
|
1202
1226
|
* ```
|
|
1203
1227
|
* @param {Point<Overflow>} val
|
|
@@ -1213,6 +1237,7 @@ export class Style {
|
|
|
1213
1237
|
*
|
|
1214
1238
|
* @example
|
|
1215
1239
|
* ```typescript
|
|
1240
|
+
* const style = new Style();
|
|
1216
1241
|
* style.position = Position.Absolute;
|
|
1217
1242
|
* style.inset = { left: 10, top: 10, right: "auto", bottom: "auto" };
|
|
1218
1243
|
* ```
|
|
@@ -1267,6 +1292,7 @@ export class Style {
|
|
|
1267
1292
|
*
|
|
1268
1293
|
* @example
|
|
1269
1294
|
* ```typescript
|
|
1295
|
+
* const style = new Style();
|
|
1270
1296
|
* style.flexGrow = 2;
|
|
1271
1297
|
* ```
|
|
1272
1298
|
* @param {number} val
|
|
@@ -1282,6 +1308,7 @@ export class Style {
|
|
|
1282
1308
|
*
|
|
1283
1309
|
* @example
|
|
1284
1310
|
* ```typescript
|
|
1311
|
+
* const style = new Style();
|
|
1285
1312
|
* style.flexWrap = FlexWrap.Wrap;
|
|
1286
1313
|
* ```
|
|
1287
1314
|
* @param {FlexWrap} val
|
|
@@ -1323,7 +1350,7 @@ export class Style {
|
|
|
1323
1350
|
* Defines the size of implicitly created rows.
|
|
1324
1351
|
*
|
|
1325
1352
|
* @returns - An array of track sizing functions
|
|
1326
|
-
* @returns {
|
|
1353
|
+
* @returns {TrackSizingFunction[]}
|
|
1327
1354
|
*/
|
|
1328
1355
|
get gridAutoRows() {
|
|
1329
1356
|
const ret = wasm.style_gridAutoRows(this.__wbg_ptr);
|
|
@@ -1336,6 +1363,7 @@ export class Style {
|
|
|
1336
1363
|
*
|
|
1337
1364
|
* @example
|
|
1338
1365
|
* ```typescript
|
|
1366
|
+
* const style = new Style();
|
|
1339
1367
|
* style.alignSelf = AlignSelf.Stretch;
|
|
1340
1368
|
* ```
|
|
1341
1369
|
* @param {AlignSelf | undefined} val
|
|
@@ -1350,6 +1378,7 @@ export class Style {
|
|
|
1350
1378
|
*
|
|
1351
1379
|
* @example
|
|
1352
1380
|
* ```typescript
|
|
1381
|
+
* const style = new Style();
|
|
1353
1382
|
* style.boxSizing = BoxSizing.ContentBox;
|
|
1354
1383
|
* ```
|
|
1355
1384
|
* @param {BoxSizing} val
|
|
@@ -1364,6 +1393,7 @@ export class Style {
|
|
|
1364
1393
|
*
|
|
1365
1394
|
* @example
|
|
1366
1395
|
* ```typescript
|
|
1396
|
+
* const style = new Style();
|
|
1367
1397
|
* style.flexBasis = 100;
|
|
1368
1398
|
* ```
|
|
1369
1399
|
* @param {Dimension} val
|
|
@@ -1378,6 +1408,7 @@ export class Style {
|
|
|
1378
1408
|
*
|
|
1379
1409
|
* @example
|
|
1380
1410
|
* ```typescript
|
|
1411
|
+
* const style = new Style();
|
|
1381
1412
|
* style.textAlign = TextAlign.LegacyCenter;
|
|
1382
1413
|
* ```
|
|
1383
1414
|
* @param {TextAlign} val
|
|
@@ -1418,6 +1449,7 @@ export class Style {
|
|
|
1418
1449
|
*
|
|
1419
1450
|
* @example
|
|
1420
1451
|
* ```typescript
|
|
1452
|
+
* const style = new Style();
|
|
1421
1453
|
* style.alignItems = AlignItems.Center;
|
|
1422
1454
|
* ```
|
|
1423
1455
|
* @param {AlignItems | undefined} val
|
|
@@ -1432,6 +1464,7 @@ export class Style {
|
|
|
1432
1464
|
*
|
|
1433
1465
|
* @example
|
|
1434
1466
|
* ```typescript
|
|
1467
|
+
* const style = new Style();
|
|
1435
1468
|
* style.flexShrink = 2;
|
|
1436
1469
|
* ```
|
|
1437
1470
|
* @param {number} val
|
|
@@ -1446,6 +1479,7 @@ export class Style {
|
|
|
1446
1479
|
*
|
|
1447
1480
|
* @example
|
|
1448
1481
|
* ```typescript
|
|
1482
|
+
* const style = new Style();
|
|
1449
1483
|
* style.display = Display.Grid;
|
|
1450
1484
|
* // CSS: grid-column: 1 / 4
|
|
1451
1485
|
* style.gridColumn = { start: 1, end: 4 };
|
|
@@ -1478,6 +1512,7 @@ export class Style {
|
|
|
1478
1512
|
*
|
|
1479
1513
|
* @example
|
|
1480
1514
|
* ```typescript
|
|
1515
|
+
* const style = new Style();
|
|
1481
1516
|
* style.aspectRatio = 16 / 9;
|
|
1482
1517
|
* ```
|
|
1483
1518
|
* @param {number | undefined} val
|
|
@@ -1492,6 +1527,7 @@ export class Style {
|
|
|
1492
1527
|
*
|
|
1493
1528
|
* @example
|
|
1494
1529
|
* ```typescript
|
|
1530
|
+
* const style = new Style();
|
|
1495
1531
|
* style.justifySelf = AlignSelf.End;
|
|
1496
1532
|
* ```
|
|
1497
1533
|
* @param {AlignSelf | undefined} val
|
|
@@ -1505,7 +1541,7 @@ export class Style {
|
|
|
1505
1541
|
* Defines the size of implicitly created columns.
|
|
1506
1542
|
*
|
|
1507
1543
|
* @returns - An array of track sizing functions
|
|
1508
|
-
* @returns {
|
|
1544
|
+
* @returns {TrackSizingFunction[]}
|
|
1509
1545
|
*/
|
|
1510
1546
|
get gridAutoColumns() {
|
|
1511
1547
|
const ret = wasm.style_gridAutoColumns(this.__wbg_ptr);
|
|
@@ -1518,6 +1554,7 @@ export class Style {
|
|
|
1518
1554
|
*
|
|
1519
1555
|
* @example
|
|
1520
1556
|
* ```typescript
|
|
1557
|
+
* const style = new Style();
|
|
1521
1558
|
* style.alignContent = AlignContent.SpaceBetween;
|
|
1522
1559
|
* ```
|
|
1523
1560
|
* @param {AlignContent | undefined} val
|
|
@@ -1541,6 +1578,7 @@ export class Style {
|
|
|
1541
1578
|
*
|
|
1542
1579
|
* @example
|
|
1543
1580
|
* ```typescript
|
|
1581
|
+
* const style = new Style();
|
|
1544
1582
|
* style.display = Display.Grid;
|
|
1545
1583
|
* style.justifyItems = AlignItems.Center;
|
|
1546
1584
|
* ```
|
|
@@ -1553,10 +1591,9 @@ export class Style {
|
|
|
1553
1591
|
* Gets the grid-template-rows property
|
|
1554
1592
|
*
|
|
1555
1593
|
* Defines the track sizing functions (heights) of the grid rows.
|
|
1556
|
-
* Returns Taffy's native serialization format.
|
|
1557
1594
|
*
|
|
1558
1595
|
* @returns - An array of `GridTrack` values
|
|
1559
|
-
* @returns {
|
|
1596
|
+
* @returns {GridTemplateComponent[]}
|
|
1560
1597
|
*/
|
|
1561
1598
|
get gridTemplateRows() {
|
|
1562
1599
|
const ret = wasm.style_gridTemplateRows(this.__wbg_ptr);
|
|
@@ -1570,6 +1607,7 @@ export class Style {
|
|
|
1570
1607
|
*
|
|
1571
1608
|
* @example
|
|
1572
1609
|
* ```typescript
|
|
1610
|
+
* const style = new Style();
|
|
1573
1611
|
* style.flexDirection = FlexDirection.Column;
|
|
1574
1612
|
* ```
|
|
1575
1613
|
* @param {FlexDirection} val
|
|
@@ -1584,6 +1622,7 @@ export class Style {
|
|
|
1584
1622
|
*
|
|
1585
1623
|
* @example
|
|
1586
1624
|
* ```typescript
|
|
1625
|
+
* const style = new Style();
|
|
1587
1626
|
* style.display = Display.Grid;
|
|
1588
1627
|
* style.gridAutoFlow = GridAutoFlow.Column;
|
|
1589
1628
|
* ```
|
|
@@ -1599,10 +1638,11 @@ export class Style {
|
|
|
1599
1638
|
*
|
|
1600
1639
|
* @example
|
|
1601
1640
|
* ```typescript
|
|
1641
|
+
* const style = new Style();
|
|
1602
1642
|
* style.display = Display.Grid;
|
|
1603
|
-
* style.gridAutoRows = [{ min: "
|
|
1643
|
+
* style.gridAutoRows = [{ min: "auto", max: "auto" }];
|
|
1604
1644
|
* ```
|
|
1605
|
-
* @param {
|
|
1645
|
+
* @param {TrackSizingFunction[]} val
|
|
1606
1646
|
*/
|
|
1607
1647
|
set gridAutoRows(val) {
|
|
1608
1648
|
wasm.style_set_gridAutoRows(this.__wbg_ptr, val);
|
|
@@ -1613,7 +1653,7 @@ export class Style {
|
|
|
1613
1653
|
* Defines named grid areas that can be referenced by grid items.
|
|
1614
1654
|
*
|
|
1615
1655
|
* @returns - An array of `GridArea` values
|
|
1616
|
-
* @returns {
|
|
1656
|
+
* @returns {GridTemplateArea[]}
|
|
1617
1657
|
*/
|
|
1618
1658
|
get gridTemplateAreas() {
|
|
1619
1659
|
const ret = wasm.style_gridTemplateAreas(this.__wbg_ptr);
|
|
@@ -1626,6 +1666,7 @@ export class Style {
|
|
|
1626
1666
|
*
|
|
1627
1667
|
* @example
|
|
1628
1668
|
* ```typescript
|
|
1669
|
+
* const style = new Style();
|
|
1629
1670
|
* style.justifyContent = JustifyContent.Center;
|
|
1630
1671
|
* ```
|
|
1631
1672
|
* @param {JustifyContent | undefined} val
|
|
@@ -1640,6 +1681,7 @@ export class Style {
|
|
|
1640
1681
|
*
|
|
1641
1682
|
* @example
|
|
1642
1683
|
* ```typescript
|
|
1684
|
+
* const style = new Style();
|
|
1643
1685
|
* style.overflow = { x: Overflow.Scroll, y: Overflow.Scroll };
|
|
1644
1686
|
* style.scrollbarWidth = 15;
|
|
1645
1687
|
* ```
|
|
@@ -1663,7 +1705,7 @@ export class Style {
|
|
|
1663
1705
|
* Defines the track sizing functions (widths) of the grid columns.
|
|
1664
1706
|
*
|
|
1665
1707
|
* @returns - An array of `GridTrack` values
|
|
1666
|
-
* @returns {
|
|
1708
|
+
* @returns {GridTemplateComponent[]}
|
|
1667
1709
|
*/
|
|
1668
1710
|
get gridTemplateColumns() {
|
|
1669
1711
|
const ret = wasm.style_gridTemplateColumns(this.__wbg_ptr);
|
|
@@ -1673,7 +1715,7 @@ export class Style {
|
|
|
1673
1715
|
* Sets the grid-auto-columns property
|
|
1674
1716
|
*
|
|
1675
1717
|
* @param val - An array of track sizing functions for implicit columns
|
|
1676
|
-
* @param {
|
|
1718
|
+
* @param {TrackSizingFunction[]} val
|
|
1677
1719
|
*/
|
|
1678
1720
|
set gridAutoColumns(val) {
|
|
1679
1721
|
wasm.style_set_gridAutoColumns(this.__wbg_ptr, val);
|
|
@@ -1681,18 +1723,8 @@ export class Style {
|
|
|
1681
1723
|
/**
|
|
1682
1724
|
* Sets the grid-template-rows property
|
|
1683
1725
|
*
|
|
1684
|
-
* @param val - An array of GridTrack objects
|
|
1685
|
-
*
|
|
1686
|
-
* @example
|
|
1687
|
-
* ```typescript
|
|
1688
|
-
* style.display = Display.Grid;
|
|
1689
|
-
* // Simple: use Taffy's serde format
|
|
1690
|
-
* style.gridTemplateRows = [
|
|
1691
|
-
* { type: "Single", value: { min: { Length: 100 }, max: { Length: 100 } } },
|
|
1692
|
-
* { type: "Single", value: { min: "Auto", max: { Fr: 1.0 } } }
|
|
1693
|
-
* ];
|
|
1694
|
-
* ```
|
|
1695
|
-
* @param {GridTrack[]} val
|
|
1726
|
+
* @param val - An array of GridTrack objects
|
|
1727
|
+
* @param {GridTemplateComponent[]} val
|
|
1696
1728
|
*/
|
|
1697
1729
|
set gridTemplateRows(val) {
|
|
1698
1730
|
wasm.style_set_gridTemplateRows(this.__wbg_ptr, val);
|
|
@@ -1716,13 +1748,14 @@ export class Style {
|
|
|
1716
1748
|
*
|
|
1717
1749
|
* @example
|
|
1718
1750
|
* ```typescript
|
|
1751
|
+
* const style = new Style();
|
|
1719
1752
|
* style.display = Display.Grid;
|
|
1720
1753
|
* style.gridTemplateAreas = [
|
|
1721
|
-
* { name: "header",
|
|
1722
|
-
* { name: "main",
|
|
1754
|
+
* { name: "header", rowStart: 1, rowEnd: 2, columnStart: 1, columnEnd: 4 },
|
|
1755
|
+
* { name: "main", rowStart: 2, rowEnd: 4, columnStart: 2, columnEnd: 4 }
|
|
1723
1756
|
* ];
|
|
1724
1757
|
* ```
|
|
1725
|
-
* @param {
|
|
1758
|
+
* @param {GridTemplateArea[]} val
|
|
1726
1759
|
*/
|
|
1727
1760
|
set gridTemplateAreas(val) {
|
|
1728
1761
|
wasm.style_set_gridTemplateAreas(this.__wbg_ptr, val);
|
|
@@ -1734,14 +1767,15 @@ export class Style {
|
|
|
1734
1767
|
*
|
|
1735
1768
|
* @example
|
|
1736
1769
|
* ```typescript
|
|
1770
|
+
* const style = new Style();
|
|
1737
1771
|
* style.display = Display.Grid;
|
|
1738
1772
|
* style.gridTemplateColumns = [
|
|
1739
|
-
* {
|
|
1740
|
-
* {
|
|
1741
|
-
* {
|
|
1773
|
+
* { min: 200, max: 200 },
|
|
1774
|
+
* { min: "auto", max: "1fr" },
|
|
1775
|
+
* { min: "auto", max: "1fr" }
|
|
1742
1776
|
* ];
|
|
1743
1777
|
* ```
|
|
1744
|
-
* @param {
|
|
1778
|
+
* @param {GridTemplateComponent[]} val
|
|
1745
1779
|
*/
|
|
1746
1780
|
set gridTemplateColumns(val) {
|
|
1747
1781
|
wasm.style_set_gridTemplateColumns(this.__wbg_ptr, val);
|
|
@@ -1765,6 +1799,7 @@ export class Style {
|
|
|
1765
1799
|
*
|
|
1766
1800
|
* @example
|
|
1767
1801
|
* ```typescript
|
|
1802
|
+
* const style = new Style();
|
|
1768
1803
|
* style.gridTemplateRowNames = [["header-start"], ["header-end", "main-start"], ["main-end"]];
|
|
1769
1804
|
* ```
|
|
1770
1805
|
* @param {string[][]} val
|
|
@@ -1779,6 +1814,7 @@ export class Style {
|
|
|
1779
1814
|
*
|
|
1780
1815
|
* @example
|
|
1781
1816
|
* ```typescript
|
|
1817
|
+
* const style = new Style();
|
|
1782
1818
|
* style.gridTemplateColumnNames = [["sidebar-start"], ["sidebar-end", "main-start"], ["main-end"]];
|
|
1783
1819
|
* ```
|
|
1784
1820
|
* @param {string[][]} val
|
|
@@ -1894,6 +1930,7 @@ export class Style {
|
|
|
1894
1930
|
*
|
|
1895
1931
|
* @example
|
|
1896
1932
|
* ```typescript
|
|
1933
|
+
* const style = new Style();
|
|
1897
1934
|
* style.gap = { width: 10, height: 10 };
|
|
1898
1935
|
* ```
|
|
1899
1936
|
* @param {Size<LengthPercentage>} val
|
|
@@ -1967,6 +2004,7 @@ export class Style {
|
|
|
1967
2004
|
*
|
|
1968
2005
|
* @example
|
|
1969
2006
|
* ```typescript
|
|
2007
|
+
* const style = new Style();
|
|
1970
2008
|
* style.size = { width: 200, height: "100%" };
|
|
1971
2009
|
* ```
|
|
1972
2010
|
* @param {Size<Dimension>} val
|
|
@@ -2008,6 +2046,7 @@ export class Style {
|
|
|
2008
2046
|
*
|
|
2009
2047
|
* @example
|
|
2010
2048
|
* ```typescript
|
|
2049
|
+
* const style = new Style();
|
|
2011
2050
|
* style.position = Position.Absolute;
|
|
2012
2051
|
* style.inset = { left: 0, top: 0, right: "auto", bottom: "auto" };
|
|
2013
2052
|
* ```
|
|
@@ -2028,6 +2067,8 @@ if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
|
|
|
2028
2067
|
* @example
|
|
2029
2068
|
* ```typescript
|
|
2030
2069
|
* try {
|
|
2070
|
+
* const tree = new TaffyTree();
|
|
2071
|
+
* const node = tree.newLeaf(new Style());
|
|
2031
2072
|
* tree.remove(node);
|
|
2032
2073
|
* } catch (e) {
|
|
2033
2074
|
* if (e instanceof TaffyError) {
|
|
@@ -2122,6 +2163,11 @@ export class TaffyTree {
|
|
|
2122
2163
|
*
|
|
2123
2164
|
* @example
|
|
2124
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
|
+
*
|
|
2125
2171
|
* // After updating text content
|
|
2126
2172
|
* tree.setNodeContext(nodeId, { text: "Updated text" });
|
|
2127
2173
|
* tree.markDirty(nodeId);
|
|
@@ -2145,6 +2191,8 @@ export class TaffyTree {
|
|
|
2145
2191
|
*
|
|
2146
2192
|
* @example
|
|
2147
2193
|
* ```typescript
|
|
2194
|
+
* const tree = new TaffyTree();
|
|
2195
|
+
* const rootId = tree.newLeaf(new Style());
|
|
2148
2196
|
* tree.printTree(rootId);
|
|
2149
2197
|
* // Output appears in browser console
|
|
2150
2198
|
* ```
|
|
@@ -2164,6 +2212,8 @@ export class TaffyTree {
|
|
|
2164
2212
|
*
|
|
2165
2213
|
* @example
|
|
2166
2214
|
* ```typescript
|
|
2215
|
+
* const tree = new TaffyTree();
|
|
2216
|
+
* const parentId = tree.newLeaf(new Style());
|
|
2167
2217
|
* const count: number = tree.childCount(parentId);
|
|
2168
2218
|
* ```
|
|
2169
2219
|
* @param {bigint} parent
|
|
@@ -2185,6 +2235,10 @@ export class TaffyTree {
|
|
|
2185
2235
|
*
|
|
2186
2236
|
* @example
|
|
2187
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);
|
|
2188
2242
|
* tree.removeChild(parentId, childId);
|
|
2189
2243
|
* ```
|
|
2190
2244
|
* @param {bigint} parent
|
|
@@ -2210,6 +2264,11 @@ export class TaffyTree {
|
|
|
2210
2264
|
*
|
|
2211
2265
|
* @example
|
|
2212
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());
|
|
2213
2272
|
* const children = BigUint64Array.from([child1, child2, child3]);
|
|
2214
2273
|
* tree.setChildren(parentId, children);
|
|
2215
2274
|
* ```
|
|
@@ -2250,31 +2309,36 @@ export class TaffyTree {
|
|
|
2250
2309
|
* to compute layouts for all nodes in the tree.
|
|
2251
2310
|
*
|
|
2252
2311
|
* @param node - The root node ID to compute layout for
|
|
2253
|
-
* @param
|
|
2312
|
+
* @param availableSpace - The available space constraints
|
|
2254
2313
|
*
|
|
2255
2314
|
* @example
|
|
2256
2315
|
* ```typescript
|
|
2316
|
+
* const tree = new TaffyTree();
|
|
2317
|
+
* const rootId = tree.newLeaf(new Style());
|
|
2318
|
+
*
|
|
2257
2319
|
* // Fixed size container
|
|
2258
|
-
* { width: 800, height: 600 }
|
|
2320
|
+
* tree.computeLayout(rootId, { width: 800, height: 600 });
|
|
2259
2321
|
*
|
|
2260
2322
|
* // Flexible width, fixed height
|
|
2261
|
-
* { width: "
|
|
2323
|
+
* tree.computeLayout(rootId, { width: "max-content", height: 600 });
|
|
2262
2324
|
*
|
|
2263
2325
|
* // Minimum content size
|
|
2264
|
-
* { width: "
|
|
2326
|
+
* tree.computeLayout(rootId, { width: "min-content", height: "min-content" });
|
|
2265
2327
|
* ```
|
|
2266
2328
|
*
|
|
2267
2329
|
* @throws `TaffyError` if the node does not exist or available space is invalid
|
|
2268
2330
|
*
|
|
2269
2331
|
* @example
|
|
2270
2332
|
* ```typescript
|
|
2333
|
+
* const tree = new TaffyTree();
|
|
2334
|
+
* const rootId = tree.newLeaf(new Style());
|
|
2271
2335
|
* tree.computeLayout(rootId, { width: 800, height: 600 });
|
|
2272
2336
|
* ```
|
|
2273
2337
|
* @param {bigint} node
|
|
2274
|
-
* @param {Size<AvailableSpace>}
|
|
2338
|
+
* @param {Size<AvailableSpace>} availableSpace
|
|
2275
2339
|
*/
|
|
2276
|
-
computeLayout(node,
|
|
2277
|
-
const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node,
|
|
2340
|
+
computeLayout(node, availableSpace) {
|
|
2341
|
+
const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, availableSpace);
|
|
2278
2342
|
if (ret[1]) {
|
|
2279
2343
|
throw takeFromExternrefTable0(ret[0]);
|
|
2280
2344
|
}
|
|
@@ -2288,6 +2352,7 @@ export class TaffyTree {
|
|
|
2288
2352
|
*
|
|
2289
2353
|
* @example
|
|
2290
2354
|
* ```typescript
|
|
2355
|
+
* const tree = new TaffyTree();
|
|
2291
2356
|
* tree.enableRounding();
|
|
2292
2357
|
* ```
|
|
2293
2358
|
*/
|
|
@@ -2303,6 +2368,8 @@ export class TaffyTree {
|
|
|
2303
2368
|
*
|
|
2304
2369
|
* @example
|
|
2305
2370
|
* ```typescript
|
|
2371
|
+
* const tree = new TaffyTree();
|
|
2372
|
+
* const node = tree.newLeaf(new Style());
|
|
2306
2373
|
* tree.disableRounding();
|
|
2307
2374
|
* const layout = tree.getLayout(node);
|
|
2308
2375
|
* console.log(layout.x);
|
|
@@ -2320,6 +2387,8 @@ export class TaffyTree {
|
|
|
2320
2387
|
*
|
|
2321
2388
|
* @example
|
|
2322
2389
|
* ```typescript
|
|
2390
|
+
* const tree = new TaffyTree();
|
|
2391
|
+
* const nodeId = tree.newLeaf(new Style());
|
|
2323
2392
|
* interface Context { text: string };
|
|
2324
2393
|
* const context = tree.getNodeContext(nodeId) as Context | undefined;
|
|
2325
2394
|
* if (context) {
|
|
@@ -2349,6 +2418,8 @@ export class TaffyTree {
|
|
|
2349
2418
|
*
|
|
2350
2419
|
* @example
|
|
2351
2420
|
* ```typescript
|
|
2421
|
+
* const tree = new TaffyTree();
|
|
2422
|
+
* const nodeId = tree.newLeaf(new Style());
|
|
2352
2423
|
* interface Context { text: string };
|
|
2353
2424
|
* tree.setNodeContext(nodeId, { text: "Updated text" } as Context);
|
|
2354
2425
|
* ```
|
|
@@ -2368,6 +2439,7 @@ export class TaffyTree {
|
|
|
2368
2439
|
*
|
|
2369
2440
|
* @example
|
|
2370
2441
|
* ```typescript
|
|
2442
|
+
* const tree = new TaffyTree();
|
|
2371
2443
|
* const count: number = tree.totalNodeCount();
|
|
2372
2444
|
* ```
|
|
2373
2445
|
* @returns {number}
|
|
@@ -2388,6 +2460,8 @@ export class TaffyTree {
|
|
|
2388
2460
|
*
|
|
2389
2461
|
* @example
|
|
2390
2462
|
* ```typescript
|
|
2463
|
+
* const tree = new TaffyTree();
|
|
2464
|
+
* const nodeId = tree.newLeaf(new Style());
|
|
2391
2465
|
* const layout: Layout = tree.unroundedLayout(nodeId);
|
|
2392
2466
|
* console.log(`Exact width: ${layout.width}`);
|
|
2393
2467
|
* ```
|
|
@@ -2413,6 +2487,7 @@ export class TaffyTree {
|
|
|
2413
2487
|
*
|
|
2414
2488
|
* @example
|
|
2415
2489
|
* ```typescript
|
|
2490
|
+
* const tree = new TaffyTree();
|
|
2416
2491
|
* const containerStyle = new Style();
|
|
2417
2492
|
* containerStyle.display = Display.Flex;
|
|
2418
2493
|
*
|
|
@@ -2450,6 +2525,10 @@ export class TaffyTree {
|
|
|
2450
2525
|
*
|
|
2451
2526
|
* @example
|
|
2452
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);
|
|
2453
2532
|
* const firstChild: bigint = tree.getChildAtIndex(parentId, 0);
|
|
2454
2533
|
* ```
|
|
2455
2534
|
* @param {bigint} parent
|
|
@@ -2463,6 +2542,28 @@ export class TaffyTree {
|
|
|
2463
2542
|
}
|
|
2464
2543
|
return BigInt.asUintN(64, ret[0]);
|
|
2465
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
|
+
}
|
|
2466
2567
|
/**
|
|
2467
2568
|
* Gets a mutable reference to the context value for a node
|
|
2468
2569
|
*
|
|
@@ -2493,6 +2594,9 @@ export class TaffyTree {
|
|
|
2493
2594
|
*
|
|
2494
2595
|
* @example
|
|
2495
2596
|
* ```typescript
|
|
2597
|
+
* const tree = new TaffyTree();
|
|
2598
|
+
* const parentId = tree.newLeaf(new Style());
|
|
2599
|
+
* const childId = tree.newLeaf(new Style());
|
|
2496
2600
|
* tree.insertChildAtIndex(parentId, 0, childId);
|
|
2497
2601
|
* ```
|
|
2498
2602
|
* @param {bigint} parent
|
|
@@ -2521,6 +2625,7 @@ export class TaffyTree {
|
|
|
2521
2625
|
* ```typescript
|
|
2522
2626
|
* interface TextContext { text: string; isBold: boolean; }
|
|
2523
2627
|
*
|
|
2628
|
+
* const tree = new TaffyTree();
|
|
2524
2629
|
* const style = new Style();
|
|
2525
2630
|
* const context: TextContext = { text: "Hello, World!", isBold: true };
|
|
2526
2631
|
* const nodeId: bigint = tree.newLeafWithContext(style, context);
|
|
@@ -2549,6 +2654,10 @@ export class TaffyTree {
|
|
|
2549
2654
|
*
|
|
2550
2655
|
* @example
|
|
2551
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);
|
|
2552
2661
|
* const removedId: bigint = tree.removeChildAtIndex(parentId, 0);
|
|
2553
2662
|
* ```
|
|
2554
2663
|
* @param {bigint} parent
|
|
@@ -2568,21 +2677,28 @@ export class TaffyTree {
|
|
|
2568
2677
|
* Removes children from `start_index` (inclusive) to `end_index` (exclusive).
|
|
2569
2678
|
*
|
|
2570
2679
|
* @param parent - The parent node ID
|
|
2571
|
-
* @param
|
|
2572
|
-
* @param
|
|
2680
|
+
* @param startIndex - Start of range (inclusive)
|
|
2681
|
+
* @param endIndex - End of range (exclusive)
|
|
2573
2682
|
*
|
|
2574
2683
|
* @throws `TaffyError` if the parent node does not exist or range is invalid
|
|
2575
2684
|
*
|
|
2576
2685
|
* @example
|
|
2577
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
|
+
*
|
|
2578
2694
|
* tree.removeChildrenRange(parentId, 1, 3);
|
|
2579
2695
|
* ```
|
|
2580
2696
|
* @param {bigint} parent
|
|
2581
|
-
* @param {number}
|
|
2582
|
-
* @param {number}
|
|
2697
|
+
* @param {number} startIndex
|
|
2698
|
+
* @param {number} endIndex
|
|
2583
2699
|
*/
|
|
2584
|
-
removeChildrenRange(parent,
|
|
2585
|
-
const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent,
|
|
2700
|
+
removeChildrenRange(parent, startIndex, endIndex) {
|
|
2701
|
+
const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, startIndex, endIndex);
|
|
2586
2702
|
if (ret[1]) {
|
|
2587
2703
|
throw takeFromExternrefTable0(ret[0]);
|
|
2588
2704
|
}
|
|
@@ -2592,7 +2708,7 @@ export class TaffyTree {
|
|
|
2592
2708
|
*
|
|
2593
2709
|
* @param parent - The parent node ID
|
|
2594
2710
|
* @param index - The index of the child to replace (0-based)
|
|
2595
|
-
* @param
|
|
2711
|
+
* @param newChild - The new child node ID
|
|
2596
2712
|
*
|
|
2597
2713
|
* @returns - The replaced (old) child ID (`bigint`)
|
|
2598
2714
|
*
|
|
@@ -2600,15 +2716,23 @@ export class TaffyTree {
|
|
|
2600
2716
|
*
|
|
2601
2717
|
* @example
|
|
2602
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
|
+
*
|
|
2603
2727
|
* const oldChildId: bigint = tree.replaceChildAtIndex(parentId, 1, newChildId);
|
|
2604
2728
|
* ```
|
|
2605
2729
|
* @param {bigint} parent
|
|
2606
2730
|
* @param {number} index
|
|
2607
|
-
* @param {bigint}
|
|
2731
|
+
* @param {bigint} newChild
|
|
2608
2732
|
* @returns {bigint}
|
|
2609
2733
|
*/
|
|
2610
|
-
replaceChildAtIndex(parent, index,
|
|
2611
|
-
const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index,
|
|
2734
|
+
replaceChildAtIndex(parent, index, newChild) {
|
|
2735
|
+
const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, newChild);
|
|
2612
2736
|
if (ret[2]) {
|
|
2613
2737
|
throw takeFromExternrefTable0(ret[1]);
|
|
2614
2738
|
}
|
|
@@ -2622,19 +2746,24 @@ export class TaffyTree {
|
|
|
2622
2746
|
* called for each leaf node that needs measurement.
|
|
2623
2747
|
*
|
|
2624
2748
|
* @param node - The root node ID to compute layout for
|
|
2625
|
-
* @param
|
|
2626
|
-
* @param
|
|
2749
|
+
* @param availableSpace - The available space constraints
|
|
2750
|
+
* @param measureFunc - A function that measures leaf node content
|
|
2627
2751
|
*
|
|
2628
2752
|
* @throws `TaffyError` if the node does not exist or available space is invalid
|
|
2629
2753
|
*
|
|
2630
2754
|
* @example
|
|
2631
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
|
+
*
|
|
2632
2761
|
* tree.computeLayoutWithMeasure(
|
|
2633
2762
|
* rootId,
|
|
2634
|
-
* { width: 800, height: "
|
|
2763
|
+
* { width: 800, height: "max-content" },
|
|
2635
2764
|
* (known, available, node, context, style) => {
|
|
2636
2765
|
* if (context?.text) {
|
|
2637
|
-
* const measured = measureText(context.text, available.width);
|
|
2766
|
+
* const measured = measureText(context.text, available.width as number);
|
|
2638
2767
|
* return { width: measured.width, height: measured.height };
|
|
2639
2768
|
* }
|
|
2640
2769
|
* return { width: 0, height: 0 };
|
|
@@ -2642,11 +2771,11 @@ export class TaffyTree {
|
|
|
2642
2771
|
* );
|
|
2643
2772
|
* ```
|
|
2644
2773
|
* @param {bigint} node
|
|
2645
|
-
* @param {Size<AvailableSpace>}
|
|
2646
|
-
* @param {MeasureFunction}
|
|
2774
|
+
* @param {Size<AvailableSpace>} availableSpace
|
|
2775
|
+
* @param {MeasureFunction} measureFunc
|
|
2647
2776
|
*/
|
|
2648
|
-
computeLayoutWithMeasure(node,
|
|
2649
|
-
const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node,
|
|
2777
|
+
computeLayoutWithMeasure(node, availableSpace, measureFunc) {
|
|
2778
|
+
const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, availableSpace, measureFunc);
|
|
2650
2779
|
if (ret[1]) {
|
|
2651
2780
|
throw takeFromExternrefTable0(ret[0]);
|
|
2652
2781
|
}
|
|
@@ -2663,6 +2792,9 @@ export class TaffyTree {
|
|
|
2663
2792
|
*
|
|
2664
2793
|
* @example
|
|
2665
2794
|
* ```typescript
|
|
2795
|
+
* const tree = new TaffyTree();
|
|
2796
|
+
* const id1 = tree.newLeaf(new Style());
|
|
2797
|
+
* const id2 = tree.newLeaf(new Style());
|
|
2666
2798
|
* const nodes = BigUint64Array.from([id1, id2]);
|
|
2667
2799
|
* const contexts = tree.getDisjointNodeContextMut(nodes);
|
|
2668
2800
|
* ```
|
|
@@ -2705,6 +2837,7 @@ export class TaffyTree {
|
|
|
2705
2837
|
*
|
|
2706
2838
|
* @example
|
|
2707
2839
|
* ```typescript
|
|
2840
|
+
* const tree = new TaffyTree();
|
|
2708
2841
|
* tree.clear();
|
|
2709
2842
|
* console.log(tree.totalNodeCount());
|
|
2710
2843
|
* ```
|
|
@@ -2726,6 +2859,11 @@ export class TaffyTree {
|
|
|
2726
2859
|
*
|
|
2727
2860
|
* @example
|
|
2728
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
|
+
*
|
|
2729
2867
|
* if (tree.dirty(nodeId)) {
|
|
2730
2868
|
* tree.computeLayout(rootId, availableSpace);
|
|
2731
2869
|
* }
|
|
@@ -2751,6 +2889,8 @@ export class TaffyTree {
|
|
|
2751
2889
|
*
|
|
2752
2890
|
* @example
|
|
2753
2891
|
* ```typescript
|
|
2892
|
+
* const tree = new TaffyTree();
|
|
2893
|
+
* const nodeId = tree.newLeaf(new Style());
|
|
2754
2894
|
* const style: Style = tree.getStyle(nodeId);
|
|
2755
2895
|
* console.log('Flex grow:', style.flexGrow);
|
|
2756
2896
|
* ```
|
|
@@ -2778,6 +2918,12 @@ export class TaffyTree {
|
|
|
2778
2918
|
*
|
|
2779
2919
|
* @example
|
|
2780
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
|
+
*
|
|
2781
2927
|
* tree.computeLayout(rootId, { width: 800, height: 600 });
|
|
2782
2928
|
* const layout: Layout = tree.getLayout(nodeId);
|
|
2783
2929
|
* console.log(`Position: (${layout.x}, ${layout.y}), Size: ${layout.width}x${layout.height}`);
|
|
@@ -2801,7 +2947,11 @@ export class TaffyTree {
|
|
|
2801
2947
|
*
|
|
2802
2948
|
* @example
|
|
2803
2949
|
* ```typescript
|
|
2804
|
-
* const
|
|
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);
|
|
2805
2955
|
* ```
|
|
2806
2956
|
* @param {bigint} child
|
|
2807
2957
|
* @returns {bigint | undefined}
|
|
@@ -2824,6 +2974,8 @@ export class TaffyTree {
|
|
|
2824
2974
|
*
|
|
2825
2975
|
* @example
|
|
2826
2976
|
* ```typescript
|
|
2977
|
+
* const tree = new TaffyTree();
|
|
2978
|
+
* const nodeId = tree.newLeaf(new Style());
|
|
2827
2979
|
* try {
|
|
2828
2980
|
* const removedId: bigint = tree.remove(nodeId);
|
|
2829
2981
|
* } catch (e) {
|
|
@@ -2851,6 +3003,8 @@ export class TaffyTree {
|
|
|
2851
3003
|
*
|
|
2852
3004
|
* @example
|
|
2853
3005
|
* ```typescript
|
|
3006
|
+
* const tree = new TaffyTree();
|
|
3007
|
+
* const parentId = tree.newLeaf(new Style());
|
|
2854
3008
|
* const children: BigUint64Array = tree.children(parentId);
|
|
2855
3009
|
* ```
|
|
2856
3010
|
* @param {bigint} parent
|
|
@@ -2877,6 +3031,7 @@ export class TaffyTree {
|
|
|
2877
3031
|
*
|
|
2878
3032
|
* @example
|
|
2879
3033
|
* ```typescript
|
|
3034
|
+
* const tree = new TaffyTree();
|
|
2880
3035
|
* const style = new Style();
|
|
2881
3036
|
* style.size = { width: 100, height: 50 };
|
|
2882
3037
|
* const nodeId: bigint = tree.newLeaf(style);
|
|
@@ -2904,6 +3059,9 @@ export class TaffyTree {
|
|
|
2904
3059
|
*
|
|
2905
3060
|
* @example
|
|
2906
3061
|
* ```typescript
|
|
3062
|
+
* const tree = new TaffyTree();
|
|
3063
|
+
* const parentId = tree.newLeaf(new Style());
|
|
3064
|
+
* const childId = tree.newLeaf(new Style());
|
|
2907
3065
|
* tree.addChild(parentId, childId);
|
|
2908
3066
|
* ```
|
|
2909
3067
|
* @param {bigint} parent
|
|
@@ -2928,6 +3086,8 @@ export class TaffyTree {
|
|
|
2928
3086
|
*
|
|
2929
3087
|
* @example
|
|
2930
3088
|
* ```typescript
|
|
3089
|
+
* const tree = new TaffyTree();
|
|
3090
|
+
* const nodeId = tree.newLeaf(new Style());
|
|
2931
3091
|
* const newStyle = new Style();
|
|
2932
3092
|
* newStyle.flexGrow = 2;
|
|
2933
3093
|
* tree.setStyle(nodeId, newStyle);
|
|
@@ -2953,8 +3113,9 @@ if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.fr
|
|
|
2953
3113
|
*
|
|
2954
3114
|
* @example
|
|
2955
3115
|
* ```typescript
|
|
2956
|
-
* import { TextAlign } from 'taffy-js';
|
|
3116
|
+
* import { Style, TextAlign } from 'taffy-js';
|
|
2957
3117
|
*
|
|
3118
|
+
* const style = new Style();
|
|
2958
3119
|
* style.textAlign = TextAlign.LegacyCenter; // Center block children
|
|
2959
3120
|
* ```
|
|
2960
3121
|
* @enum {0 | 1 | 2 | 3}
|
|
@@ -3067,10 +3228,6 @@ function __wbg_get_imports() {
|
|
|
3067
3228
|
const ret = typeof(val) === 'object' && val !== null;
|
|
3068
3229
|
return ret;
|
|
3069
3230
|
};
|
|
3070
|
-
imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
|
3071
|
-
const ret = typeof(arg0) === 'string';
|
|
3072
|
-
return ret;
|
|
3073
|
-
};
|
|
3074
3231
|
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
3075
3232
|
const ret = arg0 === undefined;
|
|
3076
3233
|
return ret;
|
|
@@ -3189,7 +3346,7 @@ function __wbg_get_imports() {
|
|
|
3189
3346
|
const ret = arg0.length;
|
|
3190
3347
|
return ret;
|
|
3191
3348
|
};
|
|
3192
|
-
imports.wbg.
|
|
3349
|
+
imports.wbg.__wbg_log_725a3bd25b473a36 = function(arg0, arg1) {
|
|
3193
3350
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
3194
3351
|
};
|
|
3195
3352
|
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
@@ -3208,10 +3365,6 @@ function __wbg_get_imports() {
|
|
|
3208
3365
|
const ret = new Error();
|
|
3209
3366
|
return ret;
|
|
3210
3367
|
};
|
|
3211
|
-
imports.wbg.__wbg_new_b546ae120718850e = function() {
|
|
3212
|
-
const ret = new Map();
|
|
3213
|
-
return ret;
|
|
3214
|
-
};
|
|
3215
3368
|
imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
|
|
3216
3369
|
const ret = arg0.next;
|
|
3217
3370
|
return ret;
|
|
@@ -3233,10 +3386,6 @@ function __wbg_get_imports() {
|
|
|
3233
3386
|
imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
|
|
3234
3387
|
arg0[arg1 >>> 0] = arg2;
|
|
3235
3388
|
};
|
|
3236
|
-
imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
|
|
3237
|
-
const ret = arg0.set(arg1, arg2);
|
|
3238
|
-
return ret;
|
|
3239
|
-
};
|
|
3240
3389
|
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
3241
3390
|
const ret = arg1.stack;
|
|
3242
3391
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|