@bentopdf/pymupdf-wasm 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,4 @@
1
+ var Z=Object.defineProperty;var i=(e,t)=>Z(e,"name",{value:t,configurable:!0}),R=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,s)=>(typeof require<"u"?require:t)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});function ee(e){return!isNaN(parseFloat(e))&&isFinite(e)}i(ee,"_isNumber");function S(e){return e.charAt(0).toUpperCase()+e.substring(1)}i(S,"_capitalize");function O(e){return function(){return this[e]}}i(O,"_getter");var E=["isConstructor","isEval","isNative","isToplevel"],P=["columnNumber","lineNumber"],N=["fileName","functionName","source"],te=["args"],ne=["evalOrigin"],k=E.concat(P,N,te,ne);function m(e){if(e)for(var t=0;t<k.length;t++)e[k[t]]!==void 0&&this["set"+S(k[t])](e[k[t]])}i(m,"StackFrame");m.prototype={getArgs:i(function(){return this.args},"getArgs"),setArgs:i(function(e){if(Object.prototype.toString.call(e)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=e},"setArgs"),getEvalOrigin:i(function(){return this.evalOrigin},"getEvalOrigin"),setEvalOrigin:i(function(e){if(e instanceof m)this.evalOrigin=e;else if(e instanceof Object)this.evalOrigin=new m(e);else throw new TypeError("Eval Origin must be an Object or StackFrame")},"setEvalOrigin"),toString:i(function(){var e=this.getFileName()||"",t=this.getLineNumber()||"",s=this.getColumnNumber()||"",r=this.getFunctionName()||"";return this.getIsEval()?e?"[eval] ("+e+":"+t+":"+s+")":"[eval]:"+t+":"+s:r?r+" ("+e+":"+t+":"+s+")":e+":"+t+":"+s},"toString")};m.fromString=i(function(t){var s=t.indexOf("("),r=t.lastIndexOf(")"),a=t.substring(0,s),n=t.substring(s+1,r).split(","),o=t.substring(r+1);if(o.indexOf("@")===0)var c=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(o,""),l=c[1],d=c[2],u=c[3];return new m({functionName:a,args:n||void 0,fileName:l,lineNumber:d||void 0,columnNumber:u||void 0})},"StackFrame$$fromString");for(b=0;b<E.length;b++)m.prototype["get"+S(E[b])]=O(E[b]),m.prototype["set"+S(E[b])]=function(e){return function(t){this[e]=!!t}}(E[b]);var b;for(v=0;v<P.length;v++)m.prototype["get"+S(P[v])]=O(P[v]),m.prototype["set"+S(P[v])]=function(e){return function(t){if(!ee(t))throw new TypeError(e+" must be a Number");this[e]=Number(t)}}(P[v]);var v;for(h=0;h<N.length;h++)m.prototype["get"+S(N[h])]=O(N[h]),m.prototype["set"+S(N[h])]=function(e){return function(t){this[e]=String(t)}}(N[h]);var h,A=m;function re(){var e=/^\s*at .*(\S+:\d+|\(native\))/m,t=/^(eval@)?(\[native code])?$/;return{parse:i(function(r){if(r.stack&&r.stack.match(e))return this.parseV8OrIE(r);if(r.stack)return this.parseFFOrSafari(r);throw new Error("Cannot parse given Error object")},"ErrorStackParser$$parse"),extractLocation:i(function(r){if(r.indexOf(":")===-1)return[r];var a=/(.+?)(?::(\d+))?(?::(\d+))?$/,n=a.exec(r.replace(/[()]/g,""));return[n[1],n[2]||void 0,n[3]||void 0]},"ErrorStackParser$$extractLocation"),parseV8OrIE:i(function(r){var a=r.stack.split(`
2
+ `).filter(function(n){return!!n.match(e)},this);return a.map(function(n){n.indexOf("(eval ")>-1&&(n=n.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var o=n.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),c=o.match(/ (\(.+\)$)/);o=c?o.replace(c[0],""):o;var l=this.extractLocation(c?c[1]:o),d=c&&o||void 0,u=["eval","<anonymous>"].indexOf(l[0])>-1?void 0:l[0];return new A({functionName:d,fileName:u,lineNumber:l[1],columnNumber:l[2],source:n})},this)},"ErrorStackParser$$parseV8OrIE"),parseFFOrSafari:i(function(r){var a=r.stack.split(`
3
+ `).filter(function(n){return!n.match(t)},this);return a.map(function(n){if(n.indexOf(" > eval")>-1&&(n=n.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),n.indexOf("@")===-1&&n.indexOf(":")===-1)return new A({functionName:n});var o=/((.*".+"[^@]*)?[^@]*)(?:@)/,c=n.match(o),l=c&&c[1]?c[1]:void 0,d=this.extractLocation(n.replace(o,""));return new A({functionName:l,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:n})},this)},"ErrorStackParser$$parseFFOrSafari")}}i(re,"ErrorStackParser");var ie=new re;var W=ie;var g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!process.browser,L=g&&typeof module<"u"&&typeof module.exports<"u"&&typeof R<"u"&&typeof __dirname<"u",B=g&&!L,Ie=typeof globalThis.Bun<"u",oe=typeof Deno<"u",$=!g&&!oe,j=$&&typeof window=="object"&&typeof document=="object"&&typeof document.createElement=="function"&&"sessionStorage"in window&&typeof importScripts!="function",H=$&&typeof importScripts=="function"&&typeof self=="object",xe=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Chrome")==-1&&navigator.userAgent.indexOf("Safari")>-1,x=typeof read=="function"&&typeof load=="function";var z,D,q,V,T;async function U(){if(!g||(z=(await import("node:url")).default,V=await import("node:fs"),T=await import("node:fs/promises"),q=(await import("node:vm")).default,D=await import("node:path"),C=D.sep,typeof R<"u"))return;let e=V,t=await import("node:crypto"),s=await import("ws"),r=await import("node:child_process"),a={fs:e,crypto:t,ws:s,child_process:r};globalThis.require=function(n){return a[n]}}i(U,"initNodeModules");function se(e,t){return D.resolve(t||".",e)}i(se,"node_resolvePath");function ae(e,t){return t===void 0&&(t=location),new URL(e,t).toString()}i(ae,"browser_resolvePath");var _;g?_=se:x?_=i(e=>e,"resolvePath"):_=ae;var C;g||(C="/");function ce(e,t){return e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?{response:fetch(e)}:{binary:T.readFile(e).then(s=>new Uint8Array(s.buffer,s.byteOffset,s.byteLength))}}i(ce,"node_getBinaryResponse");function le(e,t){if(e.startsWith("file://")&&(e=e.slice(7)),e.includes("://"))throw new Error("Shell cannot fetch urls");return{binary:Promise.resolve(new Uint8Array(readbuffer(e)))}}i(le,"shell_getBinaryResponse");function de(e,t){let s=new URL(e,location);return{response:fetch(s,t?{integrity:t}:{})}}i(de,"browser_getBinaryResponse");var I;g?I=ce:x?I=le:I=de;async function J(e,t){let{response:s,binary:r}=I(e,t);if(r)return r;let a=await s;if(!a.ok)throw new Error(`Failed to load '${e}': request failed.`);return new Uint8Array(await a.arrayBuffer())}i(J,"loadBinaryFile");var F;if(j)F=i(async e=>await import(e),"loadScript");else if(H)F=i(async e=>{try{globalThis.importScripts(e)}catch(t){if(t instanceof TypeError)await import(e);else throw t}},"loadScript");else if(g)F=ue;else if(x)F=load;else throw new Error("Cannot determine runtime environment");async function ue(e){e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?q.runInThisContext(await(await fetch(e)).text()):await import(z.pathToFileURL(e).href)}i(ue,"nodeLoadScript");async function Y(e){if(g){await U();let t=await T.readFile(e,{encoding:"utf8"});return JSON.parse(t)}else if(x){let t=read(e);return JSON.parse(t)}else return await(await fetch(e)).json()}i(Y,"loadLockFile");async function K(){if(L)return __dirname;let e;try{throw new Error}catch(r){e=r}let t=W.parse(e)[0].fileName;if(g&&!t.startsWith("file://")&&(t=`file://${t}`),B){let r=await import("node:path");return(await import("node:url")).fileURLToPath(r.dirname(t))}let s=t.lastIndexOf(C);if(s===-1)throw new Error("Could not extract indexURL path from pyodide module location");return t.slice(0,s)}i(K,"calculateDirname");function G(e){let t=e.FS,s=e.FS.filesystems.MEMFS,r=e.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:i(function(n){if(!n.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return s.mount.apply(null,arguments)},"mount"),syncfs:i(async(n,o,c)=>{try{let l=a.getLocalSet(n),d=await a.getRemoteSet(n),u=o?d:l,p=o?l:d;await a.reconcile(n,u,p),c(null)}catch(l){c(l)}},"syncfs"),getLocalSet:i(n=>{let o=Object.create(null);function c(u){return u!=="."&&u!==".."}i(c,"isRealDir");function l(u){return p=>r.join2(u,p)}i(l,"toAbsolute");let d=t.readdir(n.mountpoint).filter(c).map(l(n.mountpoint));for(;d.length;){let u=d.pop(),p=t.stat(u);t.isDir(p.mode)&&d.push.apply(d,t.readdir(u).filter(c).map(l(u))),o[u]={timestamp:p.mtime,mode:p.mode}}return{type:"local",entries:o}},"getLocalSet"),getRemoteSet:i(async n=>{let o=Object.create(null),c=await fe(n.opts.fileSystemHandle);for(let[l,d]of c)l!=="."&&(o[r.join2(n.mountpoint,l)]={timestamp:d.kind==="file"?new Date((await d.getFile()).lastModified):new Date,mode:d.kind==="file"?a.FILE_MODE:a.DIR_MODE});return{type:"remote",entries:o,handles:c}},"getRemoteSet"),loadLocalEntry:i(n=>{let c=t.lookupPath(n).node,l=t.stat(n);if(t.isDir(l.mode))return{timestamp:l.mtime,mode:l.mode};if(t.isFile(l.mode))return c.contents=s.getFileDataAsTypedArray(c),{timestamp:l.mtime,mode:l.mode,contents:c.contents};throw new Error("node type not supported")},"loadLocalEntry"),storeLocalEntry:i((n,o)=>{if(t.isDir(o.mode))t.mkdirTree(n,o.mode);else if(t.isFile(o.mode))t.writeFile(n,o.contents,{canOwn:!0});else throw new Error("node type not supported");t.chmod(n,o.mode),t.utime(n,o.timestamp,o.timestamp)},"storeLocalEntry"),removeLocalEntry:i(n=>{var o=t.stat(n);t.isDir(o.mode)?t.rmdir(n):t.isFile(o.mode)&&t.unlink(n)},"removeLocalEntry"),loadRemoteEntry:i(async n=>{if(n.kind==="file"){let o=await n.getFile();return{contents:new Uint8Array(await o.arrayBuffer()),mode:a.FILE_MODE,timestamp:new Date(o.lastModified)}}else{if(n.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+n.kind)}},"loadRemoteEntry"),storeRemoteEntry:i(async(n,o,c)=>{let l=n.get(r.dirname(o)),d=t.isFile(c.mode)?await l.getFileHandle(r.basename(o),{create:!0}):await l.getDirectoryHandle(r.basename(o),{create:!0});if(d.kind==="file"){let u=await d.createWritable();await u.write(c.contents),await u.close()}n.set(o,d)},"storeRemoteEntry"),removeRemoteEntry:i(async(n,o)=>{await n.get(r.dirname(o)).removeEntry(r.basename(o)),n.delete(o)},"removeRemoteEntry"),reconcile:i(async(n,o,c)=>{let l=0,d=[];Object.keys(o.entries).forEach(function(f){let y=o.entries[f],w=c.entries[f];(!w||t.isFile(y.mode)&&y.timestamp.getTime()>w.timestamp.getTime())&&(d.push(f),l++)}),d.sort();let u=[];if(Object.keys(c.entries).forEach(function(f){o.entries[f]||(u.push(f),l++)}),u.sort().reverse(),!l)return;let p=o.type==="remote"?o.handles:c.handles;for(let f of d){let y=r.normalize(f.replace(n.mountpoint,"/")).substring(1);if(c.type==="local"){let w=p.get(y),Q=await a.loadRemoteEntry(w);a.storeLocalEntry(f,Q)}else{let w=a.loadLocalEntry(f);await a.storeRemoteEntry(p,y,w)}}for(let f of u)if(c.type==="local")a.removeLocalEntry(f);else{let y=r.normalize(f.replace(n.mountpoint,"/")).substring(1);await a.removeRemoteEntry(p,y)}},"reconcile")};e.FS.filesystems.NATIVEFS_ASYNC=a}i(G,"initializeNativeFS");var fe=i(async e=>{let t=[];async function s(a){for await(let n of a.values())t.push(n),n.kind==="directory"&&await s(n)}i(s,"collect"),await s(e);let r=new Map;r.set(".",e);for(let a of t){let n=(await e.resolve(a)).join("/");r.set(n,a)}return r},"getFsHandles");function X(e){let t={noImageDecoding:!0,noAudioDecoding:!0,noWasmDecoding:!1,preRun:ve(e),print:e.stdout,printErr:e.stderr,onExit(s){t.exitCode=s},thisProgram:e._sysExecutable,arguments:e.args,API:{config:e},locateFile:i(s=>e.indexURL+s,"locateFile"),instantiateWasm:he(e.indexURL)};return t}i(X,"createSettings");function me(e){return function(t){let s="/";try{t.FS.mkdirTree(e)}catch(r){console.error(`Error occurred while making a home directory '${e}':`),console.error(r),console.error(`Using '${s}' for a home directory instead`),e=s}t.FS.chdir(e)}}i(me,"createHomeDirectory");function pe(e){return function(t){Object.assign(t.ENV,e)}}i(pe,"setEnvironment");function ge(e){return e?[async t=>{t.addRunDependency("fsInitHook");try{await e(t.FS,{sitePackages:t.API.sitePackages})}finally{t.removeRunDependency("fsInitHook")}}]:[]}i(ge,"callFsInitHook");function ye(e){let t=e.HEAPU32[e._Py_Version>>>2],s=t>>>24&255,r=t>>>16&255,a=t>>>8&255;return[s,r,a]}i(ye,"computeVersionTuple");function be(e){let t=J(e);return async s=>{s.API.pyVersionTuple=ye(s);let[r,a]=s.API.pyVersionTuple;s.FS.mkdirTree("/lib"),s.API.sitePackages=`/lib/python${r}.${a}/site-packages`,s.FS.mkdirTree(s.API.sitePackages),s.addRunDependency("install-stdlib");try{let n=await t;s.FS.writeFile(`/lib/python${r}${a}.zip`,n)}catch(n){console.error("Error occurred while installing the standard library:"),console.error(n)}finally{s.removeRunDependency("install-stdlib")}}}i(be,"installStdlib");function ve(e){let t;return e.stdLibURL!=null?t=e.stdLibURL:t=e.indexURL+"python_stdlib.zip",[be(t),me(e.env.HOME),pe(e.env),G,...ge(e.fsInit)]}i(ve,"getFileSystemInitializationFuncs");function he(e){if(typeof WasmOffsetConverter<"u")return;let{binary:t,response:s}=I(e+"pyodide.asm.wasm");return function(r,a){return async function(){try{let n;s?n=await WebAssembly.instantiateStreaming(s,r):n=await WebAssembly.instantiate(await t,r);let{instance:o,module:c}=n;a(o,c)}catch(n){console.warn("wasm instantiation failed!"),console.warn(n)}}(),{}}}i(he,"getInstantiateWasmFunc");var M="0.28.0a3";async function Ve(e={}){await U();let t=e.indexURL||await K();t=_(t),t.endsWith("/")||(t+="/"),e.indexURL=t;let s={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,lockFileURL:t+"pyodide-lock.json",args:[],env:{},packageCacheDir:t,packages:[],enableRunUntilComplete:!1,checkAPIVersion:!0,BUILD_ID:"db051977a6193ca15a86fbe914aa4eae8a52219915f5c5d8a6be4afbc5c5391e"},r=Object.assign(s,e);r.env.HOME??="/home/pyodide",r.env.PYTHONINSPECT??="1";let a=X(r),n=a.API;if(n.lockFilePromise=Y(r.lockFileURL),typeof _createPyodideModule!="function"){let u=`${r.indexURL}pyodide.asm.js`;await F(u)}let o;if(e._loadSnapshot){let u=await e._loadSnapshot;ArrayBuffer.isView(u)?o=u:o=new Uint8Array(u),a.noInitialRun=!0,a.INITIAL_MEMORY=o.length}let c=await _createPyodideModule(a);if(a.exitCode!==void 0)throw new c.ExitStatus(a.exitCode);if(e.pyproxyToStringRepr&&n.setPyProxyToStringMethod(!0),n.version!==M&&r.checkAPIVersion)throw new Error(`Pyodide version does not match: '${M}' <==> '${n.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);c.locateFile=u=>{throw new Error("Didn't expect to load any more file_packager files!")};let l;o&&(l=n.restoreSnapshot(o));let d=n.finalizeBootstrap(l,e._snapshotDeserializer);return n.sys.path.insert(0,""),d.version.includes("dev")||n.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${d.version}/full/`),n._pyodide.set_excepthook(),await n.packageIndexReady,n.initializeStreams(r.stdin,r.stdout,r.stderr),d}i(Ve,"loadPyodide");export{Ve as loadPyodide,M as version};
4
+ //# sourceMappingURL=pyodide.mjs.map
Binary file