@stlite/desktop 0.49.4 → 0.51.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/README.md +75 -1
- package/bin/dump_artifacts.js +5 -5
- package/build/asset-manifest.json +3 -3
- package/build/electron/main.js +2 -2
- package/build/electron/preload.js +1 -1
- package/build/electron/worker.js +118 -0
- package/build/index.html +1 -1
- package/build/pyodide/pyodide.mjs +10 -0
- package/build/static/js/4681.fc821bbf.chunk.js +1 -0
- package/build/static/js/main.50eb94c5.js +28 -0
- package/package.json +10 -5
- package/wheels/streamlit-1.32.2-cp311-none-any.whl +0 -0
- package/build/pyodide/pyodide.js +0 -12
- package/build/static/js/3203.1bd162cb.chunk.js +0 -1
- package/build/static/js/main.2bbf8b09.js +0 -28
- /package/build/static/js/{main.2bbf8b09.js.LICENSE.txt → main.50eb94c5.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stlite/desktop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "/",
|
|
6
6
|
"main": "./build/electron/main.js",
|
|
@@ -60,14 +60,15 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@craco/craco": "^7.0.0",
|
|
63
|
-
"@stlite/common": "^0.
|
|
64
|
-
"@stlite/common-react": "^0.
|
|
65
|
-
"@stlite/kernel": "^0.
|
|
63
|
+
"@stlite/common": "^0.51.0",
|
|
64
|
+
"@stlite/common-react": "^0.51.0",
|
|
65
|
+
"@stlite/kernel": "^0.51.0",
|
|
66
66
|
"@streamlit/app": "1.32.2",
|
|
67
67
|
"@testing-library/react": "^14.1.2",
|
|
68
68
|
"@testing-library/user-event": "^14.0.0",
|
|
69
69
|
"@types/jest": "^27.4.3",
|
|
70
70
|
"@types/node": "^16.18.12",
|
|
71
|
+
"@types/node-fetch": "^2.6.11",
|
|
71
72
|
"@types/react": "^17.0.7",
|
|
72
73
|
"@types/react-dom": "^17.0.5",
|
|
73
74
|
"@types/yargs": "^17.0.32",
|
|
@@ -101,7 +102,11 @@
|
|
|
101
102
|
},
|
|
102
103
|
"stlite": {
|
|
103
104
|
"desktop": {
|
|
104
|
-
"embed": true
|
|
105
|
+
"embed": true,
|
|
106
|
+
"nodeJsWorker": true,
|
|
107
|
+
"nodefsMountpoints": {
|
|
108
|
+
"/mnt": "."
|
|
109
|
+
}
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
}
|
|
Binary file
|
package/build/pyodide/pyodide.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";var loadPyodide=(()=>{var ce=Object.create;var _=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var f=(t,e)=>_(t,"name",{value:e,configurable:!0}),g=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,c)=>(typeof require<"u"?require:e)[c]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),pe=(t,e)=>{for(var c in e)_(t,c,{get:e[c],enumerable:!0})},M=(t,e,c,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of de(e))!ue.call(t,a)&&a!==c&&_(t,a,{get:()=>e[a],enumerable:!(o=le(e,a))||o.enumerable});return t};var h=(t,e,c)=>(c=t!=null?ce(fe(t)):{},M(e||!t||!t.__esModule?_(c,"default",{value:t,enumerable:!0}):c,t)),me=t=>M(_({},"__esModule",{value:!0}),t);var j=$((P,C)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define("stackframe",[],e):typeof P=="object"?C.exports=e():t.StackFrame=e()})(P,function(){"use strict";function t(d){return!isNaN(parseFloat(d))&&isFinite(d)}f(t,"_isNumber");function e(d){return d.charAt(0).toUpperCase()+d.substring(1)}f(e,"_capitalize");function c(d){return function(){return this[d]}}f(c,"_getter");var o=["isConstructor","isEval","isNative","isToplevel"],a=["columnNumber","lineNumber"],r=["fileName","functionName","source"],n=["args"],u=["evalOrigin"],i=o.concat(a,r,n,u);function s(d){if(d)for(var y=0;y<i.length;y++)d[i[y]]!==void 0&&this["set"+e(i[y])](d[i[y]])}f(s,"StackFrame"),s.prototype={getArgs:function(){return this.args},setArgs:function(d){if(Object.prototype.toString.call(d)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=d},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(d){if(d instanceof s)this.evalOrigin=d;else if(d instanceof Object)this.evalOrigin=new s(d);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var d=this.getFileName()||"",y=this.getLineNumber()||"",w=this.getColumnNumber()||"",E=this.getFunctionName()||"";return this.getIsEval()?d?"[eval] ("+d+":"+y+":"+w+")":"[eval]:"+y+":"+w:E?E+" ("+d+":"+y+":"+w+")":d+":"+y+":"+w}},s.fromString=f(function(y){var w=y.indexOf("("),E=y.lastIndexOf(")"),ne=y.substring(0,w),ie=y.substring(w+1,E).split(","),U=y.substring(E+1);if(U.indexOf("@")===0)var R=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(U,""),oe=R[1],ae=R[2],se=R[3];return new s({functionName:ne,args:ie||void 0,fileName:oe,lineNumber:ae||void 0,columnNumber:se||void 0})},"StackFrame$$fromString");for(var l=0;l<o.length;l++)s.prototype["get"+e(o[l])]=c(o[l]),s.prototype["set"+e(o[l])]=function(d){return function(y){this[d]=!!y}}(o[l]);for(var m=0;m<a.length;m++)s.prototype["get"+e(a[m])]=c(a[m]),s.prototype["set"+e(a[m])]=function(d){return function(y){if(!t(y))throw new TypeError(d+" must be a Number");this[d]=Number(y)}}(a[m]);for(var p=0;p<r.length;p++)s.prototype["get"+e(r[p])]=c(r[p]),s.prototype["set"+e(r[p])]=function(d){return function(y){this[d]=String(y)}}(r[p]);return s})});var W=$((x,B)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define("error-stack-parser",["stackframe"],e):typeof x=="object"?B.exports=e(j()):t.ErrorStackParser=e(t.StackFrame)})(x,f(function(e){"use strict";var c=/(^|@)\S+:\d+/,o=/^\s*at .*(\S+:\d+|\(native\))/m,a=/^(eval@)?(\[native code])?$/;return{parse:f(function(n){if(typeof n.stacktrace<"u"||typeof n["opera#sourceloc"]<"u")return this.parseOpera(n);if(n.stack&&n.stack.match(o))return this.parseV8OrIE(n);if(n.stack)return this.parseFFOrSafari(n);throw new Error("Cannot parse given Error object")},"ErrorStackParser$$parse"),extractLocation:f(function(n){if(n.indexOf(":")===-1)return[n];var u=/(.+?)(?::(\d+))?(?::(\d+))?$/,i=u.exec(n.replace(/[()]/g,""));return[i[1],i[2]||void 0,i[3]||void 0]},"ErrorStackParser$$extractLocation"),parseV8OrIE:f(function(n){var u=n.stack.split(`
|
|
2
|
-
`).filter(function(i){return!!i.match(o)},this);return u.map(function(i){i.indexOf("(eval ")>-1&&(i=i.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var s=i.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),l=s.match(/ (\(.+\)$)/);s=l?s.replace(l[0],""):s;var m=this.extractLocation(l?l[1]:s),p=l&&s||void 0,d=["eval","<anonymous>"].indexOf(m[0])>-1?void 0:m[0];return new e({functionName:p,fileName:d,lineNumber:m[1],columnNumber:m[2],source:i})},this)},"ErrorStackParser$$parseV8OrIE"),parseFFOrSafari:f(function(n){var u=n.stack.split(`
|
|
3
|
-
`).filter(function(i){return!i.match(a)},this);return u.map(function(i){if(i.indexOf(" > eval")>-1&&(i=i.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),i.indexOf("@")===-1&&i.indexOf(":")===-1)return new e({functionName:i});var s=/((.*".+"[^@]*)?[^@]*)(?:@)/,l=i.match(s),m=l&&l[1]?l[1]:void 0,p=this.extractLocation(i.replace(s,""));return new e({functionName:m,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:i})},this)},"ErrorStackParser$$parseFFOrSafari"),parseOpera:f(function(n){return!n.stacktrace||n.message.indexOf(`
|
|
4
|
-
`)>-1&&n.message.split(`
|
|
5
|
-
`).length>n.stacktrace.split(`
|
|
6
|
-
`).length?this.parseOpera9(n):n.stack?this.parseOpera11(n):this.parseOpera10(n)},"ErrorStackParser$$parseOpera"),parseOpera9:f(function(n){for(var u=/Line (\d+).*script (?:in )?(\S+)/i,i=n.message.split(`
|
|
7
|
-
`),s=[],l=2,m=i.length;l<m;l+=2){var p=u.exec(i[l]);p&&s.push(new e({fileName:p[2],lineNumber:p[1],source:i[l]}))}return s},"ErrorStackParser$$parseOpera9"),parseOpera10:f(function(n){for(var u=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=n.stacktrace.split(`
|
|
8
|
-
`),s=[],l=0,m=i.length;l<m;l+=2){var p=u.exec(i[l]);p&&s.push(new e({functionName:p[3]||void 0,fileName:p[2],lineNumber:p[1],source:i[l]}))}return s},"ErrorStackParser$$parseOpera10"),parseOpera11:f(function(n){var u=n.stack.split(`
|
|
9
|
-
`).filter(function(i){return!!i.match(c)&&!i.match(/^Error created at/)},this);return u.map(function(i){var s=i.split("@"),l=this.extractLocation(s.pop()),m=s.shift()||"",p=m.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,d;m.match(/\(([^)]*)\)/)&&(d=m.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var y=d===void 0||d==="[arguments not available]"?void 0:d.split(",");return new e({functionName:p,args:y,fileName:l[0],lineNumber:l[1],columnNumber:l[2],source:i})},this)},"ErrorStackParser$$parseOpera11")}},"ErrorStackParser"))});var Re={};pe(Re,{loadPyodide:()=>T,version:()=>b});var G=h(W());var v=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&typeof process.browser>"u",F=v&&typeof module<"u"&&typeof module.exports<"u"&&typeof g<"u"&&typeof __dirname<"u",H=v&&!F,ye=typeof Deno<"u",z=!v&&!ye,q=z&&typeof window<"u"&&typeof document<"u"&&typeof document.createElement<"u"&&typeof sessionStorage<"u",V=z&&typeof importScripts<"u"&&typeof self<"u";var K,k,L,X,D,ge=`"fetch" is not defined, maybe you're using node < 18? From Pyodide >= 0.25.0, node >= 18 is required. Older versions of Node.js may work, but it is not guaranteed or supported. Falling back to "node-fetch".`;async function A(){if(!v||(K=(await import(/* webpackIgnore */"url")).default,D=await import(/* webpackIgnore */"fs/promises"),globalThis.fetch?k=fetch:(console.warn(ge),k=(await import(/* webpackIgnore */"node-fetch")).default),X=(await import(/* webpackIgnore */"vm")).default,L=await import(/* webpackIgnore */"path"),I=L.sep,typeof g<"u"))return;let t=await import(/* webpackIgnore */"fs"),e=await import(/* webpackIgnore */"crypto"),c=await import(/* webpackIgnore */"ws"),o=await import(/* webpackIgnore */"child_process"),a={fs:t,crypto:e,ws:c,child_process:o};globalThis.require=function(r){return a[r]}}f(A,"initNodeModules");function he(t,e){return L.resolve(e||".",t)}f(he,"node_resolvePath");function ve(t,e){return e===void 0&&(e=location),new URL(t,e).toString()}f(ve,"browser_resolvePath");var N;v?N=he:N=ve;var I;v||(I="/");function we(t,e){return t.startsWith("file://")&&(t=t.slice(7)),t.includes("://")?{response:k(t)}:{binary:D.readFile(t).then(c=>new Uint8Array(c.buffer,c.byteOffset,c.byteLength))}}f(we,"node_getBinaryResponse");function be(t,e){let c=new URL(t,location);return{response:fetch(c,e?{integrity:e}:{})}}f(be,"browser_getBinaryResponse");var O;v?O=we:O=be;async function J(t,e){let{response:c,binary:o}=O(t,e);if(o)return o;let a=await c;if(!a.ok)throw new Error(`Failed to load '${t}': request failed.`);return new Uint8Array(await a.arrayBuffer())}f(J,"loadBinaryFile");var S;if(q)S=f(async t=>await import(/* webpackIgnore */t),"loadScript");else if(V)S=f(async t=>{try{globalThis.importScripts(t)}catch(e){if(e instanceof TypeError)await import(/* webpackIgnore */t);else throw e}},"loadScript");else if(v)S=Ee;else throw new Error("Cannot determine runtime environment");async function Ee(t){t.startsWith("file://")&&(t=t.slice(7)),t.includes("://")?X.runInThisContext(await(await k(t)).text()):await import(/* webpackIgnore */K.pathToFileURL(t).href)}f(Ee,"nodeLoadScript");async function Y(t){if(v){await A();let e=await D.readFile(t);return JSON.parse(e)}else return await(await fetch(t)).json()}f(Y,"loadLockFile");async function Q(){if(F)return __dirname;let t;try{throw new Error}catch(o){t=o}let e=G.default.parse(t)[0].fileName;if(H){let o=await import(/* webpackIgnore */"path");return(await import(/* webpackIgnore */"url")).fileURLToPath(o.dirname(e))}let c=e.lastIndexOf(I);if(c===-1)throw new Error("Could not extract indexURL path from pyodide module location");return e.slice(0,c)}f(Q,"calculateDirname");function Z(t){let e=t.FS,c=t.FS.filesystems.MEMFS,o=t.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:function(r){if(!r.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return c.mount.apply(null,arguments)},syncfs:async(r,n,u)=>{try{let i=a.getLocalSet(r),s=await a.getRemoteSet(r),l=n?s:i,m=n?i:s;await a.reconcile(r,l,m),u(null)}catch(i){u(i)}},getLocalSet:r=>{let n=Object.create(null);function u(l){return l!=="."&&l!==".."}f(u,"isRealDir");function i(l){return m=>o.join2(l,m)}f(i,"toAbsolute");let s=e.readdir(r.mountpoint).filter(u).map(i(r.mountpoint));for(;s.length;){let l=s.pop(),m=e.stat(l);e.isDir(m.mode)&&s.push.apply(s,e.readdir(l).filter(u).map(i(l))),n[l]={timestamp:m.mtime,mode:m.mode}}return{type:"local",entries:n}},getRemoteSet:async r=>{let n=Object.create(null),u=await _e(r.opts.fileSystemHandle);for(let[i,s]of u)i!=="."&&(n[o.join2(r.mountpoint,i)]={timestamp:s.kind==="file"?(await s.getFile()).lastModifiedDate:new Date,mode:s.kind==="file"?a.FILE_MODE:a.DIR_MODE});return{type:"remote",entries:n,handles:u}},loadLocalEntry:r=>{let u=e.lookupPath(r).node,i=e.stat(r);if(e.isDir(i.mode))return{timestamp:i.mtime,mode:i.mode};if(e.isFile(i.mode))return u.contents=c.getFileDataAsTypedArray(u),{timestamp:i.mtime,mode:i.mode,contents:u.contents};throw new Error("node type not supported")},storeLocalEntry:(r,n)=>{if(e.isDir(n.mode))e.mkdirTree(r,n.mode);else if(e.isFile(n.mode))e.writeFile(r,n.contents,{canOwn:!0});else throw new Error("node type not supported");e.chmod(r,n.mode),e.utime(r,n.timestamp,n.timestamp)},removeLocalEntry:r=>{var n=e.stat(r);e.isDir(n.mode)?e.rmdir(r):e.isFile(n.mode)&&e.unlink(r)},loadRemoteEntry:async r=>{if(r.kind==="file"){let n=await r.getFile();return{contents:new Uint8Array(await n.arrayBuffer()),mode:a.FILE_MODE,timestamp:n.lastModifiedDate}}else{if(r.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+r.kind)}},storeRemoteEntry:async(r,n,u)=>{let i=r.get(o.dirname(n)),s=e.isFile(u.mode)?await i.getFileHandle(o.basename(n),{create:!0}):await i.getDirectoryHandle(o.basename(n),{create:!0});if(s.kind==="file"){let l=await s.createWritable();await l.write(u.contents),await l.close()}r.set(n,s)},removeRemoteEntry:async(r,n)=>{await r.get(o.dirname(n)).removeEntry(o.basename(n)),r.delete(n)},reconcile:async(r,n,u)=>{let i=0,s=[];Object.keys(n.entries).forEach(function(p){let d=n.entries[p],y=u.entries[p];(!y||e.isFile(d.mode)&&d.timestamp.getTime()>y.timestamp.getTime())&&(s.push(p),i++)}),s.sort();let l=[];if(Object.keys(u.entries).forEach(function(p){n.entries[p]||(l.push(p),i++)}),l.sort().reverse(),!i)return;let m=n.type==="remote"?n.handles:u.handles;for(let p of s){let d=o.normalize(p.replace(r.mountpoint,"/")).substring(1);if(u.type==="local"){let y=m.get(d),w=await a.loadRemoteEntry(y);a.storeLocalEntry(p,w)}else{let y=a.loadLocalEntry(p);await a.storeRemoteEntry(m,d,y)}}for(let p of l)if(u.type==="local")a.removeLocalEntry(p);else{let d=o.normalize(p.replace(r.mountpoint,"/")).substring(1);await a.removeRemoteEntry(m,d)}}};t.FS.filesystems.NATIVEFS_ASYNC=a}f(Z,"initializeNativeFS");var _e=f(async t=>{let e=[];async function c(a){for await(let r of a.values())e.push(r),r.kind==="directory"&&await c(r)}f(c,"collect"),await c(t);let o=new Map;o.set(".",t);for(let a of e){let r=(await t.resolve(a)).join("/");o.set(r,a)}return o},"getFsHandles");function ee(){let t={};return t.noImageDecoding=!0,t.noAudioDecoding=!0,t.noWasmDecoding=!1,t.preRun=[],t.quit=(e,c)=>{throw t.exited={status:e,toThrow:c},c},t}f(ee,"createModule");function Se(t,e){t.preRun.push(function(){let c="/";try{t.FS.mkdirTree(e)}catch(o){console.error(`Error occurred while making a home directory '${e}':`),console.error(o),console.error(`Using '${c}' for a home directory instead`),e=c}t.FS.chdir(e)})}f(Se,"createHomeDirectory");function Oe(t,e){t.preRun.push(function(){Object.assign(t.ENV,e)})}f(Oe,"setEnvironment");function ke(t,e){t.preRun.push(()=>{for(let c of e)t.FS.mkdirTree(c),t.FS.mount(t.FS.filesystems.NODEFS,{root:c},c)})}f(ke,"mountLocalDirectories");function Ne(t,e){let c=J(e);t.preRun.push(()=>{let o=t._py_version_major(),a=t._py_version_minor();t.FS.mkdirTree("/lib"),t.FS.mkdirTree(`/lib/python${o}.${a}/site-packages`),t.addRunDependency("install-stdlib"),c.then(r=>{t.FS.writeFile(`/lib/python${o}${a}.zip`,r)}).catch(r=>{console.error("Error occurred while installing the standard library:"),console.error(r)}).finally(()=>{t.removeRunDependency("install-stdlib")})})}f(Ne,"installStdlib");function te(t,e){let c;e.stdLibURL!=null?c=e.stdLibURL:c=e.indexURL+"python_stdlib.zip",Ne(t,c),Se(t,e.env.HOME),Oe(t,e.env),ke(t,e._node_mounts),t.preRun.push(()=>Z(t))}f(te,"initializeFileSystem");function re(t,e){let{binary:c,response:o}=O(e+"pyodide.asm.wasm");t.instantiateWasm=function(a,r){return async function(){try{let n;o?n=await WebAssembly.instantiateStreaming(o,a):n=await WebAssembly.instantiate(await c,a);let{instance:u,module:i}=n;typeof WasmOffsetConverter<"u"&&(wasmOffsetConverter=new WasmOffsetConverter(wasmBinary,i)),r(u,i)}catch(n){console.warn("wasm instantiation failed!"),console.warn(n)}}(),{}}}f(re,"preloadWasm");var b="0.25.0";async function T(t={}){await A();let e=t.indexURL||await Q();e=N(e),e.endsWith("/")||(e+="/"),t.indexURL=e;let c={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,lockFileURL:e+"pyodide-lock.json",args:[],_node_mounts:[],env:{},packageCacheDir:e,packages:[]},o=Object.assign(c,t);o.env.HOME||(o.env.HOME="/home/pyodide");let a=ee();a.print=o.stdout,a.printErr=o.stderr,a.arguments=o.args;let r={config:o};a.API=r,r.lockFilePromise=Y(o.lockFileURL),re(a,e),te(a,o);let n=new Promise(s=>a.postRun=s);if(a.locateFile=s=>o.indexURL+s,typeof _createPyodideModule!="function"){let s=`${o.indexURL}pyodide.asm.js`;await S(s)}if(await _createPyodideModule(a),await n,a.exited)throw a.exited.toThrow;if(t.pyproxyToStringRepr&&r.setPyProxyToStringMethod(!0),r.version!==b)throw new Error(`Pyodide version does not match: '${b}' <==> '${r.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);a.locateFile=s=>{throw new Error("Didn't expect to load any more file_packager files!")};let u=r.finalizeBootstrap();if(u.version.includes("dev")||r.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${u.version}/full/`),await r.packageIndexReady,r._pyodide._importhook.register_module_not_found_hook(r._import_name_to_package_name,r.lockfile_unvendored_stdlibs_and_test),r.lockfile_info.version!==b)throw new Error("Lock file version doesn't match Pyodide version");return r.package_loader.init_loaded_packages(),o.fullStdLib&&await u.loadPackage(r.lockfile_unvendored_stdlibs),r.initializeStreams(o.stdin,o.stdout,o.stderr),u}f(T,"loadPyodide");globalThis.loadPyodide=T;return me(Re);})();
|
|
10
|
-
try{Object.assign(exports,loadPyodide)}catch(_){}
|
|
11
|
-
globalThis.loadPyodide=loadPyodide.loadPyodide;
|
|
12
|
-
//# sourceMappingURL=pyodide.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{"use strict";var e={56977:e=>{function t(e){if("string"!==typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function r(e,t){for(var r,n="",o=0,s=-1,a=0,l=0;l<=e.length;++l){if(l<e.length)r=e.charCodeAt(l);else{if(47===r)break;r=47}if(47===r){if(s===l-1||1===a);else if(s!==l-1&&2===a){if(n.length<2||2!==o||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var i=n.lastIndexOf("/");if(i!==n.length-1){-1===i?(n="",o=0):o=(n=n.slice(0,i)).length-1-n.lastIndexOf("/"),s=l,a=0;continue}}else if(2===n.length||1===n.length){n="",o=0,s=l,a=0;continue}t&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+e.slice(s+1,l):n=e.slice(s+1,l),o=l-s-1;s=l,a=0}else 46===r&&-1!==a?++a:a=-1}return n}var n={resolve:function(){for(var e,n="",o=!1,s=arguments.length-1;s>=-1&&!o;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=process.cwd()),a=e),t(a),0!==a.length&&(n=a+"/"+n,o=47===a.charCodeAt(0))}return n=r(n,!o),o?n.length>0?"/"+n:"/":n.length>0?n:"."},normalize:function(e){if(t(e),0===e.length)return".";var n=47===e.charCodeAt(0),o=47===e.charCodeAt(e.length-1);return 0!==(e=r(e,!n)).length||n||(e="."),e.length>0&&o&&(e+="/"),n?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,r=0;r<arguments.length;++r){var o=arguments[r];t(o),o.length>0&&(void 0===e?e=o:e+="/"+o)}return void 0===e?".":n.normalize(e)},relative:function(e,r){if(t(e),t(r),e===r)return"";if((e=n.resolve(e))===(r=n.resolve(r)))return"";for(var o=1;o<e.length&&47===e.charCodeAt(o);++o);for(var s=e.length,a=s-o,l=1;l<r.length&&47===r.charCodeAt(l);++l);for(var i=r.length-l,c=a<i?a:i,g=-1,d=0;d<=c;++d){if(d===c){if(i>c){if(47===r.charCodeAt(l+d))return r.slice(l+d+1);if(0===d)return r.slice(l+d)}else a>c&&(47===e.charCodeAt(o+d)?g=d:0===d&&(g=0));break}var h=e.charCodeAt(o+d);if(h!==r.charCodeAt(l+d))break;47===h&&(g=d)}var p="";for(d=o+g+1;d<=s;++d)d!==s&&47!==e.charCodeAt(d)||(0===p.length?p+="..":p+="/..");return p.length>0?p+r.slice(l+g):(l+=g,47===r.charCodeAt(l)&&++l,r.slice(l))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var r=e.charCodeAt(0),n=47===r,o=-1,s=!0,a=e.length-1;a>=1;--a)if(47===(r=e.charCodeAt(a))){if(!s){o=a;break}}else s=!1;return-1===o?n?"/":".":n&&1===o?"//":e.slice(0,o)},basename:function(e,r){if(void 0!==r&&"string"!==typeof r)throw new TypeError('"ext" argument must be a string');t(e);var n,o=0,s=-1,a=!0;if(void 0!==r&&r.length>0&&r.length<=e.length){if(r.length===e.length&&r===e)return"";var l=r.length-1,i=-1;for(n=e.length-1;n>=0;--n){var c=e.charCodeAt(n);if(47===c){if(!a){o=n+1;break}}else-1===i&&(a=!1,i=n+1),l>=0&&(c===r.charCodeAt(l)?-1===--l&&(s=n):(l=-1,s=i))}return o===s?s=i:-1===s&&(s=e.length),e.slice(o,s)}for(n=e.length-1;n>=0;--n)if(47===e.charCodeAt(n)){if(!a){o=n+1;break}}else-1===s&&(a=!1,s=n+1);return-1===s?"":e.slice(o,s)},extname:function(e){t(e);for(var r=-1,n=0,o=-1,s=!0,a=0,l=e.length-1;l>=0;--l){var i=e.charCodeAt(l);if(47!==i)-1===o&&(s=!1,o=l+1),46===i?-1===r?r=l:1!==a&&(a=1):-1!==r&&(a=-1);else if(!s){n=l+1;break}}return-1===r||-1===o||0===a||1===a&&r===o-1&&r===n+1?"":e.slice(r,o)},format:function(e){if(null===e||"object"!==typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+e+n:n}("/",e)},parse:function(e){t(e);var r={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return r;var n,o=e.charCodeAt(0),s=47===o;s?(r.root="/",n=1):n=0;for(var a=-1,l=0,i=-1,c=!0,g=e.length-1,d=0;g>=n;--g)if(47!==(o=e.charCodeAt(g)))-1===i&&(c=!1,i=g+1),46===o?-1===a?a=g:1!==d&&(d=1):-1!==a&&(d=-1);else if(!c){l=g+1;break}return-1===a||-1===i||0===d||1===d&&a===i-1&&a===l+1?-1!==i&&(r.base=r.name=0===l&&s?e.slice(1,i):e.slice(l,i)):(0===l&&s?(r.name=e.slice(1,a),r.base=e.slice(1,i)):(r.name=e.slice(l,a),r.base=e.slice(l,i)),r.ext=e.slice(a,i)),l>0?r.dir=e.slice(0,l-1):s&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};n.posix=n,e.exports=n}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{function e(e){e.forEach((e=>{let t;try{t=new URL(e)}catch(r){return}if("emfs:"===t.protocol||"file:"===t.protocol)throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${e})`)}))}var t=r(56977),n=r.n(t);function o(e,t){const r=n().normalize(t),o=n().dirname(r).split("/"),s=[];for(const n of o){s.push(n);const t=s.join("/");if(e.FS.analyzePath(t).exists){if(e.FS.isDir(t))throw new Error(`"${t}" already exists and is not a directory.`)}else try{e.FS.mkdir(t)}catch(a){throw console.error(`Failed to create a directory "${t}"`),a}}}function s(e,t,r,n){o(e,t),e.FS.writeFile(t,r,n)}function a(e){e.runPython('\nimport micropip\nmicropip.add_mock_package(\n "pyarrow", "0.0.1",\n modules={\n "pyarrow": """\n__version__ = \'0.0.1\' # TODO: Update when releasing\n\n\nclass Table:\n @classmethod\n def from_pandas(*args, **kwargs):\n raise NotImplementedError("stlite is not supporting this method.")\n"""\n }\n)\n')}var l=function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function a(e){try{i(n.next(e))}catch(t){s(t)}}function l(e){try{i(n.throw(e))}catch(t){s(t)}}function i(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,l)}i((n=n.apply(e,t||[])).next())}))};let i,c;const g=self,d=new class{constructor(){this.promise=new Promise(((e,t)=>{this.resolveInternal=e,this.rejectInternal=t}))}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}};function h(e){g.postMessage({type:"event:progress",data:{message:e}})}const p="https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.js";const u=function(){var t,r;return l(this,void 0,void 0,(function*(){const{entrypoint:n,files:o,archives:u,requirements:m,wheels:f,mountedSitePackagesSnapshotFilePath:_,pyodideUrl:y=p,streamlitConfig:v}=yield d.promise;if(h("Loading Pyodide."),console.debug("Loading Pyodide"),i=yield function(e,t){return l(this,void 0,void 0,(function*(){const r=e.slice(0,e.lastIndexOf("/")+1);let n;return e.endsWith(".mjs")?n=(yield import(e)).loadPyodide:(importScripts(e),n=self.loadPyodide),n(Object.assign(Object.assign({},t),{indexURL:r}))}))}(y,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide"),h("Mounting files."),yield Promise.all(Object.keys(o).map((e=>l(this,void 0,void 0,(function*(){const t=o[e];let r;"url"in t?(console.debug(`Fetch a file from ${t.url}`),r=yield fetch(t.url).then((e=>e.arrayBuffer())).then((e=>new Uint8Array(e)))):r=t.data;const{opts:n}=o[e];console.debug(`Write a file "${e}"`),s(i,e,r,n)}))))),h("Unpacking archives."),yield Promise.all(u.map((e=>l(this,void 0,void 0,(function*(){let t;"url"in e?(console.debug(`Fetch an archive from ${e.url}`),t=yield fetch(e.url).then((e=>e.arrayBuffer()))):t=e.buffer;const{format:r,options:n}=e;console.debug("Unpack an archive",{format:r,options:n}),i.unpackArchive(t,r,n)}))))),!_&&!f)throw new Error("Neither snapshot nor wheel files are provided.");_&&(h("Restoring the snapshot."),yield i.runPythonAsync("import tarfile, shutil, site"),yield i.runPythonAsync("\n site_packages_dirs = site.getsitepackages()\n for site_packages in site_packages_dirs:\n shutil.rmtree(site_packages)\n "),console.debug(`Unarchive ${_}`),yield i.runPythonAsync(`\n with tarfile.open("${_}", "r") as tar_gz_file:\n tar_gz_file.extractall("/")\n `),console.debug("Restored the snapshot"),h("Mocking some packages."),console.debug("Mock pyarrow"),a(i),console.debug("Mocked pyarrow")),e(m),h("Installing packages."),yield i.loadPackage("micropip");const b=i.pyimport("micropip");f?(console.debug("Installing the wheels:",f,"and the requirements:",m),yield b.install.callKwargs([f.stliteServer,f.streamlit,...m],{keep_going:!0}),console.debug("Installed the wheels and the requirements"),h("Mocking some packages."),console.debug("Mock pyarrow"),a(i),console.debug("Mocked pyarrow")):(console.debug("Installing the requirements:",m),yield b.install.callKwargs(m,{keep_going:!0}),console.debug("Installed the requirements")),yield i.runPythonAsync("\n import importlib\n importlib.invalidate_caches()\n "),h("Loading streamlit package."),console.debug("Loading the Streamlit package"),yield i.runPythonAsync("\n import streamlit.runtime\n "),console.debug("Loaded the Streamlit package"),h("Setting up the loggers."),console.debug("Setting the loggers"),yield i.runPythonAsync('\n import logging\n import streamlit.logger\n\n streamlit.logger.get_logger = logging.getLogger\n streamlit.logger.setup_formatter = None\n streamlit.logger.update_formatter = lambda *a, **k: None\n streamlit.logger.set_log_level = lambda *a, **k: None\n\n for name in streamlit.logger._loggers.keys():\n if name == "root":\n name = "streamlit"\n logger = logging.getLogger(name)\n logger.propagate = True\n logger.handlers.clear()\n logger.setLevel(logging.NOTSET)\n\n streamlit.logger._loggers = {}\n ');self.__logCallback__=(e,t)=>{e>=40?console.error(t):e>=30?console.warn(t):e>=20?console.info(t):console.debug(t)},yield i.runPythonAsync('\ndef setup_loggers(streamlit_level, streamlit_message_format):\n from js import __logCallback__\n\n\n class JsHandler(logging.Handler):\n def emit(self, record):\n msg = self.format(record)\n __logCallback__(record.levelno, msg)\n\n\n root_message_format = "%(levelname)s:%(name)s:%(message)s"\n\n root_logger = logging.getLogger()\n root_logger.handlers.clear()\n root_formatter = logging.Formatter(root_message_format)\n root_handler = JsHandler()\n root_handler.setFormatter(root_formatter)\n root_logger.addHandler(root_handler)\n root_logger.setLevel(logging.DEBUG)\n\n streamlit_logger = logging.getLogger("streamlit")\n streamlit_logger.propagate = False\n streamlit_logger.handlers.clear()\n streamlit_formatter = logging.Formatter(streamlit_message_format)\n streamlit_handler = JsHandler()\n streamlit_handler.setFormatter(streamlit_formatter)\n streamlit_logger.addHandler(streamlit_handler)\n streamlit_logger.setLevel(streamlit_level.upper())\n ');const k=(null!==(t=null===v||void 0===v?void 0:v["logger.level"])&&void 0!==t?t:"INFO").toString(),w=null!==(r=null===v||void 0===v?void 0:v["logger.messageFormat"])&&void 0!==r?r:"%(asctime)s %(message)s";i.globals.get("setup_loggers")(k,w),console.debug("Set the loggers"),h("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),yield i.runPythonAsync("\n import streamlit\n\n def is_cacheable_msg(msg):\n return False\n\n streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg\n "),console.debug("Mocked some Streamlit functions"),h("Booting up the Streamlit server."),console.debug("Booting up the Streamlit server"),self.__streamlitFlagOptions__=Object.assign(Object.assign({"browser.gatherUsageStats":!1},v),{"runner.fastReruns":!1}),yield i.runPythonAsync(`\n from stlite_server.bootstrap import load_config_options, prepare\n from stlite_server.server import Server\n from js import __streamlitFlagOptions__\n\n flag_options = __streamlitFlagOptions__.to_py()\n load_config_options(flag_options)\n\n main_script_path = "${n}"\n command_line = None\n args = []\n\n prepare(main_script_path, args)\n\n server = Server(main_script_path, command_line)\n server.start()\n `),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),c=i.globals.get("server").copy(),console.debug("Set up the HTTP server"),g.postMessage({type:"event:loaded"})}))}().catch((e=>{throw g.postMessage({type:"event:error",data:{error:e}}),e}));self.onmessage=t=>l(void 0,void 0,void 0,(function*(){const r=t.data;if("initData"===r.type)return void d.resolve(r.data);yield u;const n=t.ports[0];try{switch(r.type){case"websocket:connect":{console.debug("websocket:connect",r.data);const{path:e}=r.data;c.start_websocket(e,((e,t)=>{if(t){const t=e.getBuffer("u8");e.destroy();const r=new Uint8ClampedArray(t.data.buffer,t.data.byteOffset,t.data.byteLength);g.postMessage({type:"websocket:message",data:{payload:new Uint8Array(r)}})}else g.postMessage({type:"websocket:message",data:{payload:e}})})),n.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",r.data);const{payload:e}=r.data;c.receive_websocket_from_js(e);break}case"http:request":{console.debug("http:request",r.data);const{request:e}=r.data,t=(e,t,r)=>{const o=t.toJs(),s=r.toJs();console.debug({statusCode:e,headers:o,body:s});const a={type:"http:response",data:{response:{statusCode:e,headers:o,body:s}}};n.postMessage(a)};c.receive_http_from_js(e.method,decodeURIComponent(e.path),e.headers,e.body,t);break}case"file:write":{const{path:e,data:t,opts:o}=r.data;console.debug(`Write a file "${e}"`),s(i,e,t,o),n.postMessage({type:"reply"});break}case"file:rename":{const{oldPath:e,newPath:t}=r.data;console.debug(`Rename "${e}" to ${t}`),function(e,t,r){o(e,r),e.FS.rename(t,r)}(i,e,t),n.postMessage({type:"reply"});break}case"file:unlink":{const{path:e}=r.data;console.debug(`Remove "${e}`),i.FS.unlink(e),n.postMessage({type:"reply"});break}case"install":{const{requirements:t}=r.data,o=i.pyimport("micropip");console.debug("Install the requirements:",t),e(t),yield o.install.callKwargs(t,{keep_going:!0}).then((()=>{if(t.includes("matplotlib"))return i.runPythonAsync("\n from stlite_server.bootstrap import _fix_matplotlib_crash\n _fix_matplotlib_crash()\n ")})).then((()=>{console.debug("Successfully installed"),n.postMessage({type:"reply"})}))}}}catch(a){if(console.error(a),!(a instanceof Error))throw a;const e=new Error(a.message);e.name=a.name,e.stack=a.stack,n.postMessage({type:"reply",error:e})}})),g.postMessage({type:"event:start"})})()})();
|