diff --git a/index.html b/index.html index 7dbfaf4..2b98c31 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@

Home

@@ -100,6 +100,6 @@

Modal

- + diff --git a/scripts/main.js b/scripts/main.js index 54e373e..886726d 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -419,7 +419,8 @@ function libCatalog() { // Get collections slide("collection", "lib", c, document.getElementById("books").innerHTML == "" || (curCollection && c.id != curCollection.id)); // Load books the first time, then if different collection }); })(); - item.append(img, label); + item.appendChild(img); + item.appendChild(label); el.appendChild(item); } libraryCache = library; @@ -432,7 +433,8 @@ function libCatalog() { // Get collections var action = document.createElement("button"); action.textContent = "Try Again"; action.id = "action"; // For adding click listener - err.append(msg, action); + err.appendChild(msg); + err.appendChild(action); } else { err.appendChild(msg); } @@ -531,7 +533,18 @@ function bookCatalog() { // Get parts for (var part of book.parts) { var item = document.createElement("li"); var label = document.createElement("p"); - label.textContent = part.name; + var tc = document.createTextNode(part.name); + if (part.before) { + var before = document.createElement("span"); + before.textContent = part.before; + label.appendChild(before); + } + label.appendChild(tc); + if (part.after) { + var after = document.createElement("span"); + after.textContent = part.after; + label.appendChild(after); + } (function () { var p = part; if (p.chapters) { @@ -581,7 +594,18 @@ function partCatalog() { // Get chapters for (var chapter of chapters) { var item = document.createElement("li"); var label = document.createElement("p"); - label.textContent = chapter.name; + var tc = document.createTextNode(chapter.name); + if (chapter.before) { + var before = document.createElement("span"); + before.textContent = chapter.before; + label.appendChild(before); + } + label.appendChild(tc); + if (chapter.after) { + var after = document.createElement("span"); + after.textContent = chapter.after; + label.appendChild(after); + } (function () { var c = chapter; item.addEventListener("click", function () { @@ -731,9 +755,10 @@ function parseNote(el, note) { function note(link) { var id = link.id.slice(1); var t = ""; - for (var child of link.childNodes) { // Search for title label - if (child.nodeType == Node.TEXT_NODE) { - t = child.nodeValue; + var cn = link.childNodes; + for (var i = 0; i < cn.length; i++) { // Search for title label + if (cn[i].nodeType == Node.TEXT_NODE) { + t = cn[i].nodeValue; break; } } diff --git a/scripts/main.min.js b/scripts/main.min.js new file mode 100644 index 0000000..ec53600 --- /dev/null +++ b/scripts/main.min.js @@ -0,0 +1,6 @@ +var lang="en",translation=!1,libraryCache,collectionCache,bookCache,partCache,noteCache,curCollection,curBook,curPart,curChapter,contentTouch=readerTouch=modalTouch={};function mode(n){n&&document.body.setAttribute("data-theme",n)}function modeHandler(n){var t=localStorage.getItem("theme")||(n.matches?"dark":"light");mode(t)}var modeMQ=window.matchMedia("(prefers-color-scheme: dark)");modeMQ.addEventListener?modeMQ.addEventListener("change",modeHandler):modeMQ.addListener(modeHandler),window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&mode("dark"),mode(localStorage.getItem("theme"));var short=!1;function shortHandler(n){short=!!n.matches}var shortMQ=window.matchMedia("(max-width: 400px)");shortMQ.addEventListener?shortMQ.addEventListener("change",shortHandler):shortMQ.addListener(shortHandler),window.matchMedia&&window.matchMedia("(max-width: 400px)").matches&&(short=!0),libCatalog();function readBinaryFile(n,t){var e=new XMLHttpRequest;e.responseType="arraybuffer",e.open("GET",n,!0),e.addEventListener("load",function(){if(e.status>=200&&e.status<300)try{t(!0,msgpackr.unpack(e.response))}catch(a){t(!1,!0)}else t(!1)}),e.send(null)}function readFile(n,t){var e=new XMLHttpRequest;e.open("GET",n,!0),e.addEventListener("load",function(){e.status>=200&&e.status<300?t(!0,e.responseText):t(!1)}),e.send(null)}function readLines(n,t,e){var a=new XMLHttpRequest;a.open("GET",n,!0),a.addEventListener("load",function(){if(a.status>=200&&a.status<300){var r=a.responseText.replace(/\n\n/g,` +`).replace(/~([^\^]+)\/\^/g,"").replace(/\^/g,"").split(` +`);e(!0,t.map(function(i){return r[i-1]}))}else e(!1)}),a.send(null)}function ordinal(n){for(var t=97,e=122-t+1,a="";n>=0;)a=String.fromCharCode(n%e+t)+a,n=Math.floor(n/e)-1;return a}function integer(n){for(var t=97,e=122-t+1,a=0,r=0;r]+)>/g.exec(r);)r=r.replace(match[0],"`|"+match[1]+"`");for(var l=r;match=/(?:<([^>]+)>)|(?:\^([^\^]+)\/\^)/g.exec(r);){var o=ordinal(c),d=""+o+"";if(match[2]){for(var u=0,m=match[2];submatch=/<([^>]+)>/g.exec(match[2]);)match[2].split("~")[0].startsWith("<")&&(m=m.replace(submatch[0],submatch[1]),match[2]=match[2].replace(submatch[0],"")),++u,o=ordinal(c+u),d=""+o+"",submatch[1].startsWith("|")?(--u,m=m.replace(submatch[0],""+submatch[1].slice(1)+"")):m=m.replace(submatch[0],''+d+submatch[1]+""),match[2]=match[2].replace(submatch[0],"");o=ordinal(c),d=""+o+"";var s=m.split("~")[0],y=s.split(` +`).length;if(translation){s=m.split("~")[1];var L=s.split(` +`).length}for(;emMatch=/`([^\|]+?)`/g.exec(s);)s=s.replace(emMatch[0],''+emMatch[1]+"");var E=!0,f=0;for(var h of s.split(` +`)){++f,E?E=!1:(f<=y?s=s.replace(h,'
  • '+h+"
  • "):s=s.replace(h,"
  • "+h+"
  • "),c=0);for(var C=!0,k=0,x=1,p=h,v=h;idMatch=/( id="n)[0-9]*?([a-z]*?)(" onclick="note\(this\)">)[a-z]*?(<\/sup>)/g.exec(v);){++x,C&&(C=!1,k=integer(idMatch[2]));var g=x-k;g<0&&(g=0);var b=ordinal(g);p=p.replace(idMatch[0],idMatch[1]+(a+f-1)+b+idMatch[3]+b+idMatch[4]),v=v.replace(idMatch[0],"")}s=s.replace(h,p)}if(o=ordinal(c),d=""+o+"",translation)l=l.replace(match[0],''+d+s+"");else{s=s.split(/ (?![^<]*>)/g);var B=''+d+s[0]+"";s[0]="",l=l.replace(match[0],B+s.join(" "))}c=c+u,i.id="p"+a,a=a+f-1,translation&&(a=a-(L-y))}else l=l.replace(match[0],''+d+match[1]+"");r=r.replace(match[0],""),++c}for(;match=/`\|([^`]+)`/g.exec(l);)l=l.replace(match[0],""+match[1]+"");i.innerHTML=l,n.appendChild(i),a++}else n.appendChild(document.createElement("br"))}else n.textContent=e}var back=document.getElementById("back"),backLabel=document.getElementById("back-label"),title=document.getElementById("title"),pages=document.getElementById("content").children,tabs=document.getElementById("nav").children,alertInfo=document.getElementById("alert-info"),alertBtns=document.getElementById("alert-btns");function notify(n,t,e,a){switch(document.getElementById("alert-title").textContent=t,e){case"":alertInfo.style.display="none",alertInfo.textContent="";break;default:alertInfo.textContent=e,alertInfo.style.display=""}alertBtns.innerHTML="";for(var r in a){var i=document.createElement("button");i.textContent=r;var c=a[r];c||(c=function(){document.body.classList.remove("alert")}),i.addEventListener("click",c),alertBtns.appendChild(i)}document.body.classList.add("alert")}function swap(n,t,e){n.classList.add("swapping"),setTimeout(function(){n.textContent=t,n.classList.remove("swapping")},e*500)}function setBack(n,t,e){e=e||"",e=="button"&&(back.style.opacity="0"),back.onclick=n,swap(backLabel,t,.35),e==""&&(back.style.opacity="")}function closeInspector(n){n&&!n.target.closest("#inspector, #back")?(document.getElementById("content").removeEventListener("click",closeInspector),back.click()):n||document.getElementById("content").removeEventListener("click",closeInspector)}function slide(n,t,e,a){if(a=a!=null?a:!0,t)for(var r=0;r0){for(var e=document.getElementById("books");e.firstChild;)e.removeChild(e.lastChild);for(var a of n){var r=document.createElement("li"),i=document.createElement("img"),c=document.createElement("p");i.loading="lazy",i.src="library/"+lang+"/"+a+".spr/cover.jpg",i.srcset="library/"+lang+"/"+a+".spr/cover@2x.jpg 2x, library/"+lang+"/"+a+".spr/cover@3x.jpg 3x",i.addEventListener("error",function(){this.removeEventListener("error",arguments.callee),this.removeAttribute("srcset"),this.addEventListener("error",function(){this.removeEventListener("error",arguments.callee),this.src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22/%3E"})}),r.appendChild(i),function(){var l=a,o=r,d=c;readBinaryFile("library/"+lang+"/"+a+".spr/book.stc",function(u,m){u?(d.textContent=m.name,o.addEventListener("click",function(){slide("book",null,m,document.getElementById("parts").innerHTML==""||l!=curBook.id)}),o.appendChild(d)):(e.removeChild(o),e.children.length<=0&&(curCollection=null,back.click(),notify("error","No Books Found","No books were found in this collection.",{OK:null})))})}(),e.appendChild(r)}collectionCache=n}else curCollection=null,back.click(),notify("error","No Books Found","No books were found in this collection.",{OK:null})}function bookCatalog(){for(var n=document.getElementById("parts");n.firstChild;)n.removeChild(n.lastChild);for(var t=document.getElementById("chapters");t.firstChild;)t.removeChild(t.lastChild);for(var e=document.getElementById("article");e.firstChild;)e.removeChild(e.lastChild);noteCache=null,readBinaryFile("library/"+lang+"/"+curBook.id+".spr/book.stc",function(a,r){if(a)if(r.parts&&r.parts.length>0){for(var i of r.parts){var c=document.createElement("li"),l=document.createElement("p"),o=document.createTextNode(i.name);if(i.before){var d=document.createElement("span");d.textContent=i.before,l.appendChild(d)}if(l.appendChild(o),i.after){var u=document.createElement("span");u.textContent=i.after,l.appendChild(u)}(function(){var m=i;m.chapters?c.addEventListener("click",function(){slide("part",null,m,document.getElementById("chapters").innerHTML==""||m.id!=(curPart.id||""))}):(c.classList.add("chapter"),c.addEventListener("click",function(){slide("reader",null,m)}))})(),c.appendChild(l),n.appendChild(c)}bookCache=r.parts}else back.click(),notify("error","Contents Not Found","No content could be located in the table of contents.",{OK:null});else back.click(),notify("error","Unable to Load Contents","The table of contents could not be loaded. Please check your network connection or try again later.",{OK:null})})}function partCatalog(){var n,t=document.getElementById("chapters");for(var e of bookCache)if(e.id==curPart.id){t.classList=e.type||"list",n=e.chapters;break}if(n&&n.length>0){for(;t.firstChild;)t.removeChild(t.lastChild);for(var a=document.getElementById("article");a.firstChild;)a.removeChild(a.lastChild);noteCache=null;for(var r of n){var i=document.createElement("li"),c=document.createElement("p"),l=document.createTextNode(r.name);if(r.before){var o=document.createElement("span");o.textContent=r.before,c.appendChild(o)}if(c.appendChild(l),r.after){var d=document.createElement("span");d.textContent=r.after,c.appendChild(d)}(function(){var u=r;i.addEventListener("click",function(){slide("reader",null,u,document.getElementById("article").innerHTML==""||u.id!=(curChapter.id||""))})})(),i.appendChild(c),t.appendChild(i)}partCache=n}else back.click(),notify("error","No Chapters Found","No chapters were found in this part.",{OK:null})}function chapterCatalog(n){for(var t=document.getElementById("article");t.firstChild;)t.removeChild(t.lastChild);if(noteCache=null,n=="stp")document.getElementById("head").style.display="none",function(){readBinaryFile("library/"+lang+"/"+curBook.id+".spr/book.stp",function(a,r){if(a)for(var i of r){var c=document.createElement("p");if(c.classList.add("tp"),i.length==1&&i[0].type=="normal")c.textContent=i[0].content;else for(var l of i){switch(l.type){case"title":var o=document.createElement("h2");break;case"heading":var o=document.createElement("h3");break;case"subheading":var o=document.createElement("h4");break;case"small":var o=document.createElement("small");break;default:var o=document.createElement("span")}o.textContent=l.content,c.appendChild(o)}document.getElementById("article").appendChild(c)}})}();else if(curPart.id=="SKIP")document.getElementById("head").style.display="",document.getElementById("heading").textContent=curChapter.title||curChapter.name,document.getElementById("subheading").textContent=curChapter.subtitle||"",document.getElementById("intro").textContent=curChapter.intro||"",document.getElementById("superhead").style.display="",function(){var a=curChapter;readFile("library/"+lang+"/"+curBook.id+".spr/"+curChapter.id+".sch",function(r,i){if(r){var c=document.createElement("ol");parse(c,a.type,i),document.getElementById("article").appendChild(c)}else notify("error","Unable to Load Chapter","The chapter could not be loaded. Please check your network connection or try again later.",{OK:null})})}();else{document.getElementById("head").style.display="";for(var e of partCache)e.id==curChapter.id&&(e==partCache[0]?(document.getElementById("heading").textContent=curPart.title||"",document.getElementById("subheading").textContent=curPart.subtitle||"",document.getElementById("intro").textContent=curPart.intro||"",document.getElementById("superhead").style.display=""):document.getElementById("superhead").style.display="none",document.getElementById("chapter").textContent=e.title||e.name,document.getElementById("summary").textContent=e.summary||"",function(){var a=e;readFile("library/"+lang+"/"+curBook.id+".spr/"+curPart.id+"/"+curChapter.id+".sch",function(r,i){if(r){var c=document.createElement("ol");parse(c,a.type,i),document.getElementById("article").appendChild(c)}else notify("error","Unable to Load Chapter","The chapter could not be loaded. Please check your network connection or try again later.",{OK:null})})}())}}function parseNote(n,t){if(t.note){var e=document.createElement("li");e.textContent=t.note,n.appendChild(e)}if(t.ie){var e=document.createElement("li");e.textContent="IE "+t.ie,n.appendChild(e)}if(t.greek){var e=document.createElement("li");e.textContent="GR "+t.greek,n.appendChild(e)}if(t.jst){for(var e=document.createElement("li");match=/`(.*?)`/g.exec(t.jst);)t.jst=t.jst.replace(match[0],""+match[1]+"");e.innerHTML="JST "+t.jst,n.appendChild(e)}if(t.cross)for(var a of t.cross){var e=document.createElement("li");e.textContent=a,n.appendChild(e)}if(t.tg)for(var a of t.tg){var e=document.createElement("li");e.textContent="TG "+a,n.appendChild(e)}}function note(n){for(var t=n.id.slice(1),e="",a=n.childNodes,r=0;rMath.abs(r)?a>=10?e[1]&&e[1](t.x>=document.body.clientWidth-25):a<=10&&e[0]&&e[0](t.x<=25):e.length>2&&Math.abs(r)>Math.abs(a)&&(r>=10?e[2]&&e[2](t.y>=document.body.clientHeight-25):r<=10&&e[3]&&e[3](t.y<=25)),t.x=null,t.y=null}}document.getElementById("content").addEventListener("touchstart",function(n){touchStart(n,contentTouch)}),document.getElementById("content").addEventListener("touchend",function(n){touchEnd(n,contentTouch,[function(t){(t||document.getElementById("reader").classList.contains("hidden"))&&(closeInspector(),back.click())},null])}),document.getElementById("modal").addEventListener("touchstart",function(n){!window.matchMedia("(max-height: 600px)").matches&&(n.target.closest("#modal-header")||document.getElementById("modal-content").scrollTop<=0)&&touchStart(n,modalTouch)}),document.getElementById("modal").addEventListener("touchend",function(n){!window.matchMedia("(max-height: 600px)").matches&&(n.target.closest("#modal-header")||document.getElementById("modal-content").scrollTop<=0)&&touchEnd(n,modalTouch,[null,null,null,function(){document.body.classList.remove("modal")}])});function menu(n){var t=document.getElementById(n);t.classList.contains("open")?t.classList.remove("open"):(t.classList.add("open"),setTimeout(function(){document.addEventListener("click",function(e){!e.target.closest(n)&&e.target.tagName.toLowerCase()!="hr"&&(this.removeEventListener("click",arguments.callee),t.classList.remove("open"))})},0))}function modal(n){document.getElementById("modal-title").textContent=document.getElementById(n).dataset.title;for(var t=document.getElementById("modal-content").children,e=0;e { + return saveState(function () { clearSource(); return this ? this.unpack(source, options) : Unpackr.prototype.unpack.call(defaultOptions, source, options) }) @@ -112,11 +112,11 @@ return checkedRead(options) } unpackMultiple(source, forEach) { - let values, lastPosition = 0; + var values, lastPosition = 0; try { sequentialMode = true; - let size = source.length; - let value = this ? this.unpack(source, size) : defaultUnpackr.unpack(source, size); + var size = source.length; + var value = this ? this.unpack(source, size) : defaultUnpackr.unpack(source, size); if (forEach) { if (forEach(value, lastPosition, position$1) === false) return; while(position$1 < size) { @@ -146,9 +146,9 @@ _mergeStructures(loadedStructures, existingStructures) { loadedStructures = loadedStructures || []; if (Object.isFrozen(loadedStructures)) - loadedStructures = loadedStructures.map(structure => structure.slice(0)); - for (let i = 0, l = loadedStructures.length; i < l; i++) { - let structure = loadedStructures[i]; + loadedStructures = loadedStructures.map(function (structure) { return structure.slice(0) }); + for (var i = 0, l = loadedStructures.length; i < l; i++) { + var structure = loadedStructures[i]; if (structure) { structure.isShared = true; if (i >= 32) @@ -156,10 +156,10 @@ } } loadedStructures.sharedLength = loadedStructures.length; - for (let id in existingStructures || []) { + for (var id in existingStructures || []) { if (id >= 0) { - let structure = loadedStructures[id]; - let existing = existingStructures[id]; + var structure = loadedStructures[id]; + var existing = existingStructures[id]; if (existing) { if (structure) (loadedStructures.restoreStructures || (loadedStructures.restoreStructures = []))[id] = structure; @@ -176,11 +176,11 @@ function checkedRead(options) { try { if (!currentUnpackr.trusted && !sequentialMode) { - let sharedLength = currentStructures.sharedLength || 0; + var sharedLength = currentStructures.sharedLength || 0; if (sharedLength < currentStructures.length) currentStructures.length = sharedLength; } - let result; + var result; if (currentUnpackr.randomAccessStructure && src[position$1] < 0x40 && src[position$1] >= 0x20 && readStruct) { result = readStruct(src, position$1, srcEnd, currentUnpackr); src = null; // dispose of this so that recursive unpack calls don't save state @@ -210,9 +210,9 @@ // over read throw new Error('Unexpected end of MessagePack data') } else if (!sequentialMode) { - let jsonView; + var jsonView; try { - jsonView = JSON.stringify(result, (_, value) => typeof value === "bigint" ? `${value}n` : value).slice(0, 100); + jsonView = JSON.stringify(result, function (_, value) { return typeof value === "bigint" ? `${value}n` : value }).slice(0, 100); } catch(error) { jsonView = '(JSON view not available ' + error + ')'; } @@ -232,20 +232,20 @@ } function restoreStructures() { - for (let id in currentStructures.restoreStructures) { + for (var id in currentStructures.restoreStructures) { currentStructures[id] = currentStructures.restoreStructures[id]; } currentStructures.restoreStructures = null; } function read() { - let token = src[position$1++]; + var token = src[position$1++]; if (token < 0xa0) { if (token < 0x80) { if (token < 0x40) return token else { - let structure = currentStructures[token & 0x3f] || + var structure = currentStructures[token & 0x3f] || currentUnpackr.getStructures && loadStructures()[token & 0x3f]; if (structure) { if (!structure.read) { @@ -259,25 +259,25 @@ // map token -= 0x80; if (currentUnpackr.mapsAsObjects) { - let object = {}; - for (let i = 0; i < token; i++) { - let key = readKey(); + var object = {}; + for (var i = 0; i < token; i++) { + var key = readKey(); if (key === '__proto__') key = '__proto_'; object[key] = read(); } return object } else { - let map = new Map(); - for (let i = 0; i < token; i++) { + var map = new Map(); + for (var i = 0; i < token; i++) { map.set(read(), read()); } return map } } else { token -= 0x90; - let array = new Array(token); - for (let i = 0; i < token; i++) { + var array = new Array(token); + for (var i = 0; i < token; i++) { array[i] = read(); } if (currentUnpackr.freezeData) @@ -286,19 +286,19 @@ } } else if (token < 0xc0) { // fixstr - let length = token - 0xa0; + var length = token - 0xa0; if (srcStringEnd >= position$1) { return srcString.slice(position$1 - srcStringStart, (position$1 += length) - srcStringStart) } if (srcStringEnd == 0 && srcEnd < 140) { // for small blocks, avoiding the overhead of the extract call is helpful - let string = length < 16 ? shortStringInJS(length) : longStringInJS(length); + var string = length < 16 ? shortStringInJS(length) : longStringInJS(length); if (string != null) return string } return readFixedString(length) } else { - let value; + var value; switch (token) { case 0xc0: return null case 0xc1: @@ -345,7 +345,7 @@ value = dataView.getFloat32(position$1); if (currentUnpackr.useFloat32 > 2) { // this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved - let multiplier = mult10[((src[position$1] & 0x7f) << 1) | (src[position$1 + 1] >> 7)]; + var multiplier = mult10[((src[position$1] & 0x7f) << 1) | (src[position$1 + 1] >> 7)]; position$1 += 4; return ((multiplier * value + (value > 0 ? 0.5 : -0.5)) >> 0) / multiplier } @@ -411,7 +411,7 @@ if (value == 0x72) { return recordDefinition(src[position$1++] & 0x3f) } else { - let extension = currentExtensions[value]; + var extension = currentExtensions[value]; if (extension) { if (extension.read) { position$1++; // skip filler byte @@ -488,7 +488,7 @@ if (token >= 0xe0) return token - 0x100 if (token === undefined) { - let error = new Error('Unexpected end of MessagePack data'); + var error = new Error('Unexpected end of MessagePack data'); error.incomplete = true; throw error } @@ -497,20 +497,20 @@ } } } - const validName = /^[a-zA-Z_$][a-zA-Z\d_$]*$/; + var validName = /^[a-zA-Z_$][a-zA-Z\d_$]*$/; function createStructureReader(structure, firstId) { function readObject() { // This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function if (readObject.count++ > inlineObjectReadThreshold) { - let readObject = structure.read = (new Function('r', 'return function(){return ' + (currentUnpackr.freezeData ? 'Object.freeze' : '') + - '({' + structure.map(key => key === '__proto__' ? '__proto_:r()' : validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '})}'))(read); + var readObject = structure.read = (new Function('r', 'return function(){return ' + (currentUnpackr.freezeData ? 'Object.freeze' : '') + + '({' + structure.map(function (key) { return key === '__proto__' ? '__proto_:r()' : validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()') }).join(',') + '})}'))(read); if (structure.highByte === 0) structure.read = createSecondByteReader(firstId, structure.read); return readObject() // second byte is already read, if there is one so immediately read object } - let object = {}; - for (let i = 0, l = structure.length; i < l; i++) { - let key = structure[i]; + var object = {}; + for (var i = 0, l = structure.length; i < l; i++) { + var key = structure[i]; if (key === '__proto__') key = '__proto_'; object[key] = read(); @@ -526,13 +526,13 @@ return readObject } - const createSecondByteReader = (firstId, read0) => { + var createSecondByteReader = function (firstId, read0) { return function() { - let highByte = src[position$1++]; + var highByte = src[position$1++]; if (highByte === 0) return read0() - let id = firstId < 32 ? -(firstId + (highByte << 5)) : firstId + (highByte << 5); - let structure = currentStructures[id] || loadStructures()[id]; + var id = firstId < 32 ? -(firstId + (highByte << 5)) : firstId + (highByte << 5); + var structure = currentStructures[id] || loadStructures()[id]; if (!structure) { throw new Error('Record id is not defined for ' + id) } @@ -543,7 +543,7 @@ }; function loadStructures() { - let loadedStructures = saveState(() => { + var loadedStructures = saveState(function () { // save the state in case getStructures modifies our buffer src = null; return currentUnpackr.getStructures() @@ -555,38 +555,38 @@ var readString8 = readStringJS; var readString16 = readStringJS; var readString32 = readStringJS; - let isNativeAccelerationEnabled = false; + var isNativeAccelerationEnabled = false; function readStringJS(length) { - let result; + var result; if (length < 16) { if (result = shortStringInJS(length)) return result } if (length > 64 && decoder) return decoder.decode(src.subarray(position$1, position$1 += length)) - const end = position$1 + length; - const units = []; + var end = position$1 + length; + var units = []; result = ''; while (position$1 < end) { - const byte1 = src[position$1++]; + var byte1 = src[position$1++]; if ((byte1 & 0x80) === 0) { // 1 byte units.push(byte1); } else if ((byte1 & 0xe0) === 0xc0) { // 2 bytes - const byte2 = src[position$1++] & 0x3f; + var byte2 = src[position$1++] & 0x3f; units.push(((byte1 & 0x1f) << 6) | byte2); } else if ((byte1 & 0xf0) === 0xe0) { // 3 bytes - const byte2 = src[position$1++] & 0x3f; - const byte3 = src[position$1++] & 0x3f; + var byte2 = src[position$1++] & 0x3f; + var byte3 = src[position$1++] & 0x3f; units.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3); } else if ((byte1 & 0xf8) === 0xf0) { // 4 bytes - const byte2 = src[position$1++] & 0x3f; - const byte3 = src[position$1++] & 0x3f; - const byte4 = src[position$1++] & 0x3f; - let unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4; + var byte2 = src[position$1++] & 0x3f; + var byte3 = src[position$1++] & 0x3f; + var byte4 = src[position$1++] & 0x3f; + var unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4; if (unit > 0xffff) { unit -= 0x10000; units.push(((unit >>> 10) & 0x3ff) | 0xd800); @@ -611,8 +611,8 @@ } function readArray(length) { - let array = new Array(length); - for (let i = 0; i < length; i++) { + var array = new Array(length); + for (var i = 0; i < length; i++) { array[i] = read(); } if (currentUnpackr.freezeData) @@ -622,17 +622,17 @@ function readMap(length) { if (currentUnpackr.mapsAsObjects) { - let object = {}; - for (let i = 0; i < length; i++) { - let key = readKey(); + var object = {}; + for (var i = 0; i < length; i++) { + var key = readKey(); if (key === '__proto__') key = '__proto_'; object[key] = read(); } return object } else { - let map = new Map(); - for (let i = 0; i < length; i++) { + var map = new Map(); + for (var i = 0; i < length; i++) { map.set(read(), read()); } return map @@ -641,10 +641,10 @@ var fromCharCode = String.fromCharCode; function longStringInJS(length) { - let start = position$1; - let bytes = new Array(length); - for (let i = 0; i < length; i++) { - const byte = src[position$1++]; + var start = position$1; + var bytes = new Array(length); + for (var i = 0; i < length; i++) { + var byte = src[position$1++]; if ((byte & 0x80) > 0) { position$1 = start; return @@ -659,7 +659,7 @@ if (length === 0) return '' else { - let a = src[position$1++]; + var a = src[position$1++]; if ((a & 0x80) > 1) { position$1 -= 1; return @@ -667,15 +667,15 @@ return fromCharCode(a) } } else { - let a = src[position$1++]; - let b = src[position$1++]; + var a = src[position$1++]; + var b = src[position$1++]; if ((a & 0x80) > 0 || (b & 0x80) > 0) { position$1 -= 2; return } if (length < 3) return fromCharCode(a, b) - let c = src[position$1++]; + var c = src[position$1++]; if ((c & 0x80) > 0) { position$1 -= 3; return @@ -683,10 +683,10 @@ return fromCharCode(a, b, c) } } else { - let a = src[position$1++]; - let b = src[position$1++]; - let c = src[position$1++]; - let d = src[position$1++]; + var a = src[position$1++]; + var b = src[position$1++]; + var c = src[position$1++]; + var d = src[position$1++]; if ((a & 0x80) > 0 || (b & 0x80) > 0 || (c & 0x80) > 0 || (d & 0x80) > 0) { position$1 -= 4; return @@ -695,7 +695,7 @@ if (length === 4) return fromCharCode(a, b, c, d) else { - let e = src[position$1++]; + var e = src[position$1++]; if ((e & 0x80) > 0) { position$1 -= 5; return @@ -703,25 +703,25 @@ return fromCharCode(a, b, c, d, e) } } else if (length < 8) { - let e = src[position$1++]; - let f = src[position$1++]; + var e = src[position$1++]; + var f = src[position$1++]; if ((e & 0x80) > 0 || (f & 0x80) > 0) { position$1 -= 6; return } if (length < 7) return fromCharCode(a, b, c, d, e, f) - let g = src[position$1++]; + var g = src[position$1++]; if ((g & 0x80) > 0) { position$1 -= 7; return } return fromCharCode(a, b, c, d, e, f, g) } else { - let e = src[position$1++]; - let f = src[position$1++]; - let g = src[position$1++]; - let h = src[position$1++]; + var e = src[position$1++]; + var f = src[position$1++]; + var g = src[position$1++]; + var h = src[position$1++]; if ((e & 0x80) > 0 || (f & 0x80) > 0 || (g & 0x80) > 0 || (h & 0x80) > 0) { position$1 -= 8; return @@ -730,7 +730,7 @@ if (length === 8) return fromCharCode(a, b, c, d, e, f, g, h) else { - let i = src[position$1++]; + var i = src[position$1++]; if ((i & 0x80) > 0) { position$1 -= 9; return @@ -738,25 +738,25 @@ return fromCharCode(a, b, c, d, e, f, g, h, i) } } else if (length < 12) { - let i = src[position$1++]; - let j = src[position$1++]; + var i = src[position$1++]; + var j = src[position$1++]; if ((i & 0x80) > 0 || (j & 0x80) > 0) { position$1 -= 10; return } if (length < 11) return fromCharCode(a, b, c, d, e, f, g, h, i, j) - let k = src[position$1++]; + var k = src[position$1++]; if ((k & 0x80) > 0) { position$1 -= 11; return } return fromCharCode(a, b, c, d, e, f, g, h, i, j, k) } else { - let i = src[position$1++]; - let j = src[position$1++]; - let k = src[position$1++]; - let l = src[position$1++]; + var i = src[position$1++]; + var j = src[position$1++]; + var k = src[position$1++]; + var l = src[position$1++]; if ((i & 0x80) > 0 || (j & 0x80) > 0 || (k & 0x80) > 0 || (l & 0x80) > 0) { position$1 -= 12; return @@ -765,7 +765,7 @@ if (length === 12) return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l) else { - let m = src[position$1++]; + var m = src[position$1++]; if ((m & 0x80) > 0) { position$1 -= 13; return @@ -773,15 +773,15 @@ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m) } } else { - let m = src[position$1++]; - let n = src[position$1++]; + var m = src[position$1++]; + var n = src[position$1++]; if ((m & 0x80) > 0 || (n & 0x80) > 0) { position$1 -= 14; return } if (length < 15) return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n) - let o = src[position$1++]; + var o = src[position$1++]; if ((o & 0x80) > 0) { position$1 -= 15; return @@ -794,8 +794,8 @@ } function readOnlyJSString() { - let token = src[position$1++]; - let length; + var token = src[position$1++]; + var length; if (token < 0xc0) { // fixstr length = token - 0xa0; @@ -830,10 +830,10 @@ src.subarray(position$1, position$1 += length) } function readExt(length) { - let type = src[position$1++]; + var type = src[position$1++]; if (currentExtensions[type]) { - let end; - return currentExtensions[type](src.subarray(position$1, end = (position$1 += length)), (readPosition) => { + var end; + return currentExtensions[type](src.subarray(position$1, end = (position$1 += length)), function (readPosition) { position$1 = readPosition; try { return read(); @@ -848,7 +848,7 @@ var keyCache = new Array(4096); function readKey() { - let length = src[position$1++]; + var length = src[position$1++]; if (length >= 0xa0 && length < 0xc0) { // fixstr, potentially use key cache length = length - 0xa0; @@ -860,12 +860,12 @@ position$1--; return asSafeString(read()) } - let key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position$1) : length > 0 ? src[position$1] : 0)) & 0xfff; - let entry = keyCache[key]; - let checkPosition = position$1; - let end = position$1 + length - 3; - let chunk; - let i = 0; + var key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position$1) : length > 0 ? src[position$1] : 0)) & 0xfff; + var entry = keyCache[key]; + var checkPosition = position$1; + var end = position$1 + length - 3; + var chunk; + var i = 0; if (entry && entry.bytes == length) { while (checkPosition < end) { chunk = dataView.getUint32(checkPosition); @@ -904,7 +904,7 @@ entry.push(chunk); } // for small blocks, avoiding the overhead of the extract call is helpful - let string = length < 16 ? shortStringInJS(length) : longStringInJS(length); + var string = length < 16 ? shortStringInJS(length) : longStringInJS(length); if (string != null) return entry.string = string return entry.string = readFixedString(length) @@ -918,15 +918,15 @@ throw new Error('Invalid property type for record', typeof property); } // the registration of the record definition extension (as "r") - const recordDefinition = (id, highByte) => { - let structure = read().map(asSafeString); // ensure that all keys are strings and + var recordDefinition = function (id, highByte) { + var structure = read().map(asSafeString); // ensure that all keys are strings and // that the array is mutable - let firstByte = id; + var firstByte = id; if (highByte !== undefined) { id = id < 32 ? -((highByte << 5) + id) : ((highByte << 5) + id); structure.highByte = highByte; } - let existingStructure = currentStructures[id]; + var existingStructure = currentStructures[id]; // If it is a shared structure, we need to restore any changes after reading. // Also in sequential mode, we may get incomplete reads and thus errors, and we need to restore // to the state prior to an incomplete read in order to properly resume. @@ -937,34 +937,34 @@ structure.read = createStructureReader(structure, firstByte); return structure.read() }; - currentExtensions[0] = () => {}; // notepack defines extension 0 to mean undefined, so use that as the default here + currentExtensions[0] = function () {}; // notepack defines extension 0 to mean undefined, so use that as the default here currentExtensions[0].noBuffer = true; - currentExtensions[0x42] = (data) => { + currentExtensions[0x42] = function (data) { // decode bigint - let length = data.length; - let value = BigInt(data[0] & 0x80 ? data[0] - 0x100 : data[0]); - for (let i = 1; i < length; i++) { - value <<= 8n; + var length = data.length; + var value = BigInt(data[0] & 0x80 ? data[0] - 0x100 : data[0]); + for (var i = 1; i < length; i++) { + value <<= BigInt(8); value += BigInt(data[i]); } return value; }; - let errors = { Error, TypeError, ReferenceError }; - currentExtensions[0x65] = () => { - let data = read(); + var errors = { Error, TypeError, ReferenceError }; + currentExtensions[0x65] = function () { + var data = read(); return (errors[data[0]] || Error)(data[1], { cause: data[2] }) }; - currentExtensions[0x69] = (data) => { + currentExtensions[0x69] = function (data) { // id extension (for structured clones) if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled') - let id = dataView.getUint32(position$1 - 4); + var id = dataView.getUint32(position$1 - 4); if (!referenceMap) referenceMap = new Map(); - let token = src[position$1]; - let target; + var token = src[position$1]; + var target; // TODO: handle Maps, Sets, and other types that can cycle; this is complicated, because you potentially need to read // ahead past references to record structure definitions if (token >= 0x90 && token < 0xa0 || token == 0xdc || token == 0xdd) @@ -972,36 +972,36 @@ else target = {}; - let refEntry = { target }; // a placeholder object + var refEntry = { target }; // a placeholder object referenceMap.set(id, refEntry); - let targetProperties = read(); // read the next value as the target object to id + var targetProperties = read(); // read the next value as the target object to id if (refEntry.used) // there is a cycle, so we have to assign properties to original target return Object.assign(target, targetProperties) refEntry.target = targetProperties; // the placeholder wasn't used, replace with the deserialized one return targetProperties // no cycle, can just use the returned read object }; - currentExtensions[0x70] = (data) => { + currentExtensions[0x70] = function (data) { // pointer extension (for structured clones) if (currentUnpackr.structuredClone === false) throw new Error('Structured clone extension is disabled') - let id = dataView.getUint32(position$1 - 4); - let refEntry = referenceMap.get(id); + var id = dataView.getUint32(position$1 - 4); + var refEntry = referenceMap.get(id); refEntry.used = true; return refEntry.target }; - currentExtensions[0x73] = () => new Set(read()); + currentExtensions[0x73] = function () { new Set(read()) }; - const typedArrays = ['Int8','Uint8','Uint8Clamped','Int16','Uint16','Int32','Uint32','Float32','Float64','BigInt64','BigUint64'].map(type => type + 'Array'); + var typedArrays = ['Int8', 'Uint8', 'Uint8Clamped', 'Int16', 'Uint16', 'Int32', 'Uint32', 'Float32', 'Float64', 'BigInt64', 'BigUint64'].map(function (type) { return type + 'Array' }); - let glbl = typeof globalThis === 'object' ? globalThis : window; - currentExtensions[0x74] = (data) => { - let typeCode = data[0]; - let typedArrayName = typedArrays[typeCode]; + var glbl = typeof globalThis === 'object' ? globalThis : window; + currentExtensions[0x74] = function (data) { + var typeCode = data[0]; + var typedArrayName = typedArrays[typeCode]; if (!typedArrayName) { if (typeCode === 16) { - let ab = new ArrayBuffer(data.length - 1); - let u8 = new Uint8Array(ab); + var ab = new ArrayBuffer(data.length - 1); + var u8 = new Uint8Array(ab); u8.set(data.subarray(1)); return ab; } @@ -1010,14 +1010,14 @@ // we have to always slice/copy here to get a new ArrayBuffer that is word/byte aligned return new glbl[typedArrayName](Uint8Array.prototype.slice.call(data, 1).buffer) }; - currentExtensions[0x78] = () => { - let data = read(); + currentExtensions[0x78] = function () { + var data = read(); return new RegExp(data[0], data[1]) }; - const TEMP_BUNDLE = []; - currentExtensions[0x62] = (data) => { - let dataSize = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]; - let dataPosition = position$1; + var TEMP_BUNDLE = []; + currentExtensions[0x62] = function (data) { + var dataSize = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]; + var dataPosition = position$1; position$1 += dataSize - data.length; bundledStrings$1 = TEMP_BUNDLE; bundledStrings$1 = [readOnlyJSString(), readOnlyJSString()]; @@ -1028,7 +1028,7 @@ return read() }; - currentExtensions[0xff] = (data) => { + currentExtensions[0xff] = function (data) { // 32-bit date extension if (data.length == 4) return new Date((data[0] * 0x1000000 + (data[1] << 16) + (data[2] << 8) + data[3]) * 1000) @@ -1047,21 +1047,21 @@ // currentExtensions[0x52] = () => function saveState(callback) { - let savedSrcEnd = srcEnd; - let savedPosition = position$1; - let savedSrcStringStart = srcStringStart; - let savedSrcStringEnd = srcStringEnd; - let savedSrcString = srcString; - let savedReferenceMap = referenceMap; - let savedBundledStrings = bundledStrings$1; + var savedSrcEnd = srcEnd; + var savedPosition = position$1; + var savedSrcStringStart = srcStringStart; + var savedSrcStringEnd = srcStringEnd; + var savedSrcString = srcString; + var savedReferenceMap = referenceMap; + var savedBundledStrings = bundledStrings$1; // TODO: We may need to revisit this if we do more external calls to user code (since it could be slow) - let savedSrc = new Uint8Array(src.slice(0, srcEnd)); // we copy the data in case it changes while external data is processed - let savedStructures = currentStructures; - let savedStructuresContents = currentStructures.slice(0, currentStructures.length); - let savedPackr = currentUnpackr; - let savedSequentialMode = sequentialMode; - let value = callback(); + var savedSrc = new Uint8Array(src.slice(0, srcEnd)); // we copy the data in case it changes while external data is processed + var savedStructures = currentStructures; + var savedStructuresContents = currentStructures.slice(0, currentStructures.length); + var savedPackr = currentUnpackr; + var savedSequentialMode = sequentialMode; + var value = callback(); srcEnd = savedSrcEnd; position$1 = savedPosition; srcStringStart = savedSrcStringStart; @@ -1072,7 +1072,9 @@ src = savedSrc; sequentialMode = savedSequentialMode; currentStructures = savedStructures; - currentStructures.splice(0, currentStructures.length, ...savedStructuresContents); + for (var ssc of savedStructuresContents) { + currentStructures.splice(0, currentStructures.length, ssc); + } currentUnpackr = savedPackr; dataView = new DataView(src.buffer, src.byteOffset, src.byteLength); return value @@ -1090,69 +1092,69 @@ currentExtensions[extension.type] = extension; } - const mult10 = new Array(147); // this is a table matching binary exponents to the multiplier to determine significant digit rounding - for (let i = 0; i < 256; i++) { + var mult10 = new Array(147); // this is a table matching binary exponents to the multiplier to determine significant digit rounding + for (var i = 0; i < 256; i++) { mult10[i] = +('1e' + Math.floor(45.15 - i * 0.30103)); } - const Decoder = Unpackr; + var Decoder = Unpackr; var defaultUnpackr = new Unpackr({ useRecords: false }); - const unpack = defaultUnpackr.unpack; - const unpackMultiple = defaultUnpackr.unpackMultiple; - const decode = defaultUnpackr.unpack; - const FLOAT32_OPTIONS = { + var unpack = defaultUnpackr.unpack; + var unpackMultiple = defaultUnpackr.unpackMultiple; + var decode = defaultUnpackr.unpack; + var FLOAT32_OPTIONS = { NEVER: 0, ALWAYS: 1, DECIMAL_ROUND: 3, DECIMAL_FIT: 4 }; - let f32Array = new Float32Array(1); - let u8Array = new Uint8Array(f32Array.buffer, 0, 4); + var f32Array = new Float32Array(1); + var u8Array = new Uint8Array(f32Array.buffer, 0, 4); function roundFloat32(float32Number) { f32Array[0] = float32Number; - let multiplier = mult10[((u8Array[3] & 0x7f) << 1) | (u8Array[2] >> 7)]; + var multiplier = mult10[((u8Array[3] & 0x7f) << 1) | (u8Array[2] >> 7)]; return ((multiplier * float32Number + (float32Number > 0 ? 0.5 : -0.5)) >> 0) / multiplier } - let textEncoder; + var textEncoder; try { textEncoder = new TextEncoder(); } catch (error) {} - let extensions, extensionClasses; - const hasNodeBuffer = typeof Buffer !== 'undefined'; - const ByteArrayAllocate = hasNodeBuffer ? + var extensions, extensionClasses; + var hasNodeBuffer = typeof Buffer !== 'undefined'; + var ByteArrayAllocate = hasNodeBuffer ? function(length) { return Buffer.allocUnsafeSlow(length) } : Uint8Array; - const ByteArray = hasNodeBuffer ? Buffer : Uint8Array; - const MAX_BUFFER_SIZE = hasNodeBuffer ? 0x100000000 : 0x7fd00000; - let target, keysTarget; - let targetView; - let position = 0; - let safeEnd; - let bundledStrings = null; - let writeStructSlots; - const MAX_BUNDLE_SIZE = 0x5500; // maximum characters such that the encoded bytes fits in 16 bits. - const hasNonLatin = /[\u0080-\uFFFF]/; - const RECORD_SYMBOL = Symbol('record-id'); + var ByteArray = hasNodeBuffer ? Buffer : Uint8Array; + var MAX_BUFFER_SIZE = hasNodeBuffer ? 0x100000000 : 0x7fd00000; + var target, keysTarget; + var targetView; + var position = 0; + var safeEnd; + var bundledStrings = null; + var writeStructSlots; + var MAX_BUNDLE_SIZE = 0x5500; // maximum characters such that the encoded bytes fits in 16 bits. + var hasNonLatin = /[\u0080-\uFFFF]/; + var RECORD_SYMBOL = Symbol('record-id'); class Packr extends Unpackr { constructor(options) { super(options); this.offset = 0; - let start; - let hasSharedUpdate; - let structures; - let referenceMap; - let encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) { + var start; + var hasSharedUpdate; + var structures; + var referenceMap; + var encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position) { return target.utf8Write(string, position, 0xffffffff) } : (textEncoder && textEncoder.encodeInto) ? function(string, position) { return textEncoder.encodeInto(string, target.subarray(position)).written } : false; - let packr = this; + var packr = this; if (!options) options = {}; - let isSequential = options && options.sequential; - let hasSharedStructures = options.structures || options.saveStructures; - let maxSharedStructures = options.maxSharedStructures; + var isSequential = options && options.sequential; + var hasSharedStructures = options.structures || options.saveStructures; + var maxSharedStructures = options.maxSharedStructures; if (maxSharedStructures == null) maxSharedStructures = hasSharedStructures ? 32 : 0; if (maxSharedStructures > 8160) @@ -1160,21 +1162,21 @@ if (options.structuredClone && options.moreTypes == undefined) { this.moreTypes = true; } - let maxOwnStructures = options.maxOwnStructures; + var maxOwnStructures = options.maxOwnStructures; if (maxOwnStructures == null) maxOwnStructures = hasSharedStructures ? 32 : 64; if (!this.structures && options.useRecords != false) this.structures = []; // two byte record ids for shared structures - let useTwoByteRecords = maxSharedStructures > 32 || (maxOwnStructures + maxSharedStructures > 64); - let sharedLimitId = maxSharedStructures + 0x40; - let maxStructureId = maxSharedStructures + maxOwnStructures + 0x40; + var useTwoByteRecords = maxSharedStructures > 32 || (maxOwnStructures + maxSharedStructures > 64); + var sharedLimitId = maxSharedStructures + 0x40; + var maxStructureId = maxSharedStructures + maxOwnStructures + 0x40; if (maxStructureId > 8256) { throw new Error('Maximum maxSharedStructure + maxOwnStructure is 8192') } - let recordIdsToRemove = []; - let transitionsCount = 0; - let serializationsSinceTransitionRebuild = 0; + var recordIdsToRemove = []; + var transitionsCount = 0; + var serializationsSinceTransitionRebuild = 0; this.pack = this.encode = function(value, encodeOptions) { if (!target) { @@ -1203,7 +1205,7 @@ if (structures) { if (structures.uninitialized) structures = packr._mergeStructures(packr.getStructures()); - let sharedLength = structures.sharedLength || 0; + var sharedLength = structures.sharedLength || 0; if (sharedLength > maxSharedStructures) { //if (maxSharedStructures <= 32 && structures.sharedLength > 32) // TODO: could support this, but would need to update the limit ids throw new Error('Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to ' + structures.sharedLength) @@ -1211,13 +1213,13 @@ if (!structures.transitions) { // rebuild our structure transitions structures.transitions = Object.create(null); - for (let i = 0; i < sharedLength; i++) { - let keys = structures[i]; + for (var i = 0; i < sharedLength; i++) { + var keys = structures[i]; if (!keys) continue - let nextTransition, transition = structures.transitions; - for (let j = 0, l = keys.length; j < l; j++) { - let key = keys[j]; + var nextTransition, transition = structures.transitions; + for (var j = 0, l = keys.length; j < l; j++) { + var key = keys[j]; nextTransition = transition[key]; if (!nextTransition) { nextTransition = transition[key] = Object.create(null); @@ -1234,21 +1236,21 @@ } if (hasSharedUpdate) hasSharedUpdate = false; - let encodingError; + var encodingError; try { if (packr.randomAccessStructure && value && value.constructor && value.constructor === Object) writeStruct(value); else pack(value); - let lastBundle = bundledStrings; + var lastBundle = bundledStrings; if (bundledStrings) writeBundles(start, pack, 0); if (referenceMap && referenceMap.idsToInsert) { - let idsToInsert = referenceMap.idsToInsert.sort((a, b) => a.offset > b.offset ? 1 : -1); - let i = idsToInsert.length; - let incrementPosition = -1; + var idsToInsert = referenceMap.idsToInsert.sort(function (a, b) { a.offset > b.offset ? 1 : -1 }); + var i = idsToInsert.length; + var incrementPosition = -1; while (lastBundle && i > 0) { - let insertionPoint = idsToInsert[--i].offset + start; + var insertionPoint = idsToInsert[--i].offset + start; if (insertionPoint < (lastBundle.stringsPosition + start) && incrementPosition === -1) incrementPosition = 0; if (insertionPoint > (lastBundle.position + start)) { @@ -1274,7 +1276,7 @@ if (position > safeEnd) makeRoom(position); packr.offset = position; - let serialized = insertIds(target.subarray(start, position), idsToInsert); + var serialized = insertIds(target.subarray(start, position), idsToInsert); referenceMap = null; return serialized } @@ -1292,10 +1294,10 @@ if (structures) { resetStructures(); if (hasSharedUpdate && packr.saveStructures) { - let sharedLength = structures.sharedLength || 0; + var sharedLength = structures.sharedLength || 0; // we can't rely on start/end with REUSE_BUFFER_MODE since they will (probably) change when we save - let returnBuffer = target.subarray(start, position); - let newSharedData = prepareStructures(structures, packr); + var returnBuffer = target.subarray(start, position); + var newSharedData = prepareStructures(structures, packr); if (!encodingError) { // TODO: If there is an encoding error, should make the structures as uninitialized so they get rebuilt next time if (packr.saveStructures(newSharedData, newSharedData.isCompatible) === false) { // get updated structures and try again if the update failed @@ -1314,10 +1316,10 @@ position = start; } }; - const resetStructures = () => { + var resetStructures = function () { if (serializationsSinceTransitionRebuild < 10) serializationsSinceTransitionRebuild++; - let sharedLength = structures.sharedLength || 0; + var sharedLength = structures.sharedLength || 0; if (structures.length > sharedLength && !isSequential) structures.length = sharedLength; if (transitionsCount > 10000) { @@ -1328,13 +1330,13 @@ if (recordIdsToRemove.length > 0) recordIdsToRemove = []; } else if (recordIdsToRemove.length > 0 && !isSequential) { - for (let i = 0, l = recordIdsToRemove.length; i < l; i++) { + for (var i = 0, l = recordIdsToRemove.length; i < l; i++) { recordIdsToRemove[i][RECORD_SYMBOL] = 0; } recordIdsToRemove = []; } }; - const packArray = (value) => { + var packArray = function (value) { var length = value.length; if (length < 0x10) { target[position++] = 0x90 | length; @@ -1347,25 +1349,25 @@ targetView.setUint32(position, length); position += 4; } - for (let i = 0; i < length; i++) { + for (var i = 0; i < length; i++) { pack(value[i]); } }; - const pack = (value) => { + var pack = function (value) { if (position > safeEnd) target = makeRoom(position); var type = typeof value; var length; if (type === 'string') { - let strLength = value.length; + var strLength = value.length; if (bundledStrings && strLength >= 4 && strLength < 0x1000) { if ((bundledStrings.size += strLength) > MAX_BUNDLE_SIZE) { - let extStart; - let maxBytes = (bundledStrings[0] ? bundledStrings[0].length * 3 + bundledStrings[1].length : 0) + 10; + var extStart; + var maxBytes = (bundledStrings[0] ? bundledStrings[0].length * 3 + bundledStrings[1].length : 0) + 10; if (position + maxBytes > safeEnd) target = makeRoom(position + maxBytes); - let lastBundle; + var lastBundle; if (bundledStrings.position) { // here we use the 0x62 extension to write the last bundle and reserve space for the reference pointer to the next/current bundle lastBundle = bundledStrings; target[position] = 0xc8; // ext 16 @@ -1386,13 +1388,13 @@ bundledStrings.size = 0; bundledStrings.position = extStart; } - let twoByte = hasNonLatin.test(value); + var twoByte = hasNonLatin.test(value); bundledStrings[twoByte ? 0 : 1] += value; target[position++] = 0xc1; pack(twoByte ? -strLength : strLength); return } - let headerSize; + var headerSize; // first we estimate the header size, so we can write to the correct location if (strLength < 0x20) { headerSize = 1; @@ -1403,12 +1405,12 @@ } else { headerSize = 5; } - let maxBytes = strLength * 3; + var maxBytes = strLength * 3; if (position + maxBytes > safeEnd) target = makeRoom(position + maxBytes); if (strLength < 0x40 || !encodeUtf8) { - let i, c1, c2, strPosition = position + headerSize; + var i, c1, c2, strPosition = position + headerSize; for (i = 0; i < strLength; i++) { c1 = value.charCodeAt(i); if (c1 < 0x80) { @@ -1494,11 +1496,11 @@ position += 4; } } else { - let useFloat32; + var useFloat32; if ((useFloat32 = this.useFloat32) > 0 && value < 0x100000000 && value >= -0x80000000) { target[position++] = 0xca; targetView.setFloat32(position, value); - let xShifted; + var xShifted; if (useFloat32 < 4 || // this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved ((xShifted = value * mult10[((target[position] & 0x7f) << 1) | (target[position + 1] >> 7)]) >> 0) === xShifted) { @@ -1516,10 +1518,10 @@ target[position++] = 0xc0; else { if (referenceMap) { - let referee = referenceMap.get(value); + var referee = referenceMap.get(value); if (referee) { if (!referee.id) { - let idsToInsert = referenceMap.idsToInsert || (referenceMap.idsToInsert = []); + var idsToInsert = referenceMap.idsToInsert || (referenceMap.idsToInsert = []); referee.id = idsToInsert.push(referee); } target[position++] = 0xd6; // fixext 4 @@ -1530,7 +1532,7 @@ } else referenceMap.set(value, { offset: position - start }); } - let constructor = value.constructor; + var constructor = value.constructor; if (constructor === Object) { writeObject(value); } else if (constructor === Array) { @@ -1550,23 +1552,23 @@ targetView.setUint32(position, length); position += 4; } - for (let [key, entryValue] of value) { + for (var [key, entryValue] of value) { pack(key); pack(entryValue); } } } else { - for (let i = 0, l = extensions.length; i < l; i++) { - let extensionClass = extensionClasses[i]; + for (var i = 0, l = extensions.length; i < l; i++) { + var extensionClass = extensionClasses[i]; if (value instanceof extensionClass) { - let extension = extensions[i]; + var extension = extensions[i]; if (extension.write) { if (extension.type) { target[position++] = 0xd4; // one byte "tag" extension target[position++] = extension.type; target[position++] = 0; } - let writeResult = extension.write.call(this, value); + var writeResult = extension.write.call(this, value); if (writeResult === value) { // avoid infinite recursion if (Array.isArray(value)) { packArray(value); @@ -1578,13 +1580,13 @@ } return } - let currentTarget = target; - let currentTargetView = targetView; - let currentPosition = position; + var currentTarget = target; + var currentTargetView = targetView; + var currentPosition = position; target = null; - let result; + var result; try { - result = extension.pack.call(this, value, (size) => { + result = extension.pack.call(this, value, function (size) { // restore target and use it target = currentTarget; currentTarget = null; @@ -1618,7 +1620,7 @@ } else { // use this as an alternate mechanism for expressing how to serialize if (value.toJSON) { - const json = value.toJSON(); + var json = value.toJSON(); // if for some reason value.toJSON returns itself it'll loop forever if (json !== value) return pack(json) @@ -1649,23 +1651,23 @@ if (this.largeBigIntToFloat) { target[position++] = 0xcb; targetView.setFloat64(position, Number(value)); - } else if (this.useBigIntExtension && value < 2n**(1023n) && value > -(2n**(1023n))) { + /*} else if (this.useBigIntExtension && value < BigInt(2)**BigInt(1023) && value > -(BigInt(2)**BigInt(1023))) { target[position++] = 0xc7; position++; target[position++] = 0x42; // "B" for BigInt - let bytes = []; - let alignedSign; + var bytes = []; + var alignedSign; do { - let byte = value & 0xffn; - alignedSign = (byte & 0x80n) === (value < 0n ? 0x80n : 0n); + var byte = value & BigInt(0xff); + alignedSign = (byte & BigInt(0x80)) === (value < BigInt(0) ? BigInt(0x80) : BigInt(0)); bytes.push(byte); - value >>= 8n; - } while (!((value === 0n || value === -1n) && alignedSign)); + value >>= BigInt(8); + } while (!((value === BigInt(0) || value === -BigInt(1)) && alignedSign)); target[position-2] = bytes.length; - for (let i = bytes.length; i > 0;) { + for (var i = bytes.length; i > 0;) { target[position++] = Number(bytes[--i]); } - return + return*/ } else { throw new RangeError(value + ' was too large to fit in MessagePack 64-bit integer format, use' + ' useBigIntExtension or set largeBigIntToFloat to convert to float-64') @@ -1685,12 +1687,12 @@ } }; - const writePlainObject = (this.variableMapSize || this.coercibleKeyAsNumber || this.skipValues) ? (object) => { + var writePlainObject = (this.variableMapSize || this.coercibleKeyAsNumber || this.skipValues) ? function (object) { // this method is slightly slower, but generates "preferred serialization" (optimally small for smaller objects) - let keys; + var keys; if (this.skipValues) { keys = []; - for (let key in object) { + for (var key in object) { if ((typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) && !this.skipValues.includes(object[key])) keys.push(key); @@ -1698,7 +1700,7 @@ } else { keys = Object.keys(object); } - let length = keys.length; + var length = keys.length; if (length < 0x10) { target[position++] = 0x80 | length; } else if (length < 0x10000) { @@ -1710,28 +1712,28 @@ targetView.setUint32(position, length); position += 4; } - let key; + var key; if (this.coercibleKeyAsNumber) { - for (let i = 0; i < length; i++) { + for (var i = 0; i < length; i++) { key = keys[i]; - let num = Number(key); + var num = Number(key); pack(isNaN(num) ? key : num); pack(object[key]); } } else { - for (let i = 0; i < length; i++) { + for (var i = 0; i < length; i++) { pack(key = keys[i]); pack(object[key]); } } } : - (object) => { + function (object) { target[position++] = 0xde; // always using map 16, so we can preallocate and set the length afterwards - let objectOffset = position - start; + var objectOffset = position - start; position += 2; - let size = 0; - for (let key in object) { + var size = 0; + for (var key in object) { if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) { pack(key); pack(object[key]); @@ -1742,25 +1744,25 @@ target[objectOffset + start] = size & 0xff; }; - const writeRecord = this.useRecords === false ? writePlainObject : + var writeRecord = this.useRecords === false ? writePlainObject : (options.progressiveRecords && !useTwoByteRecords) ? // this is about 2% faster for highly stable structures, since it only requires one for-in loop (but much more expensive when new structure needs to be written) - (object) => { - let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null)); - let objectOffset = position++ - start; - let wroteKeys; - for (let key in object) { + function (object) { + var nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null)); + var objectOffset = position++ - start; + var wroteKeys; + for (var key in object) { if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) { nextTransition = transition[key]; if (nextTransition) transition = nextTransition; else { // record doesn't exist, create full new record and insert it - let keys = Object.keys(object); - let lastTransition = transition; + var keys = Object.keys(object); + var lastTransition = transition; transition = structures.transitions; - let newTransitions = 0; - for (let i = 0, l = keys.length; i < l; i++) { - let key = keys[i]; + var newTransitions = 0; + for (var i = 0, l = keys.length; i < l; i++) { + var key = keys[i]; nextTransition = transition[key]; if (!nextTransition) { nextTransition = transition[key] = Object.create(null); @@ -1781,17 +1783,17 @@ } } if (!wroteKeys) { - let recordId = transition[RECORD_SYMBOL]; + var recordId = transition[RECORD_SYMBOL]; if (recordId) target[objectOffset + start] = recordId; else insertNewRecord(transition, Object.keys(object), objectOffset, 0); } } : - (object) => { - let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null)); - let newTransitions = 0; - for (let key in object) if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) { + function (object) { + var nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null)); + var newTransitions = 0; + for (var key in object) if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) { nextTransition = transition[key]; if (!nextTransition) { nextTransition = transition[key] = Object.create(null); @@ -1799,7 +1801,7 @@ } transition = nextTransition; } - let recordId = transition[RECORD_SYMBOL]; + var recordId = transition[RECORD_SYMBOL]; if (recordId) { if (recordId >= 0x60 && useTwoByteRecords) { target[position++] = ((recordId -= 0x60) & 0x1f) + 0x60; @@ -1810,21 +1812,21 @@ newRecord(transition, transition.__keys__ || Object.keys(object), newTransitions); } // now write the values - for (let key in object) + for (var key in object) if (typeof object.hasOwnProperty !== 'function' || object.hasOwnProperty(key)) { pack(object[key]); } }; // create reference to useRecords if useRecords is a function - const checkUseRecords = typeof this.useRecords == 'function' && this.useRecords; + var checkUseRecords = typeof this.useRecords == 'function' && this.useRecords; - const writeObject = checkUseRecords ? (object) => { + var writeObject = checkUseRecords ? function (object) { checkUseRecords(object) ? writeRecord(object) : writePlainObject(object); } : writeRecord; - const makeRoom = (end) => { - let newSize; + var makeRoom = function (end) { + var newSize; if (end > 0x1000000) { // special handling for really large buffers if ((end - start) > MAX_BUFFER_SIZE) @@ -1833,7 +1835,7 @@ Math.round(Math.max((end - start) * (end > 0x4000000 ? 1.25 : 2), 0x400000) / 0x1000) * 0x1000); } else // faster handling for smaller buffers newSize = ((Math.max((end - start) << 2, target.length - 1) >> 12) + 1) << 12; - let newBuffer = new ByteArrayAllocate(newSize); + var newBuffer = new ByteArrayAllocate(newSize); targetView = newBuffer.dataView || (newBuffer.dataView = new DataView(newBuffer.buffer, 0, newSize)); end = Math.min(end, target.length); if (target.copy) @@ -1845,8 +1847,8 @@ safeEnd = newBuffer.length - 10; return target = newBuffer }; - const newRecord = (transition, keys, newTransitions) => { - let recordId = structures.nextId; + var newRecord = function (transition, keys, newTransitions) { + var recordId = structures.nextId; if (!recordId) recordId = 0x40; if (recordId < sharedLimitId && this.shouldShareStructure && !this.shouldShareStructure(keys)) { @@ -1859,7 +1861,7 @@ recordId = sharedLimitId; structures.nextId = recordId + 1; } - let highByte = keys.highByte = recordId >= 0x60 && useTwoByteRecords ? (recordId - 0x60) >> 5 : -1; + var highByte = keys.highByte = recordId >= 0x60 && useTwoByteRecords ? (recordId - 0x60) >> 5 : -1; transition[RECORD_SYMBOL] = recordId; transition.__keys__ = keys; structures[recordId - 0x40] = keys; @@ -1895,11 +1897,11 @@ pack(keys); } }; - const insertNewRecord = (transition, keys, insertionOffset, newTransitions) => { - let mainTarget = target; - let mainPosition = position; - let mainSafeEnd = safeEnd; - let mainStart = start; + var insertNewRecord = function (transition, keys, insertionOffset, newTransitions) { + var mainTarget = target; + var mainPosition = position; + var mainSafeEnd = safeEnd; + var mainStart = start; target = keysTarget; position = 0; start = 0; @@ -1908,16 +1910,16 @@ safeEnd = target.length - 10; newRecord(transition, keys, newTransitions); keysTarget = target; - let keysPosition = position; + var keysPosition = position; target = mainTarget; position = mainPosition; safeEnd = mainSafeEnd; start = mainStart; if (keysPosition > 1) { - let newEnd = position + keysPosition - 1; + var newEnd = position + keysPosition - 1; if (newEnd > safeEnd) makeRoom(newEnd); - let insertionPosition = insertionOffset + start; + var insertionPosition = insertionOffset + start; target.copyWithin(insertionPosition + keysPosition, insertionPosition + 1, position); target.set(keysTarget.slice(0, keysPosition), insertionPosition); position = newEnd; @@ -1925,12 +1927,12 @@ target[insertionOffset + start] = keysTarget[0]; } }; - const writeStruct = (object) => { - let newPosition = writeStructSlots(object, target, start, position, structures, makeRoom, (value, newPosition, notifySharedUpdate) => { + var writeStruct = function (object) { + var newPosition = writeStructSlots(object, target, start, position, structures, makeRoom, function (value, newPosition, notifySharedUpdate) { if (notifySharedUpdate) return hasSharedUpdate = true; position = newPosition; - let startTarget = target; + var startTarget = target; pack(value); resetStructures(); if (startTarget !== target) { @@ -1966,16 +1968,16 @@ extensionClasses = [ Date, Set, Error, RegExp, ArrayBuffer, Object.getPrototypeOf(Uint8Array.prototype).constructor /*TypedArray*/, C1Type ]; extensions = [{ pack(date, allocateForWrite, pack) { - let seconds = date.getTime() / 1000; + var seconds = date.getTime() / 1000; if ((this.useTimestamp32 || date.getMilliseconds() === 0) && seconds >= 0 && seconds < 0x100000000) { // Timestamp 32 - let { target, targetView, position} = allocateForWrite(6); + var { target, targetView, position} = allocateForWrite(6); target[position++] = 0xd6; target[position++] = 0xff; targetView.setUint32(position, seconds); } else if (seconds > 0 && seconds < 0x100000000) { // Timestamp 64 - let { target, targetView, position} = allocateForWrite(10); + var { target, targetView, position} = allocateForWrite(10); target[position++] = 0xd7; target[position++] = 0xff; targetView.setUint32(position, date.getMilliseconds() * 4000000 + ((seconds / 1000 / 0x100000000) >> 0)); @@ -1986,13 +1988,13 @@ return pack(this.onInvalidDate()) } // Intentionally invalid timestamp - let { target, targetView, position} = allocateForWrite(3); + var { target, targetView, position} = allocateForWrite(3); target[position++] = 0xd4; target[position++] = 0xff; target[position++] = 0xff; } else { // Timestamp 96 - let { target, targetView, position} = allocateForWrite(15); + var { target, targetView, position} = allocateForWrite(15); target[position++] = 0xc7; target[position++] = 12; target[position++] = 0xff; @@ -2006,8 +2008,8 @@ allocateForWrite(0); return pack({}) } - let array = Array.from(set); - let { target, position} = allocateForWrite(this.moreTypes ? 3 : 0); + var array = Array.from(set); + var { target, position} = allocateForWrite(this.moreTypes ? 3 : 0); if (this.moreTypes) { target[position++] = 0xd4; target[position++] = 0x73; // 's' for Set @@ -2017,7 +2019,7 @@ } }, { pack(error, allocateForWrite, pack) { - let { target, position} = allocateForWrite(this.moreTypes ? 3 : 0); + var { target, position} = allocateForWrite(this.moreTypes ? 3 : 0); if (this.moreTypes) { target[position++] = 0xd4; target[position++] = 0x65; // 'e' for error @@ -2027,7 +2029,7 @@ } }, { pack(regex, allocateForWrite, pack) { - let { target, position} = allocateForWrite(this.moreTypes ? 3 : 0); + var { target, position} = allocateForWrite(this.moreTypes ? 3 : 0); if (this.moreTypes) { target[position++] = 0xd4; target[position++] = 0x78; // 'x' for regeXp @@ -2044,7 +2046,7 @@ } }, { pack(typedArray, allocateForWrite) { - let constructor = typedArray.constructor; + var constructor = typedArray.constructor; if (constructor !== ByteArray && this.moreTypes) writeExtBuffer(typedArray, typedArrays.indexOf(constructor.name), allocateForWrite); else @@ -2052,13 +2054,13 @@ } }, { pack(c1, allocateForWrite) { // specific 0xC1 object - let { target, position} = allocateForWrite(1); + var { target, position} = allocateForWrite(1); target[position] = 0xc1; } }]; function writeExtBuffer(typedArray, type, allocateForWrite, encode) { - let length = typedArray.byteLength; + var length = typedArray.byteLength; if (length + 1 < 0x100) { var { target, position } = allocateForWrite(4 + length); target[position++] = 0xc7; @@ -2080,7 +2082,7 @@ target.set(new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength), position); } function writeBuffer(buffer, allocateForWrite) { - let length = buffer.byteLength; + var length = buffer.byteLength; var target, position; if (length < 0x100) { var { target, position } = allocateForWrite(length + 2); @@ -2101,7 +2103,7 @@ } function writeExtensionData(result, target, position, type) { - let length = result.length; + var length = result.length; switch (length) { case 1: target[position++] = 0xd4; @@ -2142,15 +2144,15 @@ function insertIds(serialized, idsToInsert) { // insert the ids that need to be referenced for structured clones - let nextId; - let distanceToMove = idsToInsert.length * 6; - let lastEnd = serialized.length - distanceToMove; + var nextId; + var distanceToMove = idsToInsert.length * 6; + var lastEnd = serialized.length - distanceToMove; while (nextId = idsToInsert.pop()) { - let offset = nextId.offset; - let id = nextId.id; + var offset = nextId.offset; + var id = nextId.id; serialized.copyWithin(offset + distanceToMove, offset, lastEnd); distanceToMove -= 6; - let position = offset + distanceToMove; + var position = offset + distanceToMove; serialized[position++] = 0xd6; serialized[position++] = 0x69; // 'i' serialized[position++] = id >> 24; @@ -2166,7 +2168,7 @@ if (bundledStrings.length > 0) { targetView.setUint32(bundledStrings.position + start, position + incrementPosition - bundledStrings.position - start); bundledStrings.stringsPosition = position - start; - let writeStrings = bundledStrings; + var writeStrings = bundledStrings; bundledStrings = null; pack(writeStrings[0]); pack(writeStrings[1]); @@ -2185,8 +2187,8 @@ addExtension$1(extension); } function prepareStructures(structures, packr) { - structures.isCompatible = (existingStructures) => { - let compatible = !existingStructures || ((packr.lastNamedStructuresLength || 0) === existingStructures.length); + structures.isCompatible = function (existingStructures) { + var compatible = !existingStructures || ((packr.lastNamedStructuresLength || 0) === existingStructures.length); if (!compatible) // we want to merge these existing structures immediately since we already have it and we are in the right transaction packr._mergeStructures(existingStructures); return compatible; @@ -2194,14 +2196,14 @@ return structures } - let defaultPackr = new Packr({ useRecords: false }); - const pack = defaultPackr.pack; - const encode = defaultPackr.pack; - const Encoder = Packr; - const { NEVER, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT } = FLOAT32_OPTIONS; - const REUSE_BUFFER_MODE = 512; - const RESET_BUFFER_MODE = 1024; - const RESERVE_START_SPACE = 2048; + var defaultPackr = new Packr({ useRecords: false }); + var pack = defaultPackr.pack; + var encode = defaultPackr.pack; + var Encoder = Packr; + var { NEVER, ALWAYS, DECIMAL_ROUND, DECIMAL_FIT } = FLOAT32_OPTIONS; + var REUSE_BUFFER_MODE = 512; + var RESET_BUFFER_MODE = 1024; + var RESERVE_START_SPACE = 2048; /** * Given an Iterable first argument, returns an Iterable where each value is packed as a Buffer @@ -2210,7 +2212,8 @@ * @param {options} [options] - msgpackr pack options * @returns {IterableIterator|Promise.} */ - function packIter (objectIterator, options = {}) { + function packIter (objectIterator, options) { + options = options != undefined ? options : {}; if (!objectIterator || typeof objectIterator !== 'object') { throw new Error('first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable') } else if (typeof objectIterator[Symbol.iterator] === 'function') { @@ -2222,18 +2225,38 @@ } } - function * packIterSync (objectIterator, options) { - const packr = new Packr(options); - for (const value of objectIterator) { - yield packr.pack(value); - } + function packIterSync (objectIterator, options) { + var packr = new Packr(options); + var iterator = objectIteratorSymbol.iterator; + return { + next: function() { + return iterator.next().then(function(result) { + if (result.done) { + return { done: true }; + } + return packr.pack(result.value).then(function(packedValue) { + return { value: packedValue, done: false }; + }); + }); + } + }; } - async function * packIterAsync (objectIterator, options) { - const packr = new Packr(options); - for await (const value of objectIterator) { - yield packr.pack(value); - } + function packIterAsync(objectIterator, options) { + var packr = new Packr(options); + var iterator = objectIteratorSymbol.asyncIterator; + return { + next: function() { + return iterator.next().then(function(result) { + if (result.done) { + return { done: true }; + } + return packr.pack(result.value).then(function(packedValue) { + return { value: packedValue, done: false }; + }); + }); + } + }; } /** @@ -2243,15 +2266,16 @@ * @param {object} [options] - unpackr options * @returns {IterableIterator|Promise. { - let yields; + var unpackr = new Unpackr(options); + var incomplete; + var parser = function (chunk) { + var yields; // if there's incomplete data from previous chunk, concatinate and try again if (incomplete) { chunk = Buffer.concat([incomplete, chunk]); @@ -2272,24 +2296,44 @@ }; if (typeof bufferIterator[Symbol.iterator] === 'function') { - return (function * iter () { - for (const value of bufferIterator) { - yield * parser(value); - } - })() + return (function iter() { + var iterator = symbol.iterator; + return { + next: function() { + return iterator.next().then(function(result) { + if (result.done) { + return { done: true }; + } + return parser(result.value).then(function(parser) { + return { value: parser, done: false }; + }); + }); + } + }; + })() } else if (typeof bufferIterator[Symbol.asyncIterator] === 'function') { - return (async function * iter () { - for await (const value of bufferIterator) { - yield * parser(value); - } + return (function iter() { + var iterator = symbol.asyncIterator; + return { + next: function() { + return iterator.next().then(function(result) { + if (result.done) { + return { done: true }; + } + return parser(result.value).then(function(parser) { + return { value: parser, done: false }; + }); + }); + } + }; })() } } - const decodeIter = unpackIter; - const encodeIter = packIter; + var decodeIter = unpackIter; + var encodeIter = packIter; - const useRecords = false; - const mapsAsObjects = true; + var useRecords = false; + var mapsAsObjects = true; exports.ALWAYS = ALWAYS; exports.C1 = C1; @@ -2318,5 +2362,4 @@ exports.unpackMultiple = unpackMultiple; exports.useRecords = useRecords; -})); -//# sourceMappingURL=index.js.map +})); \ No newline at end of file diff --git a/scripts/msgpackr.min.js b/scripts/msgpackr.min.js index 0e1db03..7ef5453 100644 --- a/scripts/msgpackr.min.js +++ b/scripts/msgpackr.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).msgpackr={})}(this,(function(e){"use strict";var t,r,n;try{t=new TextDecoder}catch(e){}var i,s,o,u,a,l=0,c={},f=0,h=0,g=[],p={useRecords:!1,mapsAsObjects:!0};class d{}const y=new d;y.name="MessagePack 0xC1";var w=!1,b=2;try{new Function("")}catch(e){b=1/0}class m{constructor(e){e&&(!1===e.useRecords&&void 0===e.mapsAsObjects&&(e.mapsAsObjects=!0),e.sequential&&!1!==e.trusted&&(e.trusted=!0,e.structures||0==e.useRecords||(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(r)return K((()=>(Z(),this?this.unpack(e,t):m.prototype.unpack.call(p,e,t))));e.buffer||e.constructor!==ArrayBuffer||(e="undefined"!=typeof Buffer?Buffer.from(e):new Uint8Array(e)),"object"==typeof t?(n=t.end||e.length,l=t.start||0):(l=0,n=t>-1?t:e.length),h=0,s=null,o=null,r=e;try{a=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(t){if(r=null,e instanceof Uint8Array)throw t;throw new Error("Source must be a Uint8Array or Buffer but was a "+(e&&"object"==typeof e?e.constructor.name:typeof e))}if(this instanceof m){if(c=this,this.structures)return i=this.structures,S(t);(!i||i.length>0)&&(i=[])}else c=p,(!i||i.length>0)&&(i=[]);return S(t)}unpackMultiple(e,t){let r,n=0;try{w=!0;let i=e.length,s=this?this.unpack(e,i):Q.unpack(e,i);if(!t){for(r=[s];le.slice(0))));for(let t=0,r=e.length;t=32&&(r.highByte=t-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let n=e[r],i=t[r];i&&(n&&((e.restoreStructures||(e.restoreStructures=[]))[r]=n),e[r]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function S(e){try{if(!c.trusted&&!w){let e=i.sharedLength||0;en)throw new Error("Unexpected end of MessagePack data");if(!w){let t;try{t=JSON.stringify(e,((e,t)=>"bigint"==typeof t?`${t}n`:t)).slice(0,100)}catch(e){t="(JSON view not available "+e+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw i&&i.restoreStructures&&U(),Z(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||l>n)&&(e.incomplete=!0),e}}function U(){for(let e in i.restoreStructures)i[e]=i.restoreStructures[e];i.restoreStructures=null}function A(){let e=r[l++];if(e<160){if(e<128){if(e<64)return e;{let t=i[63&e]||c.getStructures&&O()[63&e];return t?(t.read||(t.read=E(t,63&e)),t.read()):e}}if(e<144){if(e-=128,c.mapsAsObjects){let t={};for(let r=0;r=l)return s.slice(l-f,(l+=t)-f);if(0==h&&n<140){let e=t<16?V(t):R(t);if(null!=e)return e}return v(t)}{let t;switch(e){case 192:return null;case 193:return o?(t=A(),t>0?o[1].slice(o.position1,o.position1+=t):o[0].slice(o.position0,o.position0-=t)):y;case 194:return!1;case 195:return!0;case 196:if(t=r[l++],void 0===t)throw new Error("Unexpected end of buffer");return N(t);case 197:return t=a.getUint16(l),l+=2,N(t);case 198:return t=a.getUint32(l),l+=4,N(t);case 199:return L(r[l++]);case 200:return t=a.getUint16(l),l+=2,L(t);case 201:return t=a.getUint32(l),l+=4,L(t);case 202:if(t=a.getFloat32(l),c.useFloat32>2){let e=G[(127&r[l])<<1|r[l+1]>>7];return l+=4,(e*t+(t>0?.5:-.5)>>0)/e}return l+=4,t;case 203:return t=a.getFloat64(l),l+=8,t;case 204:return r[l++];case 205:return t=a.getUint16(l),l+=2,t;case 206:return t=a.getUint32(l),l+=4,t;case 207:return"number"===c.int64AsType?(t=4294967296*a.getUint32(l),t+=a.getUint32(l+4)):"string"===c.int64AsType?t=a.getBigUint64(l).toString():"auto"===c.int64AsType?(t=a.getBigUint64(l),t<=BigInt(2)<=BigInt(-2)<=l?s.slice(l-f,(l+=t)-f):_(t);case 218:return t=a.getUint16(l),h>=(l+=2)?s.slice(l-f,(l+=t)-f):B(t);case 219:return t=a.getUint32(l),h>=(l+=4)?s.slice(l-f,(l+=t)-f):x(t);case 220:return t=a.getUint16(l),l+=2,j(t);case 221:return t=a.getUint32(l),l+=4,j(t);case 222:return t=a.getUint16(l),l+=2,M(t);case 223:return t=a.getUint32(l),l+=4,M(t);default:if(e>=224)return e-256;if(void 0===e){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+e)}}}const I=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function E(e,t){function r(){if(r.count++>b){let r=e.read=new Function("r","return function(){return "+(c.freezeData?"Object.freeze":"")+"({"+e.map((e=>"__proto__"===e?"__proto_:r()":I.test(e)?e+":r()":"["+JSON.stringify(e)+"]:r()")).join(",")+"})}")(A);return 0===e.highByte&&(e.read=k(t,e.read)),r()}let n={};for(let t=0,r=e.length;tfunction(){let n=r[l++];if(0===n)return t();let s=e<32?-(e+(n<<5)):e+(n<<5),o=i[s]||O()[s];if(!o)throw new Error("Record id is not defined for "+s);return o.read||(o.read=E(o,e)),o.read()};function O(){let e=K((()=>(r=null,c.getStructures())));return i=c._mergeStructures(e,i)}var v=T,_=T,B=T,x=T;function T(e){let n;if(e<16&&(n=V(e)))return n;if(e>64&&t)return t.decode(r.subarray(l,l+=e));const i=l+e,s=[];for(n="";l65535&&(t-=65536,s.push(t>>>10&1023|55296),t=56320|1023&t),s.push(t)}else s.push(e);s.length>=4096&&(n+=D.apply(String,s),s.length=0)}return s.length>0&&(n+=D.apply(String,s)),n}function j(e){let t=new Array(e);for(let r=0;r0)return void(l=t);n[i]=e}return D.apply(String,n)}function V(e){if(e<4){if(e<2){if(0===e)return"";{let e=r[l++];return(128&e)>1?void(l-=1):D(e)}}{let t=r[l++],n=r[l++];if((128&t)>0||(128&n)>0)return void(l-=2);if(e<3)return D(t,n);let i=r[l++];return(128&i)>0?void(l-=3):D(t,n,i)}}{let t=r[l++],n=r[l++],i=r[l++],s=r[l++];if((128&t)>0||(128&n)>0||(128&i)>0||(128&s)>0)return void(l-=4);if(e<6){if(4===e)return D(t,n,i,s);{let e=r[l++];return(128&e)>0?void(l-=5):D(t,n,i,s,e)}}if(e<8){let o=r[l++],u=r[l++];if((128&o)>0||(128&u)>0)return void(l-=6);if(e<7)return D(t,n,i,s,o,u);let a=r[l++];return(128&a)>0?void(l-=7):D(t,n,i,s,o,u,a)}{let o=r[l++],u=r[l++],a=r[l++],c=r[l++];if((128&o)>0||(128&u)>0||(128&a)>0||(128&c)>0)return void(l-=8);if(e<10){if(8===e)return D(t,n,i,s,o,u,a,c);{let e=r[l++];return(128&e)>0?void(l-=9):D(t,n,i,s,o,u,a,c,e)}}if(e<12){let f=r[l++],h=r[l++];if((128&f)>0||(128&h)>0)return void(l-=10);if(e<11)return D(t,n,i,s,o,u,a,c,f,h);let g=r[l++];return(128&g)>0?void(l-=11):D(t,n,i,s,o,u,a,c,f,h,g)}{let f=r[l++],h=r[l++],g=r[l++],p=r[l++];if((128&f)>0||(128&h)>0||(128&g)>0||(128&p)>0)return void(l-=12);if(e<14){if(12===e)return D(t,n,i,s,o,u,a,c,f,h,g,p);{let e=r[l++];return(128&e)>0?void(l-=13):D(t,n,i,s,o,u,a,c,f,h,g,p,e)}}{let d=r[l++],y=r[l++];if((128&d)>0||(128&y)>0)return void(l-=14);if(e<15)return D(t,n,i,s,o,u,a,c,f,h,g,p,d,y);let w=r[l++];return(128&w)>0?void(l-=15):D(t,n,i,s,o,u,a,c,f,h,g,p,d,y,w)}}}}}function F(){let e,t=r[l++];if(t<192)e=t-160;else switch(t){case 217:e=r[l++];break;case 218:e=a.getUint16(l),l+=2;break;case 219:e=a.getUint32(l),l+=4;break;default:throw new Error("Expected string")}return T(e)}function N(e){return c.copyBuffers?Uint8Array.prototype.slice.call(r,l,l+=e):r.subarray(l,l+=e)}function L(e){let t=r[l++];if(g[t]){let n;return g[t](r.subarray(l,n=l+=e),(e=>{l=e;try{return A()}finally{l=n}}))}throw new Error("Unknown extension type "+t)}var P=new Array(4096);function C(){let e=r[l++];if(!(e>=160&&e<192))return l--,z(A());if(e-=160,h>=l)return s.slice(l-f,(l+=e)-f);if(!(0==h&&n<180))return v(e);let t,i=4095&(e<<5^(e>1?a.getUint16(l):e>0?r[l]:0)),o=P[i],u=l,c=l+e-3,g=0;if(o&&o.bytes==e){for(;u{let r=A().map(z),n=e;void 0!==t&&(e=e<32?-((t<<5)+e):(t<<5)+e,r.highByte=t);let s=i[e];return s&&(s.isShared||w)&&((i.restoreStructures||(i.restoreStructures=[]))[e]=s),i[e]=r,r.read=E(r,n),r.read()};g[0]=()=>{},g[0].noBuffer=!0,g[66]=e=>{let t=e.length,r=BigInt(128&e[0]?e[0]-256:e[0]);for(let n=1;n{let e=A();return(J[e[0]]||Error)(e[1],{cause:e[2]})},g[105]=e=>{if(!1===c.structuredClone)throw new Error("Structured clone extension is disabled");let t=a.getUint32(l-4);u||(u=new Map);let n,i=r[l];n=i>=144&&i<160||220==i||221==i?[]:{};let s={target:n};u.set(t,s);let o=A();return s.used?Object.assign(n,o):(s.target=o,o)},g[112]=e=>{if(!1===c.structuredClone)throw new Error("Structured clone extension is disabled");let t=a.getUint32(l-4),r=u.get(t);return r.used=!0,r.target},g[115]=()=>new Set(A());const $=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((e=>e+"Array"));let Y="object"==typeof globalThis?globalThis:window;g[116]=e=>{let t=e[0],r=$[t];if(!r){if(16===t){let t=new ArrayBuffer(e.length-1);return new Uint8Array(t).set(e.subarray(1)),t}throw new Error("Could not find typed array for code "+t)}return new Y[r](Uint8Array.prototype.slice.call(e,1).buffer)},g[120]=()=>{let e=A();return new RegExp(e[0],e[1])};const q=[];function K(e){let t=n,g=l,p=f,d=h,y=s,b=u,m=o,S=new Uint8Array(r.slice(0,n)),U=i,A=i.slice(0,i.length),I=c,E=w,k=e();return n=t,l=g,f=p,h=d,s=y,u=b,o=m,r=S,w=E,(i=U).splice(0,i.length,...A),c=I,a=new DataView(r.buffer,r.byteOffset,r.byteLength),k}function Z(){r=null,u=null,i=null}g[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],r=l;return l+=t-e.length,o=q,(o=[F(),F()]).position0=0,o.position1=0,o.postBundlePosition=l,l=r,A()},g[255]=e=>4==e.length?new Date(1e3*(16777216*e[0]+(e[1]<<16)+(e[2]<<8)+e[3])):8==e.length?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+1e3*(4294967296*(3&e[3])+16777216*e[4]+(e[5]<<16)+(e[6]<<8)+e[7])):12==e.length?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+1e3*((128&e[4]?-281474976710656:0)+1099511627776*e[6]+4294967296*e[7]+16777216*e[8]+(e[9]<<16)+(e[10]<<8)+e[11])):new Date("invalid");const G=new Array(147);for(let e=0;e<256;e++)G[e]=+("1e"+Math.floor(45.15-.30103*e));const H=m;var Q=new m({useRecords:!1});const X=Q.unpack,ee=Q.unpackMultiple,te=Q.unpack,re={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};let ne,ie,se,oe=new Float32Array(1),ue=new Uint8Array(oe.buffer,0,4);try{ne=new TextEncoder}catch(e){}const ae="undefined"!=typeof Buffer,le=ae?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,ce=ae?Buffer:Uint8Array,fe=ae?4294967296:2144337920;let he,ge,pe,de,ye=0,we=null;const be=/[\u0080-\uFFFF]/,me=Symbol("record-id");class Se extends m{constructor(e){let t,r,n,i;super(e),this.offset=0;let s=ce.prototype.utf8Write?function(e,t){return he.utf8Write(e,t,4294967295)}:!(!ne||!ne.encodeInto)&&function(e,t){return ne.encodeInto(e,he.subarray(t)).written},o=this;e||(e={});let u=e&&e.sequential,a=e.structures||e.saveStructures,l=e.maxSharedStructures;if(null==l&&(l=a?32:0),l>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&null==e.moreTypes&&(this.moreTypes=!0);let c=e.maxOwnStructures;null==c&&(c=a?32:64),this.structures||0==e.useRecords||(this.structures=[]);let f=l>32||c+l>64,h=l+64,g=l+c+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let p=[],d=0,y=0;this.pack=this.encode=function(e,s){if(he||(he=new le(8192),pe=he.dataView||(he.dataView=new DataView(he.buffer,0,8192)),ye=0),de=he.length-10,de-ye<2048?(he=new le(he.length),pe=he.dataView||(he.dataView=new DataView(he.buffer,0,he.length)),de=he.length-10,ye=0):ye=ye+7&2147483640,t=ye,s&Re&&(ye+=255&s),i=o.structuredClone?new Map:null,o.bundleStrings&&"string"!=typeof e?(we=[],we.size=1/0):we=null,n=o.structures,n){n.uninitialized&&(n=o._mergeStructures(o.getStructures()));let e=n.sharedLength||0;if(e>l)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+n.sharedLength);if(!n.transitions){n.transitions=Object.create(null);for(let t=0;te.offset>t.offset?1:-1)),r=e.length,n=-1;for(;u&&r>0;){let i=e[--r].offset+t;iu.position+t?n>=0&&(n+=6):(n>=0&&(pe.setUint32(u.position+t,pe.getUint32(u.position+t)+n),n=-1),u=u.previous,r++)}n>=0&&u&&pe.setUint32(u.position+t,pe.getUint32(u.position+t)+n),ye+=6*e.length,ye>de&&E(ye),o.offset=ye;let s=function(e,t){let r,n=6*t.length,i=e.length-n;for(;r=t.pop();){let t=r.offset,s=r.id;e.copyWithin(t+n,t,i),n-=6;let o=t+n;e[o++]=214,e[o++]=105,e[o++]=s>>24,e[o++]=s>>16&255,e[o++]=s>>8&255,e[o++]=255&s,i=t}return e}(he.subarray(t,ye),e);return i=null,s}return o.offset=ye,s&Me?(he.start=t,he.end=ye,he):he.subarray(t,ye)}catch(e){throw a=e,e}finally{if(n&&(w(),r&&o.saveStructures)){let r=n.sharedLength||0,i=he.subarray(t,ye),u=function(e,t){return e.isCompatible=e=>{let r=!e||(t.lastNamedStructuresLength||0)===e.length;return r||t._mergeStructures(e),r},e}(n,o);if(!a)return!1===o.saveStructures(u,u.isCompatible)?o.pack(e,s):(o.lastNamedStructuresLength=r,he.length>1073741824&&(he=null),i)}he.length>1073741824&&(he=null),s&De&&(ye=t)}};const w=()=>{y<10&&y++;let e=n.sharedLength||0;if(n.length>e&&!u&&(n.length=e),d>1e4)n.transitions=null,y=0,d=0,p.length>0&&(p=[]);else if(p.length>0&&!u){for(let e=0,t=p.length;e{var t=e.length;t<16?he[ye++]=144|t:t<65536?(he[ye++]=220,he[ye++]=t>>8,he[ye++]=255&t):(he[ye++]=221,pe.setUint32(ye,t),ye+=4);for(let r=0;r{ye>de&&(he=E(ye));var r,n=typeof e;if("string"===n){let n,i=e.length;if(we&&i>=4&&i<4096){if((we.size+=i)>21760){let e,r,n=(we[0]?3*we[0].length+we[1].length:0)+10;ye+n>de&&(he=E(ye+n)),we.position?(r=we,he[ye]=200,ye+=3,he[ye++]=98,e=ye-t,ye+=4,Ee(t,m,0),pe.setUint16(e+t-3,ye-t-e)):(he[ye++]=214,he[ye++]=98,e=ye-t,ye+=4),we=["",""],we.previous=r,we.size=0,we.position=e}let r=be.test(e);return we[r?0:1]+=e,he[ye++]=193,void m(r?-i:i)}n=i<32?1:i<256?2:i<65536?3:5;let o=3*i;if(ye+o>de&&(he=E(ye+o)),i<64||!s){let t,s,o,u=ye+n;for(t=0;t>6|192,he[u++]=63&s|128):55296==(64512&s)&&56320==(64512&(o=e.charCodeAt(t+1)))?(s=65536+((1023&s)<<10)+(1023&o),t++,he[u++]=s>>18|240,he[u++]=s>>12&63|128,he[u++]=s>>6&63|128,he[u++]=63&s|128):(he[u++]=s>>12|224,he[u++]=s>>6&63|128,he[u++]=63&s|128);r=u-ye-n}else r=s(e,ye+n);r<32?he[ye++]=160|r:r<256?(n<2&&he.copyWithin(ye+2,ye+1,ye+1+r),he[ye++]=217,he[ye++]=r):r<65536?(n<3&&he.copyWithin(ye+3,ye+2,ye+2+r),he[ye++]=218,he[ye++]=r>>8,he[ye++]=255&r):(n<5&&he.copyWithin(ye+5,ye+3,ye+3+r),he[ye++]=219,pe.setUint32(ye,r),ye+=4),ye+=r}else if("number"===n)if(e>>>0===e)e<32||e<128&&!1===this.useRecords||e<64&&!this.randomAccessStructure?he[ye++]=e:e<256?(he[ye++]=204,he[ye++]=e):e<65536?(he[ye++]=205,he[ye++]=e>>8,he[ye++]=255&e):(he[ye++]=206,pe.setUint32(ye,e),ye+=4);else if(e>>0===e)e>=-32?he[ye++]=256+e:e>=-128?(he[ye++]=208,he[ye++]=e+256):e>=-32768?(he[ye++]=209,pe.setInt16(ye,e),ye+=2):(he[ye++]=210,pe.setInt32(ye,e),ye+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){let r;if(he[ye++]=202,pe.setFloat32(ye,e),t<4||(r=e*G[(127&he[ye])<<1|he[ye+1]>>7])>>0===r)return void(ye+=4);ye--}he[ye++]=203,pe.setFloat64(ye,e),ye+=8}else if("object"===n||"function"===n)if(e){if(i){let r=i.get(e);if(r){if(!r.id){let e=i.idsToInsert||(i.idsToInsert=[]);r.id=e.push(r)}return he[ye++]=214,he[ye++]=112,pe.setUint32(ye,r.id),void(ye+=4)}i.set(e,{offset:ye-t})}let s=e.constructor;if(s===Object)I(e);else if(s===Array)b(e);else if(s===Map)if(this.mapAsEmptyObject)he[ye++]=128;else{(r=e.size)<16?he[ye++]=128|r:r<65536?(he[ye++]=222,he[ye++]=r>>8,he[ye++]=255&r):(he[ye++]=223,pe.setUint32(ye,r),ye+=4);for(let[t,r]of e)m(t),m(r)}else{for(let t=0,r=ie.length;t(he=i,i=null,ye+=e,ye>de&&E(ye),{target:he,targetView:pe,position:ye-e})),m)}finally{i&&(he=i,pe=s,ye=o,de=he.length-10)}return void(n&&(n.length+ye>de&&E(n.length+ye),ye=Ie(n,he,ye,r.type)))}}if(Array.isArray(e))b(e);else{if(e.toJSON){const t=e.toJSON();if(t!==e)return m(t)}if("function"===n)return m(this.writeFunction&&this.writeFunction(e));I(e)}}}else he[ye++]=192;else if("boolean"===n)he[ye++]=e?195:194;else if("bigint"===n){if(e=-(BigInt(1)<0)he[ye++]=207,pe.setBigUint64(ye,e);else{if(!this.largeBigIntToFloat){if(this.useBigIntExtension&&e-(BigInt(2)**BigInt(1023))){he[ye++]=199,ye++,he[ye++]=66;let t,r=[];do{let n=BigInt(0xff)&e;t=(BigInt(0x80)&n)===(e>=BigInt(8)}while(BigInt(0)!==e&&-BigInt(1)!==e||!t);he[ye-2]=r.length;for(let e=r.length;e>0;)he[ye++]=Number(r[--e]);return}throw new RangeError(e+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension or set largeBigIntToFloat to convert to float-64")}he[ye++]=203,pe.setFloat64(ye,Number(e))}ye+=8}else{if("undefined"!==n)throw new Error("Unknown type: "+n);this.encodeUndefinedAsNil?he[ye++]=192:(he[ye++]=212,he[ye++]=0,he[ye++]=0)}},S=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let r in e)"function"==typeof e.hasOwnProperty&&!e.hasOwnProperty(r)||this.skipValues.includes(e[r])||t.push(r)}else t=Object.keys(e);let r,n=t.length;if(n<16?he[ye++]=128|n:n<65536?(he[ye++]=222,he[ye++]=n>>8,he[ye++]=255&n):(he[ye++]=223,pe.setUint32(ye,n),ye+=4),this.coercibleKeyAsNumber)for(let i=0;i{he[ye++]=222;let r=ye-t;ye+=2;let n=0;for(let t in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(t))&&(m(t),m(e[t]),n++);he[r+++t]=n>>8,he[r+t]=255&n},U=!1===this.useRecords?S:e.progressiveRecords&&!f?e=>{let r,i,s=n.transitions||(n.transitions=Object.create(null)),o=ye++-t;for(let u in e)if("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(u)){if(r=s[u],r)s=r;else{let a=Object.keys(e),l=s;s=n.transitions;let c=0;for(let e=0,t=a.length;e{let t,r=n.transitions||(n.transitions=Object.create(null)),i=0;for(let n in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(n))&&(t=r[n],t||(t=r[n]=Object.create(null),i++),r=t);let s=r[me];s?s>=96&&f?(he[ye++]=96+(31&(s-=96)),he[ye++]=s>>5):he[ye++]=s:k(r,r.__keys__||Object.keys(e),i);for(let t in e)("function"!=typeof e.hasOwnProperty||e.hasOwnProperty(t))&&m(e[t])},A="function"==typeof this.useRecords&&this.useRecords,I=A?e=>{A(e)?U(e):S(e)}:U,E=e=>{let r;if(e>16777216){if(e-t>fe)throw new Error("Packed buffer would be larger than maximum buffer size");r=Math.min(fe,4096*Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096))}else r=1+(Math.max(e-t<<2,he.length-1)>>12)<<12;let n=new le(r);return pe=n.dataView||(n.dataView=new DataView(n.buffer,0,r)),e=Math.min(e,he.length),he.copy?he.copy(n,0,t,e):n.set(he.slice(t,e)),ye-=t,t=0,de=n.length-10,he=n},k=(e,t,i)=>{let s=n.nextId;s||(s=64),s=g&&(s=h),n.nextId=s+1);let o=t.highByte=s>=96&&f?s-96>>5:-1;e[me]=s,e.__keys__=t,n[s-64]=t,s=0?(he[ye++]=96+(31&s),he[ye++]=o):he[ye++]=s):(o>=0?(he[ye++]=213,he[ye++]=114,he[ye++]=96+(31&s),he[ye++]=o):(he[ye++]=212,he[ye++]=114,he[ye++]=s),i&&(d+=y*i),p.length>=c&&(p.shift()[me]=0),p.push(e),m(t))},O=(e,r,n,i)=>{let s=he,o=ye,u=de,a=t;he=ge,ye=0,t=0,he||(ge=he=new le(8192)),de=he.length-10,k(e,r,i),ge=he;let l=ye;if(he=s,ye=o,de=u,t=a,l>1){let e=ye+l-1;e>de&&E(e);let r=n+t;he.copyWithin(r+l,r+1,ye),he.set(ge.slice(0,l),r),ye=e}else he[n+t]=ge[0]},v=e=>{let i=undefined(e,he,t,ye,n,E,((e,t,n)=>{if(n)return r=!0;ye=t;let i=he;return m(e),w(),i!==he?{position:ye,targetView:pe,target:he}:ye}),this);if(0===i)return I(e);ye=i}}useBuffer(e){he=e,he.dataView||(he.dataView=new DataView(he.buffer,he.byteOffset,he.byteLength)),ye=0}set position(e){ye=e}get position(){return ye}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}function Ue(e,t,r,n){let i=e.byteLength;if(i+1<256){var{target:s,position:o}=r(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=r(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:u}=r(7+i);s[o++]=201,u.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=t,e.buffer||(e=new Uint8Array(e)),s.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function Ae(e,t){let r=e.byteLength;var n,i;if(r<256){var{target:n,position:i}=t(r+2);n[i++]=196,n[i++]=r}else if(r<65536){var{target:n,position:i}=t(r+3);n[i++]=197,n[i++]=r>>8,n[i++]=255&r}else{var{target:n,position:i,targetView:s}=t(r+5);n[i++]=198,s.setUint32(i,r),i+=4}n.set(e,i)}function Ie(e,t,r,n){let i=e.length;switch(i){case 1:t[r++]=212;break;case 2:t[r++]=213;break;case 4:t[r++]=214;break;case 8:t[r++]=215;break;case 16:t[r++]=216;break;default:i<256?(t[r++]=199,t[r++]=i):i<65536?(t[r++]=200,t[r++]=i>>8,t[r++]=255&i):(t[r++]=201,t[r++]=i>>24,t[r++]=i>>16&255,t[r++]=i>>8&255,t[r++]=255&i)}return t[r++]=n,t.set(e,r),r+=i}function Ee(e,t,r){if(we.length>0){pe.setUint32(we.position+e,ye+r-we.position-e),we.stringsPosition=ye-e;let n=we;we=null,t(n[0]),t(n[1])}}se=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,d],ie=[{pack(e,t,r){let n=e.getTime()/1e3;if((this.useTimestamp32||0===e.getMilliseconds())&&n>=0&&n<4294967296){let{target:e,targetView:r,position:i}=t(6);e[i++]=214,e[i++]=255,r.setUint32(i,n)}else if(n>0&&n<4294967296){let{target:r,targetView:i,position:s}=t(10);r[s++]=215,r[s++]=255,i.setUint32(s,4e6*e.getMilliseconds()+(n/1e3/4294967296>>0)),i.setUint32(s+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),r(this.onInvalidDate());let{target:e,targetView:n,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:r,targetView:i,position:s}=t(15);r[s++]=199,r[s++]=12,r[s++]=255,i.setUint32(s,1e6*e.getMilliseconds()),i.setBigInt64(s+4,BigInt(Math.floor(n)))}}},{pack(e,t,r){if(this.setAsEmptyObject)return t(0),r({});let n=Array.from(e),{target:i,position:s}=t(this.moreTypes?3:0);this.moreTypes&&(i[s++]=212,i[s++]=115,i[s++]=0),r(n)}},{pack(e,t,r){let{target:n,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(n[i++]=212,n[i++]=101,n[i++]=0),r([e.name,e.message,e.cause])}},{pack(e,t,r){let{target:n,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(n[i++]=212,n[i++]=120,n[i++]=0),r([e.source,e.flags])}},{pack(e,t){this.moreTypes?Ue(e,16,t):Ae(ae?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let r=e.constructor;r!==ce&&this.moreTypes?Ue(e,$.indexOf(r.name),t):Ae(e,t)}},{pack(e,t){let{target:r,position:n}=t(1);r[n]=193}}];let ke=new Se({useRecords:!1});const Oe=ke.pack,ve=ke.pack,_e=Se,{NEVER:Be,ALWAYS:xe,DECIMAL_ROUND:Te,DECIMAL_FIT:je}=re,Me=512,De=1024,Re=2048;const Ve=function(e,t={}){if(!e||"object"!=typeof e)throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");const r=new m(t);let n;const i=e=>{let t;n&&(e=Buffer.concat([n,e]),n=void 0);try{t=r.unpackMultiple(e)}catch(r){if(!r.incomplete)throw r;n=e.slice(r.lastPosition),t=r.values}return t};return"function"==typeof e[Symbol.iterator]?function*(){for(const t of e)yield*i(t)}():"function"==typeof e[Symbol.asyncIterator]?function(){function e(t){return t&&"function"==typeof t.then?t:Promise.resolve(t)}function n(t){return t&&"function"==typeof t.next?t:{next:function(){return{done:!0}}}}function r(t){return new Promise(function(r,o){function i(u){try{c(t.next(u))}catch(t){o(t)}}function c(t){t.done?r(t.value):e(t.value).then(i,o)}c((t=t.apply(void 0,arguments)).next())})}r(function*(){for(var t=n(e);!t.done;)yield i(t.value)})}():void 0},Fe=function(e,t={}){if(e&&"object"==typeof e){if("function"==typeof e[Symbol.iterator])return function*(e,t){const r=new Se(t);for(const t of e)yield r.pack(t)}(e,t);if("function"==typeof e.then||"function"==typeof e[Symbol.asyncIterator])return function(e,t){var r=new Se(t);return Promise.resolve(e).then(function(e){return e.map(function(t){return r.pack(t)})})}(e,t);throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable")};e.ALWAYS=xe,e.C1=y,e.DECIMAL_FIT=je,e.DECIMAL_ROUND=Te,e.Decoder=H,e.Encoder=_e,e.FLOAT32_OPTIONS=re,e.NEVER=Be,e.Packr=Se,e.RESERVE_START_SPACE=Re,e.RESET_BUFFER_MODE=De,e.REUSE_BUFFER_MODE=Me,e.Unpackr=m,e.addExtension=function(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");se.unshift(e.Class),ie.unshift(e)}!function(e){e.unpack?g[e.type]=e.unpack:g[e.type]=e}(e)},e.clearSource=Z,e.decode=te,e.decodeIter=Ve,e.encode=ve,e.encodeIter=Fe,e.isNativeAccelerationEnabled=!1,e.mapsAsObjects=!0,e.pack=Oe,e.roundFloat32=function(e){oe[0]=e;let t=G[(127&ue[3])<<1|ue[2]>>7];return(t*e+(e>0?.5:-.5)>>0)/t},e.unpack=X,e.unpackMultiple=ee,e.useRecords=!1})); +(function(m,rr){typeof exports=="object"&&typeof module!="undefined"?rr(exports):typeof define=="function"&&define.amd?define(["exports"],rr):(m=typeof globalThis!="undefined"?globalThis:m||self,rr(m.msgpackr={}))})(this,function(m){"use strict";var rr;try{rr=new TextDecoder}catch(r){}var v,$,n=0,E={},S,G,q=0,Z=0,M,z,N=[],y,Cr={useRecords:!1,mapsAsObjects:!0};class Fr{}var Ur=new Fr;Ur.name="MessagePack 0xC1";var H=!1,Vr=2,Lr;try{new Function("")}catch(r){Vr=1/0}class Q{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(v)return Qr(function(){return lr(),this?this.unpack(e,t):Q.prototype.unpack.call(Cr,e,t)});!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer!="undefined"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?($=t.end||e.length,n=t.start||0):(n=0,$=t>-1?t:e.length),Z=0,G=null,M=null,v=e;try{y=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(a){throw v=null,e instanceof Uint8Array?a:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Q){if(E=this,this.structures)return S=this.structures,xr(t);(!S||S.length>0)&&(S=[])}else E=Cr,(!S||S.length>0)&&(S=[]);return xr(t)}unpackMultiple(e,t){var a,f=0;try{H=!0;var u=e.length,x=this?this.unpack(e,u):hr.unpack(e,u);if(t){if(t(x,f,n)===!1)return;for(;n=32&&(u.highByte=a-32>>5))}e.sharedLength=e.length;for(var x in t||[])if(x>=0){var u=e[x],h=t[x];h&&(u&&((e.restoreStructures||(e.restoreStructures=[]))[x]=u),e[x]=h)}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function xr(r){try{if(!E.trusted&&!H){var e=S.sharedLength||0;e=32&&Lr?(t=Lr(v,n,$,E),v=null,!(r&&r.lazy)&&t&&(t=t.toJSON()),n=$):t=B(),M&&(n=M.postBundlePosition,M=null),H&&(S.restoreStructures=null),n==$)S&&S.restoreStructures&&Pr(),S=null,v=null,z&&(z=null);else{if(n>$)throw new Error("Unexpected end of MessagePack data");if(!H){var a;try{a=JSON.stringify(t,function(f,u){return typeof u=="bigint"?`${u}n`:u}).slice(0,100)}catch(f){a="(JSON view not available "+f+")"}throw new Error("Data read, but end of buffer not reached "+a)}}return t}catch(f){throw S&&S.restoreStructures&&Pr(),lr(),(f instanceof RangeError||f.message.startsWith("Unexpected end of buffer")||n>$)&&(f.incomplete=!0),f}}function Pr(){for(var r in S.restoreStructures)S[r]=S.restoreStructures[r];S.restoreStructures=null}function B(){var r=v[n++];if(r<160)if(r<128){if(r<64)return r;var e=S[r&63]||E.getStructures&&jr()[r&63];return e?(e.read||(e.read=Ar(e,r&63)),e.read()):r}else if(r<144)if(r-=128,E.mapsAsObjects){for(var t={},a=0;a=n)return G.slice(n-q,(n+=h)-q);if(Z==0&&$<140){var w=h<16?Or(h):Kr(h);if(w!=null)return w}return Ir(h)}else{var o;switch(r){case 192:return null;case 193:return M?(o=B(),o>0?M[1].slice(M.position1,M.position1+=o):M[0].slice(M.position0,M.position0-=o)):Ur;case 194:return!1;case 195:return!0;case 196:if(o=v[n++],o===void 0)throw new Error("Unexpected end of buffer");return kr(o);case 197:return o=y.getUint16(n),n+=2,kr(o);case 198:return o=y.getUint32(n),n+=4,kr(o);case 199:return er(v[n++]);case 200:return o=y.getUint16(n),n+=2,er(o);case 201:return o=y.getUint32(n),n+=4,er(o);case 202:if(o=y.getFloat32(n),E.useFloat32>2){var O=vr[(v[n]&127)<<1|v[n+1]>>7];return n+=4,(O*o+(o>0?.5:-.5)>>0)/O}return n+=4,o;case 203:return o=y.getFloat64(n),n+=8,o;case 204:return v[n++];case 205:return o=y.getUint16(n),n+=2,o;case 206:return o=y.getUint32(n),n+=4,o;case 207:return E.int64AsType==="number"?(o=y.getUint32(n)*4294967296,o+=y.getUint32(n+4)):E.int64AsType==="string"?o=y.getBigUint64(n).toString():E.int64AsType==="auto"?(o=y.getBigUint64(n),o<=BigInt(2)<=BigInt(-2)<=n?G.slice(n-q,(n+=o)-q):Se(o);case 218:return o=y.getUint16(n),n+=2,Z>=n?G.slice(n-q,(n+=o)-q):me(o);case 219:return o=y.getUint32(n),n+=4,Z>=n?G.slice(n-q,(n+=o)-q):be(o);case 220:return o=y.getUint16(n),n+=2,$r(o);case 221:return o=y.getUint32(n),n+=4,$r(o);case 222:return o=y.getUint16(n),n+=2,qr(o);case 223:return o=y.getUint32(n),n+=4,qr(o);default:if(r>=224)return r-256;if(r===void 0){var P=new Error("Unexpected end of MessagePack data");throw P.incomplete=!0,P}throw new Error("Unknown MessagePack token "+r)}}}var pe=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ar(r,e){function t(){if(a.count++>Vr){var a=r.read=new Function("r","return function(){return "+(E.freezeData?"Object.freeze":"")+"({"+r.map(function(w){return w==="__proto__"?"__proto_:r()":pe.test(w)?w+":r()":"["+JSON.stringify(w)+"]:r()"}).join(",")+"})}")(B);return r.highByte===0&&(r.read=Jr(e,r.read)),a()}for(var f={},u=0,x=r.length;u64&&rr)return rr.decode(v.subarray(n,n+=r));var t=n+r,a=[];for(e="";n65535&&(w-=65536,a.push(w>>>10&1023|55296),w=56320|w&1023),a.push(w)}else a.push(f);a.length>=4096&&(e+=T.apply(String,a),a.length=0)}return a.length>0&&(e+=T.apply(String,a)),e}function $r(r){for(var e=new Array(r),t=0;t0){n=e;return}t[a]=f}return T.apply(String,t)}function Or(r){if(r<4)if(r<2){if(r===0)return"";var e=v[n++];if((e&128)>1){n-=1;return}return T(e)}else{var e=v[n++],t=v[n++];if((e&128)>0||(t&128)>0){n-=2;return}if(r<3)return T(e,t);var a=v[n++];if((a&128)>0){n-=3;return}return T(e,t,a)}else{var e=v[n++],t=v[n++],a=v[n++],f=v[n++];if((e&128)>0||(t&128)>0||(a&128)>0||(f&128)>0){n-=4;return}if(r<6){if(r===4)return T(e,t,a,f);var u=v[n++];if((u&128)>0){n-=5;return}return T(e,t,a,f,u)}else if(r<8){var u=v[n++],x=v[n++];if((u&128)>0||(x&128)>0){n-=6;return}if(r<7)return T(e,t,a,f,u,x);var h=v[n++];if((h&128)>0){n-=7;return}return T(e,t,a,f,u,x,h)}else{var u=v[n++],x=v[n++],h=v[n++],w=v[n++];if((u&128)>0||(x&128)>0||(h&128)>0||(w&128)>0){n-=8;return}if(r<10){if(r===8)return T(e,t,a,f,u,x,h,w);var o=v[n++];if((o&128)>0){n-=9;return}return T(e,t,a,f,u,x,h,w,o)}else if(r<12){var o=v[n++],O=v[n++];if((o&128)>0||(O&128)>0){n-=10;return}if(r<11)return T(e,t,a,f,u,x,h,w,o,O);var k=v[n++];if((k&128)>0){n-=11;return}return T(e,t,a,f,u,x,h,w,o,O,k)}else{var o=v[n++],O=v[n++],k=v[n++],P=v[n++];if((o&128)>0||(O&128)>0||(k&128)>0||(P&128)>0){n-=12;return}if(r<14){if(r===12)return T(e,t,a,f,u,x,h,w,o,O,k,P);var j=v[n++];if((j&128)>0){n-=13;return}return T(e,t,a,f,u,x,h,w,o,O,k,P,j)}else{var j=v[n++],X=v[n++];if((j&128)>0||(X&128)>0){n-=14;return}if(r<15)return T(e,t,a,f,u,x,h,w,o,O,k,P,j,X);var K=v[n++];if((K&128)>0){n-=15;return}return T(e,t,a,f,u,x,h,w,o,O,k,P,j,X,K)}}}}}function Yr(){var r=v[n++],e;if(r<192)e=r-160;else switch(r){case 217:e=v[n++];break;case 218:e=y.getUint16(n),n+=2;break;case 219:e=y.getUint32(n),n+=4;break;default:throw new Error("Expected string")}return ar(e)}function kr(r){return E.copyBuffers?Uint8Array.prototype.slice.call(v,n,n+=r):v.subarray(n,n+=r)}function er(r){var e=v[n++];if(N[e]){var t;return N[e](v.subarray(n,t=n+=r),function(a){n=a;try{return B()}finally{n=t}})}else throw new Error("Unknown extension type "+e)}var Zr=new Array(4096);function zr(){var r=v[n++];if(r>=160&&r<192){if(r=r-160,Z>=n)return G.slice(n-q,(n+=r)-q);if(!(Z==0&&$<180))return Ir(r)}else return n--,Xr(B());var e=(r<<5^(r>1?y.getUint16(n):r>0?v[n]:0))&4095,t=Zr[e],a=n,f=n+r-3,u,x=0;if(t&&t.bytes==r){for(;a=144&&t<160||t==220||t==221?a=[]:a={};var f={target:a};z.set(e,f);var u=B();return f.used?Object.assign(a,u):(f.target=u,u)},N[112]=function(r){if(E.structuredClone===!1)throw new Error("Structured clone extension is disabled");var e=y.getUint32(n-4),t=z.get(e);return t.used=!0,t.target},N[115]=function(){new Set(B())};var Hr=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(function(r){return r+"Array"}),Ae=typeof globalThis=="object"?globalThis:window;N[116]=function(r){var e=r[0],t=Hr[e];if(!t){if(e===16){var a=new ArrayBuffer(r.length-1),f=new Uint8Array(a);return f.set(r.subarray(1)),a}throw new Error("Could not find typed array for code "+e)}return new Ae[t](Uint8Array.prototype.slice.call(r,1).buffer)},N[120]=function(){var r=B();return new RegExp(r[0],r[1])};var Ie=[];N[98]=function(r){var e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=n;return n+=e-r.length,M=Ie,M=[Yr(),Yr()],M.position0=0,M.position1=0,M.postBundlePosition=n,n=t,B()},N[255]=function(r){return r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid")};function Qr(r){var e=$,t=n,a=q,f=Z,u=G,x=z,h=M,w=new Uint8Array(v.slice(0,$)),o=S,O=S.slice(0,S.length),k=E,P=H,j=r();$=e,n=t,q=a,Z=f,G=u,z=x,M=h,v=w,H=P,S=o;for(var X of O)S.splice(0,S.length,X);return E=k,y=new DataView(v.buffer,v.byteOffset,v.byteLength),j}function lr(){v=null,z=null,S=null}function Oe(r){r.unpack?N[r.type]=r.unpack:N[r.type]=r}for(var vr=new Array(147),dr=0;dr<256;dr++)vr[dr]=+("1e"+Math.floor(45.15-dr*.30103));var ke=Q,hr=new Q({useRecords:!1}),_e=hr.unpack,Be=hr.unpackMultiple,Re=hr.unpack,Wr={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},re=new Float32Array(1),ee=new Uint8Array(re.buffer,0,4);function Me(r){re[0]=r;var e=vr[(ee[3]&127)<<1|ee[2]>>7];return(e*r+(r>0?.5:-.5)>>0)/e}var gr;try{gr=new TextEncoder}catch(r){}var yr,_r,wr=typeof Buffer!="undefined",pr=wr?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,te=wr?Buffer:Uint8Array,ne=wr?4294967296:2144337920,s,sr,U,i=0,L,I=null,Te,De=21760,Ne=/[\u0080-\uFFFF]/,nr=Symbol("record-id");class cr extends Q{constructor(e){super(e),this.offset=0;var t,a,f,u,x=te.prototype.utf8Write?function(c,d){return s.utf8Write(c,d,4294967295)}:gr&&gr.encodeInto?function(c,d){return gr.encodeInto(c,s.subarray(d)).written}:!1,h=this;e||(e={});var w=e&&e.sequential,o=e.structures||e.saveStructures,O=e.maxSharedStructures;if(O==null&&(O=o?32:0),O>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);var k=e.maxOwnStructures;k==null&&(k=o?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);var P=O>32||k+O>64,j=O+64,X=O+k+64;if(X>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");var K=[],Br=0,Sr=0;this.pack=this.encode=function(c,d){if(s||(s=new pr(8192),U=s.dataView||(s.dataView=new DataView(s.buffer,0,8192)),i=0),L=s.length-10,L-i<2048?(s=new pr(s.length),U=s.dataView||(s.dataView=new DataView(s.buffer,0,s.length)),L=s.length-10,i=0):i=i+7&2147483640,t=i,d&oe&&(i+=d&255),u=h.structuredClone?new Map:null,h.bundleStrings&&typeof c!="string"?(I=[],I.size=1/0):I=null,f=h.structures,f){f.uninitialized&&(f=h._mergeStructures(h.getStructures()));var l=f.sharedLength||0;if(l>O)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+f.sharedLength);if(!f.transitions){f.transitions=Object.create(null);for(var g=0;gNr.offset}),g=V.length,Y=-1;F&&g>0;){var ur=V[--g].offset+t;urF.position+t?Y>=0&&(Y+=6):(Y>=0&&(U.setUint32(F.position+t,U.getUint32(F.position+t)+Y),Y=-1),F=F.previous,g++)}Y>=0&&F&&U.setUint32(F.position+t,U.getUint32(F.position+t)+Y),i+=V.length*6,i>L&&W(i),h.offset=i;var tr=Fe(s.subarray(t,i),V);return u=null,tr}return h.offset=i,d&ce?(s.start=t,s.end=i,s):s.subarray(t,i)}catch(br){throw A=br,br}finally{if(f&&(xe(),a&&h.saveStructures)){var l=f.sharedLength||0,Tr=s.subarray(t,i),fr=Le(f,h);if(!A)return h.saveStructures(fr,fr.isCompatible)===!1?h.pack(c,d):(h.lastNamedStructuresLength=l,s.length>1073741824&&(s=null),Tr)}s.length>1073741824&&(s=null),d&ue&&(i=t)}};var xe=function(){Sr<10&&Sr++;var c=f.sharedLength||0;if(f.length>c&&!w&&(f.length=c),Br>1e4)f.transitions=null,Sr=0,Br=0,K.length>0&&(K=[]);else if(K.length>0&&!w){for(var d=0,l=K.length;d>8,s[i++]=d&255):(s[i++]=221,U.setUint32(i,d),i+=4);for(var l=0;lL&&(s=W(i));var d=typeof c,l;if(d==="string"){var g=c.length;if(I&&g>=4&&g<4096){if((I.size+=g)>De){var p,C=(I[0]?I[0].length*3+I[1].length:0)+10;i+C>L&&(s=W(i+C));var b;I.position?(b=I,s[i]=200,i+=3,s[i++]=98,p=i-t,i+=4,ae(t,R,0),U.setUint16(p+t-3,i-t-p)):(s[i++]=214,s[i++]=98,p=i-t,i+=4),I=["",""],I.previous=b,I.size=0,I.position=p}var J=Ne.test(c);I[J?0:1]+=c,s[i++]=193,R(J?-g:g);return}var D;g<32?D=1:g<256?D=2:g<65536?D=3:D=5;var C=g*3;if(i+C>L&&(s=W(i+C)),g<64||!x){var _,A,F,V=i+D;for(_=0;_>6|192,s[V++]=A&63|128):(A&64512)===55296&&((F=c.charCodeAt(_+1))&64512)===56320?(A=65536+((A&1023)<<10)+(F&1023),_++,s[V++]=A>>18|240,s[V++]=A>>12&63|128,s[V++]=A>>6&63|128,s[V++]=A&63|128):(s[V++]=A>>12|224,s[V++]=A>>6&63|128,s[V++]=A&63|128);l=V-i-D}else l=x(c,i+D);l<32?s[i++]=160|l:l<256?(D<2&&s.copyWithin(i+2,i+1,i+1+l),s[i++]=217,s[i++]=l):l<65536?(D<3&&s.copyWithin(i+3,i+2,i+2+l),s[i++]=218,s[i++]=l>>8,s[i++]=l&255):(D<5&&s.copyWithin(i+5,i+3,i+3+l),s[i++]=219,U.setUint32(i,l),i+=4),i+=l}else if(d==="number")if(c>>>0===c)c<32||c<128&&this.useRecords===!1||c<64&&!this.randomAccessStructure?s[i++]=c:c<256?(s[i++]=204,s[i++]=c):c<65536?(s[i++]=205,s[i++]=c>>8,s[i++]=c&255):(s[i++]=206,U.setUint32(i,c),i+=4);else if(c>>0===c)c>=-32?s[i++]=256+c:c>=-128?(s[i++]=208,s[i++]=c+256):c>=-32768?(s[i++]=209,U.setInt16(i,c),i+=2):(s[i++]=210,U.setInt32(i,c),i+=4);else{var Y;if((Y=this.useFloat32)>0&&c<4294967296&&c>=-2147483648){s[i++]=202,U.setFloat32(i,c);var ur;if(Y<4||(ur=c*vr[(s[i]&127)<<1|s[i+1]>>7])>>0===ur){i+=4;return}else i--}s[i++]=203,U.setFloat64(i,c),i+=8}else if(d==="object"||d==="function")if(!c)s[i++]=192;else{if(u){var tr=u.get(c);if(tr){if(!tr.id){var Tr=u.idsToInsert||(u.idsToInsert=[]);tr.id=Tr.push(tr)}s[i++]=214,s[i++]=112,U.setUint32(i,tr.id),i+=4;return}else u.set(c,{offset:i-t})}var fr=c.constructor;if(fr===Object)mr(c);else if(fr===Array)Rr(c);else if(fr===Map)if(this.mapAsEmptyObject)s[i++]=128;else{l=c.size,l<16?s[i++]=128|l:l<65536?(s[i++]=222,s[i++]=l>>8,s[i++]=l&255):(s[i++]=223,U.setUint32(i,l),i+=4);for(var[br,Dr]of c)R(br),R(Dr)}else{for(var _=0,Nr=yr.length;_L&&W(i),{target:s,targetView:U,position:i-we}},R)}finally{Er&&(s=Er,U=nt,i=ft,L=s.length-10)}or&&(or.length+i>L&&W(or.length+i),i=Ce(or,s,i,ir.type));return}}if(Array.isArray(c))Rr(c);else{if(c.toJSON){var ye=c.toJSON();if(ye!==c)return R(ye)}if(d==="function")return R(this.writeFunction&&this.writeFunction(c));mr(c)}}}else if(d==="boolean")s[i++]=c?195:194;else if(d==="bigint"){if(c=-(BigInt(1)<0)s[i++]=207,U.setBigUint64(i,c);else if(this.largeBigIntToFloat)s[i++]=203,U.setFloat64(i,Number(c));else throw new RangeError(c+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension or set largeBigIntToFloat to convert to float-64");i+=8}else if(d==="undefined")this.encodeUndefinedAsNil?s[i++]=192:(s[i++]=212,s[i++]=0,s[i++]=0);else throw new Error("Unknown type: "+d)},le=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?function(c){var d;if(this.skipValues){d=[];for(var g in c)(typeof c.hasOwnProperty!="function"||c.hasOwnProperty(g))&&!this.skipValues.includes(c[g])&&d.push(g)}else d=Object.keys(c);var l=d.length;l<16?s[i++]=128|l:l<65536?(s[i++]=222,s[i++]=l>>8,s[i++]=l&255):(s[i++]=223,U.setUint32(i,l),i+=4);var g;if(this.coercibleKeyAsNumber)for(var p=0;p>8,s[d+t]=l&255},ve=this.useRecords===!1?le:e.progressiveRecords&&!P?function(c){var d,l=f.transitions||(f.transitions=Object.create(null)),g=i++-t,p;for(var b in c)if(typeof c.hasOwnProperty!="function"||c.hasOwnProperty(b)){if(d=l[b],d)l=d;else{var J=Object.keys(c),D=l;l=f.transitions;for(var C=0,_=0,A=J.length;_=96&&P?(s[i++]=((b-=96)&31)+96,s[i++]=b>>5):s[i++]=b:Mr(l,l.__keys__||Object.keys(c),g);for(var p in c)(typeof c.hasOwnProperty!="function"||c.hasOwnProperty(p))&&R(c[p])},de=typeof this.useRecords=="function"&&this.useRecords,mr=de?function(c){de(c)?ve(c):le(c)}:ve,W=function(c){var d;if(c>16777216){if(c-t>ne)throw new Error("Packed buffer would be larger than maximum buffer size");d=Math.min(ne,Math.round(Math.max((c-t)*(c>67108864?1.25:2),4194304)/4096)*4096)}else d=(Math.max(c-t<<2,s.length-1)>>12)+1<<12;var l=new pr(d);return U=l.dataView||(l.dataView=new DataView(l.buffer,0,d)),c=Math.min(c,s.length),s.copy?s.copy(l,0,t,c):l.set(s.slice(t,c)),i-=t,t=0,L=l.length-10,s=l},Mr=function(c,d,l){var g=f.nextId;g||(g=64),g=X&&(g=j),f.nextId=g+1);var p=d.highByte=g>=96&&P?g-96>>5:-1;c[nr]=g,c.__keys__=d,f[g-64]=d,g=0?(s[i++]=(g&31)+96,s[i++]=p):s[i++]=g):(p>=0?(s[i++]=213,s[i++]=114,s[i++]=(g&31)+96,s[i++]=p):(s[i++]=212,s[i++]=114,s[i++]=g),l&&(Br+=Sr*l),K.length>=k&&(K.shift()[nr]=0),K.push(c),R(d))},he=function(c,d,l,g){var p=s,b=i,J=L,D=t;s=sr,i=0,t=0,s||(sr=s=new pr(8192)),L=s.length-10,Mr(c,d,g),sr=s;var C=i;if(s=p,i=b,L=J,t=D,C>1){var _=i+C-1;_>L&&W(_);var A=l+t;s.copyWithin(A+C,A+1,i),s.set(sr.slice(0,C),A),i=_}else s[l+t]=sr[0]},et=function(c){var d=Te(c,s,t,i,f,W,function(l,g,p){if(p)return a=!0;i=g;var b=s;return R(l),xe(),b!==s?{position:i,targetView:U,target:s}:i},this);if(d===0)return mr(c);i=d}}useBuffer(e){s=e,s.dataView||(s.dataView=new DataView(s.buffer,s.byteOffset,s.byteLength)),i=0}set position(e){i=e}get position(){return i}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}_r=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Fr],yr=[{pack(r,e,t){var a=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&a>=0&&a<4294967296){var{target:f,targetView:u,position:x}=e(6);f[x++]=214,f[x++]=255,u.setUint32(x,a)}else if(a>0&&a<4294967296){var{target:f,targetView:u,position:x}=e(10);f[x++]=215,f[x++]=255,u.setUint32(x,r.getMilliseconds()*4e6+(a/1e3/4294967296>>0)),u.setUint32(x+4,a)}else if(isNaN(a)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());var{target:f,targetView:u,position:x}=e(3);f[x++]=212,f[x++]=255,f[x++]=255}else{var{target:f,targetView:u,position:x}=e(15);f[x++]=199,f[x++]=12,f[x++]=255,u.setUint32(x,r.getMilliseconds()*1e6),u.setBigInt64(x+4,BigInt(Math.floor(a)))}}},{pack(r,e,t){if(this.setAsEmptyObject)return e(0),t({});var a=Array.from(r),{target:f,position:u}=e(this.moreTypes?3:0);this.moreTypes&&(f[u++]=212,f[u++]=115,f[u++]=0),t(a)}},{pack(r,e,t){var{target:a,position:f}=e(this.moreTypes?3:0);this.moreTypes&&(a[f++]=212,a[f++]=101,a[f++]=0),t([r.name,r.message,r.cause])}},{pack(r,e,t){var{target:a,position:f}=e(this.moreTypes?3:0);this.moreTypes&&(a[f++]=212,a[f++]=120,a[f++]=0),t([r.source,r.flags])}},{pack(r,e){this.moreTypes?fe(r,16,e):ie(wr?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){var t=r.constructor;t!==te&&this.moreTypes?fe(r,Hr.indexOf(t.name),e):ie(r,e)}},{pack(r,e){var{target:t,position:a}=e(1);t[a]=193}}];function fe(r,e,t,a){var f=r.byteLength;if(f+1<256){var{target:u,position:x}=t(4+f);u[x++]=199,u[x++]=f+1}else if(f+1<65536){var{target:u,position:x}=t(5+f);u[x++]=200,u[x++]=f+1>>8,u[x++]=f+1&255}else{var{target:u,position:x,targetView:h}=t(7+f);u[x++]=201,h.setUint32(x,f+1),x+=4}u[x++]=116,u[x++]=e,r.buffer||(r=new Uint8Array(r)),u.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),x)}function ie(r,e){var t=r.byteLength,a,f;if(t<256){var{target:a,position:f}=e(t+2);a[f++]=196,a[f++]=t}else if(t<65536){var{target:a,position:f}=e(t+3);a[f++]=197,a[f++]=t>>8,a[f++]=t&255}else{var{target:a,position:f,targetView:u}=e(t+5);a[f++]=198,u.setUint32(f,t),f+=4}a.set(r,f)}function Ce(r,e,t,a){var f=r.length;switch(f){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:f<256?(e[t++]=199,e[t++]=f):f<65536?(e[t++]=200,e[t++]=f>>8,e[t++]=f&255):(e[t++]=201,e[t++]=f>>24,e[t++]=f>>16&255,e[t++]=f>>8&255,e[t++]=f&255)}return e[t++]=a,e.set(r,t),t+=f,t}function Fe(r,e){for(var t,a=e.length*6,f=r.length-a;t=e.pop();){var u=t.offset,x=t.id;r.copyWithin(u+a,u,f),a-=6;var h=u+a;r[h++]=214,r[h++]=105,r[h++]=x>>24,r[h++]=x>>16&255,r[h++]=x>>8&255,r[h++]=x&255,f=u}return r}function ae(r,e,t){if(I.length>0){U.setUint32(I.position+r,i+t-I.position-r),I.stringsPosition=i-r;var a=I;I=null,e(a[0]),e(a[1])}}function Ve(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");_r.unshift(r.Class),yr.unshift(r)}Oe(r)}function Le(r,e){return r.isCompatible=function(t){var a=!t||(e.lastNamedStructuresLength||0)===t.length;return a||e._mergeStructures(t),a},r}var se=new cr({useRecords:!1}),Pe=se.pack,Je=se.pack,je=cr,{NEVER:$e,ALWAYS:qe,DECIMAL_ROUND:Ke,DECIMAL_FIT:Ye}=Wr,ce=512,ue=1024,oe=2048;function Ze(r,e){if(e=e!=null?e:{},!r||typeof r!="object")throw new Error("first argument must be an Iterable, Async Iterable, or a Promise for an Async Iterable");if(typeof r[Symbol.iterator]=="function")return ze(r,e);if(typeof r.then=="function"||typeof r[Symbol.asyncIterator]=="function")return Xe(r,e);throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a Promise")}function ze(r,e){var t=new cr(e),a=objectIteratorSymbol.iterator;return{next:function(){return a.next().then(function(f){return f.done?{done:!0}:t.pack(f.value).then(function(u){return{value:u,done:!1}})})}}}function Xe(r,e){var t=new cr(e),a=objectIteratorSymbol.asyncIterator;return{next:function(){return a.next().then(function(f){return f.done?{done:!0}:t.pack(f.value).then(function(u){return{value:u,done:!1}})})}}}function Ge(r,e){if(e=e!=null?e:{},!r||typeof r!="object")throw new Error("first argument must be an Iterable, Async Iterable, Iterator, Async Iterator, or a promise");var t=new Q(e),a,f=function(u){var x;a&&(u=Buffer.concat([a,u]),a=void 0);try{x=t.unpackMultiple(u)}catch(h){if(h.incomplete)a=u.slice(h.lastPosition),x=h.values;else throw h}return x};if(typeof r[Symbol.iterator]=="function")return function(){var x=symbol.iterator;return{next:function(){return x.next().then(function(h){return h.done?{done:!0}:f(h.value).then(function(w){return{value:w,done:!1}})})}}}();if(typeof r[Symbol.asyncIterator]=="function")return function(){var x=symbol.asyncIterator;return{next:function(){return x.next().then(function(h){return h.done?{done:!0}:f(h.value).then(function(w){return{value:w,done:!1}})})}}}()}var He=Ge,Qe=Ze,We=!1,rt=!0;m.ALWAYS=qe,m.C1=Ur,m.DECIMAL_FIT=Ye,m.DECIMAL_ROUND=Ke,m.Decoder=ke,m.Encoder=je,m.FLOAT32_OPTIONS=Wr,m.NEVER=$e,m.Packr=cr,m.RESERVE_START_SPACE=oe,m.RESET_BUFFER_MODE=ue,m.REUSE_BUFFER_MODE=ce,m.Unpackr=Q,m.addExtension=Ve,m.clearSource=lr,m.decode=Re,m.decodeIter=He,m.encode=Je,m.encodeIter=Qe,m.isNativeAccelerationEnabled=Ee,m.mapsAsObjects=rt,m.pack=Pe,m.roundFloat32=Me,m.unpack=_e,m.unpackMultiple=Be,m.useRecords=We}); diff --git a/stylesheets/main.css b/stylesheets/main.css index 919c1c6..2f04419 100644 --- a/stylesheets/main.css +++ b/stylesheets/main.css @@ -195,11 +195,13 @@ header { border-top-right-radius: inherit; } #main header { + padding-top: 20px; /* Support */ padding-top: max(env(safe-area-inset-top), 2px); } #main header::after { content: ""; background-color: var(--status); + height: 20px; /* Support */ height: env(safe-area-inset-top); position: fixed; left: 0; @@ -224,6 +226,7 @@ header { overflow-y: auto; position: absolute; top: calc(100% + 6px); + right: 12px; /* Support */ right: calc(env(safe-area-inset-right) + 12px); max-height: calc(100vh - 104px - 12px); transform-origin: top right; @@ -255,6 +258,7 @@ header { margin: 0; } nav { + padding-bottom: 2px; /* Support */ padding-bottom: max(env(safe-area-inset-bottom), 2px); } .gs { @@ -349,6 +353,8 @@ header li { } #reader, #inspector { + padding-left: 48px; /* Support */ + padding-right: 48px; /* Support */ padding-left: max(env(safe-area-inset-left), env(safe-area-inset-right), 48px); padding-right: max(env(safe-area-inset-left), env(safe-area-inset-right), 48px); } @@ -405,6 +411,7 @@ main>* { flex: 0 0 auto; position: absolute; right: 0; + padding-top: 70px; /* Support */ padding-top: calc(max(env(safe-area-inset-top), 2px) + 50px); width: 100%; height: 100%; @@ -421,6 +428,7 @@ main>*:not(#inspector)::after { background-color: transparent; pointer-events: none; position: fixed; + top: 70px; /* Support */ top: calc(max(env(safe-area-inset-top), 2px) + 50px); right: 0; bottom: 0; @@ -489,6 +497,7 @@ nav ul { } header>div { height: 48px; + padding: 0 6px; /* Support */ padding: 0 max(env(safe-area-inset-left), env(safe-area-inset-right), 6px); } .head-left, @@ -516,6 +525,9 @@ nav { border-top-left-radius: 15px; border-top-right-radius: 15px; position: fixed; + top: 50px; /* Support */ + left: 0; /* Support */ + right: 0; /* Support */ top: calc(env(safe-area-inset-top) + 30px); left: env(safe-area-inset-left); right: env(safe-area-inset-right); @@ -614,7 +626,7 @@ header button .gs { opacity: 0; pointer-events: none; transform: translate(-50%, -50%) scale(1.25); - transition: opacity .25s, transform 0s ease .25s; + transition: opacity .25s, transform 0s ease .5s; } #alert-text { line-height: 1.3; @@ -713,7 +725,6 @@ header button .gs { color: var(--secondary-text); font-size: .882rem; line-height: 1; - margin-bottom: .25rem; } .list:not(#chapters) li:not(.chapter) p::after { content: "chevron-right"; @@ -812,6 +823,7 @@ article ol:first-child { @media (max-height: 600px) { #modal { border-radius: 0; + top: 20px; /* Support */ top: env(safe-area-inset-top); } } @@ -825,9 +837,11 @@ nav li:not(.active) .gs { } /** UI **/ main>* { + padding-bottom: 52px; /* Support */ padding-bottom: calc(max(env(safe-area-inset-bottom), 2px) + 50px); } main>*::after { + bottom: 52px; /* Support */ bottom: calc(max(env(safe-area-inset-bottom), 2px) + 50px) !important; } nav { @@ -837,6 +851,7 @@ nav { right: 0; } nav>div { + padding: 0 6px; /* Support */ padding: 0 max(env(safe-area-inset-left), env(safe-area-inset-right), 6px); height: 48px; }