@stlite/desktop 0.87.0 → 0.89.0
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.
- package/bin/dump_artifacts.js +2 -2
- package/build/assets/{ErrorOutline.esm-C8z2dN3x.js → ErrorOutline.esm-D2SwfuYU.js} +1 -1
- package/build/assets/{FileDownload.esm-kSzyJagP.js → FileDownload.esm-C2Gywq_5.js} +1 -1
- package/build/assets/{FileHelper-BbrZYz8x.js → FileHelper-TEIN3a2s.js} +1 -1
- package/build/assets/{FormClearHelper-fvwQICEk.js → FormClearHelper-DBsQ33IR.js} +1 -1
- package/build/assets/{Hooks-CCS44jMc.js → Hooks-BdfQKLev.js} +1 -1
- package/build/assets/{InputInstructions-BgxdtQsQ.js → InputInstructions-CtPX8G6i.js} +1 -1
- package/build/assets/{Particles-C6lCS8Mc.js → Particles-CftaQRnu.js} +1 -1
- package/build/assets/{ProgressBar-CXipOcU9.js → ProgressBar-M7ATKOrt.js} +1 -1
- package/build/assets/{Toolbar-DiWCQxr5.js → Toolbar-AvCHJeN3.js} +1 -1
- package/build/assets/{base-input-D2OIsCyG.js → base-input-C1jq7mBd.js} +1 -1
- package/build/assets/{checkbox-BNaalk8J.js → checkbox-mkpBvvtC.js} +1 -1
- package/build/assets/{createSuper-CQM18OGw.js → createSuper-BqkNEFMI.js} +1 -1
- package/build/assets/{data-grid-overlay-editor-CK8RiHSC.js → data-grid-overlay-editor-Kkg8Jnuo.js} +1 -1
- package/build/assets/{downloader-CE817MUq.js → downloader-D5bOXv0f.js} +1 -1
- package/build/assets/{es6-D9GNxEuI.js → es6-dD9evgqV.js} +2 -2
- package/build/assets/{iframeResizer.contentWindow-CNYkPhE6.js → iframeResizer.contentWindow-CcIGM7Tj.js} +1 -1
- package/build/assets/{index-X9E9p-kg.js → index-65i-IYyx.js} +1 -1
- package/build/assets/{index-BGbl-ncy.js → index-6GmirbOq.js} +1 -1
- package/build/assets/{index-CjHv4qYi.js → index-B6MoDIcs.js} +1 -1
- package/build/assets/{index-BDOZpIxN.js → index-B6dp8D8K.js} +1 -1
- package/build/assets/{index-CKEBU2Tu.js → index-B_ESKJn8.js} +1 -1
- package/build/assets/{index-DFlTnZFo.js → index-Bn07Nrcj.js} +1 -1
- package/build/assets/{index-C1VFEx3W.js → index-BvsGq1E8.js} +1 -1
- package/build/assets/{index-CDtHDDVr.js → index-BwDs6Dqm.js} +1 -1
- package/build/assets/{index-Dc2c4xJB.js → index-BzxHONei.js} +1 -1
- package/build/assets/{index-DhxOxSgZ.js → index-C3s_fpYA.js} +1 -1
- package/build/assets/{index-DhqQeff3.js → index-COglCO5Z.js} +5 -5
- package/build/assets/{index-XLeMBlQJ.js → index-CRXKMFnY.js} +1 -1
- package/build/assets/{index-DyVqVg90.js → index-CZ-g3tsi.js} +1 -1
- package/build/assets/{index-B-7mLFMQ.js → index-CaQBKEJy.js} +1 -1
- package/build/assets/{index-Wzix0Ssr.js → index-Cbwanp8_.js} +1 -1
- package/build/assets/{index---v6J_Xe.js → index-CmCzhGLu.js} +1 -1
- package/build/assets/{index-DFWekVRf.js → index-Cmk6T6xH.js} +1 -1
- package/build/assets/{index-B5zkrGKq.js → index-CuAJIEXV.js} +1 -1
- package/build/assets/{index-CxsEqDQL.js → index-CyGIJHIN.js} +1 -1
- package/build/assets/{index-DXGgezsh.js → index-D9I-_Axj.js} +1 -1
- package/build/assets/{index-B3wu97uA.js → index-DRnW2Id8.js} +1 -1
- package/build/assets/{index-Bnvb95fQ.js → index-Dpl6MGkr.js} +1 -1
- package/build/assets/{index-Vs85zs5K.js → index-Du10bw-R.js} +1 -1
- package/build/assets/{index-C6fUDD3N.js → index-GIlSUqbu.js} +1 -1
- package/build/assets/{index-CI7_FxNG.js → index-GZIk974x.js} +1 -1
- package/build/assets/{index--SdlqSfi.js → index-GZgkD7uG.js} +1 -1
- package/build/assets/{index-mlKr_pQQ.js → index-N4aGA-cE.js} +1 -1
- package/build/assets/{index-CnRs0MgX.js → index-P6F5Xebr.js} +1 -1
- package/build/assets/{index-CGMUJ4kd.js → index-XJiwj79b.js} +1 -1
- package/build/assets/{index-BI9UgvCi.js → index-_maoKajI.js} +1 -1
- package/build/assets/{index-DDiZtaVk.js → index-cMy3wqhE.js} +1 -1
- package/build/assets/{index-DCNLpqIv.js → index-clm6On2Y.js} +4 -4
- package/build/assets/{index-D0YDqQsn.js → index-i6_APaSl.js} +1 -1
- package/build/assets/{index-DqnX_TF4.js → index-npEbF0j6.js} +1 -1
- package/build/assets/{index-cAlcGRT2.js → index-o_WbG_Oh.js} +1 -1
- package/build/assets/{index-CT5_r023.js → index-w_HPESMz.js} +1 -1
- package/build/assets/{index-7qt3HHfl.js → index-yIAfElop.js} +1 -1
- package/build/assets/{inherits-BWX75f6B.js → inherits-D8N0057t.js} +1 -1
- package/build/assets/{input-DTfsWA-x.js → input-D2HjwqoP.js} +1 -1
- package/build/assets/{memory-DS2CpVMo.js → memory-DWwc6pLO.js} +1 -1
- package/build/assets/{mergeWith-fWFIuGgc.js → mergeWith-BGcS1SpY.js} +1 -1
- package/build/assets/{number-overlay-editor-DDQgeQYn.js → number-overlay-editor-B6CLC0X9.js} +1 -1
- package/build/assets/{sandbox-VD4WfD0W.js → sandbox-C6oygvjW.js} +1 -1
- package/build/assets/{slicedToArray-CgI3PJi3.js → slicedToArray-DOoFLiRi.js} +1 -1
- package/build/assets/{timepicker-qd0SiRjC.js → timepicker-C7DrJdVV.js} +1 -1
- package/build/assets/{uniqueId-Dgo2nsPZ.js → uniqueId-C1Mkja_B.js} +1 -1
- package/build/assets/{useBasicWidgetState-9vtYd9vP.js → useBasicWidgetState-CCltHZT9.js} +1 -1
- package/build/assets/{useTextInputAutoExpand-BFx1z0yW.js → useTextInputAutoExpand-LP-kJAB7.js} +1 -1
- package/build/assets/{useUpdateUiValue-BF7Ryinr.js → useUpdateUiValue-JsRPimPm.js} +1 -1
- package/build/assets/{withFullScreenWrapper-C3PKUCi4.js → withFullScreenWrapper-CKQjmc-1.js} +1 -1
- package/build/assets/worker-CiNU4sgs.js +105 -0
- package/build/electron/worker.js +9 -9
- package/build/index.html +1 -1
- package/build/pyodide/pyodide-lock.json +1 -1
- package/build/pyodide/pyodide.asm.js +2 -4
- package/build/pyodide/pyodide.asm.wasm +0 -0
- package/build/pyodide/pyodide.mjs +3 -3
- package/build/pyodide/python_stdlib.zip +0 -0
- package/package.json +6 -6
- package/wheels/streamlit-1.48.0-cp313-none-any.whl +0 -0
- package/build/assets/worker-B7Gzidb7.js +0 -105
- package/wheels/streamlit-1.48.0-cp312-none-any.whl +0 -0
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
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 i=n.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),c=i.match(/ (\(.+\)$)/);i=c?i.replace(c[0],""):i;var l=this.extractLocation(c?c[1]:i),d=c&&i||void 0,u=["eval","<anonymous>"].indexOf(l[0])>-1?void 0:l[0];return new
|
|
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 k({functionName:n});var i=/((.*".+"[^@]*)?[^@]*)(?:@)/,c=n.match(i),l=c&&c[1]?c[1]:void 0,d=this.extractLocation(n.replace(i,""));return new k({functionName:l,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:n})},this)},"ErrorStackParser$$parseFFOrSafari")}}s(ne,"ErrorStackParser");var re=new ne;var C=re;var g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!process.browser,A=g&&typeof module<"u"&&typeof module.exports<"u"&&typeof R<"u"&&typeof __dirname<"u",W=g&&!A,Ne=typeof globalThis.Bun<"u",ie=typeof Deno<"u",B=!g&&!ie,$=B&&typeof window=="object"&&typeof document=="object"&&typeof document.createElement=="function"&&"sessionStorage"in window&&typeof importScripts!="function",j=B&&typeof importScripts=="function"&&typeof self=="object",_e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Chrome")==-1&&navigator.userAgent.indexOf("Safari")>-1;var z,D,V,H,L;async function T(){if(!g||(z=(await import("node:url")).default,H=await import("node:fs"),L=await import("node:fs/promises"),V=(await import("node:vm")).default,D=await import("node:path"),U=D.sep,typeof R<"u"))return;let e=H,t=await import("node:crypto"),o=await import("ws"),r=await import("node:child_process"),a={fs:e,crypto:t,ws:o,child_process:r};globalThis.require=function(n){return a[n]}}s(T,"initNodeModules");function oe(e,t){return D.resolve(t||".",e)}s(oe,"node_resolvePath");function ae(e,t){return t===void 0&&(t=location),new URL(e,t).toString()}s(ae,"browser_resolvePath");var O;g?O=oe:O=ae;var U;g||(U="/");function se(e,t){return e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?{response:fetch(e)}:{binary:L.readFile(e).then(o=>new Uint8Array(o.buffer,o.byteOffset,o.byteLength))}}s(se,"node_getBinaryResponse");function ce(e,t){let o=new URL(e,location);return{response:fetch(o,t?{integrity:t}:{})}}s(ce,"browser_getBinaryResponse");var F;g?F=se:F=ce;async function q(e,t){let{response:o,binary:r}=F(e,t);if(r)return r;let a=await o;if(!a.ok)throw new Error(`Failed to load '${e}': request failed.`);return new Uint8Array(await a.arrayBuffer())}s(q,"loadBinaryFile");var I;if($)I=s(async e=>await import(e),"loadScript");else if(j)I=s(async e=>{try{globalThis.importScripts(e)}catch(t){if(t instanceof TypeError)await import(e);else throw t}},"loadScript");else if(g)I=le;else throw new Error("Cannot determine runtime environment");async function le(e){e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?V.runInThisContext(await(await fetch(e)).text()):await import(z.pathToFileURL(e).href)}s(le,"nodeLoadScript");async function J(e){if(g){await T();let t=await L.readFile(e,{encoding:"utf8"});return JSON.parse(t)}else return await(await fetch(e)).json()}s(J,"loadLockFile");async function K(){if(A)return __dirname;let e;try{throw new Error}catch(r){e=r}let t=C.parse(e)[0].fileName;if(g&&!t.startsWith("file://")&&(t=`file://${t}`),W){let r=await import("node:path");return(await import("node:url")).fileURLToPath(r.dirname(t))}let o=t.lastIndexOf(U);if(o===-1)throw new Error("Could not extract indexURL path from pyodide module location");return t.slice(0,o)}s(K,"calculateDirname");function Y(e){let t=e.FS,o=e.FS.filesystems.MEMFS,r=e.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:function(n){if(!n.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return o.mount.apply(null,arguments)},syncfs:async(n,i,c)=>{try{let l=a.getLocalSet(n),d=await a.getRemoteSet(n),u=i?d:l,m=i?l:d;await a.reconcile(n,u,m),c(null)}catch(l){c(l)}},getLocalSet:n=>{let i=Object.create(null);function c(u){return u!=="."&&u!==".."}s(c,"isRealDir");function l(u){return m=>r.join2(u,m)}s(l,"toAbsolute");let d=t.readdir(n.mountpoint).filter(c).map(l(n.mountpoint));for(;d.length;){let u=d.pop(),m=t.stat(u);t.isDir(m.mode)&&d.push.apply(d,t.readdir(u).filter(c).map(l(u))),i[u]={timestamp:m.mtime,mode:m.mode}}return{type:"local",entries:i}},getRemoteSet:async n=>{let i=Object.create(null),c=await de(n.opts.fileSystemHandle);for(let[l,d]of c)l!=="."&&(i[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:i,handles:c}},loadLocalEntry: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=o.getFileDataAsTypedArray(c),{timestamp:l.mtime,mode:l.mode,contents:c.contents};throw new Error("node type not supported")},storeLocalEntry:(n,i)=>{if(t.isDir(i.mode))t.mkdirTree(n,i.mode);else if(t.isFile(i.mode))t.writeFile(n,i.contents,{canOwn:!0});else throw new Error("node type not supported");t.chmod(n,i.mode),t.utime(n,i.timestamp,i.timestamp)},removeLocalEntry:n=>{var i=t.stat(n);t.isDir(i.mode)?t.rmdir(n):t.isFile(i.mode)&&t.unlink(n)},loadRemoteEntry:async n=>{if(n.kind==="file"){let i=await n.getFile();return{contents:new Uint8Array(await i.arrayBuffer()),mode:a.FILE_MODE,timestamp:new Date(i.lastModified)}}else{if(n.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+n.kind)}},storeRemoteEntry:async(n,i,c)=>{let l=n.get(r.dirname(i)),d=t.isFile(c.mode)?await l.getFileHandle(r.basename(i),{create:!0}):await l.getDirectoryHandle(r.basename(i),{create:!0});if(d.kind==="file"){let u=await d.createWritable();await u.write(c.contents),await u.close()}n.set(i,d)},removeRemoteEntry:async(n,i)=>{await n.get(r.dirname(i)).removeEntry(r.basename(i)),n.delete(i)},reconcile:async(n,i,c)=>{let l=0,d=[];Object.keys(i.entries).forEach(function(f){let y=i.entries[f],S=c.entries[f];(!S||t.isFile(y.mode)&&y.timestamp.getTime()>S.timestamp.getTime())&&(d.push(f),l++)}),d.sort();let u=[];if(Object.keys(c.entries).forEach(function(f){i.entries[f]||(u.push(f),l++)}),u.sort().reverse(),!l)return;let m=i.type==="remote"?i.handles:c.handles;for(let f of d){let y=r.normalize(f.replace(n.mountpoint,"/")).substring(1);if(c.type==="local"){let S=m.get(y),X=await a.loadRemoteEntry(S);a.storeLocalEntry(f,X)}else{let S=a.loadLocalEntry(f);await a.storeRemoteEntry(m,y,S)}}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(m,y)}}};e.FS.filesystems.NATIVEFS_ASYNC=a}s(Y,"initializeNativeFS");var de=s(async e=>{let t=[];async function o(a){for await(let n of a.values())t.push(n),n.kind==="directory"&&await o(n)}s(o,"collect"),await o(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 G(e){let t={noImageDecoding:!0,noAudioDecoding:!0,noWasmDecoding:!1,preRun:ge(e),quit(o,r){throw t.exited={status:o,toThrow:r},r},print:e.stdout,printErr:e.stderr,thisProgram:e._sysExecutable,arguments:e.args,API:{config:e},locateFile:o=>e.indexURL+o,instantiateWasm:ye(e.indexURL)};return t}s(G,"createSettings");function ue(e){return function(t){let o="/";try{t.FS.mkdirTree(e)}catch(r){console.error(`Error occurred while making a home directory '${e}':`),console.error(r),console.error(`Using '${o}' for a home directory instead`),e=o}t.FS.chdir(e)}}s(ue,"createHomeDirectory");function fe(e){return function(t){Object.assign(t.ENV,e)}}s(fe,"setEnvironment");function me(e){return e?[async t=>{t.addRunDependency("fsInitHook");try{await e(t.FS,{sitePackages:t.API.sitePackages})}finally{t.removeRunDependency("fsInitHook")}}]:[]}s(me,"callFsInitHook");function pe(e){let t=q(e);return async o=>{let r=o._py_version_major(),a=o._py_version_minor();o.FS.mkdirTree("/lib"),o.API.sitePackages=`/lib/python${r}.${a}/site-packages`,o.FS.mkdirTree(o.API.sitePackages),o.addRunDependency("install-stdlib");try{let n=await t;o.FS.writeFile(`/lib/python${r}${a}.zip`,n)}catch(n){console.error("Error occurred while installing the standard library:"),console.error(n)}finally{o.removeRunDependency("install-stdlib")}}}s(pe,"installStdlib");function ge(e){let t;return e.stdLibURL!=null?t=e.stdLibURL:t=e.indexURL+"python_stdlib.zip",[...me(e.fsInit),pe(t),ue(e.env.HOME),fe(e.env),Y]}s(ge,"getFileSystemInitializationFuncs");function ye(e){if(typeof WasmOffsetConverter<"u")return;let{binary:t,response:o}=F(e+"pyodide.asm.wasm");return function(r,a){return async function(){try{let n;o?n=await WebAssembly.instantiateStreaming(o,r):n=await WebAssembly.instantiate(await t,r);let{instance:i,module:c}=n;a(i,c)}catch(n){console.warn("wasm instantiation failed!"),console.warn(n)}}(),{}}}s(ye,"getInstantiateWasmFunc");var M="0.27.6";async function $e(e={}){var u,m;await T();let t=e.indexURL||await K();t=O(t),t.endsWith("/")||(t+="/"),e.indexURL=t;let o={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:"58ff83c394cd9a3d28be50b7475d122087896295981974b756ce5fc170e523cf"},r=Object.assign(o,e);(u=r.env).HOME??(u.HOME="/home/pyodide"),(m=r.env).PYTHONINSPECT??(m.PYTHONINSPECT="1");let a=G(r),n=a.API;if(n.lockFilePromise=J(r.lockFileURL),typeof _createPyodideModule!="function"){let f=`${r.indexURL}pyodide.asm.js`;await I(f)}let i;if(e._loadSnapshot){let f=await e._loadSnapshot;ArrayBuffer.isView(f)?i=f:i=new Uint8Array(f),a.noInitialRun=!0,a.INITIAL_MEMORY=i.length}let c=await _createPyodideModule(a);if(a.exited)throw a.exited.toThrow;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=f=>{throw new Error("Didn't expect to load any more file_packager files!")};let l;i&&(l=n.restoreSnapshot(i));let d=n.finalizeBootstrap(l,e._snapshotDeserializer);return n.sys.path.insert(0,n.config.env.HOME),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}s($e,"loadPyodide");export{$e as loadPyodide,M as version};
|
|
1
|
+
var oe=Object.defineProperty;var o=(e,t)=>oe(e,"name",{value:t,configurable:!0}),A=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var W=(()=>{for(var e=new Uint8Array(128),t=0;t<64;t++)e[t<26?t+65:t<52?t+71:t<62?t-4:t*4-205]=t;return r=>{for(var s=r.length,a=new Uint8Array((s-(r[s-1]=="=")-(r[s-2]=="="))*3/4|0),n=0,i=0;n<s;){var c=e[r.charCodeAt(n++)],l=e[r.charCodeAt(n++)],d=e[r.charCodeAt(n++)],u=e[r.charCodeAt(n++)];a[i++]=c<<2|l>>4,a[i++]=l<<4|d>>2,a[i++]=d<<6|u}return a}})();function se(e){return!isNaN(parseFloat(e))&&isFinite(e)}o(se,"_isNumber");function S(e){return e.charAt(0).toUpperCase()+e.substring(1)}o(S,"_capitalize");function L(e){return function(){return this[e]}}o(L,"_getter");var E=["isConstructor","isEval","isNative","isToplevel"],P=["columnNumber","lineNumber"],k=["fileName","functionName","source"],ae=["args"],ce=["evalOrigin"],R=E.concat(P,k,ae,ce);function p(e){if(e)for(var t=0;t<R.length;t++)e[R[t]]!==void 0&&this["set"+S(R[t])](e[R[t]])}o(p,"StackFrame");p.prototype={getArgs:o(function(){return this.args},"getArgs"),setArgs:o(function(e){if(Object.prototype.toString.call(e)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=e},"setArgs"),getEvalOrigin:o(function(){return this.evalOrigin},"getEvalOrigin"),setEvalOrigin:o(function(e){if(e instanceof p)this.evalOrigin=e;else if(e instanceof Object)this.evalOrigin=new p(e);else throw new TypeError("Eval Origin must be an Object or StackFrame")},"setEvalOrigin"),toString:o(function(){var e=this.getFileName()||"",t=this.getLineNumber()||"",r=this.getColumnNumber()||"",s=this.getFunctionName()||"";return this.getIsEval()?e?"[eval] ("+e+":"+t+":"+r+")":"[eval]:"+t+":"+r:s?s+" ("+e+":"+t+":"+r+")":e+":"+t+":"+r},"toString")};p.fromString=o(function(t){var r=t.indexOf("("),s=t.lastIndexOf(")"),a=t.substring(0,r),n=t.substring(r+1,s).split(","),i=t.substring(s+1);if(i.indexOf("@")===0)var c=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(i,""),l=c[1],d=c[2],u=c[3];return new p({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++)p.prototype["get"+S(E[b])]=L(E[b]),p.prototype["set"+S(E[b])]=function(e){return function(t){this[e]=!!t}}(E[b]);var b;for(v=0;v<P.length;v++)p.prototype["get"+S(P[v])]=L(P[v]),p.prototype["set"+S(P[v])]=function(e){return function(t){if(!se(t))throw new TypeError(e+" must be a Number");this[e]=Number(t)}}(P[v]);var v;for(h=0;h<k.length;h++)p.prototype["get"+S(k[h])]=L(k[h]),p.prototype["set"+S(k[h])]=function(e){return function(t){this[e]=String(t)}}(k[h]);var h,O=p;function le(){var e=/^\s*at .*(\S+:\d+|\(native\))/m,t=/^(eval@)?(\[native code])?$/;return{parse:o(function(s){if(s.stack&&s.stack.match(e))return this.parseV8OrIE(s);if(s.stack)return this.parseFFOrSafari(s);throw new Error("Cannot parse given Error object")},"ErrorStackParser$$parse"),extractLocation:o(function(s){if(s.indexOf(":")===-1)return[s];var a=/(.+?)(?::(\d+))?(?::(\d+))?$/,n=a.exec(s.replace(/[()]/g,""));return[n[1],n[2]||void 0,n[3]||void 0]},"ErrorStackParser$$extractLocation"),parseV8OrIE:o(function(s){var a=s.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 i=n.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),c=i.match(/ (\(.+\)$)/);i=c?i.replace(c[0],""):i;var l=this.extractLocation(c?c[1]:i),d=c&&i||void 0,u=["eval","<anonymous>"].indexOf(l[0])>-1?void 0:l[0];return new O({functionName:d,fileName:u,lineNumber:l[1],columnNumber:l[2],source:n})},this)},"ErrorStackParser$$parseV8OrIE"),parseFFOrSafari:o(function(s){var a=s.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 O({functionName:n});var i=/((.*".+"[^@]*)?[^@]*)(?:@)/,c=n.match(i),l=c&&c[1]?c[1]:void 0,d=this.extractLocation(n.replace(i,""));return new O({functionName:l,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:n})},this)},"ErrorStackParser$$parseFFOrSafari")}}o(le,"ErrorStackParser");var de=new le;var $=de;var g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!process.browser,T=g&&typeof module<"u"&&typeof module.exports<"u"&&typeof A<"u"&&typeof __dirname<"u",j=g&&!T,Te=typeof globalThis.Bun<"u",ue=typeof Deno<"u",H=!g&&!ue,V=H&&typeof window=="object"&&typeof document=="object"&&typeof document.createElement=="function"&&"sessionStorage"in window&&typeof importScripts!="function",z=H&&typeof importScripts=="function"&&typeof self=="object",De=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 J,D,Y,q,U;async function C(){if(!g||(J=(await import("node:url")).default,q=await import("node:fs"),U=await import("node:fs/promises"),Y=(await import("node:vm")).default,D=await import("node:path"),M=D.sep,typeof A<"u"))return;let e=q,t=await import("node:crypto"),r=await import("ws"),s=await import("node:child_process"),a={fs:e,crypto:t,ws:r,child_process:s};globalThis.require=function(n){return a[n]}}o(C,"initNodeModules");function fe(e,t){return D.resolve(t||".",e)}o(fe,"node_resolvePath");function me(e,t){return t===void 0&&(t=location),new URL(e,t).toString()}o(me,"browser_resolvePath");var N;g?N=fe:x?N=o(e=>e,"resolvePath"):N=me;var M;g||(M="/");function pe(e,t){return e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?{response:fetch(e)}:{binary:U.readFile(e).then(r=>new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}}o(pe,"node_getBinaryResponse");function ge(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)))}}o(ge,"shell_getBinaryResponse");function ye(e,t){let r=new URL(e,location);return{response:fetch(r,t?{integrity:t}:{})}}o(ye,"browser_getBinaryResponse");var F;g?F=pe:x?F=ge:F=ye;async function K(e,t){let{response:r,binary:s}=F(e,t);if(s)return s;let a=await r;if(!a.ok)throw new Error(`Failed to load '${e}': request failed.`);return new Uint8Array(await a.arrayBuffer())}o(K,"loadBinaryFile");var I;if(V)I=o(async e=>await import(e),"loadScript");else if(z)I=o(async e=>{try{globalThis.importScripts(e)}catch(t){if(t instanceof TypeError)await import(e);else throw t}},"loadScript");else if(g)I=be;else if(x)I=load;else throw new Error("Cannot determine runtime environment");async function be(e){e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?Y.runInThisContext(await(await fetch(e)).text()):await import(J.pathToFileURL(e).href)}o(be,"nodeLoadScript");async function G(e){if(g){await C();let t=await U.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()}o(G,"loadLockFile");async function X(){if(T)return __dirname;let e;try{throw new Error}catch(s){e=s}let t=$.parse(e)[0].fileName;if(g&&!t.startsWith("file://")&&(t=`file://${t}`),j){let s=await import("node:path");return(await import("node:url")).fileURLToPath(s.dirname(t))}let r=t.lastIndexOf(M);if(r===-1)throw new Error("Could not extract indexURL path from pyodide module location");return t.slice(0,r)}o(X,"calculateDirname");function Q(e){return e.substring(0,e.lastIndexOf("/")+1)||globalThis.location?.toString()||"."}o(Q,"calculateInstallBaseUrl");function Z(e){let t=e.FS,r=e.FS.filesystems.MEMFS,s=e.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:o(function(n){if(!n.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return r.mount.apply(null,arguments)},"mount"),syncfs:o(async(n,i,c)=>{try{let l=a.getLocalSet(n),d=await a.getRemoteSet(n),u=i?d:l,f=i?l:d;await a.reconcile(n,u,f),c(null)}catch(l){c(l)}},"syncfs"),getLocalSet:o(n=>{let i=Object.create(null);function c(u){return u!=="."&&u!==".."}o(c,"isRealDir");function l(u){return f=>s.join2(u,f)}o(l,"toAbsolute");let d=t.readdir(n.mountpoint).filter(c).map(l(n.mountpoint));for(;d.length;){let u=d.pop(),f=t.stat(u);t.isDir(f.mode)&&d.push.apply(d,t.readdir(u).filter(c).map(l(u))),i[u]={timestamp:f.mtime,mode:f.mode}}return{type:"local",entries:i}},"getLocalSet"),getRemoteSet:o(async n=>{let i=Object.create(null),c=await ve(n.opts.fileSystemHandle);for(let[l,d]of c)l!=="."&&(i[s.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:i,handles:c}},"getRemoteSet"),loadLocalEntry:o(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=r.getFileDataAsTypedArray(c),{timestamp:l.mtime,mode:l.mode,contents:c.contents};throw new Error("node type not supported")},"loadLocalEntry"),storeLocalEntry:o((n,i)=>{if(t.isDir(i.mode))t.mkdirTree(n,i.mode);else if(t.isFile(i.mode))t.writeFile(n,i.contents,{canOwn:!0});else throw new Error("node type not supported");t.chmod(n,i.mode),t.utime(n,i.timestamp,i.timestamp)},"storeLocalEntry"),removeLocalEntry:o(n=>{var i=t.stat(n);t.isDir(i.mode)?t.rmdir(n):t.isFile(i.mode)&&t.unlink(n)},"removeLocalEntry"),loadRemoteEntry:o(async n=>{if(n.kind==="file"){let i=await n.getFile();return{contents:new Uint8Array(await i.arrayBuffer()),mode:a.FILE_MODE,timestamp:new Date(i.lastModified)}}else{if(n.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+n.kind)}},"loadRemoteEntry"),storeRemoteEntry:o(async(n,i,c)=>{let l=n.get(s.dirname(i)),d=t.isFile(c.mode)?await l.getFileHandle(s.basename(i),{create:!0}):await l.getDirectoryHandle(s.basename(i),{create:!0});if(d.kind==="file"){let u=await d.createWritable();await u.write(c.contents),await u.close()}n.set(i,d)},"storeRemoteEntry"),removeRemoteEntry:o(async(n,i)=>{await n.get(s.dirname(i)).removeEntry(s.basename(i)),n.delete(i)},"removeRemoteEntry"),reconcile:o(async(n,i,c)=>{let l=0,d=[];Object.keys(i.entries).forEach(function(m){let y=i.entries[m],w=c.entries[m];(!w||t.isFile(y.mode)&&y.timestamp.getTime()>w.timestamp.getTime())&&(d.push(m),l++)}),d.sort();let u=[];if(Object.keys(c.entries).forEach(function(m){i.entries[m]||(u.push(m),l++)}),u.sort().reverse(),!l)return;let f=i.type==="remote"?i.handles:c.handles;for(let m of d){let y=s.normalize(m.replace(n.mountpoint,"/")).substring(1);if(c.type==="local"){let w=f.get(y),ie=await a.loadRemoteEntry(w);a.storeLocalEntry(m,ie)}else{let w=a.loadLocalEntry(m);await a.storeRemoteEntry(f,y,w)}}for(let m of u)if(c.type==="local")a.removeLocalEntry(m);else{let y=s.normalize(m.replace(n.mountpoint,"/")).substring(1);await a.removeRemoteEntry(f,y)}},"reconcile")};e.FS.filesystems.NATIVEFS_ASYNC=a}o(Z,"initializeNativeFS");var ve=o(async e=>{let t=[];async function r(a){for await(let n of a.values())t.push(n),n.kind==="directory"&&await r(n)}o(r,"collect"),await r(e);let s=new Map;s.set(".",e);for(let a of t){let n=(await e.resolve(a)).join("/");s.set(n,a)}return s},"getFsHandles");var ee=W("AGFzbQEAAAABDANfAGAAAW9gAW8BfwMDAgECByECD2NyZWF0ZV9zZW50aW5lbAAAC2lzX3NlbnRpbmVsAAEKEwIHAPsBAPsbCwkAIAD7GvsUAAs=");var Se=async function(){if(!(globalThis.navigator&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&typeof navigator.maxTouchPoints<"u"&&navigator.maxTouchPoints>1))){return;try{let t=await WebAssembly.compile(ee);return await WebAssembly.instantiate(t)}catch(t){if(t instanceof WebAssembly.CompileError)return;throw t}}}();async function te(){let e=await Se;if(e)return e.exports;let t=Symbol("error marker");return{create_sentinel:o(()=>t,"create_sentinel"),is_sentinel:o(r=>r===t,"is_sentinel")}}o(te,"getSentinelImport");function ne(e){let t={noImageDecoding:!0,noAudioDecoding:!0,noWasmDecoding:!1,preRun:Ne(e),print:e.stdout,printErr:e.stderr,onExit(r){t.exitCode=r},thisProgram:e._sysExecutable,arguments:e.args,API:{config:e},locateFile:o(r=>e.indexURL+r,"locateFile"),instantiateWasm:Fe(e.indexURL)};return t}o(ne,"createSettings");function we(e){return function(t){let r="/";try{t.FS.mkdirTree(e)}catch(s){console.error(`Error occurred while making a home directory '${e}':`),console.error(s),console.error(`Using '${r}' for a home directory instead`),e=r}t.FS.chdir(e)}}o(we,"createHomeDirectory");function Ee(e){return function(t){Object.assign(t.ENV,e)}}o(Ee,"setEnvironment");function Pe(e){return e?[async t=>{t.addRunDependency("fsInitHook");try{await e(t.FS,{sitePackages:t.API.sitePackages})}finally{t.removeRunDependency("fsInitHook")}}]:[]}o(Pe,"callFsInitHook");function ke(e){let t=e.HEAPU32[e._Py_Version>>>2],r=t>>>24&255,s=t>>>16&255,a=t>>>8&255;return[r,s,a]}o(ke,"computeVersionTuple");function Ie(e){let t=K(e);return async r=>{r.API.pyVersionTuple=ke(r);let[s,a]=r.API.pyVersionTuple;r.FS.mkdirTree("/lib"),r.API.sitePackages=`/lib/python${s}.${a}/site-packages`,r.FS.mkdirTree(r.API.sitePackages),r.addRunDependency("install-stdlib");try{let n=await t;r.FS.writeFile(`/lib/python${s}${a}.zip`,n)}catch(n){console.error("Error occurred while installing the standard library:"),console.error(n)}finally{r.removeRunDependency("install-stdlib")}}}o(Ie,"installStdlib");function Ne(e){let t;return e.stdLibURL!=null?t=e.stdLibURL:t=e.indexURL+"python_stdlib.zip",[Ie(t),we(e.env.HOME),Ee(e.env),Z,...Pe(e.fsInit)]}o(Ne,"getFileSystemInitializationFuncs");function Fe(e){if(typeof WasmOffsetConverter<"u")return;let{binary:t,response:r}=F(e+"pyodide.asm.wasm"),s=te();return function(a,n){return async function(){a.sentinel=await s;try{let i;r?i=await WebAssembly.instantiateStreaming(r,a):i=await WebAssembly.instantiate(await t,a);let{instance:c,module:l}=i;n(c,l)}catch(i){console.warn("wasm instantiation failed!"),console.warn(i)}}(),{}}}o(Fe,"getInstantiateWasmFunc");var re="0.28.2";function _(e){return e===void 0||e.endsWith("/")?e:e+"/"}o(_,"withTrailingSlash");var B=re;async function at(e={}){if(e.lockFileContents&&e.lockFileURL)throw new Error("Can't pass both lockFileContents and lockFileURL");await C();let t=e.indexURL||await X();t=_(N(t));let r=e;if(r.packageBaseUrl=_(r.packageBaseUrl),r.cdnUrl=_(r.packageBaseUrl??`https://cdn.jsdelivr.net/pyodide/v${B}/full/`),!e.lockFileContents){let f=e.lockFileURL??t+"pyodide-lock.json";r.lockFileContents=G(f),r.packageBaseUrl??=Q(f)}r.indexURL=t,r.packageCacheDir&&(r.packageCacheDir=_(N(r.packageCacheDir)));let s={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,args:[],env:{},packages:[],packageCacheDir:r.packageBaseUrl,enableRunUntilComplete:!0,checkAPIVersion:!0,BUILD_ID:"941a75c165c70d9d65a059137df0382b4c6a7747ff5f3de2b264ce4a2fb36cf5"},a=Object.assign(s,r);a.env.HOME??="/home/pyodide",a.env.PYTHONINSPECT??="1";let n=ne(a),i=n.API;if(i.lockFilePromise=Promise.resolve(r.lockFileContents),typeof _createPyodideModule!="function"){let f=`${a.indexURL}pyodide.asm.js`;await I(f)}let c;if(e._loadSnapshot){let f=await e._loadSnapshot;ArrayBuffer.isView(f)?c=f:c=new Uint8Array(f),n.noInitialRun=!0,n.INITIAL_MEMORY=c.length}let l=await _createPyodideModule(n);if(n.exitCode!==void 0)throw new l.ExitStatus(n.exitCode);if(e.pyproxyToStringRepr&&i.setPyProxyToStringMethod(!0),e.convertNullToNone&&i.setCompatNullToNone(!0),i.version!==B&&a.checkAPIVersion)throw new Error(`Pyodide version does not match: '${B}' <==> '${i.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);l.locateFile=f=>{throw f.endsWith(".so")?new Error(`Failed to find dynamic library "${f}"`):new Error(`Unexpected call to locateFile("${f}")`)};let d;c&&(d=i.restoreSnapshot(c));let u=i.finalizeBootstrap(d,e._snapshotDeserializer);return i.sys.path.insert(0,""),i._pyodide.set_excepthook(),await i.packageIndexReady,i.initializeStreams(a.stdin,a.stdout,a.stderr),u}o(at,"loadPyodide");export{at as loadPyodide,B as version};
|
|
4
4
|
//# sourceMappingURL=pyodide.mjs.map
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stlite/desktop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"//": "The packages not bundled with bin/dump_artifacts.js must be specified here as the runtime dependencies. See `scripts/build_bin.js` for the details.",
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"fs-extra": "^11.2.0",
|
|
61
|
-
"pyodide": "0.
|
|
61
|
+
"pyodide": "0.28.2",
|
|
62
62
|
"yargs": "^17.7.2"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@emotion/babel-plugin": "^11.13.5",
|
|
66
66
|
"@eslint/js": "^9.32.0",
|
|
67
|
-
"@stlite/common": "^0.
|
|
68
|
-
"@stlite/common-react": "^0.
|
|
69
|
-
"@stlite/devutils": "^0.
|
|
70
|
-
"@stlite/kernel": "^0.
|
|
67
|
+
"@stlite/common": "^0.89.0",
|
|
68
|
+
"@stlite/common-react": "^0.89.0",
|
|
69
|
+
"@stlite/devutils": "^0.89.0",
|
|
70
|
+
"@stlite/kernel": "^0.89.0",
|
|
71
71
|
"@streamlit/app": "^1.48.0",
|
|
72
72
|
"@types/react": "^18.2.0",
|
|
73
73
|
"@types/react-dom": "^18.2.0",
|
|
Binary file
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
function V(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var I,N;function Y(){if(N)return I;N=1;function o(a){if(typeof a!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(a))}function l(a,e){for(var t="",n=0,s=-1,c=0,r,i=0;i<=a.length;++i){if(i<a.length)r=a.charCodeAt(i);else{if(r===47)break;r=47}if(r===47){if(!(s===i-1||c===1))if(s!==i-1&&c===2){if(t.length<2||n!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var g=t.lastIndexOf("/");if(g!==t.length-1){g===-1?(t="",n=0):(t=t.slice(0,g),n=t.length-1-t.lastIndexOf("/")),s=i,c=0;continue}}else if(t.length===2||t.length===1){t="",n=0,s=i,c=0;continue}}e&&(t.length>0?t+="/..":t="..",n=2)}else t.length>0?t+="/"+a.slice(s+1,i):t=a.slice(s+1,i),n=i-s-1;s=i,c=0}else r===46&&c!==-1?++c:c=-1}return t}function f(a,e){var t=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+n:t+a+n:n}var d={resolve:function(){for(var e="",t=!1,n,s=arguments.length-1;s>=-1&&!t;s--){var c;s>=0?c=arguments[s]:(n===void 0&&(n=process.cwd()),c=n),o(c),c.length!==0&&(e=c+"/"+e,t=c.charCodeAt(0)===47)}return e=l(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(o(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=l(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return o(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];o(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":d.normalize(e)},relative:function(e,t){if(o(e),o(t),e===t||(e=d.resolve(e),t=d.resolve(t),e===t))return"";for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var s=e.length,c=s-n,r=1;r<t.length&&t.charCodeAt(r)===47;++r);for(var i=t.length,g=i-r,S=c<g?c:g,b=-1,_=0;_<=S;++_){if(_===S){if(g>S){if(t.charCodeAt(r+_)===47)return t.slice(r+_+1);if(_===0)return t.slice(r+_)}else c>S&&(e.charCodeAt(n+_)===47?b=_:_===0&&(b=0));break}var k=e.charCodeAt(n+_),L=t.charCodeAt(r+_);if(k!==L)break;k===47&&(b=_)}var u="";for(_=n+b+1;_<=s;++_)(_===s||e.charCodeAt(_)===47)&&(u.length===0?u+="..":u+="/..");return u.length>0?u+t.slice(r+b):(r+=b,t.charCodeAt(r)===47&&++r,t.slice(r))},_makeLong:function(e){return e},dirname:function(e){if(o(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,s=-1,c=!0,r=e.length-1;r>=1;--r)if(t=e.charCodeAt(r),t===47){if(!c){s=r;break}}else c=!1;return s===-1?n?"/":".":n&&s===1?"//":e.slice(0,s)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');o(e);var n=0,s=-1,c=!0,r;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var i=t.length-1,g=-1;for(r=e.length-1;r>=0;--r){var S=e.charCodeAt(r);if(S===47){if(!c){n=r+1;break}}else g===-1&&(c=!1,g=r+1),i>=0&&(S===t.charCodeAt(i)?--i===-1&&(s=r):(i=-1,s=g))}return n===s?s=g:s===-1&&(s=e.length),e.slice(n,s)}else{for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===47){if(!c){n=r+1;break}}else s===-1&&(c=!1,s=r+1);return s===-1?"":e.slice(n,s)}},extname:function(e){o(e);for(var t=-1,n=0,s=-1,c=!0,r=0,i=e.length-1;i>=0;--i){var g=e.charCodeAt(i);if(g===47){if(!c){n=i+1;break}continue}s===-1&&(c=!1,s=i+1),g===46?t===-1?t=i:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===n+1?"":e.slice(t,s)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return f("/",e)},parse:function(e){o(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),s=n===47,c;s?(t.root="/",c=1):c=0;for(var r=-1,i=0,g=-1,S=!0,b=e.length-1,_=0;b>=c;--b){if(n=e.charCodeAt(b),n===47){if(!S){i=b+1;break}continue}g===-1&&(S=!1,g=b+1),n===46?r===-1?r=b:_!==1&&(_=1):r!==-1&&(_=-1)}return r===-1||g===-1||_===0||_===1&&r===g-1&&r===i+1?g!==-1&&(i===0&&s?t.base=t.name=e.slice(1,g):t.base=t.name=e.slice(i,g)):(i===0&&s?(t.name=e.slice(1,r),t.base=e.slice(1,g)):(t.name=e.slice(i,r),t.base=e.slice(i,g)),t.ext=e.slice(r,g)),i>0?t.dir=e.slice(0,i-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};return d.posix=d,I=d,I}var Z=Y(),M=V(Z);const B="/home/pyodide",U=o=>`${B}/${o}`,C=(o,l)=>o==null?M.resolve(B,l):M.resolve(U(o),l);function z(o,l){const f=M.normalize(l),a=M.dirname(f).split("/"),e=[];for(const t of a){e.push(t);const n=e.join("/");if(o.FS.analyzePath(n).exists){if(o.FS.isDir(n))throw new Error(`"${n}" already exists and is not a directory.`);continue}try{o.FS.mkdir(n)}catch(s){throw console.error(`Failed to create a directory "${n}"`),s}}}function H(o,l,f,d){z(o,l),o.FS.writeFile(l,f,d)}function ee(o,l,f){z(o,f),o.FS.rename(l,f)}const te="[",re="(<=>!~",oe=";",ne="@",se=new RegExp(`[${te+re+oe+ne}]`);function ae(o){return o.split(se)[0].trim()}function W(o){return o.forEach(f=>{let d;try{d=new URL(f)}catch{return}if(d.protocol==="emfs:"||d.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${f})`)}),o.filter(f=>ae(f)==="streamlit"?(console.warn(`Streamlit is specified in the requirements ("${f}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}async function ie(o){const l=typeof process<"u"&&process.versions?.node;let f;l?f=(await Promise.resolve().then(function(){return D})).sep:f="/";const d=o.slice(0,o.lastIndexOf(f)+1);if(o.endsWith(".mjs")){if(l){const a=await Promise.resolve().then(function(){return D}),e=await Promise.resolve().then(function(){return D});!o.includes("://")&&a.isAbsolute(o)&&(o=e.pathToFileURL(o).href)}return{scriptURL:o,pyodideIndexURL:d,isESModule:!0}}else return{scriptURL:o,pyodideIndexURL:d,isESModule:!1}}async function le(o,l){const{scriptURL:f,pyodideIndexURL:d,isESModule:a}=await ie(o);let e;return a?e=(await import(f)).loadPyodide:(importScripts(f),e=self.loadPyodide),e({...l,indexURL:d})}function ce(o){o.runPython(`
|
|
2
|
-
import micropip
|
|
3
|
-
micropip.add_mock_package(
|
|
4
|
-
"pyarrow", "0.0.1",
|
|
5
|
-
modules={
|
|
6
|
-
"pyarrow": """
|
|
7
|
-
__version__ = '0.0.1' # TODO: Update when releasing
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class Table:
|
|
11
|
-
@classmethod
|
|
12
|
-
def from_pandas(*args, **kwargs):
|
|
13
|
-
raise NotImplementedError("stlite is not supporting this method.")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class Array:
|
|
17
|
-
def __init__(self, *args, **kwargs):
|
|
18
|
-
raise NotImplementedError("stlite is not supporting PyArrow.Array")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class ChunkedArray:
|
|
22
|
-
def __init__(self, *args, **kwargs):
|
|
23
|
-
raise NotImplementedError("stlite is not supporting PyArrow.ChunkedArray")
|
|
24
|
-
"""
|
|
25
|
-
}
|
|
26
|
-
)
|
|
27
|
-
`)}function de(o,l,f){const d=o.pyimport("pyodide"),a=r=>d.code.find_imports(r).toJs(),e=f.map(r=>a(r)),s=Array.from(new Set(e.flat())).filter(r=>!o.runPython(`__import__('importlib').util.find_spec('${r}')`)).map(r=>o._api._import_name_to_package_name.get(r)).filter(r=>r);if(s.length===0)return Promise.resolve();const c=o.loadPackage(s);return l(s,c),c.then()}function J(o,l,f){const d=de(o,l,f);o.runPython(`
|
|
28
|
-
def __set_module_auto_load_promise__(promise):
|
|
29
|
-
from streamlit.runtime.scriptrunner import script_runner
|
|
30
|
-
script_runner.moduleAutoLoadPromise = promise
|
|
31
|
-
|
|
32
|
-
__set_module_auto_load_promise__`)(d)}async function ue(o,l,f){const{line:d,column:a}=f,e=o.Script(l);if(d>e._code_lines.length)return[];const t=e.complete.callKwargs({line:d,column:a,fuzzy:!1}),n=[];for(const s of t.toJs())n.push({name:s.name,type:s.$type,docstring:s.docstring.callKwargs({raw:!0}),complete:s.complete}),s.destroy();return n}let O=null;async function fe(o,l,f,d,a){const{files:e,archives:t,requirements:n,prebuiltPackageNames:s,wheels:c,pyodideUrl:r=o,streamlitConfig:i,idbfsMountpoints:g,nodefsMountpoints:S,moduleAutoLoad:b,env:_,languageServer:k}=f,L=W(n);if(O)a("Pyodide is already loaded."),console.debug("Pyodide is already loaded.");else{a("Loading Pyodide."),console.debug("Loading Pyodide."),O=le(r,{stdout:console.log,stderr:console.error});const m=[];c&&(m.push(c.streamlit),m.push(c.stliteLib)),k&&m.push("jedi"),L.unshift(...m),console.debug("Loaded Pyodide")}const u=await O;if(_){console.debug("Setting environment variables",_);const m=u.pyimport("os");m.environ.update(u.toPy(_)),console.debug("Set environment variables",m.environ)}let p=!1;g&&(p=!0,g.forEach(m=>{u.FS.mkdir(m),u.FS.mount(u.FS.filesystems.IDBFS,{},m)}),await new Promise((m,v)=>{u.FS.syncfs(!0,P=>{P?v(P):m()})})),S&&Object.entries(S).forEach(([m,v])=>{u.FS.mkdir(m),u.FS.mount(u.FS.filesystems.NODEFS,{root:v},m)}),a("Mounting files.");const h=[];await Promise.all(Object.keys(e).map(async m=>{const v=e[m];m=C(l,m);let P;"url"in v?(console.debug(`Fetch a file from ${v.url}`),P=await fetch(v.url).then(A=>A.arrayBuffer()).then(A=>new Uint8Array(A))):P=v.data,console.debug(`Write a file "${m}"`),H(u,m,P,e.opts),m.endsWith(".py")&&h.push(m)})),a("Unpacking archives."),await Promise.all(t.map(async m=>{let v;"url"in m?(console.debug(`Fetch an archive from ${m.url}`),v=await fetch(m.url).then(Q=>Q.arrayBuffer())):v=m.buffer;const{format:P,options:A}=m;console.debug("Unpack an archive",{format:P,options:A}),u.unpackArchive(v,P,A)})),await u.loadPackage("micropip");const y=u.pyimport("micropip");if(a("Mocking some packages."),console.debug("Mock pyarrow"),ce(u),console.debug("Mocked pyarrow"),a("Installing packages."),console.debug("Installing the prebuilt packages:",s),await u.loadPackage(s),console.debug("Installed the prebuilt packages"),console.debug("Installing the requirements:",L),await y.install.callKwargs(L,{keep_going:!0}),console.debug("Installed the requirements"),b){const m=h.map(v=>u.FS.readFile(v,{encoding:"utf8"}));J(u,d,m)}await u.runPythonAsync(`
|
|
33
|
-
import importlib
|
|
34
|
-
importlib.invalidate_caches()
|
|
35
|
-
`),a("Loading streamlit package."),console.debug("Loading the Streamlit package"),await u.runPythonAsync(`
|
|
36
|
-
import streamlit.runtime
|
|
37
|
-
`),console.debug("Loaded the Streamlit package"),a("Setting up the loggers."),console.debug("Setting the loggers"),await u.runPythonAsync(`
|
|
38
|
-
import logging
|
|
39
|
-
import streamlit.logger
|
|
40
|
-
|
|
41
|
-
streamlit.logger.get_logger = logging.getLogger
|
|
42
|
-
streamlit.logger.setup_formatter = None
|
|
43
|
-
streamlit.logger.update_formatter = lambda *a, **k: None
|
|
44
|
-
streamlit.logger.set_log_level = lambda *a, **k: None
|
|
45
|
-
|
|
46
|
-
for name in streamlit.logger._loggers.keys():
|
|
47
|
-
if name == "root":
|
|
48
|
-
name = "streamlit"
|
|
49
|
-
logger = logging.getLogger(name)
|
|
50
|
-
logger.propagate = True
|
|
51
|
-
logger.handlers.clear()
|
|
52
|
-
logger.setLevel(logging.NOTSET)
|
|
53
|
-
|
|
54
|
-
streamlit.logger._loggers = {}
|
|
55
|
-
`);const w=(m,v)=>{m>=40?console.error(v):m>=30?console.warn(v):m>=20?console.info(v):console.debug(v)},F=u.runPython(`
|
|
56
|
-
def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
|
|
57
|
-
class JsHandler(logging.Handler):
|
|
58
|
-
def emit(self, record):
|
|
59
|
-
msg = self.format(record)
|
|
60
|
-
callback(record.levelno, msg)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
root_message_format = "%(levelname)s:%(name)s:%(message)s"
|
|
64
|
-
|
|
65
|
-
root_logger = logging.getLogger()
|
|
66
|
-
root_logger.handlers.clear()
|
|
67
|
-
root_formatter = logging.Formatter(root_message_format)
|
|
68
|
-
root_handler = JsHandler()
|
|
69
|
-
root_handler.setFormatter(root_formatter)
|
|
70
|
-
root_logger.addHandler(root_handler)
|
|
71
|
-
root_logger.setLevel(logging.DEBUG)
|
|
72
|
-
|
|
73
|
-
streamlit_logger = logging.getLogger("streamlit")
|
|
74
|
-
streamlit_logger.propagate = False
|
|
75
|
-
streamlit_logger.handlers.clear()
|
|
76
|
-
streamlit_formatter = logging.Formatter(streamlit_message_format)
|
|
77
|
-
streamlit_handler = JsHandler()
|
|
78
|
-
streamlit_handler.setFormatter(streamlit_formatter)
|
|
79
|
-
streamlit_logger.addHandler(streamlit_handler)
|
|
80
|
-
streamlit_logger.setLevel(streamlit_level.upper())
|
|
81
|
-
|
|
82
|
-
__setup_loggers__`),R=(i?.["logger.level"]??"INFO").toString(),E=i?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(F(R,E,w),console.debug("Set the loggers"),a("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await u.runPythonAsync(`
|
|
83
|
-
import streamlit
|
|
84
|
-
|
|
85
|
-
def is_cacheable_msg(msg):
|
|
86
|
-
return False
|
|
87
|
-
|
|
88
|
-
streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
|
|
89
|
-
`),console.debug("Mocked some Streamlit functions"),p){a("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let m=!1;const v=()=>{console.debug("The script has finished. Syncing the filesystem."),m||(m=!0,u.FS.syncfs(!1,A=>{m=!1,A&&console.error(A)}))};(await u.runPython(`
|
|
90
|
-
def __setup_script_finished_callback__(callback):
|
|
91
|
-
from streamlit.runtime.app_session import AppSession
|
|
92
|
-
from streamlit.runtime.scriptrunner import ScriptRunnerEvent
|
|
93
|
-
|
|
94
|
-
def wrap_app_session_on_scriptrunner_event(original_method):
|
|
95
|
-
def wrapped(self, *args, **kwargs):
|
|
96
|
-
if "event" in kwargs:
|
|
97
|
-
event = kwargs["event"]
|
|
98
|
-
if event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS or event == ScriptRunnerEvent.SCRIPT_STOPPED_FOR_RERUN or event == ScriptRunnerEvent.SHUTDOWN:
|
|
99
|
-
callback()
|
|
100
|
-
return original_method(self, *args, **kwargs)
|
|
101
|
-
return wrapped
|
|
102
|
-
|
|
103
|
-
AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
|
|
104
|
-
|
|
105
|
-
__setup_script_finished_callback__`))(v),console.debug("Set up the IndexedDB filesystem synchronizer")}console.debug("Setting up the Streamlit configuration");const{load_config_options:K}=u.pyimport("stlite_lib.bootstrap"),G={"browser.gatherUsageStats":!1,...i,"runner.fastReruns":!1},X=l!=null;K(u.toPy(G),X),console.debug("Set up the Streamlit configuration");let T;if(k){a("Loading auto-completion engine."),console.debug("Loading Jedi");try{T=await u.pyimport("jedi"),console.debug("Loaded Jedi")}catch(m){console.error("Failed to load Jedi:",m),T=void 0}}return{pyodide:u,micropip:y,jedi:T,initData:f}}async function q(o,l,f){const d=C(l,f);console.debug("Preparing the Streamlit environment");const{prepare:a}=o.pyimport("stlite_lib.bootstrap");a(d,[]),console.debug("Prepared the Streamlit environment"),console.debug("Booting up the Streamlit server");const t=o.pyimport("stlite_lib.server.Server")(d,l?U(l):null);return await t.start(),console.debug("Booted up the Streamlit server"),t}function $(o,l,f,d){function a(c){l({type:"event:progress",data:{message:c}})}const e=(c,r)=>{const i=new MessageChannel;l({type:"event:moduleAutoLoad",data:{packagesToLoad:c}},[i.port2]),r.then(g=>{i.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:g}}),i.port1.close()}).catch(g=>{throw i.port1.postMessage({type:"moduleAutoLoad:error",error:g}),i.port1.close(),g})};let t=null,n=null;const s=async c=>{const r=c.data;if(r.type==="initData"){const p=r.data,h={...f,...p};console.debug("Initial data",h),t=fe(o,d,h,e,a),t.then(({pyodide:y})=>(a("Booting up the Streamlit server."),n=q(y,d,h.entrypoint),n)).then(()=>{l({type:"event:loaded"})}).catch(y=>{console.error(y),l({type:"event:error",data:{error:y}})});return}if(!t)throw new Error("Pyodide initialization has not been started yet.");if(!n)throw new Error("Streamlit server has not been started yet.");const i=await t,g=i.pyodide,S=i.micropip,b=i.jedi,{moduleAutoLoad:_}=i.initData,k=await n,L=c.ports[0];function u(p){L.postMessage(p)}try{switch(r.type){case"reboot":{console.debug("Reboot the Streamlit server",r.data);const{entrypoint:p}=r.data;k.stop(),console.debug("Booting up the Streamlit server"),n=q(g,d,p),await n,console.debug("Booted up the Streamlit server"),u({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",r.data);const{path:p}=r.data;k.start_websocket(p,(h,y)=>{if(y){const w=h;try{const F=w.toJs(),R=F.buffer.slice(F.byteOffset,F.byteOffset+F.byteLength);l({type:"websocket:message",data:{payload:R}},[R])}finally{w.destroy()}}else l({type:"websocket:message",data:{payload:h}})}),u({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",r.data);const{payload:p}=r.data;k.receive_websocket_from_js(p);break}case"http:request":{console.debug("http:request",r.data);const{request:p}=r.data,h=(y,w,F)=>{const R=new Map(w.toJs()),E=F.toJs();console.debug({statusCode:y,headers:R,body:E}),u({type:"http:response",data:{response:{statusCode:y,headers:R,body:E}}})};k.receive_http_from_js(p.method,decodeURIComponent(p.path),p.headers,p.body,h);break}case"file:write":{const{path:p,data:h,opts:y}=r.data,w=C(d,p);_&&typeof h=="string"&&w.endsWith(".py")&&(console.debug(`Auto install the requirements in ${w}`),J(g,e,[h])),console.debug(`Write a file "${w}"`),H(g,w,h,y),u({type:"reply"});break}case"file:rename":{const{oldPath:p,newPath:h}=r.data,y=C(d,p),w=C(d,h);console.debug(`Rename "${y}" to ${w}`),ee(g,y,w),u({type:"reply"});break}case"file:unlink":{const{path:p}=r.data,h=C(d,p);console.debug(`Remove "${h}`),g.FS.unlink(h),u({type:"reply"});break}case"file:read":{const{path:p,opts:h}=r.data;console.debug(`Read "${p}"`);const y=g.FS.readFile(p,h);u({type:"reply:file:read",data:{content:y}});break}case"install":{const{requirements:p}=r.data,h=W(p);console.debug("Install the requirements:",h),await S.install.callKwargs(h,{keep_going:!0}).then(()=>{console.debug("Successfully installed"),u({type:"reply"})});break}case"setEnv":{const{env:p}=r.data;g.pyimport("os").environ.update(g.toPy(p)),console.debug("Successfully set the environment variables",p),u({type:"reply"});break}case"code_completion":{if(!b)throw new Error("Jedi is not installed");const{code:p,line:h,column:y}=r.data,w=await ue(b,p,{line:h,column:y});u({type:"reply:code_completion",data:{codeCompletions:w}});break}}}catch(p){if(console.error(p),!(p instanceof Error))throw p;const h=new Error(p.message);h.name=p.name,h.stack=p.stack,u({type:"reply",error:h})}};return l({type:"event:start"}),s}const x="abcdefghijklmnopqrstuvwxyz",ge=x.length;function me(o){let l="";for(let f=0;f<o;f++){const d=Math.floor(Math.random()*ge);l+=x[d]}return l}const j="https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.mjs";if("postMessage"in self)self.onmessage=$(j,(o,l)=>l?self.postMessage(o,l):self.postMessage(o));else{const o=[];self.onconnect=l=>{let f;do f=me(4);while(o.includes(f));o.push(f),console.debug("SharedWorker mode.",{appId:f});const d=l.ports[0];d.onmessage=$(j,(a,e)=>e?d.postMessage(a,e):d.postMessage(a),void 0,f),d.start()}}var D=Object.freeze({__proto__:null});
|
|
Binary file
|