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/taffy_js.js CHANGED
@@ -1,2030 +1,3014 @@
1
1
  let wasm;
2
2
 
3
3
  function addToExternrefTable0(obj) {
4
- const idx = wasm.__externref_table_alloc();
5
- wasm.__wbindgen_externrefs.set(idx, obj);
6
- return idx;
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_externrefs.set(idx, obj);
6
+ return idx;
7
7
  }
8
8
 
9
9
  function _assertClass(instance, klass) {
10
- if (!(instance instanceof klass)) {
11
- throw new Error(`expected instance of ${klass.name}`);
12
- }
10
+ if (!(instance instanceof klass)) {
11
+ throw new Error(`expected instance of ${klass.name}`);
12
+ }
13
13
  }
14
14
 
15
15
  function debugString(val) {
16
- // primitive types
17
- const type = typeof val;
18
- if (type == 'number' || type == 'boolean' || val == null) {
19
- return `${val}`;
20
- }
21
- if (type == 'string') {
22
- return `"${val}"`;
23
- }
24
- if (type == 'symbol') {
25
- const description = val.description;
26
- if (description == null) {
27
- return 'Symbol';
28
- } else {
29
- return `Symbol(${description})`;
30
- }
31
- }
32
- if (type == 'function') {
33
- const name = val.name;
34
- if (typeof name == 'string' && name.length > 0) {
35
- return `Function(${name})`;
36
- } else {
37
- return 'Function';
38
- }
39
- }
40
- // objects
41
- if (Array.isArray(val)) {
42
- const length = val.length;
43
- let debug = '[';
44
- if (length > 0) {
45
- debug += debugString(val[0]);
46
- }
47
- for(let i = 1; i < length; i++) {
48
- debug += ', ' + debugString(val[i]);
49
- }
50
- debug += ']';
51
- return debug;
52
- }
53
- // Test for built-in
54
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
55
- let className;
56
- if (builtInMatches && builtInMatches.length > 1) {
57
- className = builtInMatches[1];
16
+ // primitive types
17
+ const type = typeof val;
18
+ if (type == "number" || type == "boolean" || val == null) {
19
+ return `${val}`;
20
+ }
21
+ if (type == "string") {
22
+ return `"${val}"`;
23
+ }
24
+ if (type == "symbol") {
25
+ const description = val.description;
26
+ if (description == null) {
27
+ return "Symbol";
58
28
  } else {
59
- // Failed to match the standard '[object ClassName]'
60
- return toString.call(val);
61
- }
62
- if (className == 'Object') {
63
- // we're a user defined class or Object
64
- // JSON.stringify avoids problems with cycles, and is generally much
65
- // easier than looping through ownProperties of `val`.
66
- try {
67
- return 'Object(' + JSON.stringify(val) + ')';
68
- } catch (_) {
69
- return 'Object';
70
- }
29
+ return `Symbol(${description})`;
71
30
  }
72
- // errors
73
- if (val instanceof Error) {
74
- return `${val.name}: ${val.message}\n${val.stack}`;
75
- }
76
- // TODO we could test for more things here, like `Set`s and `Map`s.
77
- return className;
31
+ }
32
+ if (type == "function") {
33
+ const name = val.name;
34
+ if (typeof name == "string" && name.length > 0) {
35
+ return `Function(${name})`;
36
+ } else {
37
+ return "Function";
38
+ }
39
+ }
40
+ // objects
41
+ if (Array.isArray(val)) {
42
+ const length = val.length;
43
+ let debug = "[";
44
+ if (length > 0) {
45
+ debug += debugString(val[0]);
46
+ }
47
+ for (let i = 1; i < length; i++) {
48
+ debug += ", " + debugString(val[i]);
49
+ }
50
+ debug += "]";
51
+ return debug;
52
+ }
53
+ // Test for built-in
54
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
55
+ let className;
56
+ if (builtInMatches && builtInMatches.length > 1) {
57
+ className = builtInMatches[1];
58
+ } else {
59
+ // Failed to match the standard '[object ClassName]'
60
+ return toString.call(val);
61
+ }
62
+ if (className == "Object") {
63
+ // we're a user defined class or Object
64
+ // JSON.stringify avoids problems with cycles, and is generally much
65
+ // easier than looping through ownProperties of `val`.
66
+ try {
67
+ return "Object(" + JSON.stringify(val) + ")";
68
+ } catch (_) {
69
+ return "Object";
70
+ }
71
+ }
72
+ // errors
73
+ if (val instanceof Error) {
74
+ return `${val.name}: ${val.message}\n${val.stack}`;
75
+ }
76
+ // TODO we could test for more things here, like `Set`s and `Map`s.
77
+ return className;
78
78
  }
79
79
 
80
80
  function getArrayJsValueFromWasm0(ptr, len) {
81
- ptr = ptr >>> 0;
82
- const mem = getDataViewMemory0();
83
- const result = [];
84
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
85
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
86
- }
87
- wasm.__externref_drop_slice(ptr, len);
88
- return result;
81
+ ptr = ptr >>> 0;
82
+ const mem = getDataViewMemory0();
83
+ const result = [];
84
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
85
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
86
+ }
87
+ wasm.__externref_drop_slice(ptr, len);
88
+ return result;
89
89
  }
90
90
 
91
91
  function getArrayU64FromWasm0(ptr, len) {
92
- ptr = ptr >>> 0;
93
- return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
92
+ ptr = ptr >>> 0;
93
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
94
94
  }
95
95
 
96
96
  function getArrayU8FromWasm0(ptr, len) {
97
- ptr = ptr >>> 0;
98
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
97
+ ptr = ptr >>> 0;
98
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
99
99
  }
100
100
 
101
101
  let cachedBigUint64ArrayMemory0 = null;
102
102
  function getBigUint64ArrayMemory0() {
103
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
104
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
105
- }
106
- return cachedBigUint64ArrayMemory0;
103
+ if (
104
+ cachedBigUint64ArrayMemory0 === null ||
105
+ cachedBigUint64ArrayMemory0.byteLength === 0
106
+ ) {
107
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
108
+ }
109
+ return cachedBigUint64ArrayMemory0;
107
110
  }
108
111
 
109
112
  let cachedDataViewMemory0 = null;
110
113
  function getDataViewMemory0() {
111
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
112
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
113
- }
114
- return cachedDataViewMemory0;
114
+ if (
115
+ cachedDataViewMemory0 === null ||
116
+ cachedDataViewMemory0.buffer.detached === true ||
117
+ (cachedDataViewMemory0.buffer.detached === undefined &&
118
+ cachedDataViewMemory0.buffer !== wasm.memory.buffer)
119
+ ) {
120
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
121
+ }
122
+ return cachedDataViewMemory0;
115
123
  }
116
124
 
117
125
  function getStringFromWasm0(ptr, len) {
118
- ptr = ptr >>> 0;
119
- return decodeText(ptr, len);
126
+ ptr = ptr >>> 0;
127
+ return decodeText(ptr, len);
120
128
  }
121
129
 
122
130
  let cachedUint8ArrayMemory0 = null;
123
131
  function getUint8ArrayMemory0() {
124
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
125
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
126
- }
127
- return cachedUint8ArrayMemory0;
132
+ if (
133
+ cachedUint8ArrayMemory0 === null ||
134
+ cachedUint8ArrayMemory0.byteLength === 0
135
+ ) {
136
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
137
+ }
138
+ return cachedUint8ArrayMemory0;
128
139
  }
129
140
 
130
141
  function handleError(f, args) {
131
- try {
132
- return f.apply(this, args);
133
- } catch (e) {
134
- const idx = addToExternrefTable0(e);
135
- wasm.__wbindgen_exn_store(idx);
136
- }
142
+ try {
143
+ return f.apply(this, args);
144
+ } catch (e) {
145
+ const idx = addToExternrefTable0(e);
146
+ wasm.__wbindgen_exn_store(idx);
147
+ }
137
148
  }
138
149
 
139
150
  function isLikeNone(x) {
140
- return x === undefined || x === null;
151
+ return x === undefined || x === null;
141
152
  }
142
153
 
143
154
  function passArray64ToWasm0(arg, malloc) {
144
- const ptr = malloc(arg.length * 8, 8) >>> 0;
145
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
146
- WASM_VECTOR_LEN = arg.length;
147
- return ptr;
155
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
156
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
157
+ WASM_VECTOR_LEN = arg.length;
158
+ return ptr;
148
159
  }
149
160
 
150
161
  function passStringToWasm0(arg, malloc, realloc) {
151
- if (realloc === undefined) {
152
- const buf = cachedTextEncoder.encode(arg);
153
- const ptr = malloc(buf.length, 1) >>> 0;
154
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
155
- WASM_VECTOR_LEN = buf.length;
156
- return ptr;
157
- }
162
+ if (realloc === undefined) {
163
+ const buf = cachedTextEncoder.encode(arg);
164
+ const ptr = malloc(buf.length, 1) >>> 0;
165
+ getUint8ArrayMemory0()
166
+ .subarray(ptr, ptr + buf.length)
167
+ .set(buf);
168
+ WASM_VECTOR_LEN = buf.length;
169
+ return ptr;
170
+ }
158
171
 
159
- let len = arg.length;
160
- let ptr = malloc(len, 1) >>> 0;
172
+ let len = arg.length;
173
+ let ptr = malloc(len, 1) >>> 0;
161
174
 
162
- const mem = getUint8ArrayMemory0();
175
+ const mem = getUint8ArrayMemory0();
163
176
 
164
- let offset = 0;
177
+ let offset = 0;
165
178
 
166
- for (; offset < len; offset++) {
167
- const code = arg.charCodeAt(offset);
168
- if (code > 0x7F) break;
169
- mem[ptr + offset] = code;
179
+ for (; offset < len; offset++) {
180
+ const code = arg.charCodeAt(offset);
181
+ if (code > 0x7f) break;
182
+ mem[ptr + offset] = code;
183
+ }
184
+ if (offset !== len) {
185
+ if (offset !== 0) {
186
+ arg = arg.slice(offset);
170
187
  }
171
- if (offset !== len) {
172
- if (offset !== 0) {
173
- arg = arg.slice(offset);
174
- }
175
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
176
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
177
- const ret = cachedTextEncoder.encodeInto(arg, view);
188
+ ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
189
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
190
+ const ret = cachedTextEncoder.encodeInto(arg, view);
178
191
 
179
- offset += ret.written;
180
- ptr = realloc(ptr, len, offset, 1) >>> 0;
181
- }
192
+ offset += ret.written;
193
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
194
+ }
182
195
 
183
- WASM_VECTOR_LEN = offset;
184
- return ptr;
196
+ WASM_VECTOR_LEN = offset;
197
+ return ptr;
185
198
  }
186
199
 
187
200
  function takeFromExternrefTable0(idx) {
188
- const value = wasm.__wbindgen_externrefs.get(idx);
189
- wasm.__externref_table_dealloc(idx);
190
- return value;
201
+ const value = wasm.__wbindgen_externrefs.get(idx);
202
+ wasm.__externref_table_dealloc(idx);
203
+ return value;
191
204
  }
192
205
 
193
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
206
+ let cachedTextDecoder = new TextDecoder("utf-8", {
207
+ ignoreBOM: true,
208
+ fatal: true,
209
+ });
194
210
  cachedTextDecoder.decode();
195
211
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
196
212
  let numBytesDecoded = 0;
197
213
  function decodeText(ptr, len) {
198
- numBytesDecoded += len;
199
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
200
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
201
- cachedTextDecoder.decode();
202
- numBytesDecoded = len;
203
- }
204
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
214
+ numBytesDecoded += len;
215
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
216
+ cachedTextDecoder = new TextDecoder("utf-8", {
217
+ ignoreBOM: true,
218
+ fatal: true,
219
+ });
220
+ cachedTextDecoder.decode();
221
+ numBytesDecoded = len;
222
+ }
223
+ return cachedTextDecoder.decode(
224
+ getUint8ArrayMemory0().subarray(ptr, ptr + len),
225
+ );
205
226
  }
206
227
 
207
228
  const cachedTextEncoder = new TextEncoder();
208
229
 
209
- if (!('encodeInto' in cachedTextEncoder)) {
210
- cachedTextEncoder.encodeInto = function (arg, view) {
211
- const buf = cachedTextEncoder.encode(arg);
212
- view.set(buf);
213
- return {
214
- read: arg.length,
215
- written: buf.length
216
- };
217
- }
230
+ if (!("encodeInto" in cachedTextEncoder)) {
231
+ cachedTextEncoder.encodeInto = function (arg, view) {
232
+ const buf = cachedTextEncoder.encode(arg);
233
+ view.set(buf);
234
+ return {
235
+ read: arg.length,
236
+ written: buf.length,
237
+ };
238
+ };
218
239
  }
219
240
 
220
241
  let WASM_VECTOR_LEN = 0;
221
242
 
222
- const LayoutFinalization = (typeof FinalizationRegistry === 'undefined')
243
+ const LayoutFinalization =
244
+ typeof FinalizationRegistry === "undefined"
245
+ ? { register: () => {}, unregister: () => {} }
246
+ : new FinalizationRegistry((ptr) => wasm.__wbg_layout_free(ptr >>> 0, 1));
247
+
248
+ const StyleFinalization =
249
+ typeof FinalizationRegistry === "undefined"
223
250
  ? { register: () => {}, unregister: () => {} }
224
- : new FinalizationRegistry(ptr => wasm.__wbg_layout_free(ptr >>> 0, 1));
251
+ : new FinalizationRegistry((ptr) => wasm.__wbg_style_free(ptr >>> 0, 1));
225
252
 
226
- const StyleFinalization = (typeof FinalizationRegistry === 'undefined')
253
+ const TaffyErrorFinalization =
254
+ typeof FinalizationRegistry === "undefined"
227
255
  ? { register: () => {}, unregister: () => {} }
228
- : new FinalizationRegistry(ptr => wasm.__wbg_style_free(ptr >>> 0, 1));
256
+ : new FinalizationRegistry((ptr) =>
257
+ wasm.__wbg_taffyerror_free(ptr >>> 0, 1),
258
+ );
229
259
 
230
- const TaffyTreeFinalization = (typeof FinalizationRegistry === 'undefined')
260
+ const TaffyTreeFinalization =
261
+ typeof FinalizationRegistry === "undefined"
231
262
  ? { register: () => {}, unregister: () => {} }
232
- : new FinalizationRegistry(ptr => wasm.__wbg_taffytree_free(ptr >>> 0, 1));
263
+ : new FinalizationRegistry((ptr) =>
264
+ wasm.__wbg_taffytree_free(ptr >>> 0, 1),
265
+ );
233
266
 
234
267
  /**
235
- * Multi-line content alignment enum (Align Content)
268
+ * Multi-line content alignment enumeration
269
+ *
270
+ * Controls the distribution of space between and around content items along the cross axis
271
+ * in a multi-line flex container. This corresponds to the CSS `align-content` property.
272
+ *
273
+ * **Note**: This property only has effect when `flex-wrap` is set to `Wrap` or `WrapReverse`.
236
274
  *
237
- * Controls spacing distribution between lines in a multi-line flex container.
238
- * Corresponds to CSS `align-content` property. Only effective when `flex-wrap: wrap`.
275
+ * @example
276
+ * ```typescript
277
+ * import { AlignContent, FlexWrap } from 'taffy-js';
239
278
  *
240
- * # Variants
241
- * - `SpaceBetween`: Lines evenly distributed, first/last lines flush with edges
242
- * - `SpaceAround`: Equal space on both sides of each line
243
- * - `SpaceEvenly`: All spacing completely equal
279
+ * style.flexWrap = FlexWrap.Wrap;
280
+ * style.alignContent = AlignContent.SpaceBetween; // Distribute lines evenly
281
+ * ```
244
282
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
245
283
  */
246
284
  export const AlignContent = Object.freeze({
247
- Start: 0, "0": "Start",
248
- End: 1, "1": "End",
249
- FlexStart: 2, "2": "FlexStart",
250
- FlexEnd: 3, "3": "FlexEnd",
251
- Center: 4, "4": "Center",
252
- Stretch: 5, "5": "Stretch",
253
- SpaceBetween: 6, "6": "SpaceBetween",
254
- SpaceAround: 7, "7": "SpaceAround",
255
- SpaceEvenly: 8, "8": "SpaceEvenly",
285
+ /**
286
+ * Lines packed toward the start of the cross axis
287
+ */
288
+ Start: 0,
289
+ 0: "Start",
290
+ /**
291
+ * Lines packed toward the end of the cross axis
292
+ */
293
+ End: 1,
294
+ 1: "End",
295
+ /**
296
+ * Lines packed toward the start of the flex container
297
+ */
298
+ FlexStart: 2,
299
+ 2: "FlexStart",
300
+ /**
301
+ * Lines packed toward the end of the flex container
302
+ */
303
+ FlexEnd: 3,
304
+ 3: "FlexEnd",
305
+ /**
306
+ * Lines centered within the container
307
+ */
308
+ Center: 4,
309
+ 4: "Center",
310
+ /**
311
+ * Lines stretched to fill the container
312
+ */
313
+ Stretch: 5,
314
+ 5: "Stretch",
315
+ /**
316
+ * Lines evenly distributed with first/last at edges
317
+ */
318
+ SpaceBetween: 6,
319
+ 6: "SpaceBetween",
320
+ /**
321
+ * Lines evenly distributed with equal space around each
322
+ */
323
+ SpaceAround: 7,
324
+ 7: "SpaceAround",
325
+ /**
326
+ * Lines evenly distributed with equal space between each
327
+ */
328
+ SpaceEvenly: 8,
329
+ 8: "SpaceEvenly",
256
330
  });
257
331
 
258
332
  /**
259
- * Cross-axis alignment enum for children (Align Items)
333
+ * Cross-axis alignment enumeration for all children
334
+ *
335
+ * Defines the default alignment for all flex/grid items along the cross axis.
336
+ * This corresponds to the CSS `align-items` property.
260
337
  *
261
- * Defines how all children are aligned on the cross axis in a Flex/Grid container.
338
+ * @example
339
+ * ```typescript
340
+ * import { AlignItems } from 'taffy-js';
262
341
  *
263
- * # Variants
264
- * - `Start/FlexStart`: Align to cross axis start
265
- * - `End/FlexEnd`: Align to cross axis end
266
- * - `Center`: Center alignment
267
- * - `Baseline`: Baseline alignment (text baseline)
268
- * - `Stretch`: Stretch to fill container
342
+ * style.alignItems = AlignItems.Center; // Center items on cross axis
343
+ * style.alignItems = AlignItems.Stretch; // Stretch items to fill container
344
+ * ```
269
345
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
270
346
  */
271
347
  export const AlignItems = Object.freeze({
272
- Start: 0, "0": "Start",
273
- End: 1, "1": "End",
274
- FlexStart: 2, "2": "FlexStart",
275
- FlexEnd: 3, "3": "FlexEnd",
276
- Center: 4, "4": "Center",
277
- Baseline: 5, "5": "Baseline",
278
- Stretch: 6, "6": "Stretch",
348
+ /**
349
+ * Items aligned to the start of the cross axis
350
+ */
351
+ Start: 0,
352
+ 0: "Start",
353
+ /**
354
+ * Items aligned to the end of the cross axis
355
+ */
356
+ End: 1,
357
+ 1: "End",
358
+ /**
359
+ * Items aligned to the start of the flex container
360
+ */
361
+ FlexStart: 2,
362
+ 2: "FlexStart",
363
+ /**
364
+ * Items aligned to the end of the flex container
365
+ */
366
+ FlexEnd: 3,
367
+ 3: "FlexEnd",
368
+ /**
369
+ * Items centered along the cross axis
370
+ */
371
+ Center: 4,
372
+ 4: "Center",
373
+ /**
374
+ * Items aligned to their text baselines
375
+ */
376
+ Baseline: 5,
377
+ 5: "Baseline",
378
+ /**
379
+ * Items stretched to fill the container
380
+ */
381
+ Stretch: 6,
382
+ 6: "Stretch",
279
383
  });
280
384
 
281
385
  /**
282
- * Cross-axis alignment enum for single element (Align Self)
386
+ * Cross-axis alignment enumeration for a single element
387
+ *
388
+ * Overrides the parent's `align-items` value for a specific child element.
389
+ * This corresponds to the CSS `align-self` property.
283
390
  *
284
- * Overrides parent's `align-items` for a single child element's cross-axis alignment.
391
+ * @example
392
+ * ```typescript
393
+ * import { AlignSelf } from 'taffy-js';
285
394
  *
286
- * # Variants
287
- * - `Auto`: Inherit parent's `align-items` value
288
- * - Other values have same meaning as `AlignItems`
395
+ * style.alignSelf = AlignSelf.Auto; // Use parent's align-items
396
+ * style.alignSelf = AlignSelf.Center; // Override to center this item
397
+ * ```
289
398
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
290
399
  */
291
400
  export const AlignSelf = Object.freeze({
292
- Auto: 0, "0": "Auto",
293
- Start: 1, "1": "Start",
294
- End: 2, "2": "End",
295
- FlexStart: 3, "3": "FlexStart",
296
- FlexEnd: 4, "4": "FlexEnd",
297
- Center: 5, "5": "Center",
298
- Baseline: 6, "6": "Baseline",
299
- Stretch: 7, "7": "Stretch",
401
+ /**
402
+ * Inherits the parent container's `align-items` value
403
+ */
404
+ Auto: 0,
405
+ 0: "Auto",
406
+ /**
407
+ * Item aligned to the start of the cross axis
408
+ */
409
+ Start: 1,
410
+ 1: "Start",
411
+ /**
412
+ * Item aligned to the end of the cross axis
413
+ */
414
+ End: 2,
415
+ 2: "End",
416
+ /**
417
+ * Item aligned to the start of the flex container
418
+ */
419
+ FlexStart: 3,
420
+ 3: "FlexStart",
421
+ /**
422
+ * Item aligned to the end of the flex container
423
+ */
424
+ FlexEnd: 4,
425
+ 4: "FlexEnd",
426
+ /**
427
+ * Item centered along the cross axis
428
+ */
429
+ Center: 5,
430
+ 5: "Center",
431
+ /**
432
+ * Item aligned to its text baseline
433
+ */
434
+ Baseline: 6,
435
+ 6: "Baseline",
436
+ /**
437
+ * Item stretched to fill the container
438
+ */
439
+ Stretch: 7,
440
+ 7: "Stretch",
300
441
  });
301
442
 
302
443
  /**
303
- * Box sizing enum
444
+ * Box sizing enumeration
304
445
  *
305
446
  * Controls how the total width and height of an element is calculated.
447
+ * This corresponds to the CSS `box-sizing` property.
448
+ *
449
+ * @example
450
+ * ```typescript
451
+ * import { BoxSizing } from 'taffy-js';
306
452
  *
307
- * # Variants
308
- * - `BorderBox`: Width and height include content, padding, and border (default)
309
- * - `ContentBox`: Width and height include only the content
453
+ * style.boxSizing = BoxSizing.BorderBox; // Size includes padding and border
454
+ * style.boxSizing = BoxSizing.ContentBox; // Size is content only
455
+ * ```
310
456
  * @enum {0 | 1}
311
457
  */
312
458
  export const BoxSizing = Object.freeze({
313
- BorderBox: 0, "0": "BorderBox",
314
- ContentBox: 1, "1": "ContentBox",
459
+ /**
460
+ * The width and height properties include padding and border
461
+ */
462
+ BorderBox: 0,
463
+ 0: "BorderBox",
464
+ /**
465
+ * The width and height properties include only the content
466
+ */
467
+ ContentBox: 1,
468
+ 1: "ContentBox",
315
469
  });
316
470
 
317
471
  /**
318
- * Display mode enum
472
+ * Display mode enumeration
319
473
  *
320
- * Controls the layout algorithm type for an element. Corresponds to CSS `display` property.
474
+ * Controls the layout algorithm type for an element. This corresponds to the CSS `display` property
475
+ * and determines how an element and its children are laid out.
321
476
  *
322
- * # Variants
323
- * - `Block`: Block-level layout, element takes full width
324
- * - `Flex`: Flexbox layout, one-dimensional layout model
325
- * - `Grid`: CSS Grid layout, two-dimensional layout model
326
- * - `None`: Hidden, element does not participate in layout calculation
477
+ * @example
478
+ * ```typescript
479
+ * import { Display } from 'taffy-js';
480
+ *
481
+ * style.display = Display.Flex; // Enable flexbox layout
482
+ * style.display = Display.Grid; // Enable grid layout
483
+ * style.display = Display.None; // Hide element from layout
484
+ * ```
327
485
  * @enum {0 | 1 | 2 | 3}
328
486
  */
329
487
  export const Display = Object.freeze({
330
- Block: 0, "0": "Block",
331
- Flex: 1, "1": "Flex",
332
- Grid: 2, "2": "Grid",
333
- None: 3, "3": "None",
488
+ /**
489
+ * Block-level layout where element takes the full available width
490
+ */
491
+ Block: 0,
492
+ 0: "Block",
493
+ /**
494
+ * Flexbox layout for one-dimensional item arrangement
495
+ */
496
+ Flex: 1,
497
+ 1: "Flex",
498
+ /**
499
+ * CSS Grid layout for two-dimensional item arrangement
500
+ */
501
+ Grid: 2,
502
+ 2: "Grid",
503
+ /**
504
+ * Element is removed from layout calculation entirely
505
+ */
506
+ None: 3,
507
+ 3: "None",
334
508
  });
335
509
 
336
510
  /**
337
- * Flex main axis direction enum
511
+ * Flex direction enumeration
338
512
  *
339
- * Defines the direction children are laid out in a flex container. Corresponds to CSS `flex-direction` property.
513
+ * Defines the main axis direction for flex item layout. This corresponds to the CSS
514
+ * `flex-direction` property and determines how flex items are placed within the container.
340
515
  *
341
- * # Variants
342
- * - `Row`: Horizontal direction, left to right (LTR mode)
343
- * - `Column`: Vertical direction, top to bottom
344
- * - `RowReverse`: Horizontal reverse, right to left
345
- * - `ColumnReverse`: Vertical reverse, bottom to top
516
+ * @example
517
+ * ```typescript
518
+ * import { FlexDirection } from 'taffy-js';
519
+ *
520
+ * style.flexDirection = FlexDirection.Row; // Horizontal, left to right
521
+ * style.flexDirection = FlexDirection.Column; // Vertical, top to bottom
522
+ * ```
346
523
  * @enum {0 | 1 | 2 | 3}
347
524
  */
348
525
  export const FlexDirection = Object.freeze({
349
- Row: 0, "0": "Row",
350
- Column: 1, "1": "Column",
351
- RowReverse: 2, "2": "RowReverse",
352
- ColumnReverse: 3, "3": "ColumnReverse",
526
+ /**
527
+ * Main axis runs horizontally from left to right
528
+ */
529
+ Row: 0,
530
+ 0: "Row",
531
+ /**
532
+ * Main axis runs vertically from top to bottom
533
+ */
534
+ Column: 1,
535
+ 1: "Column",
536
+ /**
537
+ * Main axis runs horizontally from right to left
538
+ */
539
+ RowReverse: 2,
540
+ 2: "RowReverse",
541
+ /**
542
+ * Main axis runs vertically from bottom to top
543
+ */
544
+ ColumnReverse: 3,
545
+ 3: "ColumnReverse",
353
546
  });
354
547
 
355
548
  /**
356
- * Flex wrap mode enum
549
+ * Flex wrap mode enumeration
357
550
  *
358
- * Controls whether flex items wrap onto multiple lines. Corresponds to CSS `flex-wrap` property.
551
+ * Controls whether flex items wrap onto multiple lines when they overflow the container.
552
+ * This corresponds to the CSS `flex-wrap` property.
359
553
  *
360
- * # Variants
361
- * - `NoWrap`: No wrapping, all items compressed into single line/column
362
- * - `Wrap`: Automatic wrapping, items flow to next line when container overflows
363
- * - `WrapReverse`: Reverse wrapping, new lines appear above or to the left
554
+ * @example
555
+ * ```typescript
556
+ * import { FlexWrap } from 'taffy-js';
557
+ *
558
+ * style.flexWrap = FlexWrap.NoWrap; // All items on single line
559
+ * style.flexWrap = FlexWrap.Wrap; // Items wrap to new lines
560
+ * ```
364
561
  * @enum {0 | 1 | 2}
365
562
  */
366
563
  export const FlexWrap = Object.freeze({
367
- NoWrap: 0, "0": "NoWrap",
368
- Wrap: 1, "1": "Wrap",
369
- WrapReverse: 2, "2": "WrapReverse",
564
+ /**
565
+ * All flex items are placed on a single line
566
+ */
567
+ NoWrap: 0,
568
+ 0: "NoWrap",
569
+ /**
570
+ * Flex items wrap onto multiple lines from top to bottom
571
+ */
572
+ Wrap: 1,
573
+ 1: "Wrap",
574
+ /**
575
+ * Flex items wrap onto multiple lines from bottom to top
576
+ */
577
+ WrapReverse: 2,
578
+ 2: "WrapReverse",
370
579
  });
371
580
 
372
581
  /**
373
- * Main axis alignment enum (Justify Content)
582
+ * Main axis alignment enumeration
374
583
  *
375
- * Defines alignment and spacing distribution of children along the main axis.
376
- * Corresponds to CSS `justify-content` property.
584
+ * Defines how flex items are aligned and spaced along the main axis.
585
+ * This corresponds to the CSS `justify-content` property.
377
586
  *
378
- * # Variants
379
- * - `Start/FlexStart`: Align to main axis start
380
- * - `End/FlexEnd`: Align to main axis end
381
- * - `Center`: Center alignment
382
- * - `SpaceBetween`: First and last items flush with edges, remaining space distributed evenly
383
- * - `SpaceAround`: Equal space on both sides of each item
384
- * - `SpaceEvenly`: All spacing completely equal
587
+ * @example
588
+ * ```typescript
589
+ * import { JustifyContent } from 'taffy-js';
590
+ *
591
+ * style.justifyContent = JustifyContent.Center; // Center items
592
+ * style.justifyContent = JustifyContent.SpaceBetween; // Distribute evenly
593
+ * ```
385
594
  * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
386
595
  */
387
596
  export const JustifyContent = Object.freeze({
388
- Start: 0, "0": "Start",
389
- End: 1, "1": "End",
390
- FlexStart: 2, "2": "FlexStart",
391
- FlexEnd: 3, "3": "FlexEnd",
392
- Center: 4, "4": "Center",
393
- Stretch: 5, "5": "Stretch",
394
- SpaceBetween: 6, "6": "SpaceBetween",
395
- SpaceAround: 7, "7": "SpaceAround",
396
- SpaceEvenly: 8, "8": "SpaceEvenly",
597
+ /**
598
+ * Items packed toward the start of the main axis
599
+ */
600
+ Start: 0,
601
+ 0: "Start",
602
+ /**
603
+ * Items packed toward the end of the main axis
604
+ */
605
+ End: 1,
606
+ 1: "End",
607
+ /**
608
+ * Items packed toward the start of the flex container
609
+ */
610
+ FlexStart: 2,
611
+ 2: "FlexStart",
612
+ /**
613
+ * Items packed toward the end of the flex container
614
+ */
615
+ FlexEnd: 3,
616
+ 3: "FlexEnd",
617
+ /**
618
+ * Items centered along the main axis
619
+ */
620
+ Center: 4,
621
+ 4: "Center",
622
+ /**
623
+ * Items stretched along the main axis
624
+ */
625
+ Stretch: 5,
626
+ 5: "Stretch",
627
+ /**
628
+ * Items evenly distributed with first/last at edges
629
+ */
630
+ SpaceBetween: 6,
631
+ 6: "SpaceBetween",
632
+ /**
633
+ * Items evenly distributed with equal space around each
634
+ */
635
+ SpaceAround: 7,
636
+ 7: "SpaceAround",
637
+ /**
638
+ * Items evenly distributed with equal space between each
639
+ */
640
+ SpaceEvenly: 8,
641
+ 8: "SpaceEvenly",
397
642
  });
398
643
 
399
644
  /**
400
- * Layout result struct
645
+ * Computed layout result containing position, size, and spacing values for a node.
646
+ *
647
+ * This class wraps the native [`taffy::Layout`] and provides read-only access
648
+ * to all computed layout values. All dimensions are in pixels.
401
649
  *
402
- * A wrapper around `taffy::Layout` that provides WASM bindings.
403
- * Contains the computed layout values for a node after calling `computeLayout()`.
404
- * All values are in pixels.
650
+ * @example
651
+ * ```typescript
652
+ * const layout = tree.getLayout(node);
405
653
  *
406
- * # Properties
407
- * - `order`: Rendering order (higher = on top)
408
- * - `x`, `y`: Position of top-left corner relative to parent
409
- * - `width`, `height`: Computed dimensions
410
- * - `contentWidth`, `contentHeight`: Size of scrollable content
411
- * - `scrollbarWidth`, `scrollbarHeight`: Size allocated for scrollbars
412
- * - `borderLeft`, `borderRight`, `borderTop`, `borderBottom`: Border widths
413
- * - `paddingLeft`, `paddingRight`, `paddingTop`, `paddingBottom`: Padding sizes
414
- * - `marginLeft`, `marginRight`, `marginTop`, `marginBottom`: Margin sizes
654
+ * console.log("Position:", layout.x, layout.y);
655
+ * console.log("Size:", layout.width, layout.height);
656
+ * console.log("Content:", layout.contentWidth, layout.contentHeight);
657
+ * console.log("Padding:", layout.paddingTop, layout.paddingRight, layout.paddingBottom, layout.paddingLeft);
658
+ * console.log("Border:", layout.borderTop, layout.borderRight, layout.borderBottom, layout.borderLeft);
659
+ * console.log("Margin:", layout.marginTop, layout.marginRight, layout.marginBottom, layout.marginLeft);
660
+ * console.log("Scrollbar:", layout.scrollbarWidth, layout.scrollbarHeight);
661
+ * console.log("Order:", layout.order);
662
+ * ```
415
663
  */
416
664
  export class Layout {
417
- static __wrap(ptr) {
418
- ptr = ptr >>> 0;
419
- const obj = Object.create(Layout.prototype);
420
- obj.__wbg_ptr = ptr;
421
- LayoutFinalization.register(obj, obj.__wbg_ptr, obj);
422
- return obj;
423
- }
424
- __destroy_into_raw() {
425
- const ptr = this.__wbg_ptr;
426
- this.__wbg_ptr = 0;
427
- LayoutFinalization.unregister(this);
428
- return ptr;
429
- }
430
- free() {
431
- const ptr = this.__destroy_into_raw();
432
- wasm.__wbg_layout_free(ptr, 0);
433
- }
434
- /**
435
- * Gets the top border width.
436
- * @returns {number}
437
- */
438
- get borderTop() {
439
- const ret = wasm.layout_borderTop(this.__wbg_ptr);
440
- return ret;
441
- }
442
- /**
443
- * Gets the top margin.
444
- * @returns {number}
445
- */
446
- get marginTop() {
447
- const ret = wasm.layout_marginTop(this.__wbg_ptr);
448
- return ret;
449
- }
450
- /**
451
- * Gets the left border width.
452
- * @returns {number}
453
- */
454
- get borderLeft() {
455
- const ret = wasm.layout_borderLeft(this.__wbg_ptr);
456
- return ret;
457
- }
458
- /**
459
- * Gets the left margin.
460
- * @returns {number}
461
- */
462
- get marginLeft() {
463
- const ret = wasm.layout_marginLeft(this.__wbg_ptr);
464
- return ret;
465
- }
466
- /**
467
- * Gets the top padding.
468
- * @returns {number}
469
- */
470
- get paddingTop() {
471
- const ret = wasm.layout_paddingTop(this.__wbg_ptr);
472
- return ret;
473
- }
474
- /**
475
- * Gets the right border width.
476
- * @returns {number}
477
- */
478
- get borderRight() {
479
- const ret = wasm.layout_borderRight(this.__wbg_ptr);
480
- return ret;
481
- }
482
- /**
483
- * Gets the right margin.
484
- * @returns {number}
485
- */
486
- get marginRight() {
487
- const ret = wasm.layout_marginRight(this.__wbg_ptr);
488
- return ret;
489
- }
490
- /**
491
- * Gets the left padding.
492
- * @returns {number}
493
- */
494
- get paddingLeft() {
495
- const ret = wasm.layout_paddingLeft(this.__wbg_ptr);
496
- return ret;
497
- }
498
- /**
499
- * Gets the bottom border width.
500
- * @returns {number}
501
- */
502
- get borderBottom() {
503
- const ret = wasm.layout_borderBottom(this.__wbg_ptr);
504
- return ret;
505
- }
506
- /**
507
- * Gets the width of the scrollable content.
508
- * @returns {number}
509
- */
510
- get contentWidth() {
511
- const ret = wasm.layout_contentWidth(this.__wbg_ptr);
512
- return ret;
513
- }
514
- /**
515
- * Gets the bottom margin.
516
- * @returns {number}
517
- */
518
- get marginBottom() {
519
- const ret = wasm.layout_marginBottom(this.__wbg_ptr);
520
- return ret;
521
- }
522
- /**
523
- * Gets the right padding.
524
- * @returns {number}
525
- */
526
- get paddingRight() {
527
- const ret = wasm.layout_paddingRight(this.__wbg_ptr);
528
- return ret;
529
- }
530
- /**
531
- * Gets the height of the scrollable content.
532
- * @returns {number}
533
- */
534
- get contentHeight() {
535
- const ret = wasm.layout_contentHeight(this.__wbg_ptr);
536
- return ret;
537
- }
538
- /**
539
- * Gets the bottom padding.
540
- * @returns {number}
541
- */
542
- get paddingBottom() {
543
- const ret = wasm.layout_paddingBottom(this.__wbg_ptr);
544
- return ret;
545
- }
546
- /**
547
- * Gets the width of the vertical scrollbar.
548
- * @returns {number}
549
- */
550
- get scrollbarWidth() {
551
- const ret = wasm.layout_scrollbarWidth(this.__wbg_ptr);
552
- return ret;
553
- }
554
- /**
555
- * Gets the height of the horizontal scrollbar.
556
- * @returns {number}
557
- */
558
- get scrollbarHeight() {
559
- const ret = wasm.layout_scrollbarHeight(this.__wbg_ptr);
560
- return ret;
561
- }
562
- /**
563
- * Gets the x coordinate of the node's top-left corner.
564
- * @returns {number}
565
- */
566
- get x() {
567
- const ret = wasm.layout_x(this.__wbg_ptr);
568
- return ret;
569
- }
570
- /**
571
- * Gets the y coordinate of the node's top-left corner.
572
- * @returns {number}
573
- */
574
- get y() {
575
- const ret = wasm.layout_y(this.__wbg_ptr);
576
- return ret;
577
- }
578
- /**
579
- * Gets the rendering order of the node.
580
- * @returns {number}
581
- */
582
- get order() {
583
- const ret = wasm.layout_order(this.__wbg_ptr);
584
- return ret >>> 0;
585
- }
586
- /**
587
- * Gets the computed width of the node.
588
- * @returns {number}
589
- */
590
- get width() {
591
- const ret = wasm.layout_width(this.__wbg_ptr);
592
- return ret;
593
- }
594
- /**
595
- * Gets the computed height of the node.
596
- * @returns {number}
597
- */
598
- get height() {
599
- const ret = wasm.layout_height(this.__wbg_ptr);
600
- return ret;
601
- }
665
+ static __wrap(ptr) {
666
+ ptr = ptr >>> 0;
667
+ const obj = Object.create(Layout.prototype);
668
+ obj.__wbg_ptr = ptr;
669
+ LayoutFinalization.register(obj, obj.__wbg_ptr, obj);
670
+ return obj;
671
+ }
672
+ __destroy_into_raw() {
673
+ const ptr = this.__wbg_ptr;
674
+ this.__wbg_ptr = 0;
675
+ LayoutFinalization.unregister(this);
676
+ return ptr;
677
+ }
678
+ free() {
679
+ const ptr = this.__destroy_into_raw();
680
+ wasm.__wbg_layout_free(ptr, 0);
681
+ }
682
+ /**
683
+ * Gets the top border width
684
+ *
685
+ * @returns - The computed top border width in pixels
686
+ * @returns {number}
687
+ */
688
+ get borderTop() {
689
+ const ret = wasm.layout_borderTop(this.__wbg_ptr);
690
+ return ret;
691
+ }
692
+ /**
693
+ * Gets the top margin
694
+ *
695
+ * @returns - The computed top margin in pixels
696
+ * @returns {number}
697
+ */
698
+ get marginTop() {
699
+ const ret = wasm.layout_marginTop(this.__wbg_ptr);
700
+ return ret;
701
+ }
702
+ /**
703
+ * Gets the left border width
704
+ *
705
+ * @returns - The computed left border width in pixels
706
+ * @returns {number}
707
+ */
708
+ get borderLeft() {
709
+ const ret = wasm.layout_borderLeft(this.__wbg_ptr);
710
+ return ret;
711
+ }
712
+ /**
713
+ * Gets the left margin
714
+ *
715
+ * @returns - The computed left margin in pixels
716
+ * @returns {number}
717
+ */
718
+ get marginLeft() {
719
+ const ret = wasm.layout_marginLeft(this.__wbg_ptr);
720
+ return ret;
721
+ }
722
+ /**
723
+ * Gets the top padding
724
+ *
725
+ * @returns - The computed top padding in pixels
726
+ * @returns {number}
727
+ */
728
+ get paddingTop() {
729
+ const ret = wasm.layout_paddingTop(this.__wbg_ptr);
730
+ return ret;
731
+ }
732
+ /**
733
+ * Gets the right border width
734
+ *
735
+ * @returns - The computed right border width in pixels
736
+ * @returns {number}
737
+ */
738
+ get borderRight() {
739
+ const ret = wasm.layout_borderRight(this.__wbg_ptr);
740
+ return ret;
741
+ }
742
+ /**
743
+ * Gets the right margin
744
+ *
745
+ * @returns - The computed right margin in pixels
746
+ * @returns {number}
747
+ */
748
+ get marginRight() {
749
+ const ret = wasm.layout_marginRight(this.__wbg_ptr);
750
+ return ret;
751
+ }
752
+ /**
753
+ * Gets the left padding
754
+ *
755
+ * @returns - The computed left padding in pixels
756
+ * @returns {number}
757
+ */
758
+ get paddingLeft() {
759
+ const ret = wasm.layout_paddingLeft(this.__wbg_ptr);
760
+ return ret;
761
+ }
762
+ /**
763
+ * Gets the bottom border width
764
+ *
765
+ * @returns - The computed bottom border width in pixels
766
+ * @returns {number}
767
+ */
768
+ get borderBottom() {
769
+ const ret = wasm.layout_borderBottom(this.__wbg_ptr);
770
+ return ret;
771
+ }
772
+ /**
773
+ * Gets the width of the scrollable content
774
+ *
775
+ * If the node has overflow content, this represents the total
776
+ * width of all content (may exceed `width`).
777
+ *
778
+ * @returns - The content width in pixels
779
+ * @returns {number}
780
+ */
781
+ get contentWidth() {
782
+ const ret = wasm.layout_contentWidth(this.__wbg_ptr);
783
+ return ret;
784
+ }
785
+ /**
786
+ * Gets the bottom margin
787
+ *
788
+ * @returns - The computed bottom margin in pixels
789
+ * @returns {number}
790
+ */
791
+ get marginBottom() {
792
+ const ret = wasm.layout_marginBottom(this.__wbg_ptr);
793
+ return ret;
794
+ }
795
+ /**
796
+ * Gets the right padding
797
+ *
798
+ * @returns - The computed right padding in pixels
799
+ * @returns {number}
800
+ */
801
+ get paddingRight() {
802
+ const ret = wasm.layout_paddingRight(this.__wbg_ptr);
803
+ return ret;
804
+ }
805
+ /**
806
+ * Gets the height of the scrollable content
807
+ *
808
+ * If the node has overflow content, this represents the total
809
+ * height of all content (may exceed `height`).
810
+ *
811
+ * @returns - The content height in pixels
812
+ * @returns {number}
813
+ */
814
+ get contentHeight() {
815
+ const ret = wasm.layout_contentHeight(this.__wbg_ptr);
816
+ return ret;
817
+ }
818
+ /**
819
+ * Gets the bottom padding
820
+ *
821
+ * @returns - The computed bottom padding in pixels
822
+ * @returns {number}
823
+ */
824
+ get paddingBottom() {
825
+ const ret = wasm.layout_paddingBottom(this.__wbg_ptr);
826
+ return ret;
827
+ }
828
+ /**
829
+ * Gets the width of the vertical scrollbar
830
+ *
831
+ * When overflow is set to scroll, this indicates the space
832
+ * reserved for the vertical scrollbar.
833
+ *
834
+ * @returns - The scrollbar width in pixels (0 if no scrollbar)
835
+ * @returns {number}
836
+ */
837
+ get scrollbarWidth() {
838
+ const ret = wasm.layout_scrollbarWidth(this.__wbg_ptr);
839
+ return ret;
840
+ }
841
+ /**
842
+ * Gets the height of the horizontal scrollbar
843
+ *
844
+ * When overflow is set to scroll, this indicates the space
845
+ * reserved for the horizontal scrollbar.
846
+ *
847
+ * @returns - The scrollbar height in pixels (0 if no scrollbar)
848
+ * @returns {number}
849
+ */
850
+ get scrollbarHeight() {
851
+ const ret = wasm.layout_scrollbarHeight(this.__wbg_ptr);
852
+ return ret;
853
+ }
854
+ /**
855
+ * Gets the X coordinate of the node's top-left corner
856
+ *
857
+ * This value is relative to the node's parent. For the root node,
858
+ * this is always 0.
859
+ *
860
+ * @returns - The horizontal position in pixels
861
+ * @returns {number}
862
+ */
863
+ get x() {
864
+ const ret = wasm.layout_x(this.__wbg_ptr);
865
+ return ret;
866
+ }
867
+ /**
868
+ * Gets the Y coordinate of the node's top-left corner
869
+ *
870
+ * This value is relative to the node's parent. For the root node,
871
+ * this is always 0.
872
+ *
873
+ * @returns - The vertical position in pixels
874
+ * @returns {number}
875
+ */
876
+ get y() {
877
+ const ret = wasm.layout_y(this.__wbg_ptr);
878
+ return ret;
879
+ }
880
+ /**
881
+ * Gets the rendering order of the node
882
+ *
883
+ * This value determines the z-order for overlapping elements.
884
+ * Lower values are rendered first (behind higher values).
885
+ *
886
+ * @returns - The rendering order as an unsigned 32-bit integer
887
+ * @returns {number}
888
+ */
889
+ get order() {
890
+ const ret = wasm.layout_order(this.__wbg_ptr);
891
+ return ret >>> 0;
892
+ }
893
+ /**
894
+ * Gets the computed width of the node
895
+ *
896
+ * This is the final width after layout computation, including
897
+ * any constraints from min/max size or flex properties.
898
+ *
899
+ * @returns - The width in pixels
900
+ * @returns {number}
901
+ */
902
+ get width() {
903
+ const ret = wasm.layout_width(this.__wbg_ptr);
904
+ return ret;
905
+ }
906
+ /**
907
+ * Gets the computed height of the node
908
+ *
909
+ * This is the final height after layout computation, including
910
+ * any constraints from min/max size or flex properties.
911
+ *
912
+ * @returns - The height in pixels
913
+ * @returns {number}
914
+ */
915
+ get height() {
916
+ const ret = wasm.layout_height(this.__wbg_ptr);
917
+ return ret;
918
+ }
602
919
  }
603
920
  if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
604
921
 
605
922
  /**
606
- * Overflow handling enum
923
+ * Overflow handling enumeration
924
+ *
925
+ * Defines how content that exceeds the container boundaries is handled.
926
+ * This corresponds to the CSS `overflow` property.
607
927
  *
608
- * Defines how content that overflows container boundaries is handled.
609
- * Corresponds to CSS `overflow` property.
928
+ * @example
929
+ * ```typescript
930
+ * import { Overflow } from 'taffy-js';
610
931
  *
611
- * # Variants
612
- * - `Visible`: Content is not clipped
613
- * - `Hidden`: Content is clipped, overflow hidden
614
- * - `Scroll`: Always show scrollbars
615
- * - `Auto`: Show scrollbars when needed (internally mapped to Scroll)
932
+ * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
933
+ * ```
616
934
  * @enum {0 | 1 | 2 | 3}
617
935
  */
618
936
  export const Overflow = Object.freeze({
619
- Visible: 0, "0": "Visible",
620
- Hidden: 1, "1": "Hidden",
621
- Scroll: 2, "2": "Scroll",
622
- Auto: 3, "3": "Auto",
937
+ /**
938
+ * Content is not clipped and may render outside the container
939
+ */
940
+ Visible: 0,
941
+ 0: "Visible",
942
+ /**
943
+ * Content is clipped at the container boundary
944
+ */
945
+ Hidden: 1,
946
+ 1: "Hidden",
947
+ /**
948
+ * Always display scrollbars for scrollable content
949
+ */
950
+ Scroll: 2,
951
+ 2: "Scroll",
952
+ /**
953
+ * Display scrollbars only when content overflows (internally maps to Scroll)
954
+ */
955
+ Auto: 3,
956
+ 3: "Auto",
623
957
  });
624
958
 
625
959
  /**
626
- * Position mode enum
960
+ * Position mode enumeration
961
+ *
962
+ * Controls how an element is positioned within its parent container.
963
+ * This corresponds to the CSS `position` property.
627
964
  *
628
- * Controls element positioning method. Corresponds to CSS `position` property.
965
+ * @example
966
+ * ```typescript
967
+ * import { Position } from 'taffy-js';
629
968
  *
630
- * # Variants
631
- * - `Relative`: Relative positioning, element stays in normal document flow
632
- * - `Absolute`: Absolute positioning, element removed from flow, positioned relative to nearest positioned ancestor
969
+ * style.position = Position.Relative; // Normal document flow
970
+ * style.position = Position.Absolute; // Removed from flow, uses inset values
971
+ * ```
633
972
  * @enum {0 | 1}
634
973
  */
635
974
  export const Position = Object.freeze({
636
- Relative: 0, "0": "Relative",
637
- Absolute: 1, "1": "Absolute",
975
+ /**
976
+ * Element participates in normal document flow
977
+ */
978
+ Relative: 0,
979
+ 0: "Relative",
980
+ /**
981
+ * Element is positioned relative to its nearest positioned ancestor
982
+ */
983
+ Absolute: 1,
984
+ 1: "Absolute",
638
985
  });
639
986
 
640
987
  /**
641
- * Node Style struct
642
- *
643
- * Configuration object containing all CSS layout properties.
644
- * Access properties via getter/setter methods.
988
+ * CSS layout configuration for a node, including flexbox, sizing, spacing, and alignment properties.
645
989
  *
646
- * # Supported Property Categories
990
+ * This class holds all CSS layout properties for a node. Create an instance with
991
+ * `new Style()` and configure properties before passing to `TaffyTree.newLeaf()`.
647
992
  *
648
- * ## Layout Mode
649
- * - `display`: Display mode (Flex/Grid/Block/None)
650
- * - `position`: Position mode (Relative/Absolute)
651
- *
652
- * ## Flexbox Properties
653
- * - `flex_direction`: Main axis direction
654
- * - `flex_wrap`: Wrap behavior
655
- * - `flex_grow`: Grow factor
656
- * - `flex_shrink`: Shrink factor
657
- * - `flex_basis`: Initial size
658
- *
659
- * ## Alignment Properties
660
- * - `align_items`, `align_self`, `align_content`
661
- * - `justify_content`
662
- *
663
- * ## Sizing Properties
664
- * - `size`, `min_size`, `max_size`
665
- * - `aspect_ratio`: Width-to-height ratio
666
- *
667
- * ## Spacing Properties
668
- * - `margin`, `padding`, `border`
669
- * - `gap`: Gap between children
670
- * - `inset`: Absolute positioning offsets
993
+ * @defaultValue
994
+ * When created, all properties are set to their CSS default values:
995
+ * - `display`: `Display.Block`
996
+ * - `position`: `Position.Relative`
997
+ * - `flexDirection`: `FlexDirection.Row`
998
+ * - `flexWrap`: `FlexWrap.NoWrap`
999
+ * - `flexGrow`: `0`
1000
+ * - `flexShrink`: `1`
1001
+ * - All alignment properties: `undefined` (use default behavior)
1002
+ * - All dimensions: `"Auto"`
1003
+ * - All spacing: `{ Length: 0 }`
671
1004
  */
672
1005
  export class Style {
673
- static __wrap(ptr) {
674
- ptr = ptr >>> 0;
675
- const obj = Object.create(Style.prototype);
676
- obj.__wbg_ptr = ptr;
677
- StyleFinalization.register(obj, obj.__wbg_ptr, obj);
678
- return obj;
679
- }
680
- __destroy_into_raw() {
681
- const ptr = this.__wbg_ptr;
682
- this.__wbg_ptr = 0;
683
- StyleFinalization.unregister(this);
684
- return ptr;
685
- }
686
- free() {
687
- const ptr = this.__destroy_into_raw();
688
- wasm.__wbg_style_free(ptr, 0);
689
- }
690
- /**
691
- * Gets the align-self property. Overrides parent's align-items for this element.
692
- * Returns AlignSelf.Auto if not explicitly set.
693
- * @returns {AlignSelf | undefined}
694
- */
695
- get align_self() {
696
- const ret = wasm.style_align_self(this.__wbg_ptr);
697
- return ret === 8 ? undefined : ret;
698
- }
699
- /**
700
- * Gets the box sizing mode (BorderBox or ContentBox).
701
- * @returns {BoxSizing}
702
- */
703
- get box_sizing() {
704
- const ret = wasm.style_box_sizing(this.__wbg_ptr);
705
- return ret;
706
- }
707
- /**
708
- * Gets the flex-basis as a JsDimension (Length, Percent, or Auto).
709
- * Flex-basis defines the initial main size before grow/shrink.
710
- * @returns {any}
711
- */
712
- get flex_basis() {
713
- const ret = wasm.style_flex_basis(this.__wbg_ptr);
714
- return ret;
715
- }
716
- /**
717
- * Sets the border width for all four edges.
718
- * Accepts { left, right, top, bottom } with LengthPercentage values.
719
- * @param {any} val
720
- */
721
- set border(val) {
722
- wasm.style_set_border(this.__wbg_ptr, val);
723
- }
724
- /**
725
- * Sets the margin for all four edges.
726
- * Accepts { left, right, top, bottom } with LengthPercentageAuto values.
727
- * @param {any} val
728
- */
729
- set margin(val) {
730
- wasm.style_set_margin(this.__wbg_ptr, val);
731
- }
732
- /**
733
- * Gets the align-items property. Controls cross-axis alignment of children.
734
- * @returns {AlignItems | undefined}
735
- */
736
- get align_items() {
737
- const ret = wasm.style_align_items(this.__wbg_ptr);
738
- return ret === 7 ? undefined : ret;
739
- }
740
- /**
741
- * Gets the flex shrink factor. Determines how much the item shrinks relative to siblings.
742
- * @returns {number}
743
- */
744
- get flex_shrink() {
745
- const ret = wasm.style_flex_shrink(this.__wbg_ptr);
746
- return ret;
747
- }
748
- /**
749
- * Sets the display mode. Controls which layout algorithm is used for children.
750
- * - `Display.Block`: Block layout
751
- * - `Display.Flex`: Flexbox layout
752
- * - `Display.Grid`: CSS Grid layout
753
- * - `Display.None`: Element is hidden and takes no space
754
- * @param {Display} val
755
- */
756
- set display(val) {
757
- wasm.style_set_display(this.__wbg_ptr, val);
758
- }
759
- /**
760
- * Sets the padding for all four edges.
761
- * Accepts { left, right, top, bottom } with LengthPercentage values.
762
- * @param {any} val
763
- */
764
- set padding(val) {
765
- wasm.style_set_padding(this.__wbg_ptr, val);
766
- }
767
- /**
768
- * Gets the aspect ratio (width / height). Returns None if not set.
769
- * @returns {number | undefined}
770
- */
771
- get aspect_ratio() {
772
- const ret = wasm.style_aspect_ratio(this.__wbg_ptr);
773
- return ret === 0x100000001 ? undefined : ret;
774
- }
775
- /**
776
- * Sets the maximum size constraints.
777
- * @param {any} val
778
- */
779
- set max_size(val) {
780
- wasm.style_set_max_size(this.__wbg_ptr, val);
781
- }
782
- /**
783
- * Sets the minimum size constraints.
784
- * @param {any} val
785
- */
786
- set min_size(val) {
787
- wasm.style_set_min_size(this.__wbg_ptr, val);
788
- }
789
- /**
790
- * Sets the overflow behavior. Accepts {x: Overflow, y: Overflow}.
791
- * @param {any} val
792
- */
793
- set overflow(val) {
794
- wasm.style_set_overflow(this.__wbg_ptr, val);
795
- }
796
- /**
797
- * Sets the position mode.
798
- * - `Position.Relative`: Normal document flow
799
- * - `Position.Absolute`: Removed from flow, positioned via inset properties
800
- * @param {Position} val
801
- */
802
- set position(val) {
803
- wasm.style_set_position(this.__wbg_ptr, val);
804
- }
805
- /**
806
- * Gets the align-content property. Controls spacing between lines in multi-line flex.
807
- * @returns {AlignContent | undefined}
808
- */
809
- get align_content() {
810
- const ret = wasm.style_align_content(this.__wbg_ptr);
811
- return ret === 9 ? undefined : ret;
812
- }
813
- /**
814
- * Sets the flex grow factor. A value of 0 means the item won't grow.
815
- * Higher values mean more growth relative to other items.
816
- * @param {number} val
817
- */
818
- set flex_grow(val) {
819
- wasm.style_set_flex_grow(this.__wbg_ptr, val);
820
- }
821
- /**
822
- * Sets the flex wrap mode. Controls whether items wrap to new lines.
823
- * @param {FlexWrap} val
824
- */
825
- set flex_wrap(val) {
826
- wasm.style_set_flex_wrap(this.__wbg_ptr, val);
827
- }
828
- /**
829
- * Gets the flex direction (Row, Column, RowReverse, ColumnReverse).
830
- * @returns {FlexDirection}
831
- */
832
- get flex_direction() {
833
- const ret = wasm.style_flex_direction(this.__wbg_ptr);
834
- return ret;
835
- }
836
- /**
837
- * Sets the align-self property. Use AlignSelf.Auto to inherit from parent.
838
- * @param {AlignSelf | null} [val]
839
- */
840
- set align_self(val) {
841
- wasm.style_set_align_self(this.__wbg_ptr, isLikeNone(val) ? 8 : val);
842
- }
843
- /**
844
- * Sets the box sizing mode.
845
- * - `BoxSizing.BorderBox`: Width and height include content, padding, and border (default)
846
- * - `BoxSizing.ContentBox`: Width and height include only the content
847
- * @param {BoxSizing} val
848
- */
849
- set box_sizing(val) {
850
- wasm.style_set_box_sizing(this.__wbg_ptr, val);
851
- }
852
- /**
853
- * Sets the flex-basis. Accepts { Length: number } | { Percent: number } | "Auto".
854
- * @param {any} val
855
- */
856
- set flex_basis(val) {
857
- wasm.style_set_flex_basis(this.__wbg_ptr, val);
858
- }
859
- /**
860
- * Gets the justify-content property. Controls main-axis alignment and spacing.
861
- * @returns {JustifyContent | undefined}
862
- */
863
- get justify_content() {
864
- const ret = wasm.style_justify_content(this.__wbg_ptr);
865
- return ret === 9 ? undefined : ret;
866
- }
867
- /**
868
- * Sets the align-items property. Affects all children's cross-axis alignment.
869
- * @param {AlignItems | null} [val]
870
- */
871
- set align_items(val) {
872
- wasm.style_set_align_items(this.__wbg_ptr, isLikeNone(val) ? 7 : val);
873
- }
874
- /**
875
- * Sets the flex shrink factor. A value of 0 prevents shrinking.
876
- * Default is 1.0 for flex items.
877
- * @param {number} val
878
- */
879
- set flex_shrink(val) {
880
- wasm.style_set_flex_shrink(this.__wbg_ptr, val);
881
- }
882
- /**
883
- * Sets the aspect ratio. For example, 16/9 = 1.777... for widescreen.
884
- * Set to None to remove the constraint.
885
- * @param {number | null} [val]
886
- */
887
- set aspect_ratio(val) {
888
- wasm.style_set_aspect_ratio(this.__wbg_ptr, isLikeNone(val) ? 0x100000001 : Math.fround(val));
889
- }
890
- /**
891
- * Sets the align-content property. Only effective when flex-wrap is enabled.
892
- * @param {AlignContent | null} [val]
893
- */
894
- set align_content(val) {
895
- wasm.style_set_align_content(this.__wbg_ptr, isLikeNone(val) ? 9 : val);
896
- }
897
- /**
898
- * Sets the flex direction. Defines the main axis for flex item layout.
899
- * @param {FlexDirection} val
900
- */
901
- set flex_direction(val) {
902
- wasm.style_set_flex_direction(this.__wbg_ptr, val);
903
- }
904
- /**
905
- * Sets the justify-content property. Distributes space along the main axis.
906
- * @param {JustifyContent | null} [val]
907
- */
908
- set justify_content(val) {
909
- wasm.style_set_justify_content(this.__wbg_ptr, isLikeNone(val) ? 9 : val);
910
- }
911
- /**
912
- * Gets the gap between children as a JsSize<JsLengthPercentage>.
913
- * Used in Flex and Grid layouts to add spacing between items.
914
- * - width: column gap (horizontal spacing)
915
- * - height: row gap (vertical spacing)
916
- * @returns {any}
917
- */
918
- get gap() {
919
- const ret = wasm.style_gap(this.__wbg_ptr);
920
- return ret;
921
- }
922
- /**
923
- * Creates a new Style instance with default values.
924
- *
925
- * All properties are initialized to their CSS default values:
926
- * - display: Block
927
- * - position: Relative
928
- * - flex_direction: Row
929
- * - All dimensions: Auto
930
- * - All spacing (margin, padding, border): 0
931
- *
932
- * # Returns
933
- * A new Style instance with default configuration.
934
- *
935
- * # Example
936
- * ```javascript
937
- * const style = new Style();
938
- * style.display = Display.Flex;
939
- * ```
940
- */
941
- constructor() {
942
- const ret = wasm.style_new();
943
- this.__wbg_ptr = ret >>> 0;
944
- StyleFinalization.register(this, this.__wbg_ptr, this);
945
- return this;
946
- }
947
- /**
948
- * Gets the size (width, height) as a JsSize<JsDimension>.
949
- * Each dimension can be Length, Percent, or Auto.
950
- * @returns {any}
951
- */
952
- get size() {
953
- const ret = wasm.style_size(this.__wbg_ptr);
954
- return ret;
955
- }
956
- /**
957
- * Gets the inset (absolute positioning offsets) as a JsRect<JsLengthPercentageAuto>.
958
- * Only effective when position is Absolute.
959
- * Defines the distance from each edge of the containing block.
960
- * @returns {any}
961
- */
962
- get inset() {
963
- const ret = wasm.style_inset(this.__wbg_ptr);
964
- return ret;
965
- }
966
- /**
967
- * Gets the border width as a JsRect<JsLengthPercentage>.
968
- * Border width defines the thickness of element borders.
969
- * Supports Length or Percent for each edge (not Auto).
970
- * @returns {any}
971
- */
972
- get border() {
973
- const ret = wasm.style_border(this.__wbg_ptr);
974
- return ret;
975
- }
976
- /**
977
- * Gets the margin as a JsRect<JsLengthPercentageAuto>.
978
- * Margin is the outer spacing around the element's border.
979
- * Supports Length, Percent, or Auto for each edge.
980
- * @returns {any}
981
- */
982
- get margin() {
983
- const ret = wasm.style_margin(this.__wbg_ptr);
984
- return ret;
985
- }
986
- /**
987
- * Gets the display mode (Block, Flex, Grid, or None).
988
- * @returns {Display}
989
- */
990
- get display() {
991
- const ret = wasm.style_display(this.__wbg_ptr);
992
- return ret;
993
- }
994
- /**
995
- * Gets the padding as a JsRect<JsLengthPercentage>.
996
- * Padding is the inner spacing between the border and content.
997
- * Supports Length or Percent for each edge (not Auto).
998
- * @returns {any}
999
- */
1000
- get padding() {
1001
- const ret = wasm.style_padding(this.__wbg_ptr);
1002
- return ret;
1003
- }
1004
- /**
1005
- * Sets the gap between children.
1006
- * Accepts { width: column_gap, height: row_gap } with LengthPercentage values.
1007
- * @param {any} val
1008
- */
1009
- set gap(val) {
1010
- wasm.style_set_gap(this.__wbg_ptr, val);
1011
- }
1012
- /**
1013
- * Gets the maximum size constraints as a JsSize<JsDimension>.
1014
- * Prevents the element from growing beyond these values.
1015
- * @returns {any}
1016
- */
1017
- get max_size() {
1018
- const ret = wasm.style_max_size(this.__wbg_ptr);
1019
- return ret;
1020
- }
1021
- /**
1022
- * Gets the minimum size constraints as a JsSize<JsDimension>.
1023
- * Prevents the element from shrinking below these values.
1024
- * @returns {any}
1025
- */
1026
- get min_size() {
1027
- const ret = wasm.style_min_size(this.__wbg_ptr);
1028
- return ret;
1029
- }
1030
- /**
1031
- * Gets the overflow behavior as a JS object with {x, y} properties.
1032
- * @returns {any}
1033
- */
1034
- get overflow() {
1035
- const ret = wasm.style_overflow(this.__wbg_ptr);
1036
- return ret;
1037
- }
1038
- /**
1039
- * Gets the position mode (Relative or Absolute).
1040
- * @returns {Position}
1041
- */
1042
- get position() {
1043
- const ret = wasm.style_position(this.__wbg_ptr);
1044
- return ret;
1045
- }
1046
- /**
1047
- * Sets the size (width, height).
1048
- * Accepts { width: Dimension, height: Dimension } where Dimension is Length/Percent/Auto.
1049
- * Logs an error to console if parsing fails.
1050
- * @param {any} val
1051
- */
1052
- set size(val) {
1053
- wasm.style_set_size(this.__wbg_ptr, val);
1054
- }
1055
- /**
1056
- * Gets the flex grow factor. Determines how much the item grows relative to siblings.
1057
- * @returns {number}
1058
- */
1059
- get flex_grow() {
1060
- const ret = wasm.style_flex_grow(this.__wbg_ptr);
1061
- return ret;
1062
- }
1063
- /**
1064
- * Gets the flex wrap mode (NoWrap, Wrap, WrapReverse).
1065
- * @returns {FlexWrap}
1066
- */
1067
- get flex_wrap() {
1068
- const ret = wasm.style_flex_wrap(this.__wbg_ptr);
1069
- return ret;
1070
- }
1071
- /**
1072
- * Sets the inset for absolute positioning.
1073
- * Accepts { left, right, top, bottom } with LengthPercentageAuto values.
1074
- * @param {any} val
1075
- */
1076
- set inset(val) {
1077
- wasm.style_set_inset(this.__wbg_ptr, val);
1078
- }
1006
+ static __wrap(ptr) {
1007
+ ptr = ptr >>> 0;
1008
+ const obj = Object.create(Style.prototype);
1009
+ obj.__wbg_ptr = ptr;
1010
+ StyleFinalization.register(obj, obj.__wbg_ptr, obj);
1011
+ return obj;
1012
+ }
1013
+ __destroy_into_raw() {
1014
+ const ptr = this.__wbg_ptr;
1015
+ this.__wbg_ptr = 0;
1016
+ StyleFinalization.unregister(this);
1017
+ return ptr;
1018
+ }
1019
+ free() {
1020
+ const ptr = this.__destroy_into_raw();
1021
+ wasm.__wbg_style_free(ptr, 0);
1022
+ }
1023
+ /**
1024
+ * Gets the align-self property
1025
+ *
1026
+ * Overrides the parent's align-items for this specific element.
1027
+ *
1028
+ * @returns - The current [`AlignSelf`](JsAlignSelf) value (returns `Auto` if not set)
1029
+ * @returns {AlignSelf | undefined}
1030
+ */
1031
+ get alignSelf() {
1032
+ const ret = wasm.style_alignSelf(this.__wbg_ptr);
1033
+ return ret === 8 ? undefined : ret;
1034
+ }
1035
+ /**
1036
+ * Gets the box sizing mode
1037
+ *
1038
+ * Determines whether padding and border are included in dimensions.
1039
+ *
1040
+ * @returns - The current [`BoxSizing`](JsBoxSizing) value
1041
+ *
1042
+ * @defaultValue `BoxSizing.BorderBox`
1043
+ * @returns {BoxSizing}
1044
+ */
1045
+ get boxSizing() {
1046
+ const ret = wasm.style_boxSizing(this.__wbg_ptr);
1047
+ return ret;
1048
+ }
1049
+ /**
1050
+ * Gets the flex-basis
1051
+ *
1052
+ * The initial size of a flex item before growing/shrinking.
1053
+ *
1054
+ * @returns - A `Dimension` value (`{ Length: n }`, `{ Percent: n }`, or `"Auto"`)
1055
+ * @returns {Dimension}
1056
+ */
1057
+ get flexBasis() {
1058
+ const ret = wasm.style_flexBasis(this.__wbg_ptr);
1059
+ return ret;
1060
+ }
1061
+ /**
1062
+ * Sets the border width
1063
+ *
1064
+ * @param val - A Rect object with LengthPercentage values
1065
+ *
1066
+ * @example
1067
+ * ```typescript
1068
+ * style.border = { left: { Length: 1 }, right: { Length: 1 }, top: { Length: 1 }, bottom: { Length: 1 } };
1069
+ * ```
1070
+ * @param {Rect<LengthPercentage>} val
1071
+ */
1072
+ set border(val) {
1073
+ wasm.style_set_border(this.__wbg_ptr, val);
1074
+ }
1075
+ /**
1076
+ * Sets the margin
1077
+ *
1078
+ * @param val - A Rect object with LengthPercentageAuto values
1079
+ *
1080
+ * @example
1081
+ * ```typescript
1082
+ * style.margin = { left: { Length: 10 }, right: { Length: 10 }, top: { Length: 5 }, bottom: { Length: 5 } };
1083
+ * ```
1084
+ * @param {Rect<LengthPercentageAuto>} val
1085
+ */
1086
+ set margin(val) {
1087
+ wasm.style_set_margin(this.__wbg_ptr, val);
1088
+ }
1089
+ /**
1090
+ * Gets the align-items property
1091
+ *
1092
+ * Defines the default alignment for all children on the cross axis.
1093
+ *
1094
+ * @returns - The current [`AlignItems`](JsAlignItems) value, or `undefined` if not set
1095
+ * @returns {AlignItems | undefined}
1096
+ */
1097
+ get alignItems() {
1098
+ const ret = wasm.style_alignItems(this.__wbg_ptr);
1099
+ return ret === 7 ? undefined : ret;
1100
+ }
1101
+ /**
1102
+ * Gets the flex shrink factor
1103
+ *
1104
+ * Determines how much the item shrinks relative to siblings when
1105
+ * there is insufficient space.
1106
+ *
1107
+ * @returns - The flex shrink factor (default: 1)
1108
+ * @returns {number}
1109
+ */
1110
+ get flexShrink() {
1111
+ const ret = wasm.style_flexShrink(this.__wbg_ptr);
1112
+ return ret;
1113
+ }
1114
+ /**
1115
+ * Sets the display mode
1116
+ *
1117
+ * @param val - The new display mode
1118
+ *
1119
+ *
1120
+ * @example
1121
+ *
1122
+ * ```typescript
1123
+ * style.display = Display.Flex;
1124
+ * ```
1125
+ * @param {Display} val
1126
+ */
1127
+ set display(val) {
1128
+ wasm.style_set_display(this.__wbg_ptr, val);
1129
+ }
1130
+ /**
1131
+ * Sets the padding
1132
+ *
1133
+ * @param val - A Rect object with LengthPercentage values
1134
+ *
1135
+ * @example
1136
+ * ```typescript
1137
+ * style.padding = { left: { Length: 20 }, right: { Length: 20 }, top: { Length: 10 }, bottom: { Length: 10 } };
1138
+ * ```
1139
+ * @param {Rect<LengthPercentage>} val
1140
+ */
1141
+ set padding(val) {
1142
+ wasm.style_set_padding(this.__wbg_ptr, val);
1143
+ }
1144
+ /**
1145
+ * Gets the aspect ratio
1146
+ *
1147
+ * The ratio of width to height. Used to maintain proportions.
1148
+ *
1149
+ * @returns - The aspect ratio value, or `undefined` if not set
1150
+ * @returns {number | undefined}
1151
+ */
1152
+ get aspectRatio() {
1153
+ const ret = wasm.style_aspectRatio(this.__wbg_ptr);
1154
+ return ret === 0x100000001 ? undefined : ret;
1155
+ }
1156
+ /**
1157
+ * Sets the maximum size constraints
1158
+ *
1159
+ * @param val - A Size object with maximum Dimension values
1160
+ *
1161
+ * @example
1162
+ * ```typescript
1163
+ * style.maxSize = { width: "MaxContent", height: { Length: 500 } };
1164
+ * ```
1165
+ * @param {Size<Dimension>} val
1166
+ */
1167
+ set maxSize(val) {
1168
+ wasm.style_set_maxSize(this.__wbg_ptr, val);
1169
+ }
1170
+ /**
1171
+ * Sets the minimum size constraints
1172
+ *
1173
+ * @param val - A Size object with minimum Dimension values
1174
+ *
1175
+ * @example
1176
+ * ```typescript
1177
+ * style.minSize = { width: { Length: 100 }, height: "Auto" };
1178
+ * ```
1179
+ * @param {Size<Dimension>} val
1180
+ */
1181
+ set minSize(val) {
1182
+ wasm.style_set_minSize(this.__wbg_ptr, val);
1183
+ }
1184
+ /**
1185
+ * Sets the overflow behavior
1186
+ *
1187
+ * @param val - An object with `x` and `y` overflow values
1188
+ *
1189
+ * @example
1190
+ * ```typescript
1191
+ * style.overflow = { x: Overflow.Hidden, y: Overflow.Scroll };
1192
+ * ```
1193
+ * @param {Point<Overflow>} val
1194
+ */
1195
+ set overflow(val) {
1196
+ wasm.style_set_overflow(this.__wbg_ptr, val);
1197
+ }
1198
+ /**
1199
+ * Sets the position mode
1200
+ *
1201
+ * @param val - The new position mode
1202
+ *
1203
+ *
1204
+ * @example
1205
+ *
1206
+ * ```typescript
1207
+ * style.position = Position.Absolute;
1208
+ * style.inset = { left: { Length: 10 }, top: { Length: 10 }, right: "Auto", bottom: "Auto" };
1209
+ * ```
1210
+ * @param {Position} val
1211
+ */
1212
+ set position(val) {
1213
+ wasm.style_set_position(this.__wbg_ptr, val);
1214
+ }
1215
+ /**
1216
+ * Gets the align-content property
1217
+ *
1218
+ * Controls distribution of space between lines in a multi-line flex container.
1219
+ *
1220
+ * @returns - The current [`AlignContent`](JsAlignContent) value, or `undefined` if not set
1221
+ * @returns {AlignContent | undefined}
1222
+ */
1223
+ get alignContent() {
1224
+ const ret = wasm.style_alignContent(this.__wbg_ptr);
1225
+ return ret === 9 ? undefined : ret;
1226
+ }
1227
+ /**
1228
+ * Sets the flex grow factor
1229
+ *
1230
+ * @param val - The new flex grow factor (must be >= 0)
1231
+ *
1232
+ * @example
1233
+ * ```typescript
1234
+ * style.flexGrow = 2;
1235
+ * ```
1236
+ * @param {number} val
1237
+ */
1238
+ set flexGrow(val) {
1239
+ wasm.style_set_flexGrow(this.__wbg_ptr, val);
1240
+ }
1241
+ /**
1242
+ * Sets the flex wrap mode
1243
+ *
1244
+ * @param val - The new flex wrap mode
1245
+ *
1246
+ *
1247
+ * @example
1248
+ *
1249
+ * ```typescript
1250
+ * style.flexWrap = FlexWrap.Wrap;
1251
+ * ```
1252
+ * @param {FlexWrap} val
1253
+ */
1254
+ set flexWrap(val) {
1255
+ wasm.style_set_flexWrap(this.__wbg_ptr, val);
1256
+ }
1257
+ /**
1258
+ * Gets the flex direction
1259
+ *
1260
+ * Defines the main axis direction for flex items.
1261
+ *
1262
+ * @returns - The current [`FlexDirection`](JsFlexDirection) value
1263
+ *
1264
+ * @defaultValue - `FlexDirection.Row`
1265
+ * @returns {FlexDirection}
1266
+ */
1267
+ get flexDirection() {
1268
+ const ret = wasm.style_flexDirection(this.__wbg_ptr);
1269
+ return ret;
1270
+ }
1271
+ /**
1272
+ * Sets the align-self property
1273
+ *
1274
+ * @param val - The new align-self value, or `undefined`/`Auto` to inherit from parent
1275
+ *
1276
+ * @example
1277
+ * ```typescript
1278
+ * style.alignSelf = AlignSelf.Stretch;
1279
+ * ```
1280
+ * @param {AlignSelf | undefined} val
1281
+ */
1282
+ set alignSelf(val) {
1283
+ wasm.style_set_alignSelf(this.__wbg_ptr, val);
1284
+ }
1285
+ /**
1286
+ * Sets the box sizing mode
1287
+ *
1288
+ * @param val - The new box sizing mode
1289
+ *
1290
+ * @example
1291
+ * ```typescript
1292
+ * style.boxSizing = BoxSizing.ContentBox;
1293
+ * ```
1294
+ * @param {BoxSizing} val
1295
+ */
1296
+ set boxSizing(val) {
1297
+ wasm.style_set_boxSizing(this.__wbg_ptr, val);
1298
+ }
1299
+ /**
1300
+ * Sets the flex-basis
1301
+ *
1302
+ * @param val - The initial size as a Dimension
1303
+ *
1304
+ * @example
1305
+ * ```typescript
1306
+ * style.flexBasis = { Length: 100 };
1307
+ * ```
1308
+ * @param {Dimension} val
1309
+ */
1310
+ set flexBasis(val) {
1311
+ wasm.style_set_flexBasis(this.__wbg_ptr, val);
1312
+ }
1313
+ /**
1314
+ * Gets the justify-content property
1315
+ *
1316
+ * Defines alignment and spacing of items along the main axis.
1317
+ *
1318
+ * @returns - The current [`JustifyContent`](JsJustifyContent) value, or `undefined` if not set
1319
+ * @returns {JustifyContent | undefined}
1320
+ */
1321
+ get justifyContent() {
1322
+ const ret = wasm.style_justifyContent(this.__wbg_ptr);
1323
+ return ret === 9 ? undefined : ret;
1324
+ }
1325
+ /**
1326
+ * Sets the align-items property
1327
+ *
1328
+ * @param val - The new align-items value, or `undefined` to use default
1329
+ *
1330
+ * @example
1331
+ *
1332
+ * ```typescript
1333
+ * style.alignItems = AlignItems.Center;
1334
+ * ```
1335
+ * @param {AlignItems | undefined} val
1336
+ */
1337
+ set alignItems(val) {
1338
+ wasm.style_set_alignItems(this.__wbg_ptr, val);
1339
+ }
1340
+ /**
1341
+ * Sets the flex shrink factor
1342
+ *
1343
+ * @param val - The new flex shrink factor (must be >= 0)
1344
+ *
1345
+ * @example
1346
+ * ```typescript
1347
+ * style.flexShrink = 2;
1348
+ * ```
1349
+ * @param {number} val
1350
+ */
1351
+ set flexShrink(val) {
1352
+ wasm.style_set_flexShrink(this.__wbg_ptr, val);
1353
+ }
1354
+ /**
1355
+ * Sets the aspect ratio
1356
+ *
1357
+ * @param val - The new aspect ratio (width/height), or `undefined` to clear
1358
+ *
1359
+ * @example
1360
+ * ```typescript
1361
+ * style.aspectRatio = 16 / 9;
1362
+ * ```
1363
+ * @param {number | undefined} val
1364
+ */
1365
+ set aspectRatio(val) {
1366
+ wasm.style_set_aspectRatio(this.__wbg_ptr, val);
1367
+ }
1368
+ /**
1369
+ * Sets the align-content property
1370
+ *
1371
+ * @param val - The new align-content value, or `undefined` to use default
1372
+ *
1373
+ * @example
1374
+ * ```typescript
1375
+ * style.alignContent = AlignContent.SpaceBetween;
1376
+ * ```
1377
+ * @param {AlignContent | undefined} val
1378
+ */
1379
+ set alignContent(val) {
1380
+ wasm.style_set_alignContent(this.__wbg_ptr, val);
1381
+ }
1382
+ /**
1383
+ * Sets the flex direction
1384
+ *
1385
+ * @param val - The new flex direction
1386
+ *
1387
+ *
1388
+ * @example
1389
+ *
1390
+ * ```typescript
1391
+ * style.flexDirection = FlexDirection.Column;
1392
+ * ```
1393
+ * @param {FlexDirection} val
1394
+ */
1395
+ set flexDirection(val) {
1396
+ wasm.style_set_flexDirection(this.__wbg_ptr, val);
1397
+ }
1398
+ /**
1399
+ * Sets the justify-content property
1400
+ *
1401
+ * @param val - The new justify-content value, or `undefined` to use default
1402
+ *
1403
+ * @example
1404
+ * ```typescript
1405
+ * style.justifyContent = JustifyContent.Center;
1406
+ * ```
1407
+ * @param {JustifyContent | undefined} val
1408
+ */
1409
+ set justifyContent(val) {
1410
+ wasm.style_set_justifyContent(this.__wbg_ptr, val);
1411
+ }
1412
+ /**
1413
+ * Gets the gap
1414
+ *
1415
+ * Spacing between flex/grid items.
1416
+ *
1417
+ * @returns - A `Size<LengthPercentage>` with column (width) and row (height) gaps
1418
+ * @returns {Size<LengthPercentage>}
1419
+ */
1420
+ get gap() {
1421
+ const ret = wasm.style_gap(this.__wbg_ptr);
1422
+ return ret;
1423
+ }
1424
+ /**
1425
+ * Creates a new Style instance with default values
1426
+ *
1427
+ * @returns - A new `Style` object with all properties set to CSS defaults
1428
+ *
1429
+ * @example
1430
+ * ```typescript
1431
+ * const style = new Style();
1432
+ * console.log(style.display); // Display.Block
1433
+ * ```
1434
+ */
1435
+ constructor() {
1436
+ const ret = wasm.style_new();
1437
+ this.__wbg_ptr = ret >>> 0;
1438
+ StyleFinalization.register(this, this.__wbg_ptr, this);
1439
+ return this;
1440
+ }
1441
+ /**
1442
+ * Gets the size (width and height)
1443
+ *
1444
+ * @returns - A `Size<Dimension>` object with `width` and `height` properties
1445
+ * @returns {Size<Dimension>}
1446
+ */
1447
+ get size() {
1448
+ const ret = wasm.style_size(this.__wbg_ptr);
1449
+ return ret;
1450
+ }
1451
+ /**
1452
+ * Gets the inset
1453
+ *
1454
+ * Positioning offsets for absolutely positioned elements.
1455
+ *
1456
+ * @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom offsets
1457
+ * @returns {Rect<LengthPercentageAuto>}
1458
+ */
1459
+ get inset() {
1460
+ const ret = wasm.style_inset(this.__wbg_ptr);
1461
+ return ret;
1462
+ }
1463
+ /**
1464
+ * Gets the border width
1465
+ *
1466
+ * Width of the element's border on each side.
1467
+ *
1468
+ * @returns - A `Rect<LengthPercentage>` with left, right, top, bottom border widths
1469
+ * @returns {Rect<LengthPercentage>}
1470
+ */
1471
+ get border() {
1472
+ const ret = wasm.style_border(this.__wbg_ptr);
1473
+ return ret;
1474
+ }
1475
+ /**
1476
+ * Gets the margin
1477
+ *
1478
+ * Outer spacing around the element.
1479
+ *
1480
+ * @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom margins
1481
+ * @returns {Rect<LengthPercentageAuto>}
1482
+ */
1483
+ get margin() {
1484
+ const ret = wasm.style_margin(this.__wbg_ptr);
1485
+ return ret;
1486
+ }
1487
+ /**
1488
+ * Gets the display mode
1489
+ *
1490
+ * Determines the layout algorithm used for this element and its children.
1491
+ *
1492
+ * @returns - The current [`Display`](JsDisplay) value
1493
+ *
1494
+ * @defaultValue - `Display.Block`
1495
+ * @returns {Display}
1496
+ */
1497
+ get display() {
1498
+ const ret = wasm.style_display(this.__wbg_ptr);
1499
+ return ret;
1500
+ }
1501
+ /**
1502
+ * Gets the padding
1503
+ *
1504
+ * Inner spacing between the element's border and content.
1505
+ *
1506
+ * @returns - A `Rect<LengthPercentage>` with left, right, top, bottom padding
1507
+ * @returns {Rect<LengthPercentage>}
1508
+ */
1509
+ get padding() {
1510
+ const ret = wasm.style_padding(this.__wbg_ptr);
1511
+ return ret;
1512
+ }
1513
+ /**
1514
+ * Sets the gap
1515
+ *
1516
+ * @param val - A Size object with LengthPercentage gap values
1517
+ *
1518
+ * @example
1519
+ * ```typescript
1520
+ * style.gap = { width: { Length: 10 }, height: { Length: 10 } };
1521
+ * ```
1522
+ * @param {Size<LengthPercentage>} val
1523
+ */
1524
+ set gap(val) {
1525
+ wasm.style_set_gap(this.__wbg_ptr, val);
1526
+ }
1527
+ /**
1528
+ * Gets the maximum size constraints
1529
+ *
1530
+ * @returns - A `Size<Dimension>` object with maximum width and height
1531
+ * @returns {Size<Dimension>}
1532
+ */
1533
+ get maxSize() {
1534
+ const ret = wasm.style_maxSize(this.__wbg_ptr);
1535
+ return ret;
1536
+ }
1537
+ /**
1538
+ * Gets the minimum size constraints
1539
+ *
1540
+ * @returns - A `Size<Dimension>` object with minimum width and height
1541
+ * @returns {Size<Dimension>}
1542
+ */
1543
+ get minSize() {
1544
+ const ret = wasm.style_minSize(this.__wbg_ptr);
1545
+ return ret;
1546
+ }
1547
+ /**
1548
+ * Gets the overflow behavior
1549
+ *
1550
+ * Controls how content that exceeds the container is handled.
1551
+ *
1552
+ * @returns - A `Point<Overflow>` with `x` and `y` overflow settings
1553
+ * @returns {Point<Overflow>}
1554
+ */
1555
+ get overflow() {
1556
+ const ret = wasm.style_overflow(this.__wbg_ptr);
1557
+ return ret;
1558
+ }
1559
+ /**
1560
+ * Gets the position mode
1561
+ *
1562
+ * Determines how the element is positioned within its parent.
1563
+ *
1564
+ * @returns - The current [`Position`](JsPosition) value
1565
+ *
1566
+ * @defaultValue - `Position.Relative`
1567
+ * @returns {Position}
1568
+ */
1569
+ get position() {
1570
+ const ret = wasm.style_position(this.__wbg_ptr);
1571
+ return ret;
1572
+ }
1573
+ /**
1574
+ * Sets the size (width and height)
1575
+ *
1576
+ * @param val - A Size object with Dimension values
1577
+ *
1578
+ * @example
1579
+ * ```typescript
1580
+ * style.size = { width: { Length: 200 }, height: { Percent: 100 } };
1581
+ * ```
1582
+ * @param {Size<Dimension>} val
1583
+ */
1584
+ set size(val) {
1585
+ wasm.style_set_size(this.__wbg_ptr, val);
1586
+ }
1587
+ /**
1588
+ * Gets the flex grow factor
1589
+ *
1590
+ * Determines how much the item grows relative to siblings when
1591
+ * there is extra space available.
1592
+ *
1593
+ * @returns - The flex grow factor (default: 0)
1594
+ * @returns {number}
1595
+ */
1596
+ get flexGrow() {
1597
+ const ret = wasm.style_flexGrow(this.__wbg_ptr);
1598
+ return ret;
1599
+ }
1600
+ /**
1601
+ * Gets the flex wrap mode
1602
+ *
1603
+ * Controls whether flex items wrap to new lines.
1604
+ *
1605
+ * @returns - The current [`FlexWrap`](JsFlexWrap) value
1606
+ *
1607
+ * @defaultValue - `FlexWrap.NoWrap`
1608
+ * @returns {FlexWrap}
1609
+ */
1610
+ get flexWrap() {
1611
+ const ret = wasm.style_flexWrap(this.__wbg_ptr);
1612
+ return ret;
1613
+ }
1614
+ /**
1615
+ * Sets the inset
1616
+ *
1617
+ * @param val - A Rect object with LengthPercentageAuto offset values
1618
+ *
1619
+ * @example
1620
+ * ```typescript
1621
+ * style.position = Position.Absolute;
1622
+ * style.inset = { left: { Length: 0 }, top: { Length: 0 }, right: "Auto", bottom: "Auto" };
1623
+ * ```
1624
+ * @param {Rect<LengthPercentageAuto>} val
1625
+ */
1626
+ set inset(val) {
1627
+ wasm.style_set_inset(this.__wbg_ptr, val);
1628
+ }
1079
1629
  }
1080
1630
  if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
1081
1631
 
1082
1632
  /**
1083
- * Layout tree manager providing node creation, tree manipulation, and layout computation.
1084
- *
1085
- * This is the main entry point for the Taffy layout engine. It wraps the native
1086
- * `taffy::TaffyTree<JsValue>` to provide a JavaScript-friendly API.
1633
+ * Error class thrown when a Taffy operation fails, containing a human-readable error message.
1087
1634
  *
1088
- * # Features
1089
- * - **Node Management**: Create, remove, and reorganize layout nodes
1090
- * - **Style Control**: Get/set styles for any node
1091
- * - **Layout Computation**: Run Flexbox/Grid/Block layout algorithms
1092
- * - **Custom Measurement**: Support for text measurement via callback functions
1093
- * - **Node Context**: Attach arbitrary JS data to nodes for custom logic
1635
+ * This class wraps the native [`taffy::TaffyError`] type and exposes it to JavaScript
1636
+ * with a readable error message. It is thrown as a JavaScript exception on failure.
1094
1637
  *
1095
- * # Example
1096
- * ```javascript
1097
- * const tree = new TaffyTree();
1098
- * const style = new Style();
1099
- * style.display = Display.Flex;
1100
- * const root = tree.newLeaf(style);
1101
- * tree.computeLayout(root, { width: { Definite: 800 }, height: { Definite: 600 } });
1102
- * const layout = tree.getLayout(root);
1638
+ * @example
1639
+ * ```typescript
1640
+ * try {
1641
+ * tree.remove(node);
1642
+ * } catch (e) {
1643
+ * if (e instanceof TaffyError) {
1644
+ * console.error(e.message);
1645
+ * }
1646
+ * }
1103
1647
  * ```
1648
+ *
1649
+ * @remarks
1650
+ * The underlying Taffy errors include:
1651
+ * - `InvalidInputNode`: Node ID doesn't exist in the tree
1652
+ * - `InvalidParentNode`: Specified parent node doesn't exist
1653
+ * - `ChildIndexOutOfBounds`: Child index exceeds available children
1654
+ */
1655
+ export class TaffyError {
1656
+ static __wrap(ptr) {
1657
+ ptr = ptr >>> 0;
1658
+ const obj = Object.create(TaffyError.prototype);
1659
+ obj.__wbg_ptr = ptr;
1660
+ TaffyErrorFinalization.register(obj, obj.__wbg_ptr, obj);
1661
+ return obj;
1662
+ }
1663
+ __destroy_into_raw() {
1664
+ const ptr = this.__wbg_ptr;
1665
+ this.__wbg_ptr = 0;
1666
+ TaffyErrorFinalization.unregister(this);
1667
+ return ptr;
1668
+ }
1669
+ free() {
1670
+ const ptr = this.__destroy_into_raw();
1671
+ wasm.__wbg_taffyerror_free(ptr, 0);
1672
+ }
1673
+ /**
1674
+ * Gets the human-readable error message
1675
+ *
1676
+ * @returns - A string describing what went wrong.
1677
+ *
1678
+ * @remarks
1679
+ * Examples:
1680
+ * - "Node with id 1234 is not present in the Taffy tree"
1681
+ * - "Index 5 is out of bounds for node with 3 children"
1682
+ * @returns {string}
1683
+ */
1684
+ get message() {
1685
+ let deferred1_0;
1686
+ let deferred1_1;
1687
+ try {
1688
+ const ret = wasm.taffyerror_message(this.__wbg_ptr);
1689
+ deferred1_0 = ret[0];
1690
+ deferred1_1 = ret[1];
1691
+ return getStringFromWasm0(ret[0], ret[1]);
1692
+ } finally {
1693
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1694
+ }
1695
+ }
1696
+ }
1697
+ if (Symbol.dispose)
1698
+ TaffyError.prototype[Symbol.dispose] = TaffyError.prototype.free;
1699
+
1700
+ /**
1701
+ * The main layout tree class for creating nodes, computing layouts, and managing a tree of styled elements.
1702
+ *
1703
+ * TaffyTree is the entry point for the Taffy layout engine. It manages
1704
+ * a tree of nodes and computes their layouts using CSS Flexbox and Grid algorithms.
1104
1705
  */
1105
1706
  export class TaffyTree {
1106
- static __wrap(ptr) {
1107
- ptr = ptr >>> 0;
1108
- const obj = Object.create(TaffyTree.prototype);
1109
- obj.__wbg_ptr = ptr;
1110
- TaffyTreeFinalization.register(obj, obj.__wbg_ptr, obj);
1111
- return obj;
1112
- }
1113
- __destroy_into_raw() {
1114
- const ptr = this.__wbg_ptr;
1115
- this.__wbg_ptr = 0;
1116
- TaffyTreeFinalization.unregister(this);
1117
- return ptr;
1118
- }
1119
- free() {
1120
- const ptr = this.__destroy_into_raw();
1121
- wasm.__wbg_taffytree_free(ptr, 0);
1122
- }
1123
- /**
1124
- * Marks a node as dirty, requiring re-layout.
1125
- *
1126
- * Call this when a node's content changes (e.g., text content)
1127
- * but its style hasn't. Style changes automatically mark nodes dirty.
1128
- *
1129
- * # Arguments
1130
- * * `node` - The node ID to mark dirty.
1131
- * @param {bigint} node
1132
- */
1133
- markDirty(node) {
1134
- const ret = wasm.taffytree_markDirty(this.__wbg_ptr, node);
1135
- if (ret[1]) {
1136
- throw takeFromExternrefTable0(ret[0]);
1137
- }
1138
- }
1139
- /**
1140
- * Prints the tree structure to the console (for debugging).
1141
- *
1142
- * # Arguments
1143
- * * `node` - The root node ID to start printing from.
1144
- * @param {bigint} node
1145
- */
1146
- printTree(node) {
1147
- wasm.taffytree_printTree(this.__wbg_ptr, node);
1148
- }
1149
- /**
1150
- * Gets the number of children of a node.
1151
- *
1152
- * # Arguments
1153
- * * `parent` - The parent node ID.
1154
- *
1155
- * # Returns
1156
- * The number of children.
1157
- * @param {bigint} parent
1158
- * @returns {number}
1159
- */
1160
- childCount(parent) {
1161
- const ret = wasm.taffytree_childCount(this.__wbg_ptr, parent);
1162
- return ret >>> 0;
1163
- }
1164
- /**
1165
- * Removes a specific child from a parent.
1166
- *
1167
- * # Arguments
1168
- * * `parent` - The parent node ID.
1169
- * * `child` - The child node ID to remove.
1170
- *
1171
- * # Returns
1172
- * * `Ok(u64)` - The ID of the removed child.
1173
- * * `Err(JsValue)` - Error if parent or child doesn't exist.
1174
- * @param {bigint} parent
1175
- * @param {bigint} child
1176
- * @returns {bigint}
1177
- */
1178
- removeChild(parent, child) {
1179
- const ret = wasm.taffytree_removeChild(this.__wbg_ptr, parent, child);
1180
- if (ret[2]) {
1181
- throw takeFromExternrefTable0(ret[1]);
1182
- }
1183
- return BigInt.asUintN(64, ret[0]);
1184
- }
1185
- /**
1186
- * Replaces all children of a node.
1187
- *
1188
- * Previous children are detached but not removed from the tree.
1189
- *
1190
- * # Arguments
1191
- * * `parent` - The parent node ID.
1192
- * * `children` - Array of new child node IDs.
1193
- * @param {bigint} parent
1194
- * @param {BigUint64Array} children
1195
- */
1196
- setChildren(parent, children) {
1197
- const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1198
- const len0 = WASM_VECTOR_LEN;
1199
- const ret = wasm.taffytree_setChildren(this.__wbg_ptr, parent, ptr0, len0);
1200
- if (ret[1]) {
1201
- throw takeFromExternrefTable0(ret[0]);
1202
- }
1203
- }
1204
- /**
1205
- * Creates a new TaffyTree with pre-allocated capacity.
1206
- *
1207
- * Use this when you know approximately how many nodes you'll create
1208
- * to avoid reallocation overhead.
1209
- *
1210
- * # Arguments
1211
- * * `capacity` - The number of nodes to pre-allocate space for.
1212
- *
1213
- * # Returns
1214
- * A new TaffyTree instance with pre-allocated capacity.
1215
- * @param {number} capacity
1216
- * @returns {TaffyTree}
1217
- */
1218
- static withCapacity(capacity) {
1219
- const ret = wasm.taffytree_withCapacity(capacity);
1220
- return TaffyTree.__wrap(ret);
1221
- }
1222
- /**
1223
- * Gets a child at a specific index.
1224
- *
1225
- * # Arguments
1226
- * * `parent` - The parent node ID.
1227
- * * `index` - The zero-based index.
1228
- *
1229
- * # Returns
1230
- * * `Ok(u64)` - The child node ID at the given index.
1231
- * * `Err(JsValue)` - Error if index is out of bounds.
1232
- * @param {bigint} parent
1233
- * @param {number} index
1234
- * @returns {bigint}
1235
- */
1236
- getChildAtIndex(parent, index) {
1237
- const ret = wasm.taffytree_getChildAtIndex(this.__wbg_ptr, parent, index);
1238
- if (ret[2]) {
1239
- throw takeFromExternrefTable0(ret[1]);
1240
- }
1241
- return BigInt.asUintN(64, ret[0]);
1242
- }
1243
- /**
1244
- * Computes the layout for a subtree.
1245
- *
1246
- * Runs the layout algorithm (Flexbox/Grid/Block) on the given node
1247
- * and all its descendants. Results are cached and can be retrieved
1248
- * with `getLayout()`.
1249
- *
1250
- * # Arguments
1251
- * * `node` - The root node ID for layout computation.
1252
- * * `available_space` - The available space constraint, e.g.:
1253
- * `{ width: { Definite: 800 }, height: { Definite: 600 } }`
1254
- *
1255
- * Available space options per dimension:
1256
- * - `{ Definite: number }` - A specific size in pixels
1257
- * - `"MinContent"` - Use minimum content size
1258
- * - `"MaxContent"` - Use maximum content size
1259
- * @param {bigint} node
1260
- * @param {any} available_space
1261
- */
1262
- computeLayout(node, available_space) {
1263
- const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, available_space);
1264
- if (ret[1]) {
1265
- throw takeFromExternrefTable0(ret[0]);
1266
- }
1267
- }
1268
- /**
1269
- * Enables rounding of layout values to whole pixels.
1270
- *
1271
- * When enabled, all computed layout values (x, y, width, height) are
1272
- * rounded to the nearest integer. This is the default behavior.
1273
- */
1274
- enableRounding() {
1275
- wasm.taffytree_enableRounding(this.__wbg_ptr);
1276
- }
1277
- /**
1278
- * Disables rounding of layout values.
1279
- *
1280
- * When disabled, layout values may have fractional pixel values.
1281
- * Use `unroundedLayout()` to get the pre-rounding values.
1282
- */
1283
- disableRounding() {
1284
- wasm.taffytree_disableRounding(this.__wbg_ptr);
1285
- }
1286
- /**
1287
- * Gets the context value for a node.
1288
- *
1289
- * # Arguments
1290
- * * `node` - The node ID.
1291
- *
1292
- * # Returns
1293
- * The context value, or `undefined` if not set.
1294
- * @param {bigint} node
1295
- * @returns {any}
1296
- */
1297
- getNodeContext(node) {
1298
- const ret = wasm.taffytree_getNodeContext(this.__wbg_ptr, node);
1299
- if (ret[2]) {
1300
- throw takeFromExternrefTable0(ret[1]);
1301
- }
1302
- return takeFromExternrefTable0(ret[0]);
1303
- }
1304
- /**
1305
- * Sets a context value for a node.
1306
- *
1307
- * Context values are passed to the measure function during layout.
1308
- * Use this to attach data like text content or custom metadata.
1309
- *
1310
- * # Arguments
1311
- * * `node` - The node ID.
1312
- * * `context` - Any JavaScript value.
1313
- * @param {bigint} node
1314
- * @param {any} context
1315
- */
1316
- setNodeContext(node, context) {
1317
- const ret = wasm.taffytree_setNodeContext(this.__wbg_ptr, node, context);
1318
- if (ret[1]) {
1319
- throw takeFromExternrefTable0(ret[0]);
1320
- }
1321
- }
1322
- /**
1323
- * Gets the total number of nodes in the tree.
1324
- *
1325
- * # Returns
1326
- * The count of all nodes (including removed nodes that haven't been reclaimed).
1327
- * @returns {number}
1328
- */
1329
- totalNodeCount() {
1330
- const ret = wasm.taffytree_totalNodeCount(this.__wbg_ptr);
1331
- return ret >>> 0;
1332
- }
1333
- /**
1334
- * Gets the unrounded (fractional) layout for a node.
1335
- *
1336
- * Useful when you need sub-pixel precision.
1337
- *
1338
- * # Arguments
1339
- * * `node` - The node ID to query.
1340
- *
1341
- * # Returns
1342
- * A `Layout` object with potentially fractional pixel values.
1343
- * @param {bigint} node
1344
- * @returns {Layout}
1345
- */
1346
- unroundedLayout(node) {
1347
- const ret = wasm.taffytree_unroundedLayout(this.__wbg_ptr, node);
1348
- if (ret[2]) {
1349
- throw takeFromExternrefTable0(ret[1]);
1350
- }
1351
- return Layout.__wrap(ret[0]);
1352
- }
1353
- /**
1354
- * Creates a new node with the given children.
1355
- *
1356
- * # Arguments
1357
- * * `style` - The Style object to apply to this node.
1358
- * * `children` - Array of child node IDs.
1359
- *
1360
- * # Returns
1361
- * * `Ok(u64)` - The node ID of the newly created node.
1362
- * * `Err(JsValue)` - Error message if creation fails.
1363
- * @param {Style} style
1364
- * @param {BigUint64Array} children
1365
- * @returns {bigint}
1366
- */
1367
- newWithChildren(style, children) {
1368
- _assertClass(style, Style);
1369
- const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1370
- const len0 = WASM_VECTOR_LEN;
1371
- const ret = wasm.taffytree_newWithChildren(this.__wbg_ptr, style.__wbg_ptr, ptr0, len0);
1372
- if (ret[2]) {
1373
- throw takeFromExternrefTable0(ret[1]);
1374
- }
1375
- return BigInt.asUintN(64, ret[0]);
1376
- }
1377
- /**
1378
- * Gets a mutable reference to the context value for a node.
1379
- *
1380
- * Note: In WASM, this returns a clone since we can't return mutable references.
1381
- *
1382
- * # Arguments
1383
- * * `node` - The node ID.
1384
- *
1385
- * # Returns
1386
- * The context value, or `undefined` if not set.
1387
- * @param {bigint} node
1388
- * @returns {any}
1389
- */
1390
- getNodeContextMut(node) {
1391
- const ret = wasm.taffytree_getNodeContextMut(this.__wbg_ptr, node);
1392
- if (ret[2]) {
1393
- throw takeFromExternrefTable0(ret[1]);
1394
- }
1395
- return takeFromExternrefTable0(ret[0]);
1396
- }
1397
- /**
1398
- * Inserts a child at a specific index.
1399
- *
1400
- * Existing children at and after the index are shifted right.
1401
- *
1402
- * # Arguments
1403
- * * `parent` - The parent node ID.
1404
- * * `index` - The zero-based index at which to insert.
1405
- * * `child` - The child node ID to insert.
1406
- * @param {bigint} parent
1407
- * @param {number} index
1408
- * @param {bigint} child
1409
- */
1410
- insertChildAtIndex(parent, index, child) {
1411
- const ret = wasm.taffytree_insertChildAtIndex(this.__wbg_ptr, parent, index, child);
1412
- if (ret[1]) {
1413
- throw takeFromExternrefTable0(ret[0]);
1414
- }
1415
- }
1416
- /**
1417
- * Creates a new leaf node with an attached context value.
1418
- *
1419
- * The context can be any JavaScript value and is useful for associating
1420
- * custom data (like text content) with a node for use in measure functions.
1421
- *
1422
- * # Arguments
1423
- * * `style` - The Style object to apply to this node.
1424
- * * `context` - Any JavaScript value to attach to this node.
1425
- *
1426
- * # Returns
1427
- * * `Ok(u64)` - The node ID of the newly created node.
1428
- * * `Err(JsValue)` - Error message if creation fails.
1429
- * @param {Style} style
1430
- * @param {any} context
1431
- * @returns {bigint}
1432
- */
1433
- newLeafWithContext(style, context) {
1434
- _assertClass(style, Style);
1435
- const ret = wasm.taffytree_newLeafWithContext(this.__wbg_ptr, style.__wbg_ptr, context);
1436
- if (ret[2]) {
1437
- throw takeFromExternrefTable0(ret[1]);
1438
- }
1439
- return BigInt.asUintN(64, ret[0]);
1440
- }
1441
- /**
1442
- * Removes a child at a specific index.
1443
- *
1444
- * # Arguments
1445
- * * `parent` - The parent node ID.
1446
- * * `index` - The zero-based index of the child to remove.
1447
- *
1448
- * # Returns
1449
- * * `Ok(u64)` - The ID of the removed child.
1450
- * * `Err(JsValue)` - Error if index is out of bounds.
1451
- * @param {bigint} parent
1452
- * @param {number} index
1453
- * @returns {bigint}
1454
- */
1455
- removeChildAtIndex(parent, index) {
1456
- const ret = wasm.taffytree_removeChildAtIndex(this.__wbg_ptr, parent, index);
1457
- if (ret[2]) {
1458
- throw takeFromExternrefTable0(ret[1]);
1459
- }
1460
- return BigInt.asUintN(64, ret[0]);
1461
- }
1462
- /**
1463
- * Removes a range of children from a parent.
1464
- *
1465
- * # Arguments
1466
- * * `parent` - The parent node ID.
1467
- * * `start` - The start index (inclusive).
1468
- * * `end` - The end index (exclusive).
1469
- * @param {bigint} parent
1470
- * @param {number} start
1471
- * @param {number} end
1472
- */
1473
- removeChildrenRange(parent, start, end) {
1474
- const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, start, end);
1475
- if (ret[1]) {
1476
- throw takeFromExternrefTable0(ret[0]);
1477
- }
1478
- }
1479
- /**
1480
- * Replaces a child at a specific index with a new child.
1481
- *
1482
- * # Arguments
1483
- * * `parent` - The parent node ID.
1484
- * * `index` - The zero-based index of the child to replace.
1485
- * * `child` - The new child node ID.
1486
- *
1487
- * # Returns
1488
- * * `Ok(u64)` - The ID of the replaced (old) child.
1489
- * * `Err(JsValue)` - Error if index is out of bounds.
1490
- * @param {bigint} parent
1491
- * @param {number} index
1492
- * @param {bigint} child
1493
- * @returns {bigint}
1494
- */
1495
- replaceChildAtIndex(parent, index, child) {
1496
- const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, child);
1497
- if (ret[2]) {
1498
- throw takeFromExternrefTable0(ret[1]);
1499
- }
1500
- return BigInt.asUintN(64, ret[0]);
1501
- }
1502
- /**
1503
- * Computes layout with a custom measure function for leaf nodes.
1504
- *
1505
- * The measure function is called for leaf nodes to determine their
1506
- * intrinsic size (e.g., for text measurement).
1507
- *
1508
- * # Arguments
1509
- * * `node` - The root node ID for layout computation.
1510
- * * `available_space` - The available space constraint.
1511
- * * `measure_func` - A JavaScript function with signature:
1512
- * `(knownDimensions, availableSpace, context) => { width, height }`
1513
- *
1514
- * The measure function receives:
1515
- * - `knownDimensions`: `{ width: number | null, height: number | null }`
1516
- * - `availableSpace`: `{ width: AvailableSpace, height: AvailableSpace }`
1517
- * - `context`: The context value attached to the node (or undefined)
1518
- *
1519
- * And should return: `{ width: number, height: number }`
1520
- * @param {bigint} node
1521
- * @param {any} available_space
1522
- * @param {Function} measure_func
1523
- */
1524
- computeLayoutWithMeasure(node, available_space, measure_func) {
1525
- const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, available_space, measure_func);
1526
- if (ret[1]) {
1527
- throw takeFromExternrefTable0(ret[0]);
1528
- }
1529
- }
1530
- /**
1531
- * Gets context values for multiple nodes at once.
1532
- *
1533
- * Useful for batch operations.
1534
- *
1535
- * # Arguments
1536
- * * `children` - Array of node IDs to query.
1537
- *
1538
- * # Returns
1539
- * Array of context values in the same order as input.
1540
- * @param {BigUint64Array} children
1541
- * @returns {any[]}
1542
- */
1543
- getDisjointNodeContextMut(children) {
1544
- const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1545
- const len0 = WASM_VECTOR_LEN;
1546
- const ret = wasm.taffytree_getDisjointNodeContextMut(this.__wbg_ptr, ptr0, len0);
1547
- if (ret[3]) {
1548
- throw takeFromExternrefTable0(ret[2]);
1549
- }
1550
- var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1551
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1552
- return v2;
1553
- }
1554
- /**
1555
- * Creates a new empty TaffyTree.
1556
- *
1557
- * This is the primary constructor. Initializes panic hook in debug builds
1558
- * to provide better error messages in the browser console.
1559
- *
1560
- * # Returns
1561
- * A new TaffyTree instance with no nodes.
1562
- */
1563
- constructor() {
1564
- const ret = wasm.taffytree_new();
1565
- this.__wbg_ptr = ret >>> 0;
1566
- TaffyTreeFinalization.register(this, this.__wbg_ptr, this);
1567
- return this;
1568
- }
1569
- /**
1570
- * Removes all nodes from the tree.
1571
- *
1572
- * After calling this, the tree is empty and all previous node IDs are invalid.
1573
- */
1574
- clear() {
1575
- wasm.taffytree_clear(this.__wbg_ptr);
1576
- }
1577
- /**
1578
- * Checks if a node is dirty (needs re-layout).
1579
- *
1580
- * # Arguments
1581
- * * `node` - The node ID to check.
1582
- *
1583
- * # Returns
1584
- * * `Ok(true)` - The node needs re-layout.
1585
- * * `Ok(false)` - The node's layout is up-to-date.
1586
- * * `Err(JsValue)` - Error if the node doesn't exist.
1587
- * @param {bigint} node
1588
- * @returns {boolean}
1589
- */
1590
- dirty(node) {
1591
- const ret = wasm.taffytree_dirty(this.__wbg_ptr, node);
1592
- if (ret[2]) {
1593
- throw takeFromExternrefTable0(ret[1]);
1594
- }
1595
- return ret[0] !== 0;
1596
- }
1597
- /**
1598
- * Gets the style for a node.
1599
- *
1600
- * # Arguments
1601
- * * `node` - The node ID to query.
1602
- *
1603
- * # Returns
1604
- * * `Ok(Style)` - A copy of the node's style.
1605
- * * `Err(JsValue)` - Error if the node doesn't exist.
1606
- * @param {bigint} node
1607
- * @returns {Style}
1608
- */
1609
- getStyle(node) {
1610
- const ret = wasm.taffytree_getStyle(this.__wbg_ptr, node);
1611
- if (ret[2]) {
1612
- throw takeFromExternrefTable0(ret[1]);
1613
- }
1614
- return Style.__wrap(ret[0]);
1615
- }
1616
- /**
1617
- * Gets the computed layout for a node.
1618
- *
1619
- * Must be called after `computeLayout()`.
1620
- *
1621
- * # Arguments
1622
- * * `node` - The node ID to query.
1623
- *
1624
- * # Returns
1625
- * A `Layout` object with computed position, size, and spacing values.
1626
- * @param {bigint} node
1627
- * @returns {Layout}
1628
- */
1629
- getLayout(node) {
1630
- const ret = wasm.taffytree_getLayout(this.__wbg_ptr, node);
1631
- if (ret[2]) {
1632
- throw takeFromExternrefTable0(ret[1]);
1633
- }
1634
- return Layout.__wrap(ret[0]);
1635
- }
1636
- /**
1637
- * Gets the parent of a node.
1638
- *
1639
- * # Arguments
1640
- * * `child` - The child node ID.
1641
- *
1642
- * # Returns
1643
- * * `Some(u64)` - The parent node ID.
1644
- * * `None` - If the node has no parent (is a root).
1645
- * @param {bigint} child
1646
- * @returns {bigint | undefined}
1647
- */
1648
- parent(child) {
1649
- const ret = wasm.taffytree_parent(this.__wbg_ptr, child);
1650
- return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
1651
- }
1652
- /**
1653
- * Removes a node from the tree.
1654
- *
1655
- * The node is detached from its parent (if any) and removed from the tree.
1656
- * Child nodes are NOT automatically removed.
1657
- *
1658
- * # Arguments
1659
- * * `node` - The node ID to remove.
1660
- *
1661
- * # Returns
1662
- * * `Ok(u64)` - The ID of the removed node.
1663
- * * `Err(JsValue)` - Error if the node doesn't exist.
1664
- * @param {bigint} node
1665
- * @returns {bigint}
1666
- */
1667
- remove(node) {
1668
- const ret = wasm.taffytree_remove(this.__wbg_ptr, node);
1669
- if (ret[2]) {
1670
- throw takeFromExternrefTable0(ret[1]);
1671
- }
1672
- return BigInt.asUintN(64, ret[0]);
1673
- }
1674
- /**
1675
- * Gets all children of a node.
1676
- *
1677
- * # Arguments
1678
- * * `parent` - The parent node ID.
1679
- *
1680
- * # Returns
1681
- * * `Ok(Box<[u64]>)` - Array of child node IDs.
1682
- * * `Err(JsValue)` - Error if the node doesn't exist.
1683
- * @param {bigint} parent
1684
- * @returns {BigUint64Array}
1685
- */
1686
- children(parent) {
1687
- const ret = wasm.taffytree_children(this.__wbg_ptr, parent);
1688
- if (ret[3]) {
1689
- throw takeFromExternrefTable0(ret[2]);
1690
- }
1691
- var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
1692
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1693
- return v1;
1694
- }
1695
- /**
1696
- * Creates a new leaf node (no children) with the given style.
1697
- *
1698
- * # Arguments
1699
- * * `style` - The Style object to apply to this node.
1700
- *
1701
- * # Returns
1702
- * * `Ok(u64)` - The node ID of the newly created node.
1703
- * * `Err(JsValue)` - Error message if creation fails.
1704
- * @param {Style} style
1705
- * @returns {bigint}
1706
- */
1707
- newLeaf(style) {
1708
- _assertClass(style, Style);
1709
- const ret = wasm.taffytree_newLeaf(this.__wbg_ptr, style.__wbg_ptr);
1710
- if (ret[2]) {
1711
- throw takeFromExternrefTable0(ret[1]);
1712
- }
1713
- return BigInt.asUintN(64, ret[0]);
1714
- }
1715
- /**
1716
- * Appends a child node to a parent.
1717
- *
1718
- * The child is added at the end of the parent's children list.
1719
- *
1720
- * # Arguments
1721
- * * `parent` - The parent node ID.
1722
- * * `child` - The child node ID to add.
1723
- * @param {bigint} parent
1724
- * @param {bigint} child
1725
- */
1726
- addChild(parent, child) {
1727
- const ret = wasm.taffytree_addChild(this.__wbg_ptr, parent, child);
1728
- if (ret[1]) {
1729
- throw takeFromExternrefTable0(ret[0]);
1730
- }
1731
- }
1732
- /**
1733
- * Sets the style for an existing node.
1734
- *
1735
- * This will mark the node and its ancestors as dirty, triggering
1736
- * a re-layout on the next `computeLayout()` call.
1737
- *
1738
- * # Arguments
1739
- * * `node` - The node ID to update.
1740
- * * `style` - The new Style to apply.
1741
- * @param {bigint} node
1742
- * @param {Style} style
1743
- */
1744
- setStyle(node, style) {
1745
- _assertClass(style, Style);
1746
- const ret = wasm.taffytree_setStyle(this.__wbg_ptr, node, style.__wbg_ptr);
1747
- if (ret[1]) {
1748
- throw takeFromExternrefTable0(ret[0]);
1749
- }
1750
- }
1707
+ static __wrap(ptr) {
1708
+ ptr = ptr >>> 0;
1709
+ const obj = Object.create(TaffyTree.prototype);
1710
+ obj.__wbg_ptr = ptr;
1711
+ TaffyTreeFinalization.register(obj, obj.__wbg_ptr, obj);
1712
+ return obj;
1713
+ }
1714
+ __destroy_into_raw() {
1715
+ const ptr = this.__wbg_ptr;
1716
+ this.__wbg_ptr = 0;
1717
+ TaffyTreeFinalization.unregister(this);
1718
+ return ptr;
1719
+ }
1720
+ free() {
1721
+ const ptr = this.__destroy_into_raw();
1722
+ wasm.__wbg_taffytree_free(ptr, 0);
1723
+ }
1724
+ /**
1725
+ * Marks a node as dirty (requiring re-layout)
1726
+ *
1727
+ * Use this when a node's content has changed but its style hasn't.
1728
+ * For example, when text content changes and needs remeasuring.
1729
+ *
1730
+ * @param node - The node ID to mark dirty
1731
+ *
1732
+ * @throws `TaffyError` if the node does not exist
1733
+ *
1734
+ * @example
1735
+ * ```typescript
1736
+ * // After updating text content
1737
+ * tree.setNodeContext(nodeId, { text: "Updated text" });
1738
+ * tree.markDirty(nodeId);
1739
+ * tree.computeLayout(rootId, availableSpace);
1740
+ * ```
1741
+ * @param {bigint} node
1742
+ */
1743
+ markDirty(node) {
1744
+ const ret = wasm.taffytree_markDirty(this.__wbg_ptr, node);
1745
+ if (ret[1]) {
1746
+ throw takeFromExternrefTable0(ret[0]);
1747
+ }
1748
+ }
1749
+ /**
1750
+ * Prints the tree structure to the console (for debugging)
1751
+ *
1752
+ * Outputs a text representation of the tree structure starting from
1753
+ * the given node. Useful for debugging layout issues.
1754
+ *
1755
+ * @param node - The root node ID to print from
1756
+ *
1757
+ * @example
1758
+ * ```typescript
1759
+ * tree.printTree(rootId);
1760
+ * // Output appears in browser console
1761
+ * ```
1762
+ * @param {bigint} node
1763
+ */
1764
+ printTree(node) {
1765
+ wasm.taffytree_printTree(this.__wbg_ptr, node);
1766
+ }
1767
+ /**
1768
+ * Gets the number of children of a node
1769
+ *
1770
+ * @param parent - The parent node ID
1771
+ *
1772
+ * @returns - The number of direct children
1773
+ *
1774
+ * @throws `TaffyError` if the node does not exist
1775
+ *
1776
+ * @example
1777
+ * ```typescript
1778
+ * const count: number = tree.childCount(parentId);
1779
+ * ```
1780
+ * @param {bigint} parent
1781
+ * @returns {number}
1782
+ */
1783
+ childCount(parent) {
1784
+ const ret = wasm.taffytree_childCount(this.__wbg_ptr, parent);
1785
+ return ret >>> 0;
1786
+ }
1787
+ /**
1788
+ * Removes a specific child from a parent
1789
+ *
1790
+ * @param parent - The parent node ID
1791
+ * @param child - The child node ID to remove
1792
+ *
1793
+ * @returns - The removed child ID (`bigint`)
1794
+ *
1795
+ * @throws `TaffyError` if the parent or child node does not exist
1796
+ *
1797
+ * @example
1798
+ * ```typescript
1799
+ * tree.removeChild(parentId, childId);
1800
+ * ```
1801
+ * @param {bigint} parent
1802
+ * @param {bigint} child
1803
+ * @returns {bigint}
1804
+ */
1805
+ removeChild(parent, child) {
1806
+ const ret = wasm.taffytree_removeChild(this.__wbg_ptr, parent, child);
1807
+ if (ret[2]) {
1808
+ throw takeFromExternrefTable0(ret[1]);
1809
+ }
1810
+ return BigInt.asUintN(64, ret[0]);
1811
+ }
1812
+ /**
1813
+ * Replaces all children of a node
1814
+ *
1815
+ * Any existing children are removed and replaced with the new array.
1816
+ *
1817
+ * @param parent - The parent node ID
1818
+ * @param children - Array of new child node IDs
1819
+ *
1820
+ * @throws `TaffyError` if the parent node does not exist
1821
+ *
1822
+ * @example
1823
+ * ```typescript
1824
+ * const children = BigUint64Array.from([child1, child2, child3]);
1825
+ * tree.setChildren(parentId, children);
1826
+ * ```
1827
+ * @param {bigint} parent
1828
+ * @param {BigUint64Array} children
1829
+ */
1830
+ setChildren(parent, children) {
1831
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1832
+ const len0 = WASM_VECTOR_LEN;
1833
+ const ret = wasm.taffytree_setChildren(this.__wbg_ptr, parent, ptr0, len0);
1834
+ if (ret[1]) {
1835
+ throw takeFromExternrefTable0(ret[0]);
1836
+ }
1837
+ }
1838
+ /**
1839
+ * Creates a new TaffyTree with pre-allocated capacity
1840
+ *
1841
+ * Use this when you know approximately how many nodes will be in the tree.
1842
+ * This can improve performance by reducing memory reallocations.
1843
+ *
1844
+ * @param capacity - The number of nodes to pre-allocate space for
1845
+ *
1846
+ * @example
1847
+ * ```typescript
1848
+ * const tree: TaffyTree = TaffyTree.withCapacity(1000);
1849
+ * ```
1850
+ * @param {number} capacity
1851
+ * @returns {TaffyTree}
1852
+ */
1853
+ static withCapacity(capacity) {
1854
+ const ret = wasm.taffytree_withCapacity(capacity);
1855
+ return TaffyTree.__wrap(ret);
1856
+ }
1857
+ /**
1858
+ * Computes the layout for a subtree
1859
+ *
1860
+ * This is the main layout computation method. Call this on the root node
1861
+ * to compute layouts for all nodes in the tree.
1862
+ *
1863
+ * @param node - The root node ID to compute layout for
1864
+ * @param available_space - The available space constraints
1865
+ *
1866
+ * @example
1867
+ * ```typescript
1868
+ * // Fixed size container
1869
+ * { width: { Definite: 800 }, height: { Definite: 600 } }
1870
+ *
1871
+ * // Flexible width, fixed height
1872
+ * { width: "MaxContent", height: { Definite: 600 } }
1873
+ *
1874
+ * // Minimum content size
1875
+ * { width: "MinContent", height: "MinContent" }
1876
+ * ```
1877
+ *
1878
+ * @throws `TaffyError` if the node does not exist or available space is invalid
1879
+ *
1880
+ * @example
1881
+ * ```typescript
1882
+ * tree.computeLayout(rootId, { width: { Definite: 800 }, height: { Definite: 600 } });
1883
+ * ```
1884
+ * @param {bigint} node
1885
+ * @param {Size<AvailableSpace>} available_space
1886
+ */
1887
+ computeLayout(node, available_space) {
1888
+ const ret = wasm.taffytree_computeLayout(
1889
+ this.__wbg_ptr,
1890
+ node,
1891
+ available_space,
1892
+ );
1893
+ if (ret[1]) {
1894
+ throw takeFromExternrefTable0(ret[0]);
1895
+ }
1896
+ }
1897
+ /**
1898
+ * Enables rounding of layout values to whole pixels
1899
+ *
1900
+ * When enabled (default), computed layout values like position and size
1901
+ * are rounded to the nearest integer. This prevents sub-pixel rendering
1902
+ * issues in most rendering contexts.
1903
+ *
1904
+ * @example
1905
+ * ```typescript
1906
+ * tree.enableRounding();
1907
+ * ```
1908
+ */
1909
+ enableRounding() {
1910
+ wasm.taffytree_enableRounding(this.__wbg_ptr);
1911
+ }
1912
+ /**
1913
+ * Disables rounding of layout values
1914
+ *
1915
+ * When disabled, computed layout values retain their fractional precision.
1916
+ * Use this when you need sub-pixel accuracy or when performing custom
1917
+ * rounding.
1918
+ *
1919
+ * @example
1920
+ * ```typescript
1921
+ * tree.disableRounding();
1922
+ * const layout = tree.getLayout(node);
1923
+ * console.log(layout.x);
1924
+ * ```
1925
+ */
1926
+ disableRounding() {
1927
+ wasm.taffytree_disableRounding(this.__wbg_ptr);
1928
+ }
1929
+ /**
1930
+ * Gets the context value for a node
1931
+ *
1932
+ * @param node - The node ID
1933
+ *
1934
+ * @returns - The attached context value, or `undefined` if none is set
1935
+ *
1936
+ * @example
1937
+ * ```typescript
1938
+ * interface Context { text: string };
1939
+ * const context = tree.getNodeContext(nodeId) as Context | undefined;
1940
+ * if (context) {
1941
+ * console.log(context.text);
1942
+ * }
1943
+ * ```
1944
+ * @param {bigint} node
1945
+ * @returns {any}
1946
+ */
1947
+ getNodeContext(node) {
1948
+ const ret = wasm.taffytree_getNodeContext(this.__wbg_ptr, node);
1949
+ if (ret[2]) {
1950
+ throw takeFromExternrefTable0(ret[1]);
1951
+ }
1952
+ return takeFromExternrefTable0(ret[0]);
1953
+ }
1954
+ /**
1955
+ * Sets a context value for a node
1956
+ *
1957
+ * The context can be any JavaScript value and is passed to the measure
1958
+ * function during layout computation.
1959
+ *
1960
+ * @param node - The node ID
1961
+ * @param context - Any JavaScript value to attach
1962
+ *
1963
+ * @throws `TaffyError` if the node does not exist
1964
+ *
1965
+ * @example
1966
+ * ```typescript
1967
+ * interface Context { text: string };
1968
+ * tree.setNodeContext(nodeId, { text: "Updated text" } as Context);
1969
+ * ```
1970
+ * @param {bigint} node
1971
+ * @param {any} context
1972
+ */
1973
+ setNodeContext(node, context) {
1974
+ const ret = wasm.taffytree_setNodeContext(this.__wbg_ptr, node, context);
1975
+ if (ret[1]) {
1976
+ throw takeFromExternrefTable0(ret[0]);
1977
+ }
1978
+ }
1979
+ /**
1980
+ * Gets the total number of nodes in the tree
1981
+ *
1982
+ * @returns - The total count of all nodes
1983
+ *
1984
+ * @example
1985
+ * ```typescript
1986
+ * const count: number = tree.totalNodeCount();
1987
+ * ```
1988
+ * @returns {number}
1989
+ */
1990
+ totalNodeCount() {
1991
+ const ret = wasm.taffytree_totalNodeCount(this.__wbg_ptr);
1992
+ return ret >>> 0;
1993
+ }
1994
+ /**
1995
+ * Gets the unrounded (fractional) layout for a node
1996
+ *
1997
+ * Returns the raw computed values before any rounding is applied.
1998
+ * Useful when you need sub-pixel precision.
1999
+ *
2000
+ * @param node - The node ID
2001
+ *
2002
+ * @returns - The unrounded `Layout`
2003
+ *
2004
+ * @example
2005
+ * ```typescript
2006
+ * const layout: Layout = tree.unroundedLayout(nodeId);
2007
+ * console.log(`Exact width: ${layout.width}`);
2008
+ * ```
2009
+ * @param {bigint} node
2010
+ * @returns {Layout}
2011
+ */
2012
+ unroundedLayout(node) {
2013
+ const ret = wasm.taffytree_unroundedLayout(this.__wbg_ptr, node);
2014
+ return Layout.__wrap(ret);
2015
+ }
2016
+ /**
2017
+ * Creates a new node with the given children
2018
+ *
2019
+ * Use this to create container nodes that have child elements.
2020
+ * The children must already exist in the tree.
2021
+ *
2022
+ * @param style - The style configuration for the node
2023
+ * @param children - Array of child node IDs (as BigUint64Array)
2024
+ *
2025
+ * @returns - The node ID (`bigint`)
2026
+ *
2027
+ * @throws `TaffyError` if the node cannot be created
2028
+ *
2029
+ * @example
2030
+ * ```typescript
2031
+ * const containerStyle = new Style();
2032
+ * containerStyle.display = Display.Flex;
2033
+ *
2034
+ * const child1: bigint = tree.newLeaf(new Style());
2035
+ * const child2: bigint = tree.newLeaf(new Style());
2036
+ *
2037
+ * const container: bigint = tree.newWithChildren(
2038
+ * containerStyle,
2039
+ * BigUint64Array.from([child1, child2])
2040
+ * );
2041
+ * ```
2042
+ * @param {Style} style
2043
+ * @param {BigUint64Array} children
2044
+ * @returns {bigint}
2045
+ */
2046
+ newWithChildren(style, children) {
2047
+ _assertClass(style, Style);
2048
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2049
+ const len0 = WASM_VECTOR_LEN;
2050
+ const ret = wasm.taffytree_newWithChildren(
2051
+ this.__wbg_ptr,
2052
+ style.__wbg_ptr,
2053
+ ptr0,
2054
+ len0,
2055
+ );
2056
+ if (ret[2]) {
2057
+ throw takeFromExternrefTable0(ret[1]);
2058
+ }
2059
+ return BigInt.asUintN(64, ret[0]);
2060
+ }
2061
+ /**
2062
+ * Gets the child at a specific index
2063
+ *
2064
+ * @param parent - The parent node ID
2065
+ * @param index - The index of the child (0-based)
2066
+ *
2067
+ * @returns - The child node ID (`bigint`)
2068
+ *
2069
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2070
+ *
2071
+ * @example
2072
+ * ```typescript
2073
+ * const firstChild: bigint = tree.getChildAtIndex(parentId, 0);
2074
+ * ```
2075
+ * @param {bigint} parent
2076
+ * @param {number} index
2077
+ * @returns {bigint}
2078
+ */
2079
+ getChildAtIndex(parent, index) {
2080
+ const ret = wasm.taffytree_getChildAtIndex(this.__wbg_ptr, parent, index);
2081
+ if (ret[2]) {
2082
+ throw takeFromExternrefTable0(ret[1]);
2083
+ }
2084
+ return BigInt.asUintN(64, ret[0]);
2085
+ }
2086
+ /**
2087
+ * Gets a mutable reference to the context value for a node
2088
+ *
2089
+ * In JavaScript, this behaves the same as `getNodeContext()` since
2090
+ * JavaScript objects are always passed by reference.
2091
+ *
2092
+ * @param node - The node ID
2093
+ *
2094
+ * @returns - The attached context value, or `undefined` if none is set
2095
+ * @param {bigint} node
2096
+ * @returns {any}
2097
+ */
2098
+ getNodeContextMut(node) {
2099
+ const ret = wasm.taffytree_getNodeContextMut(this.__wbg_ptr, node);
2100
+ if (ret[2]) {
2101
+ throw takeFromExternrefTable0(ret[1]);
2102
+ }
2103
+ return takeFromExternrefTable0(ret[0]);
2104
+ }
2105
+ /**
2106
+ * Inserts a child at a specific index
2107
+ *
2108
+ * @param parent - The parent node ID
2109
+ * @param index - The position to insert at (0-based)
2110
+ * @param child - The child node ID to insert
2111
+ *
2112
+ * @throws `TaffyError` if the parent or child node does not exist, or index is out of bounds
2113
+ *
2114
+ * @example
2115
+ * ```typescript
2116
+ * tree.insertChildAtIndex(parentId, 0, childId);
2117
+ * ```
2118
+ * @param {bigint} parent
2119
+ * @param {number} index
2120
+ * @param {bigint} child
2121
+ */
2122
+ insertChildAtIndex(parent, index, child) {
2123
+ const ret = wasm.taffytree_insertChildAtIndex(
2124
+ this.__wbg_ptr,
2125
+ parent,
2126
+ index,
2127
+ child,
2128
+ );
2129
+ if (ret[1]) {
2130
+ throw takeFromExternrefTable0(ret[0]);
2131
+ }
2132
+ }
2133
+ /**
2134
+ * Creates a new leaf node with an attached context value
2135
+ *
2136
+ * The context can be any JavaScript value and is passed to the measure
2137
+ * function during layout computation. This is useful for storing
2138
+ * references to text content or other dynamic data.
2139
+ *
2140
+ * @param style - The style configuration for the node
2141
+ * @param context - Any JavaScript value to attach to the node
2142
+ * @returns - The node ID (`bigint`)
2143
+ * @throws `TaffyError` if the node cannot be created
2144
+ *
2145
+ * @example
2146
+ * ```typescript
2147
+ * interface TextContext { text: string; isBold: boolean; }
2148
+ *
2149
+ * const style = new Style();
2150
+ * const context: TextContext = { text: "Hello, World!", isBold: true };
2151
+ * const nodeId: bigint = tree.newLeafWithContext(style, context);
2152
+ * ```
2153
+ * @param {Style} style
2154
+ * @param {any} context
2155
+ * @returns {bigint}
2156
+ */
2157
+ newLeafWithContext(style, context) {
2158
+ _assertClass(style, Style);
2159
+ const ret = wasm.taffytree_newLeafWithContext(
2160
+ this.__wbg_ptr,
2161
+ style.__wbg_ptr,
2162
+ context,
2163
+ );
2164
+ if (ret[2]) {
2165
+ throw takeFromExternrefTable0(ret[1]);
2166
+ }
2167
+ return BigInt.asUintN(64, ret[0]);
2168
+ }
2169
+ /**
2170
+ * Removes a child at a specific index
2171
+ *
2172
+ * @param parent - The parent node ID
2173
+ * @param index - The index of the child to remove (0-based)
2174
+ *
2175
+ * @returns - The removed child ID (`bigint`)
2176
+ *
2177
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2178
+ *
2179
+ * @example
2180
+ * ```typescript
2181
+ * const removedId: bigint = tree.removeChildAtIndex(parentId, 0);
2182
+ * ```
2183
+ * @param {bigint} parent
2184
+ * @param {number} index
2185
+ * @returns {bigint}
2186
+ */
2187
+ removeChildAtIndex(parent, index) {
2188
+ const ret = wasm.taffytree_removeChildAtIndex(
2189
+ this.__wbg_ptr,
2190
+ parent,
2191
+ index,
2192
+ );
2193
+ if (ret[2]) {
2194
+ throw takeFromExternrefTable0(ret[1]);
2195
+ }
2196
+ return BigInt.asUintN(64, ret[0]);
2197
+ }
2198
+ /**
2199
+ * Removes a range of children
2200
+ *
2201
+ * Removes children from `start_index` (inclusive) to `end_index` (exclusive).
2202
+ *
2203
+ * @param parent - The parent node ID
2204
+ * @param start_index - Start of range (inclusive)
2205
+ * @param end_index - End of range (exclusive)
2206
+ *
2207
+ * @throws `TaffyError` if the parent node does not exist or range is invalid
2208
+ *
2209
+ * @example
2210
+ * ```typescript
2211
+ * tree.removeChildrenRange(parentId, 1, 3);
2212
+ * ```
2213
+ * @param {bigint} parent
2214
+ * @param {number} start_index
2215
+ * @param {number} end_index
2216
+ */
2217
+ removeChildrenRange(parent, start_index, end_index) {
2218
+ const ret = wasm.taffytree_removeChildrenRange(
2219
+ this.__wbg_ptr,
2220
+ parent,
2221
+ start_index,
2222
+ end_index,
2223
+ );
2224
+ if (ret[1]) {
2225
+ throw takeFromExternrefTable0(ret[0]);
2226
+ }
2227
+ }
2228
+ /**
2229
+ * Replaces a child at a specific index
2230
+ *
2231
+ * @param parent - The parent node ID
2232
+ * @param index - The index of the child to replace (0-based)
2233
+ * @param new_child - The new child node ID
2234
+ *
2235
+ * @returns - The replaced (old) child ID (`bigint`)
2236
+ *
2237
+ * @throws `TaffyError` if the parent node does not exist or index is out of bounds
2238
+ *
2239
+ * @example
2240
+ * ```typescript
2241
+ * const oldChildId: bigint = tree.replaceChildAtIndex(parentId, 1, newChildId);
2242
+ * ```
2243
+ * @param {bigint} parent
2244
+ * @param {number} index
2245
+ * @param {bigint} new_child
2246
+ * @returns {bigint}
2247
+ */
2248
+ replaceChildAtIndex(parent, index, new_child) {
2249
+ const ret = wasm.taffytree_replaceChildAtIndex(
2250
+ this.__wbg_ptr,
2251
+ parent,
2252
+ index,
2253
+ new_child,
2254
+ );
2255
+ if (ret[2]) {
2256
+ throw takeFromExternrefTable0(ret[1]);
2257
+ }
2258
+ return BigInt.asUintN(64, ret[0]);
2259
+ }
2260
+ /**
2261
+ * Computes layout with a custom measure function for leaf nodes
2262
+ *
2263
+ * Use this when you have leaf nodes with dynamic content (like text)
2264
+ * that needs to be measured during layout. The measure function is
2265
+ * called for each leaf node that needs measurement.
2266
+ *
2267
+ * @param node - The root node ID to compute layout for
2268
+ * @param available_space - The available space constraints
2269
+ * @param measure_func - A function that measures leaf node content
2270
+ *
2271
+ * @throws `TaffyError` if the node does not exist or available space is invalid
2272
+ *
2273
+ * @example
2274
+ * ```typescript
2275
+ * tree.computeLayoutWithMeasure(
2276
+ * rootId,
2277
+ * { width: { Definite: 800 }, height: "MaxContent" },
2278
+ * (known, available, node, context, style) => {
2279
+ * if (context?.text) {
2280
+ * const measured = measureText(context.text, available.width);
2281
+ * return { width: measured.width, height: measured.height };
2282
+ * }
2283
+ * return { width: 0, height: 0 };
2284
+ * }
2285
+ * );
2286
+ * ```
2287
+ * @param {bigint} node
2288
+ * @param {Size<AvailableSpace>} available_space
2289
+ * @param {MeasureFunction} measure_func
2290
+ */
2291
+ computeLayoutWithMeasure(node, available_space, measure_func) {
2292
+ const ret = wasm.taffytree_computeLayoutWithMeasure(
2293
+ this.__wbg_ptr,
2294
+ node,
2295
+ available_space,
2296
+ measure_func,
2297
+ );
2298
+ if (ret[1]) {
2299
+ throw takeFromExternrefTable0(ret[0]);
2300
+ }
2301
+ }
2302
+ /**
2303
+ * Gets context values for multiple nodes at once
2304
+ *
2305
+ * This is more efficient than calling `getNodeContext()` multiple times
2306
+ * when you need to access contexts for many nodes.
2307
+ *
2308
+ * @param children - Array of node IDs
2309
+ *
2310
+ * @returns - Array of context values (undefined for nodes without context)
2311
+ *
2312
+ * @example
2313
+ * ```typescript
2314
+ * const nodes = BigUint64Array.from([id1, id2]);
2315
+ * const contexts = tree.getDisjointNodeContextMut(nodes);
2316
+ * ```
2317
+ * @param {BigUint64Array} children
2318
+ * @returns {any[]}
2319
+ */
2320
+ getDisjointNodeContextMut(children) {
2321
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
2322
+ const len0 = WASM_VECTOR_LEN;
2323
+ const ret = wasm.taffytree_getDisjointNodeContextMut(
2324
+ this.__wbg_ptr,
2325
+ ptr0,
2326
+ len0,
2327
+ );
2328
+ if (ret[3]) {
2329
+ throw takeFromExternrefTable0(ret[2]);
2330
+ }
2331
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
2332
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2333
+ return v2;
2334
+ }
2335
+ /**
2336
+ * Creates a new empty TaffyTree
2337
+ *
2338
+ * The tree starts with no nodes. Use `newLeaf()` or `newWithChildren()`
2339
+ * to add nodes.
2340
+ *
2341
+ * @example
2342
+ * ```typescript
2343
+ * const tree: TaffyTree = new TaffyTree();
2344
+ * ```
2345
+ */
2346
+ constructor() {
2347
+ const ret = wasm.taffytree_new();
2348
+ this.__wbg_ptr = ret >>> 0;
2349
+ TaffyTreeFinalization.register(this, this.__wbg_ptr, this);
2350
+ return this;
2351
+ }
2352
+ /**
2353
+ * Removes all nodes from the tree
2354
+ *
2355
+ * This clears the entire tree, removing all nodes and their relationships.
2356
+ * Use this to reset the tree for reuse.
2357
+ *
2358
+ * @example
2359
+ * ```typescript
2360
+ * tree.clear();
2361
+ * console.log(tree.totalNodeCount());
2362
+ * ```
2363
+ */
2364
+ clear() {
2365
+ wasm.taffytree_clear(this.__wbg_ptr);
2366
+ }
2367
+ /**
2368
+ * Checks if a node is dirty (needs re-layout)
2369
+ *
2370
+ * A node is dirty if its style or content has changed since the last
2371
+ * layout computation.
2372
+ *
2373
+ * @param node - The node ID to check
2374
+ *
2375
+ * @returns - true if dirty, false otherwise
2376
+ *
2377
+ * @throws `TaffyError` if the node does not exist
2378
+ *
2379
+ * @example
2380
+ * ```typescript
2381
+ * if (tree.dirty(nodeId)) {
2382
+ * tree.computeLayout(rootId, availableSpace);
2383
+ * }
2384
+ * ```
2385
+ * @param {bigint} node
2386
+ * @returns {boolean}
2387
+ */
2388
+ dirty(node) {
2389
+ const ret = wasm.taffytree_dirty(this.__wbg_ptr, node);
2390
+ if (ret[2]) {
2391
+ throw takeFromExternrefTable0(ret[1]);
2392
+ }
2393
+ return ret[0] !== 0;
2394
+ }
2395
+ /**
2396
+ * Gets the style for a node
2397
+ *
2398
+ * @param node - The node ID
2399
+ *
2400
+ * @returns - The node's `Style`
2401
+ *
2402
+ * @throws `TaffyError` if the node does not exist
2403
+ *
2404
+ * @example
2405
+ * ```typescript
2406
+ * const style: Style = tree.getStyle(nodeId);
2407
+ * console.log('Flex grow:', style.flexGrow);
2408
+ * ```
2409
+ * @param {bigint} node
2410
+ * @returns {Style}
2411
+ */
2412
+ getStyle(node) {
2413
+ const ret = wasm.taffytree_getStyle(this.__wbg_ptr, node);
2414
+ if (ret[2]) {
2415
+ throw takeFromExternrefTable0(ret[1]);
2416
+ }
2417
+ return Style.__wrap(ret[0]);
2418
+ }
2419
+ /**
2420
+ * Gets the computed layout for a node
2421
+ *
2422
+ * Call this after `computeLayout()` to retrieve the computed position
2423
+ * and size for a node.
2424
+ *
2425
+ * @param node - The node ID
2426
+ *
2427
+ * @returns - The computed `Layout`
2428
+ *
2429
+ * @throws `TaffyError` if the node does not exist
2430
+ *
2431
+ * @example
2432
+ * ```typescript
2433
+ * tree.computeLayout(rootId, { width: { Definite: 800 }, height: { Definite: 600 } });
2434
+ * const layout: Layout = tree.getLayout(nodeId);
2435
+ * console.log(`Position: (${layout.x}, ${layout.y}), Size: ${layout.width}x${layout.height}`);
2436
+ * ```
2437
+ * @param {bigint} node
2438
+ * @returns {Layout}
2439
+ */
2440
+ getLayout(node) {
2441
+ const ret = wasm.taffytree_getLayout(this.__wbg_ptr, node);
2442
+ if (ret[2]) {
2443
+ throw takeFromExternrefTable0(ret[1]);
2444
+ }
2445
+ return Layout.__wrap(ret[0]);
2446
+ }
2447
+ /**
2448
+ * Gets the parent of a node
2449
+ *
2450
+ * @param child - The child node ID
2451
+ *
2452
+ * @returns - The parent node ID, or `undefined` if the node has no parent
2453
+ *
2454
+ * @example
2455
+ * ```typescript
2456
+ * const parentId: bigint | undefined = tree.parent(childId);
2457
+ * ```
2458
+ * @param {bigint} child
2459
+ * @returns {bigint | undefined}
2460
+ */
2461
+ parent(child) {
2462
+ const ret = wasm.taffytree_parent(this.__wbg_ptr, child);
2463
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
2464
+ }
2465
+ /**
2466
+ * Removes a node from the tree
2467
+ *
2468
+ * The node and all its descendants are removed. If the node has a parent,
2469
+ * it is automatically removed from the parent's children.
2470
+ *
2471
+ * @param node - The node ID to remove
2472
+ *
2473
+ * @returns - The removed node ID (`bigint`)
2474
+ *
2475
+ * @throws `TaffyError` if the node does not exist
2476
+ *
2477
+ * @example
2478
+ * ```typescript
2479
+ * try {
2480
+ * const removedId: bigint = tree.remove(nodeId);
2481
+ * } catch (e) {
2482
+ * console.error("Node doesn't exist");
2483
+ * }
2484
+ * ```
2485
+ * @param {bigint} node
2486
+ * @returns {bigint}
2487
+ */
2488
+ remove(node) {
2489
+ const ret = wasm.taffytree_remove(this.__wbg_ptr, node);
2490
+ if (ret[2]) {
2491
+ throw takeFromExternrefTable0(ret[1]);
2492
+ }
2493
+ return BigInt.asUintN(64, ret[0]);
2494
+ }
2495
+ /**
2496
+ * Gets all children of a node
2497
+ *
2498
+ * @param parent - The parent node ID
2499
+ *
2500
+ * @returns - Array of child node IDs (`BigUint64Array`)
2501
+ *
2502
+ * @throws `TaffyError` if the parent node does not exist
2503
+ *
2504
+ * @example
2505
+ * ```typescript
2506
+ * const children: BigUint64Array = tree.children(parentId);
2507
+ * ```
2508
+ * @param {bigint} parent
2509
+ * @returns {BigUint64Array}
2510
+ */
2511
+ children(parent) {
2512
+ const ret = wasm.taffytree_children(this.__wbg_ptr, parent);
2513
+ if (ret[3]) {
2514
+ throw takeFromExternrefTable0(ret[2]);
2515
+ }
2516
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
2517
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2518
+ return v1;
2519
+ }
2520
+ /**
2521
+ * Creates a new leaf node with the given style
2522
+ *
2523
+ * A leaf node has no children. Use this for elements that contain
2524
+ * content (like text) rather than other elements.
2525
+ *
2526
+ * @param style - The style configuration for the node
2527
+ * @returns - The node ID (`bigint`)
2528
+ * @throws `TaffyError` if the node cannot be created
2529
+ *
2530
+ * @example
2531
+ * ```typescript
2532
+ * const style = new Style();
2533
+ * style.size = { width: { Length: 100 }, height: { Length: 50 } };
2534
+ * const nodeId: bigint = tree.newLeaf(style);
2535
+ * ```
2536
+ * @param {Style} style
2537
+ * @returns {bigint}
2538
+ */
2539
+ newLeaf(style) {
2540
+ _assertClass(style, Style);
2541
+ const ret = wasm.taffytree_newLeaf(this.__wbg_ptr, style.__wbg_ptr);
2542
+ if (ret[2]) {
2543
+ throw takeFromExternrefTable0(ret[1]);
2544
+ }
2545
+ return BigInt.asUintN(64, ret[0]);
2546
+ }
2547
+ /**
2548
+ * Appends a child node to a parent
2549
+ *
2550
+ * The child is added as the last child of the parent.
2551
+ *
2552
+ * @param parent - The parent node ID
2553
+ * @param child - The child node ID to add
2554
+ *
2555
+ * @throws `TaffyError` if the parent or child node does not exist
2556
+ *
2557
+ * @example
2558
+ * ```typescript
2559
+ * tree.addChild(parentId, childId);
2560
+ * ```
2561
+ * @param {bigint} parent
2562
+ * @param {bigint} child
2563
+ */
2564
+ addChild(parent, child) {
2565
+ const ret = wasm.taffytree_addChild(this.__wbg_ptr, parent, child);
2566
+ if (ret[1]) {
2567
+ throw takeFromExternrefTable0(ret[0]);
2568
+ }
2569
+ }
2570
+ /**
2571
+ * Sets the style for an existing node
2572
+ *
2573
+ * This replaces the node's current style with the provided one.
2574
+ * The node will be marked as dirty and require re-layout.
2575
+ *
2576
+ * @param node - The node ID
2577
+ * @param style - The new style configuration
2578
+ *
2579
+ * @throws `TaffyError` if the node does not exist
2580
+ *
2581
+ * @example
2582
+ * ```typescript
2583
+ * const newStyle = new Style();
2584
+ * newStyle.flexGrow = 2;
2585
+ * tree.setStyle(nodeId, newStyle);
2586
+ * ```
2587
+ * @param {bigint} node
2588
+ * @param {Style} style
2589
+ */
2590
+ setStyle(node, style) {
2591
+ _assertClass(style, Style);
2592
+ const ret = wasm.taffytree_setStyle(this.__wbg_ptr, node, style.__wbg_ptr);
2593
+ if (ret[1]) {
2594
+ throw takeFromExternrefTable0(ret[0]);
2595
+ }
2596
+ }
1751
2597
  }
1752
- if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
2598
+ if (Symbol.dispose)
2599
+ TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
1753
2600
 
1754
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
2601
+ const EXPECTED_RESPONSE_TYPES = new Set(["basic", "cors", "default"]);
1755
2602
 
1756
2603
  async function __wbg_load(module, imports) {
1757
- if (typeof Response === 'function' && module instanceof Response) {
1758
- if (typeof WebAssembly.instantiateStreaming === 'function') {
1759
- try {
1760
- return await WebAssembly.instantiateStreaming(module, imports);
1761
- } catch (e) {
1762
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
1763
-
1764
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1765
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1766
-
1767
- } else {
1768
- throw e;
1769
- }
1770
- }
2604
+ if (typeof Response === "function" && module instanceof Response) {
2605
+ if (typeof WebAssembly.instantiateStreaming === "function") {
2606
+ try {
2607
+ return await WebAssembly.instantiateStreaming(module, imports);
2608
+ } catch (e) {
2609
+ const validResponse =
2610
+ module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
2611
+
2612
+ if (
2613
+ validResponse &&
2614
+ module.headers.get("Content-Type") !== "application/wasm"
2615
+ ) {
2616
+ console.warn(
2617
+ "`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",
2618
+ e,
2619
+ );
2620
+ } else {
2621
+ throw e;
1771
2622
  }
2623
+ }
2624
+ }
1772
2625
 
1773
- const bytes = await module.arrayBuffer();
1774
- return await WebAssembly.instantiate(bytes, imports);
1775
- } else {
1776
- const instance = await WebAssembly.instantiate(module, imports);
2626
+ const bytes = await module.arrayBuffer();
2627
+ return await WebAssembly.instantiate(bytes, imports);
2628
+ } else {
2629
+ const instance = await WebAssembly.instantiate(module, imports);
1777
2630
 
1778
- if (instance instanceof WebAssembly.Instance) {
1779
- return { instance, module };
1780
- } else {
1781
- return instance;
1782
- }
2631
+ if (instance instanceof WebAssembly.Instance) {
2632
+ return { instance, module };
2633
+ } else {
2634
+ return instance;
1783
2635
  }
2636
+ }
1784
2637
  }
1785
2638
 
1786
2639
  function __wbg_get_imports() {
1787
- const imports = {};
1788
- imports.wbg = {};
1789
- imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
1790
- const ret = Error(getStringFromWasm0(arg0, arg1));
1791
- return ret;
1792
- };
1793
- imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
1794
- const ret = Number(arg0);
1795
- return ret;
1796
- };
1797
- imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
1798
- const ret = String(arg1);
1799
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1800
- const len1 = WASM_VECTOR_LEN;
1801
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1802
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1803
- };
1804
- imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
1805
- const v = arg0;
1806
- const ret = typeof(v) === 'boolean' ? v : undefined;
1807
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1808
- };
1809
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
1810
- const ret = debugString(arg1);
1811
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1812
- const len1 = WASM_VECTOR_LEN;
1813
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1814
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1815
- };
1816
- imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
1817
- const ret = arg0 in arg1;
1818
- return ret;
1819
- };
1820
- imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
1821
- const val = arg0;
1822
- const ret = typeof(val) === 'object' && val !== null;
1823
- return ret;
1824
- };
1825
- imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
1826
- const ret = typeof(arg0) === 'string';
1827
- return ret;
1828
- };
1829
- imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
1830
- const ret = arg0 === undefined;
1831
- return ret;
1832
- };
1833
- imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
1834
- const ret = arg0 == arg1;
1835
- return ret;
1836
- };
1837
- imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
1838
- const obj = arg1;
1839
- const ret = typeof(obj) === 'number' ? obj : undefined;
1840
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1841
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1842
- };
1843
- imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
1844
- const obj = arg1;
1845
- const ret = typeof(obj) === 'string' ? obj : undefined;
1846
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1847
- var len1 = WASM_VECTOR_LEN;
1848
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1849
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1850
- };
1851
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
1852
- throw new Error(getStringFromWasm0(arg0, arg1));
1853
- };
1854
- imports.wbg.__wbg_apply_52e9ae668d017009 = function() { return handleError(function (arg0, arg1, arg2) {
1855
- const ret = arg0.apply(arg1, arg2);
1856
- return ret;
1857
- }, arguments) };
1858
- imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
1859
- const ret = Object.entries(arg0);
1860
- return ret;
1861
- };
1862
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
1863
- let deferred0_0;
1864
- let deferred0_1;
1865
- try {
1866
- deferred0_0 = arg0;
1867
- deferred0_1 = arg1;
1868
- console.error(getStringFromWasm0(arg0, arg1));
1869
- } finally {
1870
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1871
- }
1872
- };
1873
- imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
1874
- const ret = arg0[arg1 >>> 0];
1875
- return ret;
1876
- };
1877
- imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
1878
- const ret = arg0[arg1];
1879
- return ret;
1880
- };
1881
- imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
1882
- let result;
1883
- try {
1884
- result = arg0 instanceof ArrayBuffer;
1885
- } catch (_) {
1886
- result = false;
1887
- }
1888
- const ret = result;
1889
- return ret;
1890
- };
1891
- imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
1892
- let result;
1893
- try {
1894
- result = arg0 instanceof Uint8Array;
1895
- } catch (_) {
1896
- result = false;
1897
- }
1898
- const ret = result;
1899
- return ret;
1900
- };
1901
- imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
1902
- const ret = arg0.length;
1903
- return ret;
1904
- };
1905
- imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
1906
- const ret = arg0.length;
1907
- return ret;
1908
- };
1909
- imports.wbg.__wbg_log_b0b3f53073d3e573 = function(arg0, arg1) {
1910
- console.log(getStringFromWasm0(arg0, arg1));
1911
- };
1912
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
1913
- const ret = new Object();
1914
- return ret;
1915
- };
1916
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
1917
- const ret = new Array();
1918
- return ret;
1919
- };
1920
- imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
1921
- const ret = new Uint8Array(arg0);
1922
- return ret;
1923
- };
1924
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
1925
- const ret = new Error();
1926
- return ret;
1927
- };
1928
- imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
1929
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1930
- };
1931
- imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
1932
- const ret = arg0.push(arg1);
1933
- return ret;
1934
- };
1935
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
1936
- arg0[arg1] = arg2;
1937
- };
1938
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
1939
- const ret = arg1.stack;
1940
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1941
- const len1 = WASM_VECTOR_LEN;
1942
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1943
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1944
- };
1945
- imports.wbg.__wbg_stringify_655a6390e1f5eb6b = function() { return handleError(function (arg0) {
1946
- const ret = JSON.stringify(arg0);
1947
- return ret;
1948
- }, arguments) };
1949
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1950
- // Cast intrinsic for `Ref(String) -> Externref`.
1951
- const ret = getStringFromWasm0(arg0, arg1);
1952
- return ret;
1953
- };
1954
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1955
- // Cast intrinsic for `F64 -> Externref`.
1956
- const ret = arg0;
1957
- return ret;
1958
- };
1959
- imports.wbg.__wbindgen_init_externref_table = function() {
1960
- const table = wasm.__wbindgen_externrefs;
1961
- const offset = table.grow(4);
1962
- table.set(0, undefined);
1963
- table.set(offset + 0, undefined);
1964
- table.set(offset + 1, null);
1965
- table.set(offset + 2, true);
1966
- table.set(offset + 3, false);
1967
- };
1968
-
1969
- return imports;
2640
+ const imports = {};
2641
+ imports.wbg = {};
2642
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function (arg0, arg1) {
2643
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2644
+ return ret;
2645
+ };
2646
+ imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function (arg0) {
2647
+ const ret = Number(arg0);
2648
+ return ret;
2649
+ };
2650
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function (arg0, arg1) {
2651
+ const ret = String(arg1);
2652
+ const ptr1 = passStringToWasm0(
2653
+ ret,
2654
+ wasm.__wbindgen_malloc,
2655
+ wasm.__wbindgen_realloc,
2656
+ );
2657
+ const len1 = WASM_VECTOR_LEN;
2658
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2659
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2660
+ };
2661
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function (
2662
+ arg0,
2663
+ arg1,
2664
+ ) {
2665
+ const v = arg1;
2666
+ const ret = typeof v === "bigint" ? v : undefined;
2667
+ getDataViewMemory0().setBigInt64(
2668
+ arg0 + 8 * 1,
2669
+ isLikeNone(ret) ? BigInt(0) : ret,
2670
+ true,
2671
+ );
2672
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2673
+ };
2674
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function (arg0) {
2675
+ const v = arg0;
2676
+ const ret = typeof v === "boolean" ? v : undefined;
2677
+ return isLikeNone(ret) ? 0xffffff : ret ? 1 : 0;
2678
+ };
2679
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function (
2680
+ arg0,
2681
+ arg1,
2682
+ ) {
2683
+ const ret = debugString(arg1);
2684
+ const ptr1 = passStringToWasm0(
2685
+ ret,
2686
+ wasm.__wbindgen_malloc,
2687
+ wasm.__wbindgen_realloc,
2688
+ );
2689
+ const len1 = WASM_VECTOR_LEN;
2690
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2691
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2692
+ };
2693
+ imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function (arg0, arg1) {
2694
+ const ret = arg0 in arg1;
2695
+ return ret;
2696
+ };
2697
+ imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function (arg0) {
2698
+ const ret = typeof arg0 === "bigint";
2699
+ return ret;
2700
+ };
2701
+ imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function (arg0) {
2702
+ const ret = typeof arg0 === "function";
2703
+ return ret;
2704
+ };
2705
+ imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function (arg0) {
2706
+ const ret = arg0 === null;
2707
+ return ret;
2708
+ };
2709
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function (arg0) {
2710
+ const val = arg0;
2711
+ const ret = typeof val === "object" && val !== null;
2712
+ return ret;
2713
+ };
2714
+ imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function (arg0) {
2715
+ const ret = typeof arg0 === "string";
2716
+ return ret;
2717
+ };
2718
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function (arg0) {
2719
+ const ret = arg0 === undefined;
2720
+ return ret;
2721
+ };
2722
+ imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function (
2723
+ arg0,
2724
+ arg1,
2725
+ ) {
2726
+ const ret = arg0 === arg1;
2727
+ return ret;
2728
+ };
2729
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function (
2730
+ arg0,
2731
+ arg1,
2732
+ ) {
2733
+ const ret = arg0 == arg1;
2734
+ return ret;
2735
+ };
2736
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function (
2737
+ arg0,
2738
+ arg1,
2739
+ ) {
2740
+ const obj = arg1;
2741
+ const ret = typeof obj === "number" ? obj : undefined;
2742
+ getDataViewMemory0().setFloat64(
2743
+ arg0 + 8 * 1,
2744
+ isLikeNone(ret) ? 0 : ret,
2745
+ true,
2746
+ );
2747
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2748
+ };
2749
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function (
2750
+ arg0,
2751
+ arg1,
2752
+ ) {
2753
+ const obj = arg1;
2754
+ const ret = typeof obj === "string" ? obj : undefined;
2755
+ var ptr1 = isLikeNone(ret)
2756
+ ? 0
2757
+ : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2758
+ var len1 = WASM_VECTOR_LEN;
2759
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2760
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2761
+ };
2762
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function (arg0, arg1) {
2763
+ throw new Error(getStringFromWasm0(arg0, arg1));
2764
+ };
2765
+ imports.wbg.__wbg_apply_52e9ae668d017009 = function () {
2766
+ return handleError(function (arg0, arg1, arg2) {
2767
+ const ret = arg0.apply(arg1, arg2);
2768
+ return ret;
2769
+ }, arguments);
2770
+ };
2771
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function () {
2772
+ return handleError(function (arg0, arg1) {
2773
+ const ret = arg0.call(arg1);
2774
+ return ret;
2775
+ }, arguments);
2776
+ };
2777
+ imports.wbg.__wbg_entries_83c79938054e065f = function (arg0) {
2778
+ const ret = Object.entries(arg0);
2779
+ return ret;
2780
+ };
2781
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function (arg0, arg1) {
2782
+ let deferred0_0;
2783
+ let deferred0_1;
2784
+ try {
2785
+ deferred0_0 = arg0;
2786
+ deferred0_1 = arg1;
2787
+ console.error(getStringFromWasm0(arg0, arg1));
2788
+ } finally {
2789
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2790
+ }
2791
+ };
2792
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function (arg0, arg1) {
2793
+ const ret = arg0[arg1 >>> 0];
2794
+ return ret;
2795
+ };
2796
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function () {
2797
+ return handleError(function (arg0, arg1) {
2798
+ const ret = Reflect.get(arg0, arg1);
2799
+ return ret;
2800
+ }, arguments);
2801
+ };
2802
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function (arg0, arg1) {
2803
+ const ret = arg0[arg1];
2804
+ return ret;
2805
+ };
2806
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function (arg0) {
2807
+ let result;
2808
+ try {
2809
+ result = arg0 instanceof ArrayBuffer;
2810
+ } catch (_) {
2811
+ result = false;
2812
+ }
2813
+ const ret = result;
2814
+ return ret;
2815
+ };
2816
+ imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function (arg0) {
2817
+ let result;
2818
+ try {
2819
+ result = arg0 instanceof Map;
2820
+ } catch (_) {
2821
+ result = false;
2822
+ }
2823
+ const ret = result;
2824
+ return ret;
2825
+ };
2826
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function (arg0) {
2827
+ let result;
2828
+ try {
2829
+ result = arg0 instanceof Uint8Array;
2830
+ } catch (_) {
2831
+ result = false;
2832
+ }
2833
+ const ret = result;
2834
+ return ret;
2835
+ };
2836
+ imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function (arg0) {
2837
+ const ret = Array.isArray(arg0);
2838
+ return ret;
2839
+ };
2840
+ imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function (arg0) {
2841
+ const ret = Number.isSafeInteger(arg0);
2842
+ return ret;
2843
+ };
2844
+ imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function () {
2845
+ const ret = Symbol.iterator;
2846
+ return ret;
2847
+ };
2848
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function (arg0) {
2849
+ const ret = arg0.length;
2850
+ return ret;
2851
+ };
2852
+ imports.wbg.__wbg_length_d45040a40c570362 = function (arg0) {
2853
+ const ret = arg0.length;
2854
+ return ret;
2855
+ };
2856
+ imports.wbg.__wbg_log_e4aa4f07b01ebf55 = function (arg0, arg1) {
2857
+ console.log(getStringFromWasm0(arg0, arg1));
2858
+ };
2859
+ imports.wbg.__wbg_new_1ba21ce319a06297 = function () {
2860
+ const ret = new Object();
2861
+ return ret;
2862
+ };
2863
+ imports.wbg.__wbg_new_25f239778d6112b9 = function () {
2864
+ const ret = new Array();
2865
+ return ret;
2866
+ };
2867
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function (arg0) {
2868
+ const ret = new Uint8Array(arg0);
2869
+ return ret;
2870
+ };
2871
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function () {
2872
+ const ret = new Error();
2873
+ return ret;
2874
+ };
2875
+ imports.wbg.__wbg_next_138a17bbf04e926c = function (arg0) {
2876
+ const ret = arg0.next;
2877
+ return ret;
2878
+ };
2879
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function (
2880
+ arg0,
2881
+ arg1,
2882
+ arg2,
2883
+ ) {
2884
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
2885
+ };
2886
+ imports.wbg.__wbg_push_7d9be8f38fc13975 = function (arg0, arg1) {
2887
+ const ret = arg0.push(arg1);
2888
+ return ret;
2889
+ };
2890
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function (arg0, arg1, arg2) {
2891
+ arg0[arg1] = arg2;
2892
+ };
2893
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function (arg0, arg1) {
2894
+ const ret = arg1.stack;
2895
+ const ptr1 = passStringToWasm0(
2896
+ ret,
2897
+ wasm.__wbindgen_malloc,
2898
+ wasm.__wbindgen_realloc,
2899
+ );
2900
+ const len1 = WASM_VECTOR_LEN;
2901
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2902
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2903
+ };
2904
+ imports.wbg.__wbg_stringify_655a6390e1f5eb6b = function () {
2905
+ return handleError(function (arg0) {
2906
+ const ret = JSON.stringify(arg0);
2907
+ return ret;
2908
+ }, arguments);
2909
+ };
2910
+ imports.wbg.__wbg_style_new = function (arg0) {
2911
+ const ret = Style.__wrap(arg0);
2912
+ return ret;
2913
+ };
2914
+ imports.wbg.__wbg_taffyerror_new = function (arg0) {
2915
+ const ret = TaffyError.__wrap(arg0);
2916
+ return ret;
2917
+ };
2918
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function (arg0, arg1) {
2919
+ // Cast intrinsic for `Ref(String) -> Externref`.
2920
+ const ret = getStringFromWasm0(arg0, arg1);
2921
+ return ret;
2922
+ };
2923
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function (arg0) {
2924
+ // Cast intrinsic for `U64 -> Externref`.
2925
+ const ret = BigInt.asUintN(64, arg0);
2926
+ return ret;
2927
+ };
2928
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function (arg0) {
2929
+ // Cast intrinsic for `I64 -> Externref`.
2930
+ const ret = arg0;
2931
+ return ret;
2932
+ };
2933
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function (arg0) {
2934
+ // Cast intrinsic for `F64 -> Externref`.
2935
+ const ret = arg0;
2936
+ return ret;
2937
+ };
2938
+ imports.wbg.__wbindgen_init_externref_table = function () {
2939
+ const table = wasm.__wbindgen_externrefs;
2940
+ const offset = table.grow(4);
2941
+ table.set(0, undefined);
2942
+ table.set(offset + 0, undefined);
2943
+ table.set(offset + 1, null);
2944
+ table.set(offset + 2, true);
2945
+ table.set(offset + 3, false);
2946
+ };
2947
+
2948
+ return imports;
1970
2949
  }
1971
2950
 
1972
2951
  function __wbg_finalize_init(instance, module) {
1973
- wasm = instance.exports;
1974
- __wbg_init.__wbindgen_wasm_module = module;
1975
- cachedBigUint64ArrayMemory0 = null;
1976
- cachedDataViewMemory0 = null;
1977
- cachedUint8ArrayMemory0 = null;
1978
-
1979
-
1980
- wasm.__wbindgen_start();
1981
- return wasm;
2952
+ wasm = instance.exports;
2953
+ __wbg_init.__wbindgen_wasm_module = module;
2954
+ cachedBigUint64ArrayMemory0 = null;
2955
+ cachedDataViewMemory0 = null;
2956
+ cachedUint8ArrayMemory0 = null;
2957
+
2958
+ wasm.__wbindgen_start();
2959
+ return wasm;
1982
2960
  }
1983
2961
 
1984
2962
  function initSync(module) {
1985
- if (wasm !== undefined) return wasm;
1986
-
1987
-
1988
- if (typeof module !== 'undefined') {
1989
- if (Object.getPrototypeOf(module) === Object.prototype) {
1990
- ({module} = module)
1991
- } else {
1992
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1993
- }
1994
- }
2963
+ if (wasm !== undefined) return wasm;
1995
2964
 
1996
- const imports = __wbg_get_imports();
1997
- if (!(module instanceof WebAssembly.Module)) {
1998
- module = new WebAssembly.Module(module);
1999
- }
2000
- const instance = new WebAssembly.Instance(module, imports);
2001
- return __wbg_finalize_init(instance, module);
2965
+ if (typeof module !== "undefined") {
2966
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2967
+ ({ module } = module);
2968
+ } else {
2969
+ console.warn(
2970
+ "using deprecated parameters for `initSync()`; pass a single object instead",
2971
+ );
2972
+ }
2973
+ }
2974
+
2975
+ const imports = __wbg_get_imports();
2976
+ if (!(module instanceof WebAssembly.Module)) {
2977
+ module = new WebAssembly.Module(module);
2978
+ }
2979
+ const instance = new WebAssembly.Instance(module, imports);
2980
+ return __wbg_finalize_init(instance, module);
2002
2981
  }
2003
2982
 
2004
2983
  async function __wbg_init(module_or_path) {
2005
- if (wasm !== undefined) return wasm;
2984
+ if (wasm !== undefined) return wasm;
2006
2985
 
2007
-
2008
- if (typeof module_or_path !== 'undefined') {
2009
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2010
- ({module_or_path} = module_or_path)
2011
- } else {
2012
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2013
- }
2986
+ if (typeof module_or_path !== "undefined") {
2987
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2988
+ ({ module_or_path } = module_or_path);
2989
+ } else {
2990
+ console.warn(
2991
+ "using deprecated parameters for the initialization function; pass a single object instead",
2992
+ );
2014
2993
  }
2994
+ }
2015
2995
 
2016
- if (typeof module_or_path === 'undefined') {
2017
- module_or_path = new URL('taffy_js_bg.wasm', import.meta.url);
2018
- }
2019
- const imports = __wbg_get_imports();
2996
+ if (typeof module_or_path === "undefined") {
2997
+ module_or_path = new URL("taffy_js_bg.wasm", import.meta.url);
2998
+ }
2999
+ const imports = __wbg_get_imports();
2020
3000
 
2021
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2022
- module_or_path = fetch(module_or_path);
2023
- }
3001
+ if (
3002
+ typeof module_or_path === "string" ||
3003
+ (typeof Request === "function" && module_or_path instanceof Request) ||
3004
+ (typeof URL === "function" && module_or_path instanceof URL)
3005
+ ) {
3006
+ module_or_path = fetch(module_or_path);
3007
+ }
2024
3008
 
2025
- const { instance, module } = await __wbg_load(await module_or_path, imports);
3009
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2026
3010
 
2027
- return __wbg_finalize_init(instance, module);
3011
+ return __wbg_finalize_init(instance, module);
2028
3012
  }
2029
3013
 
2030
3014
  export { initSync };