Skip to main content
Module

x/lol_html/mod.js

Low output latency streaming HTML parser/rewriter with CSS selector-based API in Deno, via Webassembly.
Go to Latest
File
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440
let wasm;
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx];}
let heap_next = heap.length;
function dropObject(idx) { if (idx < 36) return; heap[idx] = heap_next; heap_next = idx;}
function takeObject(idx) { const ret = getObject(idx); dropObject(idx); return ret;}
const cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true,});
cachedTextDecoder.decode();
let cachedUint8Memory0;function getUint8Memory0() { if (cachedUint8Memory0.byteLength === 0) { cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8Memory0;}
function getStringFromWasm0(ptr, len) { return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));}
function addHeapObject(obj) { if (heap_next === heap.length) heap.push(heap.length + 1); const idx = heap_next; heap_next = heap[idx];
heap[idx] = obj; return idx;}
function debugString(val) { // primitive types const type = typeof val; if (type == "number" || type == "boolean" || val == null) { return `${val}`; } if (type == "string") { return `"${val}"`; } if (type == "symbol") { const description = val.description; if (description == null) { return "Symbol"; } else { return `Symbol(${description})`; } } if (type == "function") { const name = val.name; if (typeof name == "string" && name.length > 0) { return `Function(${name})`; } else { return "Function"; } } // objects if (Array.isArray(val)) { const length = val.length; let debug = "["; if (length > 0) { debug += debugString(val[0]); } for (let i = 1; i < length; i++) { debug += ", " + debugString(val[i]); } debug += "]"; return debug; } // Test for built-in const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); let className; if (builtInMatches.length > 1) { className = builtInMatches[1]; } else { // Failed to match the standard '[object ClassName]' return toString.call(val); } if (className == "Object") { // we're a user defined class or Object // JSON.stringify avoids problems with cycles, and is generally much // easier than looping through ownProperties of `val`. try { return "Object(" + JSON.stringify(val) + ")"; } catch (_) { return "Object"; } } // errors if (val instanceof Error) { return `${val.name}: ${val.message}\n${val.stack}`; } // TODO we could test for more things here, like `Set`s and `Map`s. return className;}
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = new TextEncoder("utf-8");
const encodeString = (typeof cachedTextEncoder.encodeInto === "function" ? function (arg, view) { return cachedTextEncoder.encodeInto(arg, view); } : function (arg, view) { const buf = cachedTextEncoder.encode(arg); view.set(buf); return { read: arg.length, written: buf.length, }; });
function passStringToWasm0(arg, malloc, realloc) { if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length); getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); WASM_VECTOR_LEN = buf.length; return ptr; }
let len = arg.length; let ptr = malloc(len);
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) { const code = arg.charCodeAt(offset); if (code > 0x7F) break; mem[ptr + offset] = code; }
if (offset !== len) { if (offset !== 0) { arg = arg.slice(offset); } ptr = realloc(ptr, len, len = offset + arg.length * 3); const view = getUint8Memory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view);
offset += ret.written; }
WASM_VECTOR_LEN = offset; return ptr;}
let cachedInt32Memory0;function getInt32Memory0() { if (cachedInt32Memory0.byteLength === 0) { cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); } return cachedInt32Memory0;}
function isLikeNone(x) { return x === undefined || x === null;}
let stack_pointer = 32;
function addBorrowedObject(obj) { if (stack_pointer == 1) throw new Error("out of js stack"); heap[--stack_pointer] = obj; return stack_pointer;}
function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1); getUint8Memory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr;}
function handleError(f, args) { try { return f.apply(this, args); } catch (e) { wasm.__wbindgen_exn_store(addHeapObject(e)); }}/** */export class Comment { static __wrap(ptr) { const obj = Object.create(Comment.prototype); obj.ptr = ptr;
return obj; }
__destroy_into_raw() { const ptr = this.ptr; this.ptr = 0;
return ptr; }
free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_comment_free(ptr); } /** * @param {string} content * @param {any | undefined} content_type */ before(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.comment_before( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ after(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.comment_after( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ replace(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.comment_replace( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ remove() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.comment_remove(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get removed() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.comment_removed(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return r0 !== 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get text() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.comment_text(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; var r3 = getInt32Memory0()[retptr / 4 + 3]; var ptr0 = r0; var len0 = r1; if (r3) { ptr0 = 0; len0 = 0; throw takeObject(r2); } return getStringFromWasm0(ptr0, len0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(ptr0, len0); } }}/** */export class Doctype { static __wrap(ptr) { const obj = Object.create(Doctype.prototype); obj.ptr = ptr;
return obj; }
__destroy_into_raw() { const ptr = this.ptr; this.ptr = 0;
return ptr; }
free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_doctype_free(ptr); } /** */ get name() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.doctype_name(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; var r3 = getInt32Memory0()[retptr / 4 + 3]; if (r3) { throw takeObject(r2); } let v0; if (r0 !== 0) { v0 = getStringFromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 1); } return v0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get publicId() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.doctype_public_id(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; var r3 = getInt32Memory0()[retptr / 4 + 3]; if (r3) { throw takeObject(r2); } let v0; if (r0 !== 0) { v0 = getStringFromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 1); } return v0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get systemId() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.doctype_system_id(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; var r3 = getInt32Memory0()[retptr / 4 + 3]; if (r3) { throw takeObject(r2); } let v0; if (r0 !== 0) { v0 = getStringFromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 1); } return v0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } }}/** */export class DocumentEnd { static __wrap(ptr) { const obj = Object.create(DocumentEnd.prototype); obj.ptr = ptr;
return obj; }
__destroy_into_raw() { const ptr = this.ptr; this.ptr = 0;
return ptr; }
free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_documentend_free(ptr); } /** * @param {string} content * @param {any | undefined} content_type */ append(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.documentend_append( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } }}/** */export class Element { static __wrap(ptr) { const obj = Object.create(Element.prototype); obj.ptr = ptr;
return obj; }
__destroy_into_raw() { const ptr = this.ptr; this.ptr = 0;
return ptr; }
free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_element_free(ptr); } /** * @param {string} content * @param {any | undefined} content_type */ before(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_before( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ after(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_after( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ replace(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_replace( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ remove() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.element_remove(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get removed() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.element_removed(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return r0 !== 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get tagName() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.element_tag_name(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; var r3 = getInt32Memory0()[retptr / 4 + 3]; var ptr0 = r0; var len0 = r1; if (r3) { ptr0 = 0; len0 = 0; throw takeObject(r2); } return getStringFromWasm0(ptr0, len0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(ptr0, len0); } } /** */ set tagName(name) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_set_tag_name(retptr, this.ptr, ptr0, len0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get namespaceURI() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.element_namespace_uri(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get attributes() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.element_attributes(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return takeObject(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} name * @returns {string | undefined} */ getAttribute(name) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_getAttribute(retptr, this.ptr, ptr0, len0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; var r3 = getInt32Memory0()[retptr / 4 + 3]; if (r3) { throw takeObject(r2); } let v1; if (r0 !== 0) { v1 = getStringFromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 1); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} name * @returns {boolean} */ hasAttribute(name) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_hasAttribute(retptr, this.ptr, ptr0, len0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return r0 !== 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} name * @param {string} value */ setAttribute(name, value) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; const ptr1 = passStringToWasm0( value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len1 = WASM_VECTOR_LEN; wasm.element_setAttribute(retptr, this.ptr, ptr0, len0, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} name */ removeAttribute(name) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_removeAttribute(retptr, this.ptr, ptr0, len0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ prepend(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_prepend( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ append(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_append( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ setInnerContent(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.element_setInnerContent( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ removeAndKeepContent() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.element_removeAndKeepContent(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } }}/** */export class HTMLRewriter { static __wrap(ptr) { const obj = Object.create(HTMLRewriter.prototype); obj.ptr = ptr;
return obj; }
__destroy_into_raw() { const ptr = this.ptr; this.ptr = 0;
return ptr; }
free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_htmlrewriter_free(ptr); } /** * @param {string} encoding * @param {Function} output_sink */ constructor(encoding, output_sink) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( encoding, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.htmlrewriter_new(retptr, ptr0, len0, addBorrowedObject(output_sink)); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return HTMLRewriter.__wrap(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); heap[stack_pointer++] = undefined; } } /** * @param {string} selector * @param {any} handlers */ on(selector, handlers) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( selector, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.htmlrewriter_on( retptr, this.ptr, ptr0, len0, addHeapObject(handlers), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {any} handlers */ onDocument(handlers) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.htmlrewriter_onDocument(retptr, this.ptr, addHeapObject(handlers)); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {Uint8Array} chunk */ write(chunk) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(chunk, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; wasm.htmlrewriter_write(retptr, this.ptr, ptr0, len0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ end() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.htmlrewriter_end(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } }}/** */export class TextChunk { static __wrap(ptr) { const obj = Object.create(TextChunk.prototype); obj.ptr = ptr;
return obj; }
__destroy_into_raw() { const ptr = this.ptr; this.ptr = 0;
return ptr; }
free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_textchunk_free(ptr); } /** * @param {string} content * @param {any | undefined} content_type */ before(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.textchunk_before( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ after(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.textchunk_after( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {string} content * @param {any | undefined} content_type */ replace(content, content_type) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; wasm.textchunk_replace( retptr, this.ptr, ptr0, len0, isLikeNone(content_type) ? 0 : addHeapObject(content_type), ); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ remove() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.textchunk_remove(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get removed() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.textchunk_removed(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return r0 !== 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** */ get text() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.textchunk_text(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; var r3 = getInt32Memory0()[retptr / 4 + 3]; var ptr0 = r0; var len0 = r1; if (r3) { ptr0 = 0; len0 = 0; throw takeObject(r2); } return getStringFromWasm0(ptr0, len0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_free(ptr0, len0); } } /** */ get lastInTextNode() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.textchunk_last_in_text_node(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; if (r2) { throw takeObject(r1); } return r0 !== 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } }}
async function load(module, imports) { if (typeof Response === "function" && module instanceof Response) { if (typeof WebAssembly.instantiateStreaming === "function") { try { return await WebAssembly.instantiateStreaming(module, imports); } catch (e) { if (module.headers.get("Content-Type") != "application/wasm") { 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, ); } else { throw e; } } }
const bytes = await module.arrayBuffer(); return await WebAssembly.instantiate(bytes, imports); } else { const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) { return { instance, module }; } else { return instance; } }}
function getImports() { const imports = {}; imports.wbg = {}; imports.wbg.__wbindgen_object_drop_ref = function (arg0) { takeObject(arg0); }; imports.wbg.__wbindgen_string_new = function (arg0, arg1) { const ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; imports.wbg.__wbg_html_d5091c41bef0070f = function (arg0) { const ret = getObject(arg0).html; return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; }; imports.wbg.__wbg_element_27345e6d35fe0b9e = function (arg0) { const ret = getObject(arg0).element; return isLikeNone(ret) ? 0 : addHeapObject(ret); }; imports.wbg.__wbg_comments_229bea835aa1451a = function (arg0) { const ret = getObject(arg0).comments; return isLikeNone(ret) ? 0 : addHeapObject(ret); }; imports.wbg.__wbg_text_a95fd5fc39ed43db = function (arg0) { const ret = getObject(arg0).text; return isLikeNone(ret) ? 0 : addHeapObject(ret); }; imports.wbg.__wbg_doctype_13f610df13dfcd09 = function (arg0) { const ret = getObject(arg0).doctype; return isLikeNone(ret) ? 0 : addHeapObject(ret); }; imports.wbg.__wbg_comments_81a5d74dc45bd087 = function (arg0) { const ret = getObject(arg0).comments; return isLikeNone(ret) ? 0 : addHeapObject(ret); }; imports.wbg.__wbg_text_f90f7b7c44216095 = function (arg0) { const ret = getObject(arg0).text; return isLikeNone(ret) ? 0 : addHeapObject(ret); }; imports.wbg.__wbg_end_b1f55fb9f80582ed = function (arg0) { const ret = getObject(arg0).end; return isLikeNone(ret) ? 0 : addHeapObject(ret); }; imports.wbg.__wbg_comment_new = function (arg0) { const ret = Comment.__wrap(arg0); return addHeapObject(ret); }; imports.wbg.__wbg_doctype_new = function (arg0) { const ret = Doctype.__wrap(arg0); return addHeapObject(ret); }; imports.wbg.__wbg_documentend_new = function (arg0) { const ret = DocumentEnd.__wrap(arg0); return addHeapObject(ret); }; imports.wbg.__wbg_element_new = function (arg0) { const ret = Element.__wrap(arg0); return addHeapObject(ret); }; imports.wbg.__wbindgen_object_clone_ref = function (arg0) { const ret = getObject(arg0); return addHeapObject(ret); }; imports.wbg.__wbg_textchunk_new = function (arg0) { const ret = TextChunk.__wrap(arg0); return addHeapObject(ret); }; imports.wbg.__wbg_String_7462bcc0fcdbaf7d = function (arg0, arg1) { const ret = String(getObject(arg1)); const ptr0 = passStringToWasm0( ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; getInt32Memory0()[arg0 / 4 + 1] = len0; getInt32Memory0()[arg0 / 4 + 0] = ptr0; }; imports.wbg.__wbg_set_e93b31d47b90bff6 = function (arg0, arg1, arg2) { getObject(arg0)[takeObject(arg1)] = takeObject(arg2); }; imports.wbg.__wbg_new_2ab697f1555e0dbc = function () { const ret = new Array(); return addHeapObject(ret); }; imports.wbg.__wbg_new_306ce8d57919e6ae = function () { const ret = new Object(); return addHeapObject(ret); }; imports.wbg.__wbg_set_c1d04f8b45a036e7 = function (arg0, arg1, arg2) { getObject(arg0)[arg1 >>> 0] = takeObject(arg2); }; imports.wbg.__wbg_new_651776e932b7e9c7 = function (arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; imports.wbg.__wbg_call_9855a4612eb496cb = function () { return handleError(function (arg0, arg1, arg2) { const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); return addHeapObject(ret); }, arguments); }; imports.wbg.__wbg_buffer_de1150f91b23aa89 = function (arg0) { const ret = getObject(arg0).buffer; return addHeapObject(ret); }; imports.wbg.__wbg_newwithbyteoffsetandlength_9ca61320599a2c84 = function ( arg0, arg1, arg2, ) { const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; imports.wbg.__wbg_new_97cf52648830a70d = function (arg0) { const ret = new Uint8Array(getObject(arg0)); return addHeapObject(ret); }; imports.wbg.__wbindgen_debug_string = function (arg0, arg1) { const ret = debugString(getObject(arg1)); const ptr0 = passStringToWasm0( ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; getInt32Memory0()[arg0 / 4 + 1] = len0; getInt32Memory0()[arg0 / 4 + 0] = ptr0; }; imports.wbg.__wbindgen_throw = function (arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; imports.wbg.__wbindgen_memory = function () { const ret = wasm.memory; return addHeapObject(ret); };
return imports;}
function initMemory(imports, maybe_memory) {}
function finalizeInit(instance, module) { wasm = instance.exports; init.__wbindgen_wasm_module = module; cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
return wasm;}
function initSync(bytes) { const imports = getImports();
initMemory(imports);
const module = new WebAssembly.Module(bytes); const instance = new WebAssembly.Instance(module, imports);
return finalizeInit(instance, module);}
async function init(input) { if (typeof input === "undefined") { input = new URL("deno_lol_html_bg.wasm", import.meta.url); } const imports = getImports();
if ( typeof input === "string" || (typeof Request === "function" && input instanceof Request) || (typeof URL === "function" && input instanceof URL) ) { input = fetch(input); }
initMemory(imports);
const { instance, module } = await load(await input, imports);
return finalizeInit(instance, module);}
export { initSync };export default init;