@stlite/desktop 0.58.4 → 0.58.6

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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "/static/css/main.6fb7674e.css",
4
- "main.js": "/static/js/main.b1355ae6.js",
5
- "static/js/8798.1294d348.chunk.js": "/static/js/8798.1294d348.chunk.js",
4
+ "main.js": "/static/js/main.73102b64.js",
5
+ "static/js/8798.4c394478.chunk.js": "/static/js/8798.4c394478.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.0c41f474.chunk.js": "/static/js/4785.0c41f474.chunk.js",
@@ -163,6 +163,6 @@
163
163
  },
164
164
  "entrypoints": [
165
165
  "static/css/main.6fb7674e.css",
166
- "static/js/main.b1355ae6.js"
166
+ "static/js/main.73102b64.js"
167
167
  ]
168
168
  }
@@ -1,5 +1,5 @@
1
1
  var pe=Object.create;var X=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var M=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Pe=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ye(e))!ve.call(r,o)&&o!==t&&X(r,o,{get:()=>e[o],enumerable:!(s=_e(e,o))||s.enumerable});return r};var I=(r,e,t)=>(t=r!=null?pe(he(r)):{},Pe(e||!r||!r.__esModule?X(t,"default",{value:r,enumerable:!0}):t,r));var G=M(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.validateRequirements=void 0;var be="[",we="(<=>!~",Se=";",ke="@",Ae=new RegExp(`[${be+we+Se+ke}]`);function Re(r){return r.split(Ae)[0].trim()}function Fe(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=>Re(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=Fe});var Q=M(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.parseRequirementsTxt=void 0;var Me=/\s#.*$/;function Ie(r){return r.split(`
2
- `).filter(e=>!e.startsWith("#")).map(e=>e.replace(Me,"")).map(e=>e.trim()).filter(e=>e!=="")}T.parseRequirementsTxt=Ie});var Y=M(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 Z=M(w=>{"use strict";var Oe=w&&w.__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=w&&w.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Oe(e,r,t)};Object.defineProperty(w,"__esModule",{value:!0});x(G(),w);x(Q(),w);x(Y(),w)});var re=M((Xe,te)=>{"use strict";function P(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function ee(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 Le(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 R={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),P(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=ee(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(P(e),e.length===0)return".";var t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=ee(e,!t),e.length===0&&!t&&(e="."),e.length>0&&s&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return P(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];P(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":R.normalize(e)},relative:function(e,t){if(P(e),P(t),e===t||(e=R.resolve(e),t=R.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 S=e.charCodeAt(s+l),_=t.charCodeAt(n+l);if(S!==_)break;S===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(P(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');P(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){P(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 Le("/",e)},parse:function(e){P(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};R.posix=R;te.exports=R});var B=require("node:worker_threads");var le=I(Z());var q=I(re());function oe(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){oe(r,e),r.FS.writeFile(e,t,s)}function se(r,e,t){oe(r,t),r.FS.rename(e,t)}var Ee="[",Ce="(<=>!~",Te=";",Ne="@",De=new RegExp(`[${Ee+Ce+Te+Ne}]`);function Ue(r){return r.split(De)[0].trim()}function H(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=>Ue(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 xe(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 ne(r,e){let{scriptURL:t,pyodideIndexURL:s,isESModule:o}=await xe(r),i;return o?i=(await import(t)).loadPyodide:(importScripts(t),i=self.loadPyodide),i({...e,indexURL:s})}function j(r){r.runPython(`
2
+ `).filter(e=>!e.startsWith("#")).map(e=>e.replace(Me,"")).map(e=>e.trim()).filter(e=>e!=="")}T.parseRequirementsTxt=Ie});var Y=M(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 Z=M(w=>{"use strict";var Oe=w&&w.__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=w&&w.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Oe(e,r,t)};Object.defineProperty(w,"__esModule",{value:!0});x(G(),w);x(Q(),w);x(Y(),w)});var re=M((Xe,te)=>{"use strict";function P(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function ee(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 Ee(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 R={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),P(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=ee(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(P(e),e.length===0)return".";var t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=ee(e,!t),e.length===0&&!t&&(e="."),e.length>0&&s&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return P(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];P(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":R.normalize(e)},relative:function(e,t){if(P(e),P(t),e===t||(e=R.resolve(e),t=R.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 S=e.charCodeAt(s+l),_=t.charCodeAt(n+l);if(S!==_)break;S===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(P(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');P(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){P(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 Ee("/",e)},parse:function(e){P(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};R.posix=R;te.exports=R});var B=require("node:worker_threads");var le=I(Z());var q=I(re());function oe(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){oe(r,e),r.FS.writeFile(e,t,s)}function se(r,e,t){oe(r,t),r.FS.rename(e,t)}var Le="[",Ce="(<=>!~",Te=";",Ne="@",De=new RegExp(`[${Le+Ce+Te+Ne}]`);function Ue(r){return r.split(De)[0].trim()}function H(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=>Ue(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 xe(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 ne(r,e){let{scriptURL:t,pyodideIndexURL:s,isESModule:o}=await xe(r),i;return o?i=(await import(t)).loadPyodide:(importScripts(t),i=self.loadPyodide),i({...e,indexURL:s})}function j(r){r.runPython(`
3
3
  import micropip
4
4
  micropip.add_mock_package(
5
5
  "pyarrow", "0.0.1",
@@ -12,6 +12,16 @@ class Table:
12
12
  @classmethod
13
13
  def from_pandas(*args, **kwargs):
14
14
  raise NotImplementedError("stlite is not supporting this method.")
15
+
16
+
17
+ class Array:
18
+ def __init__(self, *args, **kwargs):
19
+ raise NotImplementedError("stlite is not supporting PyArrow.Array")
20
+
21
+
22
+ class ChunkedArray:
23
+ def __init__(self, *args, **kwargs):
24
+ raise NotImplementedError("stlite is not supporting PyArrow.ChunkedArray")
15
25
  """
16
26
  }
17
27
  )
@@ -43,14 +53,14 @@ from streamlit.runtime.scriptrunner import script_runner
43
53
  from js import __moduleAutoLoadPromise__
44
54
 
45
55
  script_runner.moduleAutoLoadPromise = __moduleAutoLoadPromise__
46
- `)}function ce(r,e,t){function s(f){e({type:"event:progress",data:{message:f}})}let o,i,n=new le.PromiseDelegate;async function a(){let f=await n.promise,l={...t,...f};console.debug("Initial data",l);let{entrypoint:S,files:_,archives:d,requirements:p,prebuiltPackageNames:y,wheels:h,mountedSitePackagesSnapshotFilePath:v,pyodideUrl:k=r,streamlitConfig:A,idbfsMountpoints:O,nodefsMountpoints:z,moduleAutoLoad:ue}=l,L=H(p);s("Loading Pyodide."),console.debug("Loading Pyodide"),o=await ne(k,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide");let J=!1;O&&(J=!0,O.forEach(u=>{o.FS.mkdir(u),o.FS.mount(o.FS.filesystems.IDBFS,{},u)}),await new Promise((u,m)=>{o.FS.syncfs(!0,b=>{b?m(b):u()})})),z&&Object.entries(z).forEach(([u,m])=>{o.FS.mkdir(u),o.FS.mount(o.FS.filesystems.NODEFS,{root:m},u)}),s("Mounting files.");let K=[];if(await Promise.all(Object.keys(_).map(async u=>{let m=_[u],b;"url"in m?(console.debug(`Fetch a file from ${m.url}`),b=await fetch(m.url).then(F=>F.arrayBuffer()).then(F=>new Uint8Array(F))):b=m.data;let{opts:E}=_[u];console.debug(`Write a file "${u}"`),$(o,u,b,E),u.endsWith(".py")&&K.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:b,options:E}=u;console.debug("Unpack an archive",{format:b,options:E}),o.unpackArchive(m,b,E)})),!v&&!h)throw new Error("Neither snapshot nor wheel files are provided.");v&&(s("Restoring the snapshot."),await o.runPythonAsync("import tarfile, shutil, site"),await o.runPythonAsync(`
56
+ `)}function ce(r,e,t){function s(f){e({type:"event:progress",data:{message:f}})}let o,i,n=new le.PromiseDelegate;async function a(){let f=await n.promise,l={...t,...f};console.debug("Initial data",l);let{entrypoint:S,files:_,archives:d,requirements:p,prebuiltPackageNames:y,wheels:h,mountedSitePackagesSnapshotFilePath:v,pyodideUrl:k=r,streamlitConfig:A,idbfsMountpoints:O,nodefsMountpoints:z,moduleAutoLoad:ue}=l,E=H(p);s("Loading Pyodide."),console.debug("Loading Pyodide"),o=await ne(k,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide");let J=!1;O&&(J=!0,O.forEach(u=>{o.FS.mkdir(u),o.FS.mount(o.FS.filesystems.IDBFS,{},u)}),await new Promise((u,m)=>{o.FS.syncfs(!0,b=>{b?m(b):u()})})),z&&Object.entries(z).forEach(([u,m])=>{o.FS.mkdir(u),o.FS.mount(o.FS.filesystems.NODEFS,{root:m},u)}),s("Mounting files.");let K=[];if(await Promise.all(Object.keys(_).map(async u=>{let m=_[u],b;"url"in m?(console.debug(`Fetch a file from ${m.url}`),b=await fetch(m.url).then(F=>F.arrayBuffer()).then(F=>new Uint8Array(F))):b=m.data;let{opts:L}=_[u];console.debug(`Write a file "${u}"`),$(o,u,b,L),u.endsWith(".py")&&K.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:b,options:L}=u;console.debug("Unpack an archive",{format:b,options:L}),o.unpackArchive(m,b,L)})),!v&&!h)throw new Error("Neither snapshot nor wheel files are provided.");v&&(s("Restoring the snapshot."),await o.runPythonAsync("import tarfile, shutil, site"),await o.runPythonAsync(`
47
57
  site_packages_dirs = site.getsitepackages()
48
58
  for site_packages in site_packages_dirs:
49
59
  shutil.rmtree(site_packages)
50
60
  `),console.debug(`Unarchive ${v}`),await o.runPythonAsync(`
51
61
  with tarfile.open("${v}", "r") as tar_gz_file:
52
62
  tar_gz_file.extractall("/")
53
- `),console.debug("Restored the snapshot"),s("Mocking some packages."),console.debug("Mock pyarrow"),j(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"),await o.loadPackage("micropip");let V=o.pyimport("micropip");if(h?(console.debug("Installing the wheels:",h,"and the requirements:",L),await V.install.callKwargs([h.stliteServer,h.streamlit,...L],{keep_going:!0}),console.debug("Installed the wheels and the requirements"),s("Mocking some packages."),console.debug("Mock pyarrow"),j(o),console.debug("Mocked pyarrow")):(console.debug("Installing the requirements:",L),await V.install.callKwargs(L,{keep_going:!0}),console.debug("Installed the requirements")),ue){let u=K.map(m=>o.FS.readFile(m,{encoding:"utf8"}));ae(o,e,u)}await o.runPythonAsync(`
63
+ `),console.debug("Restored the snapshot"),s("Mocking some packages."),console.debug("Mock pyarrow"),j(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"),await o.loadPackage("micropip");let V=o.pyimport("micropip");if(h?(console.debug("Installing the wheels:",h,"and the requirements:",E),await V.install.callKwargs([h.stliteServer,h.streamlit,...E],{keep_going:!0}),console.debug("Installed the wheels and the requirements"),s("Mocking some packages."),console.debug("Mock pyarrow"),j(o),console.debug("Mocked pyarrow")):(console.debug("Installing the requirements:",E),await V.install.callKwargs(E,{keep_going:!0}),console.debug("Installed the requirements")),ue){let u=K.map(m=>o.FS.readFile(m,{encoding:"utf8"}));ae(o,e,u)}await o.runPythonAsync(`
54
64
  import importlib
55
65
  importlib.invalidate_caches()
56
66
  `),s("Loading streamlit package."),console.debug("Loading the Streamlit package"),await o.runPythonAsync(`
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.b1355ae6.js"></script><link href="/static/css/main.6fb7674e.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
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.73102b64.js"></script><link href="/static/css/main.6fb7674e.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={56977:e=>{function t(e){if("string"!==typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",o=0,s=-1,i=0,a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(47===n)break;n=47}if(47===n){if(s===a-1||1===i);else if(s!==a-1&&2===i){if(r.length<2||2!==o||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",o=0):o=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),s=a,i=0;continue}}else if(2===r.length||1===r.length){r="",o=0,s=a,i=0;continue}t&&(r.length>0?r+="/..":r="..",o=2)}else r.length>0?r+="/"+e.slice(s+1,a):r=e.slice(s+1,a),o=a-s-1;s=a,i=0}else 46===n&&-1!==i?++i:i=-1}return r}var r={resolve:function(){for(var e,r="",o=!1,s=arguments.length-1;s>=-1&&!o;s--){var i;s>=0?i=arguments[s]:(void 0===e&&(e=process.cwd()),i=e),t(i),0!==i.length&&(r=i+"/"+r,o=47===i.charCodeAt(0))}return r=n(r,!o),o?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),o=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&o&&(e+="/"),r?"/"+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,n=0;n<arguments.length;++n){var o=arguments[n];t(o),o.length>0&&(void 0===e?e=o:e+="/"+o)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var o=1;o<e.length&&47===e.charCodeAt(o);++o);for(var s=e.length,i=s-o,a=1;a<n.length&&47===n.charCodeAt(a);++a);for(var l=n.length-a,c=i<l?i:l,d=-1,g=0;g<=c;++g){if(g===c){if(l>c){if(47===n.charCodeAt(a+g))return n.slice(a+g+1);if(0===g)return n.slice(a+g)}else i>c&&(47===e.charCodeAt(o+g)?d=g:0===g&&(d=0));break}var u=e.charCodeAt(o+g);if(u!==n.charCodeAt(a+g))break;47===u&&(d=g)}var p="";for(g=o+d+1;g<=s;++g)g!==s&&47!==e.charCodeAt(g)||(0===p.length?p+="..":p+="/..");return p.length>0?p+n.slice(a+d):(a+=d,47===n.charCodeAt(a)&&++a,n.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,o=-1,s=!0,i=e.length-1;i>=1;--i)if(47===(n=e.charCodeAt(i))){if(!s){o=i;break}}else s=!1;return-1===o?r?"/":".":r&&1===o?"//":e.slice(0,o)},basename:function(e,n){if(void 0!==n&&"string"!==typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,o=0,s=-1,i=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var a=n.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!i){o=r+1;break}}else-1===l&&(i=!1,l=r+1),a>=0&&(c===n.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return o===s?s=l:-1===s&&(s=e.length),e.slice(o,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!i){o=r+1;break}}else-1===s&&(i=!1,s=r+1);return-1===s?"":e.slice(o,s)},extname:function(e){t(e);for(var n=-1,r=0,o=-1,s=!0,i=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===o&&(s=!1,o=a+1),46===l?-1===n?n=a:1!==i&&(i=1):-1!==n&&(i=-1);else if(!s){r=a+1;break}}return-1===n||-1===o||0===i||1===i&&n===o-1&&n===r+1?"":e.slice(n,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 n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}("/",e)},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,o=e.charCodeAt(0),s=47===o;s?(n.root="/",r=1):r=0;for(var i=-1,a=0,l=-1,c=!0,d=e.length-1,g=0;d>=r;--d)if(47!==(o=e.charCodeAt(d)))-1===l&&(c=!1,l=d+1),46===o?-1===i?i=d:1!==g&&(g=1):-1!==i&&(g=-1);else if(!c){a=d+1;break}return-1===i||-1===l||0===g||1===g&&i===l-1&&i===a+1?-1!==l&&(n.base=n.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(n.name=e.slice(1,i),n.base=e.slice(1,l)):(n.name=e.slice(a,i),n.base=e.slice(a,l)),n.ext=e.slice(i,l)),a>0?n.dir=e.slice(0,a-1):s&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{new RegExp("[[(<=>!~;@]");class e{constructor(){this.promise=new Promise(((e,t)=>{this.resolveInternal=e,this.rejectInternal=t}))}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}}var t=n(56977),r=n.n(t);function o(e,t){const n=r().normalize(t),o=r().dirname(n).split("/"),s=[];for(const r of o){s.push(r);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(i){throw console.error(`Failed to create a directory "${t}"`),i}}}function s(e,t,n,r){o(e,t),e.FS.writeFile(t,n,r)}const i=new RegExp("[[(<=>!~;@]");function a(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(i)[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)}))}var l=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{l(r.next(e))}catch(t){s(t)}}function a(e){try{l(r.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}l((r=r.apply(e,t||[])).next())}))};function c(e,t){return l(this,void 0,void 0,(function*(){const{scriptURL:n,pyodideIndexURL:r,isESModule:o}=yield function(e){var t;return l(this,void 0,void 0,(function*(){const n="undefined"!==typeof process&&(null===(t=process.versions)||void 0===t?void 0:t.node);let r;r=n?(yield import("node:path")).sep:"/";const o=e.slice(0,e.lastIndexOf(r)+1);if(e.endsWith(".mjs")){if(n){const t=yield import("node:path"),n=yield import("node:url");!e.includes("://")&&t.isAbsolute(e)&&(e=n.pathToFileURL(e).href)}return{scriptURL:e,pyodideIndexURL:o,isESModule:!0}}return{scriptURL:e,pyodideIndexURL:o,isESModule:!1}}))}(e);let s;if(o){s=(yield import(n)).loadPyodide}else importScripts(n),s=self.loadPyodide;return s(Object.assign(Object.assign({},t),{indexURL:r}))}))}function d(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')}var g=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{l(r.next(e))}catch(t){s(t)}}function a(e){try{l(r.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}l((r=r.apply(e,t||[])).next())}))};let u;function p(e,t,n){return g(this,void 0,void 0,(function*(){const r=n.map((t=>function(e,t){if(!u){const t='\nimport ast\nfrom textwrap import dedent\n\ndef find_imports(source: str) -> list[str]:\n source = dedent(source)\n\n try:\n mod = ast.parse(source)\n except SyntaxError:\n return []\n imports = set()\n for node in mod.body:\n if isinstance(node, ast.Import):\n for name in node.names:\n node_name = name.name\n imports.add(node_name.split(".")[0])\n elif isinstance(node, ast.ImportFrom):\n module_name = node.module\n if module_name is None:\n continue\n imports.add(module_name.split(".")[0])\n return imports\n';e.runPython(t),u=e.globals.get("find_imports")}return u(t).toJs()}(e,t))),o=function(e){const t=new Set;for(const n of e)for(const e of n)t.add(e);return t}(r),s=Array.from(o).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 i=new MessageChannel;t({type:"event:moduleAutoLoad",data:{packagesToLoad:s}},i.port2);try{const t=yield e.loadPackage(s);return i.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:t}}),void i.port1.close()}catch(a){throw i.port1.postMessage({type:"moduleAutoLoad:error",error:a}),i.port1.close(),a}}))}var m=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{l(r.next(e))}catch(t){s(t)}}function a(e){try{l(r.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}l((r=r.apply(e,t||[])).next())}))};const f=n.g;function h(e,t,n){const r=p(e,t,n);f.__moduleAutoLoadPromise__=r,e.runPythonAsync("\nfrom streamlit.runtime.scriptrunner import script_runner\nfrom js import __moduleAutoLoadPromise__\n\nscript_runner.moduleAutoLoadPromise = __moduleAutoLoadPromise__\n")}const _=self.postMessage;self.onmessage=function(t,n,r){function i(e){n({type:"event:progress",data:{message:e}})}let l,g;const u=new e,p=function(){var e,o;return m(this,void 0,void 0,(function*(){const p=yield u.promise,_=Object.assign(Object.assign({},r),p);console.debug("Initial data",_);const{entrypoint:y,files:v,archives:b,requirements:w,prebuiltPackageNames:k,wheels:S,mountedSitePackagesSnapshotFilePath:A,pyodideUrl:P=t,streamlitConfig:C,idbfsMountpoints:F,nodefsMountpoints:x,moduleAutoLoad:L}=_,I=a(w);i("Loading Pyodide."),console.debug("Loading Pyodide"),l=yield c(P,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide");let E=!1;F&&(E=!0,F.forEach((e=>{l.FS.mkdir(e),l.FS.mount(l.FS.filesystems.IDBFS,{},e)})),yield new Promise(((e,t)=>{l.FS.syncfs(!0,(n=>{n?t(n):e()}))}))),x&&Object.entries(x).forEach((([e,t])=>{l.FS.mkdir(e),l.FS.mount(l.FS.filesystems.NODEFS,{root:t},e)})),i("Mounting files.");const O=[];if(yield Promise.all(Object.keys(v).map((e=>m(this,void 0,void 0,(function*(){const t=v[e];let n;"url"in t?(console.debug(`Fetch a file from ${t.url}`),n=yield fetch(t.url).then((e=>e.arrayBuffer())).then((e=>new Uint8Array(e)))):n=t.data;const{opts:r}=v[e];console.debug(`Write a file "${e}"`),s(l,e,n,r),e.endsWith(".py")&&O.push(e)}))))),i("Unpacking archives."),yield Promise.all(b.map((e=>m(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:n,options:r}=e;console.debug("Unpack an archive",{format:n,options:r}),l.unpackArchive(t,n,r)}))))),!A&&!S)throw new Error("Neither snapshot nor wheel files are provided.");A&&(i("Restoring the snapshot."),yield l.runPythonAsync("import tarfile, shutil, site"),yield l.runPythonAsync("\nsite_packages_dirs = site.getsitepackages()\nfor site_packages in site_packages_dirs:\n shutil.rmtree(site_packages)\n"),console.debug(`Unarchive ${A}`),yield l.runPythonAsync(`\nwith tarfile.open("${A}", "r") as tar_gz_file:\n tar_gz_file.extractall("/")\n`),console.debug("Restored the snapshot"),i("Mocking some packages."),console.debug("Mock pyarrow"),d(l),console.debug("Mocked pyarrow")),i("Installing packages."),console.debug("Installing the prebuilt packages:",k),yield l.loadPackage(k),console.debug("Installed the prebuilt packages"),yield l.loadPackage("micropip");const j=l.pyimport("micropip");if(S?(console.debug("Installing the wheels:",S,"and the requirements:",I),yield j.install.callKwargs([S.stliteServer,S.streamlit,...I],{keep_going:!0}),console.debug("Installed the wheels and the requirements"),i("Mocking some packages."),console.debug("Mock pyarrow"),d(l),console.debug("Mocked pyarrow")):(console.debug("Installing the requirements:",I),yield j.install.callKwargs(I,{keep_going:!0}),console.debug("Installed the requirements")),L){const e=O.map((e=>l.FS.readFile(e,{encoding:"utf8"})));h(l,n,e)}yield l.runPythonAsync("\nimport importlib\nimportlib.invalidate_caches()\n"),i("Loading streamlit package."),console.debug("Loading the Streamlit package"),yield l.runPythonAsync("\nimport streamlit.runtime\n "),console.debug("Loaded the Streamlit package"),i("Setting up the loggers."),console.debug("Setting the loggers"),yield l.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)},yield l.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 M=(null!==(e=null===C||void 0===C?void 0:C["logger.level"])&&void 0!==e?e:"INFO").toString(),R=null!==(o=null===C||void 0===C?void 0:C["logger.messageFormat"])&&void 0!==o?o:"%(asctime)s %(message)s";if(l.globals.get("setup_loggers")(M,R),console.debug("Set the loggers"),i("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),yield l.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"),E){i("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,l.FS.syncfs(!1,(t=>{e=!1,t&&console.error(t)})))},yield l.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")}return i("Booting up the Streamlit server."),console.debug("Booting up the Streamlit server"),f.__streamlitFlagOptions__=Object.assign(Object.assign({"browser.gatherUsageStats":!1},C),{"runner.fastReruns":!1}),yield l.runPythonAsync(`\nfrom stlite_server.bootstrap import load_config_options, prepare\nfrom stlite_server.server import Server\nfrom js import __streamlitFlagOptions__\n\nflag_options = __streamlitFlagOptions__.to_py()\nload_config_options(flag_options)\n\nmain_script_path = "${y}"\nargs = []\n\nprepare(main_script_path, args)\n\nserver = Server(main_script_path)\nserver.start()\n`),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),g=l.globals.get("server").copy(),console.debug("Set up the HTTP server"),n({type:"event:loaded"}),_}))}().catch((e=>{throw n({type:"event:error",data:{error:e}}),e}));return n({type:"event:start"}),e=>m(this,void 0,void 0,(function*(){const t=e.data;if("initData"===t.type)return void u.resolve(t.data);const{moduleAutoLoad:r}=yield p,i=e.ports[0];try{switch(t.type){case"websocket:connect":{console.debug("websocket:connect",t.data);const{path:e}=t.data;g.start_websocket(e,((e,t)=>{if(t){const t=e,r=t.getBuffer("u8");t.destroy();const o=new Uint8ClampedArray(r.data.buffer,r.data.byteOffset,r.data.byteLength);n({type:"websocket:message",data:{payload:new Uint8Array(o)}})}else{n({type:"websocket:message",data:{payload:e}})}})),i.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",t.data);const{payload:e}=t.data;g.receive_websocket_from_js(e);break}case"http:request":{console.debug("http:request",t.data);const{request:e}=t.data,n=(e,t,n)=>{const r=new Map(t.toJs()),o=n.toJs();console.debug({statusCode:e,headers:r,body:o});const s={type:"http:response",data:{response:{statusCode:e,headers:r,body:o}}};i.postMessage(s)};g.receive_http_from_js(e.method,decodeURIComponent(e.path),e.headers,e.body,n);break}case"file:write":{const{path:e,data:o,opts:a}=t.data;r&&"string"===typeof o&&e.endsWith(".py")&&(console.debug(`Auto install the requirements in ${e}`),h(l,n,[o])),console.debug(`Write a file "${e}"`),s(l,e,o,a),i.postMessage({type:"reply"});break}case"file:rename":{const{oldPath:e,newPath:n}=t.data;console.debug(`Rename "${e}" to ${n}`),function(e,t,n){o(e,n),e.FS.rename(t,n)}(l,e,n),i.postMessage({type:"reply"});break}case"file:unlink":{const{path:e}=t.data;console.debug(`Remove "${e}`),l.FS.unlink(e),i.postMessage({type:"reply"});break}case"install":{const{requirements:e}=t.data,n=l.pyimport("micropip"),r=a(e);console.debug("Install the requirements:",r),yield n.install.callKwargs(r,{keep_going:!0}).then((()=>{console.debug("Successfully installed"),i.postMessage({type:"reply"})}))}}}catch(c){if(console.error(c),!(c instanceof Error))throw c;const e=new Error(c.message);e.name=c.name,e.stack=c.stack,i.postMessage({type:"reply",error:e})}}))}("https://cdn.jsdelivr.net/pyodide/v0.26.0/full/pyodide.js",((e,t)=>_(e,t?[t]:void 0)))})()})();