@tarve/headless 0.7.0 → 0.8.0

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.
@@ -0,0 +1,611 @@
1
+ /* @ts-self-types="./tarve_web.d.ts" */
2
+
3
+ export class WebTree {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ WebTreeFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_webtree_free(ptr, 0);
13
+ }
14
+ /**
15
+ * Moves the native clock to `now_ms` without stepping motion. Call before `command` so
16
+ * transitions started by a patch begin now, not at the last painted frame.
17
+ * @param {number} now_ms
18
+ */
19
+ advanceClock(now_ms) {
20
+ wasm.webtree_advanceClock(this.__wbg_ptr, now_ms);
21
+ }
22
+ blur() {
23
+ wasm.webtree_blur(this.__wbg_ptr);
24
+ }
25
+ /**
26
+ * Applies a JSON `NativeCommand`, including the diagnostic `inspect`, `input` and
27
+ * `motionAdvance` commands. Commands that need a desktop window are ignored.
28
+ * @param {string} command
29
+ */
30
+ command(command) {
31
+ try {
32
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
33
+ const ptr0 = passStringToWasm0(command, wasm.__wbindgen_export, wasm.__wbindgen_export3);
34
+ const len0 = WASM_VECTOR_LEN;
35
+ wasm.webtree_command(retptr, this.__wbg_ptr, ptr0, len0);
36
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
37
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
38
+ if (r1) {
39
+ throw takeObject(r0);
40
+ }
41
+ } finally {
42
+ wasm.__wbindgen_add_to_stack_pointer(16);
43
+ }
44
+ }
45
+ /**
46
+ * CSS cursor for the hovered node: `text`, `col-resize`/`row-resize`, `pointer` or `default`.
47
+ * @returns {string}
48
+ */
49
+ cursor() {
50
+ let deferred1_0;
51
+ let deferred1_1;
52
+ try {
53
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
54
+ wasm.webtree_cursor(retptr, this.__wbg_ptr);
55
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
56
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
57
+ deferred1_0 = r0;
58
+ deferred1_1 = r1;
59
+ return getStringFromWasm0(r0, r1);
60
+ } finally {
61
+ wasm.__wbindgen_add_to_stack_pointer(16);
62
+ wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
63
+ }
64
+ }
65
+ /**
66
+ * @returns {number}
67
+ */
68
+ deviceHeight() {
69
+ const ret = wasm.webtree_deviceHeight(this.__wbg_ptr);
70
+ return ret >>> 0;
71
+ }
72
+ /**
73
+ * @returns {number}
74
+ */
75
+ deviceWidth() {
76
+ const ret = wasm.webtree_deviceWidth(this.__wbg_ptr);
77
+ return ret >>> 0;
78
+ }
79
+ /**
80
+ * Decodes a fetched remote image, or records why it failed when `error` is set.
81
+ * @param {string} url
82
+ * @param {Uint8Array} bytes
83
+ * @param {string | null} [error]
84
+ */
85
+ finishRemoteImage(url, bytes, error) {
86
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_export, wasm.__wbindgen_export3);
87
+ const len0 = WASM_VECTOR_LEN;
88
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
89
+ const len1 = WASM_VECTOR_LEN;
90
+ var ptr2 = isLikeNone(error) ? 0 : passStringToWasm0(error, wasm.__wbindgen_export, wasm.__wbindgen_export3);
91
+ var len2 = WASM_VECTOR_LEN;
92
+ wasm.webtree_finishRemoteImage(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
93
+ }
94
+ /**
95
+ * Advances motion to `now_ms`, lays out and paints when something changed.
96
+ * Returns true when `pixels()` holds a new frame.
97
+ * @param {number} now_ms
98
+ * @returns {boolean}
99
+ */
100
+ frame(now_ms) {
101
+ try {
102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
103
+ wasm.webtree_frame(retptr, this.__wbg_ptr, now_ms);
104
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
105
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
106
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
107
+ if (r2) {
108
+ throw takeObject(r1);
109
+ }
110
+ return r0 !== 0;
111
+ } finally {
112
+ wasm.__wbindgen_add_to_stack_pointer(16);
113
+ }
114
+ }
115
+ /**
116
+ * Sends a named key (`Enter`, `ShiftArrowLeft`, `Escape`…), as the desktop runtime does.
117
+ * Returns true when the tree handled it.
118
+ * @param {string} name
119
+ * @returns {boolean}
120
+ */
121
+ key(name) {
122
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export3);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ const ret = wasm.webtree_key(this.__wbg_ptr, ptr0, len0);
125
+ return ret !== 0;
126
+ }
127
+ /**
128
+ * Creates a tree from a `SceneDocument` JSON string.
129
+ * @param {string} document
130
+ */
131
+ constructor(document) {
132
+ try {
133
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
134
+ const ptr0 = passStringToWasm0(document, wasm.__wbindgen_export, wasm.__wbindgen_export3);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ wasm.webtree_new(retptr, ptr0, len0);
137
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
138
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
139
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
140
+ if (r2) {
141
+ throw takeObject(r1);
142
+ }
143
+ this.__wbg_ptr = r0;
144
+ WebTreeFinalization.register(this, this.__wbg_ptr, this);
145
+ return this;
146
+ } finally {
147
+ wasm.__wbindgen_add_to_stack_pointer(16);
148
+ }
149
+ }
150
+ /**
151
+ * Milliseconds until motion, caret blink or another clock needs a frame, or -1 when idle.
152
+ * @returns {number}
153
+ */
154
+ nextTickMs() {
155
+ const ret = wasm.webtree_nextTickMs(this.__wbg_ptr);
156
+ return ret;
157
+ }
158
+ /**
159
+ * @returns {number}
160
+ */
161
+ pixelsLen() {
162
+ const ret = wasm.webtree_pixelsLen(this.__wbg_ptr);
163
+ return ret >>> 0;
164
+ }
165
+ /**
166
+ * Address of the last frame's opaque RGBA8 pixels in wasm memory, so the page can
167
+ * hand them to the canvas without copying.
168
+ * @returns {number}
169
+ */
170
+ pixelsPtr() {
171
+ const ret = wasm.webtree_pixelsPtr(this.__wbg_ptr);
172
+ return ret >>> 0;
173
+ }
174
+ pointerContext() {
175
+ wasm.webtree_pointerContext(this.__wbg_ptr);
176
+ }
177
+ pointerDown() {
178
+ wasm.webtree_pointerDown(this.__wbg_ptr);
179
+ }
180
+ pointerLeave() {
181
+ wasm.webtree_pointerLeave(this.__wbg_ptr);
182
+ }
183
+ /**
184
+ * @param {number} x
185
+ * @param {number} y
186
+ */
187
+ pointerMove(x, y) {
188
+ wasm.webtree_pointerMove(this.__wbg_ptr, x, y);
189
+ }
190
+ pointerUp() {
191
+ wasm.webtree_pointerUp(this.__wbg_ptr);
192
+ }
193
+ /**
194
+ * Sets the logical size and device pixel ratio of the canvas.
195
+ * @param {number} width
196
+ * @param {number} height
197
+ * @param {number} scale
198
+ */
199
+ resize(width, height, scale) {
200
+ wasm.webtree_resize(this.__wbg_ptr, width, height, scale);
201
+ }
202
+ /**
203
+ * @returns {string | undefined}
204
+ */
205
+ selectedText() {
206
+ try {
207
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
208
+ wasm.webtree_selectedText(retptr, this.__wbg_ptr);
209
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
210
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
211
+ let v1;
212
+ if (r0 !== 0) {
213
+ v1 = getStringFromWasm0(r0, r1);
214
+ wasm.__wbindgen_export2(r0, r1 * 1, 1);
215
+ }
216
+ return v1;
217
+ } finally {
218
+ wasm.__wbindgen_add_to_stack_pointer(16);
219
+ }
220
+ }
221
+ /**
222
+ * Drains pending native events as a JSON array.
223
+ * @returns {string}
224
+ */
225
+ takeEvents() {
226
+ let deferred1_0;
227
+ let deferred1_1;
228
+ try {
229
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
230
+ wasm.webtree_takeEvents(retptr, this.__wbg_ptr);
231
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
232
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
233
+ deferred1_0 = r0;
234
+ deferred1_1 = r1;
235
+ return getStringFromWasm0(r0, r1);
236
+ } finally {
237
+ wasm.__wbindgen_add_to_stack_pointer(16);
238
+ wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
239
+ }
240
+ }
241
+ /**
242
+ * Remote (`http(s)://`) image URLs painted since the last call, as a JSON array.
243
+ * The host fetches them and hands the bytes to `finishRemoteImage`.
244
+ * @returns {string}
245
+ */
246
+ takeRemoteImageRequests() {
247
+ let deferred1_0;
248
+ let deferred1_1;
249
+ try {
250
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
251
+ wasm.webtree_takeRemoteImageRequests(retptr, this.__wbg_ptr);
252
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
253
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
254
+ deferred1_0 = r0;
255
+ deferred1_1 = r1;
256
+ return getStringFromWasm0(r0, r1);
257
+ } finally {
258
+ wasm.__wbindgen_add_to_stack_pointer(16);
259
+ wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
260
+ }
261
+ }
262
+ /**
263
+ * @param {string} text
264
+ */
265
+ typeText(text) {
266
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export3);
267
+ const len0 = WASM_VECTOR_LEN;
268
+ wasm.webtree_typeText(this.__wbg_ptr, ptr0, len0);
269
+ }
270
+ /**
271
+ * @param {number} delta_x
272
+ * @param {number} delta_y
273
+ */
274
+ wheel(delta_x, delta_y) {
275
+ wasm.webtree_wheel(this.__wbg_ptr, delta_x, delta_y);
276
+ }
277
+ /**
278
+ * The `windowAction` (`minimize`, `toggleMaximize`, `toggleFullscreen`, `close`) of a node, if it has one.
279
+ * @param {string} id
280
+ * @returns {string | undefined}
281
+ */
282
+ windowAction(id) {
283
+ try {
284
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
285
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export3);
286
+ const len0 = WASM_VECTOR_LEN;
287
+ wasm.webtree_windowAction(retptr, this.__wbg_ptr, ptr0, len0);
288
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
289
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
290
+ let v2;
291
+ if (r0 !== 0) {
292
+ v2 = getStringFromWasm0(r0, r1);
293
+ wasm.__wbindgen_export2(r0, r1 * 1, 1);
294
+ }
295
+ return v2;
296
+ } finally {
297
+ wasm.__wbindgen_add_to_stack_pointer(16);
298
+ }
299
+ }
300
+ }
301
+ if (Symbol.dispose) WebTree.prototype[Symbol.dispose] = WebTree.prototype.free;
302
+
303
+ /**
304
+ * A zlib-wrapped deflate stream of `data` at `level` (0–9): @tarve/headless's PNG encoder,
305
+ * the same miniz_oxide the native library gives txiki.js and Android (src/zlib.rs).
306
+ * @param {Uint8Array} data
307
+ * @param {number} level
308
+ * @returns {Uint8Array}
309
+ */
310
+ export function deflate(data, level) {
311
+ try {
312
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
313
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
314
+ const len0 = WASM_VECTOR_LEN;
315
+ wasm.deflate(retptr, ptr0, len0, level);
316
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
317
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
318
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
319
+ wasm.__wbindgen_export2(r0, r1 * 1, 1);
320
+ return v2;
321
+ } finally {
322
+ wasm.__wbindgen_add_to_stack_pointer(16);
323
+ }
324
+ }
325
+
326
+ /**
327
+ * The bytes of a zlib stream; throws when `data` is not one.
328
+ * @param {Uint8Array} data
329
+ * @returns {Uint8Array}
330
+ */
331
+ export function inflate(data) {
332
+ try {
333
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
334
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
335
+ const len0 = WASM_VECTOR_LEN;
336
+ wasm.inflate(retptr, ptr0, len0);
337
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
338
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
339
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
340
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
341
+ if (r3) {
342
+ throw takeObject(r2);
343
+ }
344
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
345
+ wasm.__wbindgen_export2(r0, r1 * 1, 1);
346
+ return v2;
347
+ } finally {
348
+ wasm.__wbindgen_add_to_stack_pointer(16);
349
+ }
350
+ }
351
+
352
+ /**
353
+ * Registers a TrueType/OpenType font for every tree created afterwards.
354
+ * `generics` is a comma-separated list of CSS generic families (`system-ui,sans-serif`).
355
+ * @param {Uint8Array} bytes
356
+ * @param {string} generics
357
+ */
358
+ export function registerFont(bytes, generics) {
359
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
360
+ const len0 = WASM_VECTOR_LEN;
361
+ const ptr1 = passStringToWasm0(generics, wasm.__wbindgen_export, wasm.__wbindgen_export3);
362
+ const len1 = WASM_VECTOR_LEN;
363
+ wasm.registerFont(ptr0, len0, ptr1, len1);
364
+ }
365
+ function __wbg_get_imports() {
366
+ const import0 = {
367
+ __proto__: null,
368
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
369
+ const ret = Error(getStringFromWasm0(arg0, arg1));
370
+ return addHeapObject(ret);
371
+ },
372
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
373
+ throw new Error(getStringFromWasm0(arg0, arg1));
374
+ },
375
+ };
376
+ return {
377
+ __proto__: null,
378
+ "./tarve_web_bg.js": import0,
379
+ };
380
+ }
381
+
382
+ const WebTreeFinalization = (typeof FinalizationRegistry === 'undefined')
383
+ ? { register: () => {}, unregister: () => {} }
384
+ : new FinalizationRegistry(ptr => wasm.__wbg_webtree_free(ptr, 1));
385
+
386
+ function addHeapObject(obj) {
387
+ if (heap_next === heap.length) heap.push(heap.length + 1);
388
+ const idx = heap_next;
389
+ heap_next = heap[idx];
390
+
391
+ heap[idx] = obj;
392
+ return idx;
393
+ }
394
+
395
+ function dropObject(idx) {
396
+ if (idx < 1028) return;
397
+ heap[idx] = heap_next;
398
+ heap_next = idx;
399
+ }
400
+
401
+ function getArrayU8FromWasm0(ptr, len) {
402
+ ptr = ptr >>> 0;
403
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
404
+ }
405
+
406
+ let cachedDataViewMemory0 = null;
407
+ function getDataViewMemory0() {
408
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
409
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
410
+ }
411
+ return cachedDataViewMemory0;
412
+ }
413
+
414
+ function getStringFromWasm0(ptr, len) {
415
+ return decodeText(ptr >>> 0, len);
416
+ }
417
+
418
+ let cachedUint8ArrayMemory0 = null;
419
+ function getUint8ArrayMemory0() {
420
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
421
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
422
+ }
423
+ return cachedUint8ArrayMemory0;
424
+ }
425
+
426
+ function getObject(idx) { return heap[idx]; }
427
+
428
+ let heap = new Array(1024).fill(undefined);
429
+ heap.push(undefined, null, true, false);
430
+
431
+ let heap_next = heap.length;
432
+
433
+ function isLikeNone(x) {
434
+ return x === undefined || x === null;
435
+ }
436
+
437
+ function passArray8ToWasm0(arg, malloc) {
438
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
439
+ getUint8ArrayMemory0().set(arg, ptr / 1);
440
+ WASM_VECTOR_LEN = arg.length;
441
+ return ptr;
442
+ }
443
+
444
+ function passStringToWasm0(arg, malloc, realloc) {
445
+ if (realloc === undefined) {
446
+ const buf = cachedTextEncoder.encode(arg);
447
+ const ptr = malloc(buf.length, 1) >>> 0;
448
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
449
+ WASM_VECTOR_LEN = buf.length;
450
+ return ptr;
451
+ }
452
+
453
+ let len = arg.length;
454
+ let ptr = malloc(len, 1) >>> 0;
455
+
456
+ const mem = getUint8ArrayMemory0();
457
+
458
+ let offset = 0;
459
+
460
+ for (; offset < len; offset++) {
461
+ const code = arg.charCodeAt(offset);
462
+ if (code > 0x7F) break;
463
+ mem[ptr + offset] = code;
464
+ }
465
+ if (offset !== len) {
466
+ if (offset !== 0) {
467
+ arg = arg.slice(offset);
468
+ }
469
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
470
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
471
+ const ret = cachedTextEncoder.encodeInto(arg, view);
472
+
473
+ offset += ret.written;
474
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
475
+ }
476
+
477
+ WASM_VECTOR_LEN = offset;
478
+ return ptr;
479
+ }
480
+
481
+ function takeObject(idx) {
482
+ const ret = getObject(idx);
483
+ dropObject(idx);
484
+ return ret;
485
+ }
486
+
487
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
488
+ cachedTextDecoder.decode();
489
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
490
+ let numBytesDecoded = 0;
491
+ function decodeText(ptr, len) {
492
+ numBytesDecoded += len;
493
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
494
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
495
+ cachedTextDecoder.decode();
496
+ numBytesDecoded = len;
497
+ }
498
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
499
+ }
500
+
501
+ const cachedTextEncoder = new TextEncoder();
502
+
503
+ if (!('encodeInto' in cachedTextEncoder)) {
504
+ cachedTextEncoder.encodeInto = function (arg, view) {
505
+ const buf = cachedTextEncoder.encode(arg);
506
+ view.set(buf);
507
+ return {
508
+ read: arg.length,
509
+ written: buf.length
510
+ };
511
+ };
512
+ }
513
+
514
+ let WASM_VECTOR_LEN = 0;
515
+
516
+ let wasmModule, wasmInstance, wasm;
517
+ function __wbg_finalize_init(instance, module) {
518
+ wasmInstance = instance;
519
+ wasm = instance.exports;
520
+ wasmModule = module;
521
+ cachedDataViewMemory0 = null;
522
+ cachedUint8ArrayMemory0 = null;
523
+ return wasm;
524
+ }
525
+
526
+ async function __wbg_load(module, imports) {
527
+ if (typeof Response === 'function' && module instanceof Response) {
528
+ if (!module.ok) {
529
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
530
+ }
531
+
532
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
533
+ try {
534
+ return await WebAssembly.instantiateStreaming(module, imports);
535
+ } catch (e) {
536
+ const validResponse = expectedResponseType(module.type);
537
+
538
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
539
+ 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);
540
+
541
+ } else { throw e; }
542
+ }
543
+ }
544
+
545
+ const bytes = await module.arrayBuffer();
546
+ return await WebAssembly.instantiate(bytes, imports);
547
+ } else {
548
+ const instance = await WebAssembly.instantiate(module, imports);
549
+
550
+ if (instance instanceof WebAssembly.Instance) {
551
+ return { instance, module };
552
+ } else {
553
+ return instance;
554
+ }
555
+ }
556
+
557
+ function expectedResponseType(type) {
558
+ switch (type) {
559
+ case 'basic': case 'cors': case 'default': return true;
560
+ }
561
+ return false;
562
+ }
563
+ }
564
+
565
+ function initSync(module) {
566
+ if (wasm !== undefined) return wasm;
567
+
568
+
569
+ if (module !== undefined) {
570
+ if (Object.getPrototypeOf(module) === Object.prototype) {
571
+ ({module} = module)
572
+ } else {
573
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
574
+ }
575
+ }
576
+
577
+ const imports = __wbg_get_imports();
578
+ if (!(module instanceof WebAssembly.Module)) {
579
+ module = new WebAssembly.Module(module);
580
+ }
581
+ const instance = new WebAssembly.Instance(module, imports);
582
+ return __wbg_finalize_init(instance, module);
583
+ }
584
+
585
+ async function __wbg_init(module_or_path) {
586
+ if (wasm !== undefined) return wasm;
587
+
588
+
589
+ if (module_or_path !== undefined) {
590
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
591
+ ({module_or_path} = module_or_path)
592
+ } else {
593
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
594
+ }
595
+ }
596
+
597
+ if (module_or_path === undefined) {
598
+ module_or_path = new URL('tarve_web_bg.wasm', import.meta.url);
599
+ }
600
+ const imports = __wbg_get_imports();
601
+
602
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
603
+ module_or_path = fetch(module_or_path);
604
+ }
605
+
606
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
607
+
608
+ return __wbg_finalize_init(instance, module);
609
+ }
610
+
611
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,36 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_webtree_free: (a: number, b: number) => void;
5
+ export const deflate: (a: number, b: number, c: number, d: number) => void;
6
+ export const inflate: (a: number, b: number, c: number) => void;
7
+ export const registerFont: (a: number, b: number, c: number, d: number) => void;
8
+ export const webtree_advanceClock: (a: number, b: number) => void;
9
+ export const webtree_blur: (a: number) => void;
10
+ export const webtree_command: (a: number, b: number, c: number, d: number) => void;
11
+ export const webtree_cursor: (a: number, b: number) => void;
12
+ export const webtree_deviceHeight: (a: number) => number;
13
+ export const webtree_deviceWidth: (a: number) => number;
14
+ export const webtree_finishRemoteImage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
15
+ export const webtree_frame: (a: number, b: number, c: number) => void;
16
+ export const webtree_key: (a: number, b: number, c: number) => number;
17
+ export const webtree_new: (a: number, b: number, c: number) => void;
18
+ export const webtree_nextTickMs: (a: number) => number;
19
+ export const webtree_pixelsLen: (a: number) => number;
20
+ export const webtree_pixelsPtr: (a: number) => number;
21
+ export const webtree_pointerContext: (a: number) => void;
22
+ export const webtree_pointerDown: (a: number) => void;
23
+ export const webtree_pointerLeave: (a: number) => void;
24
+ export const webtree_pointerMove: (a: number, b: number, c: number) => void;
25
+ export const webtree_pointerUp: (a: number) => void;
26
+ export const webtree_resize: (a: number, b: number, c: number, d: number) => void;
27
+ export const webtree_selectedText: (a: number, b: number) => void;
28
+ export const webtree_takeEvents: (a: number, b: number) => void;
29
+ export const webtree_takeRemoteImageRequests: (a: number, b: number) => void;
30
+ export const webtree_typeText: (a: number, b: number, c: number) => void;
31
+ export const webtree_wheel: (a: number, b: number, c: number) => void;
32
+ export const webtree_windowAction: (a: number, b: number, c: number, d: number) => void;
33
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
34
+ export const __wbindgen_export: (a: number, b: number) => number;
35
+ export const __wbindgen_export2: (a: number, b: number, c: number) => void;
36
+ export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
@@ -71,11 +71,22 @@ export class WebTree {
71
71
  typeText(text: string): void;
72
72
  wheel(delta_x: number, delta_y: number): void;
73
73
  /**
74
- * The `windowAction` (`minimize`, `toggleMaximize`, `close`) of a node, if it has one.
74
+ * The `windowAction` (`minimize`, `toggleMaximize`, `toggleFullscreen`, `close`) of a node, if it has one.
75
75
  */
76
76
  windowAction(id: string): string | undefined;
77
77
  }
78
78
 
79
+ /**
80
+ * A zlib-wrapped deflate stream of `data` at `level` (0–9): @tarve/headless's PNG encoder,
81
+ * the same miniz_oxide the native library gives txiki.js and Android (src/zlib.rs).
82
+ */
83
+ export function deflate(data: Uint8Array, level: number): Uint8Array;
84
+
85
+ /**
86
+ * The bytes of a zlib stream; throws when `data` is not one.
87
+ */
88
+ export function inflate(data: Uint8Array): Uint8Array;
89
+
79
90
  /**
80
91
  * Registers a TrueType/OpenType font for every tree created afterwards.
81
92
  * `generics` is a comma-separated list of CSS generic families (`system-ui,sans-serif`).
@@ -87,6 +98,8 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
87
98
  export interface InitOutput {
88
99
  readonly memory: WebAssembly.Memory;
89
100
  readonly __wbg_webtree_free: (a: number, b: number) => void;
101
+ readonly deflate: (a: number, b: number, c: number, d: number) => void;
102
+ readonly inflate: (a: number, b: number, c: number) => void;
90
103
  readonly registerFont: (a: number, b: number, c: number, d: number) => void;
91
104
  readonly webtree_advanceClock: (a: number, b: number) => void;
92
105
  readonly webtree_blur: (a: number) => void;
@@ -113,10 +126,10 @@ export interface InitOutput {
113
126
  readonly webtree_typeText: (a: number, b: number, c: number) => void;
114
127
  readonly webtree_wheel: (a: number, b: number, c: number) => void;
115
128
  readonly webtree_windowAction: (a: number, b: number, c: number, d: number) => void;
116
- readonly __wbindgen_export: (a: number, b: number) => number;
117
- readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
118
129
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
119
- readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
130
+ readonly __wbindgen_export: (a: number, b: number) => number;
131
+ readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
132
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
120
133
  }
121
134
 
122
135
  export type SyncInitInput = BufferSource | WebAssembly.Module;