1 | import { awaitPromise, setWasmExports, wrap } from './asyncify.js';
|
2 | let wasm;
|
3 | const heap = new Array(32).fill(undefined);
|
4 | heap.push(undefined, null, true, false);
|
5 | function getObject(idx) { return heap[idx]; }
|
6 | let heap_next = heap.length;
|
7 | function dropObject(idx) {
|
8 | if (idx < 36)
|
9 | return;
|
10 | heap[idx] = heap_next;
|
11 | heap_next = idx;
|
12 | }
|
13 | function takeObject(idx) {
|
14 | const ret = getObject(idx);
|
15 | dropObject(idx);
|
16 | return ret;
|
17 | }
|
18 | let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
19 | cachedTextDecoder.decode();
|
20 | let cachegetUint8Memory0 = null;
|
21 | function getUint8Memory0() {
|
22 | if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
23 | cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
24 | }
|
25 | return cachegetUint8Memory0;
|
26 | }
|
27 | function getStringFromWasm0(ptr, len) {
|
28 | return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
29 | }
|
30 | function addHeapObject(obj) {
|
31 | if (heap_next === heap.length)
|
32 | heap.push(heap.length + 1);
|
33 | const idx = heap_next;
|
34 | heap_next = heap[idx];
|
35 | heap[idx] = obj;
|
36 | return idx;
|
37 | }
|
38 | function debugString(val) {
|
39 |
|
40 | const type = typeof val;
|
41 | if (type == 'number' || type == 'boolean' || val == null) {
|
42 | return `${val}`;
|
43 | }
|
44 | if (type == 'string') {
|
45 | return `"${val}"`;
|
46 | }
|
47 | if (type == 'symbol') {
|
48 | const description = val.description;
|
49 | if (description == null) {
|
50 | return 'Symbol';
|
51 | }
|
52 | else {
|
53 | return `Symbol(${description})`;
|
54 | }
|
55 | }
|
56 | if (type == 'function') {
|
57 | const name = val.name;
|
58 | if (typeof name == 'string' && name.length > 0) {
|
59 | return `Function(${name})`;
|
60 | }
|
61 | else {
|
62 | return 'Function';
|
63 | }
|
64 | }
|
65 |
|
66 | if (Array.isArray(val)) {
|
67 | const length = val.length;
|
68 | let debug = '[';
|
69 | if (length > 0) {
|
70 | debug += debugString(val[0]);
|
71 | }
|
72 | for (let i = 1; i < length; i++) {
|
73 | debug += ', ' + debugString(val[i]);
|
74 | }
|
75 | debug += ']';
|
76 | return debug;
|
77 | }
|
78 |
|
79 | const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
80 | let className;
|
81 | if (builtInMatches.length > 1) {
|
82 | className = builtInMatches[1];
|
83 | }
|
84 | else {
|
85 |
|
86 | return toString.call(val);
|
87 | }
|
88 | if (className == 'Object') {
|
89 |
|
90 |
|
91 |
|
92 | try {
|
93 | return 'Object(' + JSON.stringify(val) + ')';
|
94 | }
|
95 | catch (_) {
|
96 | return 'Object';
|
97 | }
|
98 | }
|
99 |
|
100 | if (val instanceof Error) {
|
101 | return `${val.name}: ${val.message}\n${val.stack}`;
|
102 | }
|
103 |
|
104 | return className;
|
105 | }
|
106 | let WASM_VECTOR_LEN = 0;
|
107 | let cachedTextEncoder = new TextEncoder('utf-8');
|
108 | const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
109 | ? function (arg, view) {
|
110 | return cachedTextEncoder.encodeInto(arg, view);
|
111 | }
|
112 | : function (arg, view) {
|
113 | const buf = cachedTextEncoder.encode(arg);
|
114 | view.set(buf);
|
115 | return {
|
116 | read: arg.length,
|
117 | written: buf.length
|
118 | };
|
119 | });
|
120 | function passStringToWasm0(arg, malloc, realloc) {
|
121 | if (realloc === undefined) {
|
122 | const buf = cachedTextEncoder.encode(arg);
|
123 | const ptr = malloc(buf.length);
|
124 | getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
125 | WASM_VECTOR_LEN = buf.length;
|
126 | return ptr;
|
127 | }
|
128 | let len = arg.length;
|
129 | let ptr = malloc(len);
|
130 | const mem = getUint8Memory0();
|
131 | let offset = 0;
|
132 | for (; offset < len; offset++) {
|
133 | const code = arg.charCodeAt(offset);
|
134 | if (code > 0x7F)
|
135 | break;
|
136 | mem[ptr + offset] = code;
|
137 | }
|
138 | if (offset !== len) {
|
139 | if (offset !== 0) {
|
140 | arg = arg.slice(offset);
|
141 | }
|
142 | ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
143 | const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
144 | const ret = encodeString(arg, view);
|
145 | offset += ret.written;
|
146 | }
|
147 | WASM_VECTOR_LEN = offset;
|
148 | return ptr;
|
149 | }
|
150 | let cachegetInt32Memory0 = null;
|
151 | function getInt32Memory0() {
|
152 | if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
153 | cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
154 | }
|
155 | return cachegetInt32Memory0;
|
156 | }
|
157 | function isLikeNone(x) {
|
158 | return x === undefined || x === null;
|
159 | }
|
160 | let stack_pointer = 32;
|
161 | function addBorrowedObject(obj) {
|
162 | if (stack_pointer == 1)
|
163 | throw new Error('out of js stack');
|
164 | heap[--stack_pointer] = obj;
|
165 | return stack_pointer;
|
166 | }
|
167 | function passArray8ToWasm0(arg, malloc) {
|
168 | const ptr = malloc(arg.length * 1);
|
169 | getUint8Memory0().set(arg, ptr / 1);
|
170 | WASM_VECTOR_LEN = arg.length;
|
171 | return ptr;
|
172 | }
|
173 | function handleError(f, args) {
|
174 | try {
|
175 | return f.apply(this, args);
|
176 | }
|
177 | catch (e) {
|
178 | wasm.__wbindgen_exn_store(addHeapObject(e));
|
179 | }
|
180 | }
|
181 |
|
182 |
|
183 | export class Comment {
|
184 | static __wrap(ptr) {
|
185 | const obj = Object.create(Comment.prototype);
|
186 | obj.ptr = ptr;
|
187 | return obj;
|
188 | }
|
189 | __destroy_into_raw() {
|
190 | const ptr = this.ptr;
|
191 | this.ptr = 0;
|
192 | return ptr;
|
193 | }
|
194 | free() {
|
195 | const ptr = this.__destroy_into_raw();
|
196 | wasm.__wbg_comment_free(ptr);
|
197 | }
|
198 | |
199 |
|
200 |
|
201 |
|
202 | before(content, content_type) {
|
203 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
204 | var len0 = WASM_VECTOR_LEN;
|
205 | wasm.comment_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
206 | return this;
|
207 | }
|
208 | |
209 |
|
210 |
|
211 |
|
212 | after(content, content_type) {
|
213 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
214 | var len0 = WASM_VECTOR_LEN;
|
215 | wasm.comment_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
216 | return this;
|
217 | }
|
218 | |
219 |
|
220 |
|
221 |
|
222 | replace(content, content_type) {
|
223 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
224 | var len0 = WASM_VECTOR_LEN;
|
225 | wasm.comment_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
226 | return this;
|
227 | }
|
228 | |
229 |
|
230 | remove() {
|
231 | wasm.comment_remove(this.ptr);
|
232 | return this;
|
233 | }
|
234 | |
235 |
|
236 |
|
237 | get removed() {
|
238 | var ret = wasm.comment_removed(this.ptr);
|
239 | return ret !== 0;
|
240 | }
|
241 | |
242 |
|
243 |
|
244 | get text() {
|
245 | try {
|
246 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
247 | wasm.comment_text(retptr, this.ptr);
|
248 | var r0 = getInt32Memory0()[retptr / 4 + 0];
|
249 | var r1 = getInt32Memory0()[retptr / 4 + 1];
|
250 | return getStringFromWasm0(r0, r1);
|
251 | }
|
252 | finally {
|
253 | wasm.__wbindgen_add_to_stack_pointer(16);
|
254 | wasm.__wbindgen_free(r0, r1);
|
255 | }
|
256 | }
|
257 | |
258 |
|
259 |
|
260 | set text(text) {
|
261 | var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
262 | var len0 = WASM_VECTOR_LEN;
|
263 | wasm.comment_set_text(this.ptr, ptr0, len0);
|
264 | }
|
265 | }
|
266 |
|
267 |
|
268 | export class Doctype {
|
269 | static __wrap(ptr) {
|
270 | const obj = Object.create(Doctype.prototype);
|
271 | obj.ptr = ptr;
|
272 | return obj;
|
273 | }
|
274 | __destroy_into_raw() {
|
275 | const ptr = this.ptr;
|
276 | this.ptr = 0;
|
277 | return ptr;
|
278 | }
|
279 | free() {
|
280 | const ptr = this.__destroy_into_raw();
|
281 | wasm.__wbg_doctype_free(ptr);
|
282 | }
|
283 | |
284 |
|
285 |
|
286 | get name() {
|
287 | var ret = wasm.doctype_name(this.ptr);
|
288 | return takeObject(ret);
|
289 | }
|
290 | |
291 |
|
292 |
|
293 | get publicId() {
|
294 | var ret = wasm.doctype_public_id(this.ptr);
|
295 | return takeObject(ret);
|
296 | }
|
297 | |
298 |
|
299 |
|
300 | get systemId() {
|
301 | var ret = wasm.doctype_system_id(this.ptr);
|
302 | return takeObject(ret);
|
303 | }
|
304 | }
|
305 |
|
306 |
|
307 | export class DocumentEnd {
|
308 | static __wrap(ptr) {
|
309 | const obj = Object.create(DocumentEnd.prototype);
|
310 | obj.ptr = ptr;
|
311 | return obj;
|
312 | }
|
313 | __destroy_into_raw() {
|
314 | const ptr = this.ptr;
|
315 | this.ptr = 0;
|
316 | return ptr;
|
317 | }
|
318 | free() {
|
319 | const ptr = this.__destroy_into_raw();
|
320 | wasm.__wbg_documentend_free(ptr);
|
321 | }
|
322 | |
323 |
|
324 |
|
325 |
|
326 | append(content, content_type) {
|
327 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
328 | var len0 = WASM_VECTOR_LEN;
|
329 | wasm.documentend_append(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
330 | return this;
|
331 | }
|
332 | }
|
333 |
|
334 |
|
335 | export class Element {
|
336 | static __wrap(ptr) {
|
337 | const obj = Object.create(Element.prototype);
|
338 | obj.ptr = ptr;
|
339 | return obj;
|
340 | }
|
341 | __destroy_into_raw() {
|
342 | const ptr = this.ptr;
|
343 | this.ptr = 0;
|
344 | return ptr;
|
345 | }
|
346 | free() {
|
347 | const ptr = this.__destroy_into_raw();
|
348 | wasm.__wbg_element_free(ptr);
|
349 | }
|
350 | |
351 |
|
352 |
|
353 |
|
354 | before(content, content_type) {
|
355 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
356 | var len0 = WASM_VECTOR_LEN;
|
357 | wasm.element_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
358 | return this;
|
359 | }
|
360 | |
361 |
|
362 |
|
363 |
|
364 | after(content, content_type) {
|
365 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
366 | var len0 = WASM_VECTOR_LEN;
|
367 | wasm.element_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
368 | return this;
|
369 | }
|
370 | |
371 |
|
372 |
|
373 |
|
374 | replace(content, content_type) {
|
375 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
376 | var len0 = WASM_VECTOR_LEN;
|
377 | wasm.element_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
378 | return this;
|
379 | }
|
380 | |
381 |
|
382 | remove() {
|
383 | wasm.element_remove(this.ptr);
|
384 | return this;
|
385 | }
|
386 | |
387 |
|
388 |
|
389 | get removed() {
|
390 | var ret = wasm.element_removed(this.ptr);
|
391 | return ret !== 0;
|
392 | }
|
393 | |
394 |
|
395 |
|
396 | get tagName() {
|
397 | try {
|
398 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
399 | wasm.element_tag_name(retptr, this.ptr);
|
400 | var r0 = getInt32Memory0()[retptr / 4 + 0];
|
401 | var r1 = getInt32Memory0()[retptr / 4 + 1];
|
402 | return getStringFromWasm0(r0, r1);
|
403 | }
|
404 | finally {
|
405 | wasm.__wbindgen_add_to_stack_pointer(16);
|
406 | wasm.__wbindgen_free(r0, r1);
|
407 | }
|
408 | }
|
409 | |
410 |
|
411 |
|
412 | set tagName(name) {
|
413 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
414 | var len0 = WASM_VECTOR_LEN;
|
415 | wasm.element_set_tag_name(this.ptr, ptr0, len0);
|
416 | }
|
417 | |
418 |
|
419 |
|
420 | get namespaceURI() {
|
421 | var ret = wasm.element_namespace_uri(this.ptr);
|
422 | return takeObject(ret);
|
423 | }
|
424 | |
425 |
|
426 |
|
427 | get attributes() {
|
428 | var ret = wasm.element_attributes(this.ptr);
|
429 | return takeObject(ret)[Symbol.iterator]();
|
430 | }
|
431 | |
432 |
|
433 |
|
434 |
|
435 | getAttribute(name) {
|
436 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
437 | var len0 = WASM_VECTOR_LEN;
|
438 | var ret = wasm.element_getAttribute(this.ptr, ptr0, len0);
|
439 | return takeObject(ret);
|
440 | }
|
441 | |
442 |
|
443 |
|
444 |
|
445 | hasAttribute(name) {
|
446 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
447 | var len0 = WASM_VECTOR_LEN;
|
448 | var ret = wasm.element_hasAttribute(this.ptr, ptr0, len0);
|
449 | return ret !== 0;
|
450 | }
|
451 | |
452 |
|
453 |
|
454 |
|
455 | setAttribute(name, value) {
|
456 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
457 | var len0 = WASM_VECTOR_LEN;
|
458 | var ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
459 | var len1 = WASM_VECTOR_LEN;
|
460 | wasm.element_setAttribute(this.ptr, ptr0, len0, ptr1, len1);
|
461 | return this;
|
462 | }
|
463 | |
464 |
|
465 |
|
466 | removeAttribute(name) {
|
467 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
468 | var len0 = WASM_VECTOR_LEN;
|
469 | wasm.element_removeAttribute(this.ptr, ptr0, len0);
|
470 | return this;
|
471 | }
|
472 | |
473 |
|
474 |
|
475 |
|
476 | prepend(content, content_type) {
|
477 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
478 | var len0 = WASM_VECTOR_LEN;
|
479 | wasm.element_prepend(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
480 | return this;
|
481 | }
|
482 | |
483 |
|
484 |
|
485 |
|
486 | append(content, content_type) {
|
487 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
488 | var len0 = WASM_VECTOR_LEN;
|
489 | wasm.element_append(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
490 | return this;
|
491 | }
|
492 | |
493 |
|
494 |
|
495 |
|
496 | setInnerContent(content, content_type) {
|
497 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
498 | var len0 = WASM_VECTOR_LEN;
|
499 | wasm.element_setInnerContent(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
500 | return this;
|
501 | }
|
502 | |
503 |
|
504 | removeAndKeepContent() {
|
505 | wasm.element_removeAndKeepContent(this.ptr);
|
506 | return this;
|
507 | }
|
508 | |
509 |
|
510 |
|
511 | onEndTag(handler) {
|
512 | wasm.element_onEndTag(this.ptr, addHeapObject(handler.bind(this)));
|
513 | }
|
514 | }
|
515 |
|
516 |
|
517 | export class EndTag {
|
518 | static __wrap(ptr) {
|
519 | const obj = Object.create(EndTag.prototype);
|
520 | obj.ptr = ptr;
|
521 | return obj;
|
522 | }
|
523 | __destroy_into_raw() {
|
524 | const ptr = this.ptr;
|
525 | this.ptr = 0;
|
526 | return ptr;
|
527 | }
|
528 | free() {
|
529 | const ptr = this.__destroy_into_raw();
|
530 | wasm.__wbg_endtag_free(ptr);
|
531 | }
|
532 | |
533 |
|
534 |
|
535 | get name() {
|
536 | try {
|
537 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
538 | wasm.endtag_name(retptr, this.ptr);
|
539 | var r0 = getInt32Memory0()[retptr / 4 + 0];
|
540 | var r1 = getInt32Memory0()[retptr / 4 + 1];
|
541 | return getStringFromWasm0(r0, r1);
|
542 | }
|
543 | finally {
|
544 | wasm.__wbindgen_add_to_stack_pointer(16);
|
545 | wasm.__wbindgen_free(r0, r1);
|
546 | }
|
547 | }
|
548 | |
549 |
|
550 |
|
551 | set name(name) {
|
552 | var ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
553 | var len0 = WASM_VECTOR_LEN;
|
554 | wasm.endtag_set_name(this.ptr, ptr0, len0);
|
555 | }
|
556 | |
557 |
|
558 |
|
559 |
|
560 | before(content, content_type) {
|
561 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
562 | var len0 = WASM_VECTOR_LEN;
|
563 | wasm.endtag_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
564 | return this;
|
565 | }
|
566 | |
567 |
|
568 |
|
569 |
|
570 | after(content, content_type) {
|
571 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
572 | var len0 = WASM_VECTOR_LEN;
|
573 | wasm.endtag_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
574 | return this;
|
575 | }
|
576 | |
577 |
|
578 | remove() {
|
579 | wasm.endtag_remove(this.ptr);
|
580 | return this;
|
581 | }
|
582 | }
|
583 |
|
584 |
|
585 | export class HTMLRewriter {
|
586 | static __wrap(ptr) {
|
587 | const obj = Object.create(HTMLRewriter.prototype);
|
588 | obj.ptr = ptr;
|
589 | return obj;
|
590 | }
|
591 | __destroy_into_raw() {
|
592 | const ptr = this.ptr;
|
593 | this.ptr = 0;
|
594 | return ptr;
|
595 | }
|
596 | free() {
|
597 | const ptr = this.__destroy_into_raw();
|
598 | wasm.__wbg_htmlrewriter_free(ptr);
|
599 | }
|
600 | |
601 |
|
602 |
|
603 |
|
604 | constructor(output_sink, options) {
|
605 | try {
|
606 | var ret = wasm.htmlrewriter_new(addBorrowedObject(output_sink), isLikeNone(options) ? 0 : addHeapObject(options));
|
607 | return HTMLRewriter.__wrap(ret);
|
608 | }
|
609 | finally {
|
610 | heap[stack_pointer++] = undefined;
|
611 | }
|
612 | }
|
613 | |
614 |
|
615 |
|
616 |
|
617 | on(selector, handlers) {
|
618 | var ptr0 = passStringToWasm0(selector, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
619 | var len0 = WASM_VECTOR_LEN;
|
620 | wasm.htmlrewriter_on(this.ptr, ptr0, len0, addHeapObject(handlers));
|
621 | return this;
|
622 | }
|
623 | |
624 |
|
625 |
|
626 | onDocument(handlers) {
|
627 | wasm.htmlrewriter_onDocument(this.ptr, addHeapObject(handlers));
|
628 | return this;
|
629 | }
|
630 | |
631 |
|
632 |
|
633 | async write(chunk) {
|
634 | var ptr0 = passArray8ToWasm0(chunk, wasm.__wbindgen_malloc);
|
635 | var len0 = WASM_VECTOR_LEN;
|
636 | await wrap(this, wasm.htmlrewriter_write, this.ptr, ptr0, len0);
|
637 | }
|
638 | |
639 |
|
640 | async end() {
|
641 | await wrap(this, wasm.htmlrewriter_end, this.ptr);
|
642 | }
|
643 | |
644 |
|
645 |
|
646 | get asyncifyStackPtr() {
|
647 | var ret = wasm.htmlrewriter_asyncify_stack_ptr(this.ptr);
|
648 | return ret;
|
649 | }
|
650 | }
|
651 |
|
652 |
|
653 | export class TextChunk {
|
654 | static __wrap(ptr) {
|
655 | const obj = Object.create(TextChunk.prototype);
|
656 | obj.ptr = ptr;
|
657 | return obj;
|
658 | }
|
659 | __destroy_into_raw() {
|
660 | const ptr = this.ptr;
|
661 | this.ptr = 0;
|
662 | return ptr;
|
663 | }
|
664 | free() {
|
665 | const ptr = this.__destroy_into_raw();
|
666 | wasm.__wbg_textchunk_free(ptr);
|
667 | }
|
668 | |
669 |
|
670 |
|
671 |
|
672 | before(content, content_type) {
|
673 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
674 | var len0 = WASM_VECTOR_LEN;
|
675 | wasm.textchunk_before(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
676 | return this;
|
677 | }
|
678 | |
679 |
|
680 |
|
681 |
|
682 | after(content, content_type) {
|
683 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
684 | var len0 = WASM_VECTOR_LEN;
|
685 | wasm.textchunk_after(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
686 | return this;
|
687 | }
|
688 | |
689 |
|
690 |
|
691 |
|
692 | replace(content, content_type) {
|
693 | var ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
694 | var len0 = WASM_VECTOR_LEN;
|
695 | wasm.textchunk_replace(this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type));
|
696 | return this;
|
697 | }
|
698 | |
699 |
|
700 | remove() {
|
701 | wasm.textchunk_remove(this.ptr);
|
702 | return this;
|
703 | }
|
704 | |
705 |
|
706 |
|
707 | get removed() {
|
708 | var ret = wasm.textchunk_removed(this.ptr);
|
709 | return ret !== 0;
|
710 | }
|
711 | |
712 |
|
713 |
|
714 | get text() {
|
715 | try {
|
716 | const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
717 | wasm.textchunk_text(retptr, this.ptr);
|
718 | var r0 = getInt32Memory0()[retptr / 4 + 0];
|
719 | var r1 = getInt32Memory0()[retptr / 4 + 1];
|
720 | return getStringFromWasm0(r0, r1);
|
721 | }
|
722 | finally {
|
723 | wasm.__wbindgen_add_to_stack_pointer(16);
|
724 | wasm.__wbindgen_free(r0, r1);
|
725 | }
|
726 | }
|
727 | |
728 |
|
729 |
|
730 | get lastInTextNode() {
|
731 | var ret = wasm.textchunk_last_in_text_node(this.ptr);
|
732 | return ret !== 0;
|
733 | }
|
734 | }
|
735 | async function load(module, imports) {
|
736 | if (typeof Response === 'function' && module instanceof Response) {
|
737 | if (typeof WebAssembly.instantiateStreaming === 'function') {
|
738 | try {
|
739 | return await WebAssembly.instantiateStreaming(module, imports);
|
740 | }
|
741 | catch (e) {
|
742 | if (module.headers.get('Content-Type') != 'application/wasm') {
|
743 | 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);
|
744 | }
|
745 | else {
|
746 | throw e;
|
747 | }
|
748 | }
|
749 | }
|
750 | const bytes = await module.arrayBuffer();
|
751 | return await WebAssembly.instantiate(bytes, imports);
|
752 | }
|
753 | else {
|
754 | const instance = await WebAssembly.instantiate(module, imports);
|
755 | if (instance instanceof WebAssembly.Instance) {
|
756 | return { instance, module };
|
757 | }
|
758 | else {
|
759 | return instance;
|
760 | }
|
761 | }
|
762 | }
|
763 | async function init(input) {
|
764 | if (typeof input === 'undefined') {
|
765 | throw new Error('Initializing html_rewriter needs input');
|
766 | }
|
767 | const imports = {};
|
768 | imports.wbg = {};
|
769 | imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
|
770 | takeObject(arg0);
|
771 | };
|
772 | imports.wbg.__wbg_html_cd9a0f328493678b = function (arg0) {
|
773 | var ret = getObject(arg0).html;
|
774 | return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
775 | };
|
776 | imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
|
777 | var ret = getStringFromWasm0(arg0, arg1);
|
778 | return addHeapObject(ret);
|
779 | };
|
780 | imports.wbg.__wbg_documentend_new = function (arg0) {
|
781 | var ret = DocumentEnd.__wrap(arg0);
|
782 | return addHeapObject(ret);
|
783 | };
|
784 | imports.wbg.__wbg_awaitPromise_39a1101fd8518869 = function (arg0, arg1) {
|
785 | awaitPromise(arg0, getObject(arg1));
|
786 | };
|
787 | imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
|
788 | var ret = getObject(arg0);
|
789 | return addHeapObject(ret);
|
790 | };
|
791 | imports.wbg.__wbg_element_c38470ed972aea27 = function (arg0) {
|
792 | var ret = getObject(arg0).element;
|
793 | return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
794 | };
|
795 | imports.wbg.__wbg_comments_ba86bc03331d9378 = function (arg0) {
|
796 | var ret = getObject(arg0).comments;
|
797 | return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
798 | };
|
799 | imports.wbg.__wbg_text_7800bf26cb443911 = function (arg0) {
|
800 | var ret = getObject(arg0).text;
|
801 | return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
802 | };
|
803 | imports.wbg.__wbg_doctype_ac58c0964a59b61b = function (arg0) {
|
804 | var ret = getObject(arg0).doctype;
|
805 | return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
806 | };
|
807 | imports.wbg.__wbg_comments_94d876f6c0502e82 = function (arg0) {
|
808 | var ret = getObject(arg0).comments;
|
809 | return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
810 | };
|
811 | imports.wbg.__wbg_text_4606a16c30e4ae91 = function (arg0) {
|
812 | var ret = getObject(arg0).text;
|
813 | return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
814 | };
|
815 | imports.wbg.__wbg_end_34efb9402eac8a4e = function (arg0) {
|
816 | var ret = getObject(arg0).end;
|
817 | return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
818 | };
|
819 | imports.wbg.__wbg_element_new = function (arg0) {
|
820 | var ret = Element.__wrap(arg0);
|
821 | return addHeapObject(ret);
|
822 | };
|
823 | imports.wbg.__wbg_comment_new = function (arg0) {
|
824 | var ret = Comment.__wrap(arg0);
|
825 | return addHeapObject(ret);
|
826 | };
|
827 | imports.wbg.__wbg_textchunk_new = function (arg0) {
|
828 | var ret = TextChunk.__wrap(arg0);
|
829 | return addHeapObject(ret);
|
830 | };
|
831 | imports.wbg.__wbg_doctype_new = function (arg0) {
|
832 | var ret = Doctype.__wrap(arg0);
|
833 | return addHeapObject(ret);
|
834 | };
|
835 | imports.wbg.__wbg_endtag_new = function (arg0) {
|
836 | var ret = EndTag.__wrap(arg0);
|
837 | return addHeapObject(ret);
|
838 | };
|
839 | imports.wbg.__wbg_enableEsiTags_de6b91cc61a25874 = function (arg0) {
|
840 | var ret = getObject(arg0).enableEsiTags;
|
841 | return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
842 | };
|
843 | imports.wbg.__wbg_String_60c4ba333b5ca1c6 = function (arg0, arg1) {
|
844 | var ret = String(getObject(arg1));
|
845 | var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
846 | var len0 = WASM_VECTOR_LEN;
|
847 | getInt32Memory0()[arg0 / 4 + 1] = len0;
|
848 | getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
849 | };
|
850 | imports.wbg.__wbg_new_4fee7e2900033464 = function () {
|
851 | var ret = new Array();
|
852 | return addHeapObject(ret);
|
853 | };
|
854 | imports.wbg.__wbg_push_ba9b5e3c25cff8f9 = function (arg0, arg1) {
|
855 | var ret = getObject(arg0).push(getObject(arg1));
|
856 | return ret;
|
857 | };
|
858 | imports.wbg.__wbg_call_6c4ea719458624eb = function () {
|
859 | return handleError(function (arg0, arg1, arg2) {
|
860 | var ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
861 | return addHeapObject(ret);
|
862 | }, arguments);
|
863 | };
|
864 | imports.wbg.__wbg_new_917809a3e20a4b00 = function (arg0, arg1) {
|
865 | var ret = new TypeError(getStringFromWasm0(arg0, arg1));
|
866 | return addHeapObject(ret);
|
867 | };
|
868 | imports.wbg.__wbg_instanceof_Promise_c6535fc791fcc4d2 = function (arg0) {
|
869 | var obj = getObject(arg0);
|
870 | var ret = (obj instanceof Promise) || (Object.prototype.toString.call(obj) === '[object Promise]');
|
871 | return ret;
|
872 | };
|
873 | imports.wbg.__wbg_buffer_89a8560ab6a3d9c6 = function (arg0) {
|
874 | var ret = getObject(arg0).buffer;
|
875 | return addHeapObject(ret);
|
876 | };
|
877 | imports.wbg.__wbg_newwithbyteoffsetandlength_e45d8b33c02dc3b5 = function (arg0, arg1, arg2) {
|
878 | var ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
879 | return addHeapObject(ret);
|
880 | };
|
881 | imports.wbg.__wbg_new_bd2e1d010adb8a1a = function (arg0) {
|
882 | var ret = new Uint8Array(getObject(arg0));
|
883 | return addHeapObject(ret);
|
884 | };
|
885 | imports.wbg.__wbindgen_debug_string = function (arg0, arg1) {
|
886 | var ret = debugString(getObject(arg1));
|
887 | var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
888 | var len0 = WASM_VECTOR_LEN;
|
889 | getInt32Memory0()[arg0 / 4 + 1] = len0;
|
890 | getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
891 | };
|
892 | imports.wbg.__wbindgen_throw = function (arg0, arg1) {
|
893 | throw new Error(getStringFromWasm0(arg0, arg1));
|
894 | };
|
895 | imports.wbg.__wbindgen_rethrow = function (arg0) {
|
896 | throw takeObject(arg0);
|
897 | };
|
898 | imports.wbg.__wbindgen_memory = function () {
|
899 | var ret = wasm.memory;
|
900 | return addHeapObject(ret);
|
901 | };
|
902 | if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
903 | input = fetch(input);
|
904 | }
|
905 | const { instance, module } = await load(await input, imports);
|
906 | wasm = instance.exports;
|
907 | setWasmExports(wasm);
|
908 | init.__wbindgen_wasm_module = module;
|
909 | return wasm;
|
910 | }
|
911 | export default init;
|
912 |
|
\ | No newline at end of file |