diff --git a/DesktopEditor/graphics/pro/js/make.py b/DesktopEditor/graphics/pro/js/make.py index 589f6906d1..3370809c34 100644 --- a/DesktopEditor/graphics/pro/js/make.py +++ b/DesktopEditor/graphics/pro/js/make.py @@ -285,21 +285,13 @@ base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", # finalize base.replaceInFile("./drawingfile.js", "function getBinaryPromise(){", "function getBinaryPromise2(){") graphics_js_content = base.readFile("./drawingfile.js") -engine_base_js_content = base.readFile("./wasm/js/xps_base.js") +engine_base_js_content = base.readFile("./wasm/js/drawingfile_base.js") string_utf8_content = base.readFile("./../../../../Common/js/string_utf8.js") engine_js_content = engine_base_js_content.replace("//module", graphics_js_content) engine_js_content = engine_js_content.replace("//string_utf8", string_utf8_content) -engine_base_js_content = base.readFile("./../../../../DjVuFile/wasm/djvu_base.js") -djvu_js_content = engine_base_js_content.replace("//module", graphics_js_content) -djvu_js_content = djvu_js_content.replace("//string_utf8", string_utf8_content) -engine_base_js_content = base.readFile("./wasm/js/pdf_base.js") -pdf_js_content = engine_base_js_content.replace("//module", graphics_js_content) -pdf_js_content = pdf_js_content.replace("//string_utf8", string_utf8_content) # write new version -base.writeFile("./deploy/xps.js", engine_js_content) -base.writeFile("./deploy/djvu.js", djvu_js_content) -base.writeFile("./deploy/pdf.js", pdf_js_content) +base.writeFile("./deploy/drawingfile.js", engine_js_content) base.copy_file("./drawingfile.wasm", "./deploy/drawingfile.wasm") base.delete_file("drawingfile.js") diff --git a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js index 2401613eee..09b5120ca2 100644 --- a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js +++ b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js @@ -92,7 +92,7 @@ }; CBinaryReader.prototype.readDouble = function() { - return readInt() / 100; + return this.readInt() / 100; }; CBinaryReader.prototype.readString = function() { @@ -112,13 +112,14 @@ this.pages = []; } - CFile.prototype["load"] = function(arrayBuffer) + CFile.prototype["loadFromData"] = function(arrayBuffer) { var data = new Uint8Array(arrayBuffer); var _stream = Module["_malloc"](data.length); Module["HEAP8"].set(data, _stream); this.nativeFile = Module["_Open"](_stream, data.length); - Module["_free"](_stream); + this.stream = _stream; + this.type = Module["_GetType"](_stream, data.length); return this.getInfo(); }; CFile.prototype["getInfo"] = function() @@ -151,6 +152,9 @@ Module["_Close"](this.nativeFile); this.nativeFile = 0; this.pages = []; + if (this.stream > 0) + Module["_free"](this.stream); + this.stream = -1; }; CFile.prototype["getPages"] = function() @@ -168,7 +172,46 @@ if (glyphs == null) return; - // TODO: + var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4); + var len = lenArray[0]; + len -= 4; + if (len <= 0) + return; + + this.pages[pageIndex].Lines = []; + var buffer = new Uint8Array(Module["HEAP8"].buffer, glyphs + 4, len); + var reader = new CBinaryReader(buffer, 0, len); + + var Line = -1; + while (reader.isValid()) + { + var rec = {}; + rec["word"] = reader.readString(); + if (this.type == 2) + { + rec["x"] = 1.015 * reader.readDouble(); + rec["y"] = 1.015 * reader.readDouble(); + } + else + { + rec["x"] = reader.readDouble(); + rec["y"] = reader.readDouble(); + } + rec["w"] = reader.readDouble(); + rec["h"] = reader.readDouble(); + + Line++; + this.pages[pageIndex].Lines.push({ Glyphs : [] }); + for (let i = 0; i < _Word.length; i++) + { + this.pages[pageIndex].Lines[Line].Glyphs.push({ + X : _X + _W / (_Word.length - 1) * i, + UChar : _Word[i] + }); + } + this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H; + this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H; + } Module["_free"](glyphs); }; @@ -192,8 +235,16 @@ { var rec = {}; rec["link"] = reader.readString(); - rec["x"] = 1.015 * reader.readDouble(); - rec["y"] = 1.015 * reader.readDouble(); + if (this.type == 2) + { + rec["x"] = 1.015 * reader.readDouble(); + rec["y"] = 1.015 * reader.readDouble(); + } + else + { + rec["x"] = reader.readDouble(); + rec["y"] = reader.readDouble(); + } rec["w"] = reader.readDouble(); rec["h"] = reader.readDouble(); res.push(rec); @@ -222,7 +273,14 @@ var rec = {}; rec["page"] = reader.readInt(); rec["level"] = reader.readInt(); - rec["y"] = reader.readDouble(); + if (this.type == 2) + { + rec["y"] = reader.readDouble(); + } + else + { + rec["y"] = reader.readInt(); + } rec["description"] = reader.readString(); res.push(rec); } @@ -239,7 +297,193 @@ { Module["_free"](pointer); }; + CFile.prototype.isValid = function() + { + return this.pages.length > 0; + }; + CFile.prototype.getPage = function(pageIndex, width, height) + { + if (pageIndex < 0 || pageIndex >= this.pages.length) + return null; + if (!width) width = this.pages[pageIndex].W; + if (!height) height = this.pages[pageIndex].H; + var t0 = performance.now(); + var pixels = this.getPagePixmap(pageIndex, width, height); + if (!pixels) + return null; + + if (!this.logging) + { + var image = this._pixelsToCanvas(pixels, width, height); + } + else + { + var t1 = performance.now(); + var image = this._pixelsToCanvas(pixels, width, height); + var t2 = performance.now(); + //console.log("time: " + (t1 - t0) + ", " + (t2 - t1)); + } + /* + if (this.pages[pageIndex].Lines) + { + var ctx = image.getContext("2d"); + for (let i = 0; i < this.pages[pageIndex].Lines.length; i++) + { + for (let j = 0; j < this.pages[pageIndex].Lines[i].Glyphs.length; j++) + { + let glyph = this.pages[pageIndex].Lines[i].Glyphs[j]; + ctx.font = glyph.fontSize + 'px ' + glyph.fontName; + ctx.fillText(glyph.UChar, glyph.X, glyph.Y); + } + } + } + */ + this.free(pixels); + return image; + }; + CFile.prototype._pixelsToCanvas = function(pixels, width, height) + { + if (!this.isUse3d) + { + return this._pixelsToCanvas2d(pixels, width, height); + } + try + { + return this._pixelsToCanvas3d(pixels, width, height); + } + catch (err) + { + this.isUse3d = false; + if (this.cacheManager) + this.cacheManager.clear(); + return this._pixelsToCanvas(pixels, width, height); + } + }; + CFile.prototype._pixelsToCanvas2d = function(pixels, width, height) + { + var canvas = null; + if (this.cacheManager) + { + canvas = this.cacheManager.lock(width, height); + } + else + { + canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + } + + var mappedBuffer = new Uint8ClampedArray(this.memory().buffer, pixels, 4 * width * height); + var imageData = new ImageData(mappedBuffer, width, height); + var ctx = canvas.getContext("2d"); + if (ctx) + ctx.putImageData(imageData, 0, 0); + return canvas; + }; + + CFile.prototype._pixelsToCanvas3d = function(pixels, width, height) + { + var vs_source = "\ +attribute vec2 aVertex;\n\ +attribute vec2 aTex;\n\ +varying vec2 vTex;\n\ +void main() {\n\ + gl_Position = vec4(aVertex, 0.0, 1.0);\n\ + vTex = aTex;\n\ +}"; + + var fs_source = "\ +precision mediump float;\n\ +uniform sampler2D uTexture;\n\ +varying vec2 vTex;\n\ +void main() {\n\ + gl_FragColor = texture2D(uTexture, vTex);\n\ +}"; + var canvas = null; + if (this.cacheManager) + { + canvas = this.cacheManager.lock(width, height); + } + else + { + canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + } + + var gl = canvas.getContext('webgl', { preserveDrawingBuffer : true }); + if (!gl) + throw new Error('FAIL: could not create webgl canvas context'); + + var colorCorrect = gl.BROWSER_DEFAULT_WEBGL; + gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, colorCorrect); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + + gl.viewport(0, 0, canvas.width, canvas.height); + gl.clearColor(0, 0, 0, 1); + gl.clear(gl.COLOR_BUFFER_BIT); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: webgl canvas context setup failed'); + + function createShader(source, type) { + var shader = gl.createShader(type); + gl.shaderSource(shader, source); + gl.compileShader(shader); + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) + throw new Error('FAIL: shader ' + id + ' compilation failed'); + return shader; + } + + var program = gl.createProgram(); + gl.attachShader(program, createShader(vs_source, gl.VERTEX_SHADER)); + gl.attachShader(program, createShader(fs_source, gl.FRAGMENT_SHADER)); + gl.linkProgram(program); + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + throw new Error('FAIL: webgl shader program linking failed'); + gl.useProgram(program); + + var texture = gl.createTexture(); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(this.memory().buffer, pixels, 4 * width * height)); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: creating webgl image texture failed'); + + function createBuffer(data) { + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + return buffer; + } + + var vertexCoords = new Float32Array([-1, 1, -1, -1, 1, -1, 1, 1]); + var vertexBuffer = createBuffer(vertexCoords); + var location = gl.getAttribLocation(program, 'aVertex'); + gl.enableVertexAttribArray(location); + gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: vertex-coord setup failed'); + + var texCoords = new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]); + var texBuffer = createBuffer(texCoords); + var location = gl.getAttribLocation(program, 'aTex'); + gl.enableVertexAttribArray(location); + gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: tex-coord setup setup failed'); + + gl.drawArrays(gl.TRIANGLE_FAN, 0, 4); + return canvas; + }; window["AscViewer"]["CDrawingFile"] = CFile; })(window, undefined); diff --git a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp index 2cd86386d5..69a29176b8 100644 --- a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp +++ b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp @@ -37,7 +37,7 @@ WASM_EXPORT CGraphicsFileDrawing* Open(BYTE* data, LONG size) if (pGraphics->Open(data, size, GetType(data, size))) return pGraphics; - delete pGraphics; + delete pGraphics; return NULL; } WASM_EXPORT void Close (CGraphicsFileDrawing* pGraphics) diff --git a/DjVuFile/wasm/all_files_test/code.js b/DjVuFile/wasm/all_files_test/code.js index e2e86e8c16..d3fa18e9ae 100644 --- a/DjVuFile/wasm/all_files_test/code.js +++ b/DjVuFile/wasm/all_files_test/code.js @@ -114,7 +114,7 @@ window.onload = function() this.documentHeight = 0; this.Selection = { IsSelection : false, Image : null, page : -1 }; - this.file = new AscViewer.DjVuFile(); + this.file = new AscViewer.CDrawingFile(); /* [TIMER START] @@ -373,7 +373,7 @@ window.onload = function() this.getStructure = function() { - var res = this.file.structure(); + var res = this.file.getStructure(); return res; }; @@ -469,7 +469,7 @@ window.onload = function() if (!page.Image) { page.Image = this.file.getPage(i, w, h); - this.getGlyphs(i, w, h); + //this.getGlyphs(i, w, h); this.links = this.getLinks(i, w, h); this.links.Page = i; } @@ -487,7 +487,7 @@ window.onload = function() for (let j = 0; j < this.links.length; j++) { let Link = this.links[j]; - ctx.fillRect(x + Link.X, y + Link.Y, Link.W, Link.H); + ctx.fillRect(x + Link.x, y + Link.y, Link.w, Link.h); } } diff --git a/DjVuFile/wasm/all_files_test/drawingfile.js b/DjVuFile/wasm/all_files_test/drawingfile.js new file mode 100644 index 0000000000..a1cf4cd892 --- /dev/null +++ b/DjVuFile/wasm/all_files_test/drawingfile.js @@ -0,0 +1,610 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +(function(window, undefined) { + + var printErr = undefined; + var FS = undefined; + var print = undefined; + + var getBinaryPromise = null; + if (window["AscDesktopEditor"] && document.currentScript && 0 == document.currentScript.src.indexOf("file:///")) + { + // fetch not support file:/// scheme + window.fetch = undefined; + + getBinaryPromise = function() { + + var wasmPath = "ascdesktop://fonts/" + wasmBinaryFile.substr(8); + return new Promise(function (resolve, reject) { + + var xhr = new XMLHttpRequest(); + xhr.open('GET', wasmPath, true); + xhr.responseType = 'arraybuffer'; + + if (xhr.overrideMimeType) + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + else + xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); + + xhr.onload = function () { + if (this.status == 200) { + resolve(new Uint8Array(this.response)); + } + }; + + xhr.send(null); + + }); + } + } + else + { + getBinaryPromise = function() { + return getBinaryPromise2(); + } + } + + (function(){ + + if (undefined !== String.prototype.fromUtf8 && + undefined !== String.prototype.toUtf8) + return; + + /** + * Read string from utf8 + * @param {Uint8Array} buffer + * @param {number} [start=0] + * @param {number} [len] + * @returns {string} + */ + String.prototype.fromUtf8 = function(buffer, start, len) { + if (undefined === start) + start = 0; + if (undefined === len) + len = buffer.length; + + var result = ""; + var index = start; + var end = start + len; + while (index < end) + { + var u0 = buffer[index++]; + if (!(u0 & 128)) + { + result += String.fromCharCode(u0); + continue; + } + var u1 = buffer[index++] & 63; + if ((u0 & 224) == 192) + { + result += String.fromCharCode((u0 & 31) << 6 | u1); + continue; + } + var u2 = buffer[index++] & 63; + if ((u0 & 240) == 224) + u0 = (u0 & 15) << 12 | u1 << 6 | u2; + else + u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | buffer[index++] & 63; + if (u0 < 65536) + result += String.fromCharCode(u0); + else + { + var ch = u0 - 65536; + result += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); + } + } + return result; + }; + + /** + * Convert string to utf8 array + * @returns {Uint8Array} + */ + String.prototype.toUtf8 = function() { + var inputLen = this.length; + var testLen = 6 * inputLen + 1; + var tmpStrings = new ArrayBuffer(testLen); + + var code = 0; + var index = 0; + + var outputIndex = 0; + var outputDataTmp = new Uint8Array(tmpStrings); + var outputData = outputDataTmp; + + while (index < inputLen) + { + code = this.charCodeAt(index++); + if (code >= 0xD800 && code <= 0xDFFF && index < inputLen) + code = 0x10000 + (((code & 0x3FF) << 10) | (0x03FF & this.charCodeAt(index++))); + + if (code < 0x80) + outputData[outputIndex++] = code; + else if (code < 0x0800) + { + outputData[outputIndex++] = 0xC0 | (code >> 6); + outputData[outputIndex++] = 0x80 | (code & 0x3F); + } + else if (code < 0x10000) + { + outputData[outputIndex++] = 0xE0 | (code >> 12); + outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); + outputData[outputIndex++] = 0x80 | (code & 0x3F); + } + else if (code < 0x1FFFFF) + { + outputData[outputIndex++] = 0xF0 | (code >> 18); + outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); + outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); + outputData[outputIndex++] = 0x80 | (code & 0x3F); + } + else if (code < 0x3FFFFFF) + { + outputData[outputIndex++] = 0xF8 | (code >> 24); + outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F); + outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); + outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); + outputData[outputIndex++] = 0x80 | (code & 0x3F); + } + else if (code < 0x7FFFFFFF) + { + outputData[outputIndex++] = 0xFC | (code >> 30); + outputData[outputIndex++] = 0x80 | ((code >> 24) & 0x3F); + outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F); + outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); + outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); + outputData[outputIndex++] = 0x80 | (code & 0x3F); + } + } + + outputData[outputIndex++] = 0; + + return new Uint8Array(tmpStrings, 0, outputIndex); + }; + +})(); + + + var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=true;var ENVIRONMENT_IS_WORKER=false;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!=="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!=="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}var wasmBinaryFile="drawingfile.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise2(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["_"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["aa"];addOnInit(Module["asm"]["$"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){var result=WebAssembly.instantiate(binary,info);return result}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){wasmTable.get(func)()}else{wasmTable.get(func)(callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var runtimeKeepaliveCounter=0;function keepRuntimeAlive(){return noExitRuntime||runtimeKeepaliveCounter>0}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}var _emscripten_get_now;_emscripten_get_now=function(){return performance.now()};var _emscripten_get_now_is_monotonic=true;function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function _clock_gettime(clk_id,tp){var now;if(clk_id===0){now=Date.now()}else if((clk_id===1||clk_id===4)&&_emscripten_get_now_is_monotonic){now=_emscripten_get_now()}else{setErrNo(28);return-1}HEAP32[tp>>2]=now/1e3|0;HEAP32[tp+4>>2]=now%1e3*1e3*1e3|0;return 0}function ___clock_gettime(a0,a1){return _clock_gettime(a0,a1)}var ExceptionInfoAttrs={DESTRUCTOR_OFFSET:0,REFCOUNT_OFFSET:4,TYPE_OFFSET:8,CAUGHT_OFFSET:12,RETHROWN_OFFSET:13,SIZE:16};function ___cxa_allocate_exception(size){return _malloc(size+ExceptionInfoAttrs.SIZE)+ExceptionInfoAttrs.SIZE}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-ExceptionInfoAttrs.SIZE;this.set_type=function(type){HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]=type};this.get_type=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]};this.set_destructor=function(destructor){HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]=destructor};this.get_destructor=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]!=0};this.init=function(type,destructor){this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=prev-1;return prev===1}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}function _gmtime_r(time,tmPtr){var date=new Date(HEAP32[time>>2]*1e3);HEAP32[tmPtr>>2]=date.getUTCSeconds();HEAP32[tmPtr+4>>2]=date.getUTCMinutes();HEAP32[tmPtr+8>>2]=date.getUTCHours();HEAP32[tmPtr+12>>2]=date.getUTCDate();HEAP32[tmPtr+16>>2]=date.getUTCMonth();HEAP32[tmPtr+20>>2]=date.getUTCFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getUTCDay();HEAP32[tmPtr+36>>2]=0;HEAP32[tmPtr+32>>2]=0;var start=Date.UTC(date.getUTCFullYear(),0,1,0,0,0,0);var yday=(date.getTime()-start)/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;if(!_gmtime_r.GMTString)_gmtime_r.GMTString=allocateUTF8("GMT");HEAP32[tmPtr+40>>2]=_gmtime_r.GMTString;return tmPtr}function ___gmtime_r(a0,a1){return _gmtime_r(a0,a1)}var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},get64:function(low,high){return low}};function ___sys_chdir(path){}function ___sys_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;return 0}function ___sys_fstat64(fd,buf){}function ___sys_getcwd(buf,size){}function ___sys_getdents64(fd,dirp,count){}function ___sys_getegid32(){return 0}function ___sys_getuid32(){return ___sys_getegid32()}function ___sys_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;return 0}function ___sys_lstat64(path,buf){}function ___sys_mkdir(path,mode){path=SYSCALLS.getStr(path);return SYSCALLS.doMkdir(path,mode)}function syscallMmap2(addr,len,prot,flags,fd,off){off<<=12;var ptr;var allocated=false;if((flags&16)!==0&&addr%65536!==0){return-28}if((flags&32)!==0){ptr=_memalign(65536,len);if(!ptr)return-48;_memset(ptr,0,len);allocated=true}else{return-52}SYSCALLS.mappings[ptr]={malloc:ptr,len:len,allocated:allocated,fd:fd,prot:prot,flags:flags,offset:off};return ptr}function ___sys_mmap2(addr,len,prot,flags,fd,off){return syscallMmap2(addr,len,prot,flags,fd,off)}function syscallMunmap(addr,len){if((addr|0)===-1||len===0){return-28}var info=SYSCALLS.mappings[addr];if(!info)return 0;if(len===info.len){SYSCALLS.mappings[addr]=null;if(info.allocated){_free(info.malloc)}}return 0}function ___sys_munmap(addr,len){return syscallMunmap(addr,len)}function ___sys_open(path,flags,varargs){SYSCALLS.varargs=varargs}function ___sys_readlink(path,buf,bufsize){path=SYSCALLS.getStr(path);return SYSCALLS.doReadlink(path,buf,bufsize)}function ___sys_rmdir(path){}function ___sys_stat64(path,buf){}function ___sys_unlink(path){}function _abort(){abort()}function _longjmp(env,value){_setThrew(env,value||1);throw"longjmp"}function _emscripten_longjmp(a0,a1){return _longjmp(a0,a1)}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=2147483648;if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}function _emscripten_thread_sleep(msecs){var start=_emscripten_get_now();while(_emscripten_get_now()-start>2]=stdTimezoneOffset*60;HEAP32[__get_daylight()>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAP32[__get_tzname()+4>>2]=summerNamePtr}else{HEAP32[__get_tzname()>>2]=summerNamePtr;HEAP32[__get_tzname()+4>>2]=winterNamePtr}}function _mktime(tmPtr){_tzset();var date=new Date(HEAP32[tmPtr+20>>2]+1900,HEAP32[tmPtr+16>>2],HEAP32[tmPtr+12>>2],HEAP32[tmPtr+8>>2],HEAP32[tmPtr+4>>2],HEAP32[tmPtr>>2],0);var dst=HEAP32[tmPtr+32>>2];var guessedOffset=date.getTimezoneOffset();var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dstOffset=Math.min(winterOffset,summerOffset);if(dst<0){HEAP32[tmPtr+32>>2]=Number(summerOffset!=winterOffset&&dstOffset==guessedOffset)}else if(dst>0!=(dstOffset==guessedOffset)){var nonDstOffset=Math.max(winterOffset,summerOffset);var trueOffset=dst>0?dstOffset:nonDstOffset;date.setTime(date.getTime()+(trueOffset-guessedOffset)*6e4)}HEAP32[tmPtr+24>>2]=date.getDay();var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();return date.getTime()/1e3|0}function _setTempRet0(val){setTempRet0(val)}function __isLeapYear(year){return year%4===0&&(year%100!==0||year%400===0)}function __arraySum(array,index){var sum=0;for(var i=0;i<=index;sum+=array[i++]){}return sum}var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date,days){var newDate=new Date(date.getTime());while(days>0){var leap=__isLeapYear(newDate.getFullYear());var currentMonth=newDate.getMonth();var daysInCurrentMonth=(leap?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR)[currentMonth];if(days>daysInCurrentMonth-newDate.getDate()){days-=daysInCurrentMonth-newDate.getDate()+1;newDate.setDate(1);if(currentMonth<11){newDate.setMonth(currentMonth+1)}else{newDate.setMonth(0);newDate.setFullYear(newDate.getFullYear()+1)}}else{newDate.setDate(newDate.getDate()+days);return newDate}}return newDate}function _strftime(s,maxsize,format,tm){var tm_zone=HEAP32[tm+40>>2];var date={tm_sec:HEAP32[tm>>2],tm_min:HEAP32[tm+4>>2],tm_hour:HEAP32[tm+8>>2],tm_mday:HEAP32[tm+12>>2],tm_mon:HEAP32[tm+16>>2],tm_year:HEAP32[tm+20>>2],tm_wday:HEAP32[tm+24>>2],tm_yday:HEAP32[tm+28>>2],tm_isdst:HEAP32[tm+32>>2],tm_gmtoff:HEAP32[tm+36>>2],tm_zone:tm_zone?UTF8ToString(tm_zone):""};var pattern=UTF8ToString(format);var EXPANSION_RULES_1={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var rule in EXPANSION_RULES_1){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_1[rule])}var WEEKDAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];function leadingSomething(value,digits,character){var str=typeof value==="number"?value.toString():value||"";while(str.length0?1:0}var compare;if((compare=sgn(date1.getFullYear()-date2.getFullYear()))===0){if((compare=sgn(date1.getMonth()-date2.getMonth()))===0){compare=sgn(date1.getDate()-date2.getDate())}}return compare}function getFirstWeekStartDate(janFourth){switch(janFourth.getDay()){case 0:return new Date(janFourth.getFullYear()-1,11,29);case 1:return janFourth;case 2:return new Date(janFourth.getFullYear(),0,3);case 3:return new Date(janFourth.getFullYear(),0,2);case 4:return new Date(janFourth.getFullYear(),0,1);case 5:return new Date(janFourth.getFullYear()-1,11,31);case 6:return new Date(janFourth.getFullYear()-1,11,30)}}function getWeekBasedYear(date){var thisDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new Date(thisDate.getFullYear(),0,4);var janFourthNextYear=new Date(thisDate.getFullYear()+1,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);if(compareByDay(firstWeekStartThisYear,thisDate)<=0){if(compareByDay(firstWeekStartNextYear,thisDate)<=0){return thisDate.getFullYear()+1}else{return thisDate.getFullYear()}}else{return thisDate.getFullYear()-1}}var EXPANSION_RULES_2={"%a":function(date){return WEEKDAYS[date.tm_wday].substring(0,3)},"%A":function(date){return WEEKDAYS[date.tm_wday]},"%b":function(date){return MONTHS[date.tm_mon].substring(0,3)},"%B":function(date){return MONTHS[date.tm_mon]},"%C":function(date){var year=date.tm_year+1900;return leadingNulls(year/100|0,2)},"%d":function(date){return leadingNulls(date.tm_mday,2)},"%e":function(date){return leadingSomething(date.tm_mday,2," ")},"%g":function(date){return getWeekBasedYear(date).toString().substring(2)},"%G":function(date){return getWeekBasedYear(date)},"%H":function(date){return leadingNulls(date.tm_hour,2)},"%I":function(date){var twelveHour=date.tm_hour;if(twelveHour==0)twelveHour=12;else if(twelveHour>12)twelveHour-=12;return leadingNulls(twelveHour,2)},"%j":function(date){return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900)?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,date.tm_mon-1),3)},"%m":function(date){return leadingNulls(date.tm_mon+1,2)},"%M":function(date){return leadingNulls(date.tm_min,2)},"%n":function(){return"\n"},"%p":function(date){if(date.tm_hour>=0&&date.tm_hour<12){return"AM"}else{return"PM"}},"%S":function(date){return leadingNulls(date.tm_sec,2)},"%t":function(){return"\t"},"%u":function(date){return date.tm_wday||7},"%U":function(date){var janFirst=new Date(date.tm_year+1900,0,1);var firstSunday=janFirst.getDay()===0?janFirst:__addDays(janFirst,7-janFirst.getDay());var endDate=new Date(date.tm_year+1900,date.tm_mon,date.tm_mday);if(compareByDay(firstSunday,endDate)<0){var februaryFirstUntilEndMonth=__arraySum(__isLeapYear(endDate.getFullYear())?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,endDate.getMonth()-1)-31;var firstSundayUntilEndJanuary=31-firstSunday.getDate();var days=firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();return leadingNulls(Math.ceil(days/7),2)}return compareByDay(firstSunday,janFirst)===0?"01":"00"},"%V":function(date){var janFourthThisYear=new Date(date.tm_year+1900,0,4);var janFourthNextYear=new Date(date.tm_year+1901,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);var endDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);if(compareByDay(endDate,firstWeekStartThisYear)<0){return"53"}if(compareByDay(firstWeekStartNextYear,endDate)<=0){return"01"}var daysDifference;if(firstWeekStartThisYear.getFullYear()=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":function(date){return date.tm_zone},"%%":function(){return"%"}};for(var rule in EXPANSION_RULES_2){if(pattern.includes(rule)){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date))}}var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize){return 0}writeArrayToMemory(bytes,s);return bytes.length-1}function _strftime_l(s,maxsize,format,tm){return _strftime(s,maxsize,format,tm)}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var asmLibraryArg={"a":___assert_fail,"Q":___clock_gettime,"B":___cxa_allocate_exception,"A":___cxa_throw,"L":___gmtime_r,"P":___sys_chdir,"t":___sys_fcntl64,"U":___sys_fstat64,"O":___sys_getcwd,"X":___sys_getdents64,"N":___sys_getuid32,"R":___sys_ioctl,"S":___sys_lstat64,"T":___sys_mkdir,"W":___sys_mmap2,"V":___sys_munmap,"s":___sys_open,"M":___sys_readlink,"w":___sys_rmdir,"x":___sys_stat64,"r":___sys_unlink,"f":_abort,"d":_emscripten_longjmp,"E":_emscripten_memcpy_big,"F":_emscripten_resize_heap,"K":_emscripten_thread_sleep,"I":_environ_get,"J":_environ_sizes_get,"n":_exit,"o":_fd_close,"H":_fd_fdstat_get,"v":_fd_read,"D":_fd_seek,"q":_fd_write,"b":_getTempRet0,"y":_getpwnam,"Y":_getpwuid,"g":invoke_ii,"l":invoke_iii,"j":invoke_iiii,"i":invoke_iiiii,"u":invoke_iiiiii,"z":invoke_v,"h":invoke_vi,"e":invoke_vii,"k":invoke_viii,"C":invoke_viiii,"Z":invoke_viiiiiiiii,"m":_mktime,"c":_setTempRet0,"G":_strftime_l,"p":_time};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["$"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["ba"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["ca"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["da"]).apply(null,arguments)};var _GetType=Module["_GetType"]=function(){return(_GetType=Module["_GetType"]=Module["asm"]["ea"]).apply(null,arguments)};var _Open=Module["_Open"]=function(){return(_Open=Module["_Open"]=Module["asm"]["fa"]).apply(null,arguments)};var _Close=Module["_Close"]=function(){return(_Close=Module["_Close"]=Module["asm"]["ga"]).apply(null,arguments)};var _GetInfo=Module["_GetInfo"]=function(){return(_GetInfo=Module["_GetInfo"]=Module["asm"]["ha"]).apply(null,arguments)};var _GetPixmap=Module["_GetPixmap"]=function(){return(_GetPixmap=Module["_GetPixmap"]=Module["asm"]["ia"]).apply(null,arguments)};var _GetGlyphs=Module["_GetGlyphs"]=function(){return(_GetGlyphs=Module["_GetGlyphs"]=Module["asm"]["ja"]).apply(null,arguments)};var _GetLinks=Module["_GetLinks"]=function(){return(_GetLinks=Module["_GetLinks"]=Module["asm"]["ka"]).apply(null,arguments)};var _GetStructure=Module["_GetStructure"]=function(){return(_GetStructure=Module["_GetStructure"]=Module["asm"]["la"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["ma"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["na"]).apply(null,arguments)};function invoke_ii(index,a1){var sp=stackSave();try{return wasmTable.get(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return wasmTable.get(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{wasmTable.get(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{wasmTable.get(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{wasmTable.get(index)()}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){EXITSTATUS=status;if(implicit&&keepRuntimeAlive()&&status===0){return}if(keepRuntimeAlive()){}else{exitRuntime();if(Module["onExit"])Module["onExit"](status);ABORT=true}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run(); + + + function CBinaryReader(data, start, size) + { + this.data = data; + this.pos = start; + this.limit = start + size; + } + CBinaryReader.prototype.readInt = function() + { + var val = this.data[this.pos] | this.data[this.pos + 1] << 8 | this.data[this.pos + 2] << 16 | this.data[this.pos + 3] << 24; + this.pos += 4; + return val; + }; + CBinaryReader.prototype.readDouble = function() + { + return this.readInt() / 100; + }; + CBinaryReader.prototype.readString = function() + { + var len = this.readInt(); + var val = String.prototype.fromUtf8(this.data, this.pos, len); + this.pos += len; + return val; + }; + CBinaryReader.prototype.isValid = function() + { + return (this.pos < this.limit) ? true : false; + }; + + function CFile() + { + this.nativeFile = 0; + this.pages = []; + } + + CFile.prototype["loadFromData"] = function(arrayBuffer) + { + var data = new Uint8Array(arrayBuffer); + var _stream = Module["_malloc"](data.length); + Module["HEAP8"].set(data, _stream); + this.nativeFile = Module["_Open"](_stream, data.length); + this.stream = _stream; + this.type = Module["_GetType"](_stream, data.length); + return this.getInfo(); + }; + CFile.prototype["getInfo"] = function() + { + if (!this.nativeFile) + return false; + + var _info = Module["_GetInfo"](this.nativeFile); + if (!_info) + return false; + + var _pages = Module["HEAP32"][_info >> 2]; + var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages); + + var _cur = 1; + for (var i = 0; i < _pages; i++) + { + this.pages.push({ + "W" : _buffer[_cur++], + "H" : _buffer[_cur++], + "Dpi" : _buffer[_cur++] + }); + } + + this.free(_info); + return this.pages.length > 0; + }; + CFile.prototype["close"] = function() + { + Module["_Close"](this.nativeFile); + this.nativeFile = 0; + this.pages = []; + if (this.stream > 0) + Module["_free"](this.stream); + this.stream = -1; + }; + + CFile.prototype["getPages"] = function() + { + return this.pages; + }; + + CFile.prototype["getPagePixmap"] = function(pageIndex, width, height) + { + return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height); + }; + CFile.prototype["getGlyphs"] = function(pageIndex, width, height) + { + var glyphs = Module["_GetGlyphs"](this.nativeFile, pageIndex, width, height); + if (glyphs == null) + return; + + var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4); + var len = lenArray[0]; + len -= 4; + if (len <= 0) + return; + + this.pages[pageIndex].Lines = []; + var buffer = new Uint8Array(Module["HEAP8"].buffer, glyphs + 4, len); + var reader = new CBinaryReader(buffer, 0, len); + + var Line = -1; + while (reader.isValid()) + { + var rec = {}; + rec["word"] = reader.readString(); + if (this.type == 2) + { + rec["x"] = 1.015 * reader.readDouble(); + rec["y"] = 1.015 * reader.readDouble(); + } + else + { + rec["x"] = reader.readDouble(); + rec["y"] = reader.readDouble(); + } + rec["w"] = reader.readDouble(); + rec["h"] = reader.readDouble(); + + Line++; + this.pages[pageIndex].Lines.push({ Glyphs : [] }); + for (let i = 0; i < _Word.length; i++) + { + this.pages[pageIndex].Lines[Line].Glyphs.push({ + X : _X + _W / (_Word.length - 1) * i, + UChar : _Word[i] + }); + } + this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H; + this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H; + } + + Module["_free"](glyphs); + }; + CFile.prototype["getLinks"] = function(pageIndex, width, height) + { + var res = []; + var ext = Module["_GetLinks"](this.nativeFile, pageIndex, width, height); + var lenArray = new Int32Array(Module["HEAP8"].buffer, ext, 4); + if (lenArray == null) + return res; + + var len = lenArray[0]; + len -= 4; + if (len <= 0) + return res; + + var buffer = new Uint8Array(Module["HEAP8"].buffer, ext + 4, len); + var reader = new CBinaryReader(buffer, 0, len); + + while (reader.isValid()) + { + var rec = {}; + rec["link"] = reader.readString(); + if (this.type == 2) + { + rec["x"] = 1.015 * reader.readDouble(); + rec["y"] = 1.015 * reader.readDouble(); + } + else + { + rec["x"] = reader.readDouble(); + rec["y"] = reader.readDouble(); + } + rec["w"] = reader.readDouble(); + rec["h"] = reader.readDouble(); + res.push(rec); + } + + Module["_free"](ext); + return res; + }; + CFile.prototype["getStructure"] = function() + { + var res = []; + var str = Module["_GetStructure"](this.nativeFile); + var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4); + if (lenArray == null) + return res; + var len = lenArray[0]; + len -= 4; + if (len <= 0) + return res; + + var buffer = new Uint8Array(Module["HEAP8"].buffer, str + 4, len); + var reader = new CBinaryReader(buffer, 0, len); + + while (reader.isValid()) + { + var rec = {}; + rec["page"] = reader.readInt(); + rec["level"] = reader.readInt(); + if (this.type == 2) + { + rec["y"] = reader.readDouble(); + } + else + { + rec["y"] = reader.readInt(); + } + rec["description"] = reader.readString(); + res.push(rec); + } + + Module["_free"](str); + return res; + }; + + CFile.prototype.memory = function() + { + return Module["HEAP8"]; + }; + CFile.prototype.free = function(pointer) + { + Module["_free"](pointer); + }; + CFile.prototype.isValid = function() + { + return this.pages.length > 0; + }; + CFile.prototype.getPage = function(pageIndex, width, height) + { + if (pageIndex < 0 || pageIndex >= this.pages.length) + return null; + if (!width) width = this.pages[pageIndex].W; + if (!height) height = this.pages[pageIndex].H; + var t0 = performance.now(); + var pixels = this.getPagePixmap(pageIndex, width, height); + if (!pixels) + return null; + + if (!this.logging) + { + var image = this._pixelsToCanvas(pixels, width, height); + } + else + { + var t1 = performance.now(); + var image = this._pixelsToCanvas(pixels, width, height); + var t2 = performance.now(); + //console.log("time: " + (t1 - t0) + ", " + (t2 - t1)); + } + /* + if (this.pages[pageIndex].Lines) + { + var ctx = image.getContext("2d"); + for (let i = 0; i < this.pages[pageIndex].Lines.length; i++) + { + for (let j = 0; j < this.pages[pageIndex].Lines[i].Glyphs.length; j++) + { + let glyph = this.pages[pageIndex].Lines[i].Glyphs[j]; + ctx.font = glyph.fontSize + 'px ' + glyph.fontName; + ctx.fillText(glyph.UChar, glyph.X, glyph.Y); + } + } + } + */ + this.free(pixels); + return image; + }; + CFile.prototype._pixelsToCanvas = function(pixels, width, height) + { + if (!this.isUse3d) + { + return this._pixelsToCanvas2d(pixels, width, height); + } + + try + { + return this._pixelsToCanvas3d(pixels, width, height); + } + catch (err) + { + this.isUse3d = false; + if (this.cacheManager) + this.cacheManager.clear(); + return this._pixelsToCanvas(pixels, width, height); + } + }; + CFile.prototype._pixelsToCanvas2d = function(pixels, width, height) + { + var canvas = null; + if (this.cacheManager) + { + canvas = this.cacheManager.lock(width, height); + } + else + { + canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + } + + var mappedBuffer = new Uint8ClampedArray(this.memory().buffer, pixels, 4 * width * height); + var imageData = new ImageData(mappedBuffer, width, height); + var ctx = canvas.getContext("2d"); + if (ctx) + ctx.putImageData(imageData, 0, 0); + return canvas; + }; + + CFile.prototype._pixelsToCanvas3d = function(pixels, width, height) + { + var vs_source = "\ +attribute vec2 aVertex;\n\ +attribute vec2 aTex;\n\ +varying vec2 vTex;\n\ +void main() {\n\ + gl_Position = vec4(aVertex, 0.0, 1.0);\n\ + vTex = aTex;\n\ +}"; + + var fs_source = "\ +precision mediump float;\n\ +uniform sampler2D uTexture;\n\ +varying vec2 vTex;\n\ +void main() {\n\ + gl_FragColor = texture2D(uTexture, vTex);\n\ +}"; + var canvas = null; + if (this.cacheManager) + { + canvas = this.cacheManager.lock(width, height); + } + else + { + canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + } + + var gl = canvas.getContext('webgl', { preserveDrawingBuffer : true }); + if (!gl) + throw new Error('FAIL: could not create webgl canvas context'); + + var colorCorrect = gl.BROWSER_DEFAULT_WEBGL; + gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, colorCorrect); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + + gl.viewport(0, 0, canvas.width, canvas.height); + gl.clearColor(0, 0, 0, 1); + gl.clear(gl.COLOR_BUFFER_BIT); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: webgl canvas context setup failed'); + + function createShader(source, type) { + var shader = gl.createShader(type); + gl.shaderSource(shader, source); + gl.compileShader(shader); + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) + throw new Error('FAIL: shader ' + id + ' compilation failed'); + return shader; + } + + var program = gl.createProgram(); + gl.attachShader(program, createShader(vs_source, gl.VERTEX_SHADER)); + gl.attachShader(program, createShader(fs_source, gl.FRAGMENT_SHADER)); + gl.linkProgram(program); + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + throw new Error('FAIL: webgl shader program linking failed'); + gl.useProgram(program); + + var texture = gl.createTexture(); + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(this.memory().buffer, pixels, 4 * width * height)); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: creating webgl image texture failed'); + + function createBuffer(data) { + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + return buffer; + } + + var vertexCoords = new Float32Array([-1, 1, -1, -1, 1, -1, 1, 1]); + var vertexBuffer = createBuffer(vertexCoords); + var location = gl.getAttribLocation(program, 'aVertex'); + gl.enableVertexAttribArray(location); + gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: vertex-coord setup failed'); + + var texCoords = new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]); + var texBuffer = createBuffer(texCoords); + var location = gl.getAttribLocation(program, 'aTex'); + gl.enableVertexAttribArray(location); + gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0); + + if (gl.getError() != gl.NONE) + throw new Error('FAIL: tex-coord setup setup failed'); + + gl.drawArrays(gl.TRIANGLE_FAN, 0, 4); + return canvas; + }; + + window["AscViewer"]["CDrawingFile"] = CFile; + +})(window, undefined); diff --git a/DjVuFile/wasm/all_files_test/drawingfile.wasm b/DjVuFile/wasm/all_files_test/drawingfile.wasm new file mode 100644 index 0000000000..5bfa79e11a Binary files /dev/null and b/DjVuFile/wasm/all_files_test/drawingfile.wasm differ diff --git a/DjVuFile/wasm/all_files_test/file.js b/DjVuFile/wasm/all_files_test/file.js index ec26c1c97c..849722527c 100644 --- a/DjVuFile/wasm/all_files_test/file.js +++ b/DjVuFile/wasm/all_files_test/file.js @@ -242,156 +242,6 @@ return ""; }; - CFile.prototype.isValid = function() - { - return this.pages.length > 0; - }; - - // private functions - CFile.prototype._pixelsToCanvas2d = function(pixels, width, height) - { - var canvas = null; - if (this.cacheManager) - { - canvas = this.cacheManager.lock(width, height); - } - else - { - canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; - } - - var mappedBuffer = new Uint8ClampedArray(this.memory().buffer, pixels, 4 * width * height); - var imageData = new ImageData(mappedBuffer, width, height); - var ctx = canvas.getContext("2d"); - if (ctx) - ctx.putImageData(imageData, 0, 0); - return canvas; - }; - - CFile.prototype._pixelsToCanvas3d = function(pixels, width, height) - { - var vs_source = "\ -attribute vec2 aVertex;\n\ -attribute vec2 aTex;\n\ -varying vec2 vTex;\n\ -void main() {\n\ - gl_Position = vec4(aVertex, 0.0, 1.0);\n\ - vTex = aTex;\n\ -}"; - - var fs_source = "\ -precision mediump float;\n\ -uniform sampler2D uTexture;\n\ -varying vec2 vTex;\n\ -void main() {\n\ - gl_FragColor = texture2D(uTexture, vTex);\n\ -}"; - var canvas = null; - if (this.cacheManager) - { - canvas = this.cacheManager.lock(width, height); - } - else - { - canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; - } - - var gl = canvas.getContext('webgl', { preserveDrawingBuffer : true }); - if (!gl) - throw new Error('FAIL: could not create webgl canvas context'); - - var colorCorrect = gl.BROWSER_DEFAULT_WEBGL; - gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, colorCorrect); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); - - gl.viewport(0, 0, canvas.width, canvas.height); - gl.clearColor(0, 0, 0, 1); - gl.clear(gl.COLOR_BUFFER_BIT); - - if (gl.getError() != gl.NONE) - throw new Error('FAIL: webgl canvas context setup failed'); - - function createShader(source, type) { - var shader = gl.createShader(type); - gl.shaderSource(shader, source); - gl.compileShader(shader); - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) - throw new Error('FAIL: shader ' + id + ' compilation failed'); - return shader; - } - - var program = gl.createProgram(); - gl.attachShader(program, createShader(vs_source, gl.VERTEX_SHADER)); - gl.attachShader(program, createShader(fs_source, gl.FRAGMENT_SHADER)); - gl.linkProgram(program); - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - throw new Error('FAIL: webgl shader program linking failed'); - gl.useProgram(program); - - var texture = gl.createTexture(); - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(this.memory().buffer, pixels, 4 * width * height)); - - if (gl.getError() != gl.NONE) - throw new Error('FAIL: creating webgl image texture failed'); - - function createBuffer(data) { - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); - return buffer; - } - - var vertexCoords = new Float32Array([-1, 1, -1, -1, 1, -1, 1, 1]); - var vertexBuffer = createBuffer(vertexCoords); - var location = gl.getAttribLocation(program, 'aVertex'); - gl.enableVertexAttribArray(location); - gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0); - - if (gl.getError() != gl.NONE) - throw new Error('FAIL: vertex-coord setup failed'); - - var texCoords = new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]); - var texBuffer = createBuffer(texCoords); - var location = gl.getAttribLocation(program, 'aTex'); - gl.enableVertexAttribArray(location); - gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0); - - if (gl.getError() != gl.NONE) - throw new Error('FAIL: tex-coord setup setup failed'); - - gl.drawArrays(gl.TRIANGLE_FAN, 0, 4); - return canvas; - }; - - CFile.prototype._pixelsToCanvas = function(pixels, width, height) - { - if (!this.isUse3d) - { - return this._pixelsToCanvas2d(pixels, width, height); - } - - try - { - return this._pixelsToCanvas3d(pixels, width, height); - } - catch (err) - { - this.isUse3d = false; - if (this.cacheManager) - this.cacheManager.clear(); - return this._pixelsToCanvas(pixels, width, height); - } - }; window["AscViewer"] = window["AscViewer"] || {}; window["AscViewer"].IFile = CFile; @@ -399,53 +249,7 @@ void main() {\n\ window["AscViewer"].createFile = function(buffer) { var data = new Uint8Array(buffer); - var file = null; - - var maxCheck = Math.min(100, data.length - 5); - var pdfCheck = [ - "%".charCodeAt(0), - "P".charCodeAt(0), - "D".charCodeAt(0), - "F".charCodeAt(0), - "-".charCodeAt(0) - ]; - var isPdf = false; - for (var i = 0; i < maxCheck; i++) - { - if (data[i + 0] == pdfCheck[0] && - data[i + 1] == pdfCheck[1] && - data[i + 2] == pdfCheck[2] && - data[i + 3] == pdfCheck[3] && - data[i + 4] == pdfCheck[4]) - { - isPdf = true; - break; - } - } - - if (isPdf) - { - file = new window["AscViewer"].PdfFile(); - file.type = 0; - } - - if (data.length > 7 && !file && - 0x41 == data[0] && 0x54 == data[1] && 0x26 == data[2] && 0x54 == data[3] && - 0x46 == data[4] && 0x4f == data[5] && 0x52 == data[6] && 0x4d == data[7]) - { - file = new window["AscViewer"].DjVuFile(); - } - - if (!file) - { - file = new window["AscViewer"].XpsFile(); - } - - if (!file) - { - file = new window["AscViewer"].PdfFile(); - file.type = 1; - } + var file = new window["AscViewer"].CDrawingFile(); file.loadFromData(data); file.cacheManager = new window.CCacheManager(); diff --git a/DjVuFile/wasm/all_files_test/index.html b/DjVuFile/wasm/all_files_test/index.html index b1c0dbc6d0..33572e1cc0 100644 --- a/DjVuFile/wasm/all_files_test/index.html +++ b/DjVuFile/wasm/all_files_test/index.html @@ -6,9 +6,7 @@ - - - +
diff --git a/DjVuFile/wasm/all_files_test/pdf/pdf.js b/DjVuFile/wasm/all_files_test/pdf/pdf.js deleted file mode 100644 index 294a601c26..0000000000 --- a/DjVuFile/wasm/all_files_test/pdf/pdf.js +++ /dev/null @@ -1,116 +0,0 @@ -(function(window, undefined) { - - var printErr = undefined; - var FS = undefined; - var print = undefined; - - var getBinaryPromise = null; - if (window["AscDesktopEditor"] && document.currentScript && 0 == document.currentScript.src.indexOf("file:///")) - { - // fetch not support file:/// scheme - window.fetch = undefined; - - getBinaryPromise = function() { - - var wasmPath = "ascdesktop://fonts/" + wasmBinaryFile.substr(8); - return new Promise(function (resolve, reject) { - - var xhr = new XMLHttpRequest(); - xhr.open('GET', wasmPath, true); - xhr.responseType = 'arraybuffer'; - - if (xhr.overrideMimeType) - xhr.overrideMimeType('text/plain; charset=x-user-defined'); - else - xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); - - xhr.onload = function () { - if (this.status == 200) { - resolve(new Uint8Array(this.response)); - } - }; - - xhr.send(null); - - }); - } - } - else - { - getBinaryPromise = function() { - return getBinaryPromise2(); - } - } - - var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=true;var ENVIRONMENT_IS_WORKER=false;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime;if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(typeof WebAssembly!=="object"){err("no native wasm support detected")}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":2708,"maximum":2708+0,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(u8Array[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var WASM_PAGE_SIZE=65536;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var DYNAMIC_BASE=7293168,DYNAMICTOP_PTR=2050128;var INITIAL_TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_TOTAL_MEMORY/WASM_PAGE_SIZE})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_TOTAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";out(what);err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";throw new WebAssembly.RuntimeError(what)}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return String.prototype.startsWith?filename.startsWith(dataURIPrefix):filename.indexOf(dataURIPrefix)===0}var wasmBinaryFile="pdf.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(){try{if(wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(wasmBinaryFile)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise2(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary()})}return new Promise(function(resolve,reject){resolve(getBinary())})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}__ATINIT__.push({func:function(){___wasm_call_ctors()}});function ___lock(){}var PATH={splitPath:function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},extname:function(path){return PATH.splitPath(path)[3]},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:function(l,r){return PATH.normalize(l+"/"+r)}};var SYSCALLS={buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:0,get:function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(){var ret=UTF8ToString(SYSCALLS.get());return ret},get64:function(){var low=SYSCALLS.get(),high=SYSCALLS.get();return low},getZero:function(){SYSCALLS.get()}};function ___syscall10(which,varargs){SYSCALLS.varargs=varargs;try{var path=SYSCALLS.getStr();FS.unlink(path);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall195(which,varargs){SYSCALLS.varargs=varargs;try{var path=SYSCALLS.getStr(),buf=SYSCALLS.get();return SYSCALLS.doStat(FS.stat,path,buf)}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall221(which,varargs){SYSCALLS.varargs=varargs;try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall40(which,varargs){SYSCALLS.varargs=varargs;try{var path=SYSCALLS.getStr();FS.rmdir(path);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall5(which,varargs){SYSCALLS.varargs=varargs;try{var pathname=SYSCALLS.getStr(),flags=SYSCALLS.get(),mode=SYSCALLS.get();var stream=FS.open(pathname,flags,mode);return stream.fd}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___syscall54(which,varargs){SYSCALLS.varargs=varargs;try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___unlock(){}function _emscripten_get_heap_size(){return HEAP8.length}var setjmpId=0;function _saveSetjmp(env,label,table,size){env=env|0;label=label|0;table=table|0;size=size|0;var i=0;setjmpId=setjmpId+1|0;HEAP32[env>>2]=setjmpId;while((i|0)<(size|0)){if((HEAP32[table+(i<<3)>>2]|0)==0){HEAP32[table+(i<<3)>>2]=setjmpId;HEAP32[table+((i<<3)+4)>>2]=label;HEAP32[table+((i<<3)+8)>>2]=0;setTempRet0(size|0);return table|0}i=i+1|0}size=size*2|0;table=_realloc(table|0,8*(size+1|0)|0)|0;table=_saveSetjmp(env|0,label|0,table|0,size|0)|0;setTempRet0(size|0);return table|0}function _testSetjmp(id,table,size){id=id|0;table=table|0;size=size|0;var i=0,curr=0;while((i|0)<(size|0)){curr=HEAP32[table+(i<<3)>>2]|0;if((curr|0)==0)break;if((curr|0)==(id|0)){return HEAP32[table+((i<<3)+4)>>2]|0}i=i+1|0}return 0}function _longjmp(env,value){_setThrew(env,value||1);throw"longjmp"}function _emscripten_longjmp(env,value){_longjmp(env,value)}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=_emscripten_get_heap_size();var PAGE_MULTIPLE=65536;var maxHeapSize=2147483648-PAGE_MULTIPLE;if(requestedSize>maxHeapSize){return false}var minHeapSize=16777216;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(minHeapSize,requestedSize,overGrownHeapSize),PAGE_MULTIPLE));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}var ENV={};function _emscripten_get_environ(){if(!_emscripten_get_environ.strings){var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":(typeof navigator==="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8","_":thisProgram};for(var x in ENV){env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}_emscripten_get_environ.strings=strings}return _emscripten_get_environ.strings}function _environ_get(__environ,environ_buf){var strings=_emscripten_get_environ();var bufSize=0;strings.forEach(function(string,i){var ptr=environ_buf+bufSize;HEAP32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=_emscripten_get_environ();HEAP32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAP32[penviron_buf_size>>2]=bufSize;return 0}function _exit(status){exit(status)}function _fd_close(fd){try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_read(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doReadv(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){try{return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_write(fd,iov,iovcnt,pnum){try{var num=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _getTempRet0(){return getTempRet0()|0}var ___tm_current=2050144;var ___tm_timezone=(stringToUTF8("GMT",2050192,4),2050192);function _gmtime_r(time,tmPtr){var date=new Date(HEAP32[time>>2]*1e3);HEAP32[tmPtr>>2]=date.getUTCSeconds();HEAP32[tmPtr+4>>2]=date.getUTCMinutes();HEAP32[tmPtr+8>>2]=date.getUTCHours();HEAP32[tmPtr+12>>2]=date.getUTCDate();HEAP32[tmPtr+16>>2]=date.getUTCMonth();HEAP32[tmPtr+20>>2]=date.getUTCFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getUTCDay();HEAP32[tmPtr+36>>2]=0;HEAP32[tmPtr+32>>2]=0;var start=Date.UTC(date.getUTCFullYear(),0,1,0,0,0,0);var yday=(date.getTime()-start)/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+40>>2]=___tm_timezone;return tmPtr}function _gmtime(time){return _gmtime_r(time,___tm_current)}function _setTempRet0($i){setTempRet0($i|0)}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}var asmLibraryArg={"Ea":___lock,"Da":___syscall10,"Fa":___syscall195,"S":___syscall221,"Ca":___syscall40,"Ba":___syscall5,"Aa":___syscall54,"L":___unlock,"d":_emscripten_longjmp,"ua":_emscripten_memcpy_big,"va":_emscripten_resize_heap,"wa":_environ_get,"xa":_environ_sizes_get,"da":_exit,"T":_fd_close,"za":_fd_read,"ha":_fd_seek,"ya":_fd_write,"a":_getTempRet0,"Z":_gmtime,"x":invoke_fii,"p":invoke_fiii,"F":invoke_fiiii,"i":invoke_ii,"aa":invoke_iif,"e":invoke_iii,"La":invoke_iiidi,"Q":invoke_iiiffffiii,"ea":invoke_iiiffiiiiiii,"f":invoke_iiii,"Ja":invoke_iiiif,"m":invoke_iiiii,"Ga":invoke_iiiiifffiiii,"K":invoke_iiiiiffi,"ga":invoke_iiiiiffii,"_":invoke_iiiiiffiifii,"fa":invoke_iiiiifiii,"o":invoke_iiiiii,"r":invoke_iiiiiii,"u":invoke_iiiiiiii,"y":invoke_iiiiiiiii,"I":invoke_iiiiiiiiii,"ca":invoke_iiiiiiiiiii,"N":invoke_iiiiiiiiiiiiii,"Ka":invoke_iiiiiiiiiiiiiiiii,"ra":invoke_iiiiiiiij,"ia":invoke_iiiiij,"sa":invoke_iiiij,"ja":invoke_iiiji,"pa":invoke_iij,"oa":invoke_jii,"ka":invoke_jiiji,"l":invoke_vi,"g":invoke_vii,"ba":invoke_viid,"z":invoke_viif,"w":invoke_viiff,"W":invoke_viifff,"B":invoke_viiffff,"E":invoke_viiffffff,"U":invoke_viifffiiff,"X":invoke_viiffii,"j":invoke_viii,"Ha":invoke_viiid,"Y":invoke_viiif,"$":invoke_viiifffffiii,"Ia":invoke_viiififi,"h":invoke_viiii,"V":invoke_viiiif,"t":invoke_viiiiff,"D":invoke_viiiifi,"n":invoke_viiiii,"q":invoke_viiiiii,"H":invoke_viiiiiifi,"M":invoke_viiiiiifiifffffiii,"s":invoke_viiiiiii,"G":invoke_viiiiiiif,"A":invoke_viiiiiiifi,"v":invoke_viiiiiiii,"J":invoke_viiiiiiiii,"O":invoke_viiiiiiiiii,"P":invoke_viiiiiiiiiii,"C":invoke_viiiiiiiiiiiii,"na":invoke_viiij,"qa":invoke_viij,"ma":invoke_viiji,"la":invoke_viijii,"ta":invoke_vij,"memory":wasmMemory,"k":_saveSetjmp,"b":_setTempRet0,"table":wasmTable,"c":_testSetjmp,"R":_time};var asm=createWasm();Module["asm"]=asm;var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["Ma"]).apply(null,arguments)};var _Pdf_Load=Module["_Pdf_Load"]=function(){return(_Pdf_Load=Module["_Pdf_Load"]=Module["asm"]["Na"]).apply(null,arguments)};var _Pdf_Close=Module["_Pdf_Close"]=function(){return(_Pdf_Close=Module["_Pdf_Close"]=Module["asm"]["Oa"]).apply(null,arguments)};var _Pdf_GetInfo=Module["_Pdf_GetInfo"]=function(){return(_Pdf_GetInfo=Module["_Pdf_GetInfo"]=Module["asm"]["Pa"]).apply(null,arguments)};var _Pdf_GetPixmap=Module["_Pdf_GetPixmap"]=function(){return(_Pdf_GetPixmap=Module["_Pdf_GetPixmap"]=Module["asm"]["Qa"]).apply(null,arguments)};var _Pdf_Delete=Module["_Pdf_Delete"]=function(){return(_Pdf_Delete=Module["_Pdf_Delete"]=Module["asm"]["Ra"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["Sa"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["Ta"]).apply(null,arguments)};var _realloc=Module["_realloc"]=function(){return(_realloc=Module["_realloc"]=Module["asm"]["Ua"]).apply(null,arguments)};var _setThrew=Module["_setThrew"]=function(){return(_setThrew=Module["_setThrew"]=Module["asm"]["Va"]).apply(null,arguments)};var dynCall_v=Module["dynCall_v"]=function(){return(dynCall_v=Module["dynCall_v"]=Module["asm"]["Wa"]).apply(null,arguments)};var dynCall_vi=Module["dynCall_vi"]=function(){return(dynCall_vi=Module["dynCall_vi"]=Module["asm"]["Xa"]).apply(null,arguments)};var dynCall_vii=Module["dynCall_vii"]=function(){return(dynCall_vii=Module["dynCall_vii"]=Module["asm"]["Ya"]).apply(null,arguments)};var dynCall_viii=Module["dynCall_viii"]=function(){return(dynCall_viii=Module["dynCall_viii"]=Module["asm"]["Za"]).apply(null,arguments)};var dynCall_viiii=Module["dynCall_viiii"]=function(){return(dynCall_viiii=Module["dynCall_viiii"]=Module["asm"]["_a"]).apply(null,arguments)};var dynCall_viiiii=Module["dynCall_viiiii"]=function(){return(dynCall_viiiii=Module["dynCall_viiiii"]=Module["asm"]["$a"]).apply(null,arguments)};var dynCall_viiiiii=Module["dynCall_viiiiii"]=function(){return(dynCall_viiiiii=Module["dynCall_viiiiii"]=Module["asm"]["ab"]).apply(null,arguments)};var dynCall_viiiiiii=Module["dynCall_viiiiiii"]=function(){return(dynCall_viiiiiii=Module["dynCall_viiiiiii"]=Module["asm"]["bb"]).apply(null,arguments)};var dynCall_viiiiiiii=Module["dynCall_viiiiiiii"]=function(){return(dynCall_viiiiiiii=Module["dynCall_viiiiiiii"]=Module["asm"]["cb"]).apply(null,arguments)};var dynCall_viiiiiiiii=Module["dynCall_viiiiiiiii"]=function(){return(dynCall_viiiiiiiii=Module["dynCall_viiiiiiiii"]=Module["asm"]["db"]).apply(null,arguments)};var dynCall_viiiiiiiiii=Module["dynCall_viiiiiiiiii"]=function(){return(dynCall_viiiiiiiiii=Module["dynCall_viiiiiiiiii"]=Module["asm"]["eb"]).apply(null,arguments)};var dynCall_viiiiiiiiiii=Module["dynCall_viiiiiiiiiii"]=function(){return(dynCall_viiiiiiiiiii=Module["dynCall_viiiiiiiiiii"]=Module["asm"]["fb"]).apply(null,arguments)};var dynCall_viiiiiiiiiiiii=Module["dynCall_viiiiiiiiiiiii"]=function(){return(dynCall_viiiiiiiiiiiii=Module["dynCall_viiiiiiiiiiiii"]=Module["asm"]["gb"]).apply(null,arguments)};var dynCall_viiiiiiif=Module["dynCall_viiiiiiif"]=function(){return(dynCall_viiiiiiif=Module["dynCall_viiiiiiif"]=Module["asm"]["hb"]).apply(null,arguments)};var dynCall_viiiiiiifi=Module["dynCall_viiiiiiifi"]=function(){return(dynCall_viiiiiiifi=Module["dynCall_viiiiiiifi"]=Module["asm"]["ib"]).apply(null,arguments)};var dynCall_viiiiiifi=Module["dynCall_viiiiiifi"]=function(){return(dynCall_viiiiiifi=Module["dynCall_viiiiiifi"]=Module["asm"]["jb"]).apply(null,arguments)};var dynCall_viiiiiifiifffffiii=Module["dynCall_viiiiiifiifffffiii"]=function(){return(dynCall_viiiiiifiifffffiii=Module["dynCall_viiiiiifiifffffiii"]=Module["asm"]["kb"]).apply(null,arguments)};var dynCall_viiiif=Module["dynCall_viiiif"]=function(){return(dynCall_viiiif=Module["dynCall_viiiif"]=Module["asm"]["lb"]).apply(null,arguments)};var dynCall_viiiifi=Module["dynCall_viiiifi"]=function(){return(dynCall_viiiifi=Module["dynCall_viiiifi"]=Module["asm"]["mb"]).apply(null,arguments)};var dynCall_viiiiff=Module["dynCall_viiiiff"]=function(){return(dynCall_viiiiff=Module["dynCall_viiiiff"]=Module["asm"]["nb"]).apply(null,arguments)};var dynCall_viiij=Module["dynCall_viiij"]=function(){return(dynCall_viiij=Module["dynCall_viiij"]=Module["asm"]["ob"]).apply(null,arguments)};var dynCall_viiif=Module["dynCall_viiif"]=function(){return(dynCall_viiif=Module["dynCall_viiif"]=Module["asm"]["pb"]).apply(null,arguments)};var dynCall_viiififi=Module["dynCall_viiififi"]=function(){return(dynCall_viiififi=Module["dynCall_viiififi"]=Module["asm"]["qb"]).apply(null,arguments)};var dynCall_viiifffffiii=Module["dynCall_viiifffffiii"]=function(){return(dynCall_viiifffffiii=Module["dynCall_viiifffffiii"]=Module["asm"]["rb"]).apply(null,arguments)};var dynCall_viiid=Module["dynCall_viiid"]=function(){return(dynCall_viiid=Module["dynCall_viiid"]=Module["asm"]["sb"]).apply(null,arguments)};var dynCall_viij=Module["dynCall_viij"]=function(){return(dynCall_viij=Module["dynCall_viij"]=Module["asm"]["tb"]).apply(null,arguments)};var dynCall_viiji=Module["dynCall_viiji"]=function(){return(dynCall_viiji=Module["dynCall_viiji"]=Module["asm"]["ub"]).apply(null,arguments)};var dynCall_viijii=Module["dynCall_viijii"]=function(){return(dynCall_viijii=Module["dynCall_viijii"]=Module["asm"]["vb"]).apply(null,arguments)};var dynCall_viif=Module["dynCall_viif"]=function(){return(dynCall_viif=Module["dynCall_viif"]=Module["asm"]["wb"]).apply(null,arguments)};var dynCall_viiff=Module["dynCall_viiff"]=function(){return(dynCall_viiff=Module["dynCall_viiff"]=Module["asm"]["xb"]).apply(null,arguments)};var dynCall_viiffii=Module["dynCall_viiffii"]=function(){return(dynCall_viiffii=Module["dynCall_viiffii"]=Module["asm"]["yb"]).apply(null,arguments)};var dynCall_viifff=Module["dynCall_viifff"]=function(){return(dynCall_viifff=Module["dynCall_viifff"]=Module["asm"]["zb"]).apply(null,arguments)};var dynCall_viifffiiff=Module["dynCall_viifffiiff"]=function(){return(dynCall_viifffiiff=Module["dynCall_viifffiiff"]=Module["asm"]["Ab"]).apply(null,arguments)};var dynCall_viiffff=Module["dynCall_viiffff"]=function(){return(dynCall_viiffff=Module["dynCall_viiffff"]=Module["asm"]["Bb"]).apply(null,arguments)};var dynCall_viiffffff=Module["dynCall_viiffffff"]=function(){return(dynCall_viiffffff=Module["dynCall_viiffffff"]=Module["asm"]["Cb"]).apply(null,arguments)};var dynCall_viid=Module["dynCall_viid"]=function(){return(dynCall_viid=Module["dynCall_viid"]=Module["asm"]["Db"]).apply(null,arguments)};var dynCall_vij=Module["dynCall_vij"]=function(){return(dynCall_vij=Module["dynCall_vij"]=Module["asm"]["Eb"]).apply(null,arguments)};var dynCall_ii=Module["dynCall_ii"]=function(){return(dynCall_ii=Module["dynCall_ii"]=Module["asm"]["Fb"]).apply(null,arguments)};var dynCall_iii=Module["dynCall_iii"]=function(){return(dynCall_iii=Module["dynCall_iii"]=Module["asm"]["Gb"]).apply(null,arguments)};var dynCall_iiii=Module["dynCall_iiii"]=function(){return(dynCall_iiii=Module["dynCall_iiii"]=Module["asm"]["Hb"]).apply(null,arguments)};var dynCall_iiiii=Module["dynCall_iiiii"]=function(){return(dynCall_iiiii=Module["dynCall_iiiii"]=Module["asm"]["Ib"]).apply(null,arguments)};var dynCall_iiiiii=Module["dynCall_iiiiii"]=function(){return(dynCall_iiiiii=Module["dynCall_iiiiii"]=Module["asm"]["Jb"]).apply(null,arguments)};var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=function(){return(dynCall_iiiiiii=Module["dynCall_iiiiiii"]=Module["asm"]["Kb"]).apply(null,arguments)};var dynCall_iiiiiiii=Module["dynCall_iiiiiiii"]=function(){return(dynCall_iiiiiiii=Module["dynCall_iiiiiiii"]=Module["asm"]["Lb"]).apply(null,arguments)};var dynCall_iiiiiiiii=Module["dynCall_iiiiiiiii"]=function(){return(dynCall_iiiiiiiii=Module["dynCall_iiiiiiiii"]=Module["asm"]["Mb"]).apply(null,arguments)};var dynCall_iiiiiiiiii=Module["dynCall_iiiiiiiiii"]=function(){return(dynCall_iiiiiiiiii=Module["dynCall_iiiiiiiiii"]=Module["asm"]["Nb"]).apply(null,arguments)};var dynCall_iiiiiiiiiii=Module["dynCall_iiiiiiiiiii"]=function(){return(dynCall_iiiiiiiiiii=Module["dynCall_iiiiiiiiiii"]=Module["asm"]["Ob"]).apply(null,arguments)};var dynCall_iiiiiiiiiiiiii=Module["dynCall_iiiiiiiiiiiiii"]=function(){return(dynCall_iiiiiiiiiiiiii=Module["dynCall_iiiiiiiiiiiiii"]=Module["asm"]["Pb"]).apply(null,arguments)};var dynCall_iiiiiiiiiiiiiiiii=Module["dynCall_iiiiiiiiiiiiiiiii"]=function(){return(dynCall_iiiiiiiiiiiiiiiii=Module["dynCall_iiiiiiiiiiiiiiiii"]=Module["asm"]["Qb"]).apply(null,arguments)};var dynCall_iiiiiiiij=Module["dynCall_iiiiiiiij"]=function(){return(dynCall_iiiiiiiij=Module["dynCall_iiiiiiiij"]=Module["asm"]["Rb"]).apply(null,arguments)};var dynCall_iiiiij=Module["dynCall_iiiiij"]=function(){return(dynCall_iiiiij=Module["dynCall_iiiiij"]=Module["asm"]["Sb"]).apply(null,arguments)};var dynCall_iiiiifiii=Module["dynCall_iiiiifiii"]=function(){return(dynCall_iiiiifiii=Module["dynCall_iiiiifiii"]=Module["asm"]["Tb"]).apply(null,arguments)};var dynCall_iiiiiffi=Module["dynCall_iiiiiffi"]=function(){return(dynCall_iiiiiffi=Module["dynCall_iiiiiffi"]=Module["asm"]["Ub"]).apply(null,arguments)};var dynCall_iiiiiffii=Module["dynCall_iiiiiffii"]=function(){return(dynCall_iiiiiffii=Module["dynCall_iiiiiffii"]=Module["asm"]["Vb"]).apply(null,arguments)};var dynCall_iiiiiffiifii=Module["dynCall_iiiiiffiifii"]=function(){return(dynCall_iiiiiffiifii=Module["dynCall_iiiiiffiifii"]=Module["asm"]["Wb"]).apply(null,arguments)};var dynCall_iiiiifffiiii=Module["dynCall_iiiiifffiiii"]=function(){return(dynCall_iiiiifffiiii=Module["dynCall_iiiiifffiiii"]=Module["asm"]["Xb"]).apply(null,arguments)};var dynCall_iiiij=Module["dynCall_iiiij"]=function(){return(dynCall_iiiij=Module["dynCall_iiiij"]=Module["asm"]["Yb"]).apply(null,arguments)};var dynCall_iiiif=Module["dynCall_iiiif"]=function(){return(dynCall_iiiif=Module["dynCall_iiiif"]=Module["asm"]["Zb"]).apply(null,arguments)};var dynCall_iiiji=Module["dynCall_iiiji"]=function(){return(dynCall_iiiji=Module["dynCall_iiiji"]=Module["asm"]["_b"]).apply(null,arguments)};var dynCall_iiiffiiiiiii=Module["dynCall_iiiffiiiiiii"]=function(){return(dynCall_iiiffiiiiiii=Module["dynCall_iiiffiiiiiii"]=Module["asm"]["$b"]).apply(null,arguments)};var dynCall_iiiffffiii=Module["dynCall_iiiffffiii"]=function(){return(dynCall_iiiffffiii=Module["dynCall_iiiffffiii"]=Module["asm"]["ac"]).apply(null,arguments)};var dynCall_iiidi=Module["dynCall_iiidi"]=function(){return(dynCall_iiidi=Module["dynCall_iiidi"]=Module["asm"]["bc"]).apply(null,arguments)};var dynCall_iij=Module["dynCall_iij"]=function(){return(dynCall_iij=Module["dynCall_iij"]=Module["asm"]["cc"]).apply(null,arguments)};var dynCall_iif=Module["dynCall_iif"]=function(){return(dynCall_iif=Module["dynCall_iif"]=Module["asm"]["dc"]).apply(null,arguments)};var dynCall_jii=Module["dynCall_jii"]=function(){return(dynCall_jii=Module["dynCall_jii"]=Module["asm"]["ec"]).apply(null,arguments)};var dynCall_jiiji=Module["dynCall_jiiji"]=function(){return(dynCall_jiiji=Module["dynCall_jiiji"]=Module["asm"]["fc"]).apply(null,arguments)};var dynCall_fii=Module["dynCall_fii"]=function(){return(dynCall_fii=Module["dynCall_fii"]=Module["asm"]["gc"]).apply(null,arguments)};var dynCall_fiii=Module["dynCall_fiii"]=function(){return(dynCall_fiii=Module["dynCall_fiii"]=Module["asm"]["hc"]).apply(null,arguments)};var dynCall_fiiii=Module["dynCall_fiiii"]=function(){return(dynCall_fiiii=Module["dynCall_fiiii"]=Module["asm"]["ic"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["jc"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["kc"]).apply(null,arguments)};function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iiii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return dynCall_ii(index,a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return dynCall_iii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{dynCall_vii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{dynCall_vi(index,a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return dynCall_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiidi(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiidi(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{dynCall_viii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return dynCall_iiiiiii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return dynCall_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viiiiii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiiii(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiifi(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{dynCall_viiiiiiifi(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiifi(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{dynCall_viiiiiifi(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiifi(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viiiifi(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{dynCall_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiif(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{dynCall_viiiiiiif(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiffii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return dynCall_iiiiiffii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return dynCall_iiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiff(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiff(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viif(index,a1,a2,a3){var sp=stackSave();try{dynCall_viif(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiffffiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return dynCall_iiiffffiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiifiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{return dynCall_iiiiifiii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{dynCall_viiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{dynCall_viiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiffiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return dynCall_iiiffiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{dynCall_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16){var sp=stackSave();try{return dynCall_iiiiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{return dynCall_iiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13){var sp=stackSave();try{return dynCall_iiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13){var sp=stackSave();try{dynCall_viiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viid(index,a1,a2,a3){var sp=stackSave();try{dynCall_viid(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iif(index,a1,a2){var sp=stackSave();try{return dynCall_iif(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiif(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiiif(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_fiii(index,a1,a2,a3){var sp=stackSave();try{return dynCall_fiii(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_fii(index,a1,a2){var sp=stackSave();try{return dynCall_fii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_fiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_fiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiffff(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viiffff(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiififi(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{dynCall_viiififi(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiid(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiid(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiifffffiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{dynCall_viiifffffiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiifiifffffiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17){var sp=stackSave();try{dynCall_viiiiiifiifffffiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiffi(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return dynCall_iiiiiffi(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiffiifii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return dynCall_iiiiiffiifii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{dynCall_viiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiff(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viiiiff(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiffffff(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{dynCall_viiffffff(index,a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiif(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiif(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiffii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viiffii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viifff(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viifff(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiif(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiiif(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiifffiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{return dynCall_iiiiifffiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viifffiiff(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{dynCall_viifffiiff(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vij(index,a1,a2,a3){var sp=stackSave();try{dynCall_vij(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiij(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiij(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiiiiij(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return dynCall_iiiiiiiij(index,a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viij(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viij(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iij(index,a1,a2,a3){var sp=stackSave();try{return dynCall_iij(index,a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_jii(index,a1,a2){var sp=stackSave();try{return dynCall_jii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiij(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiij(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiji(index,a1,a2,a3,a4,a5){var sp=stackSave();try{dynCall_viiji(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viijii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{dynCall_viijii(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_jiiji(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_jiiji(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiji(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return dynCall_iiiji(index,a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiij(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return dynCall_iiiiij(index,a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}Module["asm"]=asm;var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;if(ABORT)return;initRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&noExitRuntime&&status===0){return}if(noExitRuntime){}else{ABORT=true;EXITSTATUS=status;exitRuntime();if(Module["onExit"])Module["onExit"](status)}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}noExitRuntime=true;run(); - - /** - * - * @param config - * @constructor - * @extends {AscViewer.IFile} - */ - function CFile() - { - AscViewer.IFile.call(this); - this.stream = -1; - this.type = 0; - } - - CFile.prototype = Object.create(AscViewer.IFile.prototype); - CFile.prototype.constructor = CFile; - - CFile.prototype.loadFromData = function(data) - { - var _stream = Module["_malloc"](data.length); - Module["HEAP8"].set(data, _stream); - this.nativeFile = Module["_Pdf_Load"](_stream, data.length, this.type); - this.stream = _stream; - return this.getInfo(); - }; - CFile.prototype.getInfo = function() - { - if (!this.nativeFile) - return false; - - var _info = Module["_Pdf_GetInfo"](this.nativeFile); - if (!_info) - return false; - - var _pages = Module["HEAP32"][_info >> 2]; - var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages); - - var _cur = 1; - for (var i = 0; i < _pages; i++) - { - this.pages.push({ W : _buffer[_cur++], H : _buffer[_cur++], Dpi : _buffer[_cur++] }); - } - - this.free(_info); - return this.pages.length > 0; - }; - CFile.prototype.getPagePixmap = function(pageIndex, width, height) - { - return Module["_Pdf_GetPixmap"](this.nativeFile, pageIndex, width, height); - }; - CFile.prototype.close = function() - { - Module["_Pdf_Close"](this.nativeFile); - this.nativeFile = 0; - this.pages = []; - if (this.stream > 0) - Module["_free"](this.stream); - this.stream = -1; - }; - CFile.prototype.memory = function() - { - return Module["HEAP8"]; - }; - CFile.prototype.free = function(pointer) - { - Module["_Pdf_Delete"](pointer); - }; - - window["AscViewer"].PdfFile = CFile; - -})(window, undefined); diff --git a/DjVuFile/wasm/all_files_test/pdf/pdf.wasm b/DjVuFile/wasm/all_files_test/pdf/pdf.wasm deleted file mode 100644 index 82d4be5157..0000000000 Binary files a/DjVuFile/wasm/all_files_test/pdf/pdf.wasm and /dev/null differ diff --git a/DjVuFile/wasm/all_files_test/xps_djvu/djvu.js b/DjVuFile/wasm/all_files_test/xps_djvu/djvu.js deleted file mode 100644 index e0977249e8..0000000000 --- a/DjVuFile/wasm/all_files_test/xps_djvu/djvu.js +++ /dev/null @@ -1,352 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2019 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -(function(window, undefined) { - - var printErr = undefined; - var FS = undefined; - var print = undefined; - - var getBinaryPromise = null; - if (window["AscDesktopEditor"] && document.currentScript && 0 == document.currentScript.src.indexOf("file:///")) - { - // fetch not support file:/// scheme - window.fetch = undefined; - - getBinaryPromise = function() { - - var wasmPath = "ascdesktop://fonts/" + wasmBinaryFile.substr(8); - return new Promise(function (resolve, reject) { - - var xhr = new XMLHttpRequest(); - xhr.open('GET', wasmPath, true); - xhr.responseType = 'arraybuffer'; - - if (xhr.overrideMimeType) - xhr.overrideMimeType('text/plain; charset=x-user-defined'); - else - xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); - - xhr.onload = function () { - if (this.status == 200) { - resolve(new Uint8Array(this.response)); - } - }; - - xhr.send(null); - - }); - } - } - else - { - getBinaryPromise = function() { - return getBinaryPromise2(); - } - } - - (function(){ - - if (undefined !== String.prototype.fromUtf8 && - undefined !== String.prototype.toUtf8) - return; - - /** - * Read string from utf8 - * @param {Uint8Array} buffer - * @param {number} [start=0] - * @param {number} [len] - * @returns {string} - */ - String.prototype.fromUtf8 = function(buffer, start, len) { - if (undefined === start) - start = 0; - if (undefined === len) - len = buffer.length; - - var result = ""; - var index = start; - var end = start + len; - while (index < end) - { - var u0 = buffer[index++]; - if (!(u0 & 128)) - { - result += String.fromCharCode(u0); - continue; - } - var u1 = buffer[index++] & 63; - if ((u0 & 224) == 192) - { - result += String.fromCharCode((u0 & 31) << 6 | u1); - continue; - } - var u2 = buffer[index++] & 63; - if ((u0 & 240) == 224) - u0 = (u0 & 15) << 12 | u1 << 6 | u2; - else - u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | buffer[index++] & 63; - if (u0 < 65536) - result += String.fromCharCode(u0); - else - { - var ch = u0 - 65536; - result += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); - } - } - return result; - }; - - /** - * Convert string to utf8 array - * @returns {Uint8Array} - */ - String.prototype.toUtf8 = function() { - var inputLen = this.length; - var testLen = 6 * inputLen + 1; - var tmpStrings = new ArrayBuffer(testLen); - - var code = 0; - var index = 0; - - var outputIndex = 0; - var outputDataTmp = new Uint8Array(tmpStrings); - var outputData = outputDataTmp; - - while (index < inputLen) - { - code = this.charCodeAt(index++); - if (code >= 0xD800 && code <= 0xDFFF && index < inputLen) - code = 0x10000 + (((code & 0x3FF) << 10) | (0x03FF & this.charCodeAt(index++))); - - if (code < 0x80) - outputData[outputIndex++] = code; - else if (code < 0x0800) - { - outputData[outputIndex++] = 0xC0 | (code >> 6); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x10000) - { - outputData[outputIndex++] = 0xE0 | (code >> 12); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x1FFFFF) - { - outputData[outputIndex++] = 0xF0 | (code >> 18); - outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x3FFFFFF) - { - outputData[outputIndex++] = 0xF8 | (code >> 24); - outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x7FFFFFFF) - { - outputData[outputIndex++] = 0xFC | (code >> 30); - outputData[outputIndex++] = 0x80 | ((code >> 24) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - } - - outputData[outputIndex++] = 0; - - return new Uint8Array(tmpStrings, 0, outputIndex); - }; - -})(); - - - var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=true;var ENVIRONMENT_IS_WORKER=false;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!=="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!=="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}var wasmBinaryFile="xps_djvu.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise2(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["W"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["Y"];addOnInit(Module["asm"]["X"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){var result=WebAssembly.instantiate(binary,info);return result}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){wasmTable.get(func)()}else{wasmTable.get(func)(callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var runtimeKeepaliveCounter=0;function keepRuntimeAlive(){return noExitRuntime||runtimeKeepaliveCounter>0}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}var _emscripten_get_now;_emscripten_get_now=function(){return performance.now()};var _emscripten_get_now_is_monotonic=true;function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function _clock_gettime(clk_id,tp){var now;if(clk_id===0){now=Date.now()}else if((clk_id===1||clk_id===4)&&_emscripten_get_now_is_monotonic){now=_emscripten_get_now()}else{setErrNo(28);return-1}HEAP32[tp>>2]=now/1e3|0;HEAP32[tp+4>>2]=now%1e3*1e3*1e3|0;return 0}function ___clock_gettime(a0,a1){return _clock_gettime(a0,a1)}var ExceptionInfoAttrs={DESTRUCTOR_OFFSET:0,REFCOUNT_OFFSET:4,TYPE_OFFSET:8,CAUGHT_OFFSET:12,RETHROWN_OFFSET:13,SIZE:16};function ___cxa_allocate_exception(size){return _malloc(size+ExceptionInfoAttrs.SIZE)+ExceptionInfoAttrs.SIZE}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-ExceptionInfoAttrs.SIZE;this.set_type=function(type){HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]=type};this.get_type=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]};this.set_destructor=function(destructor){HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]=destructor};this.get_destructor=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]!=0};this.init=function(type,destructor){this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=prev-1;return prev===1}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}function _gmtime_r(time,tmPtr){var date=new Date(HEAP32[time>>2]*1e3);HEAP32[tmPtr>>2]=date.getUTCSeconds();HEAP32[tmPtr+4>>2]=date.getUTCMinutes();HEAP32[tmPtr+8>>2]=date.getUTCHours();HEAP32[tmPtr+12>>2]=date.getUTCDate();HEAP32[tmPtr+16>>2]=date.getUTCMonth();HEAP32[tmPtr+20>>2]=date.getUTCFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getUTCDay();HEAP32[tmPtr+36>>2]=0;HEAP32[tmPtr+32>>2]=0;var start=Date.UTC(date.getUTCFullYear(),0,1,0,0,0,0);var yday=(date.getTime()-start)/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;if(!_gmtime_r.GMTString)_gmtime_r.GMTString=allocateUTF8("GMT");HEAP32[tmPtr+40>>2]=_gmtime_r.GMTString;return tmPtr}function ___gmtime_r(a0,a1){return _gmtime_r(a0,a1)}var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},get64:function(low,high){return low}};function ___sys_chdir(path){}function ___sys_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;return 0}function ___sys_fstat64(fd,buf){}function ___sys_getcwd(buf,size){}function ___sys_getdents64(fd,dirp,count){}function ___sys_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;return 0}function ___sys_lstat64(path,buf){}function ___sys_mkdir(path,mode){path=SYSCALLS.getStr(path);return SYSCALLS.doMkdir(path,mode)}function syscallMmap2(addr,len,prot,flags,fd,off){off<<=12;var ptr;var allocated=false;if((flags&16)!==0&&addr%65536!==0){return-28}if((flags&32)!==0){ptr=_memalign(65536,len);if(!ptr)return-48;_memset(ptr,0,len);allocated=true}else{return-52}SYSCALLS.mappings[ptr]={malloc:ptr,len:len,allocated:allocated,fd:fd,prot:prot,flags:flags,offset:off};return ptr}function ___sys_mmap2(addr,len,prot,flags,fd,off){return syscallMmap2(addr,len,prot,flags,fd,off)}function syscallMunmap(addr,len){if((addr|0)===-1||len===0){return-28}var info=SYSCALLS.mappings[addr];if(!info)return 0;if(len===info.len){SYSCALLS.mappings[addr]=null;if(info.allocated){_free(info.malloc)}}return 0}function ___sys_munmap(addr,len){return syscallMunmap(addr,len)}function ___sys_open(path,flags,varargs){SYSCALLS.varargs=varargs}function ___sys_readlink(path,buf,bufsize){path=SYSCALLS.getStr(path);return SYSCALLS.doReadlink(path,buf,bufsize)}function ___sys_rmdir(path){}function ___sys_stat64(path,buf){}function ___sys_unlink(path){}function _abort(){abort()}function _longjmp(env,value){_setThrew(env,value||1);throw"longjmp"}function _emscripten_longjmp(a0,a1){return _longjmp(a0,a1)}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=2147483648;if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator==="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAP32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAP32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAP32[penviron_buf_size>>2]=bufSize;return 0}function _exit(status){exit(status)}function _fd_close(fd){return 0}function _fd_fdstat_get(fd,pbuf){var type=fd==1||fd==2?2:abort();HEAP8[pbuf>>0]=type;return 0}function _fd_read(fd,iov,iovcnt,pnum){var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doReadv(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){}function _fd_write(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=num;return 0}function _getTempRet0(){return getTempRet0()}function _tzset(){if(_tzset.called)return;_tzset.called=true;var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAP32[__get_timezone()>>2]=stdTimezoneOffset*60;HEAP32[__get_daylight()>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAP32[__get_tzname()+4>>2]=summerNamePtr}else{HEAP32[__get_tzname()>>2]=summerNamePtr;HEAP32[__get_tzname()+4>>2]=winterNamePtr}}function _mktime(tmPtr){_tzset();var date=new Date(HEAP32[tmPtr+20>>2]+1900,HEAP32[tmPtr+16>>2],HEAP32[tmPtr+12>>2],HEAP32[tmPtr+8>>2],HEAP32[tmPtr+4>>2],HEAP32[tmPtr>>2],0);var dst=HEAP32[tmPtr+32>>2];var guessedOffset=date.getTimezoneOffset();var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dstOffset=Math.min(winterOffset,summerOffset);if(dst<0){HEAP32[tmPtr+32>>2]=Number(summerOffset!=winterOffset&&dstOffset==guessedOffset)}else if(dst>0!=(dstOffset==guessedOffset)){var nonDstOffset=Math.max(winterOffset,summerOffset);var trueOffset=dst>0?dstOffset:nonDstOffset;date.setTime(date.getTime()+(trueOffset-guessedOffset)*6e4)}HEAP32[tmPtr+24>>2]=date.getDay();var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();return date.getTime()/1e3|0}function _setTempRet0(val){setTempRet0(val)}function __isLeapYear(year){return year%4===0&&(year%100!==0||year%400===0)}function __arraySum(array,index){var sum=0;for(var i=0;i<=index;sum+=array[i++]){}return sum}var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date,days){var newDate=new Date(date.getTime());while(days>0){var leap=__isLeapYear(newDate.getFullYear());var currentMonth=newDate.getMonth();var daysInCurrentMonth=(leap?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR)[currentMonth];if(days>daysInCurrentMonth-newDate.getDate()){days-=daysInCurrentMonth-newDate.getDate()+1;newDate.setDate(1);if(currentMonth<11){newDate.setMonth(currentMonth+1)}else{newDate.setMonth(0);newDate.setFullYear(newDate.getFullYear()+1)}}else{newDate.setDate(newDate.getDate()+days);return newDate}}return newDate}function _strftime(s,maxsize,format,tm){var tm_zone=HEAP32[tm+40>>2];var date={tm_sec:HEAP32[tm>>2],tm_min:HEAP32[tm+4>>2],tm_hour:HEAP32[tm+8>>2],tm_mday:HEAP32[tm+12>>2],tm_mon:HEAP32[tm+16>>2],tm_year:HEAP32[tm+20>>2],tm_wday:HEAP32[tm+24>>2],tm_yday:HEAP32[tm+28>>2],tm_isdst:HEAP32[tm+32>>2],tm_gmtoff:HEAP32[tm+36>>2],tm_zone:tm_zone?UTF8ToString(tm_zone):""};var pattern=UTF8ToString(format);var EXPANSION_RULES_1={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var rule in EXPANSION_RULES_1){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_1[rule])}var WEEKDAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];function leadingSomething(value,digits,character){var str=typeof value==="number"?value.toString():value||"";while(str.length0?1:0}var compare;if((compare=sgn(date1.getFullYear()-date2.getFullYear()))===0){if((compare=sgn(date1.getMonth()-date2.getMonth()))===0){compare=sgn(date1.getDate()-date2.getDate())}}return compare}function getFirstWeekStartDate(janFourth){switch(janFourth.getDay()){case 0:return new Date(janFourth.getFullYear()-1,11,29);case 1:return janFourth;case 2:return new Date(janFourth.getFullYear(),0,3);case 3:return new Date(janFourth.getFullYear(),0,2);case 4:return new Date(janFourth.getFullYear(),0,1);case 5:return new Date(janFourth.getFullYear()-1,11,31);case 6:return new Date(janFourth.getFullYear()-1,11,30)}}function getWeekBasedYear(date){var thisDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new Date(thisDate.getFullYear(),0,4);var janFourthNextYear=new Date(thisDate.getFullYear()+1,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);if(compareByDay(firstWeekStartThisYear,thisDate)<=0){if(compareByDay(firstWeekStartNextYear,thisDate)<=0){return thisDate.getFullYear()+1}else{return thisDate.getFullYear()}}else{return thisDate.getFullYear()-1}}var EXPANSION_RULES_2={"%a":function(date){return WEEKDAYS[date.tm_wday].substring(0,3)},"%A":function(date){return WEEKDAYS[date.tm_wday]},"%b":function(date){return MONTHS[date.tm_mon].substring(0,3)},"%B":function(date){return MONTHS[date.tm_mon]},"%C":function(date){var year=date.tm_year+1900;return leadingNulls(year/100|0,2)},"%d":function(date){return leadingNulls(date.tm_mday,2)},"%e":function(date){return leadingSomething(date.tm_mday,2," ")},"%g":function(date){return getWeekBasedYear(date).toString().substring(2)},"%G":function(date){return getWeekBasedYear(date)},"%H":function(date){return leadingNulls(date.tm_hour,2)},"%I":function(date){var twelveHour=date.tm_hour;if(twelveHour==0)twelveHour=12;else if(twelveHour>12)twelveHour-=12;return leadingNulls(twelveHour,2)},"%j":function(date){return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900)?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,date.tm_mon-1),3)},"%m":function(date){return leadingNulls(date.tm_mon+1,2)},"%M":function(date){return leadingNulls(date.tm_min,2)},"%n":function(){return"\n"},"%p":function(date){if(date.tm_hour>=0&&date.tm_hour<12){return"AM"}else{return"PM"}},"%S":function(date){return leadingNulls(date.tm_sec,2)},"%t":function(){return"\t"},"%u":function(date){return date.tm_wday||7},"%U":function(date){var janFirst=new Date(date.tm_year+1900,0,1);var firstSunday=janFirst.getDay()===0?janFirst:__addDays(janFirst,7-janFirst.getDay());var endDate=new Date(date.tm_year+1900,date.tm_mon,date.tm_mday);if(compareByDay(firstSunday,endDate)<0){var februaryFirstUntilEndMonth=__arraySum(__isLeapYear(endDate.getFullYear())?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,endDate.getMonth()-1)-31;var firstSundayUntilEndJanuary=31-firstSunday.getDate();var days=firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();return leadingNulls(Math.ceil(days/7),2)}return compareByDay(firstSunday,janFirst)===0?"01":"00"},"%V":function(date){var janFourthThisYear=new Date(date.tm_year+1900,0,4);var janFourthNextYear=new Date(date.tm_year+1901,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);var endDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);if(compareByDay(endDate,firstWeekStartThisYear)<0){return"53"}if(compareByDay(firstWeekStartNextYear,endDate)<=0){return"01"}var daysDifference;if(firstWeekStartThisYear.getFullYear()=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":function(date){return date.tm_zone},"%%":function(){return"%"}};for(var rule in EXPANSION_RULES_2){if(pattern.includes(rule)){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date))}}var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize){return 0}writeArrayToMemory(bytes,s);return bytes.length-1}function _strftime_l(s,maxsize,format,tm){return _strftime(s,maxsize,format,tm)}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var asmLibraryArg={"a":___assert_fail,"N":___clock_gettime,"A":___cxa_allocate_exception,"z":___cxa_throw,"I":___gmtime_r,"M":___sys_chdir,"r":___sys_fcntl64,"R":___sys_fstat64,"L":___sys_getcwd,"U":___sys_getdents64,"O":___sys_ioctl,"P":___sys_lstat64,"Q":___sys_mkdir,"T":___sys_mmap2,"S":___sys_munmap,"q":___sys_open,"K":___sys_readlink,"u":___sys_rmdir,"v":___sys_stat64,"p":___sys_unlink,"f":_abort,"d":_emscripten_longjmp,"C":_emscripten_memcpy_big,"D":_emscripten_resize_heap,"G":_environ_get,"H":_environ_sizes_get,"J":_exit,"n":_fd_close,"F":_fd_fdstat_get,"t":_fd_read,"B":_fd_seek,"o":_fd_write,"b":_getTempRet0,"g":invoke_ii,"l":invoke_iii,"j":invoke_iiii,"i":invoke_iiiii,"s":invoke_iiiiii,"w":invoke_v,"h":invoke_vi,"e":invoke_vii,"k":invoke_viii,"y":invoke_viiii,"V":invoke_viiiiiiiii,"m":_mktime,"c":_setTempRet0,"E":_strftime_l,"x":_time};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["X"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["Z"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["_"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["$"]).apply(null,arguments)};var _XPS_Load=Module["_XPS_Load"]=function(){return(_XPS_Load=Module["_XPS_Load"]=Module["asm"]["aa"]).apply(null,arguments)};var _DJVU_Load=Module["_DJVU_Load"]=function(){return(_DJVU_Load=Module["_DJVU_Load"]=Module["asm"]["ba"]).apply(null,arguments)};var _XPS_Close=Module["_XPS_Close"]=function(){return(_XPS_Close=Module["_XPS_Close"]=Module["asm"]["ca"]).apply(null,arguments)};var _XPS_GetInfo=Module["_XPS_GetInfo"]=function(){return(_XPS_GetInfo=Module["_XPS_GetInfo"]=Module["asm"]["da"]).apply(null,arguments)};var _XPS_GetPixmap=Module["_XPS_GetPixmap"]=function(){return(_XPS_GetPixmap=Module["_XPS_GetPixmap"]=Module["asm"]["ea"]).apply(null,arguments)};var _XPS_GetGlyphs=Module["_XPS_GetGlyphs"]=function(){return(_XPS_GetGlyphs=Module["_XPS_GetGlyphs"]=Module["asm"]["fa"]).apply(null,arguments)};var _DJVU_GetGlyphs=Module["_DJVU_GetGlyphs"]=function(){return(_DJVU_GetGlyphs=Module["_DJVU_GetGlyphs"]=Module["asm"]["ga"]).apply(null,arguments)};var _XPS_GetStructure=Module["_XPS_GetStructure"]=function(){return(_XPS_GetStructure=Module["_XPS_GetStructure"]=Module["asm"]["ha"]).apply(null,arguments)};var _DJVU_GetStructure=Module["_DJVU_GetStructure"]=function(){return(_DJVU_GetStructure=Module["_DJVU_GetStructure"]=Module["asm"]["ia"]).apply(null,arguments)};var _XPS_Delete=Module["_XPS_Delete"]=function(){return(_XPS_Delete=Module["_XPS_Delete"]=Module["asm"]["ja"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["ka"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["la"]).apply(null,arguments)};function invoke_ii(index,a1){var sp=stackSave();try{return wasmTable.get(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return wasmTable.get(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{wasmTable.get(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{wasmTable.get(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{wasmTable.get(index)()}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){EXITSTATUS=status;if(implicit&&keepRuntimeAlive()&&status===0){return}if(keepRuntimeAlive()){}else{exitRuntime();if(Module["onExit"])Module["onExit"](status);ABORT=true}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run(); - - - /** - * - * @param config - * @constructor - * @extends {AscViewer.IFile} - */ - function CFile() - { - AscViewer.IFile.call(this); - } - - CFile.prototype = Object.create(AscViewer.IFile.prototype); - CFile.prototype.constructor = CFile; - - CFile.prototype.loadFromData = function(arrayBuffer) - { - var data = new Uint8Array(arrayBuffer); - var _stream = Module["_malloc"](data.length); - Module["HEAP8"].set(data, _stream); - this.nativeFile = Module["_DJVU_Load"](_stream, data.length); - Module["_free"](_stream); - return this.getInfo(); - }; - CFile.prototype.getInfo = function() - { - if (!this.nativeFile) - return false; - - var _info = Module["_XPS_GetInfo"](this.nativeFile); - if (!_info) - return false; - - var _pages = Module["HEAP32"][_info >> 2]; - var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages); - - var _cur = 1; - for (var i = 0; i < _pages; i++) - { - this.pages.push({ W : _buffer[_cur++], H : _buffer[_cur++], Dpi : _buffer[_cur++] }); - } - - this.free(_info); - return this.pages.length > 0; - }; - CFile.prototype.getPagePixmap = function(pageIndex, width, height) - { - var res = Module["_XPS_GetPixmap"](this.nativeFile, pageIndex, width, height); - - var glyphs = Module["_DJVU_GetGlyphs"](this.nativeFile, pageIndex); - if (glyphs == null) - return res; - var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4); - var len = lenArray[0]; - len -= 4; - if (len <= 0) - return res; - - this.pages[pageIndex].Lines = []; - var buffer = new Uint8Array(Module["HEAP8"].buffer, glyphs + 4, len); - var index = 0; - var Line = -1; - while (index < len) - { - var lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Word = "".fromUtf8(buffer, index, lenRec); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _X = parseFloat("".fromUtf8(buffer, index, lenRec)); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Y = parseFloat("".fromUtf8(buffer, index, lenRec)); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _W = parseFloat("".fromUtf8(buffer, index, lenRec)); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _H = parseFloat("".fromUtf8(buffer, index, lenRec)); - index += lenRec; - - Line++; - this.pages[pageIndex].Lines.push({ Glyphs : [] }); - for (let i = 0; i < _Word.length; i++) - { - this.pages[pageIndex].Lines[Line].Glyphs.push({ - X : (_X + _W / _Word.length * i) * 1.015, - UChar : _Word[i] - }); - } - this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y * 1.015; - this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H; - } - - return res; - }; - CFile.prototype.structure = function() - { - var res = []; - var str = Module["_DJVU_GetStructure"](this.nativeFile); - var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4); - if (lenArray == null) - return res; - var len = lenArray[0]; - len -= 4; - if (len <= 0) - return res; - - var buffer = new Uint8Array(Module["HEAP8"].buffer, str + 4, len); - var index = 0; - var Line = -1; - var prevY = -1; - while (index < len) - { - var lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Page = lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Level = lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Description = "".fromUtf8(buffer, index, lenRec); - index += lenRec; - - res.push({ page : _Page, level : _Level, Y : 0, description : _Description}); - } - - Module["_XPS_Delete"](str); - return res; - }; - CFile.prototype.close = function() - { - Module["_XPS_Close"](this.nativeFile); - this.nativeFile = 0; - this.pages = []; - }; - CFile.prototype.memory = function() - { - return Module["HEAP8"]; - }; - CFile.prototype.free = function(pointer) - { - Module["_XPS_Delete"](pointer); - }; - - window["AscViewer"].DjVuFile = CFile; - -})(window, undefined); diff --git a/DjVuFile/wasm/all_files_test/xps_djvu/xps.js b/DjVuFile/wasm/all_files_test/xps_djvu/xps.js deleted file mode 100644 index c1cc7dc566..0000000000 --- a/DjVuFile/wasm/all_files_test/xps_djvu/xps.js +++ /dev/null @@ -1,389 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2019 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -(function(window, undefined) { - - var printErr = undefined; - var FS = undefined; - var print = undefined; - - var getBinaryPromise = null; - if (window["AscDesktopEditor"] && document.currentScript && 0 == document.currentScript.src.indexOf("file:///")) - { - // fetch not support file:/// scheme - window.fetch = undefined; - - getBinaryPromise = function() { - - var wasmPath = "ascdesktop://fonts/" + wasmBinaryFile.substr(8); - return new Promise(function (resolve, reject) { - - var xhr = new XMLHttpRequest(); - xhr.open('GET', wasmPath, true); - xhr.responseType = 'arraybuffer'; - - if (xhr.overrideMimeType) - xhr.overrideMimeType('text/plain; charset=x-user-defined'); - else - xhr.setRequestHeader('Accept-Charset', 'x-user-defined'); - - xhr.onload = function () { - if (this.status == 200) { - resolve(new Uint8Array(this.response)); - } - }; - - xhr.send(null); - - }); - } - } - else - { - getBinaryPromise = function() { - return getBinaryPromise2(); - } - } - - (function(){ - - if (undefined !== String.prototype.fromUtf8 && - undefined !== String.prototype.toUtf8) - return; - - /** - * Read string from utf8 - * @param {Uint8Array} buffer - * @param {number} [start=0] - * @param {number} [len] - * @returns {string} - */ - String.prototype.fromUtf8 = function(buffer, start, len) { - if (undefined === start) - start = 0; - if (undefined === len) - len = buffer.length; - - var result = ""; - var index = start; - var end = start + len; - while (index < end) - { - var u0 = buffer[index++]; - if (!(u0 & 128)) - { - result += String.fromCharCode(u0); - continue; - } - var u1 = buffer[index++] & 63; - if ((u0 & 224) == 192) - { - result += String.fromCharCode((u0 & 31) << 6 | u1); - continue; - } - var u2 = buffer[index++] & 63; - if ((u0 & 240) == 224) - u0 = (u0 & 15) << 12 | u1 << 6 | u2; - else - u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | buffer[index++] & 63; - if (u0 < 65536) - result += String.fromCharCode(u0); - else - { - var ch = u0 - 65536; - result += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); - } - } - return result; - }; - - /** - * Convert string to utf8 array - * @returns {Uint8Array} - */ - String.prototype.toUtf8 = function() { - var inputLen = this.length; - var testLen = 6 * inputLen + 1; - var tmpStrings = new ArrayBuffer(testLen); - - var code = 0; - var index = 0; - - var outputIndex = 0; - var outputDataTmp = new Uint8Array(tmpStrings); - var outputData = outputDataTmp; - - while (index < inputLen) - { - code = this.charCodeAt(index++); - if (code >= 0xD800 && code <= 0xDFFF && index < inputLen) - code = 0x10000 + (((code & 0x3FF) << 10) | (0x03FF & this.charCodeAt(index++))); - - if (code < 0x80) - outputData[outputIndex++] = code; - else if (code < 0x0800) - { - outputData[outputIndex++] = 0xC0 | (code >> 6); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x10000) - { - outputData[outputIndex++] = 0xE0 | (code >> 12); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x1FFFFF) - { - outputData[outputIndex++] = 0xF0 | (code >> 18); - outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x3FFFFFF) - { - outputData[outputIndex++] = 0xF8 | (code >> 24); - outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - else if (code < 0x7FFFFFFF) - { - outputData[outputIndex++] = 0xFC | (code >> 30); - outputData[outputIndex++] = 0x80 | ((code >> 24) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 18) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 12) & 0x3F); - outputData[outputIndex++] = 0x80 | ((code >> 6) & 0x3F); - outputData[outputIndex++] = 0x80 | (code & 0x3F); - } - } - - outputData[outputIndex++] = 0; - - return new Uint8Array(tmpStrings, 0, outputIndex); - }; - -})(); - - - var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=true;var ENVIRONMENT_IS_WORKER=false;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!=="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var tempRet0=0;var setTempRet0=function(value){tempRet0=value};var getTempRet0=function(){return tempRet0};var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!=="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function allocateUTF8(str){var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8Array(str,HEAP8,ret,size);return ret}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}var wasmBinaryFile="xps_djvu.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise2(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["W"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["Y"];addOnInit(Module["asm"]["X"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){var result=WebAssembly.instantiate(binary,info);return result}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){wasmTable.get(func)()}else{wasmTable.get(func)(callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var runtimeKeepaliveCounter=0;function keepRuntimeAlive(){return noExitRuntime||runtimeKeepaliveCounter>0}function ___assert_fail(condition,filename,line,func){abort("Assertion failed: "+UTF8ToString(condition)+", at: "+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"])}var _emscripten_get_now;_emscripten_get_now=function(){return performance.now()};var _emscripten_get_now_is_monotonic=true;function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function _clock_gettime(clk_id,tp){var now;if(clk_id===0){now=Date.now()}else if((clk_id===1||clk_id===4)&&_emscripten_get_now_is_monotonic){now=_emscripten_get_now()}else{setErrNo(28);return-1}HEAP32[tp>>2]=now/1e3|0;HEAP32[tp+4>>2]=now%1e3*1e3*1e3|0;return 0}function ___clock_gettime(a0,a1){return _clock_gettime(a0,a1)}var ExceptionInfoAttrs={DESTRUCTOR_OFFSET:0,REFCOUNT_OFFSET:4,TYPE_OFFSET:8,CAUGHT_OFFSET:12,RETHROWN_OFFSET:13,SIZE:16};function ___cxa_allocate_exception(size){return _malloc(size+ExceptionInfoAttrs.SIZE)+ExceptionInfoAttrs.SIZE}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-ExceptionInfoAttrs.SIZE;this.set_type=function(type){HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]=type};this.get_type=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]};this.set_destructor=function(destructor){HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]=destructor};this.get_destructor=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]!=0};this.init=function(type,destructor){this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=prev-1;return prev===1}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}function _gmtime_r(time,tmPtr){var date=new Date(HEAP32[time>>2]*1e3);HEAP32[tmPtr>>2]=date.getUTCSeconds();HEAP32[tmPtr+4>>2]=date.getUTCMinutes();HEAP32[tmPtr+8>>2]=date.getUTCHours();HEAP32[tmPtr+12>>2]=date.getUTCDate();HEAP32[tmPtr+16>>2]=date.getUTCMonth();HEAP32[tmPtr+20>>2]=date.getUTCFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getUTCDay();HEAP32[tmPtr+36>>2]=0;HEAP32[tmPtr+32>>2]=0;var start=Date.UTC(date.getUTCFullYear(),0,1,0,0,0,0);var yday=(date.getTime()-start)/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;if(!_gmtime_r.GMTString)_gmtime_r.GMTString=allocateUTF8("GMT");HEAP32[tmPtr+40>>2]=_gmtime_r.GMTString;return tmPtr}function ___gmtime_r(a0,a1){return _gmtime_r(a0,a1)}var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},get64:function(low,high){return low}};function ___sys_chdir(path){}function ___sys_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;return 0}function ___sys_fstat64(fd,buf){}function ___sys_getcwd(buf,size){}function ___sys_getdents64(fd,dirp,count){}function ___sys_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;return 0}function ___sys_lstat64(path,buf){}function ___sys_mkdir(path,mode){path=SYSCALLS.getStr(path);return SYSCALLS.doMkdir(path,mode)}function syscallMmap2(addr,len,prot,flags,fd,off){off<<=12;var ptr;var allocated=false;if((flags&16)!==0&&addr%65536!==0){return-28}if((flags&32)!==0){ptr=_memalign(65536,len);if(!ptr)return-48;_memset(ptr,0,len);allocated=true}else{return-52}SYSCALLS.mappings[ptr]={malloc:ptr,len:len,allocated:allocated,fd:fd,prot:prot,flags:flags,offset:off};return ptr}function ___sys_mmap2(addr,len,prot,flags,fd,off){return syscallMmap2(addr,len,prot,flags,fd,off)}function syscallMunmap(addr,len){if((addr|0)===-1||len===0){return-28}var info=SYSCALLS.mappings[addr];if(!info)return 0;if(len===info.len){SYSCALLS.mappings[addr]=null;if(info.allocated){_free(info.malloc)}}return 0}function ___sys_munmap(addr,len){return syscallMunmap(addr,len)}function ___sys_open(path,flags,varargs){SYSCALLS.varargs=varargs}function ___sys_readlink(path,buf,bufsize){path=SYSCALLS.getStr(path);return SYSCALLS.doReadlink(path,buf,bufsize)}function ___sys_rmdir(path){}function ___sys_stat64(path,buf){}function ___sys_unlink(path){}function _abort(){abort()}function _longjmp(env,value){_setThrew(env,value||1);throw"longjmp"}function _emscripten_longjmp(a0,a1){return _longjmp(a0,a1)}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function emscripten_realloc_buffer(size){try{wasmMemory.grow(size-buffer.byteLength+65535>>>16);updateGlobalBufferAndViews(wasmMemory.buffer);return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=2147483648;if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator==="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAP32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAP32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAP32[penviron_buf_size>>2]=bufSize;return 0}function _exit(status){exit(status)}function _fd_close(fd){return 0}function _fd_fdstat_get(fd,pbuf){var type=fd==1||fd==2?2:abort();HEAP8[pbuf>>0]=type;return 0}function _fd_read(fd,iov,iovcnt,pnum){var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doReadv(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){}function _fd_write(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=num;return 0}function _getTempRet0(){return getTempRet0()}function _tzset(){if(_tzset.called)return;_tzset.called=true;var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAP32[__get_timezone()>>2]=stdTimezoneOffset*60;HEAP32[__get_daylight()>>2]=Number(winterOffset!=summerOffset);function extractZone(date){var match=date.toTimeString().match(/\(([A-Za-z ]+)\)$/);return match?match[1]:"GMT"}var winterName=extractZone(winter);var summerName=extractZone(summer);var winterNamePtr=allocateUTF8(winterName);var summerNamePtr=allocateUTF8(summerName);if(summerOffset>2]=winterNamePtr;HEAP32[__get_tzname()+4>>2]=summerNamePtr}else{HEAP32[__get_tzname()>>2]=summerNamePtr;HEAP32[__get_tzname()+4>>2]=winterNamePtr}}function _mktime(tmPtr){_tzset();var date=new Date(HEAP32[tmPtr+20>>2]+1900,HEAP32[tmPtr+16>>2],HEAP32[tmPtr+12>>2],HEAP32[tmPtr+8>>2],HEAP32[tmPtr+4>>2],HEAP32[tmPtr>>2],0);var dst=HEAP32[tmPtr+32>>2];var guessedOffset=date.getTimezoneOffset();var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dstOffset=Math.min(winterOffset,summerOffset);if(dst<0){HEAP32[tmPtr+32>>2]=Number(summerOffset!=winterOffset&&dstOffset==guessedOffset)}else if(dst>0!=(dstOffset==guessedOffset)){var nonDstOffset=Math.max(winterOffset,summerOffset);var trueOffset=dst>0?dstOffset:nonDstOffset;date.setTime(date.getTime()+(trueOffset-guessedOffset)*6e4)}HEAP32[tmPtr+24>>2]=date.getDay();var yday=(date.getTime()-start.getTime())/(1e3*60*60*24)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();return date.getTime()/1e3|0}function _setTempRet0(val){setTempRet0(val)}function __isLeapYear(year){return year%4===0&&(year%100!==0||year%400===0)}function __arraySum(array,index){var sum=0;for(var i=0;i<=index;sum+=array[i++]){}return sum}var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date,days){var newDate=new Date(date.getTime());while(days>0){var leap=__isLeapYear(newDate.getFullYear());var currentMonth=newDate.getMonth();var daysInCurrentMonth=(leap?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR)[currentMonth];if(days>daysInCurrentMonth-newDate.getDate()){days-=daysInCurrentMonth-newDate.getDate()+1;newDate.setDate(1);if(currentMonth<11){newDate.setMonth(currentMonth+1)}else{newDate.setMonth(0);newDate.setFullYear(newDate.getFullYear()+1)}}else{newDate.setDate(newDate.getDate()+days);return newDate}}return newDate}function _strftime(s,maxsize,format,tm){var tm_zone=HEAP32[tm+40>>2];var date={tm_sec:HEAP32[tm>>2],tm_min:HEAP32[tm+4>>2],tm_hour:HEAP32[tm+8>>2],tm_mday:HEAP32[tm+12>>2],tm_mon:HEAP32[tm+16>>2],tm_year:HEAP32[tm+20>>2],tm_wday:HEAP32[tm+24>>2],tm_yday:HEAP32[tm+28>>2],tm_isdst:HEAP32[tm+32>>2],tm_gmtoff:HEAP32[tm+36>>2],tm_zone:tm_zone?UTF8ToString(tm_zone):""};var pattern=UTF8ToString(format);var EXPANSION_RULES_1={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var rule in EXPANSION_RULES_1){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_1[rule])}var WEEKDAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"];function leadingSomething(value,digits,character){var str=typeof value==="number"?value.toString():value||"";while(str.length0?1:0}var compare;if((compare=sgn(date1.getFullYear()-date2.getFullYear()))===0){if((compare=sgn(date1.getMonth()-date2.getMonth()))===0){compare=sgn(date1.getDate()-date2.getDate())}}return compare}function getFirstWeekStartDate(janFourth){switch(janFourth.getDay()){case 0:return new Date(janFourth.getFullYear()-1,11,29);case 1:return janFourth;case 2:return new Date(janFourth.getFullYear(),0,3);case 3:return new Date(janFourth.getFullYear(),0,2);case 4:return new Date(janFourth.getFullYear(),0,1);case 5:return new Date(janFourth.getFullYear()-1,11,31);case 6:return new Date(janFourth.getFullYear()-1,11,30)}}function getWeekBasedYear(date){var thisDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);var janFourthThisYear=new Date(thisDate.getFullYear(),0,4);var janFourthNextYear=new Date(thisDate.getFullYear()+1,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);if(compareByDay(firstWeekStartThisYear,thisDate)<=0){if(compareByDay(firstWeekStartNextYear,thisDate)<=0){return thisDate.getFullYear()+1}else{return thisDate.getFullYear()}}else{return thisDate.getFullYear()-1}}var EXPANSION_RULES_2={"%a":function(date){return WEEKDAYS[date.tm_wday].substring(0,3)},"%A":function(date){return WEEKDAYS[date.tm_wday]},"%b":function(date){return MONTHS[date.tm_mon].substring(0,3)},"%B":function(date){return MONTHS[date.tm_mon]},"%C":function(date){var year=date.tm_year+1900;return leadingNulls(year/100|0,2)},"%d":function(date){return leadingNulls(date.tm_mday,2)},"%e":function(date){return leadingSomething(date.tm_mday,2," ")},"%g":function(date){return getWeekBasedYear(date).toString().substring(2)},"%G":function(date){return getWeekBasedYear(date)},"%H":function(date){return leadingNulls(date.tm_hour,2)},"%I":function(date){var twelveHour=date.tm_hour;if(twelveHour==0)twelveHour=12;else if(twelveHour>12)twelveHour-=12;return leadingNulls(twelveHour,2)},"%j":function(date){return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900)?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,date.tm_mon-1),3)},"%m":function(date){return leadingNulls(date.tm_mon+1,2)},"%M":function(date){return leadingNulls(date.tm_min,2)},"%n":function(){return"\n"},"%p":function(date){if(date.tm_hour>=0&&date.tm_hour<12){return"AM"}else{return"PM"}},"%S":function(date){return leadingNulls(date.tm_sec,2)},"%t":function(){return"\t"},"%u":function(date){return date.tm_wday||7},"%U":function(date){var janFirst=new Date(date.tm_year+1900,0,1);var firstSunday=janFirst.getDay()===0?janFirst:__addDays(janFirst,7-janFirst.getDay());var endDate=new Date(date.tm_year+1900,date.tm_mon,date.tm_mday);if(compareByDay(firstSunday,endDate)<0){var februaryFirstUntilEndMonth=__arraySum(__isLeapYear(endDate.getFullYear())?__MONTH_DAYS_LEAP:__MONTH_DAYS_REGULAR,endDate.getMonth()-1)-31;var firstSundayUntilEndJanuary=31-firstSunday.getDate();var days=firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();return leadingNulls(Math.ceil(days/7),2)}return compareByDay(firstSunday,janFirst)===0?"01":"00"},"%V":function(date){var janFourthThisYear=new Date(date.tm_year+1900,0,4);var janFourthNextYear=new Date(date.tm_year+1901,0,4);var firstWeekStartThisYear=getFirstWeekStartDate(janFourthThisYear);var firstWeekStartNextYear=getFirstWeekStartDate(janFourthNextYear);var endDate=__addDays(new Date(date.tm_year+1900,0,1),date.tm_yday);if(compareByDay(endDate,firstWeekStartThisYear)<0){return"53"}if(compareByDay(firstWeekStartNextYear,endDate)<=0){return"01"}var daysDifference;if(firstWeekStartThisYear.getFullYear()=0;off=Math.abs(off)/60;off=off/60*100+off%60;return(ahead?"+":"-")+String("0000"+off).slice(-4)},"%Z":function(date){return date.tm_zone},"%%":function(){return"%"}};for(var rule in EXPANSION_RULES_2){if(pattern.includes(rule)){pattern=pattern.replace(new RegExp(rule,"g"),EXPANSION_RULES_2[rule](date))}}var bytes=intArrayFromString(pattern,false);if(bytes.length>maxsize){return 0}writeArrayToMemory(bytes,s);return bytes.length-1}function _strftime_l(s,maxsize,format,tm){return _strftime(s,maxsize,format,tm)}function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var asmLibraryArg={"a":___assert_fail,"N":___clock_gettime,"A":___cxa_allocate_exception,"z":___cxa_throw,"I":___gmtime_r,"M":___sys_chdir,"r":___sys_fcntl64,"R":___sys_fstat64,"L":___sys_getcwd,"U":___sys_getdents64,"O":___sys_ioctl,"P":___sys_lstat64,"Q":___sys_mkdir,"T":___sys_mmap2,"S":___sys_munmap,"q":___sys_open,"K":___sys_readlink,"u":___sys_rmdir,"v":___sys_stat64,"p":___sys_unlink,"f":_abort,"d":_emscripten_longjmp,"C":_emscripten_memcpy_big,"D":_emscripten_resize_heap,"G":_environ_get,"H":_environ_sizes_get,"J":_exit,"n":_fd_close,"F":_fd_fdstat_get,"t":_fd_read,"B":_fd_seek,"o":_fd_write,"b":_getTempRet0,"g":invoke_ii,"l":invoke_iii,"j":invoke_iiii,"i":invoke_iiiii,"s":invoke_iiiiii,"w":invoke_v,"h":invoke_vi,"e":invoke_vii,"k":invoke_viii,"y":invoke_viiii,"V":invoke_viiiiiiiii,"m":_mktime,"c":_setTempRet0,"E":_strftime_l,"x":_time};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["X"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["Z"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["_"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["$"]).apply(null,arguments)};var _XPS_Load=Module["_XPS_Load"]=function(){return(_XPS_Load=Module["_XPS_Load"]=Module["asm"]["aa"]).apply(null,arguments)};var _DJVU_Load=Module["_DJVU_Load"]=function(){return(_DJVU_Load=Module["_DJVU_Load"]=Module["asm"]["ba"]).apply(null,arguments)};var _XPS_Close=Module["_XPS_Close"]=function(){return(_XPS_Close=Module["_XPS_Close"]=Module["asm"]["ca"]).apply(null,arguments)};var _XPS_GetInfo=Module["_XPS_GetInfo"]=function(){return(_XPS_GetInfo=Module["_XPS_GetInfo"]=Module["asm"]["da"]).apply(null,arguments)};var _XPS_GetPixmap=Module["_XPS_GetPixmap"]=function(){return(_XPS_GetPixmap=Module["_XPS_GetPixmap"]=Module["asm"]["ea"]).apply(null,arguments)};var _XPS_GetGlyphs=Module["_XPS_GetGlyphs"]=function(){return(_XPS_GetGlyphs=Module["_XPS_GetGlyphs"]=Module["asm"]["fa"]).apply(null,arguments)};var _DJVU_GetGlyphs=Module["_DJVU_GetGlyphs"]=function(){return(_DJVU_GetGlyphs=Module["_DJVU_GetGlyphs"]=Module["asm"]["ga"]).apply(null,arguments)};var _XPS_GetStructure=Module["_XPS_GetStructure"]=function(){return(_XPS_GetStructure=Module["_XPS_GetStructure"]=Module["asm"]["ha"]).apply(null,arguments)};var _DJVU_GetStructure=Module["_DJVU_GetStructure"]=function(){return(_DJVU_GetStructure=Module["_DJVU_GetStructure"]=Module["asm"]["ia"]).apply(null,arguments)};var _XPS_Delete=Module["_XPS_Delete"]=function(){return(_XPS_Delete=Module["_XPS_Delete"]=Module["asm"]["ja"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["ka"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["la"]).apply(null,arguments)};function invoke_ii(index,a1){var sp=stackSave();try{return wasmTable.get(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return wasmTable.get(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{wasmTable.get(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{wasmTable.get(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return wasmTable.get(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_viiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{wasmTable.get(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{wasmTable.get(index)()}catch(e){stackRestore(sp);if(e!==e+0&&e!=="longjmp")throw e;_setThrew(1,0)}}var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){EXITSTATUS=status;if(implicit&&keepRuntimeAlive()&&status===0){return}if(keepRuntimeAlive()){}else{exitRuntime();if(Module["onExit"])Module["onExit"](status);ABORT=true}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run(); - - - /** - * - * @param config - * @constructor - * @extends {AscViewer.IFile} - */ - function CFile() - { - AscViewer.IFile.call(this); - } - - CFile.prototype = Object.create(AscViewer.IFile.prototype); - CFile.prototype.constructor = CFile; - - CFile.prototype.loadFromData = function(arrayBuffer) - { - var data = new Uint8Array(arrayBuffer); - var _stream = Module["_malloc"](data.length); - Module["HEAP8"].set(data, _stream); - this.nativeFile = Module["_XPS_Load"](_stream, data.length); - Module["_free"](_stream); - return this.getInfo(); - }; - CFile.prototype.getInfo = function() - { - if (!this.nativeFile) - return false; - - var _info = Module["_XPS_GetInfo"](this.nativeFile); - if (!_info) - return false; - - var _pages = Module["HEAP32"][_info >> 2]; - var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages); - - var _cur = 1; - for (var i = 0; i < _pages; i++) - { - this.pages.push({ W : _buffer[_cur++], H : _buffer[_cur++], Dpi : _buffer[_cur++] }); - } - - this.free(_info); - return this.pages.length > 0; - }; - CFile.prototype.getPagePixmap = function(pageIndex, width, height) - { - var res = Module["_XPS_GetPixmap"](this.nativeFile, pageIndex, width, height); - - var glyphs = Module["_XPS_GetGlyphs"](this.nativeFile, pageIndex); - if (glyphs == null) - return res; - var lenArray = new Int32Array(Module["HEAP8"].buffer, glyphs, 4); - var len = lenArray[0]; - len -= 4; - if (len <= 0) - return res; - - this.pages[pageIndex].Lines = []; - var buffer = new Uint8Array(Module["HEAP8"].buffer, glyphs + 4, len); - var index = 0; - var Line = -1; - var prevY = -1; - while (index < len) - { - var lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _fontName = "".fromUtf8(buffer, index, lenRec); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _fontSize = parseFloat("".fromUtf8(buffer, index, lenRec)); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - let amount = lenRec; - for (var i = 0; i < amount; i++) - { - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _X = parseFloat("".fromUtf8(buffer, index, lenRec)); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Y = parseFloat("".fromUtf8(buffer, index, lenRec)); - if (_Y != prevY) - { - if (Line >= 0) - this.pages[pageIndex].Lines[Line].Glyphs.sort((prev, next) => prev.X - next.X); - Line++; - this.pages[pageIndex].Lines.push({ Glyphs : [] }); - prevY = _Y; - } - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - this.pages[pageIndex].Lines[Line].Glyphs.push({ - fontName : _fontName, - fontSize : _fontSize, - X : _X * 1.015, - Y : _Y * 1.015, - UChar : String.fromCharCode(lenRec) - }); - } - } - this.pages[pageIndex].Lines.sort((prev, next) => prev.Glyphs[0].Y - next.Glyphs[0].Y); - - prevY = -1; - var prevFontName = ""; - var prevFontSize = ""; - for (let i = 0; i < this.pages[pageIndex].Lines.length; i++) - { - for (let j = 0; j < this.pages[pageIndex].Lines[i].Glyphs.length; j++) - { - let glyph = this.pages[pageIndex].Lines[i].Glyphs[j]; - if (glyph.fontName == prevFontName) - delete glyph.fontName; - else - prevFontName = glyph.fontName; - if (glyph.fontSize == prevFontSize && j != 0) - delete glyph.fontSize; - else - prevFontSize = glyph.fontSize; - if (glyph.Y == prevY && j != 0) - delete glyph.Y; - else - prevY = glyph.Y; - } - } - Module["_XPS_Delete"](glyphs); - - return res; - }; - CFile.prototype.structure = function() - { - var res = []; - var str = Module["_XPS_GetStructure"](this.nativeFile); - var lenArray = new Int32Array(Module["HEAP8"].buffer, str, 4); - if (lenArray == null) - return res; - var len = lenArray[0]; - len -= 4; - if (len <= 0) - return res; - - var buffer = new Uint8Array(Module["HEAP8"].buffer, str + 4, len); - var index = 0; - var Line = -1; - var prevY = -1; - while (index < len) - { - var lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Page = lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Level = lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Y = parseFloat("".fromUtf8(buffer, index, lenRec)); - index += lenRec; - lenRec = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24; - index += 4; - var _Description = "".fromUtf8(buffer, index, lenRec); - index += lenRec; - - res.push({ page : _Page, level : _Level, Y : _Y, description : _Description}); - } - - Module["_XPS_Delete"](str); - return res; - }; - CFile.prototype.close = function() - { - Module["_XPS_Close"](this.nativeFile); - this.nativeFile = 0; - this.pages = []; - }; - CFile.prototype.memory = function() - { - return Module["HEAP8"]; - }; - CFile.prototype.free = function(pointer) - { - Module["_XPS_Delete"](pointer); - }; - - window["AscViewer"].XpsFile = CFile; - -})(window, undefined); diff --git a/DjVuFile/wasm/all_files_test/xps_djvu/xps_djvu.wasm b/DjVuFile/wasm/all_files_test/xps_djvu/xps_djvu.wasm deleted file mode 100644 index 9ecd5f2081..0000000000 Binary files a/DjVuFile/wasm/all_files_test/xps_djvu/xps_djvu.wasm and /dev/null differ diff --git a/DjVuFile/wasm/make.py b/DjVuFile/wasm/make.py index a92b5c02d4..e59d56f32c 100644 --- a/DjVuFile/wasm/make.py +++ b/DjVuFile/wasm/make.py @@ -15,9 +15,7 @@ base.cmd_in_dir("./../../DesktopEditor/graphics/pro/js", "python", ["make.py"]) # finalize if base.is_exist("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm"): - base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/xps.js", "./deploy/xps.js") - base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/djvu.js", "./deploy/djvu.js") - base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/pdf.js", "./deploy/pdf.js") + base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.js", "./deploy/drawingfile.js") base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm", "./deploy/drawingfile.wasm") else: print("make.py error") @@ -28,4 +26,3 @@ else: base.copy_file("./all_files_test/index.html", "./deploy/index.html") base.copy_file("./all_files_test/code.js", "./deploy/code.js") base.copy_file("./all_files_test/file.js", "./deploy/file.js") -base.copy_dir("./all_files_test/pdf", "./deploy/pdf") diff --git a/PdfReader/lib/xpdf/GlobalParams.cc b/PdfReader/lib/xpdf/GlobalParams.cc index a4a075fcb2..74cea46d82 100644 --- a/PdfReader/lib/xpdf/GlobalParams.cc +++ b/PdfReader/lib/xpdf/GlobalParams.cc @@ -784,6 +784,7 @@ GlobalParams::GlobalParams(const char *cfgFileName) { residentUnicodeMaps->add(map->getEncodingName(), map); // look for a user config file, then a system-wide config file +#ifndef BUILDING_WASM_MODULE f = NULL; fileName = NULL; if (cfgFileName && cfgFileName[0]) { @@ -820,6 +821,7 @@ GlobalParams::GlobalParams(const char *cfgFileName) { delete fileName; fclose(f); } +#endif // BUILDING_WASM_MODULE } void GlobalParams::setDataDirVar() { @@ -2239,6 +2241,8 @@ void GlobalParams::setupBaseFonts(const char *dir) { #ifdef __APPLE__ dfontFontNames = NULL; #endif + +#ifndef BUILDING_WASM_MODULE for (i = 0; displayFontTab[i].name; ++i) { if (fontFiles->lookup(displayFontTab[i].name)) { continue; @@ -2363,6 +2367,7 @@ void GlobalParams::setupBaseFonts(const char *dir) { } } } +#endif // BUILDING_WASM_MODULE #ifdef _WIN32 if (winFontDir[0]) { sysFonts->scanWindowsFonts(winFontDir);