@stlite/desktop 0.73.0 → 0.74.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 +8 -8
- package/build/electron/worker.js +14 -14
- package/build/index.html +1 -1
- package/build/static/js/2137.1a12e359.chunk.js +1 -0
- package/build/static/js/{4041.b5a10716.chunk.js → 4041.19c1ca53.chunk.js} +1 -1
- package/build/static/js/{5563.baae3e3b.chunk.js → 5563.94a19736.chunk.js} +1 -1
- package/build/static/js/{6945.df6edd7e.chunk.js → 6945.8aeefc8b.chunk.js} +1 -1
- package/build/static/js/{7683.3e5291f1.chunk.js → 7683.4b56186d.chunk.js} +1 -1
- package/build/static/js/{main.006fb699.js → main.c19f6f58.js} +3 -3
- package/package.json +4 -4
- package/wheels/stlite_lib-0.1.0-py3-none-any.whl +0 -0
- package/wheels/streamlit-1.40.1-cp312-none-any.whl +0 -0
- package/build/static/js/3612.ffb1fe1f.chunk.js +0 -1
- /package/build/static/js/{main.006fb699.js.LICENSE.txt → main.c19f6f58.js.LICENSE.txt} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/static/css/main.c5766a64.css",
|
|
4
|
-
"main.js": "/static/js/main.
|
|
5
|
-
"static/js/
|
|
4
|
+
"main.js": "/static/js/main.c19f6f58.js",
|
|
5
|
+
"static/js/2137.1a12e359.chunk.js": "/static/js/2137.1a12e359.chunk.js",
|
|
6
6
|
"static/js/6573.144dfa36.chunk.js": "/static/js/6573.144dfa36.chunk.js",
|
|
7
7
|
"static/js/5510.80a638ac.chunk.js": "/static/js/5510.80a638ac.chunk.js",
|
|
8
|
-
"static/js/4041.
|
|
8
|
+
"static/js/4041.19c1ca53.chunk.js": "/static/js/4041.19c1ca53.chunk.js",
|
|
9
9
|
"static/js/5314.39021199.chunk.js": "/static/js/5314.39021199.chunk.js",
|
|
10
10
|
"static/js/4230.7c65808e.chunk.js": "/static/js/4230.7c65808e.chunk.js",
|
|
11
11
|
"static/css/9877.da3ff442.chunk.css": "/static/css/9877.da3ff442.chunk.css",
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"static/js/7234.0980b881.chunk.js": "/static/js/7234.0980b881.chunk.js",
|
|
17
17
|
"static/js/6000.1159b8a4.chunk.js": "/static/js/6000.1159b8a4.chunk.js",
|
|
18
18
|
"static/js/3494.e2c0ae04.chunk.js": "/static/js/3494.e2c0ae04.chunk.js",
|
|
19
|
-
"static/js/7683.
|
|
19
|
+
"static/js/7683.4b56186d.chunk.js": "/static/js/7683.4b56186d.chunk.js",
|
|
20
20
|
"static/js/7755.8c689d54.chunk.js": "/static/js/7755.8c689d54.chunk.js",
|
|
21
21
|
"static/js/1809.c32c00e6.chunk.js": "/static/js/1809.c32c00e6.chunk.js",
|
|
22
22
|
"static/js/9182.d7d66fd1.chunk.js": "/static/js/9182.d7d66fd1.chunk.js",
|
|
23
|
-
"static/js/5563.
|
|
23
|
+
"static/js/5563.94a19736.chunk.js": "/static/js/5563.94a19736.chunk.js",
|
|
24
24
|
"static/js/6176.91adb590.chunk.js": "/static/js/6176.91adb590.chunk.js",
|
|
25
25
|
"static/js/2000.d1c979cc.chunk.js": "/static/js/2000.d1c979cc.chunk.js",
|
|
26
26
|
"static/js/7186.df13463b.chunk.js": "/static/js/7186.df13463b.chunk.js",
|
|
27
|
-
"static/js/6945.
|
|
27
|
+
"static/js/6945.8aeefc8b.chunk.js": "/static/js/6945.8aeefc8b.chunk.js",
|
|
28
28
|
"static/js/7956.c8053817.chunk.js": "/static/js/7956.c8053817.chunk.js",
|
|
29
29
|
"static/js/3890.4f85e8b8.chunk.js": "/static/js/3890.4f85e8b8.chunk.js",
|
|
30
30
|
"static/js/4684.97415310.chunk.js": "/static/js/4684.97415310.chunk.js",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"static/media/KaTeX_AMS-Regular.woff2": "/static/media/KaTeX_AMS-Regular.73ea273a72f4aca30ca5.woff2",
|
|
106
106
|
"static/media/KaTeX_Typewriter-Regular.ttf": "/static/media/KaTeX_Typewriter-Regular.c5c02d763c89380dcb4e.ttf",
|
|
107
107
|
"static/media/KaTeX_Main-Regular.woff2": "/static/media/KaTeX_Main-Regular.f650f111a3b890d116f1.woff2",
|
|
108
|
-
"static/media/KaTeX_Main-Bold.woff2": "/static/media/KaTeX_Main-Bold.39890742bc957b368704.woff2",
|
|
109
108
|
"pypi/stlite_lib-0.1.0-py3-none-any.whl": "/pypi/stlite_lib-0.1.0-py3-none-any.whl",
|
|
109
|
+
"static/media/KaTeX_Main-Bold.woff2": "/static/media/KaTeX_Main-Bold.39890742bc957b368704.woff2",
|
|
110
110
|
"static/media/KaTeX_SansSerif-Bold.ttf": "/static/media/KaTeX_SansSerif-Bold.5b49f4993ae22d7975b4.ttf",
|
|
111
111
|
"static/media/KaTeX_SansSerif-Italic.ttf": "/static/media/KaTeX_SansSerif-Italic.b257a18c016f37ee4543.ttf",
|
|
112
112
|
"static/media/KaTeX_Main-Italic.woff": "/static/media/KaTeX_Main-Italic.fd947498bc16392e76c2.woff",
|
|
@@ -169,6 +169,6 @@
|
|
|
169
169
|
},
|
|
170
170
|
"entrypoints": [
|
|
171
171
|
"static/css/main.c5766a64.css",
|
|
172
|
-
"static/js/main.
|
|
172
|
+
"static/js/main.c19f6f58.js"
|
|
173
173
|
]
|
|
174
174
|
}
|
package/build/electron/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).filter(e=>!e.startsWith("#")).map(e=>e.replace(
|
|
1
|
+
var ve=Object.create;var X=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty;var E=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ke=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of be(e))!we.call(r,n)&&n!==t&&X(r,n,{get:()=>e[n],enumerable:!(o=Pe(e,n))||o.enumerable});return r};var I=(r,e,t)=>(t=r!=null?ve(Se(r)):{},ke(e||!r||!r.__esModule?X(t,"default",{value:r,enumerable:!0}):t,r));var G=E(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.validateRequirements=void 0;var Ae="[",Re="(<=>!~",Fe=";",Me="@",Oe=new RegExp(`[${Ae+Re+Fe+Me}]`);function Le(r){return r.split(Oe)[0].trim()}function Ee(r){return r.forEach(t=>{let o;try{o=new URL(t)}catch{return}if(o.protocol==="emfs:"||o.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${t})`)}),r.filter(t=>Le(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)}D.validateRequirements=Ee});var Q=E(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.parseRequirementsTxt=void 0;var Ie=/\s#.*$/;function Ce(r){return r.split(`
|
|
2
|
+
`).filter(e=>!e.startsWith("#")).map(e=>e.replace(Ie,"")).map(e=>e.trim()).filter(e=>e!=="")}U.parseRequirementsTxt=Ce});var Y=E(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.PromiseDelegate=void 0;var $=class{promise;resolveInternal;rejectInternal;constructor(){this.promise=new Promise((e,t)=>{this.resolveInternal=e,this.rejectInternal=t})}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}};x.PromiseDelegate=$});var Z=E(k=>{"use strict";var Te=k&&k.__createBinding||(Object.create?function(r,e,t,o){o===void 0&&(o=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,o,n)}:function(r,e,t,o){o===void 0&&(o=t),r[o]=e[t]}),q=k&&k.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Te(e,r,t)};Object.defineProperty(k,"__esModule",{value:!0});q(G(),k);q(Q(),k);q(Y(),k)});var re=E((Ye,te)=>{"use strict";function b(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function ee(r,e){for(var t="",o=0,n=-1,s=0,i,a=0;a<=r.length;++a){if(a<r.length)i=r.charCodeAt(a);else{if(i===47)break;i=47}if(i===47){if(!(n===a-1||s===1))if(n!==a-1&&s===2){if(t.length<2||o!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",o=0):(t=t.slice(0,l),o=t.length-1-t.lastIndexOf("/")),n=a,s=0;continue}}else if(t.length===2||t.length===1){t="",o=0,n=a,s=0;continue}}e&&(t.length>0?t+="/..":t="..",o=2)}else t.length>0?t+="/"+r.slice(n+1,a):t=r.slice(n+1,a),o=a-n-1;n=a,s=0}else i===46&&s!==-1?++s:s=-1}return t}function Ne(r,e){var t=e.dir||e.root,o=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+o:t+r+o:o}var M={resolve:function(){for(var e="",t=!1,o,n=arguments.length-1;n>=-1&&!t;n--){var s;n>=0?s=arguments[n]:(o===void 0&&(o=process.cwd()),s=o),b(s),s.length!==0&&(e=s+"/"+e,t=s.charCodeAt(0)===47)}return e=ee(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(b(e),e.length===0)return".";var t=e.charCodeAt(0)===47,o=e.charCodeAt(e.length-1)===47;return e=ee(e,!t),e.length===0&&!t&&(e="."),e.length>0&&o&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return b(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 o=arguments[t];b(o),o.length>0&&(e===void 0?e=o:e+="/"+o)}return e===void 0?".":M.normalize(e)},relative:function(e,t){if(b(e),b(t),e===t||(e=M.resolve(e),t=M.resolve(t),e===t))return"";for(var o=1;o<e.length&&e.charCodeAt(o)===47;++o);for(var n=e.length,s=n-o,i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var a=t.length,l=a-i,_=s<l?s:l,g=-1,d=0;d<=_;++d){if(d===_){if(l>_){if(t.charCodeAt(i+d)===47)return t.slice(i+d+1);if(d===0)return t.slice(i+d)}else s>_&&(e.charCodeAt(o+d)===47?g=d:d===0&&(g=0));break}var m=e.charCodeAt(o+d),O=t.charCodeAt(i+d);if(m!==O)break;m===47&&(g=d)}var v="";for(d=o+g+1;d<=n;++d)(d===n||e.charCodeAt(d)===47)&&(v.length===0?v+="..":v+="/..");return v.length>0?v+t.slice(i+g):(i+=g,t.charCodeAt(i)===47&&++i,t.slice(i))},_makeLong:function(e){return e},dirname:function(e){if(b(e),e.length===0)return".";for(var t=e.charCodeAt(0),o=t===47,n=-1,s=!0,i=e.length-1;i>=1;--i)if(t=e.charCodeAt(i),t===47){if(!s){n=i;break}}else s=!1;return n===-1?o?"/":".":o&&n===1?"//":e.slice(0,n)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');b(e);var o=0,n=-1,s=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(i=e.length-1;i>=0;--i){var _=e.charCodeAt(i);if(_===47){if(!s){o=i+1;break}}else l===-1&&(s=!1,l=i+1),a>=0&&(_===t.charCodeAt(a)?--a===-1&&(n=i):(a=-1,n=l))}return o===n?n=l:n===-1&&(n=e.length),e.slice(o,n)}else{for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!s){o=i+1;break}}else n===-1&&(s=!1,n=i+1);return n===-1?"":e.slice(o,n)}},extname:function(e){b(e);for(var t=-1,o=0,n=-1,s=!0,i=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(l===47){if(!s){o=a+1;break}continue}n===-1&&(s=!1,n=a+1),l===46?t===-1?t=a:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||n===-1||i===0||i===1&&t===n-1&&t===o+1?"":e.slice(t,n)},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 Ne("/",e)},parse:function(e){b(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var o=e.charCodeAt(0),n=o===47,s;n?(t.root="/",s=1):s=0;for(var i=-1,a=0,l=-1,_=!0,g=e.length-1,d=0;g>=s;--g){if(o=e.charCodeAt(g),o===47){if(!_){a=g+1;break}continue}l===-1&&(_=!1,l=g+1),o===46?i===-1?i=g:d!==1&&(d=1):i!==-1&&(d=-1)}return i===-1||l===-1||d===0||d===1&&i===l-1&&i===a+1?l!==-1&&(a===0&&n?t.base=t.name=e.slice(1,l):t.base=t.name=e.slice(a,l)):(a===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,l)):(t.name=e.slice(a,i),t.base=e.slice(a,l)),t.ext=e.slice(i,l)),a>0?t.dir=e.slice(0,a-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};M.posix=M;te.exports=M});var z=require("node:worker_threads");var ce=I(Z());var C=I(re()),oe="/home/pyodide",j=r=>`${oe}/${r}`,R=(r,e)=>r==null?C.default.resolve(oe,e):C.default.resolve(j(r),e);function se(r,e){let t=C.default.normalize(e),n=C.default.dirname(t).split("/"),s=[];for(let i of n){s.push(i);let a=s.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(l){throw console.error(`Failed to create a directory "${a}"`),l}}}function H(r,e,t,o){se(r,e),r.FS.writeFile(e,t,o)}function ne(r,e,t){se(r,t),r.FS.rename(e,t)}var De="[",Ue="(<=>!~",xe=";",We="@",$e=new RegExp(`[${De+Ue+xe+We}]`);function qe(r){return r.split($e)[0].trim()}function B(r){return r.forEach(t=>{let o;try{o=new URL(t)}catch{return}if(o.protocol==="emfs:"||o.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${t})`)}),r.filter(t=>qe(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 je(r){let e=typeof process<"u"&&process.versions?.node,t;e?t=(await import("node:path")).sep:t="/";let o=r.slice(0,r.lastIndexOf(t)+1);if(r.endsWith(".mjs")){if(e){let n=await import("node:path"),s=await import("node:url");!r.includes("://")&&n.isAbsolute(r)&&(r=s.pathToFileURL(r).href)}return{scriptURL:r,pyodideIndexURL:o,isESModule:!0}}else return{scriptURL:r,pyodideIndexURL:o,isESModule:!1}}async function ie(r,e){let{scriptURL:t,pyodideIndexURL:o,isESModule:n}=await je(r),s;return n?s=(await import(t)).loadPyodide:(importScripts(t),s=self.loadPyodide),s({...e,indexURL:o})}function ae(r){r.runPython(`
|
|
3
3
|
import micropip
|
|
4
4
|
micropip.add_mock_package(
|
|
5
5
|
"pyarrow", "0.0.1",
|
|
@@ -25,17 +25,17 @@ class ChunkedArray:
|
|
|
25
25
|
"""
|
|
26
26
|
}
|
|
27
27
|
)
|
|
28
|
-
`)}async function
|
|
28
|
+
`)}async function le(r,e,t){let o=r.pyimport("pyodide"),n=g=>o.code.find_imports(g).toJs(),s=t.map(g=>n(g)),l=Array.from(new Set(s.flat())).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(l.length===0)return;let _=new MessageChannel;e({type:"event:moduleAutoLoad",data:{packagesToLoad:l}},_.port2);try{let g=await r.loadPackage(l);_.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:g}}),_.port1.close();return}catch(g){throw _.port1.postMessage({type:"moduleAutoLoad:error",error:g}),_.port1.close(),g}}var T=global;function de(r,e,t){let o=le(r,e,t);T.__moduleAutoLoadPromise__=o,r.runPythonAsync(`
|
|
29
29
|
from streamlit.runtime.scriptrunner import script_runner
|
|
30
30
|
from js import __moduleAutoLoadPromise__
|
|
31
31
|
|
|
32
32
|
script_runner.moduleAutoLoadPromise = __moduleAutoLoadPromise__
|
|
33
|
-
`)}function
|
|
33
|
+
`)}var W=null;function ue(r,e,t,o){function n(d){e({type:"event:progress",data:{message:d}})}let s,i,a=new ce.PromiseDelegate;async function l(){let d=await a.promise,m={...t,...d};console.debug("Initial data",m);let{entrypoint:O,files:v,archives:P,requirements:c,prebuiltPackageNames:f,wheels:y,pyodideUrl:h=r,streamlitConfig:S,idbfsMountpoints:A,nodefsMountpoints:L,moduleAutoLoad:fe}=m,N=B(c);W?(n("Pyodide is already loaded."),console.debug("Pyodide is already loaded."),s=await W):(n("Loading Pyodide."),console.debug("Loading Pyodide."),W=ie(h,{stdout:console.log,stderr:console.error}),s=await W,y&&(N.unshift(y.streamlit),N.unshift(y.stliteLib)),console.debug("Loaded Pyodide"));let J=!1;A&&(J=!0,A.forEach(u=>{s.FS.mkdir(u),s.FS.mount(s.FS.filesystems.IDBFS,{},u)}),await new Promise((u,p)=>{s.FS.syncfs(!0,w=>{w?p(w):u()})})),L&&Object.entries(L).forEach(([u,p])=>{s.FS.mkdir(u),s.FS.mount(s.FS.filesystems.NODEFS,{root:p},u)}),n("Mounting files.");let K=[];await Promise.all(Object.keys(v).map(async u=>{let p=v[u];u=R(o,u);let w;"url"in p?(console.debug(`Fetch a file from ${p.url}`),w=await fetch(p.url).then(F=>F.arrayBuffer()).then(F=>new Uint8Array(F))):w=p.data,console.debug(`Write a file "${u}"`),H(s,u,w,v.opts),u.endsWith(".py")&&K.push(u)})),n("Unpacking archives."),await Promise.all(P.map(async u=>{let p;"url"in u?(console.debug(`Fetch an archive from ${u.url}`),p=await fetch(u.url).then(he=>he.arrayBuffer())):p=u.buffer;let{format:w,options:F}=u;console.debug("Unpack an archive",{format:w,options:F}),s.unpackArchive(p,w,F)})),await s.loadPackage("micropip");let me=s.pyimport("micropip");if(n("Mocking some packages."),console.debug("Mock pyarrow"),ae(s),console.debug("Mocked pyarrow"),n("Installing packages."),console.debug("Installing the prebuilt packages:",f),await s.loadPackage(f),console.debug("Installed the prebuilt packages"),console.debug("Installing the requirements:",N),await me.install.callKwargs(N,{keep_going:!0}),console.debug("Installed the requirements"),fe){let u=K.map(p=>s.FS.readFile(p,{encoding:"utf8"}));de(s,e,u)}await s.runPythonAsync(`
|
|
34
34
|
import importlib
|
|
35
35
|
importlib.invalidate_caches()
|
|
36
|
-
`),
|
|
36
|
+
`),n("Loading streamlit package."),console.debug("Loading the Streamlit package"),await s.runPythonAsync(`
|
|
37
37
|
import streamlit.runtime
|
|
38
|
-
`),console.debug("Loaded the Streamlit package"),
|
|
38
|
+
`),console.debug("Loaded the Streamlit package"),n("Setting up the loggers."),console.debug("Setting the loggers"),await s.runPythonAsync(`
|
|
39
39
|
import logging
|
|
40
40
|
import streamlit.logger
|
|
41
41
|
|
|
@@ -53,7 +53,7 @@ for name in streamlit.logger._loggers.keys():
|
|
|
53
53
|
logger.setLevel(logging.NOTSET)
|
|
54
54
|
|
|
55
55
|
streamlit.logger._loggers = {}
|
|
56
|
-
`);let
|
|
56
|
+
`);let pe=(u,p)=>{u>=40?console.error(p):u>=30?console.warn(p):u>=20?console.info(p):console.debug(p)};T.__logCallback__=pe,await s.runPythonAsync(`
|
|
57
57
|
def setup_loggers(streamlit_level, streamlit_message_format):
|
|
58
58
|
from js import __logCallback__
|
|
59
59
|
|
|
@@ -82,14 +82,14 @@ def setup_loggers(streamlit_level, streamlit_message_format):
|
|
|
82
82
|
streamlit_handler.setFormatter(streamlit_formatter)
|
|
83
83
|
streamlit_logger.addHandler(streamlit_handler)
|
|
84
84
|
streamlit_logger.setLevel(streamlit_level.upper())
|
|
85
|
-
`);let
|
|
85
|
+
`);let _e=(S?.["logger.level"]??"INFO").toString(),ye=S?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(s.globals.get("setup_loggers")(_e,ye),console.debug("Set the loggers"),n("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await s.runPythonAsync(`
|
|
86
86
|
import streamlit
|
|
87
87
|
|
|
88
88
|
def is_cacheable_msg(msg):
|
|
89
89
|
return False
|
|
90
90
|
|
|
91
91
|
streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
|
|
92
|
-
`),console.debug("Mocked some Streamlit functions"),
|
|
92
|
+
`),console.debug("Mocked some Streamlit functions"),J){n("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let u=!1;T.__scriptFinishedCallback__=()=>{console.debug("The script has finished. Syncing the filesystem."),u||(u=!0,s.FS.syncfs(!1,p=>{u=!1,p&&console.error(p)}))},await s.runPythonAsync(`
|
|
93
93
|
from streamlit.runtime.app_session import AppSession
|
|
94
94
|
from streamlit.runtime.scriptrunner import ScriptRunnerEvent
|
|
95
95
|
from js import __scriptFinishedCallback__
|
|
@@ -104,15 +104,15 @@ def wrap_app_session_on_scriptrunner_event(original_method):
|
|
|
104
104
|
return wrapped
|
|
105
105
|
|
|
106
106
|
AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
|
|
107
|
-
`),console.debug("Set up the IndexedDB filesystem synchronizer")}return
|
|
107
|
+
`),console.debug("Set up the IndexedDB filesystem synchronizer")}let V=R(o,O);return n("Booting up the Streamlit server."),console.debug("Setting up the Streamlit configuration"),T.__sharedWorkerMode__=o!=null,T.__streamlitFlagOptions__={"browser.gatherUsageStats":!1,...S,"runner.fastReruns":!1},await s.runPythonAsync(`
|
|
108
108
|
from stlite_lib.bootstrap import load_config_options, prepare
|
|
109
|
-
from js import __streamlitFlagOptions__
|
|
109
|
+
from js import __sharedWorkerMode__, __streamlitFlagOptions__
|
|
110
110
|
|
|
111
111
|
flag_options = __streamlitFlagOptions__.to_py()
|
|
112
|
-
load_config_options(flag_options)
|
|
112
|
+
load_config_options(flag_options, __sharedWorkerMode__)
|
|
113
113
|
|
|
114
|
-
main_script_path = "${
|
|
114
|
+
main_script_path = "${V}"
|
|
115
115
|
args = []
|
|
116
116
|
|
|
117
117
|
prepare(main_script_path, args)
|
|
118
|
-
`),console.debug("Set up the Streamlit configuration"),console.debug("Booting up the Streamlit server"),i=
|
|
118
|
+
`),console.debug("Set up the Streamlit configuration"),console.debug("Booting up the Streamlit server"),i=s.pyimport("stlite_lib.server.Server")(V,o?j(o):null),await i.start(),console.debug("Booted up the Streamlit server"),e({type:"event:loaded"}),m}let _=l().catch(d=>{throw e({type:"event:error",data:{error:d}}),d}),g=async d=>{let m=d.data;if(m.type==="initData"){a.resolve(m.data);return}let{moduleAutoLoad:O}=await _,v=d.ports[0];function P(c){v.postMessage(c)}try{switch(m.type){case"reboot":{console.debug("Reboot the Streamlit server",m.data);let{entrypoint:c}=m.data;i.stop(),console.debug("Booting up the Streamlit server"),i=s.pyimport("stlite_lib.server.Server")(c),i.start(),console.debug("Booted up the Streamlit server"),P({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",m.data);let{path:c}=m.data;i.start_websocket(c,(f,y)=>{if(y){let h=f,S=h.getBuffer("u8");h.destroy();let A=new Uint8ClampedArray(S.data.buffer,S.data.byteOffset,S.data.byteLength);e({type:"websocket:message",data:{payload:new Uint8Array(A)}})}else e({type:"websocket:message",data:{payload:f}})}),P({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",m.data);let{payload:c}=m.data;i.receive_websocket_from_js(c);break}case"http:request":{console.debug("http:request",m.data);let{request:c}=m.data,f=(y,h,S)=>{let A=new Map(h.toJs()),L=S.toJs();console.debug({statusCode:y,headers:A,body:L}),P({type:"http:response",data:{response:{statusCode:y,headers:A,body:L}}})};i.receive_http_from_js(c.method,decodeURIComponent(c.path),c.headers,c.body,f);break}case"file:write":{let{path:c,data:f,opts:y}=m.data,h=R(o,c);O&&typeof f=="string"&&h.endsWith(".py")&&(console.debug(`Auto install the requirements in ${h}`),de(s,e,[f])),console.debug(`Write a file "${h}"`),H(s,h,f,y),P({type:"reply"});break}case"file:rename":{let{oldPath:c,newPath:f}=m.data,y=R(o,c),h=R(o,f);console.debug(`Rename "${y}" to ${h}`),ne(s,y,h),P({type:"reply"});break}case"file:unlink":{let{path:c}=m.data,f=R(o,c);console.debug(`Remove "${f}`),s.FS.unlink(f),P({type:"reply"});break}case"file:read":{let{path:c,opts:f}=m.data;console.debug(`Read "${c}"`);let y=s.FS.readFile(c,f);P({type:"reply:file:read",data:{content:y}});break}case"install":{let{requirements:c}=m.data,f=s.pyimport("micropip"),y=B(c);console.debug("Install the requirements:",y),await f.install.callKwargs(y,{keep_going:!0}).then(()=>{console.debug("Successfully installed"),P({type:"reply"})})}}}catch(c){if(console.error(c),!(c instanceof Error))throw c;let f=new Error(c.message);f.name=c.name,f.stack=c.stack,P({type:"reply",error:f})}};return e({type:"event:start"}),g}function ge(){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),z.parentPort?.postMessage(r)},Be=ue(process.env.PYODIDE_URL,He,{nodefsMountpoints:ge()});z.parentPort?.on("message",({data:r,port:e})=>{console.debug("[worker thread] parentPort.onMessage",{data:r,port:e}),Be({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><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'wasm-unsafe-eval' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src 'self' blob:; script-src-elem 'self' 'unsafe-inline' https:; style-src-elem 'self' 'unsafe-inline' https:; font-src 'self' data: https:; connect-src https://data.streamlit.io/ https://*.mapbox.com/ 'self' https: data:; img-src https: blob: data: file:; media-src https: blob:; frame-src https:"><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><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'wasm-unsafe-eval' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src 'self' blob:; script-src-elem 'self' 'unsafe-inline' https:; style-src-elem 'self' 'unsafe-inline' https:; font-src 'self' data: https:; connect-src https://data.streamlit.io/ https://*.mapbox.com/ 'self' https: data:; img-src https: blob: data: file:; media-src https: blob:; frame-src https:"><script defer="defer" src="/static/js/main.c19f6f58.js"></script><link href="/static/css/main.c5766a64.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var e={87531: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,i=0;i<=e.length;++i){if(i<e.length)r=e.charCodeAt(i);else{if(47===r)break;r=47}if(47===r){if(s===i-1||1===a);else if(s!==i-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 l=n.lastIndexOf("/");if(l!==n.length-1){-1===l?(n="",o=0):o=(n=n.slice(0,l)).length-1-n.lastIndexOf("/"),s=i,a=0;continue}}else if(2===n.length||1===n.length){n="",o=0,s=i,a=0;continue}t&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+e.slice(s+1,i):n=e.slice(s+1,i),o=i-s-1;s=i,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,i=1;i<r.length&&47===r.charCodeAt(i);++i);for(var l=r.length-i,c=a<l?a:l,d=-1,g=0;g<=c;++g){if(g===c){if(l>c){if(47===r.charCodeAt(i+g))return r.slice(i+g+1);if(0===g)return r.slice(i+g)}else a>c&&(47===e.charCodeAt(o+g)?d=g:0===g&&(d=0));break}var p=e.charCodeAt(o+g);if(p!==r.charCodeAt(i+g))break;47===p&&(d=g)}var u="";for(g=o+d+1;g<=s;++g)g!==s&&47!==e.charCodeAt(g)||(0===u.length?u+="..":u+="/..");return u.length>0?u+r.slice(i+d):(i+=d,47===r.charCodeAt(i)&&++i,r.slice(i))},_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 i=r.length-1,l=-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===l&&(a=!1,l=n+1),i>=0&&(c===r.charCodeAt(i)?-1===--i&&(s=n):(i=-1,s=l))}return o===s?s=l:-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,i=e.length-1;i>=0;--i){var l=e.charCodeAt(i);if(47!==l)-1===o&&(s=!1,o=i+1),46===l?-1===r?r=i:1!==a&&(a=1):-1!==r&&(a=-1);else if(!s){n=i+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,i=0,l=-1,c=!0,d=e.length-1,g=0;d>=n;--d)if(47!==(o=e.charCodeAt(d)))-1===l&&(c=!1,l=d+1),46===o?-1===a?a=d:1!==g&&(g=1):-1!==a&&(g=-1);else if(!c){i=d+1;break}return-1===a||-1===l||0===g||1===g&&a===l-1&&a===i+1?-1!==l&&(r.base=r.name=0===i&&s?e.slice(1,l):e.slice(i,l)):(0===i&&s?(r.name=e.slice(1,a),r.base=e.slice(1,l)):(r.name=e.slice(i,a),r.base=e.slice(i,l)),r.ext=e.slice(a,l)),i>0?r.dir=e.slice(0,i-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.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);new RegExp("[[(<=>!~;@]");class n{constructor(){this.promise=new Promise(((e,t)=>{this.resolveInternal=e,this.rejectInternal=t}))}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}}var o=r(87531),s=r.n(o);const a="/home/pyodide",i=e=>`${a}/${e}`,l=(e,t)=>null==e?s().resolve(a,t):s().resolve(i(e),t);function c(e,t){const r=s().normalize(t),n=s().dirname(r).split("/"),o=[];for(const s of n){o.push(s);const t=o.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 d(e,t,r,n){c(e,t),e.FS.writeFile(t,r,n)}const g=new RegExp("[[(<=>!~;@]");function p(e){e.forEach((e=>{let t;try{t=new URL(e)}catch{return}if("emfs:"===t.protocol||"file:"===t.protocol)throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${e})`)}));return e.filter((e=>{const t="streamlit"===function(e){return e.split(g)[0].trim()}(e);return!t||(console.warn(`Streamlit is specified in the requirements ("${e}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1)}))}async function u(e,t){const{scriptURL:r,pyodideIndexURL:n,isESModule:o}=await async function(e){var t;const r="undefined"!==typeof process&&(null===(t=process.versions)||void 0===t?void 0:t.node);let n;n=r?(await import("node:path")).sep:"/";const o=e.slice(0,e.lastIndexOf(n)+1);if(e.endsWith(".mjs")){if(r){const t=await import("node:path"),r=await import("node:url");!e.includes("://")&&t.isAbsolute(e)&&(e=r.pathToFileURL(e).href)}return{scriptURL:e,pyodideIndexURL:o,isESModule:!0}}return{scriptURL:e,pyodideIndexURL:o,isESModule:!1}}(e);let s;if(o){s=(await import(r)).loadPyodide}else importScripts(r),s=self.loadPyodide;return s({...t,indexURL:n})}async function m(e,t,r){const n=e.pyimport("pyodide"),o=r.map((e=>(e=>n.code.find_imports(e).toJs())(e))),s=Array.from(new Set(o.flat())).filter((t=>!e.runPython(`__import__('importlib').util.find_spec('${t}')`))).map((t=>e._api._import_name_to_package_name.get(t))).filter((e=>e));if(0===s.length)return;const a=new MessageChannel;t({type:"event:moduleAutoLoad",data:{packagesToLoad:s}},a.port2);try{const t=await e.loadPackage(s);return a.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:t}}),void a.port1.close()}catch(i){throw a.port1.postMessage({type:"moduleAutoLoad:error",error:i}),a.port1.close(),i}}const f=r.g;function h(e,t,r){const n=m(e,t,r);f.__moduleAutoLoadPromise__=n,e.runPythonAsync("\nfrom streamlit.runtime.scriptrunner import script_runner\nfrom js import __moduleAutoLoadPromise__\n\nscript_runner.moduleAutoLoadPromise = __moduleAutoLoadPromise__\n")}let _=null;function y(e,t,r,o){function s(e){t({type:"event:progress",data:{message:e}})}let a,g;const m=new n;const y=async function(){var n,c;const y=await m.promise,b={...r,...y};console.debug("Initial data",b);const{entrypoint:v,files:w,archives:k,requirements:S,prebuiltPackageNames:A,wheels:P,pyodideUrl:C=e,streamlitConfig:F,idbfsMountpoints:L,nodefsMountpoints:I,moduleAutoLoad:E}=b,R=p(S);_?(s("Pyodide is already loaded."),console.debug("Pyodide is already loaded."),a=await _):(s("Loading Pyodide."),console.debug("Loading Pyodide."),_=u(C,{stdout:console.log,stderr:console.error}),a=await _,P&&(R.unshift(P.streamlit),R.unshift(P.stliteLib)),console.debug("Loaded Pyodide"));let x=!1;L&&(x=!0,L.forEach((e=>{a.FS.mkdir(e),a.FS.mount(a.FS.filesystems.IDBFS,{},e)})),await new Promise(((e,t)=>{a.FS.syncfs(!0,(r=>{r?t(r):e()}))}))),I&&Object.entries(I).forEach((([e,t])=>{a.FS.mkdir(e),a.FS.mount(a.FS.filesystems.NODEFS,{root:t},e)})),s("Mounting files.");const M=[];await Promise.all(Object.keys(w).map((async e=>{const t=w[e];let r;e=l(o,e),"url"in t?(console.debug(`Fetch a file from ${t.url}`),r=await fetch(t.url).then((e=>e.arrayBuffer())).then((e=>new Uint8Array(e)))):r=t.data,console.debug(`Write a file "${e}"`),d(a,e,r,w.opts),e.endsWith(".py")&&M.push(e)}))),s("Unpacking archives."),await Promise.all(k.map((async e=>{let t;"url"in e?(console.debug(`Fetch an archive from ${e.url}`),t=await 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}),a.unpackArchive(t,r,n)}))),await a.loadPackage("micropip");const j=a.pyimport("micropip");if(s("Mocking some packages."),console.debug("Mock pyarrow"),function(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\nclass Array:\n def __init__(self, *args, **kwargs):\n raise NotImplementedError("stlite is not supporting PyArrow.Array")\n\n\nclass ChunkedArray:\n def __init__(self, *args, **kwargs):\n raise NotImplementedError("stlite is not supporting PyArrow.ChunkedArray")\n"""\n }\n)\n')}(a),console.debug("Mocked pyarrow"),s("Installing packages."),console.debug("Installing the prebuilt packages:",A),await a.loadPackage(A),console.debug("Installed the prebuilt packages"),console.debug("Installing the requirements:",R),await j.install.callKwargs(R,{keep_going:!0}),console.debug("Installed the requirements"),E){const e=M.map((e=>a.FS.readFile(e,{encoding:"utf8"})));h(a,t,e)}await a.runPythonAsync("\nimport importlib\nimportlib.invalidate_caches()\n"),s("Loading streamlit package."),console.debug("Loading the Streamlit package"),await a.runPythonAsync("\nimport streamlit.runtime\n "),console.debug("Loaded the Streamlit package"),s("Setting up the loggers."),console.debug("Setting the loggers"),await a.runPythonAsync('\nimport logging\nimport streamlit.logger\n\nstreamlit.logger.get_logger = logging.getLogger\nstreamlit.logger.setup_formatter = None\nstreamlit.logger.update_formatter = lambda *a, **k: None\nstreamlit.logger.set_log_level = lambda *a, **k: None\n\nfor 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\nstreamlit.logger._loggers = {}\n'),f.__logCallback__=(e,t)=>{e>=40?console.error(t):e>=30?console.warn(t):e>=20?console.info(t):console.debug(t)},await a.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 O=(null!==(n=null===F||void 0===F?void 0:F["logger.level"])&&void 0!==n?n:"INFO").toString(),U=null!==(c=null===F||void 0===F?void 0:F["logger.messageFormat"])&&void 0!==c?c:"%(asctime)s %(message)s";if(a.globals.get("setup_loggers")(O,U),console.debug("Set the loggers"),s("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await a.runPythonAsync("\nimport streamlit\n\ndef is_cacheable_msg(msg):\n return False\n\nstreamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg\n"),console.debug("Mocked some Streamlit functions"),x){s("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let e=!1;f.__scriptFinishedCallback__=()=>{console.debug("The script has finished. Syncing the filesystem."),e||(e=!0,a.FS.syncfs(!1,(t=>{e=!1,t&&console.error(t)})))},await a.runPythonAsync('\nfrom streamlit.runtime.app_session import AppSession\nfrom streamlit.runtime.scriptrunner import ScriptRunnerEvent\nfrom js import __scriptFinishedCallback__\n\ndef wrap_app_session_on_scriptrunner_event(original_method):\n def wrapped(self, *args, **kwargs):\n if "event" in kwargs:\n event = kwargs["event"]\n if event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS or event == ScriptRunnerEvent.SCRIPT_STOPPED_FOR_RERUN or event == ScriptRunnerEvent.SHUTDOWN:\n __scriptFinishedCallback__()\n return original_method(self, *args, **kwargs)\n return wrapped\n\nAppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)\n'),console.debug("Set up the IndexedDB filesystem synchronizer")}const T=l(o,v);s("Booting up the Streamlit server."),console.debug("Setting up the Streamlit configuration"),f.__sharedWorkerMode__=null!=o,f.__streamlitFlagOptions__={"browser.gatherUsageStats":!1,...F,"runner.fastReruns":!1},await a.runPythonAsync(`\nfrom stlite_lib.bootstrap import load_config_options, prepare\nfrom js import __sharedWorkerMode__, __streamlitFlagOptions__\n\nflag_options = __streamlitFlagOptions__.to_py()\nload_config_options(flag_options, __sharedWorkerMode__)\n\nmain_script_path = "${T}"\nargs = []\n\nprepare(main_script_path, args)\n`),console.debug("Set up the Streamlit configuration"),console.debug("Booting up the Streamlit server");const $=a.pyimport("stlite_lib.server.Server");return g=$(T,o?i(o):null),await g.start(),console.debug("Booted up the Streamlit server"),t({type:"event:loaded"}),b}().catch((e=>{throw t({type:"event:error",data:{error:e}}),e}));return t({type:"event:start"}),async e=>{const r=e.data;if("initData"===r.type)return void m.resolve(r.data);const{moduleAutoLoad:n}=await y,s=e.ports[0];function i(e){s.postMessage(e)}try{switch(r.type){case"reboot":{console.debug("Reboot the Streamlit server",r.data);const{entrypoint:e}=r.data;g.stop(),console.debug("Booting up the Streamlit server");const t=a.pyimport("stlite_lib.server.Server");g=t(e),g.start(),console.debug("Booted up the Streamlit server"),i({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",r.data);const{path:e}=r.data;g.start_websocket(e,((e,r)=>{if(r){const r=e,n=r.getBuffer("u8");r.destroy();const o=new Uint8ClampedArray(n.data.buffer,n.data.byteOffset,n.data.byteLength);t({type:"websocket:message",data:{payload:new Uint8Array(o)}})}else{t({type:"websocket:message",data:{payload:e}})}})),i({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",r.data);const{payload:e}=r.data;g.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 n=new Map(t.toJs()),o=r.toJs();console.debug({statusCode:e,headers:n,body:o}),i({type:"http:response",data:{response:{statusCode:e,headers:n,body:o}}})};g.receive_http_from_js(e.method,decodeURIComponent(e.path),e.headers,e.body,t);break}case"file:write":{const{path:e,data:s,opts:c}=r.data,g=l(o,e);n&&"string"===typeof s&&g.endsWith(".py")&&(console.debug(`Auto install the requirements in ${g}`),h(a,t,[s])),console.debug(`Write a file "${g}"`),d(a,g,s,c),i({type:"reply"});break}case"file:rename":{const{oldPath:e,newPath:t}=r.data,n=l(o,e),s=l(o,t);console.debug(`Rename "${n}" to ${s}`),function(e,t,r){c(e,r),e.FS.rename(t,r)}(a,n,s),i({type:"reply"});break}case"file:unlink":{const{path:e}=r.data,t=l(o,e);console.debug(`Remove "${t}`),a.FS.unlink(t),i({type:"reply"});break}case"file:read":{const{path:e,opts:t}=r.data;console.debug(`Read "${e}"`);i({type:"reply:file:read",data:{content:a.FS.readFile(e,t)}});break}case"install":{const{requirements:e}=r.data,t=a.pyimport("micropip"),n=p(e);console.debug("Install the requirements:",n),await t.install.callKwargs(n,{keep_going:!0}).then((()=>{console.debug("Successfully installed"),i({type:"reply"})}))}}}catch(u){if(console.error(u),!(u instanceof Error))throw u;const e=new Error(u.message);e.name=u.name,e.stack=u.stack,i({type:"reply",error:e})}}}const b="abcdefghijklmnopqrstuvwxyz";function v(e){let t="";for(let r=0;r<e;r++){const e=Math.floor(26*Math.random());t+=b[e]}return t}const w="https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js";if("postMessage"in self)self.onmessage=y(w,((e,t)=>self.postMessage(e,t?[t]:void 0)));else{const e=[];self.onconnect=t=>{let r;do{r=v(4)}while(e.includes(r));e.push(r),console.debug("SharedWorker mode.",{appId:r});const n=t.ports[0];n.onmessage=y(w,((e,t)=>n.postMessage(e,t?[t]:void 0)),void 0,r),n.start()}}})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[4041],{14041:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var n=r(50016),u=r(
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[4041],{14041:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var n=r(50016),u=r(14052),s=r(90076);function d({element:e,width:t,endpoints:r,elementMgr:d}){const i=(0,n.useRef)(null),{startTime:a,endTime:o,loop:c,autoplay:l}=e,m=(0,n.useMemo)((()=>{if(!e.id)return!0;const t=d.getElementState(e.id,"preventAutoplay");return t||d.setElementState(e.id,"preventAutoplay",!0),null!==t&&void 0!==t&&t}),[e.id,d]);(0,n.useEffect)((()=>{i.current&&(i.current.currentTime=a)}),[a]),(0,n.useEffect)((()=>{const t=i.current,r=()=>{t&&(t.currentTime=e.startTime)};return t&&t.addEventListener("loadedmetadata",r),()=>{t&&t.removeEventListener("loadedmetadata",r)}}),[e]),(0,n.useEffect)((()=>{const e=i.current;if(!e)return;let t=!1;const r=()=>{o>0&&e.currentTime>=o&&(c?(e.currentTime=a||0,e.play()):t||(t=!0,e.pause()))};return o>0&&e.addEventListener("timeupdate",r),()=>{e&&o>0&&e.removeEventListener("timeupdate",r)}}),[o,c,a]),(0,n.useEffect)((()=>{const e=i.current;if(!e)return;const t=()=>{c&&(e.currentTime=a||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}}),[c,a]);const f=(0,u.PY)(e.url),p=r.buildMediaURL(f);return(0,s.jsx)("audio",{className:"stAudio","data-testid":"stAudio",ref:i,controls:!0,autoPlay:l&&!m,src:p,style:{width:t}})}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[5563],{15563:(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var a=r(50016),n=r(13882),s=r(90421),i=r(
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[5563],{15563:(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var a=r(50016),n=r(13882),s=r(90421),i=r(14052),d=r(90076);const o=528;function l({element:e,width:t,endpoints:r,elementMgr:l}){const u=(0,a.useRef)(null),{type:c,url:p,startTime:m,subtitles:f,endTime:h,loop:v,autoplay:y,muted:E}=e,T=(0,i.PY)(p),L=(0,i.$m)(f),g=(0,a.useMemo)((()=>{if(!e.id)return!0;const t=l.getElementState(e.id,"preventAutoplay");return t||l.setElementState(e.id,"preventAutoplay",!0),null!==t&&void 0!==t&&t}),[e.id,l]);(0,a.useEffect)((()=>{u.current&&(u.current.currentTime=m)}),[m]),(0,a.useEffect)((()=>{const t=u.current,r=()=>{t&&(t.currentTime=e.startTime)};return t&&t.addEventListener("loadedmetadata",r),()=>{t&&t.removeEventListener("loadedmetadata",r)}}),[e]),(0,a.useEffect)((()=>{const e=u.current;if(!e)return;let t=!1;const r=()=>{h>0&&e.currentTime>=h&&(v?(e.currentTime=m||0,e.play()):t||(t=!0,e.pause()))};return h>0&&e.addEventListener("timeupdate",r),()=>{e&&h>0&&e.removeEventListener("timeupdate",r)}}),[h,v,m]),(0,a.useEffect)((()=>{const e=u.current;if(!e)return;const t=()=>{v&&(e.currentTime=m||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}}),[v,m]);const k=t=>{const{startTime:r,endTime:a,loop:n,autoplay:s,muted:i}=e,d=new URL(t);if(r&&!isNaN(r)&&d.searchParams.append("start",r.toString()),a&&!isNaN(a)&&d.searchParams.append("end",a.toString()),n){d.searchParams.append("loop","1");const e=d.pathname.split("/").pop();e&&d.searchParams.append("playlist",e)}return s&&d.searchParams.append("autoplay","1"),i&&d.searchParams.append("mute","1"),d.toString()};if(c===n.Ce.Type.YOUTUBE_IFRAME){const e=0!==t?.75*t:o;return(0,d.jsx)("iframe",{className:"stVideo","data-testid":"stVideo",title:T,src:k(T),width:t,height:e,style:{colorScheme:"normal"},frameBorder:"0",allow:"autoplay; encrypted-media",allowFullScreen:!0})}return(0,d.jsx)("video",{className:"stVideo","data-testid":"stVideo",ref:u,controls:!0,muted:E,autoPlay:y&&!g,src:r.buildMediaURL(T),style:{width:t,height:0===t?o:void 0},crossOrigin:s.LD&&L.length>0?"anonymous":void 0,children:L&&L.map(((e,t)=>(0,d.jsx)("track",{kind:"captions",src:r.buildMediaURL(e.url),label:e.label,default:0===t},t)))})}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[6945],{16945:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var i=n(50016),l=n(62363),r=n(9525),s=n(82729),d=n(28230),o=n(56806),a=n(19939),u=n(
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[6945],{16945:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var i=n(50016),l=n(62363),r=n(9525),s=n(82729),d=n(28230),o=n(56806),a=n(19939),u=n(14052),c=n(90076);const f=function(e){const{disabled:t,element:n,widgetMgr:f,width:b,endpoints:h,fragmentId:w}=e,m={width:b},{libConfig:{enforceDownloadInNewTab:p=!1}}=i.useContext(a.n),k="primary"===n.type?r.KX.PRIMARY:r.KX.SECONDARY,A=(0,u.mn)(),g=!n.help||b;return(0,c.jsx)("div",{className:"stDownloadButton","data-testid":"stDownloadButton",style:m,children:(0,c.jsx)(s.F,{help:n.help,children:(0,c.jsx)(d.Ay,{kind:k,size:r.Pj.SMALL,disabled:t,onClick:()=>{if(f.setTriggerValue(n,{fromUi:!0},w),n.url.startsWith("/media"))return void(0,u.Yr)(A,n.url);const e=function(e,t,n){return(0,l.A)({enforceDownloadInNewTab:n,url:e.buildMediaURL(t),filename:""})}(h,n.url,p);e.click()},fluidWidth:!!n.useContainerWidth&&g,children:(0,c.jsx)(o.Y,{icon:n.icon,label:n.label})})})})}},62363:(e,t,n)=>{n.d(t,{A:()=>i});const i=({enforceDownloadInNewTab:e,url:t,filename:n})=>{const i=document.createElement("a");return i.setAttribute("href",t),e?i.setAttribute("target","_blank"):i.setAttribute("target","_self"),i.setAttribute("download",n),i}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[7683,9163],{57683:(e,t,n)=>{n.r(t),n.d(t,{default:()=>x});n(50016);var i=n(81975),o=n(49694),l=n(25257),a=n(15144),s=n(18056),r=n(
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[7683,9163],{57683:(e,t,n)=>{n.r(t),n.d(t,{default:()=>x});n(50016);var i=n(81975),o=n(49694),l=n(25257),a=n(15144),s=n(18056),r=n(14052),d=n(84927);const c=(0,d.A)("div",{target:"e115fcil2"})((({theme:e})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%"})),""),h=(0,d.A)("div",{target:"e115fcil1"})({name:"1xf0csu",styles:"display:flex;flex-direction:column;align-items:stretch;width:auto;flex-grow:0"}),m=(0,d.A)("div",{target:"e115fcil0"})((({theme:e})=>({fontFamily:e.genericFonts.bodyFont,fontSize:e.fontSizes.sm,color:e.colors.fadedText60,textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS})),"");var u=n(90076),p=function(e){return e[e.OriginalWidth=-1]="OriginalWidth",e[e.ColumnWidth=-2]="ColumnWidth",e[e.AutoWidth=-3]="AutoWidth",e[e.MinImageOrContainer=-4]="MinImageOrContainer",e[e.MaxImageOrContainer=-5]="MaxImageOrContainer",e}(p||{});const x=(0,s.A)((function({element:e,width:t,endpoints:n,disableFullscreenMode:s}){const d=(0,r.$m)(e.imgs),{expanded:x,width:g,height:f,expand:v,collapse:w}=(0,a.i)(l.T);let C;const b=e.width;if([p.OriginalWidth,p.AutoWidth,p.MinImageOrContainer].includes(b))C=void 0;else if([p.ColumnWidth,p.MaxImageOrContainer].includes(b))C=x?g:t;else{if(!(b>0))throw Error(`Invalid image width: ${b}`);C=b}const y={};return f&&x?(y.maxHeight=f,y.objectFit="contain"):(y.width=C,y.maxWidth="100%"),(0,u.jsxs)(i.mx,{width:C,height:f,useContainerWidth:x,children:[(0,u.jsx)(o.A,{target:i.mx,isFullScreen:x,onExpand:v,onCollapse:w,disableFullscreenMode:s}),(0,u.jsx)(c,{className:"stImage","data-testid":"stImage",style:{width:C},children:d.map(((e,t)=>{const i=e;return(0,u.jsxs)(h,{"data-testid":"stImageContainer",children:[(0,u.jsx)("img",{style:y,src:n.buildMediaURL(i.url),alt:t.toString()}),i.caption&&(0,u.jsx)(m,{"data-testid":"stImageCaption",style:y,children:` ${i.caption} `})]},t)}))})]})}))},25257:(e,t,n)=>{n.d(t,{T:()=>i});const i=(0,n(50016).createContext)(null);i.displayName="ElementFullscreenContext"},18056:(e,t,n)=>{n.d(t,{A:()=>p});var i=n(50016),o=n(4134),l=n.n(o),a=n(83592);const s=(0,n(84927).A)("div",{target:"elp1w7k0"})((({theme:e,isExpanded:t})=>({...t?{position:"fixed",top:0,left:0,bottom:0,right:0,background:e.colors.bgColor,zIndex:e.zIndices.fullscreenWrapper,padding:e.spacing.md,paddingTop:e.sizes.fullScreenHeaderHeight,overflow:["auto","overlay"],display:"flex",alignItems:"center",justifyContent:"center"}:{}})),"");var r=n(25257),d=n(19939),c=n(30753),h=n(15144);var m=n(90076);const u=({children:e,height:t,width:n})=>{const o=(0,a.u)(),{expanded:l,fullHeight:u,fullWidth:p,zoomIn:x,zoomOut:g}=(()=>{const{setFullScreen:e}=(0,i.useContext)(d.n),[t,n]=(0,i.useState)(!1),{fullHeight:o,fullWidth:l}=(0,h.i)(c.j),a=(0,i.useCallback)((t=>{n(t),e(t)}),[e]),s=(0,i.useCallback)((()=>{document.body.style.overflow="hidden",a(!0)}),[a]),r=(0,i.useCallback)((()=>{document.body.style.overflow="unset",a(!1)}),[a]),m=(0,i.useCallback)((e=>{27===e.keyCode&&t&&r()}),[r,t]);return(0,i.useEffect)((()=>(document.addEventListener("keydown",m,!1),()=>{document.removeEventListener("keydown",m,!1)})),[m]),(0,i.useMemo)((()=>({expanded:t,zoomIn:s,zoomOut:r,fullHeight:o,fullWidth:l})),[t,s,r,o,l])})(),f=(0,i.useMemo)((()=>({width:l?p:n,height:l?u:t,expanded:l,expand:x,collapse:g})),[l,u,p,t,n,x,g]);return(0,m.jsx)(r.T.Provider,{value:f,children:(0,m.jsx)(s,{isExpanded:l,"data-testid":"stFullScreenFrame",theme:o,children:e})})};const p=function(e){const t=t=>(0,m.jsx)(u,{width:t.width,children:(0,m.jsx)(e,{...t})});return t.displayName=`withFullScreenWrapper(${e.displayName||e.name})`,l()(t,e)}},49694:(e,t,n)=>{n.d(t,{A:()=>p,K:()=>u});n(50016);var i=n(83592),o=n(43084),l=n(17948),a=n(72587),s=n(83774),r=n(28230),d=n(9525),c=n(20758),h=n(81975),m=n(90076);function u({label:e,show_label:t,icon:n,onClick:o}){const l=(0,i.u)(),h=t?e:"";return(0,m.jsx)("div",{"data-testid":"stElementToolbarButton",children:(0,m.jsx)(s.A,{content:(0,m.jsx)(a.Ay,{source:e,allowHTML:!1,style:{fontSize:l.fontSizes.sm}}),placement:s.W.TOP,onMouseEnterDelay:1e3,inline:!0,children:(0,m.jsxs)(r.Ay,{onClick:e=>{o&&o(),e.stopPropagation()},kind:d.KX.ELEMENT_TOOLBAR,"aria-label":e,children:[n&&(0,m.jsx)(c.A,{content:n,size:"md",testid:"stElementToolbarButtonIcon"}),h&&(0,m.jsx)("span",{children:h})]})})})}const p=({onExpand:e,onCollapse:t,isFullScreen:n,locked:i,children:a,target:s,disableFullscreenMode:r})=>(0,m.jsx)(h.Sq,{className:"stElementToolbar","data-testid":"stElementToolbar",locked:i||n,target:s,children:(0,m.jsxs)(h.x8,{children:[a,e&&!r&&!n&&(0,m.jsx)(u,{label:"Fullscreen",icon:o.g,onClick:()=>e()}),t&&!r&&n&&(0,m.jsx)(u,{label:"Close fullscreen",icon:l.Q,onClick:()=>t()})]})})},81975:(e,t,n)=>{n.d(t,{Sq:()=>a,mx:()=>r,x8:()=>s});var i=n(84927),o=n(9320);const l="-2.4rem",a=(0,i.A)("div",{target:"e2wxzia2"})((({theme:e,locked:t,target:n})=>({padding:`${e.spacing.sm} 0 ${e.spacing.sm} ${e.spacing.sm}`,position:"absolute",top:t?l:"-1rem",right:e.spacing.none,transition:"none",...!t&&{opacity:0,"&:active, &:focus-visible, &:hover":{transition:"opacity 150ms 100ms, top 100ms 100ms",opacity:1,top:l},...n&&{[`${n}:hover &, ${n}:active &, ${n}:focus-visible &`]:{transition:"opacity 150ms 100ms, top 100ms 100ms",opacity:1,top:l}}}})),""),s=(0,i.A)("div",{target:"e2wxzia1"})((({theme:e})=>({color:(0,o.iq)(e)?e.colors.fadedText60:e.colors.bodyText,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",boxShadow:"1px 2px 8px rgba(0, 0, 0, 0.08)",borderRadius:e.radii.default,backgroundColor:e.colors.lightenedBg05,width:"fit-content",zIndex:e.zIndices.sidebar+1})),""),r=(0,i.A)("div",{target:"e2wxzia0"})((({width:e,height:t,useContainerWidth:n})=>({position:"relative",height:n?t:"fit-content",width:n?e:"fit-content",maxWidth:"100%"})),"")},15144:(e,t,n)=>{n.d(t,{i:()=>o});var i=n(50016);const o=e=>{const t=(0,i.useContext)(e);var n;if(null===t||void 0===t)throw new Error(`useRequiredContext: ${null!==(n=e.displayName)&&void 0!==n?n:"context"} not found`);return t}},43084:(e,t,n)=>{n.d(t,{g:()=>a});var i=n(89575),o=n(50016),l=n(50088),a=o.forwardRef((function(e,t){return o.createElement(l.I,(0,i.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}))}));a.displayName="Fullscreen"},17948:(e,t,n)=>{n.d(t,{Q:()=>a});var i=n(89575),o=n(50016),l=n(50088),a=o.forwardRef((function(e,t){return o.createElement(l.I,(0,i.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}))}));a.displayName="FullscreenExit"}}]);
|