@stlite/desktop 0.62.3 → 0.63.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/build/asset-manifest.json +3 -3
- package/build/electron/worker.js +8 -12
- package/build/index.html +1 -1
- package/build/pyodide/pyodide-lock.json +1 -1
- package/build/pyodide/pyodide.asm.js +1 -1
- package/build/pyodide/pyodide.asm.wasm +0 -0
- package/build/pyodide/pyodide.mjs +3 -9
- package/build/pyodide/python_stdlib.zip +0 -0
- package/build/static/js/{8798.a2b2458c.chunk.js → 8798.40210cf2.chunk.js} +1 -1
- package/build/static/js/{main.53e797b7.js → main.be274c69.js} +3 -3
- package/package.json +6 -6
- package/wheels/stlite_lib-0.1.0-py3-none-any.whl +0 -0
- package/wheels/streamlit-1.36.0-cp312-none-any.whl +0 -0
- /package/build/static/js/{main.53e797b7.js.LICENSE.txt → main.be274c69.js.LICENSE.txt} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/static/css/main.fc8432ac.css",
|
|
4
|
-
"main.js": "/static/js/main.
|
|
5
|
-
"static/js/8798.
|
|
4
|
+
"main.js": "/static/js/main.be274c69.js",
|
|
5
|
+
"static/js/8798.40210cf2.chunk.js": "/static/js/8798.40210cf2.chunk.js",
|
|
6
6
|
"static/js/4994.2d981099.chunk.js": "/static/js/4994.2d981099.chunk.js",
|
|
7
7
|
"static/js/3685.39209b63.chunk.js": "/static/js/3685.39209b63.chunk.js",
|
|
8
8
|
"static/js/4785.3cf5ba35.chunk.js": "/static/js/4785.3cf5ba35.chunk.js",
|
|
@@ -163,6 +163,6 @@
|
|
|
163
163
|
},
|
|
164
164
|
"entrypoints": [
|
|
165
165
|
"static/css/main.fc8432ac.css",
|
|
166
|
-
"static/js/main.
|
|
166
|
+
"static/js/main.be274c69.js"
|
|
167
167
|
]
|
|
168
168
|
}
|
package/build/electron/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var me=Object.create;var K=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var I=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ve=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _e(e))!he.call(r,o)&&o!==t&&K(r,o,{get:()=>e[o],enumerable:!(s=pe(e,o))||s.enumerable});return r};var M=(r,e,t)=>(t=r!=null?me(ye(r)):{},ve(e||!r||!r.__esModule?K(t,"default",{value:r,enumerable:!0}):t,r));var V=I(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.validateRequirements=void 0;var Pe="[",be="(<=>!~",Se=";",we="@",ke=new RegExp(`[${Pe+be+Se+we}]`);function Ae(r){return r.split(ke)[0].trim()}function Re(r){return r.forEach(t=>{let s;try{s=new URL(t)}catch{return}if(s.protocol==="emfs:"||s.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${t})`)}),r.filter(t=>Ae(t)==="streamlit"?(console.warn(`Streamlit is specified in the requirements ("${t}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}C.validateRequirements=Re});var X=I(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.parseRequirementsTxt=void 0;var Fe=/\s#.*$/;function Ie(r){return r.split(`
|
|
2
|
-
`).filter(e=>!e.startsWith("#")).map(e=>e.replace(Fe,"")).map(e=>e.trim()).filter(e=>e!=="")}T.parseRequirementsTxt=Ie});var G=I(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.PromiseDelegate=void 0;var U=class{constructor(){this.promise=new Promise((e,t)=>{this.resolveInternal=e,this.rejectInternal=t})}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}};N.PromiseDelegate=U});var Q=I(b=>{"use strict";var Me=b&&b.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t);var o=Object.getOwnPropertyDescriptor(e,t);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,s,o)}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t]}),x=b&&b.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Me(e,r,t)};Object.defineProperty(b,"__esModule",{value:!0});x(V(),b);x(X(),b);x(G(),b)});var ee=I((
|
|
2
|
+
`).filter(e=>!e.startsWith("#")).map(e=>e.replace(Fe,"")).map(e=>e.trim()).filter(e=>e!=="")}T.parseRequirementsTxt=Ie});var G=I(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.PromiseDelegate=void 0;var U=class{constructor(){this.promise=new Promise((e,t)=>{this.resolveInternal=e,this.rejectInternal=t})}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}};N.PromiseDelegate=U});var Q=I(b=>{"use strict";var Me=b&&b.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t);var o=Object.getOwnPropertyDescriptor(e,t);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,s,o)}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t]}),x=b&&b.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Me(e,r,t)};Object.defineProperty(b,"__esModule",{value:!0});x(V(),b);x(X(),b);x(G(),b)});var ee=I((Xe,Z)=>{"use strict";function v(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function Y(r,e){for(var t="",s=0,o=-1,i=0,n,a=0;a<=r.length;++a){if(a<r.length)n=r.charCodeAt(a);else{if(n===47)break;n=47}if(n===47){if(!(o===a-1||i===1))if(o!==a-1&&i===2){if(t.length<2||s!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var c=t.lastIndexOf("/");if(c!==t.length-1){c===-1?(t="",s=0):(t=t.slice(0,c),s=t.length-1-t.lastIndexOf("/")),o=a,i=0;continue}}else if(t.length===2||t.length===1){t="",s=0,o=a,i=0;continue}}e&&(t.length>0?t+="/..":t="..",s=2)}else t.length>0?t+="/"+r.slice(o+1,a):t=r.slice(o+1,a),s=a-o-1;o=a,i=0}else n===46&&i!==-1?++i:i=-1}return t}function Oe(r,e){var t=e.dir||e.root,s=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+s:t+r+s:s}var A={resolve:function(){for(var e="",t=!1,s,o=arguments.length-1;o>=-1&&!t;o--){var i;o>=0?i=arguments[o]:(s===void 0&&(s=process.cwd()),i=s),v(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=Y(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(v(e),e.length===0)return".";var t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=Y(e,!t),e.length===0&&!t&&(e="."),e.length>0&&s&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return v(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 s=arguments[t];v(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":A.normalize(e)},relative:function(e,t){if(v(e),v(t),e===t||(e=A.resolve(e),t=A.resolve(t),e===t))return"";for(var s=1;s<e.length&&e.charCodeAt(s)===47;++s);for(var o=e.length,i=o-s,n=1;n<t.length&&t.charCodeAt(n)===47;++n);for(var a=t.length,c=a-n,g=i<c?i:c,f=-1,l=0;l<=g;++l){if(l===g){if(c>g){if(t.charCodeAt(n+l)===47)return t.slice(n+l+1);if(l===0)return t.slice(n+l)}else i>g&&(e.charCodeAt(s+l)===47?f=l:l===0&&(f=0));break}var w=e.charCodeAt(s+l),_=t.charCodeAt(n+l);if(w!==_)break;w===47&&(f=l)}var d="";for(l=s+f+1;l<=o;++l)(l===o||e.charCodeAt(l)===47)&&(d.length===0?d+="..":d+="/..");return d.length>0?d+t.slice(n+f):(n+=f,t.charCodeAt(n)===47&&++n,t.slice(n))},_makeLong:function(e){return e},dirname:function(e){if(v(e),e.length===0)return".";for(var t=e.charCodeAt(0),s=t===47,o=-1,i=!0,n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){o=n;break}}else i=!1;return o===-1?s?"/":".":s&&o===1?"//":e.slice(0,o)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');v(e);var s=0,o=-1,i=!0,n;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,c=-1;for(n=e.length-1;n>=0;--n){var g=e.charCodeAt(n);if(g===47){if(!i){s=n+1;break}}else c===-1&&(i=!1,c=n+1),a>=0&&(g===t.charCodeAt(a)?--a===-1&&(o=n):(a=-1,o=c))}return s===o?o=c:o===-1&&(o=e.length),e.slice(s,o)}else{for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===47){if(!i){s=n+1;break}}else o===-1&&(i=!1,o=n+1);return o===-1?"":e.slice(s,o)}},extname:function(e){v(e);for(var t=-1,s=0,o=-1,i=!0,n=0,a=e.length-1;a>=0;--a){var c=e.charCodeAt(a);if(c===47){if(!i){s=a+1;break}continue}o===-1&&(i=!1,o=a+1),c===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||o===-1||n===0||n===1&&t===o-1&&t===s+1?"":e.slice(t,o)},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 Oe("/",e)},parse:function(e){v(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var s=e.charCodeAt(0),o=s===47,i;o?(t.root="/",i=1):i=0;for(var n=-1,a=0,c=-1,g=!0,f=e.length-1,l=0;f>=i;--f){if(s=e.charCodeAt(f),s===47){if(!g){a=f+1;break}continue}c===-1&&(g=!1,c=f+1),s===46?n===-1?n=f:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||c===-1||l===0||l===1&&n===c-1&&n===a+1?c!==-1&&(a===0&&o?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(a,c)):(a===0&&o?(t.name=e.slice(1,n),t.base=e.slice(1,c)):(t.name=e.slice(a,n),t.base=e.slice(a,c)),t.ext=e.slice(n,c)),a>0?t.dir=e.slice(0,a-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};A.posix=A;Z.exports=A});var H=require("node:worker_threads");var ae=M(Q());var q=M(ee());function te(r,e){let t=q.default.normalize(e),o=q.default.dirname(t).split("/"),i=[];for(let n of o){i.push(n);let a=i.join("/");if(r.FS.analyzePath(a).exists){if(r.FS.isDir(a))throw new Error(`"${a}" already exists and is not a directory.`);continue}try{r.FS.mkdir(a)}catch(c){throw console.error(`Failed to create a directory "${a}"`),c}}}function $(r,e,t,s){te(r,e),r.FS.writeFile(e,t,s)}function re(r,e,t){te(r,t),r.FS.rename(e,t)}var Le="[",Ee="(<=>!~",Ce=";",Te="@",Ne=new RegExp(`[${Le+Ee+Ce+Te}]`);function De(r){return r.split(Ne)[0].trim()}function j(r){return r.forEach(t=>{let s;try{s=new URL(t)}catch{return}if(s.protocol==="emfs:"||s.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${t})`)}),r.filter(t=>De(t)==="streamlit"?(console.warn(`Streamlit is specified in the requirements ("${t}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}async function Ue(r){let e=typeof process<"u"&&process.versions?.node,t;e?t=(await import("node:path")).sep:t="/";let s=r.slice(0,r.lastIndexOf(t)+1);if(r.endsWith(".mjs")){if(e){let o=await import("node:path"),i=await import("node:url");!r.includes("://")&&o.isAbsolute(r)&&(r=i.pathToFileURL(r).href)}return{scriptURL:r,pyodideIndexURL:s,isESModule:!0}}else return{scriptURL:r,pyodideIndexURL:s,isESModule:!1}}async function oe(r,e){let{scriptURL:t,pyodideIndexURL:s,isESModule:o}=await Ue(r),i;return o?i=(await import(t)).loadPyodide:(importScripts(t),i=self.loadPyodide),i({...e,indexURL:s})}function se(r){r.runPython(`
|
|
3
3
|
import micropip
|
|
4
4
|
micropip.add_mock_package(
|
|
5
5
|
"pyarrow", "0.0.1",
|
|
@@ -25,7 +25,7 @@ class ChunkedArray:
|
|
|
25
25
|
"""
|
|
26
26
|
}
|
|
27
27
|
)
|
|
28
|
-
`)}var
|
|
28
|
+
`)}var W;function xe(r,e){return W||(r.runPython(`
|
|
29
29
|
import ast
|
|
30
30
|
from textwrap import dedent
|
|
31
31
|
|
|
@@ -48,12 +48,12 @@ def find_imports(source: str) -> list[str]:
|
|
|
48
48
|
continue
|
|
49
49
|
imports.add(module_name.split(".")[0])
|
|
50
50
|
return imports
|
|
51
|
-
`),
|
|
51
|
+
`),W=r.globals.get("find_imports")),W(e).toJs()}function qe(r){let e=new Set;for(let t of r)for(let s of t)e.add(s);return e}async function ne(r,e,t){let s=t.map(g=>xe(r,g)),o=qe(s),a=Array.from(o).filter(g=>!r.runPython(`__import__('importlib').util.find_spec('${g}')`)).map(g=>r._api._import_name_to_package_name.get(g)).filter(g=>g);if(a.length===0)return;let c=new MessageChannel;e({type:"event:moduleAutoLoad",data:{packagesToLoad:a}},c.port2);try{let g=await r.loadPackage(a);c.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:g}}),c.port1.close();return}catch(g){throw c.port1.postMessage({type:"moduleAutoLoad:error",error:g}),c.port1.close(),g}}var D=global;function ie(r,e,t){let s=ne(r,e,t);D.__moduleAutoLoadPromise__=s,r.runPythonAsync(`
|
|
52
52
|
from streamlit.runtime.scriptrunner import script_runner
|
|
53
53
|
from js import __moduleAutoLoadPromise__
|
|
54
54
|
|
|
55
55
|
script_runner.moduleAutoLoadPromise = __moduleAutoLoadPromise__
|
|
56
|
-
`)}function le(r,e,t){function s(
|
|
56
|
+
`)}function le(r,e,t){function s(f){e({type:"event:progress",data:{message:f}})}let o,i,n=new ae.PromiseDelegate;async function a(){let f=await n.promise,l={...t,...f};console.debug("Initial data",l);let{entrypoint:w,files:_,archives:d,requirements:p,prebuiltPackageNames:y,wheels:h,pyodideUrl:k=r,streamlitConfig:S,idbfsMountpoints:R,nodefsMountpoints:O,moduleAutoLoad:ce}=l,L=j(p);s("Loading Pyodide."),console.debug("Loading Pyodide"),o=await oe(k,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide");let B=!1;R&&(B=!0,R.forEach(u=>{o.FS.mkdir(u),o.FS.mount(o.FS.filesystems.IDBFS,{},u)}),await new Promise((u,m)=>{o.FS.syncfs(!0,P=>{P?m(P):u()})})),O&&Object.entries(O).forEach(([u,m])=>{o.FS.mkdir(u),o.FS.mount(o.FS.filesystems.NODEFS,{root:m},u)}),s("Mounting files.");let z=[];await Promise.all(Object.keys(_).map(async u=>{let m=_[u],P;"url"in m?(console.debug(`Fetch a file from ${m.url}`),P=await fetch(m.url).then(F=>F.arrayBuffer()).then(F=>new Uint8Array(F))):P=m.data;let{opts:E}=_[u];console.debug(`Write a file "${u}"`),$(o,u,P,E),u.endsWith(".py")&&z.push(u)})),s("Unpacking archives."),await Promise.all(d.map(async u=>{let m;"url"in u?(console.debug(`Fetch an archive from ${u.url}`),m=await fetch(u.url).then(F=>F.arrayBuffer())):m=u.buffer;let{format:P,options:E}=u;console.debug("Unpack an archive",{format:P,options:E}),o.unpackArchive(m,P,E)})),await o.loadPackage("micropip");let J=o.pyimport("micropip");if(s("Mocking some packages."),console.debug("Mock pyarrow"),se(o),console.debug("Mocked pyarrow"),s("Installing packages."),console.debug("Installing the prebuilt packages:",y),await o.loadPackage(y),console.debug("Installed the prebuilt packages"),h?(console.debug("Installing the wheels:",h,"and the requirements:",L),await J.install.callKwargs([h.stliteLib,h.streamlit,...L],{keep_going:!0}),console.debug("Installed the wheels and the requirements")):(console.debug("Installing the requirements:",L),await J.install.callKwargs(L,{keep_going:!0}),console.debug("Installed the requirements")),ce){let u=z.map(m=>o.FS.readFile(m,{encoding:"utf8"}));ie(o,e,u)}await o.runPythonAsync(`
|
|
57
57
|
import importlib
|
|
58
58
|
importlib.invalidate_caches()
|
|
59
59
|
`),s("Loading streamlit package."),console.debug("Loading the Streamlit package"),await o.runPythonAsync(`
|
|
@@ -105,7 +105,7 @@ def setup_loggers(streamlit_level, streamlit_message_format):
|
|
|
105
105
|
streamlit_handler.setFormatter(streamlit_formatter)
|
|
106
106
|
streamlit_logger.addHandler(streamlit_handler)
|
|
107
107
|
streamlit_logger.setLevel(streamlit_level.upper())
|
|
108
|
-
`);let
|
|
108
|
+
`);let ge=(S?.["logger.level"]??"INFO").toString(),fe=S?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(o.globals.get("setup_loggers")(ge,fe),console.debug("Set the loggers"),s("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await o.runPythonAsync(`
|
|
109
109
|
import streamlit
|
|
110
110
|
|
|
111
111
|
def is_cacheable_msg(msg):
|
|
@@ -127,19 +127,15 @@ def wrap_app_session_on_scriptrunner_event(original_method):
|
|
|
127
127
|
return wrapped
|
|
128
128
|
|
|
129
129
|
AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
|
|
130
|
-
`),console.debug("Set up the IndexedDB filesystem synchronizer")}return s("Booting up the Streamlit server."),console.debug("
|
|
130
|
+
`),console.debug("Set up the IndexedDB filesystem synchronizer")}return s("Booting up the Streamlit server."),console.debug("Setting up the Streamlit configuration"),D.__streamlitFlagOptions__={"browser.gatherUsageStats":!1,...S,"runner.fastReruns":!1},await o.runPythonAsync(`
|
|
131
131
|
from stlite_lib.bootstrap import load_config_options, prepare
|
|
132
|
-
from stlite_lib.server import Server
|
|
133
132
|
from js import __streamlitFlagOptions__
|
|
134
133
|
|
|
135
134
|
flag_options = __streamlitFlagOptions__.to_py()
|
|
136
135
|
load_config_options(flag_options)
|
|
137
136
|
|
|
138
|
-
main_script_path = "${
|
|
137
|
+
main_script_path = "${w}"
|
|
139
138
|
args = []
|
|
140
139
|
|
|
141
140
|
prepare(main_script_path, args)
|
|
142
|
-
|
|
143
|
-
server = Server(main_script_path)
|
|
144
|
-
server.start()
|
|
145
|
-
`),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),i=o.globals.get("server").copy(),console.debug("Set up the HTTP server"),e({type:"event:loaded"}),l}let d=a().catch(g=>{throw e({type:"event:error",data:{error:g}}),g}),f=async g=>{let l=g.data;if(l.type==="initData"){n.resolve(l.data);return}let{moduleAutoLoad:k}=await d,_=g.ports[0];try{switch(l.type){case"websocket:connect":{console.debug("websocket:connect",l.data);let{path:c}=l.data;i.start_websocket(c,(p,y)=>{if(y){let h=p,w=h.getBuffer("u8");h.destroy();let S=new Uint8ClampedArray(w.data.buffer,w.data.byteOffset,w.data.byteLength);e({type:"websocket:message",data:{payload:new Uint8Array(S)}})}else e({type:"websocket:message",data:{payload:p}})}),_.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",l.data);let{payload:c}=l.data;i.receive_websocket_from_js(c);break}case"http:request":{console.debug("http:request",l.data);let{request:c}=l.data,p=(y,h,w)=>{let S=new Map(h.toJs()),R=w.toJs();console.debug({statusCode:y,headers:S,body:R});let O={type:"http:response",data:{response:{statusCode:y,headers:S,body:R}}};_.postMessage(O)};i.receive_http_from_js(c.method,decodeURIComponent(c.path),c.headers,c.body,p);break}case"file:write":{let{path:c,data:p,opts:y}=l.data;k&&typeof p=="string"&&c.endsWith(".py")&&(console.debug(`Auto install the requirements in ${c}`),ie(o,e,[p])),console.debug(`Write a file "${c}"`),H(o,c,p,y),_.postMessage({type:"reply"});break}case"file:rename":{let{oldPath:c,newPath:p}=l.data;console.debug(`Rename "${c}" to ${p}`),re(o,c,p),_.postMessage({type:"reply"});break}case"file:unlink":{let{path:c}=l.data;console.debug(`Remove "${c}`),o.FS.unlink(c),_.postMessage({type:"reply"});break}case"install":{let{requirements:c}=l.data,p=o.pyimport("micropip"),y=$(c);console.debug("Install the requirements:",y),await p.install.callKwargs(y,{keep_going:!0}).then(()=>{console.debug("Successfully installed"),_.postMessage({type:"reply"})})}}}catch(c){if(console.error(c),!(c instanceof Error))throw c;let p=new Error(c.message);p.name=c.name,p.stack=c.stack,_.postMessage({type:"reply",error:p})}};return e({type:"event:start"}),f}function de(){let r=process.env.NODEFS_MOUNTPOINTS;if(!r)return;let e;try{e=JSON.parse(r)}catch{console.error(`Failed to parse NODEFS_MOUNTPOINTS as JSON: ${r}`);return}if(typeof e!="object"){console.error(`NODEFS_MOUNTPOINTS is not an object: ${r}`);return}if(Array.isArray(e)){console.error(`NODEFS_MOUNTPOINTS is an array: ${r}`);return}if(Object.keys(e).some(t=>typeof t!="string")){console.error(`NODEFS_MOUNTPOINTS has non-string keys: ${r}`);return}if(Object.values(e).some(t=>typeof t!="string")){console.error(`NODEFS_MOUNTPOINTS has non-string values: ${r}`);return}return e}var He=r=>{console.debug("[worker thread] postMessage from worker",r),W.parentPort?.postMessage(r)},$e=le(process.env.PYODIDE_URL,He,{nodefsMountpoints:de()});W.parentPort?.on("message",({data:r,port:e})=>{console.debug("[worker thread] parentPort.onMessage",{data:r,port:e}),$e({data:r,ports:[e]})});
|
|
141
|
+
`),console.debug("Set up the Streamlit configuration"),console.debug("Booting up the Streamlit server"),i=o.pyimport("stlite_lib.server.Server")(w),i.start(),console.debug("Booted up the Streamlit server"),e({type:"event:loaded"}),l}let c=a().catch(f=>{throw e({type:"event:error",data:{error:f}}),f}),g=async f=>{let l=f.data;if(l.type==="initData"){n.resolve(l.data);return}let{moduleAutoLoad:w}=await c,_=f.ports[0];try{switch(l.type){case"reboot":{console.debug("Reboot the Streamlit server",l.data);let{entrypoint:d}=l.data;i.stop(),console.debug("Booting up the Streamlit server"),i=o.pyimport("stlite_lib.server.Server")(d),i.start(),console.debug("Booted up the Streamlit server"),_.postMessage({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",l.data);let{path:d}=l.data;i.start_websocket(d,(p,y)=>{if(y){let h=p,k=h.getBuffer("u8");h.destroy();let S=new Uint8ClampedArray(k.data.buffer,k.data.byteOffset,k.data.byteLength);e({type:"websocket:message",data:{payload:new Uint8Array(S)}})}else e({type:"websocket:message",data:{payload:p}})}),_.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",l.data);let{payload:d}=l.data;i.receive_websocket_from_js(d);break}case"http:request":{console.debug("http:request",l.data);let{request:d}=l.data,p=(y,h,k)=>{let S=new Map(h.toJs()),R=k.toJs();console.debug({statusCode:y,headers:S,body:R});let O={type:"http:response",data:{response:{statusCode:y,headers:S,body:R}}};_.postMessage(O)};i.receive_http_from_js(d.method,decodeURIComponent(d.path),d.headers,d.body,p);break}case"file:write":{let{path:d,data:p,opts:y}=l.data;w&&typeof p=="string"&&d.endsWith(".py")&&(console.debug(`Auto install the requirements in ${d}`),ie(o,e,[p])),console.debug(`Write a file "${d}"`),$(o,d,p,y),_.postMessage({type:"reply"});break}case"file:rename":{let{oldPath:d,newPath:p}=l.data;console.debug(`Rename "${d}" to ${p}`),re(o,d,p),_.postMessage({type:"reply"});break}case"file:unlink":{let{path:d}=l.data;console.debug(`Remove "${d}`),o.FS.unlink(d),_.postMessage({type:"reply"});break}case"install":{let{requirements:d}=l.data,p=o.pyimport("micropip"),y=j(d);console.debug("Install the requirements:",y),await p.install.callKwargs(y,{keep_going:!0}).then(()=>{console.debug("Successfully installed"),_.postMessage({type:"reply"})})}}}catch(d){if(console.error(d),!(d instanceof Error))throw d;let p=new Error(d.message);p.name=d.name,p.stack=d.stack,_.postMessage({type:"reply",error:p})}};return e({type:"event:start"}),g}function de(){let r=process.env.NODEFS_MOUNTPOINTS;if(!r)return;let e;try{e=JSON.parse(r)}catch{console.error(`Failed to parse NODEFS_MOUNTPOINTS as JSON: ${r}`);return}if(typeof e!="object"){console.error(`NODEFS_MOUNTPOINTS is not an object: ${r}`);return}if(Array.isArray(e)){console.error(`NODEFS_MOUNTPOINTS is an array: ${r}`);return}if(Object.keys(e).some(t=>typeof t!="string")){console.error(`NODEFS_MOUNTPOINTS has non-string keys: ${r}`);return}if(Object.values(e).some(t=>typeof t!="string")){console.error(`NODEFS_MOUNTPOINTS has non-string values: ${r}`);return}return e}var $e=r=>{console.debug("[worker thread] postMessage from worker",r),H.parentPort?.postMessage(r)},je=le(process.env.PYODIDE_URL,$e,{nodefsMountpoints:de()});H.parentPort?.on("message",({data:r,port:e})=>{console.debug("[worker thread] parentPort.onMessage",{data:r,port:e}),je({data:r,ports:[e]})});
|
package/build/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><script defer="defer" src="/static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><script defer="defer" src="/static/js/main.be274c69.js"></script><link href="/static/css/main.fc8432ac.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|