taffy-js 0.1.1 → 0.1.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/README.md +306 -46
- package/package.json +13 -27
- package/{pkg/taffy_wasm.d.ts → taffy_js.d.ts} +142 -47
- package/{pkg/taffy_wasm.js → taffy_js.js} +388 -70
- package/taffy_js_bg.wasm +0 -0
- package/pkg/README.md +0 -178
- package/pkg/package.json +0 -26
- package/pkg/taffy_wasm_bg.wasm +0 -0
- package/pkg/taffy_wasm_bg.wasm.d.ts +0 -157
|
@@ -81,34 +81,38 @@ export enum AlignItems {
|
|
|
81
81
|
* How a single item is aligned along the cross axis, overriding `AlignItems`.
|
|
82
82
|
*/
|
|
83
83
|
export enum AlignSelf {
|
|
84
|
+
/**
|
|
85
|
+
* Auto
|
|
86
|
+
*/
|
|
87
|
+
Auto = 0,
|
|
84
88
|
/**
|
|
85
89
|
* items are aligned at the start of the cross axis.
|
|
86
90
|
*/
|
|
87
|
-
Start =
|
|
91
|
+
Start = 1,
|
|
88
92
|
/**
|
|
89
93
|
* Items are aligned at the end of the cross axis.
|
|
90
94
|
*/
|
|
91
|
-
End =
|
|
95
|
+
End = 2,
|
|
92
96
|
/**
|
|
93
97
|
* Items are aligned at the start of the flex-direction cross axis.
|
|
94
98
|
*/
|
|
95
|
-
FlexStart =
|
|
99
|
+
FlexStart = 3,
|
|
96
100
|
/**
|
|
97
101
|
* Items are aligned at the end of the flex-direction cross axis.
|
|
98
102
|
*/
|
|
99
|
-
FlexEnd =
|
|
103
|
+
FlexEnd = 4,
|
|
100
104
|
/**
|
|
101
105
|
* Items are aligned at the center of the cross axis.
|
|
102
106
|
*/
|
|
103
|
-
Center =
|
|
107
|
+
Center = 5,
|
|
104
108
|
/**
|
|
105
109
|
* Items are aligned based on their baselines.
|
|
106
110
|
*/
|
|
107
|
-
Baseline =
|
|
111
|
+
Baseline = 6,
|
|
108
112
|
/**
|
|
109
113
|
* Items are stretched to fill the container along the cross axis.
|
|
110
114
|
*/
|
|
111
|
-
Stretch =
|
|
115
|
+
Stretch = 7,
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
export class AvailableSpace {
|
|
@@ -190,6 +194,21 @@ export enum Display {
|
|
|
190
194
|
Block = 3,
|
|
191
195
|
}
|
|
192
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Start and End are used for logical positioning (e.g. paddingStart).
|
|
199
|
+
*/
|
|
200
|
+
export enum Edge {
|
|
201
|
+
Left = 0,
|
|
202
|
+
Right = 1,
|
|
203
|
+
Top = 2,
|
|
204
|
+
Bottom = 3,
|
|
205
|
+
Start = 4,
|
|
206
|
+
End = 5,
|
|
207
|
+
Horizontal = 6,
|
|
208
|
+
Vertical = 7,
|
|
209
|
+
All = 8,
|
|
210
|
+
}
|
|
211
|
+
|
|
193
212
|
/**
|
|
194
213
|
* The direction of the main axis for a flex container.
|
|
195
214
|
*/
|
|
@@ -252,6 +271,12 @@ export enum GridAutoFlow {
|
|
|
252
271
|
ColumnDense = 3,
|
|
253
272
|
}
|
|
254
273
|
|
|
274
|
+
export enum Gutter {
|
|
275
|
+
Column = 0,
|
|
276
|
+
Row = 1,
|
|
277
|
+
All = 2,
|
|
278
|
+
}
|
|
279
|
+
|
|
255
280
|
/**
|
|
256
281
|
* How items are distributed along the main axis.
|
|
257
282
|
*/
|
|
@@ -675,16 +700,46 @@ export class Style {
|
|
|
675
700
|
export class TaffyNode {
|
|
676
701
|
free(): void;
|
|
677
702
|
[Symbol.dispose](): void;
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
703
|
+
getLayout(): Layout;
|
|
704
|
+
markDirty(): void;
|
|
705
|
+
setBorder(edge: Edge, value: number): void;
|
|
706
|
+
setHeight(value: number): void;
|
|
707
|
+
setMargin(edge: Edge, value: number): void;
|
|
708
|
+
setDisplay(display: Display): void;
|
|
709
|
+
setPadding(edge: Edge, value: number): void;
|
|
710
|
+
insertChild(child: TaffyNode, index: number): void;
|
|
711
|
+
removeChild(child: TaffyNode): void;
|
|
712
|
+
setChildren(children: BigUint64Array): void;
|
|
713
|
+
setFlexGrow(value: number): void;
|
|
714
|
+
setFlexWrap(wrap: FlexWrap): void;
|
|
715
|
+
setMinWidth(value: number): void;
|
|
716
|
+
computeLayout(available_space: any): void;
|
|
717
|
+
setAlignSelf(align: AlignSelf): void;
|
|
718
|
+
setFlexBasis(value: number): void;
|
|
719
|
+
setMinHeight(value: number): void;
|
|
720
|
+
setWidthAuto(): void;
|
|
721
|
+
setAlignItems(align: AlignItems): void;
|
|
722
|
+
setFlexShrink(value: number): void;
|
|
723
|
+
setHeightAuto(): void;
|
|
724
|
+
setMarginAuto(edge: Edge): void;
|
|
725
|
+
setMeasureFunc(js_func: Function): void;
|
|
726
|
+
setPositionType(position: Position): void;
|
|
727
|
+
setWidthPercent(value: number): void;
|
|
728
|
+
setFlexDirection(direction: FlexDirection): void;
|
|
729
|
+
setHeightPercent(value: number): void;
|
|
730
|
+
setFlexBasisAuto(): void;
|
|
731
|
+
setJustifyContent(justify: JustifyContent): void;
|
|
732
|
+
setMinWidthPercent(value: number): void;
|
|
733
|
+
setFlexBasisPercent(value: number): void;
|
|
734
|
+
setMinHeightPercent(value: number): void;
|
|
682
735
|
constructor(style: any);
|
|
683
736
|
free(): void;
|
|
684
737
|
style(): any;
|
|
685
|
-
|
|
738
|
+
setGap(gutter: Gutter, value: number): void;
|
|
739
|
+
addChild(child: TaffyNode): void;
|
|
686
740
|
set_style(style: any): void;
|
|
687
|
-
|
|
741
|
+
setWidth(value: number): void;
|
|
742
|
+
id: bigint;
|
|
688
743
|
}
|
|
689
744
|
|
|
690
745
|
/**
|
|
@@ -754,7 +809,7 @@ export enum TrackUnit {
|
|
|
754
809
|
*
|
|
755
810
|
* Returns a `JsValue` error if the operation fails (e.g., recursive hierarchy).
|
|
756
811
|
*/
|
|
757
|
-
export function add_child(parent:
|
|
812
|
+
export function add_child(parent: bigint, child: bigint): void;
|
|
758
813
|
|
|
759
814
|
/**
|
|
760
815
|
* Auto dimension constant
|
|
@@ -762,7 +817,10 @@ export function add_child(parent: number, child: number): void;
|
|
|
762
817
|
export function auto(): Dimension;
|
|
763
818
|
|
|
764
819
|
/**
|
|
765
|
-
* Clear all nodes
|
|
820
|
+
* Clear all nodes from the layout tree.
|
|
821
|
+
*
|
|
822
|
+
* This removes all nodes and resets the tree to an empty state.
|
|
823
|
+
* Any existing node IDs become invalid after this call.
|
|
766
824
|
*/
|
|
767
825
|
export function clear(): void;
|
|
768
826
|
|
|
@@ -778,7 +836,7 @@ export function clear(): void;
|
|
|
778
836
|
*
|
|
779
837
|
* Returns a `JsValue` error if the layout computation fails.
|
|
780
838
|
*/
|
|
781
|
-
export function compute_layout(root:
|
|
839
|
+
export function compute_layout(root: bigint, available_space: any): void;
|
|
782
840
|
|
|
783
841
|
/**
|
|
784
842
|
* Helper function to create a dimension
|
|
@@ -800,7 +858,7 @@ export function dimension(value: number, unit: DimensionUnit): Dimension;
|
|
|
800
858
|
*
|
|
801
859
|
* Returns a `JsValue` error if the node does not exist.
|
|
802
860
|
*/
|
|
803
|
-
export function get_children(parent:
|
|
861
|
+
export function get_children(parent: bigint): BigUint64Array;
|
|
804
862
|
|
|
805
863
|
/**
|
|
806
864
|
* Retrieves the computed layout information for a specific node.
|
|
@@ -817,7 +875,7 @@ export function get_children(parent: number): Uint32Array;
|
|
|
817
875
|
*
|
|
818
876
|
* Returns a `JsValue` error if the node does not exist or layout information is unavailable.
|
|
819
877
|
*/
|
|
820
|
-
export function get_layout(node:
|
|
878
|
+
export function get_layout(node: bigint): any;
|
|
821
879
|
|
|
822
880
|
/**
|
|
823
881
|
* Retrieves the parent ID of a given node.
|
|
@@ -834,10 +892,13 @@ export function get_layout(node: number): any;
|
|
|
834
892
|
*
|
|
835
893
|
* Returns a `JsValue` error if internal tree access fails.
|
|
836
894
|
*/
|
|
837
|
-
export function get_parent(node:
|
|
895
|
+
export function get_parent(node: bigint): bigint | undefined;
|
|
838
896
|
|
|
839
897
|
/**
|
|
840
|
-
* Initialize
|
|
898
|
+
* Initialize the WASM module.
|
|
899
|
+
*
|
|
900
|
+
* This function is automatically called when the WASM module is loaded.
|
|
901
|
+
* It sets up the console error panic hook for better error messages in development.
|
|
841
902
|
*/
|
|
842
903
|
export function init(): void;
|
|
843
904
|
|
|
@@ -852,7 +913,7 @@ export function init(): void;
|
|
|
852
913
|
*
|
|
853
914
|
* Returns a `JsValue` error if the node does not exist.
|
|
854
915
|
*/
|
|
855
|
-
export function mark_dirty(node:
|
|
916
|
+
export function mark_dirty(node: bigint): void;
|
|
856
917
|
|
|
857
918
|
/**
|
|
858
919
|
* Creates a new leaf node with the specified style.
|
|
@@ -869,7 +930,7 @@ export function mark_dirty(node: number): void;
|
|
|
869
930
|
*
|
|
870
931
|
* Returns a `JsValue` error if the style cannot be deserialized or if node creation fails.
|
|
871
932
|
*/
|
|
872
|
-
export function new_leaf(style: any):
|
|
933
|
+
export function new_leaf(style: any): bigint;
|
|
873
934
|
|
|
874
935
|
/**
|
|
875
936
|
* Creates a new node with children and the specified style.
|
|
@@ -887,10 +948,14 @@ export function new_leaf(style: any): number;
|
|
|
887
948
|
*
|
|
888
949
|
* Returns a `JsValue` error if the style cannot be deserialized or if node creation fails.
|
|
889
950
|
*/
|
|
890
|
-
export function new_with_children(style: any, children:
|
|
951
|
+
export function new_with_children(style: any, children: BigUint64Array): bigint;
|
|
891
952
|
|
|
892
953
|
/**
|
|
893
|
-
* Get the total number of nodes
|
|
954
|
+
* Get the total number of nodes currently in the layout tree.
|
|
955
|
+
*
|
|
956
|
+
* # Returns
|
|
957
|
+
*
|
|
958
|
+
* The total count of all nodes in the tree.
|
|
894
959
|
*/
|
|
895
960
|
export function node_count(): number;
|
|
896
961
|
|
|
@@ -916,7 +981,7 @@ export function px(value: number): Dimension;
|
|
|
916
981
|
*
|
|
917
982
|
* Returns a `JsValue` error if the child is not found in the parent.
|
|
918
983
|
*/
|
|
919
|
-
export function remove_child(parent:
|
|
984
|
+
export function remove_child(parent: bigint, child: bigint): void;
|
|
920
985
|
|
|
921
986
|
/**
|
|
922
987
|
* Removes a node from the tree and frees its resources.
|
|
@@ -929,7 +994,7 @@ export function remove_child(parent: number, child: number): void;
|
|
|
929
994
|
*
|
|
930
995
|
* Returns a `JsValue` error if the node does not exist or cannot be removed.
|
|
931
996
|
*/
|
|
932
|
-
export function remove_node(node:
|
|
997
|
+
export function remove_node(node: bigint): void;
|
|
933
998
|
|
|
934
999
|
/**
|
|
935
1000
|
* Sets the children of a node, replacing any existing children.
|
|
@@ -943,7 +1008,7 @@ export function remove_node(node: number): void;
|
|
|
943
1008
|
*
|
|
944
1009
|
* Returns a `JsValue` error if the operation fails.
|
|
945
1010
|
*/
|
|
946
|
-
export function set_children(parent:
|
|
1011
|
+
export function set_children(parent: bigint, children: BigUint64Array): void;
|
|
947
1012
|
|
|
948
1013
|
/**
|
|
949
1014
|
* Updates the style of an existing node.
|
|
@@ -957,7 +1022,7 @@ export function set_children(parent: number, children: Uint32Array): void;
|
|
|
957
1022
|
*
|
|
958
1023
|
* Returns a `JsValue` error if the style cannot be deserialized or if the node does not exist.
|
|
959
1024
|
*/
|
|
960
|
-
export function set_style(node:
|
|
1025
|
+
export function set_style(node: bigint, style: any): void;
|
|
961
1026
|
|
|
962
1027
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
963
1028
|
|
|
@@ -1005,7 +1070,7 @@ export interface InitOutput {
|
|
|
1005
1070
|
readonly __wbg_get_style_text_align: (a: number) => number;
|
|
1006
1071
|
readonly __wbg_get_style_top: (a: number) => number;
|
|
1007
1072
|
readonly __wbg_get_style_width: (a: number) => number;
|
|
1008
|
-
readonly __wbg_get_taffynode_id: (a: number) =>
|
|
1073
|
+
readonly __wbg_get_taffynode_id: (a: number) => bigint;
|
|
1009
1074
|
readonly __wbg_get_trackdefinition_unit: (a: number) => number;
|
|
1010
1075
|
readonly __wbg_line_free: (a: number, b: number) => void;
|
|
1011
1076
|
readonly __wbg_point_free: (a: number, b: number) => void;
|
|
@@ -1049,37 +1114,67 @@ export interface InitOutput {
|
|
|
1049
1114
|
readonly __wbg_set_style_text_align: (a: number, b: number) => void;
|
|
1050
1115
|
readonly __wbg_set_style_top: (a: number, b: number) => void;
|
|
1051
1116
|
readonly __wbg_set_style_width: (a: number, b: number) => void;
|
|
1052
|
-
readonly __wbg_set_taffynode_id: (a: number, b:
|
|
1117
|
+
readonly __wbg_set_taffynode_id: (a: number, b: bigint) => void;
|
|
1053
1118
|
readonly __wbg_set_trackdefinition_unit: (a: number, b: number) => void;
|
|
1054
1119
|
readonly __wbg_style_free: (a: number, b: number) => void;
|
|
1055
1120
|
readonly __wbg_taffynode_free: (a: number, b: number) => void;
|
|
1056
1121
|
readonly __wbg_trackdefinition_free: (a: number, b: number) => void;
|
|
1057
|
-
readonly add_child: (a:
|
|
1122
|
+
readonly add_child: (a: bigint, b: bigint) => [number, number];
|
|
1058
1123
|
readonly auto: () => number;
|
|
1059
1124
|
readonly clear: () => [number, number];
|
|
1060
|
-
readonly compute_layout: (a:
|
|
1125
|
+
readonly compute_layout: (a: bigint, b: any) => [number, number];
|
|
1061
1126
|
readonly dimension: (a: number, b: number) => number;
|
|
1062
|
-
readonly get_children: (a:
|
|
1063
|
-
readonly get_layout: (a:
|
|
1064
|
-
readonly get_parent: (a:
|
|
1127
|
+
readonly get_children: (a: bigint) => [number, number, number, number];
|
|
1128
|
+
readonly get_layout: (a: bigint) => [number, number, number];
|
|
1129
|
+
readonly get_parent: (a: bigint) => [number, bigint, number, number];
|
|
1065
1130
|
readonly init: () => void;
|
|
1066
|
-
readonly mark_dirty: (a:
|
|
1067
|
-
readonly new_leaf: (a: any) => [
|
|
1068
|
-
readonly new_with_children: (a: any, b: number, c: number) => [
|
|
1131
|
+
readonly mark_dirty: (a: bigint) => [number, number];
|
|
1132
|
+
readonly new_leaf: (a: any) => [bigint, number, number];
|
|
1133
|
+
readonly new_with_children: (a: any, b: number, c: number) => [bigint, number, number];
|
|
1069
1134
|
readonly node_count: () => number;
|
|
1070
1135
|
readonly percent: (a: number) => number;
|
|
1071
1136
|
readonly px: (a: number) => number;
|
|
1072
|
-
readonly remove_child: (a:
|
|
1073
|
-
readonly remove_node: (a:
|
|
1074
|
-
readonly set_children: (a:
|
|
1075
|
-
readonly set_style: (a:
|
|
1076
|
-
readonly
|
|
1077
|
-
readonly
|
|
1137
|
+
readonly remove_child: (a: bigint, b: bigint) => [number, number];
|
|
1138
|
+
readonly remove_node: (a: bigint) => [number, number];
|
|
1139
|
+
readonly set_children: (a: bigint, b: number, c: number) => [number, number];
|
|
1140
|
+
readonly set_style: (a: bigint, b: any) => [number, number];
|
|
1141
|
+
readonly taffynode_addChild: (a: number, b: number) => [number, number];
|
|
1142
|
+
readonly taffynode_computeLayout: (a: number, b: any) => [number, number];
|
|
1078
1143
|
readonly taffynode_free: (a: number) => [number, number];
|
|
1079
|
-
readonly
|
|
1144
|
+
readonly taffynode_getLayout: (a: number) => [number, number, number];
|
|
1145
|
+
readonly taffynode_insertChild: (a: number, b: number, c: number) => [number, number];
|
|
1146
|
+
readonly taffynode_markDirty: (a: number) => [number, number];
|
|
1080
1147
|
readonly taffynode_new: (a: any) => [number, number, number];
|
|
1081
|
-
readonly
|
|
1082
|
-
readonly
|
|
1148
|
+
readonly taffynode_removeChild: (a: number, b: number) => [number, number];
|
|
1149
|
+
readonly taffynode_setAlignItems: (a: number, b: number) => [number, number];
|
|
1150
|
+
readonly taffynode_setAlignSelf: (a: number, b: number) => [number, number];
|
|
1151
|
+
readonly taffynode_setBorder: (a: number, b: number, c: number) => [number, number];
|
|
1152
|
+
readonly taffynode_setChildren: (a: number, b: number, c: number) => [number, number];
|
|
1153
|
+
readonly taffynode_setDisplay: (a: number, b: number) => [number, number];
|
|
1154
|
+
readonly taffynode_setFlexBasis: (a: number, b: number) => [number, number];
|
|
1155
|
+
readonly taffynode_setFlexBasisAuto: (a: number) => [number, number];
|
|
1156
|
+
readonly taffynode_setFlexBasisPercent: (a: number, b: number) => [number, number];
|
|
1157
|
+
readonly taffynode_setFlexDirection: (a: number, b: number) => [number, number];
|
|
1158
|
+
readonly taffynode_setFlexGrow: (a: number, b: number) => [number, number];
|
|
1159
|
+
readonly taffynode_setFlexShrink: (a: number, b: number) => [number, number];
|
|
1160
|
+
readonly taffynode_setFlexWrap: (a: number, b: number) => [number, number];
|
|
1161
|
+
readonly taffynode_setGap: (a: number, b: number, c: number) => [number, number];
|
|
1162
|
+
readonly taffynode_setHeight: (a: number, b: number) => [number, number];
|
|
1163
|
+
readonly taffynode_setHeightAuto: (a: number) => [number, number];
|
|
1164
|
+
readonly taffynode_setHeightPercent: (a: number, b: number) => [number, number];
|
|
1165
|
+
readonly taffynode_setJustifyContent: (a: number, b: number) => [number, number];
|
|
1166
|
+
readonly taffynode_setMargin: (a: number, b: number, c: number) => [number, number];
|
|
1167
|
+
readonly taffynode_setMarginAuto: (a: number, b: number) => [number, number];
|
|
1168
|
+
readonly taffynode_setMeasureFunc: (a: number, b: any) => [number, number];
|
|
1169
|
+
readonly taffynode_setMinHeight: (a: number, b: number) => [number, number];
|
|
1170
|
+
readonly taffynode_setMinHeightPercent: (a: number, b: number) => [number, number];
|
|
1171
|
+
readonly taffynode_setMinWidth: (a: number, b: number) => [number, number];
|
|
1172
|
+
readonly taffynode_setMinWidthPercent: (a: number, b: number) => [number, number];
|
|
1173
|
+
readonly taffynode_setPadding: (a: number, b: number, c: number) => [number, number];
|
|
1174
|
+
readonly taffynode_setPositionType: (a: number, b: number) => [number, number];
|
|
1175
|
+
readonly taffynode_setWidth: (a: number, b: number) => [number, number];
|
|
1176
|
+
readonly taffynode_setWidthAuto: (a: number) => [number, number];
|
|
1177
|
+
readonly taffynode_setWidthPercent: (a: number, b: number) => [number, number];
|
|
1083
1178
|
readonly taffynode_set_style: (a: number, b: any) => [number, number];
|
|
1084
1179
|
readonly taffynode_style: (a: number) => [number, number, number];
|
|
1085
1180
|
readonly __wbg_set_layout_x: (a: number, b: number) => void;
|