@stlite/desktop 0.82.0 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dump_artifacts.js +15 -15
- package/build/assets/ErrorOutline.esm-w3SotGgg.js +1 -0
- package/build/assets/{FileDownload.esm-Bzb3HjS9.js → FileDownload.esm-DNaG7mhy.js} +1 -1
- package/build/assets/{FileHelper-BNpeYRlH.js → FileHelper-DoUfoupm.js} +4 -4
- package/build/assets/{FormClearHelper-DxeY-rII.js → FormClearHelper-DI9KwuTl.js} +1 -1
- package/build/assets/{Hooks-BOkao1bO.js → Hooks-BRr-mPDr.js} +1 -1
- package/build/assets/{InputInstructions-DuxSO2sS.js → InputInstructions-mpv25B9R.js} +1 -1
- package/build/assets/MaterialSymbols-Rounded.DsbC8sYI.woff2 +0 -0
- package/build/assets/{ProgressBar-xr2SnNK1.js → ProgressBar-DalMRT-4.js} +2 -2
- package/build/assets/{RenderInPortalIfExists-D-C7LcEp.js → RenderInPortalIfExists-CfX3LXlx.js} +1 -1
- package/build/assets/Toolbar-1r13KE9d.js +1 -0
- package/build/assets/{base-input-NsRtpzFx.js → base-input-BJ4WO1K3.js} +4 -4
- package/build/assets/{checkbox-Dj0lswiB.js → checkbox-COr-UunX.js} +1 -1
- package/build/assets/{createSuper-Ipqc67nc.js → createSuper-BD8Om4of.js} +1 -1
- package/build/assets/{data-grid-overlay-editor-BDv7jlce.js → data-grid-overlay-editor-DUKLRWRf.js} +1 -1
- package/build/assets/{downloader-CaOAUbUF.js → downloader-K2yu2VBv.js} +1 -1
- package/build/assets/{es6-BZHzmZtr.js → es6-CqFPgbyx.js} +2 -2
- package/build/assets/{iframeResizer.contentWindow-CHGlD-N9.js → iframeResizer.contentWindow-CYxwXEKD.js} +1 -1
- package/build/assets/{index-D1dbR74e.js → index-B7nFcP4b.js} +1 -1
- package/build/assets/index-BBSx627c.js +12 -0
- package/build/assets/index-BTWAYrEA.js +1 -0
- package/build/assets/index-BVYhtbL7.js +1 -0
- package/build/assets/{index-CTC0h65f.js → index-BY2_5dEP.js} +1 -1
- package/build/assets/index-Bga7N97D.js +1 -0
- package/build/assets/index-CBHSzhtV.js +1 -0
- package/build/assets/index-CG0w2Shn.js +3 -0
- package/build/assets/index-CJj5-jL6.js +2 -0
- package/build/assets/index-CTKSPDuj.js +3 -0
- package/build/assets/{index-OxGwEg3m.js → index-CVPZJuoC.js} +144 -144
- package/build/assets/{index-BTv0oYZW.js → index-CbGVTpRX.js} +1 -1
- package/build/assets/{index-B-ykjfbX.js → index-CgIf_789.js} +260 -233
- package/build/assets/index-CgaLKbNA.js +1 -0
- package/build/assets/index-Chg_Z_Ai.js +1 -0
- package/build/assets/{index-B4X2D_eW.js → index-Cy3sYumn.js} +1 -1
- package/build/assets/{index-CUa9G_2w.js → index-D4DI0i3_.js} +2 -2
- package/build/assets/index-DAFr20lD.js +1 -0
- package/build/assets/{index-DhYvQko1.js → index-DAyJZph2.js} +1 -1
- package/build/assets/{index-CA7xtrC9.js → index-DHvjd_NM.js} +8 -8
- package/build/assets/{index-GJHR2pBi.js → index-DIR2fiU3.js} +1 -1
- package/build/assets/{index-B-LSEdUZ.js → index-DJ9ENWJ6.js} +1 -1
- package/build/assets/{index-DrIrAYez.js → index-DZGNB9Z2.js} +2 -2
- package/build/assets/{index-Cns8y39_.js → index-D_aTbShm.js} +1 -1
- package/build/assets/{index-Cyc3gr_v.js → index-DbWqdg_N.js} +2 -2
- package/build/assets/index-DhpOSNWU.js +1 -0
- package/build/assets/{index-Cp10Db30.js → index-Dkkplt7E.js} +1 -1
- package/build/assets/{index-DvUGK7b6.js → index-FQnDjdgN.js} +1 -1
- package/build/assets/index-GeTKqk0L.js +1 -0
- package/build/assets/{index-CRx6-P3W.js → index-QxKGd3KZ.js} +1 -1
- package/build/assets/{index-DJZ72tug.js → index-TIqCq-vm.js} +1 -1
- package/build/assets/{index-By6Q65Pf.js → index-WJi2gbUd.js} +1 -1
- package/build/assets/index-bXFpQSEH.js +1 -0
- package/build/assets/index-dOLNZa0u.js +1 -0
- package/build/assets/index-h6PFbOmO.js +188 -0
- package/build/assets/{index-Dk-OPVLJ.js → index-oIFkiM-w.js} +1 -1
- package/build/assets/index-qPiigGKE.js +1 -0
- package/build/assets/index-xsH4HHeE.js +6 -0
- package/build/assets/{index.5L7agjmb.css → index.Bqb_jNud.css} +1 -1
- package/build/assets/{inherits-BbfuKc-R.js → inherits-DtR6i4OG.js} +1 -1
- package/build/assets/{input-CkptI290.js → input-9qldoJOB.js} +2 -2
- package/build/assets/{memory-BDEJOdDh.js → memory-Cy3-iIgx.js} +1 -1
- package/build/assets/mergeWith-DdD-5zWL.js +1 -0
- package/build/assets/{number-overlay-editor-cmVGLaYJ.js → number-overlay-editor-DmP64vrs.js} +1 -1
- package/build/assets/{sandbox-VVt-VWM8.js → sandbox-DzhFXmWd.js} +1 -1
- package/build/assets/{slicedToArray-HZKHLTaA.js → slicedToArray-CNrowD0v.js} +2 -2
- package/build/assets/{textarea-Cy6EVtfz.js → textarea-Bql4j-_M.js} +2 -2
- package/build/assets/{timepicker-DQlSkM-Q.js → timepicker-sEhIITXf.js} +2 -2
- package/build/assets/{uniqueId-Dka3DuQQ.js → uniqueId-DfRnwW3q.js} +1 -1
- package/build/assets/{useBasicWidgetState-Bm5AJWX7.js → useBasicWidgetState-DJ8kXLgn.js} +1 -1
- package/build/assets/{useOnInputChange-C3lvbUNp.js → useOnInputChange-CZX_IkMh.js} +1 -1
- package/build/assets/withFullScreenWrapper-DBlEST2L.js +1 -0
- package/build/assets/{worker-eTai8nRu.js → worker-CXcujS1W.js} +10 -10
- package/build/electron/worker.js +8 -8
- package/build/index.html +2 -2
- package/package.json +8 -7
- package/wheels/streamlit-1.45.1-cp312-none-any.whl +0 -0
- package/build/assets/MaterialSymbols-Rounded.BFCIvovZ.woff2 +0 -0
- package/build/assets/Toolbar-CJ0mD5An.js +0 -1
- package/build/assets/index-7fVMC6lw.js +0 -1
- package/build/assets/index-BfXMsSNA.js +0 -188
- package/build/assets/index-BtnOdn6v.js +0 -1
- package/build/assets/index-BwTtx5nh.js +0 -1
- package/build/assets/index-C7CxGGAJ.js +0 -3
- package/build/assets/index-CHhIqZol.js +0 -1
- package/build/assets/index-Ck_7L8T4.js +0 -3
- package/build/assets/index-CnyprtY_.js +0 -1
- package/build/assets/index-CoJDuQ5Y.js +0 -1
- package/build/assets/index-D9Fv1oGe.js +0 -1
- package/build/assets/index-D9ZJ5ysG.js +0 -1
- package/build/assets/index-DMVOLuV0.js +0 -1
- package/build/assets/index-DX_vgtQT.js +0 -1
- package/build/assets/index-DbTxB5ik.js +0 -12
- package/build/assets/index-DeRs-vXN.js +0 -1
- package/build/assets/index-SCb8nZ6H.js +0 -2
- package/build/assets/index-t--hEgTQ.js +0 -6
- package/build/assets/index-zPhSbuEH.js +0 -1
- package/build/assets/mergeWith-D2cULMN8.js +0 -1
- package/build/assets/withFullScreenWrapper-CEJUxUJC.js +0 -1
- package/wheels/streamlit-1.44.1-cp312-none-any.whl +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function Q(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var E,j;function Y(){if(j)return E;j=1;function o(
|
|
1
|
+
function Q(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var E,j;function Y(){if(j)return E;j=1;function o(l){if(typeof l!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(l))}function c(l,e){for(var t="",i=0,s=-1,n=0,r,a=0;a<=l.length;++a){if(a<l.length)r=l.charCodeAt(a);else{if(r===47)break;r=47}if(r===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var p=t.lastIndexOf("/");if(p!==t.length-1){p===-1?(t="",i=0):(t=t.slice(0,p),i=t.length-1-t.lastIndexOf("/")),s=a,n=0;continue}}else if(t.length===2||t.length===1){t="",i=0,s=a,n=0;continue}}e&&(t.length>0?t+="/..":t="..",i=2)}else t.length>0?t+="/"+l.slice(s+1,a):t=l.slice(s+1,a),i=a-s-1;s=a,n=0}else r===46&&n!==-1?++n:n=-1}return t}function d(l,e){var t=e.dir||e.root,i=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+i:t+l+i:i}var m={resolve:function(){for(var e="",t=!1,i,s=arguments.length-1;s>=-1&&!t;s--){var n;s>=0?n=arguments[s]:(i===void 0&&(i=process.cwd()),n=i),o(n),n.length!==0&&(e=n+"/"+e,t=n.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,i=e.charCodeAt(e.length-1)===47;return e=c(e,!t),e.length===0&&!t&&(e="."),e.length>0&&i&&(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 i=arguments[t];o(i),i.length>0&&(e===void 0?e=i:e+="/"+i)}return e===void 0?".":m.normalize(e)},relative:function(e,t){if(o(e),o(t),e===t||(e=m.resolve(e),t=m.resolve(t),e===t))return"";for(var i=1;i<e.length&&e.charCodeAt(i)===47;++i);for(var s=e.length,n=s-i,r=1;r<t.length&&t.charCodeAt(r)===47;++r);for(var a=t.length,p=a-r,S=n<p?n:p,b=-1,h=0;h<=S;++h){if(h===S){if(p>S){if(t.charCodeAt(r+h)===47)return t.slice(r+h+1);if(h===0)return t.slice(r+h)}else n>S&&(e.charCodeAt(i+h)===47?b=h:h===0&&(b=0));break}var v=e.charCodeAt(i+h),g=t.charCodeAt(r+h);if(v!==g)break;v===47&&(b=h)}var _="";for(h=i+b+1;h<=s;++h)(h===s||e.charCodeAt(h)===47)&&(_.length===0?_+="..":_+="/..");return _.length>0?_+t.slice(r+b):(r+=b,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),i=t===47,s=-1,n=!0,r=e.length-1;r>=1;--r)if(t=e.charCodeAt(r),t===47){if(!n){s=r;break}}else n=!1;return s===-1?i?"/":".":i&&s===1?"//":e.slice(0,s)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');o(e);var i=0,s=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,p=-1;for(r=e.length-1;r>=0;--r){var S=e.charCodeAt(r);if(S===47){if(!n){i=r+1;break}}else p===-1&&(n=!1,p=r+1),a>=0&&(S===t.charCodeAt(a)?--a===-1&&(s=r):(a=-1,s=p))}return i===s?s=p:s===-1&&(s=e.length),e.slice(i,s)}else{for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===47){if(!n){i=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":e.slice(i,s)}},extname:function(e){o(e);for(var t=-1,i=0,s=-1,n=!0,r=0,a=e.length-1;a>=0;--a){var p=e.charCodeAt(a);if(p===47){if(!n){i=a+1;break}continue}s===-1&&(n=!1,s=a+1),p===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===i+1?"":e.slice(t,s)},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 d("/",e)},parse:function(e){o(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var i=e.charCodeAt(0),s=i===47,n;s?(t.root="/",n=1):n=0;for(var r=-1,a=0,p=-1,S=!0,b=e.length-1,h=0;b>=n;--b){if(i=e.charCodeAt(b),i===47){if(!S){a=b+1;break}continue}p===-1&&(S=!1,p=b+1),i===46?r===-1?r=b:h!==1&&(h=1):r!==-1&&(h=-1)}return r===-1||p===-1||h===0||h===1&&r===p-1&&r===a+1?p!==-1&&(a===0&&s?t.base=t.name=e.slice(1,p):t.base=t.name=e.slice(a,p)):(a===0&&s?(t.name=e.slice(1,r),t.base=e.slice(1,p)):(t.name=e.slice(a,r),t.base=e.slice(a,p)),t.ext=e.slice(r,p)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};return m.posix=m,E=m,E}var Z=Y(),R=Q(Z);const O="/home/pyodide",N=o=>`${O}/${o}`,F=(o,c)=>o==null?R.resolve(O,c):R.resolve(N(o),c);function z(o,c){const d=R.normalize(c),l=R.dirname(d).split("/"),e=[];for(const t of l){e.push(t);const i=e.join("/");if(o.FS.analyzePath(i).exists){if(o.FS.isDir(i))throw new Error(`"${i}" already exists and is not a directory.`);continue}try{o.FS.mkdir(i)}catch(s){throw console.error(`Failed to create a directory "${i}"`),s}}}function q(o,c,d,m){z(o,c),o.FS.writeFile(c,d,m)}function ee(o,c,d){z(o,d),o.FS.rename(c,d)}const te="[",re="(<=>!~",oe=";",ne="@",se=new RegExp(`[${te+re+oe+ne}]`);function ie(o){return o.split(se)[0].trim()}function U(o){return o.forEach(d=>{let m;try{m=new URL(d)}catch{return}if(m.protocol==="emfs:"||m.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${d})`)}),o.filter(d=>ie(d)==="streamlit"?(console.warn(`Streamlit is specified in the requirements ("${d}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}async function ae(o){var l;const c=typeof process<"u"&&((l=process.versions)==null?void 0:l.node);let d;c?d=(await import("./__vite-browser-external-9wXp6ZBx.js")).sep:d="/";const m=o.slice(0,o.lastIndexOf(d)+1);if(o.endsWith(".mjs")){if(c){const e=await import("./__vite-browser-external-9wXp6ZBx.js"),t=await import("./__vite-browser-external-9wXp6ZBx.js");!o.includes("://")&&e.isAbsolute(o)&&(o=t.pathToFileURL(o).href)}return{scriptURL:o,pyodideIndexURL:m,isESModule:!0}}else return{scriptURL:o,pyodideIndexURL:m,isESModule:!1}}async function le(o,c){const{scriptURL:d,pyodideIndexURL:m,isESModule:l}=await ae(o);let e;return l?e=(await import(d)).loadPyodide:(importScripts(d),e=self.loadPyodide),e({...c,indexURL:m})}function ce(o){o.runPython(`
|
|
2
2
|
import micropip
|
|
3
3
|
micropip.add_mock_package(
|
|
4
4
|
"pyarrow", "0.0.1",
|
|
@@ -24,7 +24,7 @@ class ChunkedArray:
|
|
|
24
24
|
"""
|
|
25
25
|
}
|
|
26
26
|
)
|
|
27
|
-
`)}function de(o,
|
|
27
|
+
`)}function de(o,c,d){const m=o.pyimport("pyodide"),l=r=>m.code.find_imports(r).toJs(),e=d.map(r=>l(r)),s=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(s.length===0)return Promise.resolve();const n=o.loadPackage(s);return c(s,n),n.then()}function $(o,c,d){const m=de(o,c,d);o.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
|
|
@@ -131,12 +131,12 @@ def get_code_completions(code: str, current_line_number: int, cursor_offset: int
|
|
|
131
131
|
# Convert results to JSON so that we can use it in the worker
|
|
132
132
|
converter = lsp_converters.get_converter()
|
|
133
133
|
return json.dumps(converter.unstructure(suggestions, unstructure_as=CompletionList))
|
|
134
|
-
`)},me=async(o,
|
|
134
|
+
`)},me=async(o,c)=>{let d;try{if(d=c.globals.get("get_code_completions"),!d)return console.error("Can not generate suggestions list, the get_code_completions function is not defined"),{items:[]};const m=d(o.code,o.line,o.column);return m?JSON.parse(m):{items:[]}}catch(m){return console.error(m),{items:[]}}finally{d&&d.constructor.name==="PyProxy"&&d.destroy()}};let I=null;async function ge(o,c,d,m,l){const{entrypoint:e,files:t,archives:i,requirements:s,prebuiltPackageNames:n,wheels:r,pyodideUrl:a=o,streamlitConfig:p,idbfsMountpoints:S,nodefsMountpoints:b,moduleAutoLoad:h,env:v,languageServer:g}=d,_=U(s);if(I)l("Pyodide is already loaded."),console.debug("Pyodide is already loaded.");else{l("Loading Pyodide."),console.debug("Loading Pyodide."),I=le(a,{stdout:console.log,stderr:console.error});const f=[];r&&(f.push(r.streamlit),f.push(r.stliteLib)),g&&(f.push("jedi"),f.push("lsprotocol")),_.unshift(...f),console.debug("Loaded Pyodide")}const u=await I;if(v){console.debug("Setting environment variables",v);const f=u.pyimport("os");f.environ.update(u.toPy(v)),console.debug("Set environment variables",f.environ)}let w=!1;S&&(w=!0,S.forEach(f=>{u.FS.mkdir(f),u.FS.mount(u.FS.filesystems.IDBFS,{},f)}),await new Promise((f,y)=>{u.FS.syncfs(!0,k=>{k?y(k):f()})})),b&&Object.entries(b).forEach(([f,y])=>{u.FS.mkdir(f),u.FS.mount(u.FS.filesystems.NODEFS,{root:y},f)}),l("Mounting files.");const P=[];await Promise.all(Object.keys(t).map(async f=>{const y=t[f];f=F(c,f);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 "${f}"`),q(u,f,k,t.opts),f.endsWith(".py")&&P.push(f)})),l("Unpacking archives."),await Promise.all(i.map(async f=>{let y;"url"in f?(console.debug(`Fetch an archive from ${f.url}`),y=await fetch(f.url).then(X=>X.arrayBuffer())):y=f.buffer;const{format:k,options:A}=f;console.debug("Unpack an archive",{format:k,options:A}),u.unpackArchive(y,k,A)})),await u.loadPackage("micropip");const C=u.pyimport("micropip");if(l("Mocking some packages."),console.debug("Mock pyarrow"),ce(u),console.debug("Mocked pyarrow"),l("Installing packages."),console.debug("Installing the prebuilt packages:",n),await u.loadPackage(n),console.debug("Installed the prebuilt packages"),console.debug("Installing the requirements:",_),await C.install.callKwargs(_,{keep_going:!0}),console.debug("Installed the requirements"),h){const f=P.map(y=>u.FS.readFile(y,{encoding:"utf8"}));$(u,m,f)}await u.runPythonAsync(`
|
|
135
135
|
import importlib
|
|
136
136
|
importlib.invalidate_caches()
|
|
137
|
-
`),
|
|
137
|
+
`),l("Loading streamlit package."),console.debug("Loading the Streamlit package"),await u.runPythonAsync(`
|
|
138
138
|
import streamlit.runtime
|
|
139
|
-
`),console.debug("Loaded the Streamlit package"),
|
|
139
|
+
`),console.debug("Loaded the Streamlit package"),l("Setting up the loggers."),console.debug("Setting the loggers"),await u.runPythonAsync(`
|
|
140
140
|
import logging
|
|
141
141
|
import streamlit.logger
|
|
142
142
|
|
|
@@ -154,7 +154,7 @@ for name in streamlit.logger._loggers.keys():
|
|
|
154
154
|
logger.setLevel(logging.NOTSET)
|
|
155
155
|
|
|
156
156
|
streamlit.logger._loggers = {}
|
|
157
|
-
`);const L=(
|
|
157
|
+
`);const L=(f,y)=>{f>=40?console.error(y):f>=30?console.warn(y):f>=20?console.info(y):console.debug(y)},H=u.runPython(`
|
|
158
158
|
def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
|
|
159
159
|
class JsHandler(logging.Handler):
|
|
160
160
|
def emit(self, record):
|
|
@@ -181,14 +181,14 @@ def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
|
|
|
181
181
|
streamlit_logger.addHandler(streamlit_handler)
|
|
182
182
|
streamlit_logger.setLevel(streamlit_level.upper())
|
|
183
183
|
|
|
184
|
-
__setup_loggers__`),
|
|
184
|
+
__setup_loggers__`),W=((p==null?void 0:p["logger.level"])??"INFO").toString(),K=(p==null?void 0:p["logger.messageFormat"])??"%(asctime)s %(message)s";if(H(W,K,L),console.debug("Set the loggers"),l("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await u.runPythonAsync(`
|
|
185
185
|
import streamlit
|
|
186
186
|
|
|
187
187
|
def is_cacheable_msg(msg):
|
|
188
188
|
return False
|
|
189
189
|
|
|
190
190
|
streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
|
|
191
|
-
`),console.debug("Mocked some Streamlit functions"),w){
|
|
191
|
+
`),console.debug("Mocked some Streamlit functions"),w){l("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,u.FS.syncfs(!1,A=>{f=!1,A&&console.error(A)}))};(await u.runPython(`
|
|
192
192
|
def __setup_script_finished_callback__(callback):
|
|
193
193
|
from streamlit.runtime.app_session import AppSession
|
|
194
194
|
from streamlit.runtime.scriptrunner import ScriptRunnerEvent
|
|
@@ -204,7 +204,7 @@ def __setup_script_finished_callback__(callback):
|
|
|
204
204
|
|
|
205
205
|
AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
|
|
206
206
|
|
|
207
|
-
__setup_script_finished_callback__`))(y),console.debug("Set up the IndexedDB filesystem synchronizer")}
|
|
207
|
+
__setup_script_finished_callback__`))(y),console.debug("Set up the IndexedDB filesystem synchronizer")}if(g){l("Importing Language Server"),console.debug("Importing Language Server");try{await ue(u),console.debug("Imported Language Server")}catch(f){console.error("Error while importing Language Server",f)}}l("Booting up the Streamlit server."),console.debug("Setting up the Streamlit configuration");const J=await u.runPython(`
|
|
208
208
|
def __bootstrap__(main_script_path, flag_options, shared_worker_mode):
|
|
209
209
|
from stlite_lib.bootstrap import load_config_options, prepare
|
|
210
210
|
|
|
@@ -212,4 +212,4 @@ def __bootstrap__(main_script_path, flag_options, shared_worker_mode):
|
|
|
212
212
|
|
|
213
213
|
prepare(main_script_path, [])
|
|
214
214
|
|
|
215
|
-
__bootstrap__`),M=F(
|
|
215
|
+
__bootstrap__`),M=F(c,e),G={"browser.gatherUsageStats":!1,...p,"runner.fastReruns":!1},V=c!=null;J(M,u.toPy(G),V),console.debug("Set up the Streamlit configuration"),console.debug("Booting up the Streamlit server");const T=u.pyimport("stlite_lib.server.Server")(M,c?N(c):null);return await T.start(),console.debug("Booted up the Streamlit server"),{pyodide:u,httpServer:T,micropip:C,initData:d}}function D(o,c,d,m){function l(s){c({type:"event:progress",data:{message:s}})}const e=(s,n)=>{const r=new MessageChannel;c({type:"event:moduleAutoLoad",data:{packagesToLoad:s}},[r.port2]),n.then(a=>{r.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:a}}),r.port1.close()}).catch(a=>{throw r.port1.postMessage({type:"moduleAutoLoad:error",error:a}),r.port1.close(),a})};let t=null;const i=async s=>{const n=s.data;if(n.type==="initData"){const g=n.data,_={...d,...g};console.debug("Initial data",_),t=ge(o,m,_,e,l),t.then(()=>{c({type:"event:loaded"})}).catch(u=>{console.error(u),c({type:"event:error",data:{error:u}})});return}if(!t)throw new Error("Pyodide initialization has not been started yet.");const r=await t,a=r.pyodide;let p=r.httpServer;const S=r.micropip,{moduleAutoLoad:b}=r.initData,h=s.ports[0];function v(g){h.postMessage(g)}try{switch(n.type){case"reboot":{console.debug("Reboot the Streamlit server",n.data);const{entrypoint:g}=n.data;p.stop(),console.debug("Booting up the Streamlit server");const _=F(m,g);p=a.pyimport("stlite_lib.server.Server")(_),p.start(),console.debug("Booted up the Streamlit server"),v({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",n.data);const{path:g}=n.data;p.start_websocket(g,(_,u)=>{if(u){const w=_;try{const P=w.toJs(),C=P.buffer.slice(P.byteOffset,P.byteOffset+P.byteLength);c({type:"websocket:message",data:{payload:C}},[C])}finally{w.destroy()}}else c({type:"websocket:message",data:{payload:_}})}),v({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",n.data);const{payload:g}=n.data;p.receive_websocket_from_js(g);break}case"http:request":{console.debug("http:request",n.data);const{request:g}=n.data,_=(u,w,P)=>{const C=new Map(w.toJs()),L=P.toJs();console.debug({statusCode:u,headers:C,body:L}),v({type:"http:response",data:{response:{statusCode:u,headers:C,body:L}}})};p.receive_http_from_js(g.method,decodeURIComponent(g.path),g.headers,g.body,_);break}case"file:write":{const{path:g,data:_,opts:u}=n.data,w=F(m,g);b&&typeof _=="string"&&w.endsWith(".py")&&(console.debug(`Auto install the requirements in ${w}`),$(a,e,[_])),console.debug(`Write a file "${w}"`),q(a,w,_,u),v({type:"reply"});break}case"file:rename":{const{oldPath:g,newPath:_}=n.data,u=F(m,g),w=F(m,_);console.debug(`Rename "${u}" to ${w}`),ee(a,u,w),v({type:"reply"});break}case"file:unlink":{const{path:g}=n.data,_=F(m,g);console.debug(`Remove "${_}`),a.FS.unlink(_),v({type:"reply"});break}case"file:read":{const{path:g,opts:_}=n.data;console.debug(`Read "${g}"`);const u=a.FS.readFile(g,_);v({type:"reply:file:read",data:{content:u}});break}case"install":{const{requirements:g}=n.data,_=U(g);console.debug("Install the requirements:",_),await S.install.callKwargs(_,{keep_going:!0}).then(()=>{console.debug("Successfully installed"),v({type:"reply"})});break}case"setEnv":{const{env:g}=n.data;a.pyimport("os").environ.update(a.toPy(g)),console.debug("Successfully set the environment variables",g),v({type:"reply"});break}case"language-server:code_completion":{const g=await me(n.data,a);v({type:"reply:language-server:code_completion",data:g});break}}}catch(g){if(console.error(g),!(g instanceof Error))throw g;const _=new Error(g.message);_.name=g.name,_.stack=g.stack,v({type:"reply",error:_})}};return c({type:"event:start"}),i}const B="abcdefghijklmnopqrstuvwxyz",fe=B.length;function pe(o){let c="";for(let d=0;d<o;d++){const m=Math.floor(Math.random()*fe);c+=B[m]}return c}const x="https://cdn.jsdelivr.net/pyodide/v0.27.6/full/pyodide.mjs";if("postMessage"in self)self.onmessage=D(x,(o,c)=>c?self.postMessage(o,c):self.postMessage(o));else{const o=[];self.onconnect=c=>{let d;do d=pe(4);while(o.includes(d));o.push(d),console.debug("SharedWorker mode.",{appId:d});const m=c.ports[0];m.onmessage=D(x,(l,e)=>e?m.postMessage(l,e):m.postMessage(l),void 0,d),m.start()}}
|
package/build/electron/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ae=Object.create;var $=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var me=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ge=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ce(e))!ue.call(r,n)&&n!==t&&$(r,n,{get:()=>e[n],enumerable:!(o=le(e,n))||o.enumerable});return r};var I=(r,e,t)=>(t=r!=null?ae(de(r)):{},ge(e||!r||!r.__esModule?$(t,"default",{value:r,enumerable:!0}):t,r));var B=me((Le,z)=>{"use strict";function S(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function q(r,e){for(var t="",o=0,n=-1,i=0,s,a=0;a<=r.length;++a){if(a<r.length)s=r.charCodeAt(a);else{if(s===47)break;s=47}if(s===47){if(!(n===a-1||i===1))if(n!==a-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=a,i=0;continue}}else if(t.length===2||t.length===1){t="",o=0,n=a,i=0;continue}}e&&(t.length>0?t+="/..":t="..",o=2)}else t.length>0?t+="/"+r.slice(n+1,a):t=r.slice(n+1,a),o=a-n-1;n=a,i=0}else s===46&&i!==-1?++i:i=-1}return t}function fe(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),S(i),i.length!==0&&(e=i+"/"+e,t=i.charCodeAt(0)===47)}return e=q(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(S(e),e.length===0)return".";var t=e.charCodeAt(0)===47,o=e.charCodeAt(e.length-1)===47;return e=q(e,!t),e.length===0&&!t&&(e="."),e.length>0&&o&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return S(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];S(o),o.length>0&&(e===void 0?e=o:e+="/"+o)}return e===void 0?".":L.normalize(e)},relative:function(e,t){if(S(e),S(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 a=t.length,d=a-s,f=i<d?i:d,g=-1,u=0;u<=f;++u){if(u===f){if(d>f){if(t.charCodeAt(s+u)===47)return t.slice(s+u+1);if(u===0)return t.slice(s+u)}else i>f&&(e.charCodeAt(o+u)===47?g=u:u===0&&(g=0));break}var b=e.charCodeAt(o+u),F=t.charCodeAt(s+u);if(b!==F)break;b===47&&(g=u)}var v="";for(u=o+g+1;u<=n;++u)(u===n||e.charCodeAt(u)===47)&&(v.length===0?v+="..":v+="/..");return v.length>0?v+t.slice(s+g):(s+=g,t.charCodeAt(s)===47&&++s,t.slice(s))},_makeLong:function(e){return e},dirname:function(e){if(S(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');S(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 a=t.length-1,d=-1;for(s=e.length-1;s>=0;--s){var f=e.charCodeAt(s);if(f===47){if(!i){o=s+1;break}}else d===-1&&(i=!1,d=s+1),a>=0&&(f===t.charCodeAt(a)?--a===-1&&(n=s):(a=-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){S(e);for(var t=-1,o=0,n=-1,i=!0,s=0,a=e.length-1;a>=0;--a){var d=e.charCodeAt(a);if(d===47){if(!i){o=a+1;break}continue}n===-1&&(i=!1,n=a+1),d===46?t===-1?t=a: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 fe("/",e)},parse:function(e){S(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,a=0,d=-1,f=!0,g=e.length-1,u=0;g>=i;--g){if(o=e.charCodeAt(g),o===47){if(!f){a=g+1;break}continue}d===-1&&(f=!1,d=g+1),o===46?s===-1?s=g:u!==1&&(u=1):s!==-1&&(u=-1)}return s===-1||d===-1||u===0||u===1&&s===d-1&&s===a+1?d!==-1&&(a===0&&n?t.base=t.name=e.slice(1,d):t.base=t.name=e.slice(a,d)):(a===0&&n?(t.name=e.slice(1,s),t.base=e.slice(1,d)):(t.name=e.slice(a,s),t.base=e.slice(a,d)),t.ext=e.slice(s,d)),a>0?t.dir=e.slice(0,a-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};L.posix=L;z.exports=L});var U=require("node:worker_threads");var R=I(B()),H="/home/pyodide",O=r=>`${H}/${r}`,C=(r,e)=>r==null?R.default.resolve(H,e):R.default.resolve(O(r),e);function K(r,e){let t=R.default.normalize(e),n=R.default.dirname(t).split("/"),i=[];for(let s of n){i.push(s);let a=i.join("/");if(r.FS.analyzePath(a).exists){if(r.FS.isDir(a))throw new Error(`"${a}" already exists and is not a directory.`);continue}try{r.FS.mkdir(a)}catch(d){throw console.error(`Failed to create a directory "${a}"`),d}}}function x(r,e,t,o){K(r,e),r.FS.writeFile(e,t,o)}function J(r,e,t){K(r,t),r.FS.rename(e,t)}var pe="[",_e="(<=>!~",ye=";",he="@",be=new RegExp(`[${pe+_e+ye+he}]`);function ve(r){return r.split(be)[0].trim()}function T(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 Pe(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 V(r,e){let{scriptURL:t,pyodideIndexURL:o,isESModule:n}=await Pe(r),i;return n?i=(await import(t)).loadPyodide:(importScripts(t),i=self.loadPyodide),i({...e,indexURL:o})}function G(r){r.runPython(`
|
|
2
2
|
import micropip
|
|
3
3
|
micropip.add_mock_package(
|
|
4
4
|
"pyarrow", "0.0.1",
|
|
@@ -24,7 +24,7 @@ class ChunkedArray:
|
|
|
24
24
|
"""
|
|
25
25
|
}
|
|
26
26
|
)
|
|
27
|
-
`)}function
|
|
27
|
+
`)}function Se(r,e,t){let o=r.pyimport("pyodide"),n=g=>o.code.find_imports(g).toJs(),i=t.map(g=>n(g)),d=Array.from(new Set(i.flat())).filter(g=>!r.runPython(`__import__('importlib').util.find_spec('${g}')`)).map(g=>r._api._import_name_to_package_name.get(g)).filter(g=>g);if(d.length===0)return Promise.resolve();let f=r.loadPackage(d);return e(d,f),f.then()}function N(r,e,t){let o=Se(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
|
|
@@ -131,7 +131,7 @@ def get_code_completions(code: str, current_line_number: int, cursor_offset: int
|
|
|
131
131
|
# Convert results to JSON so that we can use it in the worker
|
|
132
132
|
converter = lsp_converters.get_converter()
|
|
133
133
|
return json.dumps(converter.unstructure(suggestions, unstructure_as=CompletionList))
|
|
134
|
-
`)},Q=async(r,e)=>{let t;try{if(t=e.globals.get("get_code_completions"),!t)return console.error("Can not generate suggestions list, the get_code_completions function is not defined"),{items:[]};let o=t(r.code,r.line,r.column);return o?JSON.parse(o):{items:[]}}catch(o){return console.error(o),{items:[]}}finally{t&&t.constructor.name==="PyProxy"&&t.destroy()}};var
|
|
134
|
+
`)},Q=async(r,e)=>{let t;try{if(t=e.globals.get("get_code_completions"),!t)return console.error("Can not generate suggestions list, the get_code_completions function is not defined"),{items:[]};let o=t(r.code,r.line,r.column);return o?JSON.parse(o):{items:[]}}catch(o){return console.error(o),{items:[]}}finally{t&&t.constructor.name==="PyProxy"&&t.destroy()}};var D=null;async function ke(r,e,t,o,n){let{entrypoint:i,files:s,archives:a,requirements:d,prebuiltPackageNames:f,wheels:g,pyodideUrl:u=r,streamlitConfig:b,idbfsMountpoints:F,nodefsMountpoints:v,moduleAutoLoad:E,env:h,languageServer:m}=t,p=T(d);if(D)n("Pyodide is already loaded."),console.debug("Pyodide is already loaded.");else{n("Loading Pyodide."),console.debug("Loading Pyodide."),D=V(u,{stdout:console.log,stderr:console.error});let c=[];g&&(c.push(g.streamlit),c.push(g.stliteLib)),m&&(c.push("jedi"),c.push("lsprotocol")),p.unshift(...c),console.debug("Loaded Pyodide")}let l=await D;if(h){console.debug("Setting environment variables",h);let c=l.pyimport("os");c.environ.update(l.toPy(h)),console.debug("Set environment variables",c.environ)}let y=!1;F&&(y=!0,F.forEach(c=>{l.FS.mkdir(c),l.FS.mount(l.FS.filesystems.IDBFS,{},c)}),await new Promise((c,_)=>{l.FS.syncfs(!0,P=>{P?_(P):c()})})),v&&Object.entries(v).forEach(([c,_])=>{l.FS.mkdir(c),l.FS.mount(l.FS.filesystems.NODEFS,{root:_},c)}),n("Mounting files.");let k=[];await Promise.all(Object.keys(s).map(async c=>{let _=s[c];c=C(e,c);let P;"url"in _?(console.debug(`Fetch a file from ${_.url}`),P=await fetch(_.url).then(w=>w.arrayBuffer()).then(w=>new Uint8Array(w))):P=_.data,console.debug(`Write a file "${c}"`),x(l,c,P,s.opts),c.endsWith(".py")&&k.push(c)})),n("Unpacking archives."),await Promise.all(a.map(async c=>{let _;"url"in c?(console.debug(`Fetch an archive from ${c.url}`),_=await fetch(c.url).then(ie=>ie.arrayBuffer())):_=c.buffer;let{format:P,options:w}=c;console.debug("Unpack an archive",{format:P,options:w}),l.unpackArchive(_,P,w)})),await l.loadPackage("micropip");let A=l.pyimport("micropip");if(n("Mocking some packages."),console.debug("Mock pyarrow"),G(l),console.debug("Mocked pyarrow"),n("Installing packages."),console.debug("Installing the prebuilt packages:",f),await l.loadPackage(f),console.debug("Installed the prebuilt packages"),console.debug("Installing the requirements:",p),await A.install.callKwargs(p,{keep_going:!0}),console.debug("Installed the requirements"),E){let c=k.map(_=>l.FS.readFile(_,{encoding:"utf8"}));N(l,o,c)}await l.runPythonAsync(`
|
|
135
135
|
import importlib
|
|
136
136
|
importlib.invalidate_caches()
|
|
137
137
|
`),n("Loading streamlit package."),console.debug("Loading the Streamlit package"),await l.runPythonAsync(`
|
|
@@ -154,7 +154,7 @@ for name in streamlit.logger._loggers.keys():
|
|
|
154
154
|
logger.setLevel(logging.NOTSET)
|
|
155
155
|
|
|
156
156
|
streamlit.logger._loggers = {}
|
|
157
|
-
`);let M=(
|
|
157
|
+
`);let M=(c,_)=>{c>=40?console.error(_):c>=30?console.warn(_):c>=20?console.info(_):console.debug(_)},ee=l.runPython(`
|
|
158
158
|
def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
|
|
159
159
|
class JsHandler(logging.Handler):
|
|
160
160
|
def emit(self, record):
|
|
@@ -181,14 +181,14 @@ def __setup_loggers__(streamlit_level, streamlit_message_format, callback):
|
|
|
181
181
|
streamlit_logger.addHandler(streamlit_handler)
|
|
182
182
|
streamlit_logger.setLevel(streamlit_level.upper())
|
|
183
183
|
|
|
184
|
-
__setup_loggers__`),
|
|
184
|
+
__setup_loggers__`),te=(b?.["logger.level"]??"INFO").toString(),re=b?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(ee(te,re,M),console.debug("Set the loggers"),n("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await l.runPythonAsync(`
|
|
185
185
|
import streamlit
|
|
186
186
|
|
|
187
187
|
def is_cacheable_msg(msg):
|
|
188
188
|
return False
|
|
189
189
|
|
|
190
190
|
streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
|
|
191
|
-
`),console.debug("Mocked some Streamlit functions"),y){n("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let
|
|
191
|
+
`),console.debug("Mocked some Streamlit functions"),y){n("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let c=!1,_=()=>{console.debug("The script has finished. Syncing the filesystem."),c||(c=!0,l.FS.syncfs(!1,w=>{c=!1,w&&console.error(w)}))};(await l.runPython(`
|
|
192
192
|
def __setup_script_finished_callback__(callback):
|
|
193
193
|
from streamlit.runtime.app_session import AppSession
|
|
194
194
|
from streamlit.runtime.scriptrunner import ScriptRunnerEvent
|
|
@@ -204,7 +204,7 @@ def __setup_script_finished_callback__(callback):
|
|
|
204
204
|
|
|
205
205
|
AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
|
|
206
206
|
|
|
207
|
-
__setup_script_finished_callback__`))(_),console.debug("Set up the IndexedDB filesystem synchronizer")}m
|
|
207
|
+
__setup_script_finished_callback__`))(_),console.debug("Set up the IndexedDB filesystem synchronizer")}if(m){n("Importing Language Server"),console.debug("Importing Language Server");try{await X(l),console.debug("Imported Language Server")}catch(c){console.error("Error while importing Language Server",c)}}n("Booting up the Streamlit server."),console.debug("Setting up the Streamlit configuration");let oe=await l.runPython(`
|
|
208
208
|
def __bootstrap__(main_script_path, flag_options, shared_worker_mode):
|
|
209
209
|
from stlite_lib.bootstrap import load_config_options, prepare
|
|
210
210
|
|
|
@@ -212,4 +212,4 @@ def __bootstrap__(main_script_path, flag_options, shared_worker_mode):
|
|
|
212
212
|
|
|
213
213
|
prepare(main_script_path, [])
|
|
214
214
|
|
|
215
|
-
__bootstrap__`),
|
|
215
|
+
__bootstrap__`),j=C(e,i),ne={"browser.gatherUsageStats":!1,...b,"runner.fastReruns":!1},se=e!=null;oe(j,l.toPy(ne),se),console.debug("Set up the Streamlit configuration"),console.debug("Booting up the Streamlit server");let W=l.pyimport("stlite_lib.server.Server")(j,e?O(e):null);return await W.start(),console.debug("Booted up the Streamlit server"),{pyodide:l,httpServer:W,micropip:A,initData:t}}function Y(r,e,t,o){function n(d){e({type:"event:progress",data:{message:d}})}let i=(d,f)=>{let g=new MessageChannel;e({type:"event:moduleAutoLoad",data:{packagesToLoad:d}},[g.port2]),f.then(u=>{g.port1.postMessage({type:"moduleAutoLoad:success",data:{loadedPackages:u}}),g.port1.close()}).catch(u=>{throw g.port1.postMessage({type:"moduleAutoLoad:error",error:u}),g.port1.close(),u})},s=null,a=async d=>{let f=d.data;if(f.type==="initData"){let m=f.data,p={...t,...m};console.debug("Initial data",p),s=ke(r,o,p,i,n),s.then(()=>{e({type:"event:loaded"})}).catch(l=>{console.error(l),e({type:"event:error",data:{error:l}})});return}if(!s)throw new Error("Pyodide initialization has not been started yet.");let g=await s,u=g.pyodide,b=g.httpServer,F=g.micropip,{moduleAutoLoad:v}=g.initData,E=d.ports[0];function h(m){E.postMessage(m)}try{switch(f.type){case"reboot":{console.debug("Reboot the Streamlit server",f.data);let{entrypoint:m}=f.data;b.stop(),console.debug("Booting up the Streamlit server");let p=C(o,m);b=u.pyimport("stlite_lib.server.Server")(p),b.start(),console.debug("Booted up the Streamlit server"),h({type:"reply"});break}case"websocket:connect":{console.debug("websocket:connect",f.data);let{path:m}=f.data;b.start_websocket(m,(p,l)=>{if(l){let y=p;try{let k=y.toJs(),A=k.buffer.slice(k.byteOffset,k.byteOffset+k.byteLength);e({type:"websocket:message",data:{payload:A}},[A])}finally{y.destroy()}}else e({type:"websocket:message",data:{payload:p}})}),h({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",f.data);let{payload:m}=f.data;b.receive_websocket_from_js(m);break}case"http:request":{console.debug("http:request",f.data);let{request:m}=f.data,p=(l,y,k)=>{let A=new Map(y.toJs()),M=k.toJs();console.debug({statusCode:l,headers:A,body:M}),h({type:"http:response",data:{response:{statusCode:l,headers:A,body:M}}})};b.receive_http_from_js(m.method,decodeURIComponent(m.path),m.headers,m.body,p);break}case"file:write":{let{path:m,data:p,opts:l}=f.data,y=C(o,m);v&&typeof p=="string"&&y.endsWith(".py")&&(console.debug(`Auto install the requirements in ${y}`),N(u,i,[p])),console.debug(`Write a file "${y}"`),x(u,y,p,l),h({type:"reply"});break}case"file:rename":{let{oldPath:m,newPath:p}=f.data,l=C(o,m),y=C(o,p);console.debug(`Rename "${l}" to ${y}`),J(u,l,y),h({type:"reply"});break}case"file:unlink":{let{path:m}=f.data,p=C(o,m);console.debug(`Remove "${p}`),u.FS.unlink(p),h({type:"reply"});break}case"file:read":{let{path:m,opts:p}=f.data;console.debug(`Read "${m}"`);let l=u.FS.readFile(m,p);h({type:"reply:file:read",data:{content:l}});break}case"install":{let{requirements:m}=f.data,p=T(m);console.debug("Install the requirements:",p),await F.install.callKwargs(p,{keep_going:!0}).then(()=>{console.debug("Successfully installed"),h({type:"reply"})});break}case"setEnv":{let{env:m}=f.data;u.pyimport("os").environ.update(u.toPy(m)),console.debug("Successfully set the environment variables",m),h({type:"reply"});break}case"language-server:code_completion":{let m=await Q(f.data,u);h({type:"reply:language-server:code_completion",data:m});break}}}catch(m){if(console.error(m),!(m instanceof Error))throw m;let p=new Error(m.message);p.name=m.name,p.stack=m.stack,h({type:"reply",error:p})}};return e({type:"event:start"}),a}function Z(){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 we=r=>{console.debug("[worker thread] postMessage from worker",r),U.parentPort?.postMessage(r)},Ae=Y(process.env.PYODIDE_URL,we,{nodefsMountpoints:Z()});U.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,8 +6,8 @@
|
|
|
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 craco.config.js. -->
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
-
<link rel="stylesheet" crossorigin href="/assets/index.
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CVPZJuoC.js"></script>
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/assets/index.Bqb_jNud.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stlite/desktop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.83.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test": "vitest",
|
|
31
31
|
"start:electron": "tsc -p electron && cross-env NODE_ENV=development concurrently \"./scripts/build_electron.js --watch\" \"electron .\"",
|
|
32
32
|
"build:electron": "tsc -p electron && cross-env NODE_ENV=production ./scripts/build_electron.js",
|
|
33
|
-
"build:pyodide": "
|
|
33
|
+
"build:pyodide": "./scripts/download_pyodide.sh",
|
|
34
34
|
"build:bin": "tsc -p bin-src && ./scripts/build_bin.js",
|
|
35
35
|
"build:wheels": "./scripts/copy_wheels.js",
|
|
36
36
|
"postbuild:web": "./scripts/post_build_web.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"build:app": "yarn build:web && yarn build:electron && yarn build:pyodide",
|
|
40
40
|
"build": "yarn build:app && yarn build:wheels && yarn build:bin",
|
|
41
41
|
"predump:dev": "yarn build:wheels && mkdir -p ./build",
|
|
42
|
-
"dump:dev": "tsx ./bin-src/dump_artifacts/index.ts",
|
|
42
|
+
"dump:dev": "cross-env NODE_ENV=development tsx ./bin-src/dump_artifacts/index.ts",
|
|
43
43
|
"dump": "dump-stlite-desktop-artifacts",
|
|
44
44
|
"serve": "cross-env NODE_ENV=production electron .",
|
|
45
45
|
"fix:eslint": "eslint --fix '{src,electron,bin}/**/*.{ts,tsx}'",
|
|
@@ -63,10 +63,11 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@emotion/babel-plugin": "^11.13.5",
|
|
66
|
-
"@stlite/common": "^0.
|
|
67
|
-
"@stlite/common-react": "^0.
|
|
68
|
-
"@stlite/
|
|
69
|
-
"@
|
|
66
|
+
"@stlite/common": "^0.83.0",
|
|
67
|
+
"@stlite/common-react": "^0.83.0",
|
|
68
|
+
"@stlite/devutils": "^0.83.0",
|
|
69
|
+
"@stlite/kernel": "^0.83.0",
|
|
70
|
+
"@streamlit/app": "^1.45.1",
|
|
70
71
|
"@types/react": "^18.2.0",
|
|
71
72
|
"@types/react-dom": "^18.2.0",
|
|
72
73
|
"@types/yargs": "^17.0.32",
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as o,E as m,_ as p,c,D as f,j as i,A as u,b$ as g,bH as b,bV as w,bC as z,bW as E,b5 as y}from"./index-OxGwEg3m.js";var v=o.forwardRef(function(e,n){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(m,p({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:n}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"}))});v.displayName="Fullscreen";var x=o.forwardRef(function(e,n){var t={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return o.createElement(m,p({iconAttrs:t,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:n}),o.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),o.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}))});x.displayName="FullscreenExit";const d="-2.4rem",C=c("div",{target:"e2wxzia2"})(({theme:e,locked:n,target:t})=>({padding:`${e.spacing.sm} 0 ${e.spacing.sm} ${e.spacing.sm}`,position:"absolute",top:n?d:"-1rem",right:e.spacing.none,transition:"none",...!n&&{opacity:0,"&:active, &:focus-visible, &:hover":{transition:"opacity 150ms 100ms, top 100ms 100ms",opacity:1,top:d},...t&&{[`${t}:hover &, ${t}:active &, ${t}:focus-visible &`]:{transition:"opacity 150ms 100ms, top 100ms 100ms",opacity:1,top:d}}}}),""),j=c("div",{target:"e2wxzia1"})(({theme:e})=>({color:f(e)?e.colors.fadedText60:e.colors.bodyText,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",boxShadow:"1px 2px 8px rgba(0, 0, 0, 0.08)",borderRadius:e.radii.default,backgroundColor:e.colors.lightenedBg05,width:"fit-content",zIndex:e.zIndices.sidebar+1}),""),V=c("div",{target:"e2wxzia0"})(({width:e,height:n,useContainerWidth:t,topCentered:s})=>({position:"relative",height:t&&n?n:"fit-content",width:t?e:"fit-content",maxWidth:"100%",...s?{display:"flex",justifyContent:"center"}:{}}),"");function h({label:e,show_label:n,icon:t,onClick:s}){const r=u(),a=n?e:"";return i.jsx("div",{"data-testid":"stElementToolbarButton",children:i.jsx(g,{content:i.jsx(y,{source:e,allowHTML:!1,style:{fontSize:r.fontSizes.sm}}),placement:b.TOP,onMouseEnterDelay:1e3,inline:!0,children:i.jsxs(w,{onClick:l=>{s&&s(),l.stopPropagation()},kind:z.ELEMENT_TOOLBAR,"aria-label":e,children:[t&&i.jsx(E,{content:t,size:"md",testid:"stElementToolbarButtonIcon"}),a&&i.jsx("span",{children:a})]})})})}const T=({onExpand:e,onCollapse:n,isFullScreen:t,locked:s,children:r,target:a,disableFullscreenMode:l})=>i.jsx(C,{className:"stElementToolbar","data-testid":"stElementToolbar",locked:s||t,target:a,children:i.jsxs(j,{children:[r,e&&!l&&!t&&i.jsx(h,{label:"Fullscreen",icon:v,onClick:()=>e()}),n&&!l&&t&&i.jsx(h,{label:"Close fullscreen",icon:x,onClick:()=>n()})]})});export{V as S,T,h as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as o,j as s,cl as d,bZ as n}from"./index-OxGwEg3m.js";import{a as b}from"./useBasicWidgetState-Bm5AJWX7.js";import"./FormClearHelper-DxeY-rII.js";const f=(e,l)=>e.getStringValue(l),p=e=>e.default??null,v=e=>e.value??null,S=(e,l,a,t)=>{l.setStringValue(e,a.value,{fromUi:a.fromUi},t)},c=({element:e,disabled:l,widgetMgr:a,fragmentId:t})=>{var r;const[g,i]=b({getStateFromWidgetMgr:f,getDefaultStateFromProto:p,getCurrStateFromProto:v,updateWidgetMgrState:S,element:e,widgetMgr:a,fragmentId:t}),m=o.useCallback(u=>{i({value:u,fromUi:!0})},[i]);return s.jsx(d,{label:e.label,labelVisibility:n((r=e.labelVisibility)==null?void 0:r.value),help:e.help,onChange:m,disabled:l,value:g})},h=o.memo(c);export{h as default};
|