taffy-js 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +356 -397
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -15
- package/taffy_js.d.ts +0 -958
- package/taffy_js.js +0 -2031
- package/taffy_js_bg.wasm +0 -0
package/taffy_js.js
DELETED
|
@@ -1,2031 +0,0 @@
|
|
|
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 LayoutFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
223
|
-
? { register: () => {}, unregister: () => {} }
|
|
224
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_layout_free(ptr >>> 0, 1));
|
|
225
|
-
|
|
226
|
-
const StyleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
227
|
-
? { register: () => {}, unregister: () => {} }
|
|
228
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_style_free(ptr >>> 0, 1));
|
|
229
|
-
|
|
230
|
-
const TaffyTreeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
231
|
-
? { register: () => {}, unregister: () => {} }
|
|
232
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_taffytree_free(ptr >>> 0, 1));
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Multi-line content alignment enum (Align Content)
|
|
236
|
-
*
|
|
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`.
|
|
239
|
-
*
|
|
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
|
|
244
|
-
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
|
|
245
|
-
*/
|
|
246
|
-
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",
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Cross-axis alignment enum for children (Align Items)
|
|
260
|
-
*
|
|
261
|
-
* Defines how all children are aligned on the cross axis in a Flex/Grid container.
|
|
262
|
-
*
|
|
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
|
|
269
|
-
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
|
|
270
|
-
*/
|
|
271
|
-
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",
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Cross-axis alignment enum for single element (Align Self)
|
|
283
|
-
*
|
|
284
|
-
* Overrides parent's `align-items` for a single child element's cross-axis alignment.
|
|
285
|
-
*
|
|
286
|
-
* # Variants
|
|
287
|
-
* - `Auto`: Inherit parent's `align-items` value
|
|
288
|
-
* - Other values have same meaning as `AlignItems`
|
|
289
|
-
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7}
|
|
290
|
-
*/
|
|
291
|
-
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",
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Box sizing enum
|
|
304
|
-
*
|
|
305
|
-
* Controls how the total width and height of an element is calculated.
|
|
306
|
-
*
|
|
307
|
-
* # Variants
|
|
308
|
-
* - `BorderBox`: Width and height include content, padding, and border (default)
|
|
309
|
-
* - `ContentBox`: Width and height include only the content
|
|
310
|
-
* @enum {0 | 1}
|
|
311
|
-
*/
|
|
312
|
-
export const BoxSizing = Object.freeze({
|
|
313
|
-
BorderBox: 0, "0": "BorderBox",
|
|
314
|
-
ContentBox: 1, "1": "ContentBox",
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Display mode enum
|
|
319
|
-
*
|
|
320
|
-
* Controls the layout algorithm type for an element. Corresponds to CSS `display` property.
|
|
321
|
-
*
|
|
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
|
|
327
|
-
* @enum {0 | 1 | 2 | 3}
|
|
328
|
-
*/
|
|
329
|
-
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",
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Flex main axis direction enum
|
|
338
|
-
*
|
|
339
|
-
* Defines the direction children are laid out in a flex container. Corresponds to CSS `flex-direction` property.
|
|
340
|
-
*
|
|
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
|
|
346
|
-
* @enum {0 | 1 | 2 | 3}
|
|
347
|
-
*/
|
|
348
|
-
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",
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Flex wrap mode enum
|
|
357
|
-
*
|
|
358
|
-
* Controls whether flex items wrap onto multiple lines. Corresponds to CSS `flex-wrap` property.
|
|
359
|
-
*
|
|
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
|
|
364
|
-
* @enum {0 | 1 | 2}
|
|
365
|
-
*/
|
|
366
|
-
export const FlexWrap = Object.freeze({
|
|
367
|
-
NoWrap: 0, "0": "NoWrap",
|
|
368
|
-
Wrap: 1, "1": "Wrap",
|
|
369
|
-
WrapReverse: 2, "2": "WrapReverse",
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Main axis alignment enum (Justify Content)
|
|
374
|
-
*
|
|
375
|
-
* Defines alignment and spacing distribution of children along the main axis.
|
|
376
|
-
* Corresponds to CSS `justify-content` property.
|
|
377
|
-
*
|
|
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
|
|
385
|
-
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
|
|
386
|
-
*/
|
|
387
|
-
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",
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Layout result struct
|
|
401
|
-
*
|
|
402
|
-
* A wrapper around `taffy::Layout` that provides WASM bindings.
|
|
403
|
-
* Contains the computed layout values for a node after calling `computeLayout()`.
|
|
404
|
-
* All values are in pixels.
|
|
405
|
-
*
|
|
406
|
-
* # Properties
|
|
407
|
-
* - `order`: Rendering order (higher = on top)
|
|
408
|
-
* - `x`, `y`: Position of top-left corner relative to parent
|
|
409
|
-
* - `width`, `height`: Computed dimensions
|
|
410
|
-
* - `contentWidth`, `contentHeight`: Size of scrollable content
|
|
411
|
-
* - `scrollbarWidth`, `scrollbarHeight`: Size allocated for scrollbars
|
|
412
|
-
* - `borderLeft`, `borderRight`, `borderTop`, `borderBottom`: Border widths
|
|
413
|
-
* - `paddingLeft`, `paddingRight`, `paddingTop`, `paddingBottom`: Padding sizes
|
|
414
|
-
* - `marginLeft`, `marginRight`, `marginTop`, `marginBottom`: Margin sizes
|
|
415
|
-
*/
|
|
416
|
-
export class Layout {
|
|
417
|
-
static __wrap(ptr) {
|
|
418
|
-
ptr = ptr >>> 0;
|
|
419
|
-
const obj = Object.create(Layout.prototype);
|
|
420
|
-
obj.__wbg_ptr = ptr;
|
|
421
|
-
LayoutFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
422
|
-
return obj;
|
|
423
|
-
}
|
|
424
|
-
__destroy_into_raw() {
|
|
425
|
-
const ptr = this.__wbg_ptr;
|
|
426
|
-
this.__wbg_ptr = 0;
|
|
427
|
-
LayoutFinalization.unregister(this);
|
|
428
|
-
return ptr;
|
|
429
|
-
}
|
|
430
|
-
free() {
|
|
431
|
-
const ptr = this.__destroy_into_raw();
|
|
432
|
-
wasm.__wbg_layout_free(ptr, 0);
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Gets the top border width.
|
|
436
|
-
* @returns {number}
|
|
437
|
-
*/
|
|
438
|
-
get borderTop() {
|
|
439
|
-
const ret = wasm.layout_borderTop(this.__wbg_ptr);
|
|
440
|
-
return ret;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Gets the top margin.
|
|
444
|
-
* @returns {number}
|
|
445
|
-
*/
|
|
446
|
-
get marginTop() {
|
|
447
|
-
const ret = wasm.layout_marginTop(this.__wbg_ptr);
|
|
448
|
-
return ret;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Gets the left border width.
|
|
452
|
-
* @returns {number}
|
|
453
|
-
*/
|
|
454
|
-
get borderLeft() {
|
|
455
|
-
const ret = wasm.layout_borderLeft(this.__wbg_ptr);
|
|
456
|
-
return ret;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Gets the left margin.
|
|
460
|
-
* @returns {number}
|
|
461
|
-
*/
|
|
462
|
-
get marginLeft() {
|
|
463
|
-
const ret = wasm.layout_marginLeft(this.__wbg_ptr);
|
|
464
|
-
return ret;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Gets the top padding.
|
|
468
|
-
* @returns {number}
|
|
469
|
-
*/
|
|
470
|
-
get paddingTop() {
|
|
471
|
-
const ret = wasm.layout_paddingTop(this.__wbg_ptr);
|
|
472
|
-
return ret;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Gets the right border width.
|
|
476
|
-
* @returns {number}
|
|
477
|
-
*/
|
|
478
|
-
get borderRight() {
|
|
479
|
-
const ret = wasm.layout_borderRight(this.__wbg_ptr);
|
|
480
|
-
return ret;
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Gets the right margin.
|
|
484
|
-
* @returns {number}
|
|
485
|
-
*/
|
|
486
|
-
get marginRight() {
|
|
487
|
-
const ret = wasm.layout_marginRight(this.__wbg_ptr);
|
|
488
|
-
return ret;
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Gets the left padding.
|
|
492
|
-
* @returns {number}
|
|
493
|
-
*/
|
|
494
|
-
get paddingLeft() {
|
|
495
|
-
const ret = wasm.layout_paddingLeft(this.__wbg_ptr);
|
|
496
|
-
return ret;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Gets the bottom border width.
|
|
500
|
-
* @returns {number}
|
|
501
|
-
*/
|
|
502
|
-
get borderBottom() {
|
|
503
|
-
const ret = wasm.layout_borderBottom(this.__wbg_ptr);
|
|
504
|
-
return ret;
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Gets the width of the scrollable content.
|
|
508
|
-
* @returns {number}
|
|
509
|
-
*/
|
|
510
|
-
get contentWidth() {
|
|
511
|
-
const ret = wasm.layout_contentWidth(this.__wbg_ptr);
|
|
512
|
-
return ret;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Gets the bottom margin.
|
|
516
|
-
* @returns {number}
|
|
517
|
-
*/
|
|
518
|
-
get marginBottom() {
|
|
519
|
-
const ret = wasm.layout_marginBottom(this.__wbg_ptr);
|
|
520
|
-
return ret;
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Gets the right padding.
|
|
524
|
-
* @returns {number}
|
|
525
|
-
*/
|
|
526
|
-
get paddingRight() {
|
|
527
|
-
const ret = wasm.layout_paddingRight(this.__wbg_ptr);
|
|
528
|
-
return ret;
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Gets the height of the scrollable content.
|
|
532
|
-
* @returns {number}
|
|
533
|
-
*/
|
|
534
|
-
get contentHeight() {
|
|
535
|
-
const ret = wasm.layout_contentHeight(this.__wbg_ptr);
|
|
536
|
-
return ret;
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Gets the bottom padding.
|
|
540
|
-
* @returns {number}
|
|
541
|
-
*/
|
|
542
|
-
get paddingBottom() {
|
|
543
|
-
const ret = wasm.layout_paddingBottom(this.__wbg_ptr);
|
|
544
|
-
return ret;
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Gets the width of the vertical scrollbar.
|
|
548
|
-
* @returns {number}
|
|
549
|
-
*/
|
|
550
|
-
get scrollbarWidth() {
|
|
551
|
-
const ret = wasm.layout_scrollbarWidth(this.__wbg_ptr);
|
|
552
|
-
return ret;
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* Gets the height of the horizontal scrollbar.
|
|
556
|
-
* @returns {number}
|
|
557
|
-
*/
|
|
558
|
-
get scrollbarHeight() {
|
|
559
|
-
const ret = wasm.layout_scrollbarHeight(this.__wbg_ptr);
|
|
560
|
-
return ret;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Gets the x coordinate of the node's top-left corner.
|
|
564
|
-
* @returns {number}
|
|
565
|
-
*/
|
|
566
|
-
get x() {
|
|
567
|
-
const ret = wasm.layout_x(this.__wbg_ptr);
|
|
568
|
-
return ret;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* Gets the y coordinate of the node's top-left corner.
|
|
572
|
-
* @returns {number}
|
|
573
|
-
*/
|
|
574
|
-
get y() {
|
|
575
|
-
const ret = wasm.layout_y(this.__wbg_ptr);
|
|
576
|
-
return ret;
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Gets the rendering order of the node.
|
|
580
|
-
* @returns {number}
|
|
581
|
-
*/
|
|
582
|
-
get order() {
|
|
583
|
-
const ret = wasm.layout_order(this.__wbg_ptr);
|
|
584
|
-
return ret >>> 0;
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Gets the computed width of the node.
|
|
588
|
-
* @returns {number}
|
|
589
|
-
*/
|
|
590
|
-
get width() {
|
|
591
|
-
const ret = wasm.layout_width(this.__wbg_ptr);
|
|
592
|
-
return ret;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Gets the computed height of the node.
|
|
596
|
-
* @returns {number}
|
|
597
|
-
*/
|
|
598
|
-
get height() {
|
|
599
|
-
const ret = wasm.layout_height(this.__wbg_ptr);
|
|
600
|
-
return ret;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
if (Symbol.dispose) Layout.prototype[Symbol.dispose] = Layout.prototype.free;
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Overflow handling enum
|
|
607
|
-
*
|
|
608
|
-
* Defines how content that overflows container boundaries is handled.
|
|
609
|
-
* Corresponds to CSS `overflow` property.
|
|
610
|
-
*
|
|
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)
|
|
616
|
-
* @enum {0 | 1 | 2 | 3}
|
|
617
|
-
*/
|
|
618
|
-
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",
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Position mode enum
|
|
627
|
-
*
|
|
628
|
-
* Controls element positioning method. Corresponds to CSS `position` property.
|
|
629
|
-
*
|
|
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
|
|
633
|
-
* @enum {0 | 1}
|
|
634
|
-
*/
|
|
635
|
-
export const Position = Object.freeze({
|
|
636
|
-
Relative: 0, "0": "Relative",
|
|
637
|
-
Absolute: 1, "1": "Absolute",
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Node Style struct
|
|
642
|
-
*
|
|
643
|
-
* Configuration object containing all CSS layout properties.
|
|
644
|
-
* Access properties via getter/setter methods.
|
|
645
|
-
*
|
|
646
|
-
* # Supported Property Categories
|
|
647
|
-
*
|
|
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
|
|
671
|
-
*/
|
|
672
|
-
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
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
if (Symbol.dispose) Style.prototype[Symbol.dispose] = Style.prototype.free;
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
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.
|
|
1087
|
-
*
|
|
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
|
|
1094
|
-
*
|
|
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);
|
|
1103
|
-
* ```
|
|
1104
|
-
*/
|
|
1105
|
-
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
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
if (Symbol.dispose) TaffyTree.prototype[Symbol.dispose] = TaffyTree.prototype.free;
|
|
1753
|
-
|
|
1754
|
-
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
1755
|
-
|
|
1756
|
-
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
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
const bytes = await module.arrayBuffer();
|
|
1774
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
1775
|
-
} else {
|
|
1776
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
1777
|
-
|
|
1778
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
1779
|
-
return { instance, module };
|
|
1780
|
-
} else {
|
|
1781
|
-
return instance;
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
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;
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
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;
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
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
|
-
}
|
|
1995
|
-
|
|
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);
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
async function __wbg_init(module_or_path) {
|
|
2005
|
-
if (wasm !== undefined) return wasm;
|
|
2006
|
-
|
|
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
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
|
|
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();
|
|
2020
|
-
|
|
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
|
-
}
|
|
2024
|
-
|
|
2025
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
2026
|
-
|
|
2027
|
-
return __wbg_finalize_init(instance, module);
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
export { initSync };
|
|
2031
|
-
export default __wbg_init;
|