taffy-js 0.2.3 → 0.2.4
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 +353 -395
- package/package.json +2 -2
- package/taffy_js.d.ts +1688 -572
- package/taffy_js.js +2804 -1820
- package/taffy_js_bg.wasm +0 -0
package/taffy_js.d.ts
CHANGED
|
@@ -2,827 +2,1846 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - `
|
|
12
|
-
* - `
|
|
13
|
-
* - `
|
|
5
|
+
* Available space constraint for layout computation.
|
|
6
|
+
*
|
|
7
|
+
* Specifies how much space is available for a node during layout calculation.
|
|
8
|
+
* This is passed to `computeLayout()` to define the container constraints.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* - Use `number` when you have a fixed container size
|
|
12
|
+
* - Use `"minContent"` to shrink-wrap to the minimum content size
|
|
13
|
+
* - Use `"maxContent"` to expand to fit all content without wrapping
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import init, { TaffyTree, Style, type AvailableSpace, type Size } from 'taffy-js';
|
|
18
|
+
*
|
|
19
|
+
* await init();
|
|
20
|
+
* const tree = new TaffyTree();
|
|
21
|
+
* const root: bigint = tree.newLeaf(new Style());
|
|
22
|
+
*
|
|
23
|
+
* // Fixed size container with type annotation
|
|
24
|
+
* const fixedSpace: Size<AvailableSpace> = {
|
|
25
|
+
* width: 800,
|
|
26
|
+
* height: 600
|
|
27
|
+
* };
|
|
28
|
+
* tree.computeLayout(root, fixedSpace);
|
|
29
|
+
*
|
|
30
|
+
* // Flexible width, fixed height
|
|
31
|
+
* const flexibleSpace: Size<AvailableSpace> = {
|
|
32
|
+
* width: "maxContent",
|
|
33
|
+
* height: 400
|
|
34
|
+
* };
|
|
35
|
+
* tree.computeLayout(root, flexibleSpace);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export type AvailableSpace = number | "minContent" | "maxContent";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Generic size type with width and height.
|
|
42
|
+
*
|
|
43
|
+
* A two-dimensional container for width and height values. The type parameter `T`
|
|
44
|
+
* determines what kind of values are stored.
|
|
45
|
+
*
|
|
46
|
+
* @typeParam T - The type of each dimension (e.g., `number`, `Dimension`, `AvailableSpace`)
|
|
47
|
+
*
|
|
48
|
+
* @property width - The horizontal dimension value
|
|
49
|
+
* @property height - The vertical dimension value
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import type { Size, Dimension, AvailableSpace } from 'taffy-js';
|
|
54
|
+
*
|
|
55
|
+
* // Size with explicit type parameters
|
|
56
|
+
* const pixelSize: Size<number> = { width: 200, height: 100 };
|
|
57
|
+
*
|
|
58
|
+
* const dimensionSize: Size<Dimension> = {
|
|
59
|
+
* width: { Length: 200 },
|
|
60
|
+
* height: { Percent: 50 }
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* const availableSize: Size<AvailableSpace> = {
|
|
64
|
+
* width: 800,
|
|
65
|
+
* height: "MaxContent"
|
|
66
|
+
* };
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export interface Size<T> {
|
|
70
|
+
/** The horizontal dimension value */
|
|
71
|
+
width: T;
|
|
72
|
+
/** The vertical dimension value */
|
|
73
|
+
height: T;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Custom measure function for leaf nodes with text or other dynamic content.
|
|
78
|
+
*
|
|
79
|
+
* This callback is invoked during layout computation for leaf nodes that need
|
|
80
|
+
* custom sizing based on their content (e.g., text nodes that need text measurement).
|
|
81
|
+
*
|
|
82
|
+
* @param knownDimensions - Dimensions already determined by constraints. Each dimension
|
|
83
|
+
* is `number` if known, or `null` if needs to be measured.
|
|
84
|
+
* @param availableSpace - The available space constraints for the node. Can be definite
|
|
85
|
+
* pixels, "minContent", or "maxContent".
|
|
86
|
+
* @param node - The node ID (`bigint`) of the node being measured
|
|
87
|
+
* @param context - User-provided context attached to the node via `newLeafWithContext()`
|
|
88
|
+
* @param style - The node's current Style configuration
|
|
89
|
+
*
|
|
90
|
+
* @returns - The measured size of the content in pixels
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import init, { TaffyTree, Style, type MeasureFunction, type Size } from 'taffy-js';
|
|
95
|
+
*
|
|
96
|
+
* interface TextContext {
|
|
97
|
+
* text: string;
|
|
98
|
+
* fontSize: number;
|
|
99
|
+
* }
|
|
100
|
+
*
|
|
101
|
+
* await init();
|
|
102
|
+
* const tree = new TaffyTree();
|
|
103
|
+
*
|
|
104
|
+
* const style = new Style();
|
|
105
|
+
* const context: TextContext = { text: "Hello, World!", fontSize: 16 };
|
|
106
|
+
* const textNode: bigint = tree.newLeafWithContext(style, context);
|
|
107
|
+
*
|
|
108
|
+
* // Typed measure function
|
|
109
|
+
* const measureText: MeasureFunction = (
|
|
110
|
+
* knownDimensions,
|
|
111
|
+
* availableSpace,
|
|
112
|
+
* node,
|
|
113
|
+
* context,
|
|
114
|
+
* style
|
|
115
|
+
* ): Size<number> => {
|
|
116
|
+
* const ctx = context as TextContext | undefined;
|
|
117
|
+
* if (!ctx?.text) return { width: 0, height: 0 };
|
|
118
|
+
*
|
|
119
|
+
* const width = knownDimensions.width ?? measureTextWidth(ctx.text, ctx.fontSize);
|
|
120
|
+
* const height = knownDimensions.height ?? ctx.fontSize * 1.2;
|
|
121
|
+
*
|
|
122
|
+
* return { width, height };
|
|
123
|
+
* };
|
|
124
|
+
*
|
|
125
|
+
* tree.computeLayoutWithMeasure(
|
|
126
|
+
* textNode,
|
|
127
|
+
* { width: 200, height: "maxContent" },
|
|
128
|
+
* measureText
|
|
129
|
+
* );
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export type MeasureFunction = (
|
|
133
|
+
knownDimensions: Size<number | null>,
|
|
134
|
+
availableSpace: Size<AvailableSpace>,
|
|
135
|
+
node: bigint,
|
|
136
|
+
context: any,
|
|
137
|
+
style: Style,
|
|
138
|
+
) => Size<number>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Dimension type supporting length, percentage, or auto values.
|
|
142
|
+
*
|
|
143
|
+
* Used for sizing properties like `width`, `height`, `flexBasis`, etc.
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* - `number`: Fixed size in pixels
|
|
147
|
+
* - `"{number}%"`: Percentage of parent's size (0-100)
|
|
148
|
+
* - `"auto"`: Size determined by content or layout algorithm
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* import { Style, type Dimension, type Size } from 'taffy-js';
|
|
153
|
+
*
|
|
154
|
+
* const style = new Style();
|
|
155
|
+
*
|
|
156
|
+
* // With explicit type annotations
|
|
157
|
+
* const fixedSize: Size<Dimension> = {
|
|
158
|
+
* width: 200,
|
|
159
|
+
* height: 100
|
|
160
|
+
* };
|
|
161
|
+
*
|
|
162
|
+
* const percentSize: Size<Dimension> = {
|
|
163
|
+
* width: "50%",
|
|
164
|
+
* height: "100%"
|
|
165
|
+
* };
|
|
166
|
+
*
|
|
167
|
+
* const autoSize: Size<Dimension> = {
|
|
168
|
+
* width: "auto",
|
|
169
|
+
* height: "auto"
|
|
170
|
+
* };
|
|
171
|
+
*
|
|
172
|
+
* style.size = fixedSize;
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export type Dimension = number | `${number}%` | "auto";
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Length or percentage value (no auto support).
|
|
179
|
+
*
|
|
180
|
+
* Used for properties that require explicit values, such as `padding`, `border`, and `gap`.
|
|
181
|
+
*
|
|
182
|
+
* @remarks
|
|
183
|
+
* - `number`: Fixed size in pixels
|
|
184
|
+
* - `"{number}%"`: Percentage of parent's size (0-100)
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* import { Style, type LengthPercentage, type Rect, type Size } from 'taffy-js';
|
|
189
|
+
*
|
|
190
|
+
* const style = new Style();
|
|
191
|
+
*
|
|
192
|
+
* const padding: Rect<LengthPercentage> = {
|
|
193
|
+
* left: 10,
|
|
194
|
+
* right: 10,
|
|
195
|
+
* top: 5,
|
|
196
|
+
* bottom: 5
|
|
197
|
+
* };
|
|
198
|
+
*
|
|
199
|
+
* const gap: Size<LengthPercentage> = {
|
|
200
|
+
* width: "5%",
|
|
201
|
+
* height: "5%"
|
|
202
|
+
* };
|
|
203
|
+
*
|
|
204
|
+
* style.padding = padding;
|
|
205
|
+
* style.gap = gap;
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export type LengthPercentage = number | `${number}%`;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Length, percentage, or auto value.
|
|
212
|
+
*
|
|
213
|
+
* Used for properties that support auto values, such as `margin` and `inset`.
|
|
214
|
+
*
|
|
215
|
+
* @remarks
|
|
216
|
+
* - `number`: Fixed size in pixels
|
|
217
|
+
* - `"{number}%"`: Percentage of parent's size (0-100)
|
|
218
|
+
* - `"auto"`: Automatic value (behavior depends on property)
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* import { Style, type LengthPercentageAuto, type Rect } from 'taffy-js';
|
|
223
|
+
*
|
|
224
|
+
* const style = new Style();
|
|
225
|
+
*
|
|
226
|
+
* // Auto margins for horizontal centering
|
|
227
|
+
* const centerMargin: Rect<LengthPercentageAuto> = {
|
|
228
|
+
* left: "auto",
|
|
229
|
+
* right: "auto",
|
|
230
|
+
* top: 0,
|
|
231
|
+
* bottom: 0
|
|
232
|
+
* };
|
|
233
|
+
*
|
|
234
|
+
* style.margin = centerMargin;
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
export type LengthPercentageAuto = number | `${number}%` | "auto";
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Point with x and y coordinates/values.
|
|
241
|
+
*
|
|
242
|
+
* Used for properties that have separate horizontal (x) and vertical (y) values,
|
|
243
|
+
* such as `overflow`.
|
|
244
|
+
*
|
|
245
|
+
* @typeParam T - The type of each coordinate
|
|
246
|
+
*
|
|
247
|
+
* @property x - The horizontal value
|
|
248
|
+
* @property y - The vertical value
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* import { Style, Overflow, type Point } from 'taffy-js';
|
|
253
|
+
*
|
|
254
|
+
* const style = new Style();
|
|
255
|
+
*
|
|
256
|
+
* const overflow: Point<typeof Overflow[keyof typeof Overflow]> = {
|
|
257
|
+
* x: Overflow.Hidden,
|
|
258
|
+
* y: Overflow.Scroll
|
|
259
|
+
* };
|
|
260
|
+
*
|
|
261
|
+
* style.overflow = overflow;
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
export interface Point<T> {
|
|
265
|
+
/** The horizontal (x-axis) value */
|
|
266
|
+
x: T;
|
|
267
|
+
/** The vertical (y-axis) value */
|
|
268
|
+
y: T;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Rectangle with left, right, top, and bottom values.
|
|
273
|
+
*
|
|
274
|
+
* Used for box model properties like `margin`, `padding`, `border`, and `inset`.
|
|
275
|
+
*
|
|
276
|
+
* @typeParam T - The type of each side value
|
|
277
|
+
*
|
|
278
|
+
* @property left - The left side value
|
|
279
|
+
* @property right - The right side value
|
|
280
|
+
* @property top - The top side value
|
|
281
|
+
* @property bottom - The bottom side value
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* import { Style, type Rect, type LengthPercentage, type LengthPercentageAuto } from 'taffy-js';
|
|
286
|
+
*
|
|
287
|
+
* const style = new Style();
|
|
288
|
+
*
|
|
289
|
+
* // Typed padding
|
|
290
|
+
* const padding: Rect<LengthPercentage> = {
|
|
291
|
+
* left: 10,
|
|
292
|
+
* right: 10,
|
|
293
|
+
* top: 10,
|
|
294
|
+
* bottom: 10
|
|
295
|
+
* };
|
|
296
|
+
*
|
|
297
|
+
* // Typed margin with auto
|
|
298
|
+
* const margin: Rect<LengthPercentageAuto> = {
|
|
299
|
+
* left: "auto",
|
|
300
|
+
* right: "auto",
|
|
301
|
+
* top: 10,
|
|
302
|
+
* bottom: 30
|
|
303
|
+
* };
|
|
304
|
+
*
|
|
305
|
+
* style.padding = padding;
|
|
306
|
+
* style.margin = margin;
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
export interface Rect<T> {
|
|
310
|
+
/** The left side value */
|
|
311
|
+
left: T;
|
|
312
|
+
/** The right side value */
|
|
313
|
+
right: T;
|
|
314
|
+
/** The top side value */
|
|
315
|
+
top: T;
|
|
316
|
+
/** The bottom side value */
|
|
317
|
+
bottom: T;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Detailed layout information (for grid layouts).
|
|
322
|
+
*
|
|
323
|
+
* Returned by `detailedLayoutInfo()` for nodes using CSS Grid layout.
|
|
324
|
+
* Contains detailed information about grid tracks and item placement.
|
|
325
|
+
*
|
|
326
|
+
* @remarks
|
|
327
|
+
* This is only available when the `detailed_layout_info` feature is enabled.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* import type { DetailedLayoutInfo, DetailedGridInfo } from 'taffy-js';
|
|
332
|
+
*
|
|
333
|
+
* const info: DetailedLayoutInfo = tree.detailedLayoutInfo(gridNode);
|
|
334
|
+
*
|
|
335
|
+
* if (info !== "None" && typeof info === 'object' && 'Grid' in info) {
|
|
336
|
+
* const grid: DetailedGridInfo = info.Grid;
|
|
337
|
+
* console.log('Rows:', grid.rows.sizes);
|
|
338
|
+
* console.log('Columns:', grid.columns.sizes);
|
|
339
|
+
* }
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
export type DetailedLayoutInfo = DetailedGridInfo | null;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Detailed information about a grid layout.
|
|
346
|
+
*
|
|
347
|
+
* Contains information about grid rows, columns, and item placement.
|
|
348
|
+
*
|
|
349
|
+
* @property rows - Information about row tracks
|
|
350
|
+
* @property columns - Information about column tracks
|
|
351
|
+
* @property items - Array of item placement information
|
|
352
|
+
*/
|
|
353
|
+
export interface DetailedGridInfo {
|
|
354
|
+
/** Information about the grid's row tracks */
|
|
355
|
+
rows: DetailedGridTracksInfo;
|
|
356
|
+
/** Information about the grid's column tracks */
|
|
357
|
+
columns: DetailedGridTracksInfo;
|
|
358
|
+
/** Placement information for each grid item */
|
|
359
|
+
items: DetailedGridItemsInfo[];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Information about grid tracks (rows or columns).
|
|
364
|
+
*
|
|
365
|
+
* Provides detailed sizing and gutter information for a set of grid tracks.
|
|
366
|
+
*
|
|
367
|
+
* @property negative_implicit_tracks - Number of implicit tracks before explicit tracks
|
|
368
|
+
* @property explicit_tracks - Number of explicitly defined tracks
|
|
369
|
+
* @property positive_implicit_tracks - Number of implicit tracks after explicit tracks
|
|
370
|
+
* @property gutters - Array of gutter sizes between tracks (in pixels)
|
|
371
|
+
* @property sizes - Array of track sizes (in pixels)
|
|
372
|
+
*/
|
|
373
|
+
export interface DetailedGridTracksInfo {
|
|
374
|
+
/** Number of implicit tracks before explicit tracks (for negative line numbers) */
|
|
375
|
+
negative_implicit_tracks: number;
|
|
376
|
+
/** Number of tracks explicitly defined in grid-template-rows/columns */
|
|
377
|
+
explicit_tracks: number;
|
|
378
|
+
/** Number of implicit tracks created after explicit tracks */
|
|
379
|
+
positive_implicit_tracks: number;
|
|
380
|
+
/** Gap sizes between tracks in pixels */
|
|
381
|
+
gutters: number[];
|
|
382
|
+
/** Computed sizes of each track in pixels */
|
|
383
|
+
sizes: number[];
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Information about a grid item's placement.
|
|
388
|
+
*
|
|
389
|
+
* Specifies which grid lines the item spans on both axes.
|
|
390
|
+
* Line numbers are 1-indexed, with 1 being the first line.
|
|
391
|
+
*
|
|
392
|
+
* @property row_start - Starting row line number (1-indexed)
|
|
393
|
+
* @property row_end - Ending row line number (exclusive)
|
|
394
|
+
* @property column_start - Starting column line number (1-indexed)
|
|
395
|
+
* @property column_end - Ending column line number (exclusive)
|
|
396
|
+
*/
|
|
397
|
+
export interface DetailedGridItemsInfo {
|
|
398
|
+
/** Starting row line (1-indexed) */
|
|
399
|
+
row_start: number;
|
|
400
|
+
/** Ending row line (exclusive) */
|
|
401
|
+
row_end: number;
|
|
402
|
+
/** Starting column line (1-indexed) */
|
|
403
|
+
column_start: number;
|
|
404
|
+
/** Ending column line (exclusive) */
|
|
405
|
+
column_end: number;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Multi-line content alignment enumeration
|
|
410
|
+
*
|
|
411
|
+
* Controls the distribution of space between and around content items along the cross axis
|
|
412
|
+
* in a multi-line flex container. This corresponds to the CSS `align-content` property.
|
|
413
|
+
*
|
|
414
|
+
* **Note**: This property only has effect when `flex-wrap` is set to `Wrap` or `WrapReverse`.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```typescript
|
|
418
|
+
* import { AlignContent, FlexWrap } from 'taffy-js';
|
|
419
|
+
*
|
|
420
|
+
* style.flexWrap = FlexWrap.Wrap;
|
|
421
|
+
* style.alignContent = AlignContent.SpaceBetween; // Distribute lines evenly
|
|
422
|
+
* ```
|
|
14
423
|
*/
|
|
15
424
|
export enum AlignContent {
|
|
425
|
+
/**
|
|
426
|
+
* Lines packed toward the start of the cross axis
|
|
427
|
+
*/
|
|
16
428
|
Start = 0,
|
|
429
|
+
/**
|
|
430
|
+
* Lines packed toward the end of the cross axis
|
|
431
|
+
*/
|
|
17
432
|
End = 1,
|
|
433
|
+
/**
|
|
434
|
+
* Lines packed toward the start of the flex container
|
|
435
|
+
*/
|
|
18
436
|
FlexStart = 2,
|
|
437
|
+
/**
|
|
438
|
+
* Lines packed toward the end of the flex container
|
|
439
|
+
*/
|
|
19
440
|
FlexEnd = 3,
|
|
441
|
+
/**
|
|
442
|
+
* Lines centered within the container
|
|
443
|
+
*/
|
|
20
444
|
Center = 4,
|
|
445
|
+
/**
|
|
446
|
+
* Lines stretched to fill the container
|
|
447
|
+
*/
|
|
21
448
|
Stretch = 5,
|
|
449
|
+
/**
|
|
450
|
+
* Lines evenly distributed with first/last at edges
|
|
451
|
+
*/
|
|
22
452
|
SpaceBetween = 6,
|
|
453
|
+
/**
|
|
454
|
+
* Lines evenly distributed with equal space around each
|
|
455
|
+
*/
|
|
23
456
|
SpaceAround = 7,
|
|
457
|
+
/**
|
|
458
|
+
* Lines evenly distributed with equal space between each
|
|
459
|
+
*/
|
|
24
460
|
SpaceEvenly = 8,
|
|
25
461
|
}
|
|
26
462
|
|
|
27
463
|
/**
|
|
28
|
-
* Cross-axis alignment
|
|
29
|
-
*
|
|
30
|
-
* Defines
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
464
|
+
* Cross-axis alignment enumeration for all children
|
|
465
|
+
*
|
|
466
|
+
* Defines the default alignment for all flex/grid items along the cross axis.
|
|
467
|
+
* This corresponds to the CSS `align-items` property.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* import { AlignItems } from 'taffy-js';
|
|
472
|
+
*
|
|
473
|
+
* style.alignItems = AlignItems.Center; // Center items on cross axis
|
|
474
|
+
* style.alignItems = AlignItems.Stretch; // Stretch items to fill container
|
|
475
|
+
* ```
|
|
38
476
|
*/
|
|
39
477
|
export enum AlignItems {
|
|
478
|
+
/**
|
|
479
|
+
* Items aligned to the start of the cross axis
|
|
480
|
+
*/
|
|
40
481
|
Start = 0,
|
|
482
|
+
/**
|
|
483
|
+
* Items aligned to the end of the cross axis
|
|
484
|
+
*/
|
|
41
485
|
End = 1,
|
|
486
|
+
/**
|
|
487
|
+
* Items aligned to the start of the flex container
|
|
488
|
+
*/
|
|
42
489
|
FlexStart = 2,
|
|
490
|
+
/**
|
|
491
|
+
* Items aligned to the end of the flex container
|
|
492
|
+
*/
|
|
43
493
|
FlexEnd = 3,
|
|
494
|
+
/**
|
|
495
|
+
* Items centered along the cross axis
|
|
496
|
+
*/
|
|
44
497
|
Center = 4,
|
|
498
|
+
/**
|
|
499
|
+
* Items aligned to their text baselines
|
|
500
|
+
*/
|
|
45
501
|
Baseline = 5,
|
|
502
|
+
/**
|
|
503
|
+
* Items stretched to fill the container
|
|
504
|
+
*/
|
|
46
505
|
Stretch = 6,
|
|
47
506
|
}
|
|
48
507
|
|
|
49
508
|
/**
|
|
50
|
-
* Cross-axis alignment
|
|
51
|
-
*
|
|
52
|
-
* Overrides parent's `align-items` for a
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
509
|
+
* Cross-axis alignment enumeration for a single element
|
|
510
|
+
*
|
|
511
|
+
* Overrides the parent's `align-items` value for a specific child element.
|
|
512
|
+
* This corresponds to the CSS `align-self` property.
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```typescript
|
|
516
|
+
* import { AlignSelf } from 'taffy-js';
|
|
517
|
+
*
|
|
518
|
+
* style.alignSelf = AlignSelf.Auto; // Use parent's align-items
|
|
519
|
+
* style.alignSelf = AlignSelf.Center; // Override to center this item
|
|
520
|
+
* ```
|
|
57
521
|
*/
|
|
58
522
|
export enum AlignSelf {
|
|
523
|
+
/**
|
|
524
|
+
* Inherits the parent container's `align-items` value
|
|
525
|
+
*/
|
|
59
526
|
Auto = 0,
|
|
527
|
+
/**
|
|
528
|
+
* Item aligned to the start of the cross axis
|
|
529
|
+
*/
|
|
60
530
|
Start = 1,
|
|
531
|
+
/**
|
|
532
|
+
* Item aligned to the end of the cross axis
|
|
533
|
+
*/
|
|
61
534
|
End = 2,
|
|
535
|
+
/**
|
|
536
|
+
* Item aligned to the start of the flex container
|
|
537
|
+
*/
|
|
62
538
|
FlexStart = 3,
|
|
539
|
+
/**
|
|
540
|
+
* Item aligned to the end of the flex container
|
|
541
|
+
*/
|
|
63
542
|
FlexEnd = 4,
|
|
543
|
+
/**
|
|
544
|
+
* Item centered along the cross axis
|
|
545
|
+
*/
|
|
64
546
|
Center = 5,
|
|
547
|
+
/**
|
|
548
|
+
* Item aligned to its text baseline
|
|
549
|
+
*/
|
|
65
550
|
Baseline = 6,
|
|
551
|
+
/**
|
|
552
|
+
* Item stretched to fill the container
|
|
553
|
+
*/
|
|
66
554
|
Stretch = 7,
|
|
67
555
|
}
|
|
68
556
|
|
|
69
557
|
/**
|
|
70
|
-
* Box sizing
|
|
71
|
-
*
|
|
558
|
+
* Box sizing enumeration
|
|
559
|
+
*
|
|
72
560
|
* Controls how the total width and height of an element is calculated.
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
561
|
+
* This corresponds to the CSS `box-sizing` property.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```typescript
|
|
565
|
+
* import { BoxSizing } from 'taffy-js';
|
|
566
|
+
*
|
|
567
|
+
* style.boxSizing = BoxSizing.BorderBox; // Size includes padding and border
|
|
568
|
+
* style.boxSizing = BoxSizing.ContentBox; // Size is content only
|
|
569
|
+
* ```
|
|
77
570
|
*/
|
|
78
571
|
export enum BoxSizing {
|
|
572
|
+
/**
|
|
573
|
+
* The width and height properties include padding and border
|
|
574
|
+
*/
|
|
79
575
|
BorderBox = 0,
|
|
576
|
+
/**
|
|
577
|
+
* The width and height properties include only the content
|
|
578
|
+
*/
|
|
80
579
|
ContentBox = 1,
|
|
81
580
|
}
|
|
82
581
|
|
|
83
582
|
/**
|
|
84
|
-
* Display mode
|
|
85
|
-
*
|
|
86
|
-
* Controls the layout algorithm type for an element.
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
583
|
+
* Display mode enumeration
|
|
584
|
+
*
|
|
585
|
+
* Controls the layout algorithm type for an element. This corresponds to the CSS `display` property
|
|
586
|
+
* and determines how an element and its children are laid out.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```typescript
|
|
590
|
+
* import { Display } from 'taffy-js';
|
|
591
|
+
*
|
|
592
|
+
* style.display = Display.Flex; // Enable flexbox layout
|
|
593
|
+
* style.display = Display.Grid; // Enable grid layout
|
|
594
|
+
* style.display = Display.None; // Hide element from layout
|
|
595
|
+
* ```
|
|
93
596
|
*/
|
|
94
597
|
export enum Display {
|
|
598
|
+
/**
|
|
599
|
+
* Block-level layout where element takes the full available width
|
|
600
|
+
*/
|
|
95
601
|
Block = 0,
|
|
602
|
+
/**
|
|
603
|
+
* Flexbox layout for one-dimensional item arrangement
|
|
604
|
+
*/
|
|
96
605
|
Flex = 1,
|
|
606
|
+
/**
|
|
607
|
+
* CSS Grid layout for two-dimensional item arrangement
|
|
608
|
+
*/
|
|
97
609
|
Grid = 2,
|
|
610
|
+
/**
|
|
611
|
+
* Element is removed from layout calculation entirely
|
|
612
|
+
*/
|
|
98
613
|
None = 3,
|
|
99
614
|
}
|
|
100
615
|
|
|
101
616
|
/**
|
|
102
|
-
* Flex
|
|
103
|
-
*
|
|
104
|
-
* Defines the
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
617
|
+
* Flex direction enumeration
|
|
618
|
+
*
|
|
619
|
+
* Defines the main axis direction for flex item layout. This corresponds to the CSS
|
|
620
|
+
* `flex-direction` property and determines how flex items are placed within the container.
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* ```typescript
|
|
624
|
+
* import { FlexDirection } from 'taffy-js';
|
|
625
|
+
*
|
|
626
|
+
* style.flexDirection = FlexDirection.Row; // Horizontal, left to right
|
|
627
|
+
* style.flexDirection = FlexDirection.Column; // Vertical, top to bottom
|
|
628
|
+
* ```
|
|
111
629
|
*/
|
|
112
630
|
export enum FlexDirection {
|
|
631
|
+
/**
|
|
632
|
+
* Main axis runs horizontally from left to right
|
|
633
|
+
*/
|
|
113
634
|
Row = 0,
|
|
635
|
+
/**
|
|
636
|
+
* Main axis runs vertically from top to bottom
|
|
637
|
+
*/
|
|
114
638
|
Column = 1,
|
|
639
|
+
/**
|
|
640
|
+
* Main axis runs horizontally from right to left
|
|
641
|
+
*/
|
|
115
642
|
RowReverse = 2,
|
|
643
|
+
/**
|
|
644
|
+
* Main axis runs vertically from bottom to top
|
|
645
|
+
*/
|
|
116
646
|
ColumnReverse = 3,
|
|
117
647
|
}
|
|
118
648
|
|
|
119
649
|
/**
|
|
120
|
-
* Flex wrap mode
|
|
121
|
-
*
|
|
122
|
-
* Controls whether flex items wrap onto multiple lines
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
650
|
+
* Flex wrap mode enumeration
|
|
651
|
+
*
|
|
652
|
+
* Controls whether flex items wrap onto multiple lines when they overflow the container.
|
|
653
|
+
* This corresponds to the CSS `flex-wrap` property.
|
|
654
|
+
*
|
|
655
|
+
* @example
|
|
656
|
+
* ```typescript
|
|
657
|
+
* import { FlexWrap } from 'taffy-js';
|
|
658
|
+
*
|
|
659
|
+
* style.flexWrap = FlexWrap.NoWrap; // All items on single line
|
|
660
|
+
* style.flexWrap = FlexWrap.Wrap; // Items wrap to new lines
|
|
661
|
+
* ```
|
|
128
662
|
*/
|
|
129
663
|
export enum FlexWrap {
|
|
664
|
+
/**
|
|
665
|
+
* All flex items are placed on a single line
|
|
666
|
+
*/
|
|
130
667
|
NoWrap = 0,
|
|
668
|
+
/**
|
|
669
|
+
* Flex items wrap onto multiple lines from top to bottom
|
|
670
|
+
*/
|
|
131
671
|
Wrap = 1,
|
|
672
|
+
/**
|
|
673
|
+
* Flex items wrap onto multiple lines from bottom to top
|
|
674
|
+
*/
|
|
132
675
|
WrapReverse = 2,
|
|
133
676
|
}
|
|
134
677
|
|
|
135
678
|
/**
|
|
136
|
-
* Main axis alignment
|
|
137
|
-
*
|
|
138
|
-
* Defines
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
679
|
+
* Main axis alignment enumeration
|
|
680
|
+
*
|
|
681
|
+
* Defines how flex items are aligned and spaced along the main axis.
|
|
682
|
+
* This corresponds to the CSS `justify-content` property.
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* ```typescript
|
|
686
|
+
* import { JustifyContent } from 'taffy-js';
|
|
687
|
+
*
|
|
688
|
+
* style.justifyContent = JustifyContent.Center; // Center items
|
|
689
|
+
* style.justifyContent = JustifyContent.SpaceBetween; // Distribute evenly
|
|
690
|
+
* ```
|
|
148
691
|
*/
|
|
149
692
|
export enum JustifyContent {
|
|
693
|
+
/**
|
|
694
|
+
* Items packed toward the start of the main axis
|
|
695
|
+
*/
|
|
150
696
|
Start = 0,
|
|
697
|
+
/**
|
|
698
|
+
* Items packed toward the end of the main axis
|
|
699
|
+
*/
|
|
151
700
|
End = 1,
|
|
701
|
+
/**
|
|
702
|
+
* Items packed toward the start of the flex container
|
|
703
|
+
*/
|
|
152
704
|
FlexStart = 2,
|
|
705
|
+
/**
|
|
706
|
+
* Items packed toward the end of the flex container
|
|
707
|
+
*/
|
|
153
708
|
FlexEnd = 3,
|
|
709
|
+
/**
|
|
710
|
+
* Items centered along the main axis
|
|
711
|
+
*/
|
|
154
712
|
Center = 4,
|
|
713
|
+
/**
|
|
714
|
+
* Items stretched along the main axis
|
|
715
|
+
*/
|
|
155
716
|
Stretch = 5,
|
|
717
|
+
/**
|
|
718
|
+
* Items evenly distributed with first/last at edges
|
|
719
|
+
*/
|
|
156
720
|
SpaceBetween = 6,
|
|
721
|
+
/**
|
|
722
|
+
* Items evenly distributed with equal space around each
|
|
723
|
+
*/
|
|
157
724
|
SpaceAround = 7,
|
|
725
|
+
/**
|
|
726
|
+
* Items evenly distributed with equal space between each
|
|
727
|
+
*/
|
|
158
728
|
SpaceEvenly = 8,
|
|
159
729
|
}
|
|
160
730
|
|
|
731
|
+
/**
|
|
732
|
+
* Computed layout result containing position, size, and spacing values for a node.
|
|
733
|
+
*
|
|
734
|
+
* This class wraps the native [`taffy::Layout`] and provides read-only access
|
|
735
|
+
* to all computed layout values. All dimensions are in pixels.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```typescript
|
|
739
|
+
* const layout = tree.getLayout(node);
|
|
740
|
+
*
|
|
741
|
+
* console.log("Position:", layout.x, layout.y);
|
|
742
|
+
* console.log("Size:", layout.width, layout.height);
|
|
743
|
+
* console.log("Content:", layout.contentWidth, layout.contentHeight);
|
|
744
|
+
* console.log("Padding:", layout.paddingTop, layout.paddingRight, layout.paddingBottom, layout.paddingLeft);
|
|
745
|
+
* console.log("Border:", layout.borderTop, layout.borderRight, layout.borderBottom, layout.borderLeft);
|
|
746
|
+
* console.log("Margin:", layout.marginTop, layout.marginRight, layout.marginBottom, layout.marginLeft);
|
|
747
|
+
* console.log("Scrollbar:", layout.scrollbarWidth, layout.scrollbarHeight);
|
|
748
|
+
* console.log("Order:", layout.order);
|
|
749
|
+
* ```
|
|
750
|
+
*/
|
|
161
751
|
export class Layout {
|
|
162
752
|
private constructor();
|
|
163
753
|
free(): void;
|
|
164
754
|
[Symbol.dispose](): void;
|
|
165
755
|
/**
|
|
166
|
-
* Gets the top border width
|
|
756
|
+
* Gets the top border width
|
|
757
|
+
*
|
|
758
|
+
* @returns - The computed top border width in pixels
|
|
167
759
|
*/
|
|
168
760
|
readonly borderTop: number;
|
|
169
761
|
/**
|
|
170
|
-
* Gets the top margin
|
|
762
|
+
* Gets the top margin
|
|
763
|
+
*
|
|
764
|
+
* @returns - The computed top margin in pixels
|
|
171
765
|
*/
|
|
172
766
|
readonly marginTop: number;
|
|
173
767
|
/**
|
|
174
|
-
* Gets the left border width
|
|
768
|
+
* Gets the left border width
|
|
769
|
+
*
|
|
770
|
+
* @returns - The computed left border width in pixels
|
|
175
771
|
*/
|
|
176
772
|
readonly borderLeft: number;
|
|
177
773
|
/**
|
|
178
|
-
* Gets the left margin
|
|
774
|
+
* Gets the left margin
|
|
775
|
+
*
|
|
776
|
+
* @returns - The computed left margin in pixels
|
|
179
777
|
*/
|
|
180
778
|
readonly marginLeft: number;
|
|
181
779
|
/**
|
|
182
|
-
* Gets the top padding
|
|
780
|
+
* Gets the top padding
|
|
781
|
+
*
|
|
782
|
+
* @returns - The computed top padding in pixels
|
|
183
783
|
*/
|
|
184
784
|
readonly paddingTop: number;
|
|
185
785
|
/**
|
|
186
|
-
* Gets the right border width
|
|
786
|
+
* Gets the right border width
|
|
787
|
+
*
|
|
788
|
+
* @returns - The computed right border width in pixels
|
|
187
789
|
*/
|
|
188
790
|
readonly borderRight: number;
|
|
189
791
|
/**
|
|
190
|
-
* Gets the right margin
|
|
792
|
+
* Gets the right margin
|
|
793
|
+
*
|
|
794
|
+
* @returns - The computed right margin in pixels
|
|
191
795
|
*/
|
|
192
796
|
readonly marginRight: number;
|
|
193
797
|
/**
|
|
194
|
-
* Gets the left padding
|
|
798
|
+
* Gets the left padding
|
|
799
|
+
*
|
|
800
|
+
* @returns - The computed left padding in pixels
|
|
195
801
|
*/
|
|
196
802
|
readonly paddingLeft: number;
|
|
197
803
|
/**
|
|
198
|
-
* Gets the bottom border width
|
|
804
|
+
* Gets the bottom border width
|
|
805
|
+
*
|
|
806
|
+
* @returns - The computed bottom border width in pixels
|
|
199
807
|
*/
|
|
200
808
|
readonly borderBottom: number;
|
|
201
809
|
/**
|
|
202
|
-
* Gets the width of the scrollable content
|
|
810
|
+
* Gets the width of the scrollable content
|
|
811
|
+
*
|
|
812
|
+
* If the node has overflow content, this represents the total
|
|
813
|
+
* width of all content (may exceed `width`).
|
|
814
|
+
*
|
|
815
|
+
* @returns - The content width in pixels
|
|
203
816
|
*/
|
|
204
817
|
readonly contentWidth: number;
|
|
205
818
|
/**
|
|
206
|
-
* Gets the bottom margin
|
|
819
|
+
* Gets the bottom margin
|
|
820
|
+
*
|
|
821
|
+
* @returns - The computed bottom margin in pixels
|
|
207
822
|
*/
|
|
208
823
|
readonly marginBottom: number;
|
|
209
824
|
/**
|
|
210
|
-
* Gets the right padding
|
|
825
|
+
* Gets the right padding
|
|
826
|
+
*
|
|
827
|
+
* @returns - The computed right padding in pixels
|
|
211
828
|
*/
|
|
212
829
|
readonly paddingRight: number;
|
|
213
830
|
/**
|
|
214
|
-
* Gets the height of the scrollable content
|
|
831
|
+
* Gets the height of the scrollable content
|
|
832
|
+
*
|
|
833
|
+
* If the node has overflow content, this represents the total
|
|
834
|
+
* height of all content (may exceed `height`).
|
|
835
|
+
*
|
|
836
|
+
* @returns - The content height in pixels
|
|
215
837
|
*/
|
|
216
838
|
readonly contentHeight: number;
|
|
217
839
|
/**
|
|
218
|
-
* Gets the bottom padding
|
|
840
|
+
* Gets the bottom padding
|
|
841
|
+
*
|
|
842
|
+
* @returns - The computed bottom padding in pixels
|
|
219
843
|
*/
|
|
220
844
|
readonly paddingBottom: number;
|
|
221
845
|
/**
|
|
222
|
-
* Gets the width of the vertical scrollbar
|
|
846
|
+
* Gets the width of the vertical scrollbar
|
|
847
|
+
*
|
|
848
|
+
* When overflow is set to scroll, this indicates the space
|
|
849
|
+
* reserved for the vertical scrollbar.
|
|
850
|
+
*
|
|
851
|
+
* @returns - The scrollbar width in pixels (0 if no scrollbar)
|
|
223
852
|
*/
|
|
224
853
|
readonly scrollbarWidth: number;
|
|
225
854
|
/**
|
|
226
|
-
* Gets the height of the horizontal scrollbar
|
|
855
|
+
* Gets the height of the horizontal scrollbar
|
|
856
|
+
*
|
|
857
|
+
* When overflow is set to scroll, this indicates the space
|
|
858
|
+
* reserved for the horizontal scrollbar.
|
|
859
|
+
*
|
|
860
|
+
* @returns - The scrollbar height in pixels (0 if no scrollbar)
|
|
227
861
|
*/
|
|
228
862
|
readonly scrollbarHeight: number;
|
|
229
863
|
/**
|
|
230
|
-
* Gets the
|
|
864
|
+
* Gets the X coordinate of the node's top-left corner
|
|
865
|
+
*
|
|
866
|
+
* This value is relative to the node's parent. For the root node,
|
|
867
|
+
* this is always 0.
|
|
868
|
+
*
|
|
869
|
+
* @returns - The horizontal position in pixels
|
|
231
870
|
*/
|
|
232
871
|
readonly x: number;
|
|
233
872
|
/**
|
|
234
|
-
* Gets the
|
|
873
|
+
* Gets the Y coordinate of the node's top-left corner
|
|
874
|
+
*
|
|
875
|
+
* This value is relative to the node's parent. For the root node,
|
|
876
|
+
* this is always 0.
|
|
877
|
+
*
|
|
878
|
+
* @returns - The vertical position in pixels
|
|
235
879
|
*/
|
|
236
880
|
readonly y: number;
|
|
237
881
|
/**
|
|
238
|
-
* Gets the rendering order of the node
|
|
882
|
+
* Gets the rendering order of the node
|
|
883
|
+
*
|
|
884
|
+
* This value determines the z-order for overlapping elements.
|
|
885
|
+
* Lower values are rendered first (behind higher values).
|
|
886
|
+
*
|
|
887
|
+
* @returns - The rendering order as an unsigned 32-bit integer
|
|
239
888
|
*/
|
|
240
889
|
readonly order: number;
|
|
241
890
|
/**
|
|
242
|
-
* Gets the computed width of the node
|
|
891
|
+
* Gets the computed width of the node
|
|
892
|
+
*
|
|
893
|
+
* This is the final width after layout computation, including
|
|
894
|
+
* any constraints from min/max size or flex properties.
|
|
895
|
+
*
|
|
896
|
+
* @returns - The width in pixels
|
|
243
897
|
*/
|
|
244
898
|
readonly width: number;
|
|
245
899
|
/**
|
|
246
|
-
* Gets the computed height of the node
|
|
900
|
+
* Gets the computed height of the node
|
|
901
|
+
*
|
|
902
|
+
* This is the final height after layout computation, including
|
|
903
|
+
* any constraints from min/max size or flex properties.
|
|
904
|
+
*
|
|
905
|
+
* @returns - The height in pixels
|
|
247
906
|
*/
|
|
248
907
|
readonly height: number;
|
|
249
908
|
}
|
|
250
909
|
|
|
251
910
|
/**
|
|
252
|
-
* Overflow handling
|
|
253
|
-
*
|
|
254
|
-
* Defines how content that
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
911
|
+
* Overflow handling enumeration
|
|
912
|
+
*
|
|
913
|
+
* Defines how content that exceeds the container boundaries is handled.
|
|
914
|
+
* This corresponds to the CSS `overflow` property.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* ```typescript
|
|
918
|
+
* import { Overflow } from 'taffy-js';
|
|
919
|
+
*
|
|
920
|
+
* style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
|
|
921
|
+
* ```
|
|
262
922
|
*/
|
|
263
923
|
export enum Overflow {
|
|
924
|
+
/**
|
|
925
|
+
* Content is not clipped and may render outside the container
|
|
926
|
+
*/
|
|
264
927
|
Visible = 0,
|
|
928
|
+
/**
|
|
929
|
+
* Content is clipped at the container boundary
|
|
930
|
+
*/
|
|
265
931
|
Hidden = 1,
|
|
932
|
+
/**
|
|
933
|
+
* Always display scrollbars for scrollable content
|
|
934
|
+
*/
|
|
266
935
|
Scroll = 2,
|
|
936
|
+
/**
|
|
937
|
+
* Display scrollbars only when content overflows (internally maps to Scroll)
|
|
938
|
+
*/
|
|
267
939
|
Auto = 3,
|
|
268
940
|
}
|
|
269
941
|
|
|
270
942
|
/**
|
|
271
|
-
* Position mode
|
|
272
|
-
*
|
|
273
|
-
* Controls element
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
943
|
+
* Position mode enumeration
|
|
944
|
+
*
|
|
945
|
+
* Controls how an element is positioned within its parent container.
|
|
946
|
+
* This corresponds to the CSS `position` property.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```typescript
|
|
950
|
+
* import { Position } from 'taffy-js';
|
|
951
|
+
*
|
|
952
|
+
* style.position = Position.Relative; // Normal document flow
|
|
953
|
+
* style.position = Position.Absolute; // Removed from flow, uses inset values
|
|
954
|
+
* ```
|
|
278
955
|
*/
|
|
279
956
|
export enum Position {
|
|
957
|
+
/**
|
|
958
|
+
* Element participates in normal document flow
|
|
959
|
+
*/
|
|
280
960
|
Relative = 0,
|
|
961
|
+
/**
|
|
962
|
+
* Element is positioned relative to its nearest positioned ancestor
|
|
963
|
+
*/
|
|
281
964
|
Absolute = 1,
|
|
282
965
|
}
|
|
283
966
|
|
|
967
|
+
/**
|
|
968
|
+
* CSS layout configuration for a node, including flexbox, sizing, spacing, and alignment properties.
|
|
969
|
+
*
|
|
970
|
+
* This class holds all CSS layout properties for a node. Create an instance with
|
|
971
|
+
* `new Style()` and configure properties before passing to `TaffyTree.newLeaf()`.
|
|
972
|
+
*
|
|
973
|
+
* @defaultValue
|
|
974
|
+
* When created, all properties are set to their CSS default values:
|
|
975
|
+
* - `display`: `Display.Block`
|
|
976
|
+
* - `position`: `Position.Relative`
|
|
977
|
+
* - `flexDirection`: `FlexDirection.Row`
|
|
978
|
+
* - `flexWrap`: `FlexWrap.NoWrap`
|
|
979
|
+
* - `flexGrow`: `0`
|
|
980
|
+
* - `flexShrink`: `1`
|
|
981
|
+
* - All alignment properties: `undefined` (use default behavior)
|
|
982
|
+
* - All dimensions: `"Auto"`
|
|
983
|
+
* - All spacing: `{ Length: 0 }`
|
|
984
|
+
*
|
|
985
|
+
*/
|
|
284
986
|
export class Style {
|
|
285
987
|
free(): void;
|
|
286
988
|
[Symbol.dispose](): void;
|
|
287
989
|
/**
|
|
288
|
-
* Creates a new Style instance with default values
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
* - All dimensions: Auto
|
|
295
|
-
* - All spacing (margin, padding, border): 0
|
|
296
|
-
*
|
|
297
|
-
* # Returns
|
|
298
|
-
* A new Style instance with default configuration.
|
|
299
|
-
*
|
|
300
|
-
* # Example
|
|
301
|
-
* ```javascript
|
|
990
|
+
* Creates a new Style instance with default values
|
|
991
|
+
*
|
|
992
|
+
* @returns - A new `Style` object with all properties set to CSS defaults
|
|
993
|
+
*
|
|
994
|
+
* @example
|
|
995
|
+
* ```typescript
|
|
302
996
|
* const style = new Style();
|
|
303
|
-
* style.display
|
|
997
|
+
* console.log(style.display); // Display.Block
|
|
304
998
|
* ```
|
|
305
999
|
*/
|
|
306
1000
|
constructor();
|
|
307
1001
|
/**
|
|
308
|
-
* Gets the align-self property
|
|
309
|
-
*
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
*
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*/
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Gets the
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
*
|
|
339
|
-
*/
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
*
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
*
|
|
347
|
-
*/
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Gets the
|
|
1002
|
+
* Gets the align-self property
|
|
1003
|
+
*
|
|
1004
|
+
* Overrides the parent's align-items for this specific element.
|
|
1005
|
+
*
|
|
1006
|
+
* @returns - The current [`AlignSelf`](JsAlignSelf) value (returns `Auto` if not set)
|
|
1007
|
+
*/
|
|
1008
|
+
alignSelf: AlignSelf | undefined;
|
|
1009
|
+
/**
|
|
1010
|
+
* Gets the box sizing mode
|
|
1011
|
+
*
|
|
1012
|
+
* Determines whether padding and border are included in dimensions.
|
|
1013
|
+
*
|
|
1014
|
+
* @returns - The current [`BoxSizing`](JsBoxSizing) value
|
|
1015
|
+
*
|
|
1016
|
+
* @defaultValue `BoxSizing.BorderBox`
|
|
1017
|
+
*/
|
|
1018
|
+
boxSizing: BoxSizing;
|
|
1019
|
+
/**
|
|
1020
|
+
* Gets the flex-basis
|
|
1021
|
+
*
|
|
1022
|
+
* The initial size of a flex item before growing/shrinking.
|
|
1023
|
+
*
|
|
1024
|
+
* @returns - A `Dimension` value (`{ Length: n }`, `{ Percent: n }`, or `"Auto"`)
|
|
1025
|
+
*/
|
|
1026
|
+
flexBasis: Dimension;
|
|
1027
|
+
/**
|
|
1028
|
+
* Gets the border width
|
|
1029
|
+
*
|
|
1030
|
+
* Width of the element's border on each side.
|
|
1031
|
+
*
|
|
1032
|
+
* @returns - A `Rect<LengthPercentage>` with left, right, top, bottom border widths
|
|
1033
|
+
*/
|
|
1034
|
+
border: Rect<LengthPercentage>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Gets the margin
|
|
1037
|
+
*
|
|
1038
|
+
* Outer spacing around the element.
|
|
1039
|
+
*
|
|
1040
|
+
* @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom margins
|
|
1041
|
+
*/
|
|
1042
|
+
margin: Rect<LengthPercentageAuto>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Gets the align-items property
|
|
1045
|
+
*
|
|
1046
|
+
* Defines the default alignment for all children on the cross axis.
|
|
1047
|
+
*
|
|
1048
|
+
* @returns - The current [`AlignItems`](JsAlignItems) value, or `undefined` if not set
|
|
1049
|
+
*/
|
|
1050
|
+
alignItems: AlignItems | undefined;
|
|
1051
|
+
/**
|
|
1052
|
+
* Gets the flex shrink factor
|
|
1053
|
+
*
|
|
1054
|
+
* Determines how much the item shrinks relative to siblings when
|
|
1055
|
+
* there is insufficient space.
|
|
1056
|
+
*
|
|
1057
|
+
* @returns - The flex shrink factor (default: 1)
|
|
1058
|
+
*/
|
|
1059
|
+
flexShrink: number;
|
|
1060
|
+
/**
|
|
1061
|
+
* Gets the display mode
|
|
1062
|
+
*
|
|
1063
|
+
* Determines the layout algorithm used for this element and its children.
|
|
1064
|
+
*
|
|
1065
|
+
* @returns - The current [`Display`](JsDisplay) value
|
|
1066
|
+
*
|
|
1067
|
+
* @defaultValue - `Display.Block`
|
|
351
1068
|
*/
|
|
352
1069
|
display: Display;
|
|
353
1070
|
/**
|
|
354
|
-
* Gets the padding
|
|
355
|
-
*
|
|
356
|
-
*
|
|
1071
|
+
* Gets the padding
|
|
1072
|
+
*
|
|
1073
|
+
* Inner spacing between the element's border and content.
|
|
1074
|
+
*
|
|
1075
|
+
* @returns - A `Rect<LengthPercentage>` with left, right, top, bottom padding
|
|
357
1076
|
*/
|
|
358
|
-
padding:
|
|
1077
|
+
padding: Rect<LengthPercentage>;
|
|
359
1078
|
/**
|
|
360
|
-
* Gets the aspect ratio
|
|
1079
|
+
* Gets the aspect ratio
|
|
1080
|
+
*
|
|
1081
|
+
* The ratio of width to height. Used to maintain proportions.
|
|
1082
|
+
*
|
|
1083
|
+
* @returns - The aspect ratio value, or `undefined` if not set
|
|
361
1084
|
*/
|
|
362
|
-
|
|
1085
|
+
aspectRatio: number | undefined;
|
|
363
1086
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
1087
|
+
* Gets the maximum size constraints
|
|
1088
|
+
*
|
|
1089
|
+
* @returns - A `Size<Dimension>` object with maximum width and height
|
|
366
1090
|
*/
|
|
367
|
-
|
|
1091
|
+
maxSize: Size<Dimension>;
|
|
368
1092
|
/**
|
|
369
|
-
* Gets the
|
|
370
|
-
*
|
|
1093
|
+
* Gets the minimum size constraints
|
|
1094
|
+
*
|
|
1095
|
+
* @returns - A `Size<Dimension>` object with minimum width and height
|
|
371
1096
|
*/
|
|
372
|
-
|
|
1097
|
+
minSize: Size<Dimension>;
|
|
373
1098
|
/**
|
|
374
|
-
* Gets the
|
|
375
|
-
*
|
|
1099
|
+
* Gets the overflow behavior
|
|
1100
|
+
*
|
|
1101
|
+
* Controls how content that exceeds the container is handled.
|
|
1102
|
+
*
|
|
1103
|
+
* @returns - A `Point<Overflow>` with `x` and `y` overflow settings
|
|
376
1104
|
*/
|
|
377
|
-
|
|
1105
|
+
overflow: Point<Overflow>;
|
|
378
1106
|
/**
|
|
379
|
-
* Gets the
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
*
|
|
1107
|
+
* Gets the position mode
|
|
1108
|
+
*
|
|
1109
|
+
* Determines how the element is positioned within its parent.
|
|
1110
|
+
*
|
|
1111
|
+
* @returns - The current [`Position`](JsPosition) value
|
|
1112
|
+
*
|
|
1113
|
+
* @defaultValue - `Position.Relative`
|
|
384
1114
|
*/
|
|
385
1115
|
position: Position;
|
|
386
1116
|
/**
|
|
387
|
-
* Gets the align-content property
|
|
1117
|
+
* Gets the align-content property
|
|
1118
|
+
*
|
|
1119
|
+
* Controls distribution of space between lines in a multi-line flex container.
|
|
1120
|
+
*
|
|
1121
|
+
* @returns - The current [`AlignContent`](JsAlignContent) value, or `undefined` if not set
|
|
388
1122
|
*/
|
|
389
|
-
|
|
1123
|
+
alignContent: AlignContent | undefined;
|
|
390
1124
|
/**
|
|
391
|
-
*
|
|
1125
|
+
* Gets the flex grow factor
|
|
1126
|
+
*
|
|
1127
|
+
* Determines how much the item grows relative to siblings when
|
|
1128
|
+
* there is extra space available.
|
|
1129
|
+
*
|
|
1130
|
+
* @returns - The flex grow factor (default: 0)
|
|
392
1131
|
*/
|
|
393
|
-
|
|
1132
|
+
flexGrow: number;
|
|
394
1133
|
/**
|
|
395
|
-
* Gets the flex
|
|
1134
|
+
* Gets the flex wrap mode
|
|
1135
|
+
*
|
|
1136
|
+
* Controls whether flex items wrap to new lines.
|
|
1137
|
+
*
|
|
1138
|
+
* @returns - The current [`FlexWrap`](JsFlexWrap) value
|
|
1139
|
+
*
|
|
1140
|
+
* @defaultValue - `FlexWrap.NoWrap`
|
|
396
1141
|
*/
|
|
397
|
-
|
|
1142
|
+
flexWrap: FlexWrap;
|
|
398
1143
|
/**
|
|
399
|
-
* Gets the flex
|
|
1144
|
+
* Gets the flex direction
|
|
1145
|
+
*
|
|
1146
|
+
* Defines the main axis direction for flex items.
|
|
1147
|
+
*
|
|
1148
|
+
* @returns - The current [`FlexDirection`](JsFlexDirection) value
|
|
1149
|
+
*
|
|
1150
|
+
* @defaultValue - `FlexDirection.Row`
|
|
400
1151
|
*/
|
|
401
|
-
|
|
1152
|
+
flexDirection: FlexDirection;
|
|
402
1153
|
/**
|
|
403
|
-
* Gets the
|
|
1154
|
+
* Gets the justify-content property
|
|
1155
|
+
*
|
|
1156
|
+
* Defines alignment and spacing of items along the main axis.
|
|
1157
|
+
*
|
|
1158
|
+
* @returns - The current [`JustifyContent`](JsJustifyContent) value, or `undefined` if not set
|
|
404
1159
|
*/
|
|
405
|
-
|
|
1160
|
+
justifyContent: JustifyContent | undefined;
|
|
406
1161
|
/**
|
|
407
|
-
* Gets the
|
|
1162
|
+
* Gets the gap
|
|
1163
|
+
*
|
|
1164
|
+
* Spacing between flex/grid items.
|
|
1165
|
+
*
|
|
1166
|
+
* @returns - A `Size<LengthPercentage>` with column (width) and row (height) gaps
|
|
408
1167
|
*/
|
|
409
|
-
|
|
1168
|
+
gap: Size<LengthPercentage>;
|
|
410
1169
|
/**
|
|
411
|
-
*
|
|
1170
|
+
* Gets the size (width and height)
|
|
1171
|
+
*
|
|
1172
|
+
* @returns - A `Size<Dimension>` object with `width` and `height` properties
|
|
412
1173
|
*/
|
|
413
|
-
|
|
1174
|
+
size: Size<Dimension>;
|
|
414
1175
|
/**
|
|
415
|
-
* Gets the
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
1176
|
+
* Gets the inset
|
|
1177
|
+
*
|
|
1178
|
+
* Positioning offsets for absolutely positioned elements.
|
|
1179
|
+
*
|
|
1180
|
+
* @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom offsets
|
|
419
1181
|
*/
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
1182
|
+
inset: Rect<LengthPercentageAuto>;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* Error class thrown when a Taffy operation fails, containing a human-readable error message.
|
|
1187
|
+
*
|
|
1188
|
+
* This class wraps the native [`taffy::TaffyError`] type and exposes it to JavaScript
|
|
1189
|
+
* with a readable error message. It is thrown as a JavaScript exception on failure.
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```typescript
|
|
1193
|
+
* try {
|
|
1194
|
+
* tree.remove(node);
|
|
1195
|
+
* } catch (e) {
|
|
1196
|
+
* if (e instanceof TaffyError) {
|
|
1197
|
+
* console.error(e.message);
|
|
1198
|
+
* }
|
|
1199
|
+
* }
|
|
1200
|
+
* ```
|
|
1201
|
+
*
|
|
1202
|
+
* @remarks
|
|
1203
|
+
* The underlying Taffy errors include:
|
|
1204
|
+
* - `InvalidInputNode`: Node ID doesn't exist in the tree
|
|
1205
|
+
* - `InvalidParentNode`: Specified parent node doesn't exist
|
|
1206
|
+
* - `ChildIndexOutOfBounds`: Child index exceeds available children
|
|
1207
|
+
*/
|
|
1208
|
+
export class TaffyError {
|
|
1209
|
+
private constructor();
|
|
1210
|
+
free(): void;
|
|
1211
|
+
[Symbol.dispose](): void;
|
|
426
1212
|
/**
|
|
427
|
-
* Gets the
|
|
428
|
-
*
|
|
429
|
-
*
|
|
1213
|
+
* Gets the human-readable error message
|
|
1214
|
+
*
|
|
1215
|
+
* @returns - A string describing what went wrong.
|
|
1216
|
+
*
|
|
1217
|
+
* @remarks
|
|
1218
|
+
* Examples:
|
|
1219
|
+
* - "Node with id 1234 is not present in the Taffy tree"
|
|
1220
|
+
* - "Index 5 is out of bounds for node with 3 children"
|
|
430
1221
|
*/
|
|
431
|
-
|
|
1222
|
+
readonly message: string;
|
|
432
1223
|
}
|
|
433
1224
|
|
|
1225
|
+
/**
|
|
1226
|
+
* The main layout tree class for creating nodes, computing layouts, and managing a tree of styled elements.
|
|
1227
|
+
*
|
|
1228
|
+
* TaffyTree is the entry point for the Taffy layout engine. It manages
|
|
1229
|
+
* a tree of nodes and computes their layouts using CSS Flexbox and Grid algorithms.
|
|
1230
|
+
*
|
|
1231
|
+
*/
|
|
434
1232
|
export class TaffyTree {
|
|
435
1233
|
free(): void;
|
|
436
1234
|
[Symbol.dispose](): void;
|
|
437
1235
|
/**
|
|
438
|
-
* Marks a node as dirty
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
1236
|
+
* Marks a node as dirty (requiring re-layout)
|
|
1237
|
+
*
|
|
1238
|
+
* Use this when a node's content has changed but its style hasn't.
|
|
1239
|
+
* For example, when text content changes and needs remeasuring.
|
|
1240
|
+
*
|
|
1241
|
+
* @param node - The node ID to mark dirty
|
|
1242
|
+
*
|
|
1243
|
+
* @throws `TaffyError` if the node does not exist
|
|
1244
|
+
*
|
|
1245
|
+
* @example
|
|
1246
|
+
* ```typescript
|
|
1247
|
+
* // After updating text content
|
|
1248
|
+
* tree.setNodeContext(nodeId, { text: "Updated text" });
|
|
1249
|
+
* tree.markDirty(nodeId);
|
|
1250
|
+
* tree.computeLayout(rootId, availableSpace);
|
|
1251
|
+
* ```
|
|
445
1252
|
*/
|
|
446
1253
|
markDirty(node: bigint): void;
|
|
447
1254
|
/**
|
|
448
|
-
* Prints the tree structure to the console (for debugging)
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
1255
|
+
* Prints the tree structure to the console (for debugging)
|
|
1256
|
+
*
|
|
1257
|
+
* Outputs a text representation of the tree structure starting from
|
|
1258
|
+
* the given node. Useful for debugging layout issues.
|
|
1259
|
+
*
|
|
1260
|
+
* @param node - The root node ID to print from
|
|
1261
|
+
*
|
|
1262
|
+
* @example
|
|
1263
|
+
* ```typescript
|
|
1264
|
+
* tree.printTree(rootId);
|
|
1265
|
+
* // Output appears in browser console
|
|
1266
|
+
* ```
|
|
452
1267
|
*/
|
|
453
1268
|
printTree(node: bigint): void;
|
|
454
1269
|
/**
|
|
455
|
-
* Gets the number of children of a node
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
1270
|
+
* Gets the number of children of a node
|
|
1271
|
+
*
|
|
1272
|
+
* @param parent - The parent node ID
|
|
1273
|
+
*
|
|
1274
|
+
* @returns - The number of direct children
|
|
1275
|
+
*
|
|
1276
|
+
* @throws `TaffyError` if the node does not exist
|
|
1277
|
+
*
|
|
1278
|
+
* @example
|
|
1279
|
+
* ```typescript
|
|
1280
|
+
* const count: number = tree.childCount(parentId);
|
|
1281
|
+
* ```
|
|
462
1282
|
*/
|
|
463
1283
|
childCount(parent: bigint): number;
|
|
464
1284
|
/**
|
|
465
|
-
* Removes a specific child from a parent
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
1285
|
+
* Removes a specific child from a parent
|
|
1286
|
+
*
|
|
1287
|
+
* @param parent - The parent node ID
|
|
1288
|
+
* @param child - The child node ID to remove
|
|
1289
|
+
*
|
|
1290
|
+
* @returns - The removed child ID (`bigint`)
|
|
1291
|
+
*
|
|
1292
|
+
* @throws `TaffyError` if the parent or child node does not exist
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
* ```typescript
|
|
1296
|
+
* tree.removeChild(parentId, childId);
|
|
1297
|
+
* ```
|
|
474
1298
|
*/
|
|
475
1299
|
removeChild(parent: bigint, child: bigint): bigint;
|
|
476
1300
|
/**
|
|
477
|
-
* Replaces all children of a node
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
1301
|
+
* Replaces all children of a node
|
|
1302
|
+
*
|
|
1303
|
+
* Any existing children are removed and replaced with the new array.
|
|
1304
|
+
*
|
|
1305
|
+
* @param parent - The parent node ID
|
|
1306
|
+
* @param children - Array of new child node IDs
|
|
1307
|
+
*
|
|
1308
|
+
* @throws `TaffyError` if the parent node does not exist
|
|
1309
|
+
*
|
|
1310
|
+
* @example
|
|
1311
|
+
* ```typescript
|
|
1312
|
+
* const children = BigUint64Array.from([child1, child2, child3]);
|
|
1313
|
+
* tree.setChildren(parentId, children);
|
|
1314
|
+
* ```
|
|
484
1315
|
*/
|
|
485
1316
|
setChildren(parent: bigint, children: BigUint64Array): void;
|
|
486
1317
|
/**
|
|
487
|
-
* Creates a new TaffyTree with pre-allocated capacity
|
|
488
|
-
*
|
|
489
|
-
* Use this when you know approximately how many nodes
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
1318
|
+
* Creates a new TaffyTree with pre-allocated capacity
|
|
1319
|
+
*
|
|
1320
|
+
* Use this when you know approximately how many nodes will be in the tree.
|
|
1321
|
+
* This can improve performance by reducing memory reallocations.
|
|
1322
|
+
*
|
|
1323
|
+
* @param capacity - The number of nodes to pre-allocate space for
|
|
1324
|
+
*
|
|
1325
|
+
* @example
|
|
1326
|
+
* ```typescript
|
|
1327
|
+
* const tree: TaffyTree = TaffyTree.withCapacity(1000);
|
|
1328
|
+
* ```
|
|
497
1329
|
*/
|
|
498
1330
|
static withCapacity(capacity: number): TaffyTree;
|
|
499
1331
|
/**
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
1332
|
+
* Computes the layout for a subtree
|
|
1333
|
+
*
|
|
1334
|
+
* This is the main layout computation method. Call this on the root node
|
|
1335
|
+
* to compute layouts for all nodes in the tree.
|
|
1336
|
+
*
|
|
1337
|
+
* @param node - The root node ID to compute layout for
|
|
1338
|
+
* @param available_space - The available space constraints
|
|
1339
|
+
*
|
|
1340
|
+
* @example
|
|
1341
|
+
* ```typescript
|
|
1342
|
+
* // Fixed size container
|
|
1343
|
+
* { width: { Definite: 800 }, height: { Definite: 600 } }
|
|
1344
|
+
*
|
|
1345
|
+
* // Flexible width, fixed height
|
|
1346
|
+
* { width: "MaxContent", height: { Definite: 600 } }
|
|
1347
|
+
*
|
|
1348
|
+
* // Minimum content size
|
|
1349
|
+
* { width: "MinContent", height: "MinContent" }
|
|
1350
|
+
* ```
|
|
1351
|
+
*
|
|
1352
|
+
* @throws `TaffyError` if the node does not exist or available space is invalid
|
|
1353
|
+
*
|
|
1354
|
+
* @example
|
|
1355
|
+
* ```typescript
|
|
1356
|
+
* tree.computeLayout(rootId, { width: { Definite: 800 }, height: { Definite: 600 } });
|
|
1357
|
+
* ```
|
|
509
1358
|
*/
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
* Available space options per dimension:
|
|
524
|
-
* - `{ Definite: number }` - A specific size in pixels
|
|
525
|
-
* - `"MinContent"` - Use minimum content size
|
|
526
|
-
* - `"MaxContent"` - Use maximum content size
|
|
527
|
-
*/
|
|
528
|
-
computeLayout(node: bigint, available_space: any): void;
|
|
529
|
-
/**
|
|
530
|
-
* Enables rounding of layout values to whole pixels.
|
|
531
|
-
*
|
|
532
|
-
* When enabled, all computed layout values (x, y, width, height) are
|
|
533
|
-
* rounded to the nearest integer. This is the default behavior.
|
|
1359
|
+
computeLayout(node: bigint, available_space: Size<AvailableSpace>): void;
|
|
1360
|
+
/**
|
|
1361
|
+
* Enables rounding of layout values to whole pixels
|
|
1362
|
+
*
|
|
1363
|
+
* When enabled (default), computed layout values like position and size
|
|
1364
|
+
* are rounded to the nearest integer. This prevents sub-pixel rendering
|
|
1365
|
+
* issues in most rendering contexts.
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* ```typescript
|
|
1369
|
+
* tree.enableRounding();
|
|
1370
|
+
* ```
|
|
534
1371
|
*/
|
|
535
1372
|
enableRounding(): void;
|
|
536
1373
|
/**
|
|
537
|
-
* Disables rounding of layout values
|
|
538
|
-
*
|
|
539
|
-
* When disabled, layout values
|
|
540
|
-
* Use
|
|
1374
|
+
* Disables rounding of layout values
|
|
1375
|
+
*
|
|
1376
|
+
* When disabled, computed layout values retain their fractional precision.
|
|
1377
|
+
* Use this when you need sub-pixel accuracy or when performing custom
|
|
1378
|
+
* rounding.
|
|
1379
|
+
*
|
|
1380
|
+
* @example
|
|
1381
|
+
* ```typescript
|
|
1382
|
+
* tree.disableRounding();
|
|
1383
|
+
* const layout = tree.getLayout(node);
|
|
1384
|
+
* console.log(layout.x);
|
|
1385
|
+
* ```
|
|
541
1386
|
*/
|
|
542
1387
|
disableRounding(): void;
|
|
543
1388
|
/**
|
|
544
|
-
* Gets the context value for a node
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
1389
|
+
* Gets the context value for a node
|
|
1390
|
+
*
|
|
1391
|
+
* @param node - The node ID
|
|
1392
|
+
*
|
|
1393
|
+
* @returns - The attached context value, or `undefined` if none is set
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```typescript
|
|
1397
|
+
* interface Context { text: string };
|
|
1398
|
+
* const context = tree.getNodeContext(nodeId) as Context | undefined;
|
|
1399
|
+
* if (context) {
|
|
1400
|
+
* console.log(context.text);
|
|
1401
|
+
* }
|
|
1402
|
+
* ```
|
|
551
1403
|
*/
|
|
552
1404
|
getNodeContext(node: bigint): any;
|
|
553
1405
|
/**
|
|
554
|
-
* Sets a context value for a node
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
1406
|
+
* Sets a context value for a node
|
|
1407
|
+
*
|
|
1408
|
+
* The context can be any JavaScript value and is passed to the measure
|
|
1409
|
+
* function during layout computation.
|
|
1410
|
+
*
|
|
1411
|
+
* @param node - The node ID
|
|
1412
|
+
* @param context - Any JavaScript value to attach
|
|
1413
|
+
*
|
|
1414
|
+
* @throws `TaffyError` if the node does not exist
|
|
1415
|
+
*
|
|
1416
|
+
* @example
|
|
1417
|
+
* ```typescript
|
|
1418
|
+
* interface Context { text: string };
|
|
1419
|
+
* tree.setNodeContext(nodeId, { text: "Updated text" } as Context);
|
|
1420
|
+
* ```
|
|
562
1421
|
*/
|
|
563
1422
|
setNodeContext(node: bigint, context: any): void;
|
|
564
1423
|
/**
|
|
565
|
-
* Gets the total number of nodes in the tree
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
1424
|
+
* Gets the total number of nodes in the tree
|
|
1425
|
+
*
|
|
1426
|
+
* @returns - The total count of all nodes
|
|
1427
|
+
*
|
|
1428
|
+
* @example
|
|
1429
|
+
* ```typescript
|
|
1430
|
+
* const count: number = tree.totalNodeCount();
|
|
1431
|
+
* ```
|
|
569
1432
|
*/
|
|
570
1433
|
totalNodeCount(): number;
|
|
571
1434
|
/**
|
|
572
|
-
* Gets the unrounded (fractional) layout for a node
|
|
573
|
-
*
|
|
1435
|
+
* Gets the unrounded (fractional) layout for a node
|
|
1436
|
+
*
|
|
1437
|
+
* Returns the raw computed values before any rounding is applied.
|
|
574
1438
|
* Useful when you need sub-pixel precision.
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
1439
|
+
*
|
|
1440
|
+
* @param node - The node ID
|
|
1441
|
+
*
|
|
1442
|
+
* @returns - The unrounded `Layout`
|
|
1443
|
+
*
|
|
1444
|
+
* @example
|
|
1445
|
+
* ```typescript
|
|
1446
|
+
* const layout: Layout = tree.unroundedLayout(nodeId);
|
|
1447
|
+
* console.log(`Exact width: ${layout.width}`);
|
|
1448
|
+
* ```
|
|
581
1449
|
*/
|
|
582
1450
|
unroundedLayout(node: bigint): Layout;
|
|
583
1451
|
/**
|
|
584
|
-
* Creates a new node with the given children
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
1452
|
+
* Creates a new node with the given children
|
|
1453
|
+
*
|
|
1454
|
+
* Use this to create container nodes that have child elements.
|
|
1455
|
+
* The children must already exist in the tree.
|
|
1456
|
+
*
|
|
1457
|
+
* @param style - The style configuration for the node
|
|
1458
|
+
* @param children - Array of child node IDs (as BigUint64Array)
|
|
1459
|
+
*
|
|
1460
|
+
* @returns - The node ID (`bigint`)
|
|
1461
|
+
*
|
|
1462
|
+
* @throws `TaffyError` if the node cannot be created
|
|
1463
|
+
*
|
|
1464
|
+
* @example
|
|
1465
|
+
* ```typescript
|
|
1466
|
+
* const containerStyle = new Style();
|
|
1467
|
+
* containerStyle.display = Display.Flex;
|
|
1468
|
+
*
|
|
1469
|
+
* const child1: bigint = tree.newLeaf(new Style());
|
|
1470
|
+
* const child2: bigint = tree.newLeaf(new Style());
|
|
1471
|
+
*
|
|
1472
|
+
* const container: bigint = tree.newWithChildren(
|
|
1473
|
+
* containerStyle,
|
|
1474
|
+
* BigUint64Array.from([child1, child2])
|
|
1475
|
+
* );
|
|
1476
|
+
* ```
|
|
593
1477
|
*/
|
|
594
1478
|
newWithChildren(style: Style, children: BigUint64Array): bigint;
|
|
595
1479
|
/**
|
|
596
|
-
* Gets
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
1480
|
+
* Gets the child at a specific index
|
|
1481
|
+
*
|
|
1482
|
+
* @param parent - The parent node ID
|
|
1483
|
+
* @param index - The index of the child (0-based)
|
|
1484
|
+
*
|
|
1485
|
+
* @returns - The child node ID (`bigint`)
|
|
1486
|
+
*
|
|
1487
|
+
* @throws `TaffyError` if the parent node does not exist or index is out of bounds
|
|
1488
|
+
*
|
|
1489
|
+
* @example
|
|
1490
|
+
* ```typescript
|
|
1491
|
+
* const firstChild: bigint = tree.getChildAtIndex(parentId, 0);
|
|
1492
|
+
* ```
|
|
1493
|
+
*/
|
|
1494
|
+
getChildAtIndex(parent: bigint, index: number): bigint;
|
|
1495
|
+
/**
|
|
1496
|
+
* Gets a mutable reference to the context value for a node
|
|
1497
|
+
*
|
|
1498
|
+
* In JavaScript, this behaves the same as `getNodeContext()` since
|
|
1499
|
+
* JavaScript objects are always passed by reference.
|
|
1500
|
+
*
|
|
1501
|
+
* @param node - The node ID
|
|
1502
|
+
*
|
|
1503
|
+
* @returns - The attached context value, or `undefined` if none is set
|
|
605
1504
|
*/
|
|
606
1505
|
getNodeContextMut(node: bigint): any;
|
|
607
1506
|
/**
|
|
608
|
-
* Inserts a child at a specific index
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
1507
|
+
* Inserts a child at a specific index
|
|
1508
|
+
*
|
|
1509
|
+
* @param parent - The parent node ID
|
|
1510
|
+
* @param index - The position to insert at (0-based)
|
|
1511
|
+
* @param child - The child node ID to insert
|
|
1512
|
+
*
|
|
1513
|
+
* @throws `TaffyError` if the parent or child node does not exist, or index is out of bounds
|
|
1514
|
+
*
|
|
1515
|
+
* @example
|
|
1516
|
+
* ```typescript
|
|
1517
|
+
* tree.insertChildAtIndex(parentId, 0, childId);
|
|
1518
|
+
* ```
|
|
616
1519
|
*/
|
|
617
1520
|
insertChildAtIndex(parent: bigint, index: number, child: bigint): void;
|
|
618
1521
|
/**
|
|
619
|
-
* Creates a new leaf node with an attached context value
|
|
620
|
-
*
|
|
621
|
-
* The context can be any JavaScript value and is
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
1522
|
+
* Creates a new leaf node with an attached context value
|
|
1523
|
+
*
|
|
1524
|
+
* The context can be any JavaScript value and is passed to the measure
|
|
1525
|
+
* function during layout computation. This is useful for storing
|
|
1526
|
+
* references to text content or other dynamic data.
|
|
1527
|
+
*
|
|
1528
|
+
* @param style - The style configuration for the node
|
|
1529
|
+
* @param context - Any JavaScript value to attach to the node
|
|
1530
|
+
* @returns - The node ID (`bigint`)
|
|
1531
|
+
* @throws `TaffyError` if the node cannot be created
|
|
1532
|
+
*
|
|
1533
|
+
* @example
|
|
1534
|
+
* ```typescript
|
|
1535
|
+
* interface TextContext { text: string; isBold: boolean; }
|
|
1536
|
+
*
|
|
1537
|
+
* const style = new Style();
|
|
1538
|
+
* const context: TextContext = { text: "Hello, World!", isBold: true };
|
|
1539
|
+
* const nodeId: bigint = tree.newLeafWithContext(style, context);
|
|
1540
|
+
* ```
|
|
631
1541
|
*/
|
|
632
1542
|
newLeafWithContext(style: Style, context: any): bigint;
|
|
633
1543
|
/**
|
|
634
|
-
* Removes a child at a specific index
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
1544
|
+
* Removes a child at a specific index
|
|
1545
|
+
*
|
|
1546
|
+
* @param parent - The parent node ID
|
|
1547
|
+
* @param index - The index of the child to remove (0-based)
|
|
1548
|
+
*
|
|
1549
|
+
* @returns - The removed child ID (`bigint`)
|
|
1550
|
+
*
|
|
1551
|
+
* @throws `TaffyError` if the parent node does not exist or index is out of bounds
|
|
1552
|
+
*
|
|
1553
|
+
* @example
|
|
1554
|
+
* ```typescript
|
|
1555
|
+
* const removedId: bigint = tree.removeChildAtIndex(parentId, 0);
|
|
1556
|
+
* ```
|
|
643
1557
|
*/
|
|
644
1558
|
removeChildAtIndex(parent: bigint, index: number): bigint;
|
|
645
1559
|
/**
|
|
646
|
-
* Removes a range of children
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
*
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
*
|
|
1560
|
+
* Removes a range of children
|
|
1561
|
+
*
|
|
1562
|
+
* Removes children from `start_index` (inclusive) to `end_index` (exclusive).
|
|
1563
|
+
*
|
|
1564
|
+
* @param parent - The parent node ID
|
|
1565
|
+
* @param start_index - Start of range (inclusive)
|
|
1566
|
+
* @param end_index - End of range (exclusive)
|
|
1567
|
+
*
|
|
1568
|
+
* @throws `TaffyError` if the parent node does not exist or range is invalid
|
|
1569
|
+
*
|
|
1570
|
+
* @example
|
|
1571
|
+
* ```typescript
|
|
1572
|
+
* tree.removeChildrenRange(parentId, 1, 3);
|
|
1573
|
+
* ```
|
|
1574
|
+
*/
|
|
1575
|
+
removeChildrenRange(
|
|
1576
|
+
parent: bigint,
|
|
1577
|
+
start_index: number,
|
|
1578
|
+
end_index: number,
|
|
1579
|
+
): void;
|
|
1580
|
+
/**
|
|
1581
|
+
* Replaces a child at a specific index
|
|
1582
|
+
*
|
|
1583
|
+
* @param parent - The parent node ID
|
|
1584
|
+
* @param index - The index of the child to replace (0-based)
|
|
1585
|
+
* @param new_child - The new child node ID
|
|
1586
|
+
*
|
|
1587
|
+
* @returns - The replaced (old) child ID (`bigint`)
|
|
1588
|
+
*
|
|
1589
|
+
* @throws `TaffyError` if the parent node does not exist or index is out of bounds
|
|
1590
|
+
*
|
|
1591
|
+
* @example
|
|
1592
|
+
* ```typescript
|
|
1593
|
+
* const oldChildId: bigint = tree.replaceChildAtIndex(parentId, 1, newChildId);
|
|
1594
|
+
* ```
|
|
1595
|
+
*/
|
|
1596
|
+
replaceChildAtIndex(parent: bigint, index: number, new_child: bigint): bigint;
|
|
1597
|
+
/**
|
|
1598
|
+
* Computes layout with a custom measure function for leaf nodes
|
|
1599
|
+
*
|
|
1600
|
+
* Use this when you have leaf nodes with dynamic content (like text)
|
|
1601
|
+
* that needs to be measured during layout. The measure function is
|
|
1602
|
+
* called for each leaf node that needs measurement.
|
|
1603
|
+
*
|
|
1604
|
+
* @param node - The root node ID to compute layout for
|
|
1605
|
+
* @param available_space - The available space constraints
|
|
1606
|
+
* @param measure_func - A function that measures leaf node content
|
|
1607
|
+
*
|
|
1608
|
+
* @throws `TaffyError` if the node does not exist or available space is invalid
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* ```typescript
|
|
1612
|
+
* tree.computeLayoutWithMeasure(
|
|
1613
|
+
* rootId,
|
|
1614
|
+
* { width: { Definite: 800 }, height: "MaxContent" },
|
|
1615
|
+
* (known, available, node, context, style) => {
|
|
1616
|
+
* if (context?.text) {
|
|
1617
|
+
* const measured = measureText(context.text, available.width);
|
|
1618
|
+
* return { width: measured.width, height: measured.height };
|
|
1619
|
+
* }
|
|
1620
|
+
* return { width: 0, height: 0 };
|
|
1621
|
+
* }
|
|
1622
|
+
* );
|
|
1623
|
+
* ```
|
|
1624
|
+
*/
|
|
1625
|
+
computeLayoutWithMeasure(
|
|
1626
|
+
node: bigint,
|
|
1627
|
+
available_space: Size<AvailableSpace>,
|
|
1628
|
+
measure_func: MeasureFunction,
|
|
1629
|
+
): void;
|
|
1630
|
+
/**
|
|
1631
|
+
* Gets context values for multiple nodes at once
|
|
1632
|
+
*
|
|
1633
|
+
* This is more efficient than calling `getNodeContext()` multiple times
|
|
1634
|
+
* when you need to access contexts for many nodes.
|
|
1635
|
+
*
|
|
1636
|
+
* @param children - Array of node IDs
|
|
1637
|
+
*
|
|
1638
|
+
* @returns - Array of context values (undefined for nodes without context)
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* ```typescript
|
|
1642
|
+
* const nodes = BigUint64Array.from([id1, id2]);
|
|
1643
|
+
* const contexts = tree.getDisjointNodeContextMut(nodes);
|
|
1644
|
+
* ```
|
|
697
1645
|
*/
|
|
698
1646
|
getDisjointNodeContextMut(children: BigUint64Array): any[];
|
|
699
1647
|
/**
|
|
700
|
-
* Creates a new empty TaffyTree
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
* to
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
1648
|
+
* Creates a new empty TaffyTree
|
|
1649
|
+
*
|
|
1650
|
+
* The tree starts with no nodes. Use `newLeaf()` or `newWithChildren()`
|
|
1651
|
+
* to add nodes.
|
|
1652
|
+
*
|
|
1653
|
+
* @example
|
|
1654
|
+
* ```typescript
|
|
1655
|
+
* const tree: TaffyTree = new TaffyTree();
|
|
1656
|
+
* ```
|
|
707
1657
|
*/
|
|
708
1658
|
constructor();
|
|
709
1659
|
/**
|
|
710
|
-
* Removes all nodes from the tree
|
|
711
|
-
*
|
|
712
|
-
*
|
|
1660
|
+
* Removes all nodes from the tree
|
|
1661
|
+
*
|
|
1662
|
+
* This clears the entire tree, removing all nodes and their relationships.
|
|
1663
|
+
* Use this to reset the tree for reuse.
|
|
1664
|
+
*
|
|
1665
|
+
* @example
|
|
1666
|
+
* ```typescript
|
|
1667
|
+
* tree.clear();
|
|
1668
|
+
* console.log(tree.totalNodeCount());
|
|
1669
|
+
* ```
|
|
713
1670
|
*/
|
|
714
1671
|
clear(): void;
|
|
715
1672
|
/**
|
|
716
|
-
* Checks if a node is dirty (needs re-layout)
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
*
|
|
1673
|
+
* Checks if a node is dirty (needs re-layout)
|
|
1674
|
+
*
|
|
1675
|
+
* A node is dirty if its style or content has changed since the last
|
|
1676
|
+
* layout computation.
|
|
1677
|
+
*
|
|
1678
|
+
* @param node - The node ID to check
|
|
1679
|
+
*
|
|
1680
|
+
* @returns - true if dirty, false otherwise
|
|
1681
|
+
*
|
|
1682
|
+
* @throws `TaffyError` if the node does not exist
|
|
1683
|
+
*
|
|
1684
|
+
* @example
|
|
1685
|
+
* ```typescript
|
|
1686
|
+
* if (tree.dirty(nodeId)) {
|
|
1687
|
+
* tree.computeLayout(rootId, availableSpace);
|
|
1688
|
+
* }
|
|
1689
|
+
* ```
|
|
725
1690
|
*/
|
|
726
1691
|
dirty(node: bigint): boolean;
|
|
727
1692
|
/**
|
|
728
|
-
* Gets the style for a node
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
1693
|
+
* Gets the style for a node
|
|
1694
|
+
*
|
|
1695
|
+
* @param node - The node ID
|
|
1696
|
+
*
|
|
1697
|
+
* @returns - The node's `Style`
|
|
1698
|
+
*
|
|
1699
|
+
* @throws `TaffyError` if the node does not exist
|
|
1700
|
+
*
|
|
1701
|
+
* @example
|
|
1702
|
+
* ```typescript
|
|
1703
|
+
* const style: Style = tree.getStyle(nodeId);
|
|
1704
|
+
* console.log('Flex grow:', style.flexGrow);
|
|
1705
|
+
* ```
|
|
736
1706
|
*/
|
|
737
1707
|
getStyle(node: bigint): Style;
|
|
738
1708
|
/**
|
|
739
|
-
* Gets the computed layout for a node
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
1709
|
+
* Gets the computed layout for a node
|
|
1710
|
+
*
|
|
1711
|
+
* Call this after `computeLayout()` to retrieve the computed position
|
|
1712
|
+
* and size for a node.
|
|
1713
|
+
*
|
|
1714
|
+
* @param node - The node ID
|
|
1715
|
+
*
|
|
1716
|
+
* @returns - The computed `Layout`
|
|
1717
|
+
*
|
|
1718
|
+
* @throws `TaffyError` if the node does not exist
|
|
1719
|
+
*
|
|
1720
|
+
* @example
|
|
1721
|
+
* ```typescript
|
|
1722
|
+
* tree.computeLayout(rootId, { width: { Definite: 800 }, height: { Definite: 600 } });
|
|
1723
|
+
* const layout: Layout = tree.getLayout(nodeId);
|
|
1724
|
+
* console.log(`Position: (${layout.x}, ${layout.y}), Size: ${layout.width}x${layout.height}`);
|
|
1725
|
+
* ```
|
|
748
1726
|
*/
|
|
749
1727
|
getLayout(node: bigint): Layout;
|
|
750
1728
|
/**
|
|
751
|
-
* Gets the parent of a node
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
1729
|
+
* Gets the parent of a node
|
|
1730
|
+
*
|
|
1731
|
+
* @param child - The child node ID
|
|
1732
|
+
*
|
|
1733
|
+
* @returns - The parent node ID, or `undefined` if the node has no parent
|
|
1734
|
+
*
|
|
1735
|
+
* @example
|
|
1736
|
+
* ```typescript
|
|
1737
|
+
* const parentId: bigint | undefined = tree.parent(childId);
|
|
1738
|
+
* ```
|
|
759
1739
|
*/
|
|
760
1740
|
parent(child: bigint): bigint | undefined;
|
|
761
1741
|
/**
|
|
762
|
-
* Removes a node from the tree
|
|
763
|
-
*
|
|
764
|
-
* The node
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
1742
|
+
* Removes a node from the tree
|
|
1743
|
+
*
|
|
1744
|
+
* The node and all its descendants are removed. If the node has a parent,
|
|
1745
|
+
* it is automatically removed from the parent's children.
|
|
1746
|
+
*
|
|
1747
|
+
* @param node - The node ID to remove
|
|
1748
|
+
*
|
|
1749
|
+
* @returns - The removed node ID (`bigint`)
|
|
1750
|
+
*
|
|
1751
|
+
* @throws `TaffyError` if the node does not exist
|
|
1752
|
+
*
|
|
1753
|
+
* @example
|
|
1754
|
+
* ```typescript
|
|
1755
|
+
* try {
|
|
1756
|
+
* const removedId: bigint = tree.remove(nodeId);
|
|
1757
|
+
* } catch (e) {
|
|
1758
|
+
* console.error("Node doesn't exist");
|
|
1759
|
+
* }
|
|
1760
|
+
* ```
|
|
773
1761
|
*/
|
|
774
1762
|
remove(node: bigint): bigint;
|
|
775
1763
|
/**
|
|
776
|
-
* Gets all children of a node
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
1764
|
+
* Gets all children of a node
|
|
1765
|
+
*
|
|
1766
|
+
* @param parent - The parent node ID
|
|
1767
|
+
*
|
|
1768
|
+
* @returns - Array of child node IDs (`BigUint64Array`)
|
|
1769
|
+
*
|
|
1770
|
+
* @throws `TaffyError` if the parent node does not exist
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
* ```typescript
|
|
1774
|
+
* const children: BigUint64Array = tree.children(parentId);
|
|
1775
|
+
* ```
|
|
784
1776
|
*/
|
|
785
1777
|
children(parent: bigint): BigUint64Array;
|
|
786
1778
|
/**
|
|
787
|
-
* Creates a new leaf node
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
1779
|
+
* Creates a new leaf node with the given style
|
|
1780
|
+
*
|
|
1781
|
+
* A leaf node has no children. Use this for elements that contain
|
|
1782
|
+
* content (like text) rather than other elements.
|
|
1783
|
+
*
|
|
1784
|
+
* @param style - The style configuration for the node
|
|
1785
|
+
* @returns - The node ID (`bigint`)
|
|
1786
|
+
* @throws `TaffyError` if the node cannot be created
|
|
1787
|
+
*
|
|
1788
|
+
* @example
|
|
1789
|
+
* ```typescript
|
|
1790
|
+
* const style = new Style();
|
|
1791
|
+
* style.size = { width: { Length: 100 }, height: { Length: 50 } };
|
|
1792
|
+
* const nodeId: bigint = tree.newLeaf(style);
|
|
1793
|
+
* ```
|
|
795
1794
|
*/
|
|
796
1795
|
newLeaf(style: Style): bigint;
|
|
797
1796
|
/**
|
|
798
|
-
* Appends a child node to a parent
|
|
799
|
-
*
|
|
800
|
-
* The child is added
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
1797
|
+
* Appends a child node to a parent
|
|
1798
|
+
*
|
|
1799
|
+
* The child is added as the last child of the parent.
|
|
1800
|
+
*
|
|
1801
|
+
* @param parent - The parent node ID
|
|
1802
|
+
* @param child - The child node ID to add
|
|
1803
|
+
*
|
|
1804
|
+
* @throws `TaffyError` if the parent or child node does not exist
|
|
1805
|
+
*
|
|
1806
|
+
* @example
|
|
1807
|
+
* ```typescript
|
|
1808
|
+
* tree.addChild(parentId, childId);
|
|
1809
|
+
* ```
|
|
805
1810
|
*/
|
|
806
1811
|
addChild(parent: bigint, child: bigint): void;
|
|
807
1812
|
/**
|
|
808
|
-
* Sets the style for an existing node
|
|
809
|
-
*
|
|
810
|
-
* This
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
*
|
|
1813
|
+
* Sets the style for an existing node
|
|
1814
|
+
*
|
|
1815
|
+
* This replaces the node's current style with the provided one.
|
|
1816
|
+
* The node will be marked as dirty and require re-layout.
|
|
1817
|
+
*
|
|
1818
|
+
* @param node - The node ID
|
|
1819
|
+
* @param style - The new style configuration
|
|
1820
|
+
*
|
|
1821
|
+
* @throws `TaffyError` if the node does not exist
|
|
1822
|
+
*
|
|
1823
|
+
* @example
|
|
1824
|
+
* ```typescript
|
|
1825
|
+
* const newStyle = new Style();
|
|
1826
|
+
* newStyle.flexGrow = 2;
|
|
1827
|
+
* tree.setStyle(nodeId, newStyle);
|
|
1828
|
+
* ```
|
|
816
1829
|
*/
|
|
817
1830
|
setStyle(node: bigint, style: Style): void;
|
|
818
1831
|
}
|
|
819
1832
|
|
|
820
|
-
export type InitInput =
|
|
1833
|
+
export type InitInput =
|
|
1834
|
+
| RequestInfo
|
|
1835
|
+
| URL
|
|
1836
|
+
| Response
|
|
1837
|
+
| BufferSource
|
|
1838
|
+
| WebAssembly.Module;
|
|
821
1839
|
|
|
822
1840
|
export interface InitOutput {
|
|
823
1841
|
readonly memory: WebAssembly.Memory;
|
|
824
1842
|
readonly __wbg_layout_free: (a: number, b: number) => void;
|
|
825
1843
|
readonly __wbg_style_free: (a: number, b: number) => void;
|
|
1844
|
+
readonly __wbg_taffyerror_free: (a: number, b: number) => void;
|
|
826
1845
|
readonly __wbg_taffytree_free: (a: number, b: number) => void;
|
|
827
1846
|
readonly layout_borderBottom: (a: number) => number;
|
|
828
1847
|
readonly layout_borderLeft: (a: number) => number;
|
|
@@ -845,87 +1864,177 @@ export interface InitOutput {
|
|
|
845
1864
|
readonly layout_width: (a: number) => number;
|
|
846
1865
|
readonly layout_x: (a: number) => number;
|
|
847
1866
|
readonly layout_y: (a: number) => number;
|
|
848
|
-
readonly
|
|
849
|
-
readonly
|
|
850
|
-
readonly
|
|
851
|
-
readonly
|
|
1867
|
+
readonly style_alignContent: (a: number) => number;
|
|
1868
|
+
readonly style_alignItems: (a: number) => number;
|
|
1869
|
+
readonly style_alignSelf: (a: number) => number;
|
|
1870
|
+
readonly style_aspectRatio: (a: number) => number;
|
|
852
1871
|
readonly style_border: (a: number) => any;
|
|
853
|
-
readonly
|
|
1872
|
+
readonly style_boxSizing: (a: number) => number;
|
|
854
1873
|
readonly style_display: (a: number) => number;
|
|
855
|
-
readonly
|
|
856
|
-
readonly
|
|
857
|
-
readonly
|
|
858
|
-
readonly
|
|
859
|
-
readonly
|
|
1874
|
+
readonly style_flexBasis: (a: number) => any;
|
|
1875
|
+
readonly style_flexDirection: (a: number) => number;
|
|
1876
|
+
readonly style_flexGrow: (a: number) => number;
|
|
1877
|
+
readonly style_flexShrink: (a: number) => number;
|
|
1878
|
+
readonly style_flexWrap: (a: number) => number;
|
|
860
1879
|
readonly style_gap: (a: number) => any;
|
|
861
1880
|
readonly style_inset: (a: number) => any;
|
|
862
|
-
readonly
|
|
1881
|
+
readonly style_justifyContent: (a: number) => number;
|
|
863
1882
|
readonly style_margin: (a: number) => any;
|
|
864
|
-
readonly
|
|
865
|
-
readonly
|
|
1883
|
+
readonly style_maxSize: (a: number) => any;
|
|
1884
|
+
readonly style_minSize: (a: number) => any;
|
|
866
1885
|
readonly style_new: () => number;
|
|
867
1886
|
readonly style_overflow: (a: number) => any;
|
|
868
1887
|
readonly style_padding: (a: number) => any;
|
|
869
1888
|
readonly style_position: (a: number) => number;
|
|
870
|
-
readonly
|
|
871
|
-
readonly
|
|
872
|
-
readonly
|
|
873
|
-
readonly
|
|
1889
|
+
readonly style_set_alignContent: (a: number, b: any) => void;
|
|
1890
|
+
readonly style_set_alignItems: (a: number, b: any) => void;
|
|
1891
|
+
readonly style_set_alignSelf: (a: number, b: any) => void;
|
|
1892
|
+
readonly style_set_aspectRatio: (a: number, b: any) => void;
|
|
874
1893
|
readonly style_set_border: (a: number, b: any) => void;
|
|
875
|
-
readonly
|
|
1894
|
+
readonly style_set_boxSizing: (a: number, b: number) => void;
|
|
876
1895
|
readonly style_set_display: (a: number, b: number) => void;
|
|
877
|
-
readonly
|
|
878
|
-
readonly
|
|
879
|
-
readonly
|
|
880
|
-
readonly
|
|
881
|
-
readonly
|
|
1896
|
+
readonly style_set_flexBasis: (a: number, b: any) => void;
|
|
1897
|
+
readonly style_set_flexDirection: (a: number, b: number) => void;
|
|
1898
|
+
readonly style_set_flexGrow: (a: number, b: number) => void;
|
|
1899
|
+
readonly style_set_flexShrink: (a: number, b: number) => void;
|
|
1900
|
+
readonly style_set_flexWrap: (a: number, b: number) => void;
|
|
882
1901
|
readonly style_set_gap: (a: number, b: any) => void;
|
|
883
1902
|
readonly style_set_inset: (a: number, b: any) => void;
|
|
884
|
-
readonly
|
|
1903
|
+
readonly style_set_justifyContent: (a: number, b: any) => void;
|
|
885
1904
|
readonly style_set_margin: (a: number, b: any) => void;
|
|
886
|
-
readonly
|
|
887
|
-
readonly
|
|
1905
|
+
readonly style_set_maxSize: (a: number, b: any) => void;
|
|
1906
|
+
readonly style_set_minSize: (a: number, b: any) => void;
|
|
888
1907
|
readonly style_set_overflow: (a: number, b: any) => void;
|
|
889
1908
|
readonly style_set_padding: (a: number, b: any) => void;
|
|
890
1909
|
readonly style_set_position: (a: number, b: number) => void;
|
|
891
1910
|
readonly style_set_size: (a: number, b: any) => void;
|
|
892
1911
|
readonly style_size: (a: number) => any;
|
|
893
|
-
readonly
|
|
1912
|
+
readonly taffyerror_message: (a: number) => [number, number];
|
|
1913
|
+
readonly taffytree_addChild: (
|
|
1914
|
+
a: number,
|
|
1915
|
+
b: bigint,
|
|
1916
|
+
c: bigint,
|
|
1917
|
+
) => [number, number];
|
|
894
1918
|
readonly taffytree_childCount: (a: number, b: bigint) => number;
|
|
895
|
-
readonly taffytree_children: (
|
|
1919
|
+
readonly taffytree_children: (
|
|
1920
|
+
a: number,
|
|
1921
|
+
b: bigint,
|
|
1922
|
+
) => [number, number, number, number];
|
|
896
1923
|
readonly taffytree_clear: (a: number) => void;
|
|
897
|
-
readonly taffytree_computeLayout: (
|
|
898
|
-
|
|
1924
|
+
readonly taffytree_computeLayout: (
|
|
1925
|
+
a: number,
|
|
1926
|
+
b: bigint,
|
|
1927
|
+
c: any,
|
|
1928
|
+
) => [number, number];
|
|
1929
|
+
readonly taffytree_computeLayoutWithMeasure: (
|
|
1930
|
+
a: number,
|
|
1931
|
+
b: bigint,
|
|
1932
|
+
c: any,
|
|
1933
|
+
d: any,
|
|
1934
|
+
) => [number, number];
|
|
899
1935
|
readonly taffytree_dirty: (a: number, b: bigint) => [number, number, number];
|
|
900
1936
|
readonly taffytree_disableRounding: (a: number) => void;
|
|
901
1937
|
readonly taffytree_enableRounding: (a: number) => void;
|
|
902
|
-
readonly taffytree_getChildAtIndex: (
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
readonly
|
|
908
|
-
|
|
1938
|
+
readonly taffytree_getChildAtIndex: (
|
|
1939
|
+
a: number,
|
|
1940
|
+
b: bigint,
|
|
1941
|
+
c: number,
|
|
1942
|
+
) => [bigint, number, number];
|
|
1943
|
+
readonly taffytree_getDisjointNodeContextMut: (
|
|
1944
|
+
a: number,
|
|
1945
|
+
b: number,
|
|
1946
|
+
c: number,
|
|
1947
|
+
) => [number, number, number, number];
|
|
1948
|
+
readonly taffytree_getLayout: (
|
|
1949
|
+
a: number,
|
|
1950
|
+
b: bigint,
|
|
1951
|
+
) => [number, number, number];
|
|
1952
|
+
readonly taffytree_getNodeContext: (
|
|
1953
|
+
a: number,
|
|
1954
|
+
b: bigint,
|
|
1955
|
+
) => [number, number, number];
|
|
1956
|
+
readonly taffytree_getNodeContextMut: (
|
|
1957
|
+
a: number,
|
|
1958
|
+
b: bigint,
|
|
1959
|
+
) => [number, number, number];
|
|
1960
|
+
readonly taffytree_getStyle: (
|
|
1961
|
+
a: number,
|
|
1962
|
+
b: bigint,
|
|
1963
|
+
) => [number, number, number];
|
|
1964
|
+
readonly taffytree_insertChildAtIndex: (
|
|
1965
|
+
a: number,
|
|
1966
|
+
b: bigint,
|
|
1967
|
+
c: number,
|
|
1968
|
+
d: bigint,
|
|
1969
|
+
) => [number, number];
|
|
909
1970
|
readonly taffytree_markDirty: (a: number, b: bigint) => [number, number];
|
|
910
1971
|
readonly taffytree_new: () => number;
|
|
911
|
-
readonly taffytree_newLeaf: (
|
|
912
|
-
|
|
913
|
-
|
|
1972
|
+
readonly taffytree_newLeaf: (
|
|
1973
|
+
a: number,
|
|
1974
|
+
b: number,
|
|
1975
|
+
) => [bigint, number, number];
|
|
1976
|
+
readonly taffytree_newLeafWithContext: (
|
|
1977
|
+
a: number,
|
|
1978
|
+
b: number,
|
|
1979
|
+
c: any,
|
|
1980
|
+
) => [bigint, number, number];
|
|
1981
|
+
readonly taffytree_newWithChildren: (
|
|
1982
|
+
a: number,
|
|
1983
|
+
b: number,
|
|
1984
|
+
c: number,
|
|
1985
|
+
d: number,
|
|
1986
|
+
) => [bigint, number, number];
|
|
914
1987
|
readonly taffytree_parent: (a: number, b: bigint) => [number, bigint];
|
|
915
1988
|
readonly taffytree_printTree: (a: number, b: bigint) => void;
|
|
916
1989
|
readonly taffytree_remove: (a: number, b: bigint) => [bigint, number, number];
|
|
917
|
-
readonly taffytree_removeChild: (
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
readonly
|
|
923
|
-
|
|
1990
|
+
readonly taffytree_removeChild: (
|
|
1991
|
+
a: number,
|
|
1992
|
+
b: bigint,
|
|
1993
|
+
c: bigint,
|
|
1994
|
+
) => [bigint, number, number];
|
|
1995
|
+
readonly taffytree_removeChildAtIndex: (
|
|
1996
|
+
a: number,
|
|
1997
|
+
b: bigint,
|
|
1998
|
+
c: number,
|
|
1999
|
+
) => [bigint, number, number];
|
|
2000
|
+
readonly taffytree_removeChildrenRange: (
|
|
2001
|
+
a: number,
|
|
2002
|
+
b: bigint,
|
|
2003
|
+
c: number,
|
|
2004
|
+
d: number,
|
|
2005
|
+
) => [number, number];
|
|
2006
|
+
readonly taffytree_replaceChildAtIndex: (
|
|
2007
|
+
a: number,
|
|
2008
|
+
b: bigint,
|
|
2009
|
+
c: number,
|
|
2010
|
+
d: bigint,
|
|
2011
|
+
) => [bigint, number, number];
|
|
2012
|
+
readonly taffytree_setChildren: (
|
|
2013
|
+
a: number,
|
|
2014
|
+
b: bigint,
|
|
2015
|
+
c: number,
|
|
2016
|
+
d: number,
|
|
2017
|
+
) => [number, number];
|
|
2018
|
+
readonly taffytree_setNodeContext: (
|
|
2019
|
+
a: number,
|
|
2020
|
+
b: bigint,
|
|
2021
|
+
c: any,
|
|
2022
|
+
) => [number, number];
|
|
2023
|
+
readonly taffytree_setStyle: (
|
|
2024
|
+
a: number,
|
|
2025
|
+
b: bigint,
|
|
2026
|
+
c: number,
|
|
2027
|
+
) => [number, number];
|
|
924
2028
|
readonly taffytree_totalNodeCount: (a: number) => number;
|
|
925
|
-
readonly taffytree_unroundedLayout: (a: number, b: bigint) =>
|
|
2029
|
+
readonly taffytree_unroundedLayout: (a: number, b: bigint) => number;
|
|
926
2030
|
readonly taffytree_withCapacity: (a: number) => number;
|
|
927
2031
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
928
|
-
readonly __wbindgen_realloc: (
|
|
2032
|
+
readonly __wbindgen_realloc: (
|
|
2033
|
+
a: number,
|
|
2034
|
+
b: number,
|
|
2035
|
+
c: number,
|
|
2036
|
+
d: number,
|
|
2037
|
+
) => number;
|
|
929
2038
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
930
2039
|
readonly __externref_table_alloc: () => number;
|
|
931
2040
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
@@ -938,21 +2047,28 @@ export interface InitOutput {
|
|
|
938
2047
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
939
2048
|
|
|
940
2049
|
/**
|
|
941
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
942
|
-
* a precompiled `WebAssembly.Module`.
|
|
943
|
-
*
|
|
944
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
945
|
-
*
|
|
946
|
-
* @returns {InitOutput}
|
|
947
|
-
*/
|
|
948
|
-
export function initSync(
|
|
2050
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
2051
|
+
* a precompiled `WebAssembly.Module`.
|
|
2052
|
+
*
|
|
2053
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
2054
|
+
*
|
|
2055
|
+
* @returns {InitOutput}
|
|
2056
|
+
*/
|
|
2057
|
+
export function initSync(
|
|
2058
|
+
module: { module: SyncInitInput } | SyncInitInput,
|
|
2059
|
+
): InitOutput;
|
|
949
2060
|
|
|
950
2061
|
/**
|
|
951
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
952
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
953
|
-
*
|
|
954
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
955
|
-
*
|
|
956
|
-
* @returns {Promise<InitOutput>}
|
|
957
|
-
*/
|
|
958
|
-
export default function __wbg_init
|
|
2062
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
2063
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
2064
|
+
*
|
|
2065
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
2066
|
+
*
|
|
2067
|
+
* @returns {Promise<InitOutput>}
|
|
2068
|
+
*/
|
|
2069
|
+
export default function __wbg_init(
|
|
2070
|
+
module_or_path?:
|
|
2071
|
+
| { module_or_path: InitInput | Promise<InitInput> }
|
|
2072
|
+
| InitInput
|
|
2073
|
+
| Promise<InitInput>,
|
|
2074
|
+
): Promise<InitOutput>;
|