@stlite/desktop 0.91.1 → 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 (76) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/bin/dump_artifacts.js +1 -1
  3. package/build/assets/{ErrorOutline.esm-BLjkDUgO-BiXylF9Q.js → ErrorOutline.esm-CBPRrcCq-C9-TIHiy.js} +1 -1
  4. package/build/assets/{FileDownload.esm-BP6Yw6Mo-BauI2spi.js → FileDownload.esm-zztsCQgv-C5piFaVt.js} +1 -1
  5. package/build/assets/{FileHelper-BCkX4r3T-DFMmrw88.js → FileHelper-D9iak492-B1kwMP-N.js} +1 -1
  6. package/build/assets/{FormClearHelper-Dgu5Halt-BxICjxpW.js → FormClearHelper-B-0AN2KG-drNJ-Zdq.js} +1 -1
  7. package/build/assets/{Hooks-BLb3umpI-9FUxV5o-.js → Hooks-BLb3umpI-CC08A2wx.js} +1 -1
  8. package/build/assets/{InputInstructions-yTnPUqJo-CoOBrVL7.js → InputInstructions-w5hPdqFC-DnPj3I4S.js} +1 -1
  9. package/build/assets/{Particles-Dlshfcc8-CNq_pZlo.js → Particles-DQoPZNo9-BWmBxXhd.js} +1 -1
  10. package/build/assets/{ProgressBar-bzD0ionS-CaMxdV67.js → ProgressBar-DlHaaa-z-DdC3oXz0.js} +1 -1
  11. package/build/assets/{Toolbar-Ba82LOXi-C-TMlOex.js → Toolbar-Cau3SOTY-cJ6wtM04.js} +1 -1
  12. package/build/assets/{base-input-DjjpNP8Y-DtsTHlXD.js → base-input-D-Fvddky-3QuAUeGB.js} +1 -1
  13. package/build/assets/{checkbox-i_07yegq-B7N8fYE1.js → checkbox-CjcIG3na-LB8a9-d7.js} +1 -1
  14. package/build/assets/{createSuper-Bj1hzAgo-DTBN9Cdm.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-szZSaHY-.js → downloader-DcCTL3Wz-DfHnsO-D.js} +1 -1
  17. package/build/assets/{es6--XPcqeHG-B7r8Rb2B.js → es6--XPcqeHG-CU-P5RWV.js} +2 -2
  18. package/build/assets/{iframeResizer.contentWindow-D_iySM1B-C8GQUol2.js → iframeResizer.contentWindow-vAQsQkcx-DjDgPkx5.js} +1 -1
  19. package/build/assets/{index-GJmmE3rK-9unNgOON.js → index--hiX6Uwv-DtKO9Hld.js} +1 -1
  20. package/build/assets/{index-DDqIvyop-CtB9mW2T.js → index-6t9Tq-Ab-Cc_ees8I.js} +1 -1
  21. package/build/assets/{index-EaQvJARH-BtsSVy_Q.js → index-B5h0Xgw3-CNFqm9ip.js} +1 -1
  22. package/build/assets/{index-B_WoYQrI-DzwQulx6.js → index-BDD6ManL-XC9-hEWd.js} +1 -1
  23. package/build/assets/{index-DhLLbarZ-JEJ3GjGo.js → index-BDtR3I-m-C6v_enzF.js} +1 -1
  24. package/build/assets/{index-0Kn1AVK2-CFHLqZQv.js → index-BNeCf0z6-eizg-dFz.js} +1 -1
  25. package/build/assets/{index-DUaAy90Q-XjKFsjy5.js → index-BXbsmcnm-D0BJVs7R.js} +1 -1
  26. package/build/assets/index-Bt2pmgaJ-ymksNLCl.js +198 -0
  27. package/build/assets/{index-CvM3pTat-B8q07d1y.js → index-Bx1YyC6x-bUWv5Yyf.js} +1 -1
  28. package/build/assets/{index-D3uELfdo.js → index-BxpEVUJq.js} +5 -5
  29. package/build/assets/{index-Bo7cn_f6-DkJNz7_c.js → index-C5FPtYYS-BTTgdUI2.js} +1 -1
  30. package/build/assets/{index-Ct4am237-CcMxDLpd.js → index-CL9VPrGG-DvzaBWYj.js} +1 -1
  31. package/build/assets/{index-BhasphER-CtCV9cV8.js → index-COXlYbHo-B2m8urCs.js} +1 -1
  32. package/build/assets/{index-CSKWQlNk-CT5sDNrq.js → index-CR_1rzEZ-DaqWZNME.js} +1 -1
  33. package/build/assets/{index-C_q9gQa7-DDnyjQrF.js → index-CUH8SI0g-CgCG3Tq7.js} +1 -1
  34. package/build/assets/{index-CugHuPaw-BlbAJDrs.js → index-CeUKVR_x-6fYziq6X.js} +1 -1
  35. package/build/assets/{index-BPtHoAnG-Bw2wANqW.js → index-D4OS_mB9-BwMU_oxN.js} +1 -1
  36. package/build/assets/{index-CTwTw5ms-DakzaYYn.js → index-D5GvvN8r-CL05rAIV.js} +1 -1
  37. package/build/assets/{index-B-TfdrsK-M9kXXCZC.js → index-D6OV4wQy-CQIpYALu.js} +1 -1
  38. package/build/assets/{index-B3KILbqX-BzOz8wK5.js → index-D8AcUh2z-BvmWAicd.js} +1 -1
  39. package/build/assets/{index-kYeUTGL3-OTlUcjkG.js → index-D9Ww6wIM-CODTYNKi.js} +1 -1
  40. package/build/assets/{index-BxHa0gYF-QN3i1uRA.js → index-D9xjkRNt-CFe8X0f3.js} +1 -1
  41. package/build/assets/{index-DMjPNVEr-D5adQnea.js → index-DBM8Q3zu-1UaS0Le1.js} +1 -1
  42. package/build/assets/{index-X1p_3J78-Vt5ccOoW.js → index-DEKI5kx7-B8lK1On8.js} +1 -1
  43. package/build/assets/{index-DOzur6Jw-BNtjcqTY.js → index-DVo6TdD5-Cigl7ucs.js} +1 -1
  44. package/build/assets/{index-B-p8cwea-D1OIlg5n.js → index-DYssp6us-ss1M0SKX.js} +1 -1
  45. package/build/assets/{index-D5JbiLwX-CJBgVo_3.js → index-Da8BucgM-CDMzLZMq.js} +1 -1
  46. package/build/assets/{index-vYM99bZC-_qzTrUih.js → index-DbIPIRRU-UJS7GIgX.js} +1 -1
  47. package/build/assets/{index-Fts1z9_x-20UUj5MC.js → index-DqAvSOqr-BCGTFud5.js} +1 -1
  48. package/build/assets/{index-NlD3wxQH-BRnDRGJG.js → index-Ds3R2kL1-CFh_Kz3Y.js} +1 -1
  49. package/build/assets/{index-p-pTZlQx-8zFcur2d.js → index-FbSORAjW-Lthz52ML.js} +1 -1
  50. package/build/assets/{index-CATwv37T-B7vouX3Y.js → index-JJq6JoHy-CX1Omp_x.js} +1 -1
  51. package/build/assets/{index-D0GcWpyX--juTltdu.js → index-OAJkEMe--vGYqEFkN.js} +1 -1
  52. package/build/assets/{index-DmB3SAP2-X6jwpSIv.js → index-PfjJDWy5-DkldmeJ8.js} +1 -1
  53. package/build/assets/{index-CAzavyuT-BhYS_U-d.js → index-kgY8PEpO-BUILDAe7.js} +1 -1
  54. package/build/assets/{index-DU9g9Sd6-Daa3488f.js → index-oFRA4JRK-kx0e_3zA.js} +1 -1
  55. package/build/assets/{index-BB-Jchwk-Bom7C4Yg.js → index-vdN_5NIh-CyyygayY.js} +1 -1
  56. package/build/assets/{inherits-Rx5YJbse-DVYurFFp.js → inherits-DIXnBNlu-DQhXiByk.js} +1 -1
  57. package/build/assets/{input-BDVeiWWL-DMiIFeVV.js → input-D3V-zfyu-Ca751_uU.js} +1 -1
  58. package/build/assets/{memory-B3L1Fctl-Bm8c-YGK.js → memory-B3L1Fctl-DNb7NEQl.js} +1 -1
  59. package/build/assets/{number-overlay-editor-BGJ9OD_Z-DIBxtO2v.js → number-overlay-editor-ChRMsdOl-C6ThLwiC.js} +1 -1
  60. package/build/assets/{sandbox-ChAzL-i--D3ngLCsZ.js → sandbox-ChAzL-i--FikCfyDW.js} +1 -1
  61. package/build/assets/{slicedToArray-DCtO1hP1-DNgLFFIn.js → slicedToArray-BPQXLGHq-C21Y2TxO.js} +1 -1
  62. package/build/assets/{timepicker-BTEFSiul-BiCu9n-C.js → timepicker-B0aGGgzd-sxFvpbfo.js} +1 -1
  63. package/build/assets/{uniqueId-DFKpdKNq-BgvPpMK3.js → uniqueId-MHj2wT7u-DPxsodx6.js} +1 -1
  64. package/build/assets/{useBasicWidgetState-DqA4I-I_-DtgK63iS.js → useBasicWidgetState-zjZCXhqV-BNiFnFun.js} +1 -1
  65. package/build/assets/{useTextInputAutoExpand-Di5cdshf-IDsnD2RC.js → useTextInputAutoExpand-ox95UJrD-CZJQOtsK.js} +1 -1
  66. package/build/assets/{useUpdateUiValue-09I2_X1f-DW6jbCsf.js → useUpdateUiValue-Yj1mvLxf-DIZzUp3u.js} +1 -1
  67. package/build/assets/{withFullScreenWrapper-WW0e_nhm-CAjrnrPK.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-BiH9JogL-SwK5dD6O.js +0 -1
  75. package/build/assets/index-GLEJ4uEg-Df22L041.js +0 -188
  76. package/build/assets/worker-BOuMG9lT-DqkGm1hg.js +0 -106
@@ -0,0 +1,106 @@
1
+ (function(){"use strict";function X(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var M,$;function Q(){if($)return M;$=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 u=t.lastIndexOf("/");if(u!==t.length-1){u===-1?(t="",s=0):(t=t.slice(0,u),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 m(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 g={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?".":g.normalize(e)},relative:function(e,t){if(o(e),o(t),e===t||(e=g.resolve(e),t=g.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,u=l-r,k=d<u?d:u,w=-1,_=0;_<=k;++_){if(_===k){if(u>k){if(t.charCodeAt(r+_)===47)return t.slice(r+_+1);if(_===0)return t.slice(r+_)}else d>k&&(e.charCodeAt(s+_)===47?w=_:_===0&&(w=0));break}var P=e.charCodeAt(s+_),C=t.charCodeAt(r+_);if(P!==C)break;P===47&&(w=_)}var b="";for(_=s+w+1;_<=a;++_)(_===a||e.charCodeAt(_)===47)&&(b.length===0?b+="..":b+="/..");return b.length>0?b+t.slice(r+w):(r+=w,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,u=-1;for(r=e.length-1;r>=0;--r){var k=e.charCodeAt(r);if(k===47){if(!d){s=r+1;break}}else u===-1&&(d=!1,u=r+1),l>=0&&(k===t.charCodeAt(l)?--l===-1&&(a=r):(l=-1,a=u))}return s===a?a=u: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 u=e.charCodeAt(l);if(u===47){if(!d){s=l+1;break}continue}a===-1&&(d=!1,a=l+1),u===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 m("/",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,u=-1,k=!0,w=e.length-1,_=0;w>=d;--w){if(s=e.charCodeAt(w),s===47){if(!k){l=w+1;break}continue}u===-1&&(k=!1,u=w+1),s===46?r===-1?r=w:_!==1&&(_=1):r!==-1&&(_=-1)}return r===-1||u===-1||_===0||_===1&&r===u-1&&r===l+1?u!==-1&&(l===0&&a?t.base=t.name=e.slice(1,u):t.base=t.name=e.slice(l,u)):(l===0&&a?(t.name=e.slice(1,r),t.base=e.slice(1,u)):(t.name=e.slice(l,r),t.base=e.slice(l,u)),t.ext=e.slice(r,u)),l>0?t.dir=e.slice(0,l-1):a&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};return g.posix=g,M=g,M}var V=Q(),E=X(V);const B="/home/pyodide",U=o=>`${B}/${o}`,R=(o,c)=>o==null?E.resolve(B,c):E.resolve(U(o),c);function z(o,c){const m=E.normalize(c),i=E.dirname(m).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 H(o,c,m,g){z(o,c),o.FS.writeFile(c,m,g)}function Y(o,c,m){z(o,m),o.FS.rename(c,m)}const Z="[",ee="(<=>!~",te=";",re="@",oe=new RegExp(`[${Z+ee+te+re}]`);function ne(o){return o.split(oe)[0].trim()}function T(o){return o.forEach(m=>{let g;try{g=new URL(m)}catch{return}if(g.protocol==="emfs:"||g.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${m})`)}),o.filter(m=>ne(m)==="streamlit"?(console.warn(`Streamlit is specified in the requirements ("${m}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}async function se(o){const c=typeof process<"u"&&process.versions?.node;let m;c?m=(await Promise.resolve().then(function(){return j})).sep:m="/";const g=o.slice(0,o.lastIndexOf(m)+1);if(o.endsWith(".mjs")){if(c){const i=await Promise.resolve().then(function(){return j}),e=await Promise.resolve().then(function(){return j});!o.includes("://")&&i.isAbsolute(o)&&(o=e.pathToFileURL(o).href)}return{scriptURL:o,pyodideIndexURL:g,isESModule:!0}}else return{scriptURL:o,pyodideIndexURL:g,isESModule:!1}}async function ae(o,c){const{scriptURL:m,pyodideIndexURL:g,isESModule:i}=await se(o);let e;return i?e=(await import(m)).loadPyodide:(importScripts(m),e=self.loadPyodide),e({...c,indexURL:g})}function ie(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 le(o,c,m){const g=o.pyimport("pyodide"),i=r=>g.code.find_imports(r).toJs(),e=m.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 J(o,c,m){const g=le(o,c,m);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__`)(g)}async function ce(o,c,m){const{line:g,column:i}=m,e=o.Script(c);if(g>e._code_lines.length)return[];const t=e.complete.callKwargs({line:g,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,N=Promise.resolve(),D=!1;async function de(o,c,m,g,i){const{files:e,archives:t,requirements:s,prebuiltPackageNames:a,wheels:d,installs:r,pyodideUrl:l=o,streamlitConfig:u,idbfsMountpoints:k,nodefsMountpoints:w,moduleAutoLoad:_,env:P,languageServer:C}=m,b=T(s);O?(i("Pyodide is already loaded."),console.debug("Pyodide is already loaded.")):(i("Loading Pyodide."),console.debug("Loading Pyodide."),O=ae(l,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide"));const n=await O;if(P){console.debug("Setting environment variables",P);const f=n.pyimport("os");f.environ.update(n.toPy(P)),console.debug("Set environment variables",f.environ)}let p=!1;k&&(p=!0,k.forEach(f=>{n.FS.mkdir(f),n.FS.mount(n.FS.filesystems.IDBFS,{},f)}),await new Promise((f,y)=>{n.FS.syncfs(!0,S=>{S?y(S):f()})})),w&&Object.entries(w).forEach(([f,y])=>{n.FS.mkdir(f),n.FS.mount(n.FS.filesystems.NODEFS,{root:y},f)}),i("Mounting files.");const h=[];await Promise.all(Object.keys(e).map(async f=>{const y=e[f];f=R(c,f);let S;"url"in y?(console.debug(`Fetch a file from ${y.url}`),S=await fetch(y.url).then(A=>A.arrayBuffer()).then(A=>new Uint8Array(A))):S=y.data,console.debug(`Write a file "${f}"`),H(n,f,S,e.opts),f.endsWith(".py")&&h.push(f)})),i("Unpacking archives."),await Promise.all(t.map(async f=>{let y;"url"in f?(console.debug(`Fetch an archive from ${f.url}`),y=await fetch(f.url).then(be=>be.arrayBuffer())):y=f.buffer;const{format:S,options:A}=f;console.debug("Unpack an archive",{format:S,options:A}),n.unpackArchive(y,S,A)})),await n.loadPackage("micropip");const v=n.pyimport("micropip");i("Mocking some packages."),console.debug("Mock pyarrow"),ie(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");const F=async()=>{console.debug("Installing the packages:",{requirements:b,systemPackagesInstalled:D});const f=[];D||(console.debug("System packages will be installed"),d&&(f.push(d.streamlit),f.push(d.stliteLib)),C&&f.push("jedi"));const y=[...f,...b];console.debug("Installing the packages:",y),await v.install.callKwargs(y,{keep_going:!0}),f.length>0&&(console.debug("Installed the system packages"),D=!0),console.debug("Installed the packages")},L=N.then(()=>F());if(N=L.catch(f=>{console.error("Package installation failed:",f)}),await L,r&&(console.debug("Installing the additional requirements"),await Promise.all(r.map(({requirements:f,options:y})=>{const S=T(f);return console.debug("Installing the requirements:",S),v.install.callKwargs(S,y??{})}))),_){const f=h.map(y=>n.FS.readFile(y,{encoding:"utf8"}));J(n,g,f)}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 I=(f,y)=>{f>=40?console.error(y):f>=30?console.warn(y):f>=20?console.info(y):console.debug(y)},fe=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__`),me=(u?.["logger.level"]??"INFO").toString(),pe=u?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(fe(me,pe,I),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 f=!1;const y=()=>{console.debug("The script has finished. Syncing the filesystem."),f||(f=!0,n.FS.syncfs(!1,A=>{f=!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:he}=n.pyimport("stlite_lib.bootstrap"),_e={"browser.gatherUsageStats":!1,...u,"runner.fastReruns":!1},ye=c!=null;he(n.toPy(_e),ye),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(f){console.error("Failed to load Jedi:",f),q=void 0}}return{pyodide:n,micropip:v,jedi:q,initData:m}}async function W(o,c,m){const g=R(c,m);console.debug("Preparing the Streamlit environment");const{prepare:i}=o.pyimport("stlite_lib.bootstrap");i(g,[]),console.debug("Prepared the Streamlit environment"),console.debug("Booting up the Streamlit server");const t=o.pyimport("stlite_lib.server.Server")(g,c?U(c):void 0);return await t.start(),console.debug("Booted up the Streamlit server"),t}function x(o,c,m,g){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(u=>{l.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:u}}),l.port1.close()}).catch(u=>{throw l.port1.postMessage({type:"moduleAutoLoad:error",error:u}),l.port1.close(),u})};let t=null,s=null;const a=async d=>{const r=d.data;if(r.type==="initData"){const n=r.data,p={...m,...n};console.debug("Initial data",p),t=de(o,g,p,e,i),t.then(({pyodide:h})=>(i("Booting up the Streamlit server."),s=W(h,g,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,u=l.pyodide,k=l.micropip,w=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=W(u,g,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 v=p;try{const F=v.toJs(),L=F.buffer.slice(F.byteOffset,F.byteOffset+F.byteLength);c({type:"websocket:message",data:{payload:L}},[L])}finally{v.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,v,F)=>{const L=new Map(v.toJs()),I=F.toJs();console.debug({statusCode:h,headers:L,body:I}),b({type:"http:response",data:{response:{statusCode:h,headers:L,body:I}}})};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,v=R(g,n);_&&typeof p=="string"&&v.endsWith(".py")&&(console.debug(`Auto install the requirements in ${v}`),J(u,e,[p])),console.debug(`Write a file "${v}"`),H(u,v,p,h),b({type:"reply"});break}case"file:rename":{const{oldPath:n,newPath:p}=r.data,h=R(g,n),v=R(g,p);console.debug(`Rename "${h}" to ${v}`),Y(u,h,v),b({type:"reply"});break}case"file:unlink":{const{path:n}=r.data,p=R(g,n);console.debug(`Remove "${p}`),u.FS.unlink(p),b({type:"reply"});break}case"file:read":{const{path:n,opts:p}=r.data;console.debug(`Read "${n}"`);const h=u.FS.readFile(n,p);b({type:"reply:file:read",data:{content:h}});break}case"install":{const{requirements:n,options:p}=r.data,h=T(n);console.debug("Install the requirements:",h),await k.install.callKwargs(h,p??{}).then(()=>{console.debug("Successfully installed"),b({type:"reply"})});break}case"setEnv":{const{env:n}=r.data;u.pyimport("os").environ.update(u.toPy(n)),console.debug("Successfully set the environment variables",n),b({type:"reply"});break}case"code_completion":{if(!w)throw new Error("Jedi is not installed");const{code:n,line:p,column:h}=r.data,v=await ce(w,n,{line:p,column:h});b({type:"reply:code_completion",data:{codeCompletions:v}});break}case"run_python":{const{code:n}=r.data;console.debug("Run python code",n);const p=await u.runPythonAsync(n);let h;p instanceof u.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}case"add_mock_package":{const{name:n,version:p,modules:h,persistent:v}=r.data;console.debug("Add a mock package:",{name:n,version:p,modules:h,persistent:v}),k.add_mock_package.callKwargs({name:n,version:p,modules:u.toPy(h),persistent:v}),b({type:"reply"});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 K="abcdefghijklmnopqrstuvwxyz",ue=K.length;function ge(o){let c="";for(let m=0;m<o;m++){const g=Math.floor(Math.random()*ue);c+=K[g]}return c}const G="https://cdn.jsdelivr.net/pyodide/v0.28.2/full/pyodide.mjs";if("postMessage"in self)self.onmessage=x(G,(o,c)=>c?self.postMessage(o,c):self.postMessage(o));else{const o=[];self.onconnect=c=>{let m;do m=ge(4);while(o.includes(m));o.push(m),console.debug("SharedWorker mode.",{appId:m});const g=c.ports[0];g.onmessage=x(G,(i,e)=>e?g.postMessage(i,e):g.postMessage(i),void 0,m),g.start()}}var j=Object.freeze({__proto__:null})})();
106
+ //# sourceMappingURL=worker-B65uO5d3.js.map
@@ -1,4 +1,4 @@
1
- var ae=Object.create;var H=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var ue=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var fe=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of le(e))!de.call(r,n)&&n!==t&&H(r,n,{get:()=>e[n],enumerable:!(o=ie(e,n))||o.enumerable});return r};var M=(r,e,t)=>(t=r!=null?ae(ce(r)):{},fe(e||!r||!r.__esModule?H(t,"default",{value:r,enumerable:!0}):t,r));var z=ue((Pe,W)=>{"use strict";function w(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function J(r,e){for(var t="",o=0,n=-1,i=0,s,l=0;l<=r.length;++l){if(l<r.length)s=r.charCodeAt(l);else{if(s===47)break;s=47}if(s===47){if(!(n===l-1||i===1))if(n!==l-1&&i===2){if(t.length<2||o!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var d=t.lastIndexOf("/");if(d!==t.length-1){d===-1?(t="",o=0):(t=t.slice(0,d),o=t.length-1-t.lastIndexOf("/")),n=l,i=0;continue}}else if(t.length===2||t.length===1){t="",o=0,n=l,i=0;continue}}e&&(t.length>0?t+="/..":t="..",o=2)}else t.length>0?t+="/"+r.slice(n+1,l):t=r.slice(n+1,l),o=l-n-1;n=l,i=0}else s===46&&i!==-1?++i:i=-1}return t}function ge(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 L={resolve:function(){for(var e="",t=!1,o,n=arguments.length-1;n>=-1&&!t;n--){var i;n>=0?i=arguments[n]:(o===void 0&&(o=process.cwd()),i=o),w(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=J(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(w(e),e.length===0)return".";var t=e.charCodeAt(0)===47,o=e.charCodeAt(e.length-1)===47;return e=J(e,!t),e.length===0&&!t&&(e="."),e.length>0&&o&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return w(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];w(o),o.length>0&&(e===void 0?e=o:e+="/"+o)}return e===void 0?".":L.normalize(e)},relative:function(e,t){if(w(e),w(t),e===t||(e=L.resolve(e),t=L.resolve(t),e===t))return"";for(var o=1;o<e.length&&e.charCodeAt(o)===47;++o);for(var n=e.length,i=n-o,s=1;s<t.length&&t.charCodeAt(s)===47;++s);for(var l=t.length,d=l-s,p=i<d?i:d,c=-1,f=0;f<=p;++f){if(f===p){if(d>p){if(t.charCodeAt(s+f)===47)return t.slice(s+f+1);if(f===0)return t.slice(s+f)}else i>p&&(e.charCodeAt(o+f)===47?c=f:f===0&&(c=0));break}var _=e.charCodeAt(o+f),E=t.charCodeAt(s+f);if(_!==E)break;_===47&&(c=f)}var S="";for(f=o+c+1;f<=n;++f)(f===n||e.charCodeAt(f)===47)&&(S.length===0?S+="..":S+="/..");return S.length>0?S+t.slice(s+c):(s+=c,t.charCodeAt(s)===47&&++s,t.slice(s))},_makeLong:function(e){return e},dirname:function(e){if(w(e),e.length===0)return".";for(var t=e.charCodeAt(0),o=t===47,n=-1,i=!0,s=e.length-1;s>=1;--s)if(t=e.charCodeAt(s),t===47){if(!i){n=s;break}}else i=!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');w(e);var o=0,n=-1,i=!0,s;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var l=t.length-1,d=-1;for(s=e.length-1;s>=0;--s){var p=e.charCodeAt(s);if(p===47){if(!i){o=s+1;break}}else d===-1&&(i=!1,d=s+1),l>=0&&(p===t.charCodeAt(l)?--l===-1&&(n=s):(l=-1,n=d))}return o===n?n=d:n===-1&&(n=e.length),e.slice(o,n)}else{for(s=e.length-1;s>=0;--s)if(e.charCodeAt(s)===47){if(!i){o=s+1;break}}else n===-1&&(i=!1,n=s+1);return n===-1?"":e.slice(o,n)}},extname:function(e){w(e);for(var t=-1,o=0,n=-1,i=!0,s=0,l=e.length-1;l>=0;--l){var d=e.charCodeAt(l);if(d===47){if(!i){o=l+1;break}continue}n===-1&&(i=!1,n=l+1),d===46?t===-1?t=l:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||n===-1||s===0||s===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 ge("/",e)},parse:function(e){w(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var o=e.charCodeAt(0),n=o===47,i;n?(t.root="/",i=1):i=0;for(var s=-1,l=0,d=-1,p=!0,c=e.length-1,f=0;c>=i;--c){if(o=e.charCodeAt(c),o===47){if(!p){l=c+1;break}continue}d===-1&&(p=!1,d=c+1),o===46?s===-1?s=c:f!==1&&(f=1):s!==-1&&(f=-1)}return s===-1||d===-1||f===0||f===1&&s===d-1&&s===l+1?d!==-1&&(l===0&&n?t.base=t.name=e.slice(1,d):t.base=t.name=e.slice(l,d)):(l===0&&n?(t.name=e.slice(1,s),t.base=e.slice(1,d)):(t.name=e.slice(l,s),t.base=e.slice(l,d)),t.ext=e.slice(s,d)),l>0?t.dir=e.slice(0,l-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};L.posix=L;W.exports=L});var q=require("node:worker_threads");var C=M(z(),1),B="/home/pyodide",x=r=>`${B}/${r}`,R=(r,e)=>r==null?C.default.resolve(B,e):C.default.resolve(x(r),e);function K(r,e){let t=C.default.normalize(e),n=C.default.dirname(t).split(/(?=\/)/),i="";for(let s of n){i+=s;let l=r.FS.analyzePath(i);if(l.exists&&l.object){if(!r.FS.isDir(l.object.mode))throw new Error(`"${i}" already exists and is not a directory.`);continue}try{r.FS.mkdir(i)}catch(d){throw console.error(`Failed to create a directory "${i}"`),d}}}function U(r,e,t,o){K(r,e),r.FS.writeFile(e,t,o)}function X(r,e,t){K(r,t),r.FS.rename(e,t)}var me="(<=>!~";var pe=new RegExp(`[${"["+me+";@"}]`);function he(r){return r.split(pe)[0].trim()}function I(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=>he(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 _e(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"),i=await import("node:url");!r.includes("://")&&n.isAbsolute(r)&&(r=i.pathToFileURL(r).href)}return{scriptURL:r,pyodideIndexURL:o,isESModule:!0}}else return{scriptURL:r,pyodideIndexURL:o,isESModule:!1}}async function G(r,e){let{scriptURL:t,pyodideIndexURL:o,isESModule:n}=await _e(r),i;return n?i=(await import(t)).loadPyodide:(importScripts(t),i=self.loadPyodide),i({...e,indexURL:o})}function Q(r){r.runPython(`
1
+ var de=Object.create;var J=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var pe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var he=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ge(e))!fe.call(r,n)&&n!==t&&J(r,n,{get:()=>e[n],enumerable:!(o=ue(e,n))||o.enumerable});return r};var I=(r,e,t)=>(t=r!=null?de(me(r)):{},he(e||!r||!r.__esModule?J(t,"default",{value:r,enumerable:!0}):t,r));var B=pe((Re,z)=>{"use strict";function w(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function W(r,e){for(var t="",o=0,n=-1,i=0,a,l=0;l<=r.length;++l){if(l<r.length)a=r.charCodeAt(l);else{if(a===47)break;a=47}if(a===47){if(!(n===l-1||i===1))if(n!==l-1&&i===2){if(t.length<2||o!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var u=t.lastIndexOf("/");if(u!==t.length-1){u===-1?(t="",o=0):(t=t.slice(0,u),o=t.length-1-t.lastIndexOf("/")),n=l,i=0;continue}}else if(t.length===2||t.length===1){t="",o=0,n=l,i=0;continue}}e&&(t.length>0?t+="/..":t="..",o=2)}else t.length>0?t+="/"+r.slice(n+1,l):t=r.slice(n+1,l),o=l-n-1;n=l,i=0}else a===46&&i!==-1?++i:i=-1}return t}function _e(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 L={resolve:function(){for(var e="",t=!1,o,n=arguments.length-1;n>=-1&&!t;n--){var i;n>=0?i=arguments[n]:(o===void 0&&(o=process.cwd()),i=o),w(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=W(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(w(e),e.length===0)return".";var t=e.charCodeAt(0)===47,o=e.charCodeAt(e.length-1)===47;return e=W(e,!t),e.length===0&&!t&&(e="."),e.length>0&&o&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return w(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];w(o),o.length>0&&(e===void 0?e=o:e+="/"+o)}return e===void 0?".":L.normalize(e)},relative:function(e,t){if(w(e),w(t),e===t||(e=L.resolve(e),t=L.resolve(t),e===t))return"";for(var o=1;o<e.length&&e.charCodeAt(o)===47;++o);for(var n=e.length,i=n-o,a=1;a<t.length&&t.charCodeAt(a)===47;++a);for(var l=t.length,u=l-a,h=i<u?i:u,c=-1,m=0;m<=h;++m){if(m===h){if(u>h){if(t.charCodeAt(a+m)===47)return t.slice(a+m+1);if(m===0)return t.slice(a+m)}else i>h&&(e.charCodeAt(o+m)===47?c=m:m===0&&(c=0));break}var _=e.charCodeAt(o+m),R=t.charCodeAt(a+m);if(_!==R)break;_===47&&(c=m)}var S="";for(m=o+c+1;m<=n;++m)(m===n||e.charCodeAt(m)===47)&&(S.length===0?S+="..":S+="/..");return S.length>0?S+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(w(e),e.length===0)return".";for(var t=e.charCodeAt(0),o=t===47,n=-1,i=!0,a=e.length-1;a>=1;--a)if(t=e.charCodeAt(a),t===47){if(!i){n=a;break}}else i=!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');w(e);var o=0,n=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var l=t.length-1,u=-1;for(a=e.length-1;a>=0;--a){var h=e.charCodeAt(a);if(h===47){if(!i){o=a+1;break}}else u===-1&&(i=!1,u=a+1),l>=0&&(h===t.charCodeAt(l)?--l===-1&&(n=a):(l=-1,n=u))}return o===n?n=u:n===-1&&(n=e.length),e.slice(o,n)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){o=a+1;break}}else n===-1&&(i=!1,n=a+1);return n===-1?"":e.slice(o,n)}},extname:function(e){w(e);for(var t=-1,o=0,n=-1,i=!0,a=0,l=e.length-1;l>=0;--l){var u=e.charCodeAt(l);if(u===47){if(!i){o=l+1;break}continue}n===-1&&(i=!1,n=l+1),u===46?t===-1?t=l:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||n===-1||a===0||a===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 _e("/",e)},parse:function(e){w(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var o=e.charCodeAt(0),n=o===47,i;n?(t.root="/",i=1):i=0;for(var a=-1,l=0,u=-1,h=!0,c=e.length-1,m=0;c>=i;--c){if(o=e.charCodeAt(c),o===47){if(!h){l=c+1;break}continue}u===-1&&(h=!1,u=c+1),o===46?a===-1?a=c:m!==1&&(m=1):a!==-1&&(m=-1)}return a===-1||u===-1||m===0||m===1&&a===u-1&&a===l+1?u!==-1&&(l===0&&n?t.base=t.name=e.slice(1,u):t.base=t.name=e.slice(l,u)):(l===0&&n?(t.name=e.slice(1,a),t.base=e.slice(1,u)):(t.name=e.slice(l,a),t.base=e.slice(l,u)),t.ext=e.slice(a,u)),l>0?t.dir=e.slice(0,l-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};L.posix=L;z.exports=L});var q=require("node:worker_threads");var C=I(B(),1),K="/home/pyodide",x=r=>`${K}/${r}`,E=(r,e)=>r==null?C.default.resolve(K,e):C.default.resolve(x(r),e);function X(r,e){let t=C.default.normalize(e),n=C.default.dirname(t).split(/(?=\/)/),i="";for(let a of n){i+=a;let l=r.FS.analyzePath(i);if(l.exists&&l.object){if(!r.FS.isDir(l.object.mode))throw new Error(`"${i}" already exists and is not a directory.`);continue}try{r.FS.mkdir(i)}catch(u){throw console.error(`Failed to create a directory "${i}"`),u}}}function U(r,e,t,o){X(r,e),r.FS.writeFile(e,t,o)}function G(r,e,t){X(r,t),r.FS.rename(e,t)}var ye="(<=>!~";var be=new RegExp(`[${"["+ye+";@"}]`);function ve(r){return r.split(be)[0].trim()}function M(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=>ve(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 Se(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"),i=await import("node:url");!r.includes("://")&&n.isAbsolute(r)&&(r=i.pathToFileURL(r).href)}return{scriptURL:r,pyodideIndexURL:o,isESModule:!0}}else return{scriptURL:r,pyodideIndexURL:o,isESModule:!1}}async function Q(r,e){let{scriptURL:t,pyodideIndexURL:o,isESModule:n}=await Se(r),i;return n?i=(await import(t)).loadPyodide:(importScripts(t),i=self.loadPyodide),i({...e,indexURL:o})}function V(r){r.runPython(`
2
2
  import micropip
3
3
  micropip.add_mock_package(
4
4
  "pyarrow", "0.0.1",
@@ -24,17 +24,17 @@ class ChunkedArray:
24
24
  """
25
25
  }
26
26
  )
27
- `)}function ye(r,e,t){let o=r.pyimport("pyodide"),n=c=>o.code.find_imports(c).toJs(),i=t.map(c=>n(c)),d=Array.from(new Set(i.flat())).filter(c=>!r.runPython(`__import__('importlib').util.find_spec('${c}')`)).map(c=>r._api._import_name_to_package_name.get(c)).filter(c=>c);if(d.length===0)return Promise.resolve();let p=r.loadPackage(d);return e(d,p),p.then()}function $(r,e,t){let o=ye(r,e,t);r.runPython(`
27
+ `)}function we(r,e,t){let o=r.pyimport("pyodide"),n=c=>o.code.find_imports(c).toJs(),i=t.map(c=>n(c)),u=Array.from(new Set(i.flat())).filter(c=>!r.runPython(`__import__('importlib').util.find_spec('${c}')`)).map(c=>r._api._import_name_to_package_name.get(c)).filter(c=>c);if(u.length===0)return Promise.resolve();let h=r.loadPackage(u);return e(u,h),h.then()}function $(r,e,t){let o=we(r,e,t);r.runPython(`
28
28
  def __set_module_auto_load_promise__(promise):
29
29
  from streamlit.runtime.scriptrunner import script_runner
30
30
  script_runner.moduleAutoLoadPromise = promise
31
31
 
32
- __set_module_auto_load_promise__`)(o)}async function V(r,e,t){let{line:o,column:n}=t,i=r.Script(e);if(o>i._code_lines.length)return[];let s=i.complete.callKwargs({line:o,column:n,fuzzy:!1}),l=[];for(let d of s.toJs())l.push({name:d.name,type:d.$type,docstring:d.docstring.callKwargs({raw:!0}),complete:d.complete}),d.destroy();return l}var j=null;async function be(r,e,t,o,n){let{files:i,archives:s,requirements:l,prebuiltPackageNames:d,wheels:p,installs:c,pyodideUrl:f=r,streamlitConfig:_,idbfsMountpoints:E,nodefsMountpoints:S,moduleAutoLoad:N,env:k,languageServer:O}=t,b=I(l);if(j)n("Pyodide is already loaded."),console.debug("Pyodide is already loaded.");else{n("Loading Pyodide."),console.debug("Loading Pyodide."),j=G(f,{stdout:console.log,stderr:console.error});let u=[];p&&(u.push(p.streamlit),u.push(p.stliteLib)),O&&u.push("jedi"),b.unshift(...u),console.debug("Loaded Pyodide")}let a=await j;if(k){console.debug("Setting environment variables",k);let u=a.pyimport("os");u.environ.update(a.toPy(k)),console.debug("Set environment variables",u.environ)}let g=!1;E&&(g=!0,E.forEach(u=>{a.FS.mkdir(u),a.FS.mount(a.FS.filesystems.IDBFS,{},u)}),await new Promise((u,h)=>{a.FS.syncfs(!0,v=>{v?h(v):u()})})),S&&Object.entries(S).forEach(([u,h])=>{a.FS.mkdir(u),a.FS.mount(a.FS.filesystems.NODEFS,{root:h},u)}),n("Mounting files.");let m=[];await Promise.all(Object.keys(i).map(async u=>{let h=i[u];u=R(e,u);let v;"url"in h?(console.debug(`Fetch a file from ${h.url}`),v=await fetch(h.url).then(P=>P.arrayBuffer()).then(P=>new Uint8Array(P))):v=h.data,console.debug(`Write a file "${u}"`),U(a,u,v,i.opts),u.endsWith(".py")&&m.push(u)})),n("Unpacking archives."),await Promise.all(s.map(async u=>{let h;"url"in u?(console.debug(`Fetch an archive from ${u.url}`),h=await fetch(u.url).then(se=>se.arrayBuffer())):h=u.buffer;let{format:v,options:P}=u;console.debug("Unpack an archive",{format:v,options:P}),a.unpackArchive(h,v,P)})),await a.loadPackage("micropip");let y=a.pyimport("micropip");if(n("Mocking some packages."),console.debug("Mock pyarrow"),Q(a),console.debug("Mocked pyarrow"),n("Installing packages."),console.debug("Installing the prebuilt packages:",d),await a.loadPackage(d),console.debug("Installed the prebuilt packages"),console.debug("Installing the requirements:",b),await y.install.callKwargs(b,{keep_going:!0}),console.debug("Installed the requirements"),c&&(console.debug("Installing the additional requirements"),await Promise.all(c.map(({requirements:u,options:h})=>{let v=I(u);return console.debug("Installing the requirements:",v),y.install.callKwargs(v,h??{})}))),N){let u=m.map(h=>a.FS.readFile(h,{encoding:"utf8"}));$(a,o,u)}await a.runPythonAsync(`
32
+ __set_module_auto_load_promise__`)(o)}async function Y(r,e,t){let{line:o,column:n}=t,i=r.Script(e);if(o>i._code_lines.length)return[];let a=i.complete.callKwargs({line:o,column:n,fuzzy:!1}),l=[];for(let u of a.toJs())l.push({name:u.name,type:u.$type,docstring:u.docstring.callKwargs({raw:!0}),complete:u.complete}),u.destroy();return l}var j=null,Z=Promise.resolve(),H=!1;async function ke(r,e,t,o,n){let{files:i,archives:a,requirements:l,prebuiltPackageNames:u,wheels:h,installs:c,pyodideUrl:m=r,streamlitConfig:_,idbfsMountpoints:R,nodefsMountpoints:S,moduleAutoLoad:N,env:P,languageServer:O}=t,b=M(l);j?(n("Pyodide is already loaded."),console.debug("Pyodide is already loaded.")):(n("Loading Pyodide."),console.debug("Loading Pyodide."),j=Q(m,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide"));let s=await j;if(P){console.debug("Setting environment variables",P);let d=s.pyimport("os");d.environ.update(s.toPy(P)),console.debug("Set environment variables",d.environ)}let g=!1;R&&(g=!0,R.forEach(d=>{s.FS.mkdir(d),s.FS.mount(s.FS.filesystems.IDBFS,{},d)}),await new Promise((d,p)=>{s.FS.syncfs(!0,v=>{v?p(v):d()})})),S&&Object.entries(S).forEach(([d,p])=>{s.FS.mkdir(d),s.FS.mount(s.FS.filesystems.NODEFS,{root:p},d)}),n("Mounting files.");let f=[];await Promise.all(Object.keys(i).map(async d=>{let p=i[d];d=E(e,d);let v;"url"in p?(console.debug(`Fetch a file from ${p.url}`),v=await fetch(p.url).then(k=>k.arrayBuffer()).then(k=>new Uint8Array(k))):v=p.data,console.debug(`Write a file "${d}"`),U(s,d,v,i.opts),d.endsWith(".py")&&f.push(d)})),n("Unpacking archives."),await Promise.all(a.map(async d=>{let p;"url"in d?(console.debug(`Fetch an archive from ${d.url}`),p=await fetch(d.url).then(ce=>ce.arrayBuffer())):p=d.buffer;let{format:v,options:k}=d;console.debug("Unpack an archive",{format:v,options:k}),s.unpackArchive(p,v,k)})),await s.loadPackage("micropip");let y=s.pyimport("micropip");n("Mocking some packages."),console.debug("Mock pyarrow"),V(s),console.debug("Mocked pyarrow"),n("Installing packages."),console.debug("Installing the prebuilt packages:",u),await s.loadPackage(u),console.debug("Installed the prebuilt packages");let A=async()=>{console.debug("Installing the packages:",{requirements:b,systemPackagesInstalled:H});let d=[];H||(console.debug("System packages will be installed"),h&&(d.push(h.streamlit),d.push(h.stliteLib)),O&&d.push("jedi"));let p=[...d,...b];console.debug("Installing the packages:",p),await y.install.callKwargs(p,{keep_going:!0}),d.length>0&&(console.debug("Installed the system packages"),H=!0),console.debug("Installed the packages")},F=Z.then(()=>A());if(Z=F.catch(d=>{console.error("Package installation failed:",d)}),await F,c&&(console.debug("Installing the additional requirements"),await Promise.all(c.map(({requirements:d,options:p})=>{let v=M(d);return console.debug("Installing the requirements:",v),y.install.callKwargs(v,p??{})}))),N){let d=f.map(p=>s.FS.readFile(p,{encoding:"utf8"}));$(s,o,d)}await s.runPythonAsync(`
33
33
  import importlib
34
34
  importlib.invalidate_caches()
35
- `),n("Loading streamlit package."),console.debug("Loading the Streamlit package"),await a.runPythonAsync(`
35
+ `),n("Loading streamlit package."),console.debug("Loading the Streamlit package"),await s.runPythonAsync(`
36
36
  import streamlit.runtime
37
- `),console.debug("Loaded the Streamlit package"),n("Setting up the loggers."),console.debug("Setting the loggers"),await a.runPythonAsync(`
37
+ `),console.debug("Loaded the Streamlit package"),n("Setting up the loggers."),console.debug("Setting the loggers"),await s.runPythonAsync(`
38
38
  import logging
39
39
  import streamlit.logger
40
40
 
@@ -52,7 +52,7 @@ for name in streamlit.logger._loggers.keys():
52
52
  logger.setLevel(logging.NOTSET)
53
53
 
54
54
  streamlit.logger._loggers = {}
55
- `);let A=(u,h)=>{u>=40?console.error(h):u>=30?console.warn(h):u>=20?console.info(h):console.debug(h)},F=a.runPython(`
55
+ `);let T=(d,p)=>{d>=40?console.error(p):d>=30?console.warn(p):d>=20?console.info(p):console.debug(p)},oe=s.runPython(`
56
56
  def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
57
57
  class JsHandler(logging.Handler):
58
58
  def emit(self, record):
@@ -79,14 +79,14 @@ def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
79
79
  streamlit_logger.addHandler(streamlit_handler)
80
80
  streamlit_logger.setLevel(streamlit_level.upper())
81
81
 
82
- __setup_loggers__`),T=(_?.["logger.level"]??"INFO").toString(),te=_?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(F(T,te,A),console.debug("Set the loggers"),n("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await a.runPythonAsync(`
82
+ __setup_loggers__`),ne=(_?.["logger.level"]??"INFO").toString(),se=_?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(oe(ne,se,T),console.debug("Set the loggers"),n("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await s.runPythonAsync(`
83
83
  import streamlit
84
84
 
85
85
  def is_cacheable_msg(msg):
86
86
  return False
87
87
 
88
88
  streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
89
- `),console.debug("Mocked some Streamlit functions"),g){n("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let u=!1,h=()=>{console.debug("The script has finished. Syncing the filesystem."),u||(u=!0,a.FS.syncfs(!1,P=>{u=!1,P&&console.error(P)}))};(await a.runPython(`
89
+ `),console.debug("Mocked some Streamlit functions"),g){n("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let d=!1,p=()=>{console.debug("The script has finished. Syncing the filesystem."),d||(d=!0,s.FS.syncfs(!1,k=>{d=!1,k&&console.error(k)}))};(await s.runPython(`
90
90
  def __setup_script_finished_callback__(callback):
91
91
  from streamlit.runtime.app_session import AppSession
92
92
  from streamlit.runtime.scriptrunner import ScriptRunnerEvent
@@ -102,4 +102,4 @@ def __setup_script_finished_callback__(callback):
102
102
 
103
103
  AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
104
104
 
105
- __setup_script_finished_callback__`))(h),console.debug("Set up the IndexedDB filesystem synchronizer")}console.debug("Setting up the Streamlit configuration");let{load_config_options:re}=a.pyimport("stlite_lib.bootstrap"),oe={"browser.gatherUsageStats":!1,..._,"runner.fastReruns":!1},ne=e!=null;re(a.toPy(oe),ne),console.debug("Set up the Streamlit configuration");let D;if(O){n("Loading auto-completion engine."),console.debug("Loading Jedi");try{D=await a.pyimport("jedi"),console.debug("Loaded Jedi")}catch(u){console.error("Failed to load Jedi:",u),D=void 0}}return{pyodide:a,micropip:y,jedi:D,initData:t}}async function Y(r,e,t){let o=R(e,t);console.debug("Preparing the Streamlit environment");let{prepare:n}=r.pyimport("stlite_lib.bootstrap");n(o,[]),console.debug("Prepared the Streamlit environment"),console.debug("Booting up the Streamlit server");let s=r.pyimport("stlite_lib.server.Server")(o,e?x(e):void 0);return await s.start(),console.debug("Booted up the Streamlit server"),s}function Z(r,e,t,o){function n(p){e({type:"event:loadProgress",data:{message:p}})}let i=(p,c)=>{let f=new MessageChannel;e({type:"event:moduleAutoLoad",data:{packagesToLoad:p}},[f.port2]),c.then(_=>{f.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:_}}),f.port1.close()}).catch(_=>{throw f.port1.postMessage({type:"moduleAutoLoad:error",error:_}),f.port1.close(),_})},s=null,l=null,d=async p=>{let c=p.data;if(c.type==="initData"){let a=c.data,g={...t,...a};console.debug("Initial data",g),s=be(r,o,g,i,n),s.then(({pyodide:m})=>(n("Booting up the Streamlit server."),l=Y(m,o,g.entrypoint),l)).then(()=>{e({type:"event:loadFinished"})}).catch(m=>{console.error(m),e({type:"event:loadError",data:{error:m}})});return}if(!s)throw new Error("Pyodide initialization has not been started yet.");if(!l)throw new Error("Streamlit server has not been started yet.");let f=await s,_=f.pyodide,E=f.micropip,S=f.jedi,{moduleAutoLoad:N}=f.initData,k=await l,O=p.ports[0];function b(a){O.postMessage(a)}try{switch(c.type){case"reboot":{console.debug("Reboot the Streamlit server",c.data);let{entrypoint:a}=c.data;k.stop(),console.debug("Booting up the Streamlit server"),l=Y(_,o,a),await l,console.debug("Booted up the Streamlit server"),b({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",c.data);let{path:a}=c.data;k.start_websocket(a,(g,m)=>{if(m){let y=g;try{let A=y.toJs(),F=A.buffer.slice(A.byteOffset,A.byteOffset+A.byteLength);e({type:"websocket:message",data:{payload:F}},[F])}finally{y.destroy()}}else e({type:"websocket:message",data:{payload:g}})}),b({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",c.data);let{payload:a}=c.data;k.receive_websocket_from_js(a);break}case"http:request":{console.debug("http:request",c.data);let{request:a}=c.data,g=(m,y,A)=>{let F=new Map(y.toJs()),T=A.toJs();console.debug({statusCode:m,headers:F,body:T}),b({type:"http:response",data:{response:{statusCode:m,headers:F,body:T}}})};k.receive_http_from_js(a.method,decodeURIComponent(a.path),a.headers,a.body,g);break}case"file:write":{let{path:a,data:g,opts:m}=c.data,y=R(o,a);N&&typeof g=="string"&&y.endsWith(".py")&&(console.debug(`Auto install the requirements in ${y}`),$(_,i,[g])),console.debug(`Write a file "${y}"`),U(_,y,g,m),b({type:"reply"});break}case"file:rename":{let{oldPath:a,newPath:g}=c.data,m=R(o,a),y=R(o,g);console.debug(`Rename "${m}" to ${y}`),X(_,m,y),b({type:"reply"});break}case"file:unlink":{let{path:a}=c.data,g=R(o,a);console.debug(`Remove "${g}`),_.FS.unlink(g),b({type:"reply"});break}case"file:read":{let{path:a,opts:g}=c.data;console.debug(`Read "${a}"`);let m=_.FS.readFile(a,g);b({type:"reply:file:read",data:{content:m}});break}case"install":{let{requirements:a,options:g}=c.data,m=I(a);console.debug("Install the requirements:",m),await E.install.callKwargs(m,g??{}).then(()=>{console.debug("Successfully installed"),b({type:"reply"})});break}case"setEnv":{let{env:a}=c.data;_.pyimport("os").environ.update(_.toPy(a)),console.debug("Successfully set the environment variables",a),b({type:"reply"});break}case"code_completion":{if(!S)throw new Error("Jedi is not installed");let{code:a,line:g,column:m}=c.data,y=await V(S,a,{line:g,column:m});b({type:"reply:code_completion",data:{codeCompletions:y}});break}case"run_python":{let{code:a}=c.data;console.debug("Run python code",a);let g=await _.runPythonAsync(a),m;g instanceof _.ffi.PyProxy?(console.debug("The result is a PyProxy object"),m=g.toJs(),g.destroy(),console.debug("Converted the result to a JS object",m)):(m=g,console.debug("The result is a JS primitive",m)),b({type:"reply:run_python",data:{result:m}});break}}}catch(a){if(console.error(a),!(a instanceof Error))throw a;let g=new Error(a.message);g.name=a.name,g.stack=a.stack,b({type:"reply",error:g})}};return e({type:"event:envSetup"}),d}function ee(){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 ve=r=>{console.debug("[worker thread] postMessage from worker",r),q.parentPort?.postMessage(r)},Se=Z(process.env.PYODIDE_URL,ve,{nodefsMountpoints:ee()});q.parentPort?.on("message",({data:r,port:e})=>{console.debug("[worker thread] parentPort.onMessage",{data:r,port:e}),Se({data:r,ports:[e]})});
105
+ __setup_script_finished_callback__`))(p),console.debug("Set up the IndexedDB filesystem synchronizer")}console.debug("Setting up the Streamlit configuration");let{load_config_options:ae}=s.pyimport("stlite_lib.bootstrap"),ie={"browser.gatherUsageStats":!1,..._,"runner.fastReruns":!1},le=e!=null;ae(s.toPy(ie),le),console.debug("Set up the Streamlit configuration");let D;if(O){n("Loading auto-completion engine."),console.debug("Loading Jedi");try{D=await s.pyimport("jedi"),console.debug("Loaded Jedi")}catch(d){console.error("Failed to load Jedi:",d),D=void 0}}return{pyodide:s,micropip:y,jedi:D,initData:t}}async function ee(r,e,t){let o=E(e,t);console.debug("Preparing the Streamlit environment");let{prepare:n}=r.pyimport("stlite_lib.bootstrap");n(o,[]),console.debug("Prepared the Streamlit environment"),console.debug("Booting up the Streamlit server");let a=r.pyimport("stlite_lib.server.Server")(o,e?x(e):void 0);return await a.start(),console.debug("Booted up the Streamlit server"),a}function te(r,e,t,o){function n(h){e({type:"event:loadProgress",data:{message:h}})}let i=(h,c)=>{let m=new MessageChannel;e({type:"event:moduleAutoLoad",data:{packagesToLoad:h}},[m.port2]),c.then(_=>{m.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:_}}),m.port1.close()}).catch(_=>{throw m.port1.postMessage({type:"moduleAutoLoad:error",error:_}),m.port1.close(),_})},a=null,l=null,u=async h=>{let c=h.data;if(c.type==="initData"){let s=c.data,g={...t,...s};console.debug("Initial data",g),a=ke(r,o,g,i,n),a.then(({pyodide:f})=>(n("Booting up the Streamlit server."),l=ee(f,o,g.entrypoint),l)).then(()=>{e({type:"event:loadFinished"})}).catch(f=>{console.error(f),e({type:"event:loadError",data:{error:f}})});return}if(!a)throw new Error("Pyodide initialization has not been started yet.");if(!l)throw new Error("Streamlit server has not been started yet.");let m=await a,_=m.pyodide,R=m.micropip,S=m.jedi,{moduleAutoLoad:N}=m.initData,P=await l,O=h.ports[0];function b(s){O.postMessage(s)}try{switch(c.type){case"reboot":{console.debug("Reboot the Streamlit server",c.data);let{entrypoint:s}=c.data;P.stop(),console.debug("Booting up the Streamlit server"),l=ee(_,o,s),await l,console.debug("Booted up the Streamlit server"),b({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",c.data);let{path:s}=c.data;P.start_websocket(s,(g,f)=>{if(f){let y=g;try{let A=y.toJs(),F=A.buffer.slice(A.byteOffset,A.byteOffset+A.byteLength);e({type:"websocket:message",data:{payload:F}},[F])}finally{y.destroy()}}else e({type:"websocket:message",data:{payload:g}})}),b({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",c.data);let{payload:s}=c.data;P.receive_websocket_from_js(s);break}case"http:request":{console.debug("http:request",c.data);let{request:s}=c.data,g=(f,y,A)=>{let F=new Map(y.toJs()),T=A.toJs();console.debug({statusCode:f,headers:F,body:T}),b({type:"http:response",data:{response:{statusCode:f,headers:F,body:T}}})};P.receive_http_from_js(s.method,decodeURIComponent(s.path),s.headers,s.body,g);break}case"file:write":{let{path:s,data:g,opts:f}=c.data,y=E(o,s);N&&typeof g=="string"&&y.endsWith(".py")&&(console.debug(`Auto install the requirements in ${y}`),$(_,i,[g])),console.debug(`Write a file "${y}"`),U(_,y,g,f),b({type:"reply"});break}case"file:rename":{let{oldPath:s,newPath:g}=c.data,f=E(o,s),y=E(o,g);console.debug(`Rename "${f}" to ${y}`),G(_,f,y),b({type:"reply"});break}case"file:unlink":{let{path:s}=c.data,g=E(o,s);console.debug(`Remove "${g}`),_.FS.unlink(g),b({type:"reply"});break}case"file:read":{let{path:s,opts:g}=c.data;console.debug(`Read "${s}"`);let f=_.FS.readFile(s,g);b({type:"reply:file:read",data:{content:f}});break}case"install":{let{requirements:s,options:g}=c.data,f=M(s);console.debug("Install the requirements:",f),await R.install.callKwargs(f,g??{}).then(()=>{console.debug("Successfully installed"),b({type:"reply"})});break}case"setEnv":{let{env:s}=c.data;_.pyimport("os").environ.update(_.toPy(s)),console.debug("Successfully set the environment variables",s),b({type:"reply"});break}case"code_completion":{if(!S)throw new Error("Jedi is not installed");let{code:s,line:g,column:f}=c.data,y=await Y(S,s,{line:g,column:f});b({type:"reply:code_completion",data:{codeCompletions:y}});break}case"run_python":{let{code:s}=c.data;console.debug("Run python code",s);let g=await _.runPythonAsync(s),f;g instanceof _.ffi.PyProxy?(console.debug("The result is a PyProxy object"),f=g.toJs(),g.destroy(),console.debug("Converted the result to a JS object",f)):(f=g,console.debug("The result is a JS primitive",f)),b({type:"reply:run_python",data:{result:f}});break}case"add_mock_package":{let{name:s,version:g,modules:f,persistent:y}=c.data;console.debug("Add a mock package:",{name:s,version:g,modules:f,persistent:y}),R.add_mock_package.callKwargs({name:s,version:g,modules:_.toPy(f),persistent:y}),b({type:"reply"});break}}}catch(s){if(console.error(s),!(s instanceof Error))throw s;let g=new Error(s.message);g.name=s.name,g.stack=s.stack,b({type:"reply",error:g})}};return e({type:"event:envSetup"}),u}function re(){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 Pe=r=>{console.debug("[worker thread] postMessage from worker",r),q.parentPort?.postMessage(r)},Ae=te(process.env.PYODIDE_URL,Pe,{nodefsMountpoints:re()});q.parentPort?.on("message",({data:r,port:e})=>{console.debug("[worker thread] parentPort.onMessage",{data:r,port:e}),Ae({data:r,ports:[e]})});
package/build/index.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
  <title>Stlite Desktop</title>
8
8
  <!-- The Content-Security-Policy setting will be injected at build time. See vite.config.js. -->
9
- <script type="module" crossorigin src="/assets/index-D3uELfdo.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-BxpEVUJq.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="/assets/index-Bjs8n_uU.css">
11
11
  </head>
12
12
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stlite/desktop",
3
- "version": "0.91.1",
3
+ "version": "0.91.2",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -63,11 +63,11 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@emotion/babel-plugin": "^11.13.5",
66
- "@eslint/js": "^9.32.0",
66
+ "@eslint/js": "^9.39.1",
67
67
  "@stlite/common": "^0.90.1",
68
68
  "@stlite/devutils": "^0.90.0",
69
- "@stlite/kernel": "^0.94.0",
70
- "@stlite/react": "^0.1.0",
69
+ "@stlite/kernel": "^0.97.1",
70
+ "@stlite/react": "^0.1.1",
71
71
  "@types/react": "^18.2.0",
72
72
  "@types/react-dom": "^18.2.0",
73
73
  "@types/yargs": "^17.0.35",
@@ -76,26 +76,27 @@
76
76
  "cross-env": "^10.1.0",
77
77
  "electron": "34.3.0",
78
78
  "electron-reload": "^2.0.0-alpha.1",
79
- "esbuild": "^0.27.0",
80
- "eslint": "^9.32.0",
81
- "eslint-plugin-prettier": "^5.5.3",
79
+ "esbuild": "^0.27.1",
80
+ "eslint": "^9.39.1",
81
+ "eslint-config-prettier": "^10.1.8",
82
+ "eslint-plugin-prettier": "^5.5.4",
82
83
  "eslint-plugin-react": "^7.37.5",
83
84
  "eslint-plugin-react-hooks": "^7.0.1",
84
- "glob": "^12.0.0",
85
+ "glob": "^13.0.0",
85
86
  "node-html-parser": "^7.0.1",
86
87
  "prettier": "^3.6.2",
87
88
  "react": "^18.2.0",
88
89
  "react-dom": "^18.2.0",
89
- "rimraf": "^6.0.1",
90
+ "rimraf": "^6.1.2",
90
91
  "rollup-plugin-visualizer": "^5.12.0",
91
92
  "sass": "^1.90.0",
92
93
  "superstruct": "^2.0.2",
93
94
  "ts-node": "^10.9.1",
94
95
  "tsx": "^4.19.2",
95
96
  "typescript": "^5.9.2",
96
- "typescript-eslint": "^8.38.0",
97
+ "typescript-eslint": "^8.46.2",
97
98
  "vite": "^7.1.5",
98
- "vitest": "^4.0.13",
99
+ "vitest": "^4.0.15",
99
100
  "wait-on": "^8.0.1",
100
101
  "winston": "^3.13.0"
101
102
  },
@@ -1 +0,0 @@
1
- import{r,b as J}from"./index-D3uELfdo.js";import{V as R,E as Q,m as U,G as Z,c as ee,k as te,a as re}from"./index-GLEJ4uEg-Df22L041.js";import"./withFullScreenWrapper-WW0e_nhm-CAjrnrPK.js";import"./Toolbar-Ba82LOXi-C-TMlOex.js";import"./FormClearHelper-Dgu5Halt-BxICjxpW.js";import"./sprintf-D5E86llw-6tzWM3a-.js";import"./checkbox-i_07yegq-B7N8fYE1.js";import"./createDownloadLinkElement-CbRjLJ8e-NbV49OP9.js";import"./slicedToArray-DCtO1hP1-DNgLFFIn.js";import"./inherits-Rx5YJbse-DVYurFFp.js";import"./createSuper-Bj1hzAgo-DTBN9Cdm.js";import"./FileDownload.esm-BP6Yw6Mo-BauI2spi.js";const ie=()=>t=>t.targetX,ae=()=>t=>t.targetY,oe=()=>t=>t.targetWidth,ne=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,le=()=>t=>Math.max(0,(t.targetHeight-28)/2),de=re("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[ae(),"px"],"d19meir1-1":[ie(),"px"],"d19meir1-2":[oe(),"px"],"d19meir1-3":[ne(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[le(),"px"]}});function ce(){const[t,o]=r.useState();return[t??void 0,o]}function ue(){const[t,o]=ce(),[a,f]=r.useState(0),[m,b]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const n=new IntersectionObserver(s=>{s.length!==0&&b(s[0].isIntersecting)},{threshold:1});return n.observe(t),()=>n.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let n;const s=()=>{const{right:k}=t.getBoundingClientRect();f(g=>Math.min(g+window.innerWidth-k-10,0)),n=requestAnimationFrame(s)};return n=requestAnimationFrame(s),()=>{n!==void 0&&cancelAnimationFrame(n)}},[t,m]);const C=r.useMemo(()=>({transform:`translateX(${a}px)`}),[a]);return{ref:o,style:C}}const we=t=>{const{target:o,content:a,onFinishEditing:f,forceEditMode:m,initialValue:b,imageEditorOverride:C,markdownDivCreateNode:n,highlight:s,className:k,theme:g,id:K,cell:p,bloom:S,portalElementRef:P,validateCell:v,getCellRenderer:M,provideEditor:N,isOutsideClick:W,customEventTarget:X,activation:x}=t,[l,Y]=r.useState(m?a:void 0),w=r.useRef(l??a);w.current=l??a;const[h,F]=r.useState(()=>v===void 0?!0:!(R(a)&&v?.(p,a,w.current)===!1)),c=r.useCallback((e,i)=>{f(h?e:void 0,i)},[h,f]),q=r.useCallback(e=>{if(v!==void 0&&e!==void 0&&R(e)){const i=v(p,e,w.current);i===!1?F(!1):(typeof i=="object"&&(e=i),F(!0))}Y(e)},[p,v]),E=r.useRef(!1),u=r.useRef(void 0),B=r.useCallback(()=>{c(l,[0,0]),E.current=!0},[l,c]),j=r.useCallback((e,i)=>{c(e,i??u.current??[0,0]),E.current=!0},[c]),L=r.useCallback(async e=>{let i=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),u.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),u.current=[0,1],i=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),u.current=[e.shiftKey?-1:1,0],i=!0),window.setTimeout(()=>{!E.current&&u.current!==void 0&&(c(i?l:void 0,u.current),E.current=!0)},0)},[c,l]),O=l??a,[d,$]=r.useMemo(()=>{if(Q(a))return[];const e={...a,location:p,activation:x},i=N?.(e);return i!==void 0?[i,!1]:[M(a)?.provideEditor?.(e),!1]},[p,a,M,N,x]),{ref:z,style:_}=ue();let I=!0,V,A=!0,y;if(d!==void 0){I=d.disablePadding!==!0,A=d.disableStyling!==!0;const e=U(d);e&&(y=d.styleOverride);const i=e?d.editor:d;V=r.createElement(i,{portalElementRef:P,isHighlighted:s,activation:x,onChange:q,value:O,initialValue:b,onFinishedEditing:j,validatedSelection:R(O)?O.selectionRange:void 0,forceEditMode:m,target:o,imageEditorOverride:C,markdownDivCreateNode:n,isValid:h,theme:g})}y={...y,..._};const G=P?.current??document.getElementById("portal");if(G===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please, either provide a portalElementRef or add `<div id="portal" />` as the last child of your `<body>`.'),null;let D=A?"gdg-style":"gdg-unstyle";h||(D+=" gdg-invalid"),I&&(D+=" gdg-pad");const H=S?.[0]??1,T=S?.[1]??1;return J.createPortal(r.createElement(Z.Provider,{value:g},r.createElement(ee,{style:te(g),className:k,onClickOutside:B,isOutsideClick:W,customEventTarget:X},r.createElement(de,{ref:z,id:K,className:D,style:y,as:$===!0?"label":void 0,targetX:o.x-H,targetY:o.y-T,targetWidth:o.width+H*2,targetHeight:o.height+T*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:L},V)))),G)};export{we as default};