@stlite/desktop 0.24.0 → 0.25.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.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- var D=Object.create;var m=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var f=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var P=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of S(t))!q.call(e,o)&&o!==r&&m(e,o,{get:()=>t[o],enumerable:!(i=T(t,o))||i.enumerable});return e};var s=(e,t,r)=>(r=e!=null?D(O(e)):{},P(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e));var h=f(d=>{"use strict";Object.defineProperty(d,"__esModule",{value:!0});d.parseRequirementsTxt=void 0;function $(e){return e.split(`
3
- `).filter(t=>!t.startsWith("#")).map(t=>t.trim()).filter(t=>t!=="")}d.parseRequirementsTxt=$});var g=f(c=>{"use strict";var j=c&&c.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),x=c&&c.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&j(t,e,r)};Object.defineProperty(c,"__esModule",{value:!0});x(h(),c)});var w=s(require("yargs")),v=require("yargs/helpers"),a=s(require("path")),n=s(require("fs/promises")),y=s(require("fs-extra")),b=s(require("node-fetch")),_=require("pyodide"),k=s(g());global.fetch=b.default;async function C(e){console.info("Copy the build directory (the bare built app files) to this directory...");let t=a.default.resolve(__dirname,"../build");if(!(await n.default.stat(t)).isDirectory())throw new Error(`The source ${t} does not exist.`);if(t===e.copyTo){console.warn(`sourceDir == destDir (${t}). Are you in the development environment? Skip copying the directory.`);return}if(e.keepOld)try{await n.default.access(e.copyTo),console.info(`${e.copyTo} already exists. Use it and skip copying.`);return}catch{throw new Error(`${e.copyTo} does not exist even though the \`keepOld\` option is specified`)}console.log(`Copy ${t} to ${e.copyTo}`),await n.default.rm(e.copyTo,{recursive:!0,force:!0}),await y.default.copy(t,e.copyTo)}async function u(e,t){console.log(`Install the local wheel ${t}`);let r=await n.default.readFile(t),i="/tmp/"+a.default.basename(t);e.FS.writeFile(i,r);let o=e.pyimport("micropip"),l=`emfs:${i}`;console.log(`Install ${l}`),await o.install.callKwargs(l,{keep_going:!0})}async function K(e){console.info("Create the site-packages snapshot file...");let t=await(0,_.loadPyodide)();if(await t.loadPackage(["micropip"]),e.useLocalKernelWheels){let l=a.default.dirname(require.resolve("@stlite/kernel")),p=a.default.resolve(l,"../py");await u(t,a.default.join(p,"tornado/dist/tornado-6.2-py3-none-any.whl")),await u(t,a.default.join(p,"stlite-pyarrow/dist/stlite_pyarrow-0.1.0-py3-none-any.whl")),await u(t,a.default.join(p,"streamlit/lib/dist/streamlit-1.13.0-py2.py3-none-any.whl"))}else{let l=t.pyimport("micropip"),p=["https://cdn.jsdelivr.net/npm/@stlite/kernel@0.19.1/py/tornado/dist/tornado-6.2-py3-none-any.whl","https://cdn.jsdelivr.net/npm/@stlite/kernel@0.19.1/py/stlite-pyarrow/dist/stlite_pyarrow-0.1.0-py3-none-any.whl","https://cdn.jsdelivr.net/npm/@stlite/kernel@0.19.1/py/streamlit/lib/dist/streamlit-1.13.0-py2.py3-none-any.whl"];console.log("Install",p),await l.install.callKwargs(p,{keep_going:!0})}console.log(`Install the requirements ${JSON.stringify(e.requirements)}`),await t.pyimport("micropip").install.callKwargs(e.requirements,{keep_going:!0}),console.log("Archive the site-packages director(y|ies)");let i="/tmp/site-packages-snapshot.tar.gz";await t.runPythonAsync(`
2
+ var O=Object.create;var g=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var x=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $(t))!F.call(e,o)&&o!==r&&g(e,o,{get:()=>t[o],enumerable:!(i=P(t,o))||i.enumerable});return e};var n=(e,t,r)=>(r=e!=null?O(j(e)):{},x(t||!e||!e.__esModule?g(r,"default",{value:e,enumerable:!0}):r,e));var v=w(u=>{"use strict";Object.defineProperty(u,"__esModule",{value:!0});u.parseRequirementsTxt=void 0;function C(e){return e.split(`
3
+ `).filter(t=>!t.startsWith("#")).map(t=>t.trim()).filter(t=>t!=="")}u.parseRequirementsTxt=C});var _=w(c=>{"use strict";var K=c&&c.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),R=c&&c.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&K(t,e,r)};Object.defineProperty(c,"__esModule",{value:!0});R(v(),c)});var D=n(require("yargs")),b=require("yargs/helpers"),a=n(require("path")),s=n(require("fs/promises")),f=n(require("fs-extra")),y=n(require("node-fetch")),k=require("pyodide"),T=n(_());global.fetch=y.default;async function B(e){console.info("Copy the build directory (the bare built app files) to this directory...");let t=a.default.resolve(__dirname,"../build");if(!(await s.default.stat(t)).isDirectory())throw new Error(`The source ${t} does not exist.`);if(t===e.copyTo){console.warn(`sourceDir == destDir (${t}). Are you in the development environment? Skip copying the directory.`);return}if(e.keepOld)try{await s.default.access(e.copyTo),console.info(`${e.copyTo} already exists. Use it and skip copying.`);return}catch{throw new Error(`${e.copyTo} does not exist even though the \`keepOld\` option is specified`)}console.log(`Copy ${t} to ${e.copyTo}`),await s.default.rm(e.copyTo,{recursive:!0,force:!0}),await f.default.copy(t,e.copyTo)}async function m(e,t){console.log(`Install the local wheel ${t}`);let r=await s.default.readFile(t),i="/tmp/"+a.default.basename(t);e.FS.writeFile(i,r);let o=e.pyimport("micropip"),p=`emfs:${i}`;console.log(`Install ${p}`),await o.install.callKwargs(p,{keep_going:!0})}async function E(e){console.info("Create the site-packages snapshot file...");let t=await(0,k.loadPyodide)();if(await t.loadPackage(["micropip"]),e.useLocalKernelWheels){let p=a.default.dirname(require.resolve("@stlite/kernel")),l=a.default.resolve(p,"../py");await m(t,a.default.join(l,"tornado/dist/tornado-6.2-py3-none-any.whl")),await m(t,a.default.join(l,"stlite-pyarrow/dist/stlite_pyarrow-0.1.0-py3-none-any.whl")),await m(t,a.default.join(l,"streamlit/lib/dist/streamlit-1.17.0-py2.py3-none-any.whl"))}else{let l=require(a.default.resolve(__dirname,"../package.json")).version,S=`https://data.jsdelivr.com/v1/package/npm/@stlite/kernel@${l}/flat`,h=(await(await(0,y.default)(S)).json()).files.filter(d=>d.name.endsWith(".whl")).map(d=>`https://cdn.jsdelivr.net/npm/@stlite/kernel@${l}${d.name}`),q=t.pyimport("micropip");console.log("Install",h),await q.install.callKwargs(h,{keep_going:!0})}console.log(`Install the requirements ${JSON.stringify(e.requirements)}`),await t.pyimport("micropip").install.callKwargs(e.requirements,{keep_going:!0}),console.log("Archive the site-packages director(y|ies)");let i="/tmp/site-packages-snapshot.tar.gz";await t.runPythonAsync(`
4
4
  import tarfile
5
5
  import site
6
6
 
@@ -10,4 +10,4 @@ var D=Object.create;var m=Object.defineProperty;var T=Object.getOwnPropertyDescr
10
10
  with tarfile.open(tar_file_name, mode='w:gz') as gzf:
11
11
  for site_packages in site_packages_dirs:
12
12
  gzf.add(site_packages)
13
- `),console.log("Extract the archive file from EMFS");let o=t.FS.readFile(i);console.log(`Save the archive file (${e.saveTo})`),await n.default.writeFile(e.saveTo,o)}async function F(e){console.info("Copy the Streamlit app directory..."),console.log(`Copy ${e.sourceDir} to ${e.copyTo}`),await n.default.rm(e.copyTo,{recursive:!0,force:!0}),await y.default.copy(e.sourceDir,e.copyTo)}async function B(e){let t=await n.default.readFile(e,{encoding:"utf-8"});return(0,k.parseRequirementsTxt)(t)}function E(e){e.forEach(t=>{let r;try{r=new URL(t)}catch{return}if(r.protocol==="emfs:"||r.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${t})`)})}(0,w.default)((0,v.hideBin)(process.argv)).command("* <appHomeDirSource> [packages..]","Put the user code and data and the snapshot of the required packages into the build artifact.",()=>{},e=>{console.info(e)}).positional("appHomeDirSource",{describe:"The source directory of the user code and data that will be mounted in the Pyodide file system at app runtime",type:"string",demandOption:!0}).positional("packages",{describe:"Package names to install.",type:"string",array:!0}).options("requirement",{describe:"Install from the given requirements file. This option can be used multiple times.",array:!0,type:"string",alias:"r",default:[]}).options("localKernelWheels",{describe:"Use the locally installed kernel wheels",type:"boolean",alias:"l",default:!1}).options("keepOldBuild",{type:"boolean",default:!1,alias:"k",describe:"Keep the existing build directory contents except appHomeDir."}).parseAsync().then(async e=>{let t=a.default.resolve(process.cwd(),"./build");try{await n.default.access(e.appHomeDirSource)}catch{throw new Error(`${e.appHomeDirSource} does not exist.`)}let r=e.packages;for(let i of e.requirement)r=r.concat(await B(i));E(r),await C({copyTo:t,keepOld:e.keepOldBuild}),await K({useLocalKernelWheels:e.localKernelWheels,requirements:r,saveTo:a.default.resolve(t,"./site-packages-snapshot.tar.gz")}),await F({sourceDir:e.appHomeDirSource,copyTo:a.default.resolve(t,"./streamlit_app")})});
13
+ `),console.log("Extract the archive file from EMFS");let o=t.FS.readFile(i);console.log(`Save the archive file (${e.saveTo})`),await s.default.writeFile(e.saveTo,o)}async function H(e){console.info("Copy the Streamlit app directory..."),console.log(`Copy ${e.sourceDir} to ${e.copyTo}`),await s.default.rm(e.copyTo,{recursive:!0,force:!0}),await f.default.copy(e.sourceDir,e.copyTo)}async function W(e){let t=await s.default.readFile(e,{encoding:"utf-8"});return(0,T.parseRequirementsTxt)(t)}function I(e){e.forEach(t=>{let r;try{r=new URL(t)}catch{return}if(r.protocol==="emfs:"||r.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${t})`)})}(0,D.default)((0,b.hideBin)(process.argv)).command("* <appHomeDirSource> [packages..]","Put the user code and data and the snapshot of the required packages into the build artifact.",()=>{},e=>{console.info(e)}).positional("appHomeDirSource",{describe:"The source directory of the user code and data that will be mounted in the Pyodide file system at app runtime",type:"string",demandOption:!0}).positional("packages",{describe:"Package names to install.",type:"string",array:!0}).options("requirement",{describe:"Install from the given requirements file. This option can be used multiple times.",array:!0,type:"string",alias:"r",default:[]}).options("localKernelWheels",{describe:"Use the locally installed kernel wheels",type:"boolean",alias:"l",default:!1}).options("keepOldBuild",{type:"boolean",default:!1,alias:"k",describe:"Keep the existing build directory contents except appHomeDir."}).parseAsync().then(async e=>{let t=a.default.resolve(process.cwd(),"./build");try{await s.default.access(e.appHomeDirSource)}catch{throw new Error(`${e.appHomeDirSource} does not exist.`)}let r=e.packages;for(let i of e.requirement)r=r.concat(await W(i));I(r),await B({copyTo:t,keepOld:e.keepOldBuild}),await E({useLocalKernelWheels:e.localKernelWheels,requirements:r,saveTo:a.default.resolve(t,"./site-packages-snapshot.tar.gz")}),await H({sourceDir:e.appHomeDirSource,copyTo:a.default.resolve(t,"./streamlit_app")})});
@@ -5,7 +5,7 @@
5
5
  "static/js/2.90589c59.chunk.js": "/static/js/2.90589c59.chunk.js",
6
6
  "static/js/3.8dacc9e7.chunk.js": "/static/js/3.8dacc9e7.chunk.js",
7
7
  "main.css": "/static/css/main.7bc75681.chunk.css",
8
- "main.js": "/static/js/main.31e91b88.chunk.js",
8
+ "main.js": "/static/js/main.f1cf2dec.chunk.js",
9
9
  "runtime-main.js": "/static/js/runtime-main.e5a1f36a.js",
10
10
  "static/css/6.69790b96.chunk.css": "/static/css/6.69790b96.chunk.css",
11
11
  "static/js/6.9c8c6dae.chunk.js": "/static/js/6.9c8c6dae.chunk.js",
@@ -84,6 +84,6 @@
84
84
  "static/css/6.69790b96.chunk.css",
85
85
  "static/js/6.9c8c6dae.chunk.js",
86
86
  "static/css/main.7bc75681.chunk.css",
87
- "static/js/main.31e91b88.chunk.js"
87
+ "static/js/main.f1cf2dec.chunk.js"
88
88
  ]
89
89
  }
package/build/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'wasm-unsafe-eval' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src blob:; script-src-elem 'self' 'unsafe-inline' https:; style-src-elem 'self' 'unsafe-inline' https:; font-src 'self' data: https:; connect-src https://data.streamlit.io/ https://*.mapbox.com/ 'self' https:; img-src https: blob: data: file:; media-src https: blob:; frame-src https:"><link href="/static/css/6.69790b96.chunk.css" rel="stylesheet"><link href="/static/css/main.7bc75681.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="/static/js/runtime-main.e5a1f36a.js"></script><script src="/static/js/6.9c8c6dae.chunk.js"></script><script src="/static/js/main.31e91b88.chunk.js"></script></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'wasm-unsafe-eval' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src blob:; script-src-elem 'self' 'unsafe-inline' https:; style-src-elem 'self' 'unsafe-inline' https:; font-src 'self' data: https:; connect-src https://data.streamlit.io/ https://*.mapbox.com/ 'self' https:; img-src https: blob: data: file:; media-src https: blob:; frame-src https:"><link href="/static/css/6.69790b96.chunk.css" rel="stylesheet"><link href="/static/css/main.7bc75681.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="/static/js/runtime-main.e5a1f36a.js"></script><script src="/static/js/6.9c8c6dae.chunk.js"></script><script src="/static/js/main.f1cf2dec.chunk.js"></script></body></html>