taffy-js 0.2.0 → 0.2.1

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 ADDED
@@ -0,0 +1,1789 @@
1
+ let wasm;
2
+
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_externrefs.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function _assertClass(instance, klass) {
10
+ if (!(instance instanceof klass)) {
11
+ throw new Error(`expected instance of ${klass.name}`);
12
+ }
13
+ }
14
+
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];
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
+ }
79
+
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;
89
+ }
90
+
91
+ function getArrayU64FromWasm0(ptr, len) {
92
+ ptr = ptr >>> 0;
93
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
94
+ }
95
+
96
+ function getArrayU8FromWasm0(ptr, len) {
97
+ ptr = ptr >>> 0;
98
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
99
+ }
100
+
101
+ let cachedBigUint64ArrayMemory0 = null;
102
+ function getBigUint64ArrayMemory0() {
103
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
104
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
105
+ }
106
+ return cachedBigUint64ArrayMemory0;
107
+ }
108
+
109
+ let cachedDataViewMemory0 = null;
110
+ 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;
115
+ }
116
+
117
+ function getStringFromWasm0(ptr, len) {
118
+ ptr = ptr >>> 0;
119
+ return decodeText(ptr, len);
120
+ }
121
+
122
+ let cachedUint8ArrayMemory0 = null;
123
+ function getUint8ArrayMemory0() {
124
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
125
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
126
+ }
127
+ return cachedUint8ArrayMemory0;
128
+ }
129
+
130
+ 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
+ }
137
+ }
138
+
139
+ function isLikeNone(x) {
140
+ return x === undefined || x === null;
141
+ }
142
+
143
+ 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;
148
+ }
149
+
150
+ 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
+ }
158
+
159
+ let len = arg.length;
160
+ let ptr = malloc(len, 1) >>> 0;
161
+
162
+ const mem = getUint8ArrayMemory0();
163
+
164
+ let offset = 0;
165
+
166
+ for (; offset < len; offset++) {
167
+ const code = arg.charCodeAt(offset);
168
+ if (code > 0x7F) break;
169
+ mem[ptr + offset] = code;
170
+ }
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);
178
+
179
+ offset += ret.written;
180
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
181
+ }
182
+
183
+ WASM_VECTOR_LEN = offset;
184
+ return ptr;
185
+ }
186
+
187
+ function takeFromExternrefTable0(idx) {
188
+ const value = wasm.__wbindgen_externrefs.get(idx);
189
+ wasm.__externref_table_dealloc(idx);
190
+ return value;
191
+ }
192
+
193
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
194
+ cachedTextDecoder.decode();
195
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
196
+ let numBytesDecoded = 0;
197
+ 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));
205
+ }
206
+
207
+ const cachedTextEncoder = new TextEncoder();
208
+
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
+ }
218
+ }
219
+
220
+ let WASM_VECTOR_LEN = 0;
221
+
222
+ const StyleFinalization = (typeof FinalizationRegistry === 'undefined')
223
+ ? { register: () => {}, unregister: () => {} }
224
+ : new FinalizationRegistry(ptr => wasm.__wbg_style_free(ptr >>> 0, 1));
225
+
226
+ const TaffyTreeFinalization = (typeof FinalizationRegistry === 'undefined')
227
+ ? { register: () => {}, unregister: () => {} }
228
+ : new FinalizationRegistry(ptr => wasm.__wbg_taffytree_free(ptr >>> 0, 1));
229
+
230
+ /**
231
+ * Multi-line content alignment enum (Align Content)
232
+ *
233
+ * Controls spacing distribution between lines in a multi-line flex container.
234
+ * Corresponds to CSS `align-content` property. Only effective when `flex-wrap: wrap`.
235
+ *
236
+ * # Variants
237
+ * - `SpaceBetween`: Lines evenly distributed, first/last lines flush with edges
238
+ * - `SpaceAround`: Equal space on both sides of each line
239
+ * - `SpaceEvenly`: All spacing completely equal
240
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
241
+ */
242
+ export const AlignContent = Object.freeze({
243
+ Start: 0, "0": "Start",
244
+ End: 1, "1": "End",
245
+ FlexStart: 2, "2": "FlexStart",
246
+ FlexEnd: 3, "3": "FlexEnd",
247
+ Center: 4, "4": "Center",
248
+ Stretch: 5, "5": "Stretch",
249
+ SpaceBetween: 6, "6": "SpaceBetween",
250
+ SpaceAround: 7, "7": "SpaceAround",
251
+ SpaceEvenly: 8, "8": "SpaceEvenly",
252
+ });
253
+
254
+ /**
255
+ * Cross-axis alignment enum for children (Align Items)
256
+ *
257
+ * Defines how all children are aligned on the cross axis in a Flex/Grid container.
258
+ *
259
+ * # Variants
260
+ * - `Start/FlexStart`: Align to cross axis start
261
+ * - `End/FlexEnd`: Align to cross axis end
262
+ * - `Center`: Center alignment
263
+ * - `Baseline`: Baseline alignment (text baseline)
264
+ * - `Stretch`: Stretch to fill container
265
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
266
+ */
267
+ export const AlignItems = Object.freeze({
268
+ Start: 0, "0": "Start",
269
+ End: 1, "1": "End",
270
+ FlexStart: 2, "2": "FlexStart",
271
+ FlexEnd: 3, "3": "FlexEnd",
272
+ Center: 4, "4": "Center",
273
+ Baseline: 5, "5": "Baseline",
274
+ Stretch: 6, "6": "Stretch",
275
+ });
276
+
277
+ /**
278
+ * Cross-axis alignment enum for single element (Align Self)
279
+ *
280
+ * Overrides parent's `align-items` for a single child element's cross-axis alignment.
281
+ *
282
+ * # Variants
283
+ * - `Auto`: Inherit parent's `align-items` value
284
+ * - Other values have same meaning as `AlignItems`
285
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
286
+ */
287
+ export const AlignSelf = Object.freeze({
288
+ Auto: 0, "0": "Auto",
289
+ Start: 1, "1": "Start",
290
+ End: 2, "2": "End",
291
+ FlexStart: 3, "3": "FlexStart",
292
+ FlexEnd: 4, "4": "FlexEnd",
293
+ Center: 5, "5": "Center",
294
+ Baseline: 6, "6": "Baseline",
295
+ Stretch: 7, "7": "Stretch",
296
+ });
297
+
298
+ /**
299
+ * Display mode enum
300
+ *
301
+ * Controls the layout algorithm type for an element. Corresponds to CSS `display` property.
302
+ *
303
+ * # Variants
304
+ * - `Block`: Block-level layout, element takes full width
305
+ * - `Flex`: Flexbox layout, one-dimensional layout model
306
+ * - `Grid`: CSS Grid layout, two-dimensional layout model
307
+ * - `None`: Hidden, element does not participate in layout calculation
308
+ * @enum {0 | 1 | 2 | 3}
309
+ */
310
+ export const Display = Object.freeze({
311
+ Block: 0, "0": "Block",
312
+ Flex: 1, "1": "Flex",
313
+ Grid: 2, "2": "Grid",
314
+ None: 3, "3": "None",
315
+ });
316
+
317
+ /**
318
+ * Flex main axis direction enum
319
+ *
320
+ * Defines the direction children are laid out in a flex container. Corresponds to CSS `flex-direction` property.
321
+ *
322
+ * # Variants
323
+ * - `Row`: Horizontal direction, left to right (LTR mode)
324
+ * - `Column`: Vertical direction, top to bottom
325
+ * - `RowReverse`: Horizontal reverse, right to left
326
+ * - `ColumnReverse`: Vertical reverse, bottom to top
327
+ * @enum {0 | 1 | 2 | 3}
328
+ */
329
+ export const FlexDirection = Object.freeze({
330
+ Row: 0, "0": "Row",
331
+ Column: 1, "1": "Column",
332
+ RowReverse: 2, "2": "RowReverse",
333
+ ColumnReverse: 3, "3": "ColumnReverse",
334
+ });
335
+
336
+ /**
337
+ * Flex wrap mode enum
338
+ *
339
+ * Controls whether flex items wrap onto multiple lines. Corresponds to CSS `flex-wrap` property.
340
+ *
341
+ * # Variants
342
+ * - `NoWrap`: No wrapping, all items compressed into single line/column
343
+ * - `Wrap`: Automatic wrapping, items flow to next line when container overflows
344
+ * - `WrapReverse`: Reverse wrapping, new lines appear above or to the left
345
+ * @enum {0 | 1 | 2}
346
+ */
347
+ export const FlexWrap = Object.freeze({
348
+ NoWrap: 0, "0": "NoWrap",
349
+ Wrap: 1, "1": "Wrap",
350
+ WrapReverse: 2, "2": "WrapReverse",
351
+ });
352
+
353
+ /**
354
+ * Main axis alignment enum (Justify Content)
355
+ *
356
+ * Defines alignment and spacing distribution of children along the main axis.
357
+ * Corresponds to CSS `justify-content` property.
358
+ *
359
+ * # Variants
360
+ * - `Start/FlexStart`: Align to main axis start
361
+ * - `End/FlexEnd`: Align to main axis end
362
+ * - `Center`: Center alignment
363
+ * - `SpaceBetween`: First and last items flush with edges, remaining space distributed evenly
364
+ * - `SpaceAround`: Equal space on both sides of each item
365
+ * - `SpaceEvenly`: All spacing completely equal
366
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
367
+ */
368
+ export const JustifyContent = Object.freeze({
369
+ Start: 0, "0": "Start",
370
+ End: 1, "1": "End",
371
+ FlexStart: 2, "2": "FlexStart",
372
+ FlexEnd: 3, "3": "FlexEnd",
373
+ Center: 4, "4": "Center",
374
+ Stretch: 5, "5": "Stretch",
375
+ SpaceBetween: 6, "6": "SpaceBetween",
376
+ SpaceAround: 7, "7": "SpaceAround",
377
+ SpaceEvenly: 8, "8": "SpaceEvenly",
378
+ });
379
+
380
+ /**
381
+ * Overflow handling enum
382
+ *
383
+ * Defines how content that overflows container boundaries is handled.
384
+ * Corresponds to CSS `overflow` property.
385
+ *
386
+ * # Variants
387
+ * - `Visible`: Content is not clipped
388
+ * - `Hidden`: Content is clipped, overflow hidden
389
+ * - `Scroll`: Always show scrollbars
390
+ * - `Auto`: Show scrollbars when needed (internally mapped to Scroll)
391
+ * @enum {0 | 1 | 2 | 3}
392
+ */
393
+ export const Overflow = Object.freeze({
394
+ Visible: 0, "0": "Visible",
395
+ Hidden: 1, "1": "Hidden",
396
+ Scroll: 2, "2": "Scroll",
397
+ Auto: 3, "3": "Auto",
398
+ });
399
+
400
+ /**
401
+ * Position mode enum
402
+ *
403
+ * Controls element positioning method. Corresponds to CSS `position` property.
404
+ *
405
+ * # Variants
406
+ * - `Relative`: Relative positioning, element stays in normal document flow
407
+ * - `Absolute`: Absolute positioning, element removed from flow, positioned relative to nearest positioned ancestor
408
+ * @enum {0 | 1}
409
+ */
410
+ export const Position = Object.freeze({
411
+ Relative: 0, "0": "Relative",
412
+ Absolute: 1, "1": "Absolute",
413
+ });
414
+
415
+ /**
416
+ * Node Style struct
417
+ *
418
+ * Configuration object containing all CSS layout properties.
419
+ * Access properties via getter/setter methods.
420
+ *
421
+ * # Supported Property Categories
422
+ *
423
+ * ## Layout Mode
424
+ * - `display`: Display mode (Flex/Grid/Block/None)
425
+ * - `position`: Position mode (Relative/Absolute)
426
+ *
427
+ * ## Flexbox Properties
428
+ * - `flex_direction`: Main axis direction
429
+ * - `flex_wrap`: Wrap behavior
430
+ * - `flex_grow`: Grow factor
431
+ * - `flex_shrink`: Shrink factor
432
+ * - `flex_basis`: Initial size
433
+ *
434
+ * ## Alignment Properties
435
+ * - `align_items`, `align_self`, `align_content`
436
+ * - `justify_content`
437
+ *
438
+ * ## Sizing Properties
439
+ * - `size`, `min_size`, `max_size`
440
+ * - `aspect_ratio`: Width-to-height ratio
441
+ *
442
+ * ## Spacing Properties
443
+ * - `margin`, `padding`, `border`
444
+ * - `gap`: Gap between children
445
+ * - `inset`: Absolute positioning offsets
446
+ */
447
+ export class Style {
448
+ static __wrap(ptr) {
449
+ ptr = ptr >>> 0;
450
+ const obj = Object.create(Style.prototype);
451
+ obj.__wbg_ptr = ptr;
452
+ StyleFinalization.register(obj, obj.__wbg_ptr, obj);
453
+ return obj;
454
+ }
455
+ __destroy_into_raw() {
456
+ const ptr = this.__wbg_ptr;
457
+ this.__wbg_ptr = 0;
458
+ StyleFinalization.unregister(this);
459
+ return ptr;
460
+ }
461
+ free() {
462
+ const ptr = this.__destroy_into_raw();
463
+ wasm.__wbg_style_free(ptr, 0);
464
+ }
465
+ /**
466
+ * Gets the align-self property. Overrides parent's align-items for this element.
467
+ * Returns AlignSelf.Auto if not explicitly set.
468
+ * @returns {AlignSelf | undefined}
469
+ */
470
+ get align_self() {
471
+ const ret = wasm.style_align_self(this.__wbg_ptr);
472
+ return ret === 8 ? undefined : ret;
473
+ }
474
+ /**
475
+ * Gets the flex-basis as a JsDimension (Length, Percent, or Auto).
476
+ * Flex-basis defines the initial main size before grow/shrink.
477
+ * @returns {any}
478
+ */
479
+ get flex_basis() {
480
+ const ret = wasm.style_flex_basis(this.__wbg_ptr);
481
+ return ret;
482
+ }
483
+ /**
484
+ * Sets the border width for all four edges.
485
+ * Accepts { left, right, top, bottom } with LengthPercentage values.
486
+ * @param {any} val
487
+ */
488
+ set border(val) {
489
+ wasm.style_set_border(this.__wbg_ptr, val);
490
+ }
491
+ /**
492
+ * Sets the margin for all four edges.
493
+ * Accepts { left, right, top, bottom } with LengthPercentageAuto values.
494
+ * @param {any} val
495
+ */
496
+ set margin(val) {
497
+ wasm.style_set_margin(this.__wbg_ptr, val);
498
+ }
499
+ /**
500
+ * Gets the align-items property. Controls cross-axis alignment of children.
501
+ * @returns {AlignItems | undefined}
502
+ */
503
+ get align_items() {
504
+ const ret = wasm.style_align_items(this.__wbg_ptr);
505
+ return ret === 7 ? undefined : ret;
506
+ }
507
+ /**
508
+ * Gets the flex shrink factor. Determines how much the item shrinks relative to siblings.
509
+ * @returns {number}
510
+ */
511
+ get flex_shrink() {
512
+ const ret = wasm.style_flex_shrink(this.__wbg_ptr);
513
+ return ret;
514
+ }
515
+ /**
516
+ * Sets the display mode. Controls which layout algorithm is used for children.
517
+ * - `Display.Block`: Block layout
518
+ * - `Display.Flex`: Flexbox layout
519
+ * - `Display.Grid`: CSS Grid layout
520
+ * - `Display.None`: Element is hidden and takes no space
521
+ * @param {Display} val
522
+ */
523
+ set display(val) {
524
+ wasm.style_set_display(this.__wbg_ptr, val);
525
+ }
526
+ /**
527
+ * Sets the padding for all four edges.
528
+ * Accepts { left, right, top, bottom } with LengthPercentage values.
529
+ * @param {any} val
530
+ */
531
+ set padding(val) {
532
+ wasm.style_set_padding(this.__wbg_ptr, val);
533
+ }
534
+ /**
535
+ * Gets the aspect ratio (width / height). Returns None if not set.
536
+ * @returns {number | undefined}
537
+ */
538
+ get aspect_ratio() {
539
+ const ret = wasm.style_aspect_ratio(this.__wbg_ptr);
540
+ return ret === 0x100000001 ? undefined : ret;
541
+ }
542
+ /**
543
+ * Sets the maximum size constraints.
544
+ * @param {any} val
545
+ */
546
+ set max_size(val) {
547
+ wasm.style_set_max_size(this.__wbg_ptr, val);
548
+ }
549
+ /**
550
+ * Sets the minimum size constraints.
551
+ * @param {any} val
552
+ */
553
+ set min_size(val) {
554
+ wasm.style_set_min_size(this.__wbg_ptr, val);
555
+ }
556
+ /**
557
+ * Sets the overflow behavior. Accepts {x: Overflow, y: Overflow}.
558
+ * @param {any} val
559
+ */
560
+ set overflow(val) {
561
+ wasm.style_set_overflow(this.__wbg_ptr, val);
562
+ }
563
+ /**
564
+ * Sets the position mode.
565
+ * - `Position.Relative`: Normal document flow
566
+ * - `Position.Absolute`: Removed from flow, positioned via inset properties
567
+ * @param {Position} val
568
+ */
569
+ set position(val) {
570
+ wasm.style_set_position(this.__wbg_ptr, val);
571
+ }
572
+ /**
573
+ * Gets the align-content property. Controls spacing between lines in multi-line flex.
574
+ * @returns {AlignContent | undefined}
575
+ */
576
+ get align_content() {
577
+ const ret = wasm.style_align_content(this.__wbg_ptr);
578
+ return ret === 9 ? undefined : ret;
579
+ }
580
+ /**
581
+ * Sets the flex grow factor. A value of 0 means the item won't grow.
582
+ * Higher values mean more growth relative to other items.
583
+ * @param {number} val
584
+ */
585
+ set flex_grow(val) {
586
+ wasm.style_set_flex_grow(this.__wbg_ptr, val);
587
+ }
588
+ /**
589
+ * Sets the flex wrap mode. Controls whether items wrap to new lines.
590
+ * @param {FlexWrap} val
591
+ */
592
+ set flex_wrap(val) {
593
+ wasm.style_set_flex_wrap(this.__wbg_ptr, val);
594
+ }
595
+ /**
596
+ * Gets the flex direction (Row, Column, RowReverse, ColumnReverse).
597
+ * @returns {FlexDirection}
598
+ */
599
+ get flex_direction() {
600
+ const ret = wasm.style_flex_direction(this.__wbg_ptr);
601
+ return ret;
602
+ }
603
+ /**
604
+ * Sets the align-self property. Use AlignSelf.Auto to inherit from parent.
605
+ * @param {AlignSelf | null} [val]
606
+ */
607
+ set align_self(val) {
608
+ wasm.style_set_align_self(this.__wbg_ptr, isLikeNone(val) ? 8 : val);
609
+ }
610
+ /**
611
+ * Sets the flex-basis. Accepts { Length: number } | { Percent: number } | "Auto".
612
+ * @param {any} val
613
+ */
614
+ set flex_basis(val) {
615
+ wasm.style_set_flex_basis(this.__wbg_ptr, val);
616
+ }
617
+ /**
618
+ * Gets the justify-content property. Controls main-axis alignment and spacing.
619
+ * @returns {JustifyContent | undefined}
620
+ */
621
+ get justify_content() {
622
+ const ret = wasm.style_justify_content(this.__wbg_ptr);
623
+ return ret === 9 ? undefined : ret;
624
+ }
625
+ /**
626
+ * Sets the align-items property. Affects all children's cross-axis alignment.
627
+ * @param {AlignItems | null} [val]
628
+ */
629
+ set align_items(val) {
630
+ wasm.style_set_align_items(this.__wbg_ptr, isLikeNone(val) ? 7 : val);
631
+ }
632
+ /**
633
+ * Sets the flex shrink factor. A value of 0 prevents shrinking.
634
+ * Default is 1.0 for flex items.
635
+ * @param {number} val
636
+ */
637
+ set flex_shrink(val) {
638
+ wasm.style_set_flex_shrink(this.__wbg_ptr, val);
639
+ }
640
+ /**
641
+ * Sets the aspect ratio. For example, 16/9 = 1.777... for widescreen.
642
+ * Set to None to remove the constraint.
643
+ * @param {number | null} [val]
644
+ */
645
+ set aspect_ratio(val) {
646
+ wasm.style_set_aspect_ratio(this.__wbg_ptr, isLikeNone(val) ? 0x100000001 : Math.fround(val));
647
+ }
648
+ /**
649
+ * Sets the align-content property. Only effective when flex-wrap is enabled.
650
+ * @param {AlignContent | null} [val]
651
+ */
652
+ set align_content(val) {
653
+ wasm.style_set_align_content(this.__wbg_ptr, isLikeNone(val) ? 9 : val);
654
+ }
655
+ /**
656
+ * Sets the flex direction. Defines the main axis for flex item layout.
657
+ * @param {FlexDirection} val
658
+ */
659
+ set flex_direction(val) {
660
+ wasm.style_set_flex_direction(this.__wbg_ptr, val);
661
+ }
662
+ /**
663
+ * Sets the justify-content property. Distributes space along the main axis.
664
+ * @param {JustifyContent | null} [val]
665
+ */
666
+ set justify_content(val) {
667
+ wasm.style_set_justify_content(this.__wbg_ptr, isLikeNone(val) ? 9 : val);
668
+ }
669
+ /**
670
+ * Gets the gap between children as a JsSize<JsLengthPercentage>.
671
+ * Used in Flex and Grid layouts to add spacing between items.
672
+ * - width: column gap (horizontal spacing)
673
+ * - height: row gap (vertical spacing)
674
+ * @returns {any}
675
+ */
676
+ get gap() {
677
+ const ret = wasm.style_gap(this.__wbg_ptr);
678
+ return ret;
679
+ }
680
+ /**
681
+ * Creates a new Style instance with default values.
682
+ *
683
+ * All properties are initialized to their CSS default values:
684
+ * - display: Block
685
+ * - position: Relative
686
+ * - flex_direction: Row
687
+ * - All dimensions: Auto
688
+ * - All spacing (margin, padding, border): 0
689
+ *
690
+ * # Returns
691
+ * A new Style instance with default configuration.
692
+ *
693
+ * # Example
694
+ * ```javascript
695
+ * const style = new Style();
696
+ * style.display = Display.Flex;
697
+ * ```
698
+ */
699
+ constructor() {
700
+ const ret = wasm.style_new();
701
+ this.__wbg_ptr = ret >>> 0;
702
+ StyleFinalization.register(this, this.__wbg_ptr, this);
703
+ return this;
704
+ }
705
+ /**
706
+ * Gets the size (width, height) as a JsSize<JsDimension>.
707
+ * Each dimension can be Length, Percent, or Auto.
708
+ * @returns {any}
709
+ */
710
+ get size() {
711
+ const ret = wasm.style_size(this.__wbg_ptr);
712
+ return ret;
713
+ }
714
+ /**
715
+ * Gets the inset (absolute positioning offsets) as a JsRect<JsLengthPercentageAuto>.
716
+ * Only effective when position is Absolute.
717
+ * Defines the distance from each edge of the containing block.
718
+ * @returns {any}
719
+ */
720
+ get inset() {
721
+ const ret = wasm.style_inset(this.__wbg_ptr);
722
+ return ret;
723
+ }
724
+ /**
725
+ * Gets the border width as a JsRect<JsLengthPercentage>.
726
+ * Border width defines the thickness of element borders.
727
+ * Supports Length or Percent for each edge (not Auto).
728
+ * @returns {any}
729
+ */
730
+ get border() {
731
+ const ret = wasm.style_border(this.__wbg_ptr);
732
+ return ret;
733
+ }
734
+ /**
735
+ * Gets the margin as a JsRect<JsLengthPercentageAuto>.
736
+ * Margin is the outer spacing around the element's border.
737
+ * Supports Length, Percent, or Auto for each edge.
738
+ * @returns {any}
739
+ */
740
+ get margin() {
741
+ const ret = wasm.style_margin(this.__wbg_ptr);
742
+ return ret;
743
+ }
744
+ /**
745
+ * Gets the display mode (Block, Flex, Grid, or None).
746
+ * @returns {Display}
747
+ */
748
+ get display() {
749
+ const ret = wasm.style_display(this.__wbg_ptr);
750
+ return ret;
751
+ }
752
+ /**
753
+ * Gets the padding as a JsRect<JsLengthPercentage>.
754
+ * Padding is the inner spacing between the border and content.
755
+ * Supports Length or Percent for each edge (not Auto).
756
+ * @returns {any}
757
+ */
758
+ get padding() {
759
+ const ret = wasm.style_padding(this.__wbg_ptr);
760
+ return ret;
761
+ }
762
+ /**
763
+ * Sets the gap between children.
764
+ * Accepts { width: column_gap, height: row_gap } with LengthPercentage values.
765
+ * @param {any} val
766
+ */
767
+ set gap(val) {
768
+ wasm.style_set_gap(this.__wbg_ptr, val);
769
+ }
770
+ /**
771
+ * Gets the maximum size constraints as a JsSize<JsDimension>.
772
+ * Prevents the element from growing beyond these values.
773
+ * @returns {any}
774
+ */
775
+ get max_size() {
776
+ const ret = wasm.style_max_size(this.__wbg_ptr);
777
+ return ret;
778
+ }
779
+ /**
780
+ * Gets the minimum size constraints as a JsSize<JsDimension>.
781
+ * Prevents the element from shrinking below these values.
782
+ * @returns {any}
783
+ */
784
+ get min_size() {
785
+ const ret = wasm.style_min_size(this.__wbg_ptr);
786
+ return ret;
787
+ }
788
+ /**
789
+ * Gets the overflow behavior as a JS object with {x, y} properties.
790
+ * @returns {any}
791
+ */
792
+ get overflow() {
793
+ const ret = wasm.style_overflow(this.__wbg_ptr);
794
+ return ret;
795
+ }
796
+ /**
797
+ * Gets the position mode (Relative or Absolute).
798
+ * @returns {Position}
799
+ */
800
+ get position() {
801
+ const ret = wasm.style_position(this.__wbg_ptr);
802
+ return ret;
803
+ }
804
+ /**
805
+ * Sets the size (width, height).
806
+ * Accepts { width: Dimension, height: Dimension } where Dimension is Length/Percent/Auto.
807
+ * Logs an error to console if parsing fails.
808
+ * @param {any} val
809
+ */
810
+ set size(val) {
811
+ wasm.style_set_size(this.__wbg_ptr, val);
812
+ }
813
+ /**
814
+ * Gets the flex grow factor. Determines how much the item grows relative to siblings.
815
+ * @returns {number}
816
+ */
817
+ get flex_grow() {
818
+ const ret = wasm.style_flex_grow(this.__wbg_ptr);
819
+ return ret;
820
+ }
821
+ /**
822
+ * Gets the flex wrap mode (NoWrap, Wrap, WrapReverse).
823
+ * @returns {FlexWrap}
824
+ */
825
+ get flex_wrap() {
826
+ const ret = wasm.style_flex_wrap(this.__wbg_ptr);
827
+ return ret;
828
+ }
829
+ /**
830
+ * Sets the inset for absolute positioning.
831
+ * Accepts { left, right, top, bottom } with LengthPercentageAuto values.
832
+ * @param {any} val
833
+ */
834
+ set inset(val) {
835
+ wasm.style_set_inset(this.__wbg_ptr, val);
836
+ }
837
+ }
838
+ if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
839
+
840
+ /**
841
+ * Layout tree manager providing node creation, tree manipulation, and layout computation.
842
+ *
843
+ * This is the main entry point for the Taffy layout engine. It wraps the native
844
+ * `taffy::TaffyTree<JsValue>` to provide a JavaScript-friendly API.
845
+ *
846
+ * # Features
847
+ * - **Node Management**: Create, remove, and reorganize layout nodes
848
+ * - **Style Control**: Get/set styles for any node
849
+ * - **Layout Computation**: Run Flexbox/Grid/Block layout algorithms
850
+ * - **Custom Measurement**: Support for text measurement via callback functions
851
+ * - **Node Context**: Attach arbitrary JS data to nodes for custom logic
852
+ *
853
+ * # Example
854
+ * ```javascript
855
+ * const tree = new TaffyTree();
856
+ * const style = new Style();
857
+ * style.display = Display.Flex;
858
+ * const root = tree.newLeaf(style);
859
+ * tree.computeLayout(root, { width: { Definite: 800 }, height: { Definite: 600 } });
860
+ * const layout = tree.getLayout(root);
861
+ * ```
862
+ */
863
+ export class TaffyTree {
864
+ static __wrap(ptr) {
865
+ ptr = ptr >>> 0;
866
+ const obj = Object.create(TaffyTree.prototype);
867
+ obj.__wbg_ptr = ptr;
868
+ TaffyTreeFinalization.register(obj, obj.__wbg_ptr, obj);
869
+ return obj;
870
+ }
871
+ __destroy_into_raw() {
872
+ const ptr = this.__wbg_ptr;
873
+ this.__wbg_ptr = 0;
874
+ TaffyTreeFinalization.unregister(this);
875
+ return ptr;
876
+ }
877
+ free() {
878
+ const ptr = this.__destroy_into_raw();
879
+ wasm.__wbg_taffytree_free(ptr, 0);
880
+ }
881
+ /**
882
+ * Marks a node as dirty, requiring re-layout.
883
+ *
884
+ * Call this when a node's content changes (e.g., text content)
885
+ * but its style hasn't. Style changes automatically mark nodes dirty.
886
+ *
887
+ * # Arguments
888
+ * * `node` - The node ID to mark dirty.
889
+ * @param {bigint} node
890
+ */
891
+ markDirty(node) {
892
+ const ret = wasm.taffytree_markDirty(this.__wbg_ptr, node);
893
+ if (ret[1]) {
894
+ throw takeFromExternrefTable0(ret[0]);
895
+ }
896
+ }
897
+ /**
898
+ * Prints the tree structure to the console (for debugging).
899
+ *
900
+ * # Arguments
901
+ * * `node` - The root node ID to start printing from.
902
+ * @param {bigint} node
903
+ */
904
+ printTree(node) {
905
+ wasm.taffytree_printTree(this.__wbg_ptr, node);
906
+ }
907
+ /**
908
+ * Gets the number of children of a node.
909
+ *
910
+ * # Arguments
911
+ * * `parent` - The parent node ID.
912
+ *
913
+ * # Returns
914
+ * The number of children.
915
+ * @param {bigint} parent
916
+ * @returns {number}
917
+ */
918
+ childCount(parent) {
919
+ const ret = wasm.taffytree_childCount(this.__wbg_ptr, parent);
920
+ return ret >>> 0;
921
+ }
922
+ /**
923
+ * Removes a specific child from a parent.
924
+ *
925
+ * # Arguments
926
+ * * `parent` - The parent node ID.
927
+ * * `child` - The child node ID to remove.
928
+ *
929
+ * # Returns
930
+ * * `Ok(u64)` - The ID of the removed child.
931
+ * * `Err(JsValue)` - Error if parent or child doesn't exist.
932
+ * @param {bigint} parent
933
+ * @param {bigint} child
934
+ * @returns {bigint}
935
+ */
936
+ removeChild(parent, child) {
937
+ const ret = wasm.taffytree_removeChild(this.__wbg_ptr, parent, child);
938
+ if (ret[2]) {
939
+ throw takeFromExternrefTable0(ret[1]);
940
+ }
941
+ return BigInt.asUintN(64, ret[0]);
942
+ }
943
+ /**
944
+ * Replaces all children of a node.
945
+ *
946
+ * Previous children are detached but not removed from the tree.
947
+ *
948
+ * # Arguments
949
+ * * `parent` - The parent node ID.
950
+ * * `children` - Array of new child node IDs.
951
+ * @param {bigint} parent
952
+ * @param {BigUint64Array} children
953
+ */
954
+ setChildren(parent, children) {
955
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
956
+ const len0 = WASM_VECTOR_LEN;
957
+ const ret = wasm.taffytree_setChildren(this.__wbg_ptr, parent, ptr0, len0);
958
+ if (ret[1]) {
959
+ throw takeFromExternrefTable0(ret[0]);
960
+ }
961
+ }
962
+ /**
963
+ * Creates a new TaffyTree with pre-allocated capacity.
964
+ *
965
+ * Use this when you know approximately how many nodes you'll create
966
+ * to avoid reallocation overhead.
967
+ *
968
+ * # Arguments
969
+ * * `capacity` - The number of nodes to pre-allocate space for.
970
+ *
971
+ * # Returns
972
+ * A new TaffyTree instance with pre-allocated capacity.
973
+ * @param {number} capacity
974
+ * @returns {TaffyTree}
975
+ */
976
+ static withCapacity(capacity) {
977
+ const ret = wasm.taffytree_withCapacity(capacity);
978
+ return TaffyTree.__wrap(ret);
979
+ }
980
+ /**
981
+ * Gets a child at a specific index.
982
+ *
983
+ * # Arguments
984
+ * * `parent` - The parent node ID.
985
+ * * `index` - The zero-based index.
986
+ *
987
+ * # Returns
988
+ * * `Ok(u64)` - The child node ID at the given index.
989
+ * * `Err(JsValue)` - Error if index is out of bounds.
990
+ * @param {bigint} parent
991
+ * @param {number} index
992
+ * @returns {bigint}
993
+ */
994
+ getChildAtIndex(parent, index) {
995
+ const ret = wasm.taffytree_getChildAtIndex(this.__wbg_ptr, parent, index);
996
+ if (ret[2]) {
997
+ throw takeFromExternrefTable0(ret[1]);
998
+ }
999
+ return BigInt.asUintN(64, ret[0]);
1000
+ }
1001
+ /**
1002
+ * Computes the layout for a subtree.
1003
+ *
1004
+ * Runs the layout algorithm (Flexbox/Grid/Block) on the given node
1005
+ * and all its descendants. Results are cached and can be retrieved
1006
+ * with `getLayout()`.
1007
+ *
1008
+ * # Arguments
1009
+ * * `node` - The root node ID for layout computation.
1010
+ * * `available_space` - The available space constraint, e.g.:
1011
+ * `{ width: { Definite: 800 }, height: { Definite: 600 } }`
1012
+ *
1013
+ * Available space options per dimension:
1014
+ * - `{ Definite: number }` - A specific size in pixels
1015
+ * - `"MinContent"` - Use minimum content size
1016
+ * - `"MaxContent"` - Use maximum content size
1017
+ * @param {bigint} node
1018
+ * @param {any} available_space
1019
+ */
1020
+ computeLayout(node, available_space) {
1021
+ const ret = wasm.taffytree_computeLayout(this.__wbg_ptr, node, available_space);
1022
+ if (ret[1]) {
1023
+ throw takeFromExternrefTable0(ret[0]);
1024
+ }
1025
+ }
1026
+ /**
1027
+ * Enables rounding of layout values to whole pixels.
1028
+ *
1029
+ * When enabled, all computed layout values (x, y, width, height) are
1030
+ * rounded to the nearest integer. This is the default behavior.
1031
+ */
1032
+ enableRounding() {
1033
+ wasm.taffytree_enableRounding(this.__wbg_ptr);
1034
+ }
1035
+ /**
1036
+ * Disables rounding of layout values.
1037
+ *
1038
+ * When disabled, layout values may have fractional pixel values.
1039
+ * Use `unroundedLayout()` to get the pre-rounding values.
1040
+ */
1041
+ disableRounding() {
1042
+ wasm.taffytree_disableRounding(this.__wbg_ptr);
1043
+ }
1044
+ /**
1045
+ * Gets the context value for a node.
1046
+ *
1047
+ * # Arguments
1048
+ * * `node` - The node ID.
1049
+ *
1050
+ * # Returns
1051
+ * The context value, or `undefined` if not set.
1052
+ * @param {bigint} node
1053
+ * @returns {any}
1054
+ */
1055
+ getNodeContext(node) {
1056
+ const ret = wasm.taffytree_getNodeContext(this.__wbg_ptr, node);
1057
+ if (ret[2]) {
1058
+ throw takeFromExternrefTable0(ret[1]);
1059
+ }
1060
+ return takeFromExternrefTable0(ret[0]);
1061
+ }
1062
+ /**
1063
+ * Sets a context value for a node.
1064
+ *
1065
+ * Context values are passed to the measure function during layout.
1066
+ * Use this to attach data like text content or custom metadata.
1067
+ *
1068
+ * # Arguments
1069
+ * * `node` - The node ID.
1070
+ * * `context` - Any JavaScript value.
1071
+ * @param {bigint} node
1072
+ * @param {any} context
1073
+ */
1074
+ setNodeContext(node, context) {
1075
+ const ret = wasm.taffytree_setNodeContext(this.__wbg_ptr, node, context);
1076
+ if (ret[1]) {
1077
+ throw takeFromExternrefTable0(ret[0]);
1078
+ }
1079
+ }
1080
+ /**
1081
+ * Gets the total number of nodes in the tree.
1082
+ *
1083
+ * # Returns
1084
+ * The count of all nodes (including removed nodes that haven't been reclaimed).
1085
+ * @returns {number}
1086
+ */
1087
+ totalNodeCount() {
1088
+ const ret = wasm.taffytree_totalNodeCount(this.__wbg_ptr);
1089
+ return ret >>> 0;
1090
+ }
1091
+ /**
1092
+ * Gets the unrounded (fractional) layout for a node.
1093
+ *
1094
+ * Useful when you need sub-pixel precision.
1095
+ *
1096
+ * # Arguments
1097
+ * * `node` - The node ID to query.
1098
+ *
1099
+ * # Returns
1100
+ * A layout object with potentially fractional values.
1101
+ * @param {bigint} node
1102
+ * @returns {any}
1103
+ */
1104
+ unroundedLayout(node) {
1105
+ const ret = wasm.taffytree_unroundedLayout(this.__wbg_ptr, node);
1106
+ if (ret[2]) {
1107
+ throw takeFromExternrefTable0(ret[1]);
1108
+ }
1109
+ return takeFromExternrefTable0(ret[0]);
1110
+ }
1111
+ /**
1112
+ * Creates a new node with the given children.
1113
+ *
1114
+ * # Arguments
1115
+ * * `style` - The Style object to apply to this node.
1116
+ * * `children` - Array of child node IDs.
1117
+ *
1118
+ * # Returns
1119
+ * * `Ok(u64)` - The node ID of the newly created node.
1120
+ * * `Err(JsValue)` - Error message if creation fails.
1121
+ * @param {Style} style
1122
+ * @param {BigUint64Array} children
1123
+ * @returns {bigint}
1124
+ */
1125
+ newWithChildren(style, children) {
1126
+ _assertClass(style, Style);
1127
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1128
+ const len0 = WASM_VECTOR_LEN;
1129
+ const ret = wasm.taffytree_newWithChildren(this.__wbg_ptr, style.__wbg_ptr, ptr0, len0);
1130
+ if (ret[2]) {
1131
+ throw takeFromExternrefTable0(ret[1]);
1132
+ }
1133
+ return BigInt.asUintN(64, ret[0]);
1134
+ }
1135
+ /**
1136
+ * Gets a mutable reference to the context value for a node.
1137
+ *
1138
+ * Note: In WASM, this returns a clone since we can't return mutable references.
1139
+ *
1140
+ * # Arguments
1141
+ * * `node` - The node ID.
1142
+ *
1143
+ * # Returns
1144
+ * The context value, or `undefined` if not set.
1145
+ * @param {bigint} node
1146
+ * @returns {any}
1147
+ */
1148
+ getNodeContextMut(node) {
1149
+ const ret = wasm.taffytree_getNodeContextMut(this.__wbg_ptr, node);
1150
+ if (ret[2]) {
1151
+ throw takeFromExternrefTable0(ret[1]);
1152
+ }
1153
+ return takeFromExternrefTable0(ret[0]);
1154
+ }
1155
+ /**
1156
+ * Inserts a child at a specific index.
1157
+ *
1158
+ * Existing children at and after the index are shifted right.
1159
+ *
1160
+ * # Arguments
1161
+ * * `parent` - The parent node ID.
1162
+ * * `index` - The zero-based index at which to insert.
1163
+ * * `child` - The child node ID to insert.
1164
+ * @param {bigint} parent
1165
+ * @param {number} index
1166
+ * @param {bigint} child
1167
+ */
1168
+ insertChildAtIndex(parent, index, child) {
1169
+ const ret = wasm.taffytree_insertChildAtIndex(this.__wbg_ptr, parent, index, child);
1170
+ if (ret[1]) {
1171
+ throw takeFromExternrefTable0(ret[0]);
1172
+ }
1173
+ }
1174
+ /**
1175
+ * Creates a new leaf node with an attached context value.
1176
+ *
1177
+ * The context can be any JavaScript value and is useful for associating
1178
+ * custom data (like text content) with a node for use in measure functions.
1179
+ *
1180
+ * # Arguments
1181
+ * * `style` - The Style object to apply to this node.
1182
+ * * `context` - Any JavaScript value to attach to this node.
1183
+ *
1184
+ * # Returns
1185
+ * * `Ok(u64)` - The node ID of the newly created node.
1186
+ * * `Err(JsValue)` - Error message if creation fails.
1187
+ * @param {Style} style
1188
+ * @param {any} context
1189
+ * @returns {bigint}
1190
+ */
1191
+ newLeafWithContext(style, context) {
1192
+ _assertClass(style, Style);
1193
+ const ret = wasm.taffytree_newLeafWithContext(this.__wbg_ptr, style.__wbg_ptr, context);
1194
+ if (ret[2]) {
1195
+ throw takeFromExternrefTable0(ret[1]);
1196
+ }
1197
+ return BigInt.asUintN(64, ret[0]);
1198
+ }
1199
+ /**
1200
+ * Removes a child at a specific index.
1201
+ *
1202
+ * # Arguments
1203
+ * * `parent` - The parent node ID.
1204
+ * * `index` - The zero-based index of the child to remove.
1205
+ *
1206
+ * # Returns
1207
+ * * `Ok(u64)` - The ID of the removed child.
1208
+ * * `Err(JsValue)` - Error if index is out of bounds.
1209
+ * @param {bigint} parent
1210
+ * @param {number} index
1211
+ * @returns {bigint}
1212
+ */
1213
+ removeChildAtIndex(parent, index) {
1214
+ const ret = wasm.taffytree_removeChildAtIndex(this.__wbg_ptr, parent, index);
1215
+ if (ret[2]) {
1216
+ throw takeFromExternrefTable0(ret[1]);
1217
+ }
1218
+ return BigInt.asUintN(64, ret[0]);
1219
+ }
1220
+ /**
1221
+ * Removes a range of children from a parent.
1222
+ *
1223
+ * # Arguments
1224
+ * * `parent` - The parent node ID.
1225
+ * * `start` - The start index (inclusive).
1226
+ * * `end` - The end index (exclusive).
1227
+ * @param {bigint} parent
1228
+ * @param {number} start
1229
+ * @param {number} end
1230
+ */
1231
+ removeChildrenRange(parent, start, end) {
1232
+ const ret = wasm.taffytree_removeChildrenRange(this.__wbg_ptr, parent, start, end);
1233
+ if (ret[1]) {
1234
+ throw takeFromExternrefTable0(ret[0]);
1235
+ }
1236
+ }
1237
+ /**
1238
+ * Replaces a child at a specific index with a new child.
1239
+ *
1240
+ * # Arguments
1241
+ * * `parent` - The parent node ID.
1242
+ * * `index` - The zero-based index of the child to replace.
1243
+ * * `child` - The new child node ID.
1244
+ *
1245
+ * # Returns
1246
+ * * `Ok(u64)` - The ID of the replaced (old) child.
1247
+ * * `Err(JsValue)` - Error if index is out of bounds.
1248
+ * @param {bigint} parent
1249
+ * @param {number} index
1250
+ * @param {bigint} child
1251
+ * @returns {bigint}
1252
+ */
1253
+ replaceChildAtIndex(parent, index, child) {
1254
+ const ret = wasm.taffytree_replaceChildAtIndex(this.__wbg_ptr, parent, index, child);
1255
+ if (ret[2]) {
1256
+ throw takeFromExternrefTable0(ret[1]);
1257
+ }
1258
+ return BigInt.asUintN(64, ret[0]);
1259
+ }
1260
+ /**
1261
+ * Computes layout with a custom measure function for leaf nodes.
1262
+ *
1263
+ * The measure function is called for leaf nodes to determine their
1264
+ * intrinsic size (e.g., for text measurement).
1265
+ *
1266
+ * # Arguments
1267
+ * * `node` - The root node ID for layout computation.
1268
+ * * `available_space` - The available space constraint.
1269
+ * * `measure_func` - A JavaScript function with signature:
1270
+ * `(knownDimensions, availableSpace, context) => { width, height }`
1271
+ *
1272
+ * The measure function receives:
1273
+ * - `knownDimensions`: `{ width: number | null, height: number | null }`
1274
+ * - `availableSpace`: `{ width: AvailableSpace, height: AvailableSpace }`
1275
+ * - `context`: The context value attached to the node (or undefined)
1276
+ *
1277
+ * And should return: `{ width: number, height: number }`
1278
+ * @param {bigint} node
1279
+ * @param {any} available_space
1280
+ * @param {Function} measure_func
1281
+ */
1282
+ computeLayoutWithMeasure(node, available_space, measure_func) {
1283
+ const ret = wasm.taffytree_computeLayoutWithMeasure(this.__wbg_ptr, node, available_space, measure_func);
1284
+ if (ret[1]) {
1285
+ throw takeFromExternrefTable0(ret[0]);
1286
+ }
1287
+ }
1288
+ /**
1289
+ * Gets context values for multiple nodes at once.
1290
+ *
1291
+ * Useful for batch operations.
1292
+ *
1293
+ * # Arguments
1294
+ * * `children` - Array of node IDs to query.
1295
+ *
1296
+ * # Returns
1297
+ * Array of context values in the same order as input.
1298
+ * @param {BigUint64Array} children
1299
+ * @returns {any[]}
1300
+ */
1301
+ getDisjointNodeContextMut(children) {
1302
+ const ptr0 = passArray64ToWasm0(children, wasm.__wbindgen_malloc);
1303
+ const len0 = WASM_VECTOR_LEN;
1304
+ const ret = wasm.taffytree_getDisjointNodeContextMut(this.__wbg_ptr, ptr0, len0);
1305
+ if (ret[3]) {
1306
+ throw takeFromExternrefTable0(ret[2]);
1307
+ }
1308
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1309
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1310
+ return v2;
1311
+ }
1312
+ /**
1313
+ * Creates a new empty TaffyTree.
1314
+ *
1315
+ * This is the primary constructor. Initializes panic hook in debug builds
1316
+ * to provide better error messages in the browser console.
1317
+ *
1318
+ * # Returns
1319
+ * A new TaffyTree instance with no nodes.
1320
+ */
1321
+ constructor() {
1322
+ const ret = wasm.taffytree_new();
1323
+ this.__wbg_ptr = ret >>> 0;
1324
+ TaffyTreeFinalization.register(this, this.__wbg_ptr, this);
1325
+ return this;
1326
+ }
1327
+ /**
1328
+ * Removes all nodes from the tree.
1329
+ *
1330
+ * After calling this, the tree is empty and all previous node IDs are invalid.
1331
+ */
1332
+ clear() {
1333
+ wasm.taffytree_clear(this.__wbg_ptr);
1334
+ }
1335
+ /**
1336
+ * Checks if a node is dirty (needs re-layout).
1337
+ *
1338
+ * # Arguments
1339
+ * * `node` - The node ID to check.
1340
+ *
1341
+ * # Returns
1342
+ * * `Ok(true)` - The node needs re-layout.
1343
+ * * `Ok(false)` - The node's layout is up-to-date.
1344
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1345
+ * @param {bigint} node
1346
+ * @returns {boolean}
1347
+ */
1348
+ dirty(node) {
1349
+ const ret = wasm.taffytree_dirty(this.__wbg_ptr, node);
1350
+ if (ret[2]) {
1351
+ throw takeFromExternrefTable0(ret[1]);
1352
+ }
1353
+ return ret[0] !== 0;
1354
+ }
1355
+ /**
1356
+ * Gets the style for a node.
1357
+ *
1358
+ * # Arguments
1359
+ * * `node` - The node ID to query.
1360
+ *
1361
+ * # Returns
1362
+ * * `Ok(Style)` - A copy of the node's style.
1363
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1364
+ * @param {bigint} node
1365
+ * @returns {Style}
1366
+ */
1367
+ getStyle(node) {
1368
+ const ret = wasm.taffytree_getStyle(this.__wbg_ptr, node);
1369
+ if (ret[2]) {
1370
+ throw takeFromExternrefTable0(ret[1]);
1371
+ }
1372
+ return Style.__wrap(ret[0]);
1373
+ }
1374
+ /**
1375
+ * Gets the computed layout for a node.
1376
+ *
1377
+ * Must be called after `computeLayout()`.
1378
+ *
1379
+ * # Arguments
1380
+ * * `node` - The node ID to query.
1381
+ *
1382
+ * # Returns
1383
+ * A layout object: `{ order, size: {width, height}, location: {x, y}, ... }`
1384
+ * @param {bigint} node
1385
+ * @returns {any}
1386
+ */
1387
+ getLayout(node) {
1388
+ const ret = wasm.taffytree_getLayout(this.__wbg_ptr, node);
1389
+ if (ret[2]) {
1390
+ throw takeFromExternrefTable0(ret[1]);
1391
+ }
1392
+ return takeFromExternrefTable0(ret[0]);
1393
+ }
1394
+ /**
1395
+ * Gets the parent of a node.
1396
+ *
1397
+ * # Arguments
1398
+ * * `child` - The child node ID.
1399
+ *
1400
+ * # Returns
1401
+ * * `Some(u64)` - The parent node ID.
1402
+ * * `None` - If the node has no parent (is a root).
1403
+ * @param {bigint} child
1404
+ * @returns {bigint | undefined}
1405
+ */
1406
+ parent(child) {
1407
+ const ret = wasm.taffytree_parent(this.__wbg_ptr, child);
1408
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
1409
+ }
1410
+ /**
1411
+ * Removes a node from the tree.
1412
+ *
1413
+ * The node is detached from its parent (if any) and removed from the tree.
1414
+ * Child nodes are NOT automatically removed.
1415
+ *
1416
+ * # Arguments
1417
+ * * `node` - The node ID to remove.
1418
+ *
1419
+ * # Returns
1420
+ * * `Ok(u64)` - The ID of the removed node.
1421
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1422
+ * @param {bigint} node
1423
+ * @returns {bigint}
1424
+ */
1425
+ remove(node) {
1426
+ const ret = wasm.taffytree_remove(this.__wbg_ptr, node);
1427
+ if (ret[2]) {
1428
+ throw takeFromExternrefTable0(ret[1]);
1429
+ }
1430
+ return BigInt.asUintN(64, ret[0]);
1431
+ }
1432
+ /**
1433
+ * Gets all children of a node.
1434
+ *
1435
+ * # Arguments
1436
+ * * `parent` - The parent node ID.
1437
+ *
1438
+ * # Returns
1439
+ * * `Ok(Box<[u64]>)` - Array of child node IDs.
1440
+ * * `Err(JsValue)` - Error if the node doesn't exist.
1441
+ * @param {bigint} parent
1442
+ * @returns {BigUint64Array}
1443
+ */
1444
+ children(parent) {
1445
+ const ret = wasm.taffytree_children(this.__wbg_ptr, parent);
1446
+ if (ret[3]) {
1447
+ throw takeFromExternrefTable0(ret[2]);
1448
+ }
1449
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
1450
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1451
+ return v1;
1452
+ }
1453
+ /**
1454
+ * Creates a new leaf node (no children) with the given style.
1455
+ *
1456
+ * # Arguments
1457
+ * * `style` - The Style object to apply to this node.
1458
+ *
1459
+ * # Returns
1460
+ * * `Ok(u64)` - The node ID of the newly created node.
1461
+ * * `Err(JsValue)` - Error message if creation fails.
1462
+ * @param {Style} style
1463
+ * @returns {bigint}
1464
+ */
1465
+ newLeaf(style) {
1466
+ _assertClass(style, Style);
1467
+ const ret = wasm.taffytree_newLeaf(this.__wbg_ptr, style.__wbg_ptr);
1468
+ if (ret[2]) {
1469
+ throw takeFromExternrefTable0(ret[1]);
1470
+ }
1471
+ return BigInt.asUintN(64, ret[0]);
1472
+ }
1473
+ /**
1474
+ * Appends a child node to a parent.
1475
+ *
1476
+ * The child is added at the end of the parent's children list.
1477
+ *
1478
+ * # Arguments
1479
+ * * `parent` - The parent node ID.
1480
+ * * `child` - The child node ID to add.
1481
+ * @param {bigint} parent
1482
+ * @param {bigint} child
1483
+ */
1484
+ addChild(parent, child) {
1485
+ const ret = wasm.taffytree_addChild(this.__wbg_ptr, parent, child);
1486
+ if (ret[1]) {
1487
+ throw takeFromExternrefTable0(ret[0]);
1488
+ }
1489
+ }
1490
+ /**
1491
+ * Sets the style for an existing node.
1492
+ *
1493
+ * This will mark the node and its ancestors as dirty, triggering
1494
+ * a re-layout on the next `computeLayout()` call.
1495
+ *
1496
+ * # Arguments
1497
+ * * `node` - The node ID to update.
1498
+ * * `style` - The new Style to apply.
1499
+ * @param {bigint} node
1500
+ * @param {Style} style
1501
+ */
1502
+ setStyle(node, style) {
1503
+ _assertClass(style, Style);
1504
+ const ret = wasm.taffytree_setStyle(this.__wbg_ptr, node, style.__wbg_ptr);
1505
+ if (ret[1]) {
1506
+ throw takeFromExternrefTable0(ret[0]);
1507
+ }
1508
+ }
1509
+ }
1510
+ if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
1511
+
1512
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
1513
+
1514
+ async function __wbg_load(module, imports) {
1515
+ if (typeof Response === 'function' && module instanceof Response) {
1516
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1517
+ try {
1518
+ return await WebAssembly.instantiateStreaming(module, imports);
1519
+ } catch (e) {
1520
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
1521
+
1522
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1523
+ 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);
1524
+
1525
+ } else {
1526
+ throw e;
1527
+ }
1528
+ }
1529
+ }
1530
+
1531
+ const bytes = await module.arrayBuffer();
1532
+ return await WebAssembly.instantiate(bytes, imports);
1533
+ } else {
1534
+ const instance = await WebAssembly.instantiate(module, imports);
1535
+
1536
+ if (instance instanceof WebAssembly.Instance) {
1537
+ return { instance, module };
1538
+ } else {
1539
+ return instance;
1540
+ }
1541
+ }
1542
+ }
1543
+
1544
+ function __wbg_get_imports() {
1545
+ const imports = {};
1546
+ imports.wbg = {};
1547
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
1548
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1549
+ return ret;
1550
+ };
1551
+ imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
1552
+ const ret = Number(arg0);
1553
+ return ret;
1554
+ };
1555
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
1556
+ const ret = String(arg1);
1557
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1558
+ const len1 = WASM_VECTOR_LEN;
1559
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1560
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1561
+ };
1562
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
1563
+ const v = arg0;
1564
+ const ret = typeof(v) === 'boolean' ? v : undefined;
1565
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1566
+ };
1567
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
1568
+ const ret = debugString(arg1);
1569
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1570
+ const len1 = WASM_VECTOR_LEN;
1571
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1572
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1573
+ };
1574
+ imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
1575
+ const ret = arg0 in arg1;
1576
+ return ret;
1577
+ };
1578
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
1579
+ const val = arg0;
1580
+ const ret = typeof(val) === 'object' && val !== null;
1581
+ return ret;
1582
+ };
1583
+ imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
1584
+ const ret = typeof(arg0) === 'string';
1585
+ return ret;
1586
+ };
1587
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
1588
+ const ret = arg0 === undefined;
1589
+ return ret;
1590
+ };
1591
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
1592
+ const ret = arg0 == arg1;
1593
+ return ret;
1594
+ };
1595
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
1596
+ const obj = arg1;
1597
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1598
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1599
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1600
+ };
1601
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
1602
+ const obj = arg1;
1603
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1604
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1605
+ var len1 = WASM_VECTOR_LEN;
1606
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1607
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1608
+ };
1609
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
1610
+ throw new Error(getStringFromWasm0(arg0, arg1));
1611
+ };
1612
+ imports.wbg.__wbg_apply_52e9ae668d017009 = function() { return handleError(function (arg0, arg1, arg2) {
1613
+ const ret = arg0.apply(arg1, arg2);
1614
+ return ret;
1615
+ }, arguments) };
1616
+ imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
1617
+ const ret = Object.entries(arg0);
1618
+ return ret;
1619
+ };
1620
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
1621
+ let deferred0_0;
1622
+ let deferred0_1;
1623
+ try {
1624
+ deferred0_0 = arg0;
1625
+ deferred0_1 = arg1;
1626
+ console.error(getStringFromWasm0(arg0, arg1));
1627
+ } finally {
1628
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1629
+ }
1630
+ };
1631
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
1632
+ const ret = arg0[arg1 >>> 0];
1633
+ return ret;
1634
+ };
1635
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
1636
+ const ret = arg0[arg1];
1637
+ return ret;
1638
+ };
1639
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
1640
+ let result;
1641
+ try {
1642
+ result = arg0 instanceof ArrayBuffer;
1643
+ } catch (_) {
1644
+ result = false;
1645
+ }
1646
+ const ret = result;
1647
+ return ret;
1648
+ };
1649
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
1650
+ let result;
1651
+ try {
1652
+ result = arg0 instanceof Uint8Array;
1653
+ } catch (_) {
1654
+ result = false;
1655
+ }
1656
+ const ret = result;
1657
+ return ret;
1658
+ };
1659
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
1660
+ const ret = arg0.length;
1661
+ return ret;
1662
+ };
1663
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
1664
+ const ret = arg0.length;
1665
+ return ret;
1666
+ };
1667
+ imports.wbg.__wbg_log_730ba2e365bddb50 = function(arg0, arg1) {
1668
+ console.log(getStringFromWasm0(arg0, arg1));
1669
+ };
1670
+ imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
1671
+ const ret = new Object();
1672
+ return ret;
1673
+ };
1674
+ imports.wbg.__wbg_new_25f239778d6112b9 = function() {
1675
+ const ret = new Array();
1676
+ return ret;
1677
+ };
1678
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
1679
+ const ret = new Uint8Array(arg0);
1680
+ return ret;
1681
+ };
1682
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
1683
+ const ret = new Error();
1684
+ return ret;
1685
+ };
1686
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
1687
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1688
+ };
1689
+ imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
1690
+ const ret = arg0.push(arg1);
1691
+ return ret;
1692
+ };
1693
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
1694
+ arg0[arg1] = arg2;
1695
+ };
1696
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
1697
+ const ret = arg1.stack;
1698
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1699
+ const len1 = WASM_VECTOR_LEN;
1700
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1701
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1702
+ };
1703
+ imports.wbg.__wbg_stringify_655a6390e1f5eb6b = function() { return handleError(function (arg0) {
1704
+ const ret = JSON.stringify(arg0);
1705
+ return ret;
1706
+ }, arguments) };
1707
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1708
+ // Cast intrinsic for `Ref(String) -> Externref`.
1709
+ const ret = getStringFromWasm0(arg0, arg1);
1710
+ return ret;
1711
+ };
1712
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1713
+ // Cast intrinsic for `F64 -> Externref`.
1714
+ const ret = arg0;
1715
+ return ret;
1716
+ };
1717
+ imports.wbg.__wbindgen_init_externref_table = function() {
1718
+ const table = wasm.__wbindgen_externrefs;
1719
+ const offset = table.grow(4);
1720
+ table.set(0, undefined);
1721
+ table.set(offset + 0, undefined);
1722
+ table.set(offset + 1, null);
1723
+ table.set(offset + 2, true);
1724
+ table.set(offset + 3, false);
1725
+ };
1726
+
1727
+ return imports;
1728
+ }
1729
+
1730
+ function __wbg_finalize_init(instance, module) {
1731
+ wasm = instance.exports;
1732
+ __wbg_init.__wbindgen_wasm_module = module;
1733
+ cachedBigUint64ArrayMemory0 = null;
1734
+ cachedDataViewMemory0 = null;
1735
+ cachedUint8ArrayMemory0 = null;
1736
+
1737
+
1738
+ wasm.__wbindgen_start();
1739
+ return wasm;
1740
+ }
1741
+
1742
+ function initSync(module) {
1743
+ if (wasm !== undefined) return wasm;
1744
+
1745
+
1746
+ if (typeof module !== 'undefined') {
1747
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1748
+ ({module} = module)
1749
+ } else {
1750
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1751
+ }
1752
+ }
1753
+
1754
+ const imports = __wbg_get_imports();
1755
+ if (!(module instanceof WebAssembly.Module)) {
1756
+ module = new WebAssembly.Module(module);
1757
+ }
1758
+ const instance = new WebAssembly.Instance(module, imports);
1759
+ return __wbg_finalize_init(instance, module);
1760
+ }
1761
+
1762
+ async function __wbg_init(module_or_path) {
1763
+ if (wasm !== undefined) return wasm;
1764
+
1765
+
1766
+ if (typeof module_or_path !== 'undefined') {
1767
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1768
+ ({module_or_path} = module_or_path)
1769
+ } else {
1770
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1771
+ }
1772
+ }
1773
+
1774
+ if (typeof module_or_path === 'undefined') {
1775
+ module_or_path = new URL('taffy_js_bg.wasm', import.meta.url);
1776
+ }
1777
+ const imports = __wbg_get_imports();
1778
+
1779
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1780
+ module_or_path = fetch(module_or_path);
1781
+ }
1782
+
1783
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1784
+
1785
+ return __wbg_finalize_init(instance, module);
1786
+ }
1787
+
1788
+ export { initSync };
1789
+ export default __wbg_init;