@stlite/desktop 0.91.0 → 0.91.2

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/bin/dump_artifacts.js +1 -1
  3. package/build/assets/{ErrorOutline.esm-5cmZjQRC-icYL4BM5.js → ErrorOutline.esm-CBPRrcCq-C9-TIHiy.js} +1 -1
  4. package/build/assets/{FileDownload.esm-rDRR6AEq-DjpuiBZc.js → FileDownload.esm-zztsCQgv-C5piFaVt.js} +1 -1
  5. package/build/assets/{FileHelper-DDgj8qUb-DZYWXyeE.js → FileHelper-D9iak492-B1kwMP-N.js} +1 -1
  6. package/build/assets/{FormClearHelper-Bi1RDDCw-CUfvtGEu.js → FormClearHelper-B-0AN2KG-drNJ-Zdq.js} +1 -1
  7. package/build/assets/{Hooks-BLb3umpI-D_n25nUE.js → Hooks-BLb3umpI-CC08A2wx.js} +1 -1
  8. package/build/assets/{InputInstructions-DK4vKQJt-CxHQuxCq.js → InputInstructions-w5hPdqFC-DnPj3I4S.js} +1 -1
  9. package/build/assets/{Particles-CVTDiAXz-DxW9qGxs.js → Particles-DQoPZNo9-BWmBxXhd.js} +1 -1
  10. package/build/assets/{ProgressBar-DBzTytnw-KD3bOGNH.js → ProgressBar-DlHaaa-z-DdC3oXz0.js} +1 -1
  11. package/build/assets/{Toolbar-C79vGzHM-4gREjS-R.js → Toolbar-Cau3SOTY-cJ6wtM04.js} +1 -1
  12. package/build/assets/{base-input-DqwZ6cLM-CfKARdZH.js → base-input-D-Fvddky-3QuAUeGB.js} +1 -1
  13. package/build/assets/{checkbox-DSLjv1hz-C5dTTEJn.js → checkbox-CjcIG3na-LB8a9-d7.js} +1 -1
  14. package/build/assets/{createSuper-B3kpwht8-vR1ZxlfE.js → createSuper-B81LEHTk-DVB4ulOX.js} +1 -1
  15. package/build/assets/data-grid-overlay-editor-C7-8Z8CC-CmhK1L1G.js +1 -0
  16. package/build/assets/{downloader-DcCTL3Wz-B8zcxQVm.js → downloader-DcCTL3Wz-DfHnsO-D.js} +1 -1
  17. package/build/assets/{es6--XPcqeHG-Ct8fR_QW.js → es6--XPcqeHG-CU-P5RWV.js} +2 -2
  18. package/build/assets/{iframeResizer.contentWindow-BYeUxEkG-BGHgpKaO.js → iframeResizer.contentWindow-vAQsQkcx-DjDgPkx5.js} +1 -1
  19. package/build/assets/{index-DDzvi540-BP83xTE8.js → index--hiX6Uwv-DtKO9Hld.js} +1 -1
  20. package/build/assets/{index-CqUzXpnq-BkRqyTZ-.js → index-6t9Tq-Ab-Cc_ees8I.js} +1 -1
  21. package/build/assets/{index-zCpSIFXF-CNWD8XSX.js → index-B5h0Xgw3-CNFqm9ip.js} +1 -1
  22. package/build/assets/{index-fUOYudAa-DwvNVa4q.js → index-BDD6ManL-XC9-hEWd.js} +1 -1
  23. package/build/assets/{index-0V3zFawH-dk2qSnUj.js → index-BDtR3I-m-C6v_enzF.js} +1 -1
  24. package/build/assets/{index-B77TIzH--_sfHBOLj.js → index-BNeCf0z6-eizg-dFz.js} +1 -1
  25. package/build/assets/{index-BPsr3GBY-CJGmhZ4p.js → index-BXbsmcnm-D0BJVs7R.js} +1 -1
  26. package/build/assets/index-Bt2pmgaJ-ymksNLCl.js +198 -0
  27. package/build/assets/{index-DdN7bQv1-B-kAc3Ut.js → index-Bx1YyC6x-bUWv5Yyf.js} +1 -1
  28. package/build/assets/{index-BUGX2TMK.js → index-BxpEVUJq.js} +45 -45
  29. package/build/assets/{index-BFxpMDN6-DR2ES9VX.js → index-C5FPtYYS-BTTgdUI2.js} +1 -1
  30. package/build/assets/{index-CKLXnSph-0c1m_tEn.js → index-CL9VPrGG-DvzaBWYj.js} +1 -1
  31. package/build/assets/{index-DpgEDPmz-DJh9zWZb.js → index-COXlYbHo-B2m8urCs.js} +1 -1
  32. package/build/assets/{index-xHja9EuR-BJAq-yTR.js → index-CR_1rzEZ-DaqWZNME.js} +1 -1
  33. package/build/assets/{index-CK3GkxeH-D2XBcs5n.js → index-CUH8SI0g-CgCG3Tq7.js} +1 -1
  34. package/build/assets/{index-D6seXbqB-BPSqxK2r.js → index-CeUKVR_x-6fYziq6X.js} +1 -1
  35. package/build/assets/{index-p30tlBB--Bny4OpXe.js → index-D4OS_mB9-BwMU_oxN.js} +1 -1
  36. package/build/assets/{index-DUxsAr3N-YOYvjsWo.js → index-D5GvvN8r-CL05rAIV.js} +1 -1
  37. package/build/assets/{index-DJv86VV6-BxF_m0zQ.js → index-D6OV4wQy-CQIpYALu.js} +1 -1
  38. package/build/assets/{index-fJZU9fvL-CKGTaTkl.js → index-D8AcUh2z-BvmWAicd.js} +1 -1
  39. package/build/assets/index-D9Ww6wIM-CODTYNKi.js +1 -0
  40. package/build/assets/{index-j0zTFwH2-B6bjwCqo.js → index-D9xjkRNt-CFe8X0f3.js} +1 -1
  41. package/build/assets/{index-BkEF79ga-BDywftDb.js → index-DBM8Q3zu-1UaS0Le1.js} +1 -1
  42. package/build/assets/{index-pBZdYFXV-CISZ02sQ.js → index-DEKI5kx7-B8lK1On8.js} +1 -1
  43. package/build/assets/{index-CZG1F3wS-BFc-W9r-.js → index-DVo6TdD5-Cigl7ucs.js} +1 -1
  44. package/build/assets/{index-CFJPpmiv-DJLEtKZ0.js → index-DYssp6us-ss1M0SKX.js} +1 -1
  45. package/build/assets/{index-BV9PPylv-DWAKeZC_.js → index-Da8BucgM-CDMzLZMq.js} +1 -1
  46. package/build/assets/{index-Hwxwzkvz-BrKybKu3.js → index-DbIPIRRU-UJS7GIgX.js} +1 -1
  47. package/build/assets/{index-D--Ibtdf-DP7qoXbQ.js → index-DqAvSOqr-BCGTFud5.js} +1 -1
  48. package/build/assets/{index-BQabGVla-C_9TU-y1.js → index-Ds3R2kL1-CFh_Kz3Y.js} +1 -1
  49. package/build/assets/{index-Ng0C2pop-CzH2RCjT.js → index-FbSORAjW-Lthz52ML.js} +1 -1
  50. package/build/assets/{index-B7QM9sAr-BJJ9a1xS.js → index-JJq6JoHy-CX1Omp_x.js} +1 -1
  51. package/build/assets/{index-DlIOBmG6-fWsA1K6o.js → index-OAJkEMe--vGYqEFkN.js} +1 -1
  52. package/build/assets/{index-CxQBvv94-C1cgCYzN.js → index-PfjJDWy5-DkldmeJ8.js} +1 -1
  53. package/build/assets/{index-CQ0SOKgT-K7zOmyHq.js → index-kgY8PEpO-BUILDAe7.js} +1 -1
  54. package/build/assets/{index-BacWTAj2-C6QHLACm.js → index-oFRA4JRK-kx0e_3zA.js} +1 -1
  55. package/build/assets/{index-DfmwwL-F-BtkRVq0J.js → index-vdN_5NIh-CyyygayY.js} +1 -1
  56. package/build/assets/{inherits-V2B09WF6-BfQai87E.js → inherits-DIXnBNlu-DQhXiByk.js} +1 -1
  57. package/build/assets/{input-0QG8D109-QEdIPUBc.js → input-D3V-zfyu-Ca751_uU.js} +1 -1
  58. package/build/assets/{memory-B3L1Fctl-DNNZq00W.js → memory-B3L1Fctl-DNb7NEQl.js} +1 -1
  59. package/build/assets/{number-overlay-editor-CQf9AWEA-RmKnGQqj.js → number-overlay-editor-ChRMsdOl-C6ThLwiC.js} +1 -1
  60. package/build/assets/{sandbox-ChAzL-i--Bt92ucFR.js → sandbox-ChAzL-i--FikCfyDW.js} +1 -1
  61. package/build/assets/{slicedToArray-bXF_q2D_-C8JYb8qs.js → slicedToArray-BPQXLGHq-C21Y2TxO.js} +1 -1
  62. package/build/assets/{timepicker-BaiGCRZ1-Sm9ehMNI.js → timepicker-B0aGGgzd-sxFvpbfo.js} +1 -1
  63. package/build/assets/{uniqueId-DEZw4fCm-ChV-p6H5.js → uniqueId-MHj2wT7u-DPxsodx6.js} +1 -1
  64. package/build/assets/{useBasicWidgetState-gAw0WJ0t-BlUmDiku.js → useBasicWidgetState-zjZCXhqV-BNiFnFun.js} +1 -1
  65. package/build/assets/{useTextInputAutoExpand-CrQdinCr-BiEwhNXe.js → useTextInputAutoExpand-ox95UJrD-CZJQOtsK.js} +1 -1
  66. package/build/assets/{useUpdateUiValue-Bz-Z5Int-0QBs3uQx.js → useUpdateUiValue-Yj1mvLxf-DIZzUp3u.js} +1 -1
  67. package/build/assets/{withFullScreenWrapper-BKnfDWJg-dLKoL1-0.js → withFullScreenWrapper-Ca0mIjWH-ClODS1xe.js} +1 -1
  68. package/build/assets/worker-B65uO5d3-CuVvmm9s.js +106 -0
  69. package/build/electron/worker.js +9 -9
  70. package/build/index.html +1 -1
  71. package/package.json +12 -11
  72. package/wheels/stlite_lib-0.1.0-py3-none-any.whl +0 -0
  73. package/wheels/streamlit-1.50.0-cp313-none-any.whl +0 -0
  74. package/build/assets/data-grid-overlay-editor-DlwBF2tR-B5qTFESv.js +0 -1
  75. package/build/assets/index-BaDPYxKb-eLNjgO02.js +0 -1
  76. package/build/assets/index-Cwu3avS4-DiDBV46w.js +0 -188
  77. package/build/assets/worker-BOuMG9lT-DqkGm1hg.js +0 -106
@@ -1,106 +0,0 @@
1
- (function(){"use strict";function K(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var T,j;function G(){if(j)return T;j=1;function o(i){if(typeof i!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(i))}function c(i,e){for(var t="",s=0,a=-1,d=0,r,l=0;l<=i.length;++l){if(l<i.length)r=i.charCodeAt(l);else{if(r===47)break;r=47}if(r===47){if(!(a===l-1||d===1))if(a!==l-1&&d===2){if(t.length<2||s!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var g=t.lastIndexOf("/");if(g!==t.length-1){g===-1?(t="",s=0):(t=t.slice(0,g),s=t.length-1-t.lastIndexOf("/")),a=l,d=0;continue}}else if(t.length===2||t.length===1){t="",s=0,a=l,d=0;continue}}e&&(t.length>0?t+="/..":t="..",s=2)}else t.length>0?t+="/"+i.slice(a+1,l):t=i.slice(a+1,l),s=l-a-1;a=l,d=0}else r===46&&d!==-1?++d:d=-1}return t}function f(i,e){var t=e.dir||e.root,s=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+s:t+i+s:s}var u={resolve:function(){for(var e="",t=!1,s,a=arguments.length-1;a>=-1&&!t;a--){var d;a>=0?d=arguments[a]:(s===void 0&&(s=process.cwd()),d=s),o(d),d.length!==0&&(e=d+"/"+e,t=d.charCodeAt(0)===47)}return e=c(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(o(e),e.length===0)return".";var t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=c(e,!t),e.length===0&&!t&&(e="."),e.length>0&&s&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return o(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var s=arguments[t];o(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":u.normalize(e)},relative:function(e,t){if(o(e),o(t),e===t||(e=u.resolve(e),t=u.resolve(t),e===t))return"";for(var s=1;s<e.length&&e.charCodeAt(s)===47;++s);for(var a=e.length,d=a-s,r=1;r<t.length&&t.charCodeAt(r)===47;++r);for(var l=t.length,g=l-r,S=d<g?d:g,v=-1,_=0;_<=S;++_){if(_===S){if(g>S){if(t.charCodeAt(r+_)===47)return t.slice(r+_+1);if(_===0)return t.slice(r+_)}else d>S&&(e.charCodeAt(s+_)===47?v=_:_===0&&(v=0));break}var P=e.charCodeAt(s+_),C=t.charCodeAt(r+_);if(P!==C)break;P===47&&(v=_)}var b="";for(_=s+v+1;_<=a;++_)(_===a||e.charCodeAt(_)===47)&&(b.length===0?b+="..":b+="/..");return b.length>0?b+t.slice(r+v):(r+=v,t.charCodeAt(r)===47&&++r,t.slice(r))},_makeLong:function(e){return e},dirname:function(e){if(o(e),e.length===0)return".";for(var t=e.charCodeAt(0),s=t===47,a=-1,d=!0,r=e.length-1;r>=1;--r)if(t=e.charCodeAt(r),t===47){if(!d){a=r;break}}else d=!1;return a===-1?s?"/":".":s&&a===1?"//":e.slice(0,a)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');o(e);var s=0,a=-1,d=!0,r;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var l=t.length-1,g=-1;for(r=e.length-1;r>=0;--r){var S=e.charCodeAt(r);if(S===47){if(!d){s=r+1;break}}else g===-1&&(d=!1,g=r+1),l>=0&&(S===t.charCodeAt(l)?--l===-1&&(a=r):(l=-1,a=g))}return s===a?a=g:a===-1&&(a=e.length),e.slice(s,a)}else{for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===47){if(!d){s=r+1;break}}else a===-1&&(d=!1,a=r+1);return a===-1?"":e.slice(s,a)}},extname:function(e){o(e);for(var t=-1,s=0,a=-1,d=!0,r=0,l=e.length-1;l>=0;--l){var g=e.charCodeAt(l);if(g===47){if(!d){s=l+1;break}continue}a===-1&&(d=!1,a=l+1),g===46?t===-1?t=l:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||a===-1||r===0||r===1&&t===a-1&&t===s+1?"":e.slice(t,a)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return f("/",e)},parse:function(e){o(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var s=e.charCodeAt(0),a=s===47,d;a?(t.root="/",d=1):d=0;for(var r=-1,l=0,g=-1,S=!0,v=e.length-1,_=0;v>=d;--v){if(s=e.charCodeAt(v),s===47){if(!S){l=v+1;break}continue}g===-1&&(S=!1,g=v+1),s===46?r===-1?r=v:_!==1&&(_=1):r!==-1&&(_=-1)}return r===-1||g===-1||_===0||_===1&&r===g-1&&r===l+1?g!==-1&&(l===0&&a?t.base=t.name=e.slice(1,g):t.base=t.name=e.slice(l,g)):(l===0&&a?(t.name=e.slice(1,r),t.base=e.slice(1,g)):(t.name=e.slice(l,r),t.base=e.slice(l,g)),t.ext=e.slice(r,g)),l>0?t.dir=e.slice(0,l-1):a&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};return u.posix=u,T=u,T}var X=G(),E=K(X);const $="/home/pyodide",B=o=>`${$}/${o}`,R=(o,c)=>o==null?E.resolve($,c):E.resolve(B(o),c);function U(o,c){const f=E.normalize(c),i=E.dirname(f).split(/(?=\/)/);let e="";for(const t of i){e+=t;const s=o.FS.analyzePath(e);if(s.exists&&s.object){if(!o.FS.isDir(s.object.mode))throw new Error(`"${e}" already exists and is not a directory.`);continue}try{o.FS.mkdir(e)}catch(a){throw console.error(`Failed to create a directory "${e}"`),a}}}function z(o,c,f,u){U(o,c),o.FS.writeFile(c,f,u)}function Q(o,c,f){U(o,f),o.FS.rename(c,f)}const V="[",Y="(<=>!~",Z=";",ee="@",te=new RegExp(`[${V+Y+Z+ee}]`);function re(o){return o.split(te)[0].trim()}function I(o){return o.forEach(f=>{let u;try{u=new URL(f)}catch{return}if(u.protocol==="emfs:"||u.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${f})`)}),o.filter(f=>re(f)==="streamlit"?(console.warn(`Streamlit is specified in the requirements ("${f}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}async function oe(o){const c=typeof process<"u"&&process.versions?.node;let f;c?f=(await Promise.resolve().then(function(){return D})).sep:f="/";const u=o.slice(0,o.lastIndexOf(f)+1);if(o.endsWith(".mjs")){if(c){const i=await Promise.resolve().then(function(){return D}),e=await Promise.resolve().then(function(){return D});!o.includes("://")&&i.isAbsolute(o)&&(o=e.pathToFileURL(o).href)}return{scriptURL:o,pyodideIndexURL:u,isESModule:!0}}else return{scriptURL:o,pyodideIndexURL:u,isESModule:!1}}async function ne(o,c){const{scriptURL:f,pyodideIndexURL:u,isESModule:i}=await oe(o);let e;return i?e=(await import(f)).loadPyodide:(importScripts(f),e=self.loadPyodide),e({...c,indexURL:u})}function se(o){o.runPython(`
2
- import micropip
3
- micropip.add_mock_package(
4
- "pyarrow", "0.0.1",
5
- modules={
6
- "pyarrow": """
7
- __version__ = '0.0.1' # TODO: Update when releasing
8
-
9
-
10
- class Table:
11
- @classmethod
12
- def from_pandas(*args, **kwargs):
13
- raise NotImplementedError("stlite is not supporting this method.")
14
-
15
-
16
- class Array:
17
- def __init__(self, *args, **kwargs):
18
- raise NotImplementedError("stlite is not supporting PyArrow.Array")
19
-
20
-
21
- class ChunkedArray:
22
- def __init__(self, *args, **kwargs):
23
- raise NotImplementedError("stlite is not supporting PyArrow.ChunkedArray")
24
- """
25
- }
26
- )
27
- `)}function ae(o,c,f){const u=o.pyimport("pyodide"),i=r=>u.code.find_imports(r).toJs(),e=f.map(r=>i(r)),a=Array.from(new Set(e.flat())).filter(r=>!o.runPython(`__import__('importlib').util.find_spec('${r}')`)).map(r=>o._api._import_name_to_package_name.get(r)).filter(r=>r);if(a.length===0)return Promise.resolve();const d=o.loadPackage(a);return c(a,d),d.then()}function H(o,c,f){const u=ae(o,c,f);o.runPython(`
28
- def __set_module_auto_load_promise__(promise):
29
- from streamlit.runtime.scriptrunner import script_runner
30
- script_runner.moduleAutoLoadPromise = promise
31
-
32
- __set_module_auto_load_promise__`)(u)}async function ie(o,c,f){const{line:u,column:i}=f,e=o.Script(c);if(u>e._code_lines.length)return[];const t=e.complete.callKwargs({line:u,column:i,fuzzy:!1}),s=[];for(const a of t.toJs())s.push({name:a.name,type:a.$type,docstring:a.docstring.callKwargs({raw:!0}),complete:a.complete}),a.destroy();return s}let O=null;async function le(o,c,f,u,i){const{files:e,archives:t,requirements:s,prebuiltPackageNames:a,wheels:d,installs:r,pyodideUrl:l=o,streamlitConfig:g,idbfsMountpoints:S,nodefsMountpoints:v,moduleAutoLoad:_,env:P,languageServer:C}=f,b=I(s);if(O)i("Pyodide is already loaded."),console.debug("Pyodide is already loaded.");else{i("Loading Pyodide."),console.debug("Loading Pyodide."),O=ne(l,{stdout:console.log,stderr:console.error});const m=[];d&&(m.push(d.streamlit),m.push(d.stliteLib)),C&&m.push("jedi"),b.unshift(...m),console.debug("Loaded Pyodide")}const n=await O;if(P){console.debug("Setting environment variables",P);const m=n.pyimport("os");m.environ.update(n.toPy(P)),console.debug("Set environment variables",m.environ)}let p=!1;S&&(p=!0,S.forEach(m=>{n.FS.mkdir(m),n.FS.mount(n.FS.filesystems.IDBFS,{},m)}),await new Promise((m,y)=>{n.FS.syncfs(!0,k=>{k?y(k):m()})})),v&&Object.entries(v).forEach(([m,y])=>{n.FS.mkdir(m),n.FS.mount(n.FS.filesystems.NODEFS,{root:y},m)}),i("Mounting files.");const h=[];await Promise.all(Object.keys(e).map(async m=>{const y=e[m];m=R(c,m);let k;"url"in y?(console.debug(`Fetch a file from ${y.url}`),k=await fetch(y.url).then(A=>A.arrayBuffer()).then(A=>new Uint8Array(A))):k=y.data,console.debug(`Write a file "${m}"`),z(n,m,k,e.opts),m.endsWith(".py")&&h.push(m)})),i("Unpacking archives."),await Promise.all(t.map(async m=>{let y;"url"in m?(console.debug(`Fetch an archive from ${m.url}`),y=await fetch(m.url).then(pe=>pe.arrayBuffer())):y=m.buffer;const{format:k,options:A}=m;console.debug("Unpack an archive",{format:k,options:A}),n.unpackArchive(y,k,A)})),await n.loadPackage("micropip");const w=n.pyimport("micropip");if(i("Mocking some packages."),console.debug("Mock pyarrow"),se(n),console.debug("Mocked pyarrow"),i("Installing packages."),console.debug("Installing the prebuilt packages:",a),await n.loadPackage(a),console.debug("Installed the prebuilt packages"),console.debug("Installing the requirements:",b),await w.install.callKwargs(b,{keep_going:!0}),console.debug("Installed the requirements"),r&&(console.debug("Installing the additional requirements"),await Promise.all(r.map(({requirements:m,options:y})=>{const k=I(m);return console.debug("Installing the requirements:",k),w.install.callKwargs(k,y??{})}))),_){const m=h.map(y=>n.FS.readFile(y,{encoding:"utf8"}));H(n,u,m)}await n.runPythonAsync(`
33
- import importlib
34
- importlib.invalidate_caches()
35
- `),i("Loading streamlit package."),console.debug("Loading the Streamlit package"),await n.runPythonAsync(`
36
- import streamlit.runtime
37
- `),console.debug("Loaded the Streamlit package"),i("Setting up the loggers."),console.debug("Setting the loggers"),await n.runPythonAsync(`
38
- import logging
39
- import streamlit.logger
40
-
41
- streamlit.logger.get_logger = logging.getLogger
42
- streamlit.logger.setup_formatter = None
43
- streamlit.logger.update_formatter = lambda *a, **k: None
44
- streamlit.logger.set_log_level = lambda *a, **k: None
45
-
46
- for name in streamlit.logger._loggers.keys():
47
- if name == "root":
48
- name = "streamlit"
49
- logger = logging.getLogger(name)
50
- logger.propagate = True
51
- logger.handlers.clear()
52
- logger.setLevel(logging.NOTSET)
53
-
54
- streamlit.logger._loggers = {}
55
- `);const F=(m,y)=>{m>=40?console.error(y):m>=30?console.warn(y):m>=20?console.info(y):console.debug(y)},L=n.runPython(`
56
- def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
57
- class JsHandler(logging.Handler):
58
- def emit(self, record):
59
- msg = self.format(record)
60
- callback(record.levelno, msg)
61
-
62
-
63
- root_message_format = "%(levelname)s:%(name)s:%(message)s"
64
-
65
- root_logger = logging.getLogger()
66
- root_logger.handlers.clear()
67
- root_formatter = logging.Formatter(root_message_format)
68
- root_handler = JsHandler()
69
- root_handler.setFormatter(root_formatter)
70
- root_logger.addHandler(root_handler)
71
- root_logger.setLevel(logging.DEBUG)
72
-
73
- streamlit_logger = logging.getLogger("streamlit")
74
- streamlit_logger.propagate = False
75
- streamlit_logger.handlers.clear()
76
- streamlit_formatter = logging.Formatter(streamlit_message_format)
77
- streamlit_handler = JsHandler()
78
- streamlit_handler.setFormatter(streamlit_formatter)
79
- streamlit_logger.addHandler(streamlit_handler)
80
- streamlit_logger.setLevel(streamlit_level.upper())
81
-
82
- __setup_loggers__`),M=(g?.["logger.level"]??"INFO").toString(),ue=g?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(L(M,ue,F),console.debug("Set the loggers"),i("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await n.runPythonAsync(`
83
- import streamlit
84
-
85
- def is_cacheable_msg(msg):
86
- return False
87
-
88
- streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
89
- `),console.debug("Mocked some Streamlit functions"),p){i("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let m=!1;const y=()=>{console.debug("The script has finished. Syncing the filesystem."),m||(m=!0,n.FS.syncfs(!1,A=>{m=!1,A&&console.error(A)}))};(await n.runPython(`
90
- def __setup_script_finished_callback__(callback):
91
- from streamlit.runtime.app_session import AppSession
92
- from streamlit.runtime.scriptrunner import ScriptRunnerEvent
93
-
94
- def wrap_app_session_on_scriptrunner_event(original_method):
95
- def wrapped(self, *args, **kwargs):
96
- if "event" in kwargs:
97
- event = kwargs["event"]
98
- if event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS or event == ScriptRunnerEvent.SCRIPT_STOPPED_FOR_RERUN or event == ScriptRunnerEvent.SHUTDOWN:
99
- callback()
100
- return original_method(self, *args, **kwargs)
101
- return wrapped
102
-
103
- AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
104
-
105
- __setup_script_finished_callback__`))(y),console.debug("Set up the IndexedDB filesystem synchronizer")}console.debug("Setting up the Streamlit configuration");const{load_config_options:ge}=n.pyimport("stlite_lib.bootstrap"),fe={"browser.gatherUsageStats":!1,...g,"runner.fastReruns":!1},me=c!=null;ge(n.toPy(fe),me),console.debug("Set up the Streamlit configuration");let q;if(C){i("Loading auto-completion engine."),console.debug("Loading Jedi");try{q=await n.pyimport("jedi"),console.debug("Loaded Jedi")}catch(m){console.error("Failed to load Jedi:",m),q=void 0}}return{pyodide:n,micropip:w,jedi:q,initData:f}}async function J(o,c,f){const u=R(c,f);console.debug("Preparing the Streamlit environment");const{prepare:i}=o.pyimport("stlite_lib.bootstrap");i(u,[]),console.debug("Prepared the Streamlit environment"),console.debug("Booting up the Streamlit server");const t=o.pyimport("stlite_lib.server.Server")(u,c?B(c):void 0);return await t.start(),console.debug("Booted up the Streamlit server"),t}function N(o,c,f,u){function i(d){c({type:"event:loadProgress",data:{message:d}})}const e=(d,r)=>{const l=new MessageChannel;c({type:"event:moduleAutoLoad",data:{packagesToLoad:d}},[l.port2]),r.then(g=>{l.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:g}}),l.port1.close()}).catch(g=>{throw l.port1.postMessage({type:"moduleAutoLoad:error",error:g}),l.port1.close(),g})};let t=null,s=null;const a=async d=>{const r=d.data;if(r.type==="initData"){const n=r.data,p={...f,...n};console.debug("Initial data",p),t=le(o,u,p,e,i),t.then(({pyodide:h})=>(i("Booting up the Streamlit server."),s=J(h,u,p.entrypoint),s)).then(()=>{c({type:"event:loadFinished"})}).catch(h=>{console.error(h),c({type:"event:loadError",data:{error:h}})});return}if(!t)throw new Error("Pyodide initialization has not been started yet.");if(!s)throw new Error("Streamlit server has not been started yet.");const l=await t,g=l.pyodide,S=l.micropip,v=l.jedi,{moduleAutoLoad:_}=l.initData,P=await s,C=d.ports[0];function b(n){C.postMessage(n)}try{switch(r.type){case"reboot":{console.debug("Reboot the Streamlit server",r.data);const{entrypoint:n}=r.data;P.stop(),console.debug("Booting up the Streamlit server"),s=J(g,u,n),await s,console.debug("Booted up the Streamlit server"),b({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",r.data);const{path:n}=r.data;P.start_websocket(n,(p,h)=>{if(h){const w=p;try{const F=w.toJs(),L=F.buffer.slice(F.byteOffset,F.byteOffset+F.byteLength);c({type:"websocket:message",data:{payload:L}},[L])}finally{w.destroy()}}else c({type:"websocket:message",data:{payload:p}})}),b({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",r.data);const{payload:n}=r.data;P.receive_websocket_from_js(n);break}case"http:request":{console.debug("http:request",r.data);const{request:n}=r.data,p=(h,w,F)=>{const L=new Map(w.toJs()),M=F.toJs();console.debug({statusCode:h,headers:L,body:M}),b({type:"http:response",data:{response:{statusCode:h,headers:L,body:M}}})};P.receive_http_from_js(n.method,decodeURIComponent(n.path),n.headers,n.body,p);break}case"file:write":{const{path:n,data:p,opts:h}=r.data,w=R(u,n);_&&typeof p=="string"&&w.endsWith(".py")&&(console.debug(`Auto install the requirements in ${w}`),H(g,e,[p])),console.debug(`Write a file "${w}"`),z(g,w,p,h),b({type:"reply"});break}case"file:rename":{const{oldPath:n,newPath:p}=r.data,h=R(u,n),w=R(u,p);console.debug(`Rename "${h}" to ${w}`),Q(g,h,w),b({type:"reply"});break}case"file:unlink":{const{path:n}=r.data,p=R(u,n);console.debug(`Remove "${p}`),g.FS.unlink(p),b({type:"reply"});break}case"file:read":{const{path:n,opts:p}=r.data;console.debug(`Read "${n}"`);const h=g.FS.readFile(n,p);b({type:"reply:file:read",data:{content:h}});break}case"install":{const{requirements:n,options:p}=r.data,h=I(n);console.debug("Install the requirements:",h),await S.install.callKwargs(h,p??{}).then(()=>{console.debug("Successfully installed"),b({type:"reply"})});break}case"setEnv":{const{env:n}=r.data;g.pyimport("os").environ.update(g.toPy(n)),console.debug("Successfully set the environment variables",n),b({type:"reply"});break}case"code_completion":{if(!v)throw new Error("Jedi is not installed");const{code:n,line:p,column:h}=r.data,w=await ie(v,n,{line:p,column:h});b({type:"reply:code_completion",data:{codeCompletions:w}});break}case"run_python":{const{code:n}=r.data;console.debug("Run python code",n);const p=await g.runPythonAsync(n);let h;p instanceof g.ffi.PyProxy?(console.debug("The result is a PyProxy object"),h=p.toJs(),p.destroy(),console.debug("Converted the result to a JS object",h)):(h=p,console.debug("The result is a JS primitive",h)),b({type:"reply:run_python",data:{result:h}});break}}}catch(n){if(console.error(n),!(n instanceof Error))throw n;const p=new Error(n.message);p.name=n.name,p.stack=n.stack,b({type:"reply",error:p})}};return c({type:"event:envSetup"}),a}const W="abcdefghijklmnopqrstuvwxyz",ce=W.length;function de(o){let c="";for(let f=0;f<o;f++){const u=Math.floor(Math.random()*ce);c+=W[u]}return c}const x="https://cdn.jsdelivr.net/pyodide/v0.28.2/full/pyodide.mjs";if("postMessage"in self)self.onmessage=N(x,(o,c)=>c?self.postMessage(o,c):self.postMessage(o));else{const o=[];self.onconnect=c=>{let f;do f=de(4);while(o.includes(f));o.push(f),console.debug("SharedWorker mode.",{appId:f});const u=c.ports[0];u.onmessage=N(x,(i,e)=>e?u.postMessage(i,e):u.postMessage(i),void 0,f),u.start()}}var D=Object.freeze({__proto__:null})})();
106
- //# sourceMappingURL=worker-BOuMG9lT.js.map