taffy-js 0.2.2 → 0.2.3
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/package.json +1 -1
- package/taffy_js.d.ts +116 -4
- package/taffy_js.js +217 -7
- package/taffy_js_bg.wasm +0 -0
package/package.json
CHANGED
package/taffy_js.d.ts
CHANGED
|
@@ -158,6 +158,96 @@ export enum JustifyContent {
|
|
|
158
158
|
SpaceEvenly = 8,
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
export class Layout {
|
|
162
|
+
private constructor();
|
|
163
|
+
free(): void;
|
|
164
|
+
[Symbol.dispose](): void;
|
|
165
|
+
/**
|
|
166
|
+
* Gets the top border width.
|
|
167
|
+
*/
|
|
168
|
+
readonly borderTop: number;
|
|
169
|
+
/**
|
|
170
|
+
* Gets the top margin.
|
|
171
|
+
*/
|
|
172
|
+
readonly marginTop: number;
|
|
173
|
+
/**
|
|
174
|
+
* Gets the left border width.
|
|
175
|
+
*/
|
|
176
|
+
readonly borderLeft: number;
|
|
177
|
+
/**
|
|
178
|
+
* Gets the left margin.
|
|
179
|
+
*/
|
|
180
|
+
readonly marginLeft: number;
|
|
181
|
+
/**
|
|
182
|
+
* Gets the top padding.
|
|
183
|
+
*/
|
|
184
|
+
readonly paddingTop: number;
|
|
185
|
+
/**
|
|
186
|
+
* Gets the right border width.
|
|
187
|
+
*/
|
|
188
|
+
readonly borderRight: number;
|
|
189
|
+
/**
|
|
190
|
+
* Gets the right margin.
|
|
191
|
+
*/
|
|
192
|
+
readonly marginRight: number;
|
|
193
|
+
/**
|
|
194
|
+
* Gets the left padding.
|
|
195
|
+
*/
|
|
196
|
+
readonly paddingLeft: number;
|
|
197
|
+
/**
|
|
198
|
+
* Gets the bottom border width.
|
|
199
|
+
*/
|
|
200
|
+
readonly borderBottom: number;
|
|
201
|
+
/**
|
|
202
|
+
* Gets the width of the scrollable content.
|
|
203
|
+
*/
|
|
204
|
+
readonly contentWidth: number;
|
|
205
|
+
/**
|
|
206
|
+
* Gets the bottom margin.
|
|
207
|
+
*/
|
|
208
|
+
readonly marginBottom: number;
|
|
209
|
+
/**
|
|
210
|
+
* Gets the right padding.
|
|
211
|
+
*/
|
|
212
|
+
readonly paddingRight: number;
|
|
213
|
+
/**
|
|
214
|
+
* Gets the height of the scrollable content.
|
|
215
|
+
*/
|
|
216
|
+
readonly contentHeight: number;
|
|
217
|
+
/**
|
|
218
|
+
* Gets the bottom padding.
|
|
219
|
+
*/
|
|
220
|
+
readonly paddingBottom: number;
|
|
221
|
+
/**
|
|
222
|
+
* Gets the width of the vertical scrollbar.
|
|
223
|
+
*/
|
|
224
|
+
readonly scrollbarWidth: number;
|
|
225
|
+
/**
|
|
226
|
+
* Gets the height of the horizontal scrollbar.
|
|
227
|
+
*/
|
|
228
|
+
readonly scrollbarHeight: number;
|
|
229
|
+
/**
|
|
230
|
+
* Gets the x coordinate of the node's top-left corner.
|
|
231
|
+
*/
|
|
232
|
+
readonly x: number;
|
|
233
|
+
/**
|
|
234
|
+
* Gets the y coordinate of the node's top-left corner.
|
|
235
|
+
*/
|
|
236
|
+
readonly y: number;
|
|
237
|
+
/**
|
|
238
|
+
* Gets the rendering order of the node.
|
|
239
|
+
*/
|
|
240
|
+
readonly order: number;
|
|
241
|
+
/**
|
|
242
|
+
* Gets the computed width of the node.
|
|
243
|
+
*/
|
|
244
|
+
readonly width: number;
|
|
245
|
+
/**
|
|
246
|
+
* Gets the computed height of the node.
|
|
247
|
+
*/
|
|
248
|
+
readonly height: number;
|
|
249
|
+
}
|
|
250
|
+
|
|
161
251
|
/**
|
|
162
252
|
* Overflow handling enum
|
|
163
253
|
*
|
|
@@ -487,9 +577,9 @@ export class TaffyTree {
|
|
|
487
577
|
* * `node` - The node ID to query.
|
|
488
578
|
*
|
|
489
579
|
* # Returns
|
|
490
|
-
* A
|
|
580
|
+
* A `Layout` object with potentially fractional pixel values.
|
|
491
581
|
*/
|
|
492
|
-
unroundedLayout(node: bigint):
|
|
582
|
+
unroundedLayout(node: bigint): Layout;
|
|
493
583
|
/**
|
|
494
584
|
* Creates a new node with the given children.
|
|
495
585
|
*
|
|
@@ -654,9 +744,9 @@ export class TaffyTree {
|
|
|
654
744
|
* * `node` - The node ID to query.
|
|
655
745
|
*
|
|
656
746
|
* # Returns
|
|
657
|
-
* A
|
|
747
|
+
* A `Layout` object with computed position, size, and spacing values.
|
|
658
748
|
*/
|
|
659
|
-
getLayout(node: bigint):
|
|
749
|
+
getLayout(node: bigint): Layout;
|
|
660
750
|
/**
|
|
661
751
|
* Gets the parent of a node.
|
|
662
752
|
*
|
|
@@ -731,8 +821,30 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
731
821
|
|
|
732
822
|
export interface InitOutput {
|
|
733
823
|
readonly memory: WebAssembly.Memory;
|
|
824
|
+
readonly __wbg_layout_free: (a: number, b: number) => void;
|
|
734
825
|
readonly __wbg_style_free: (a: number, b: number) => void;
|
|
735
826
|
readonly __wbg_taffytree_free: (a: number, b: number) => void;
|
|
827
|
+
readonly layout_borderBottom: (a: number) => number;
|
|
828
|
+
readonly layout_borderLeft: (a: number) => number;
|
|
829
|
+
readonly layout_borderRight: (a: number) => number;
|
|
830
|
+
readonly layout_borderTop: (a: number) => number;
|
|
831
|
+
readonly layout_contentHeight: (a: number) => number;
|
|
832
|
+
readonly layout_contentWidth: (a: number) => number;
|
|
833
|
+
readonly layout_height: (a: number) => number;
|
|
834
|
+
readonly layout_marginBottom: (a: number) => number;
|
|
835
|
+
readonly layout_marginLeft: (a: number) => number;
|
|
836
|
+
readonly layout_marginRight: (a: number) => number;
|
|
837
|
+
readonly layout_marginTop: (a: number) => number;
|
|
838
|
+
readonly layout_order: (a: number) => number;
|
|
839
|
+
readonly layout_paddingBottom: (a: number) => number;
|
|
840
|
+
readonly layout_paddingLeft: (a: number) => number;
|
|
841
|
+
readonly layout_paddingRight: (a: number) => number;
|
|
842
|
+
readonly layout_paddingTop: (a: number) => number;
|
|
843
|
+
readonly layout_scrollbarHeight: (a: number) => number;
|
|
844
|
+
readonly layout_scrollbarWidth: (a: number) => number;
|
|
845
|
+
readonly layout_width: (a: number) => number;
|
|
846
|
+
readonly layout_x: (a: number) => number;
|
|
847
|
+
readonly layout_y: (a: number) => number;
|
|
736
848
|
readonly style_align_content: (a: number) => number;
|
|
737
849
|
readonly style_align_items: (a: number) => number;
|
|
738
850
|
readonly style_align_self: (a: number) => number;
|
package/taffy_js.js
CHANGED
|
@@ -219,6 +219,10 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
219
219
|
|
|
220
220
|
let WASM_VECTOR_LEN = 0;
|
|
221
221
|
|
|
222
|
+
const LayoutFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
223
|
+
? { register: () => {}, unregister: () => {} }
|
|
224
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_layout_free(ptr >>> 0, 1));
|
|
225
|
+
|
|
222
226
|
const StyleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
223
227
|
? { register: () => {}, unregister: () => {} }
|
|
224
228
|
: new FinalizationRegistry(ptr => wasm.__wbg_style_free(ptr >>> 0, 1));
|
|
@@ -392,6 +396,212 @@ export const JustifyContent = Object.freeze({
|
|
|
392
396
|
SpaceEvenly: 8, "8": "SpaceEvenly",
|
|
393
397
|
});
|
|
394
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Layout result struct
|
|
401
|
+
*
|
|
402
|
+
* A wrapper around `taffy::Layout` that provides WASM bindings.
|
|
403
|
+
* Contains the computed layout values for a node after calling `computeLayout()`.
|
|
404
|
+
* All values are in pixels.
|
|
405
|
+
*
|
|
406
|
+
* # Properties
|
|
407
|
+
* - `order`: Rendering order (higher = on top)
|
|
408
|
+
* - `x`, `y`: Position of top-left corner relative to parent
|
|
409
|
+
* - `width`, `height`: Computed dimensions
|
|
410
|
+
* - `contentWidth`, `contentHeight`: Size of scrollable content
|
|
411
|
+
* - `scrollbarWidth`, `scrollbarHeight`: Size allocated for scrollbars
|
|
412
|
+
* - `borderLeft`, `borderRight`, `borderTop`, `borderBottom`: Border widths
|
|
413
|
+
* - `paddingLeft`, `paddingRight`, `paddingTop`, `paddingBottom`: Padding sizes
|
|
414
|
+
* - `marginLeft`, `marginRight`, `marginTop`, `marginBottom`: Margin sizes
|
|
415
|
+
*/
|
|
416
|
+
export class Layout {
|
|
417
|
+
static __wrap(ptr) {
|
|
418
|
+
ptr = ptr >>> 0;
|
|
419
|
+
const obj = Object.create(Layout.prototype);
|
|
420
|
+
obj.__wbg_ptr = ptr;
|
|
421
|
+
LayoutFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
422
|
+
return obj;
|
|
423
|
+
}
|
|
424
|
+
__destroy_into_raw() {
|
|
425
|
+
const ptr = this.__wbg_ptr;
|
|
426
|
+
this.__wbg_ptr = 0;
|
|
427
|
+
LayoutFinalization.unregister(this);
|
|
428
|
+
return ptr;
|
|
429
|
+
}
|
|
430
|
+
free() {
|
|
431
|
+
const ptr = this.__destroy_into_raw();
|
|
432
|
+
wasm.__wbg_layout_free(ptr, 0);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Gets the top border width.
|
|
436
|
+
* @returns {number}
|
|
437
|
+
*/
|
|
438
|
+
get borderTop() {
|
|
439
|
+
const ret = wasm.layout_borderTop(this.__wbg_ptr);
|
|
440
|
+
return ret;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Gets the top margin.
|
|
444
|
+
* @returns {number}
|
|
445
|
+
*/
|
|
446
|
+
get marginTop() {
|
|
447
|
+
const ret = wasm.layout_marginTop(this.__wbg_ptr);
|
|
448
|
+
return ret;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Gets the left border width.
|
|
452
|
+
* @returns {number}
|
|
453
|
+
*/
|
|
454
|
+
get borderLeft() {
|
|
455
|
+
const ret = wasm.layout_borderLeft(this.__wbg_ptr);
|
|
456
|
+
return ret;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Gets the left margin.
|
|
460
|
+
* @returns {number}
|
|
461
|
+
*/
|
|
462
|
+
get marginLeft() {
|
|
463
|
+
const ret = wasm.layout_marginLeft(this.__wbg_ptr);
|
|
464
|
+
return ret;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Gets the top padding.
|
|
468
|
+
* @returns {number}
|
|
469
|
+
*/
|
|
470
|
+
get paddingTop() {
|
|
471
|
+
const ret = wasm.layout_paddingTop(this.__wbg_ptr);
|
|
472
|
+
return ret;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Gets the right border width.
|
|
476
|
+
* @returns {number}
|
|
477
|
+
*/
|
|
478
|
+
get borderRight() {
|
|
479
|
+
const ret = wasm.layout_borderRight(this.__wbg_ptr);
|
|
480
|
+
return ret;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Gets the right margin.
|
|
484
|
+
* @returns {number}
|
|
485
|
+
*/
|
|
486
|
+
get marginRight() {
|
|
487
|
+
const ret = wasm.layout_marginRight(this.__wbg_ptr);
|
|
488
|
+
return ret;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Gets the left padding.
|
|
492
|
+
* @returns {number}
|
|
493
|
+
*/
|
|
494
|
+
get paddingLeft() {
|
|
495
|
+
const ret = wasm.layout_paddingLeft(this.__wbg_ptr);
|
|
496
|
+
return ret;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Gets the bottom border width.
|
|
500
|
+
* @returns {number}
|
|
501
|
+
*/
|
|
502
|
+
get borderBottom() {
|
|
503
|
+
const ret = wasm.layout_borderBottom(this.__wbg_ptr);
|
|
504
|
+
return ret;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Gets the width of the scrollable content.
|
|
508
|
+
* @returns {number}
|
|
509
|
+
*/
|
|
510
|
+
get contentWidth() {
|
|
511
|
+
const ret = wasm.layout_contentWidth(this.__wbg_ptr);
|
|
512
|
+
return ret;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Gets the bottom margin.
|
|
516
|
+
* @returns {number}
|
|
517
|
+
*/
|
|
518
|
+
get marginBottom() {
|
|
519
|
+
const ret = wasm.layout_marginBottom(this.__wbg_ptr);
|
|
520
|
+
return ret;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Gets the right padding.
|
|
524
|
+
* @returns {number}
|
|
525
|
+
*/
|
|
526
|
+
get paddingRight() {
|
|
527
|
+
const ret = wasm.layout_paddingRight(this.__wbg_ptr);
|
|
528
|
+
return ret;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Gets the height of the scrollable content.
|
|
532
|
+
* @returns {number}
|
|
533
|
+
*/
|
|
534
|
+
get contentHeight() {
|
|
535
|
+
const ret = wasm.layout_contentHeight(this.__wbg_ptr);
|
|
536
|
+
return ret;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Gets the bottom padding.
|
|
540
|
+
* @returns {number}
|
|
541
|
+
*/
|
|
542
|
+
get paddingBottom() {
|
|
543
|
+
const ret = wasm.layout_paddingBottom(this.__wbg_ptr);
|
|
544
|
+
return ret;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Gets the width of the vertical scrollbar.
|
|
548
|
+
* @returns {number}
|
|
549
|
+
*/
|
|
550
|
+
get scrollbarWidth() {
|
|
551
|
+
const ret = wasm.layout_scrollbarWidth(this.__wbg_ptr);
|
|
552
|
+
return ret;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Gets the height of the horizontal scrollbar.
|
|
556
|
+
* @returns {number}
|
|
557
|
+
*/
|
|
558
|
+
get scrollbarHeight() {
|
|
559
|
+
const ret = wasm.layout_scrollbarHeight(this.__wbg_ptr);
|
|
560
|
+
return ret;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Gets the x coordinate of the node's top-left corner.
|
|
564
|
+
* @returns {number}
|
|
565
|
+
*/
|
|
566
|
+
get x() {
|
|
567
|
+
const ret = wasm.layout_x(this.__wbg_ptr);
|
|
568
|
+
return ret;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Gets the y coordinate of the node's top-left corner.
|
|
572
|
+
* @returns {number}
|
|
573
|
+
*/
|
|
574
|
+
get y() {
|
|
575
|
+
const ret = wasm.layout_y(this.__wbg_ptr);
|
|
576
|
+
return ret;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Gets the rendering order of the node.
|
|
580
|
+
* @returns {number}
|
|
581
|
+
*/
|
|
582
|
+
get order() {
|
|
583
|
+
const ret = wasm.layout_order(this.__wbg_ptr);
|
|
584
|
+
return ret >>> 0;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Gets the computed width of the node.
|
|
588
|
+
* @returns {number}
|
|
589
|
+
*/
|
|
590
|
+
get width() {
|
|
591
|
+
const ret = wasm.layout_width(this.__wbg_ptr);
|
|
592
|
+
return ret;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Gets the computed height of the node.
|
|
596
|
+
* @returns {number}
|
|
597
|
+
*/
|
|
598
|
+
get height() {
|
|
599
|
+
const ret = wasm.layout_height(this.__wbg_ptr);
|
|
600
|
+
return ret;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
|
|
604
|
+
|
|
395
605
|
/**
|
|
396
606
|
* Overflow handling enum
|
|
397
607
|
*
|
|
@@ -1129,16 +1339,16 @@ export class TaffyTree {
|
|
|
1129
1339
|
* * `node` - The node ID to query.
|
|
1130
1340
|
*
|
|
1131
1341
|
* # Returns
|
|
1132
|
-
* A
|
|
1342
|
+
* A `Layout` object with potentially fractional pixel values.
|
|
1133
1343
|
* @param {bigint} node
|
|
1134
|
-
* @returns {
|
|
1344
|
+
* @returns {Layout}
|
|
1135
1345
|
*/
|
|
1136
1346
|
unroundedLayout(node) {
|
|
1137
1347
|
const ret = wasm.taffytree_unroundedLayout(this.__wbg_ptr, node);
|
|
1138
1348
|
if (ret[2]) {
|
|
1139
1349
|
throw takeFromExternrefTable0(ret[1]);
|
|
1140
1350
|
}
|
|
1141
|
-
return
|
|
1351
|
+
return Layout.__wrap(ret[0]);
|
|
1142
1352
|
}
|
|
1143
1353
|
/**
|
|
1144
1354
|
* Creates a new node with the given children.
|
|
@@ -1412,16 +1622,16 @@ export class TaffyTree {
|
|
|
1412
1622
|
* * `node` - The node ID to query.
|
|
1413
1623
|
*
|
|
1414
1624
|
* # Returns
|
|
1415
|
-
* A
|
|
1625
|
+
* A `Layout` object with computed position, size, and spacing values.
|
|
1416
1626
|
* @param {bigint} node
|
|
1417
|
-
* @returns {
|
|
1627
|
+
* @returns {Layout}
|
|
1418
1628
|
*/
|
|
1419
1629
|
getLayout(node) {
|
|
1420
1630
|
const ret = wasm.taffytree_getLayout(this.__wbg_ptr, node);
|
|
1421
1631
|
if (ret[2]) {
|
|
1422
1632
|
throw takeFromExternrefTable0(ret[1]);
|
|
1423
1633
|
}
|
|
1424
|
-
return
|
|
1634
|
+
return Layout.__wrap(ret[0]);
|
|
1425
1635
|
}
|
|
1426
1636
|
/**
|
|
1427
1637
|
* Gets the parent of a node.
|
|
@@ -1696,7 +1906,7 @@ function __wbg_get_imports() {
|
|
|
1696
1906
|
const ret = arg0.length;
|
|
1697
1907
|
return ret;
|
|
1698
1908
|
};
|
|
1699
|
-
imports.wbg.
|
|
1909
|
+
imports.wbg.__wbg_log_b0b3f53073d3e573 = function(arg0, arg1) {
|
|
1700
1910
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
1701
1911
|
};
|
|
1702
1912
|
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
package/taffy_js_bg.wasm
CHANGED
|
Binary file
|