@stlite/desktop 0.27.2 → 0.27.3

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/README.md CHANGED
@@ -12,7 +12,7 @@ Convert your [Streamlit](https://streamlit.io/) application into a desktop app w
12
12
  "main": "./build/electron/main.js",
13
13
  "scripts": {
14
14
  "dump": "dump-stlite-desktop-artifacts",
15
- "serve": "NODE_ENV=\"production\" electron .",
15
+ "serve": "cross-env NODE_ENV=production electron .",
16
16
  "pack": "electron-builder --dir",
17
17
  "dist": "electron-builder",
18
18
  "postinstall": "electron-builder install-app-deps"
@@ -25,6 +25,7 @@ Convert your [Streamlit](https://streamlit.io/) application into a desktop app w
25
25
  },
26
26
  "devDependencies": {
27
27
  "@stlite/desktop": "^0.25.0",
28
+ "cross-env": "^7.0.3",
28
29
  "electron": "23.1.1",
29
30
  "electron-builder": "^23.6.0"
30
31
  }
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "/static/css/main.b43a24ba.css",
4
- "main.js": "/static/js/main.ae72fb3d.js",
5
- "static/js/7073.08b496aa.chunk.js": "/static/js/7073.08b496aa.chunk.js",
4
+ "main.js": "/static/js/main.1d4d9c5e.js",
5
+ "static/js/7073.ac05e1ad.chunk.js": "/static/js/7073.ac05e1ad.chunk.js",
6
6
  "static/js/4994.8f0118ec.chunk.js": "/static/js/4994.8f0118ec.chunk.js",
7
- "static/js/9462.1c932557.chunk.js": "/static/js/9462.1c932557.chunk.js",
7
+ "static/js/9462.02aa4a97.chunk.js": "/static/js/9462.02aa4a97.chunk.js",
8
8
  "static/js/1367.9dcea0bc.chunk.js": "/static/js/1367.9dcea0bc.chunk.js",
9
9
  "static/js/5865.90a40692.chunk.js": "/static/js/5865.90a40692.chunk.js",
10
10
  "static/css/3683.60b7ada4.chunk.css": "/static/css/3683.60b7ada4.chunk.css",
@@ -15,12 +15,12 @@
15
15
  "static/js/2116.2e449b06.chunk.js": "/static/js/2116.2e449b06.chunk.js",
16
16
  "static/js/6097.56c4b02a.chunk.js": "/static/js/6097.56c4b02a.chunk.js",
17
17
  "static/js/91.f23bbeac.chunk.js": "/static/js/91.f23bbeac.chunk.js",
18
- "static/js/2632.6fe5e4a8.chunk.js": "/static/js/2632.6fe5e4a8.chunk.js",
18
+ "static/js/2632.2ce818e2.chunk.js": "/static/js/2632.2ce818e2.chunk.js",
19
19
  "static/js/9735.0e70600f.chunk.js": "/static/js/9735.0e70600f.chunk.js",
20
20
  "static/js/5678.b7f865a0.chunk.js": "/static/js/5678.b7f865a0.chunk.js",
21
- "static/js/9551.61e47ac7.chunk.js": "/static/js/9551.61e47ac7.chunk.js",
21
+ "static/js/9551.d488bda4.chunk.js": "/static/js/9551.d488bda4.chunk.js",
22
22
  "static/js/7937.a3bc5cdb.chunk.js": "/static/js/7937.a3bc5cdb.chunk.js",
23
- "static/js/3392.0d6a4b1f.chunk.js": "/static/js/3392.0d6a4b1f.chunk.js",
23
+ "static/js/3392.fc9c3f49.chunk.js": "/static/js/3392.fc9c3f49.chunk.js",
24
24
  "static/js/7496.37614377.chunk.js": "/static/js/7496.37614377.chunk.js",
25
25
  "static/js/3977.8a9ac9d7.chunk.js": "/static/js/3977.8a9ac9d7.chunk.js",
26
26
  "static/js/6242.5e6f91ac.chunk.js": "/static/js/6242.5e6f91ac.chunk.js",
@@ -151,6 +151,6 @@
151
151
  },
152
152
  "entrypoints": [
153
153
  "static/css/main.b43a24ba.css",
154
- "static/js/main.ae72fb3d.js"
154
+ "static/js/main.1d4d9c5e.js"
155
155
  ]
156
156
  }
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 'self' 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:"><script defer="defer" src="/static/js/main.ae72fb3d.js"></script><link href="/static/css/main.b43a24ba.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'wasm-unsafe-eval' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src 'self' 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:"><script defer="defer" src="/static/js/main.1d4d9c5e.js"></script><link href="/static/css/main.b43a24ba.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
@@ -1 +1 @@
1
- (globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[2632],{86926:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>p});var r=e(5057),n=e(89733),o=e(84584),a=e(85493),s=e(62658),l=e(22199),d=e(45490);const h=(0,d.Z)("div",{target:"etr89bj2"})((({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:t.spacing.lg})),""),c=(0,d.Z)("div",{target:"etr89bj1"})((({theme:t})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0})),""),g=(0,d.Z)("div",{target:"etr89bj0"})((({theme:t})=>({fontFamily:t.genericFonts.bodyFont,fontSize:t.fontSizes.sm,color:t.colors.fadedText60,textAlign:"center",marginTop:t.spacing.xs,wordWrap:"break-word",padding:"0.125rem"})),"");var u,m=e(96266);!function(t){t[t.OriginalWidth=-1]="OriginalWidth",t[t.ColumnWidth=-2]="ColumnWidth",t[t.AutoWidth=-3]="AutoWidth"}(u||(u={}));const p=(0,s.Z)((function({width:t,isFullScreen:i,element:e,height:s}){const{getBaseUriParts:d}=(0,r.useContext)(a.Z),p=(0,o.$R)(e.imgs);let f;const x=e.width;if(x===u.OriginalWidth||x===u.AutoWidth)f=void 0;else if(x===u.ColumnWidth)f=t;else{if(!(x>0))throw Error(`Invalid image width: ${x}`);f=x}const w={};return s&&i?(w.maxHeight=s,w["object-fit"]="contain"):(w.width=f,x===u.AutoWidth&&(w.maxWidth="100%")),(0,m.jsx)(h,{style:{width:t},children:p.map(((t,i)=>{const e=t;return(0,m.jsxs)(c,{"data-testid":"stImage",children:[e.markup?(0,n.ZP)((0,l.kB)(e.markup)):(0,m.jsx)("img",{style:w,src:(0,l.Bz)(e.url,d()),alt:i.toString()}),e.caption&&(0,m.jsx)(g,{"data-testid":"caption",style:w,children:` ${e.caption} `})]},i)}))})}))},24875:()=>{}}]);
1
+ (globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[2632],{86926:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>p});var r=e(5057),n=e(89733),o=e(70460),a=e(85493),s=e(62658),l=e(22199),d=e(45490);const h=(0,d.Z)("div",{target:"etr89bj2"})((({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:t.spacing.lg})),""),c=(0,d.Z)("div",{target:"etr89bj1"})((({theme:t})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0})),""),g=(0,d.Z)("div",{target:"etr89bj0"})((({theme:t})=>({fontFamily:t.genericFonts.bodyFont,fontSize:t.fontSizes.sm,color:t.colors.fadedText60,textAlign:"center",marginTop:t.spacing.xs,wordWrap:"break-word",padding:"0.125rem"})),"");var u,m=e(96266);!function(t){t[t.OriginalWidth=-1]="OriginalWidth",t[t.ColumnWidth=-2]="ColumnWidth",t[t.AutoWidth=-3]="AutoWidth"}(u||(u={}));const p=(0,s.Z)((function({width:t,isFullScreen:i,element:e,height:s}){const{getBaseUriParts:d}=(0,r.useContext)(a.Z),p=(0,o.$R)(e.imgs);let f;const x=e.width;if(x===u.OriginalWidth||x===u.AutoWidth)f=void 0;else if(x===u.ColumnWidth)f=t;else{if(!(x>0))throw Error(`Invalid image width: ${x}`);f=x}const w={};return s&&i?(w.maxHeight=s,w["object-fit"]="contain"):(w.width=f,x===u.AutoWidth&&(w.maxWidth="100%")),(0,m.jsx)(h,{style:{width:t},children:p.map(((t,i)=>{const e=t;return(0,m.jsxs)(c,{"data-testid":"stImage",children:[e.markup?(0,n.ZP)((0,l.kB)(e.markup)):(0,m.jsx)("img",{style:w,src:(0,l.Bz)(e.url,d()),alt:i.toString()}),e.caption&&(0,m.jsx)(g,{"data-testid":"caption",style:w,children:` ${e.caption} `})]},i)}))})}))},24875:()=>{}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[3392],{23392:(t,e,i)=>{i.r(e),i.d(e,{default:()=>a});var s=i(5057),l=i(85493),n=i(92445),r=i(46540),d=i(22199),o=i(84584),u=i(96266);const a=function(t){const{disabled:e,element:i,widgetMgr:a,width:c}=t,h={width:c},{getBaseUriParts:b}=(0,s.useContext)(l.Z),k=(0,o.v_)();return(0,u.jsx)("div",{className:"row-widget stDownloadButton",style:h,children:(0,u.jsx)(n.uD,{help:i.help,children:(0,u.jsx)(n.ZP,{kind:n.hY.SECONDARY,size:n.$u.SMALL,disabled:e,onClick:()=>{if(a.setTriggerValue(i,{fromUi:!0}),i.url.startsWith("/media"))return void(0,o.uP)(k,i.url);const t=document.createElement("a"),e=`${(0,d.Bz)(i.url,b())}?title=${encodeURIComponent(document.title)}`;t.setAttribute("href",e),t.setAttribute("target","_blank"),t.click()},fluidWidth:i.useContainerWidth||!1,children:(0,u.jsx)(r.Z,{source:i.label,allowHTML:!1,isButton:!0})})})})}}}]);
1
+ "use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[3392],{23392:(t,e,i)=>{i.r(e),i.d(e,{default:()=>a});var s=i(5057),l=i(85493),n=i(92445),r=i(46540),d=i(22199),o=i(70460),u=i(96266);const a=function(t){const{disabled:e,element:i,widgetMgr:a,width:c}=t,h={width:c},{getBaseUriParts:b}=(0,s.useContext)(l.Z),k=(0,o.v_)();return(0,u.jsx)("div",{className:"row-widget stDownloadButton",style:h,children:(0,u.jsx)(n.uD,{help:i.help,children:(0,u.jsx)(n.ZP,{kind:n.hY.SECONDARY,size:n.$u.SMALL,disabled:e,onClick:()=>{if(a.setTriggerValue(i,{fromUi:!0}),i.url.startsWith("/media"))return void(0,o.uP)(k,i.url);const t=document.createElement("a"),e=`${(0,d.Bz)(i.url,b())}?title=${encodeURIComponent(document.title)}`;t.setAttribute("href",e),t.setAttribute("target","_blank"),t.click()},fluidWidth:i.useContainerWidth||!1,children:(0,u.jsx)(r.Z,{source:i.label,allowHTML:!1,isButton:!0})})})})}}}]);
@@ -1 +1 @@
1
- (()=>{"use strict";var e={56977:e=>{function t(e){if("string"!==typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",o=0,s=-1,i=0,a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(47===n)break;n=47}if(47===n){if(s===a-1||1===i);else if(s!==a-1&&2===i){if(r.length<2||2!==o||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",o=0):o=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),s=a,i=0;continue}}else if(2===r.length||1===r.length){r="",o=0,s=a,i=0;continue}t&&(r.length>0?r+="/..":r="..",o=2)}else r.length>0?r+="/"+e.slice(s+1,a):r=e.slice(s+1,a),o=a-s-1;s=a,i=0}else 46===n&&-1!==i?++i:i=-1}return r}var r={resolve:function(){for(var e,r="",o=!1,s=arguments.length-1;s>=-1&&!o;s--){var i;s>=0?i=arguments[s]:(void 0===e&&(e=process.cwd()),i=e),t(i),0!==i.length&&(r=i+"/"+r,o=47===i.charCodeAt(0))}return r=n(r,!o),o?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),o=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&o&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,n=0;n<arguments.length;++n){var o=arguments[n];t(o),o.length>0&&(void 0===e?e=o:e+="/"+o)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var o=1;o<e.length&&47===e.charCodeAt(o);++o);for(var s=e.length,i=s-o,a=1;a<n.length&&47===n.charCodeAt(a);++a);for(var l=n.length-a,c=i<l?i:l,d=-1,g=0;g<=c;++g){if(g===c){if(l>c){if(47===n.charCodeAt(a+g))return n.slice(a+g+1);if(0===g)return n.slice(a+g)}else i>c&&(47===e.charCodeAt(o+g)?d=g:0===g&&(d=0));break}var u=e.charCodeAt(o+g);if(u!==n.charCodeAt(a+g))break;47===u&&(d=g)}var p="";for(g=o+d+1;g<=s;++g)g!==s&&47!==e.charCodeAt(g)||(0===p.length?p+="..":p+="/..");return p.length>0?p+n.slice(a+d):(a+=d,47===n.charCodeAt(a)&&++a,n.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,o=-1,s=!0,i=e.length-1;i>=1;--i)if(47===(n=e.charCodeAt(i))){if(!s){o=i;break}}else s=!1;return-1===o?r?"/":".":r&&1===o?"//":e.slice(0,o)},basename:function(e,n){if(void 0!==n&&"string"!==typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,o=0,s=-1,i=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var a=n.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!i){o=r+1;break}}else-1===l&&(i=!1,l=r+1),a>=0&&(c===n.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return o===s?s=l:-1===s&&(s=e.length),e.slice(o,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!i){o=r+1;break}}else-1===s&&(i=!1,s=r+1);return-1===s?"":e.slice(o,s)},extname:function(e){t(e);for(var n=-1,r=0,o=-1,s=!0,i=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===o&&(s=!1,o=a+1),46===l?-1===n?n=a:1!==i&&(i=1):-1!==n&&(i=-1);else if(!s){r=a+1;break}}return-1===n||-1===o||0===i||1===i&&n===o-1&&n===r+1?"":e.slice(n,o)},format:function(e){if(null===e||"object"!==typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}("/",e)},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,o=e.charCodeAt(0),s=47===o;s?(n.root="/",r=1):r=0;for(var i=-1,a=0,l=-1,c=!0,d=e.length-1,g=0;d>=r;--d)if(47!==(o=e.charCodeAt(d)))-1===l&&(c=!1,l=d+1),46===o?-1===i?i=d:1!==g&&(g=1):-1!==i&&(g=-1);else if(!c){a=d+1;break}return-1===i||-1===l||0===g||1===g&&i===l-1&&i===a+1?-1!==l&&(n.base=n.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(n.name=e.slice(1,i),n.base=e.slice(1,l)):(n.name=e.slice(a,i),n.base=e.slice(a,l)),n.ext=e.slice(i,l)),a>0?n.dir=e.slice(0,a-1):s&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e;!function(e){function t(e){return null===e||"boolean"===typeof e||"number"===typeof e||"string"===typeof e}function n(e){return Array.isArray(e)}function r(e,o){if(e===o)return!0;if(t(e)||t(o))return!1;var s=n(e),i=n(o);return s===i&&(s&&i?function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0,o=e.length;n<o;++n)if(!r(e[n],t[n]))return!1;return!0}(e,o):function(e,t){if(e===t)return!0;for(var n in e)if(void 0!==e[n]&&!(n in t))return!1;for(var n in t)if(void 0!==t[n]&&!(n in e))return!1;for(var n in e){var o=e[n],s=t[n];if(void 0!==o||void 0!==s){if(void 0===o||void 0===s)return!1;if(!r(o,s))return!1}}return!0}(e,o))}function o(e){return t(e)?e:n(e)?function(e){for(var t=new Array(e.length),n=0,r=e.length;n<r;++n)t[n]=o(e[n]);return t}(e):function(e){var t={};for(var n in e){var r=e[n];void 0!==r&&(t[n]=o(r))}return t}(e)}e.emptyObject=Object.freeze({}),e.emptyArray=Object.freeze([]),e.isPrimitive=t,e.isArray=n,e.isObject=function(e){return!t(e)&&!n(e)},e.deepEqual=r,e.deepCopy=o}(e||(e={}));!function(){function e(){this._types=[],this._values=[]}e.prototype.types=function(){return this._types.slice()},e.prototype.hasData=function(e){return-1!==this._types.indexOf(e)},e.prototype.getData=function(e){var t=this._types.indexOf(e);return-1!==t?this._values[t]:void 0},e.prototype.setData=function(e,t){this.clearData(e),this._types.push(e),this._values.push(t)},e.prototype.clearData=function(e){var t=this._types.indexOf(e);-1!==t&&(this._types.splice(t,1),this._values.splice(t,1))},e.prototype.clear=function(){this._types.length=0,this._values.length=0}}();var t,r,o=function(){function e(){var e=this;this.promise=new Promise((function(t,n){e._resolve=t,e._reject=n}))}return e.prototype.resolve=function(e){(0,this._resolve)(e)},e.prototype.reject=function(e){(0,this._reject)(e)},e}();function s(e){for(var t=0,n=0,r=e.length;n<r;++n)n%4===0&&(t=4294967295*Math.random()>>>0),e[n]=255&t,t>>>=8}!function(e){e.getRandomValues=function(){var e="undefined"!==typeof window&&(window.crypto||window.msCrypto)||null;return e&&"function"===typeof e.getRandomValues?function(t){return e.getRandomValues(t)}:s}()}(t||(t={})),function(e){e.uuid4=function(e){for(var t=new Uint8Array(16),n=new Array(256),r=0;r<16;++r)n[r]="0"+r.toString(16);for(r=16;r<256;++r)n[r]=r.toString(16);return function(){return e(t),t[6]=64|15&t[6],t[8]=128|63&t[8],n[t[0]]+n[t[1]]+n[t[2]]+n[t[3]]+"-"+n[t[4]]+n[t[5]]+"-"+n[t[6]]+n[t[7]]+"-"+n[t[8]]+n[t[9]]+"-"+n[t[10]]+n[t[11]]+n[t[12]]+n[t[13]]+n[t[14]]+n[t[15]]}}(t.getRandomValues)}(r||(r={}));var i=n(56977),a=n.n(i);function l(e,t){const n=a().normalize(t),r=a().dirname(n).split("/"),o=[];for(const i of r){o.push(i);const t=o.join("/");if(e.FS.analyzePath(t).exists){if(e.FS.isDir(t))throw new Error(`"${t}" already exists and is not a directory.`)}else try{e.FS.mkdir(t)}catch(s){throw console.error(`Failed to create a directory "${t}"`),s}}}function c(e,t,n,r){l(e,t),e.FS.writeFile(t,n,r)}function d(e){e.forEach((e=>{let t;try{t=new URL(e)}catch(n){return}if("emfs:"===t.protocol||"file:"===t.protocol)throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${e})`)}))}function g(e){e.runPython('\nimport micropip\nmicropip.add_mock_package(\n "pyarrow", "0.0.1",\n modules={\n "pyarrow": """\n__version__ = \'0.0.1\' # TODO: Update when releasing\n\n\nclass Table:\n @classmethod\n def from_pandas(*args, **kwargs):\n raise NotImplementedError("stlite is not supporting this method.")\n"""\n }\n)\n')}var u=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{l(r.next(e))}catch(t){s(t)}}function a(e){try{l(r.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}l((r=r.apply(e,t||[])).next())}))};let p,f;const h=self,m=new o;function y(e){h.postMessage({type:"event:progress",data:{message:e}})}const v=function(){return u(this,void 0,void 0,(function*(){const{entrypoint:e,files:t,requirements:n,wheels:r,mountedSitePackagesSnapshotFilePath:o,pyodideEntrypointUrl:s}=yield m.promise;if(y("Loading Pyodide."),console.debug("Import the entrypoint script."),importScripts(null!==s&&void 0!==s?s:"https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js"),console.debug("Loading Pyodide"),p=yield loadPyodide({stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide"),y("Mounting files."),Object.keys(t).forEach((e=>{const{data:n,opts:r}=t[e];console.debug(`Write a file "${e}"`),c(p,e,n,r)})),o)y("Restoring the snapshot."),yield p.runPythonAsync("import tarfile, shutil, site"),yield p.runPythonAsync("\n site_packages_dirs = site.getsitepackages()\n for site_packages in site_packages_dirs:\n shutil.rmtree(site_packages)\n "),console.debug(`Unarchive ${o}`),yield p.runPythonAsync(`\n with tarfile.open("${o}", "r") as tar_gz_file:\n tar_gz_file.extractall("/")\n `),console.debug("Restored the snapshot"),y("Mocking some packages."),console.debug("Mock pyarrow"),g(p),console.debug("Mocked pyarrow");else{if(!r)throw new Error("Neither snapshot nor wheel files are provided.");{y("Installing streamlit and its dependencies."),console.debug("Loading stlite-server, and streamlit"),yield p.loadPackage("micropip");const e=p.pyimport("micropip");yield e.install.callKwargs([r.stliteServer],{keep_going:!0}),yield e.install.callKwargs([r.streamlit],{keep_going:!0}),console.debug("Loaded stlite-server, and streamlit"),y("Mocking some packages."),console.debug("Mock pyarrow"),g(p),console.debug("Mocked pyarrow"),y("Installing the requirements."),console.debug("Installing the requirements:",n),d(n),yield e.install.callKwargs(n,{keep_going:!0}),console.debug("Installed the requirements:",n)}}yield p.runPythonAsync("\n import importlib\n importlib.invalidate_caches()\n "),y("Loading streamlit package."),console.debug("Loading the Streamlit package"),yield p.runPythonAsync("\n import streamlit.runtime\n import streamlit.web\n "),console.debug("Loaded the Streamlit package"),y("Setting up the loggers."),console.debug("Setting the loggers"),yield p.runPythonAsync("\n import logging\n import streamlit.logger\n\n streamlit.logger.get_logger = logging.getLogger\n streamlit.logger.setup_formatter = None\n streamlit.logger.update_formatter = lambda *a, **k: None\n streamlit.logger.set_log_level = lambda *a, **k: None\n ");self.__logCallback__=e=>{e.startsWith("CRITICAL")||e.startsWith("ERROR")?console.error(e):e.startsWith("WARNING")?console.warn(e):e.startsWith("INFO")?console.info(e):e.startsWith("DEBUG")?console.debug(e):console.log(e)},yield p.runPythonAsync('\n from js import __logCallback__\n\n\n class JsHandler(logging.Handler):\n def emit(self, record):\n msg = self.format(record)\n __logCallback__(msg)\n\n\n main_formatter = logging.Formatter("%(levelname)s:%(name)s:%(message)s")\n\n js_handler = JsHandler()\n js_handler.setFormatter(main_formatter)\n\n root_logger = logging.getLogger()\n root_logger.handlers.clear()\n root_logger.addHandler(js_handler)\n root_logger.setLevel(logging.DEBUG)\n\n streamlit_handler = logging.getLogger("streamlit")\n streamlit_handler.setLevel(logging.DEBUG)\n '),console.debug("Set the loggers"),y("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),yield p.runPythonAsync("\n import streamlit\n import contextlib\n\n @contextlib.contextmanager\n def spinner(*args, **kwargs):\n yield\n\n streamlit.spinner = spinner\n streamlit.runtime.caching.cache_utils.spinner = spinner\n streamlit.runtime.legacy_caching.caching.spinner = spinner\n "),console.debug("Mocked some Streamlit functions"),y("Booting up the Streamlit server."),console.debug("Booting up the Streamlit server"),yield p.runPythonAsync(`\n from stlite_server.bootstrap import load_config_options, prepare\n from stlite_server.server import Server\n\n load_config_options({\n "global.dataFrameSerialization": "legacy", # Not to use PyArrow\n "browser.gatherUsageStats": False,\n })\n\n main_script_path = "${e}"\n command_line = None\n args = []\n\n prepare(main_script_path, args)\n\n server = Server(main_script_path, command_line)\n server.start()\n `),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),f=p.globals.get("server").copy(),console.debug("Set up the HTTP server"),h.postMessage({type:"event:loaded"})}))}().catch((e=>{throw h.postMessage({type:"event:error",data:{error:e}}),e}));self.onmessage=e=>u(void 0,void 0,void 0,(function*(){const t=e.data;if("initData"===t.type)return void m.resolve(t.data);yield v;const n=e.ports[0];try{switch(t.type){case"websocket:connect":{console.debug("websocket:connect",t.data);const{path:e}=t.data;f.start_websocket(e,((e,t)=>{if(t){const t=e.getBuffer("u8");e.destroy();const n=new Uint8ClampedArray(t.data.buffer,t.data.byteOffset,t.data.byteLength);h.postMessage({type:"websocket:message",data:{payload:new Uint8Array(n)}})}else h.postMessage({type:"websocket:message",data:{payload:e}})})),n.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",t.data);const{payload:e}=t.data;f.receive_websocket_from_js(e);break}case"http:request":{console.debug("http:request",t.data);const{request:e}=t.data,r=(e,t,r)=>{const o=t.toJs(),s=r.toJs();console.debug({statusCode:e,headers:o,body:s});const i={type:"http:response",data:{response:{statusCode:e,headers:o,body:s}}};n.postMessage(i)};f.receive_http_from_js(e.method,e.path,e.headers,e.body,r);break}case"file:write":{const{path:e,data:r,opts:o}=t.data;console.debug(`Write a file "${e}"`),c(p,e,r,o),n.postMessage({type:"reply"});break}case"file:rename":{const{oldPath:e,newPath:r}=t.data;console.debug(`Rename "${e}" to ${r}`),function(e,t,n){l(e,n),e.FS.rename(t,n)}(p,e,r),n.postMessage({type:"reply"});break}case"file:unlink":{const{path:e}=t.data;console.debug(`Remove "${e}`),p.FS.unlink(e),n.postMessage({type:"reply"});break}case"install":{const{requirements:e}=t.data,r=p.pyimport("micropip");console.debug("Install the requirements:",e),d(e),yield r.install.callKwargs(e,{keep_going:!0}).then((()=>{if(e.includes("matplotlib"))return p.runPythonAsync("\n from stlite_server.bootstrap import _fix_matplotlib_crash\n _fix_matplotlib_crash()\n ")})).then((()=>{console.debug("Successfully installed"),n.postMessage({type:"reply"})}))}}}catch(r){n.postMessage({type:"reply",error:r})}})),h.postMessage({type:"event:start"})})()})();
1
+ (()=>{"use strict";var e={56977:e=>{function t(e){if("string"!==typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",o=0,s=-1,i=0,a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(47===n)break;n=47}if(47===n){if(s===a-1||1===i);else if(s!==a-1&&2===i){if(r.length<2||2!==o||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",o=0):o=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),s=a,i=0;continue}}else if(2===r.length||1===r.length){r="",o=0,s=a,i=0;continue}t&&(r.length>0?r+="/..":r="..",o=2)}else r.length>0?r+="/"+e.slice(s+1,a):r=e.slice(s+1,a),o=a-s-1;s=a,i=0}else 46===n&&-1!==i?++i:i=-1}return r}var r={resolve:function(){for(var e,r="",o=!1,s=arguments.length-1;s>=-1&&!o;s--){var i;s>=0?i=arguments[s]:(void 0===e&&(e=process.cwd()),i=e),t(i),0!==i.length&&(r=i+"/"+r,o=47===i.charCodeAt(0))}return r=n(r,!o),o?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),o=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&o&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,n=0;n<arguments.length;++n){var o=arguments[n];t(o),o.length>0&&(void 0===e?e=o:e+="/"+o)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var o=1;o<e.length&&47===e.charCodeAt(o);++o);for(var s=e.length,i=s-o,a=1;a<n.length&&47===n.charCodeAt(a);++a);for(var l=n.length-a,c=i<l?i:l,d=-1,g=0;g<=c;++g){if(g===c){if(l>c){if(47===n.charCodeAt(a+g))return n.slice(a+g+1);if(0===g)return n.slice(a+g)}else i>c&&(47===e.charCodeAt(o+g)?d=g:0===g&&(d=0));break}var u=e.charCodeAt(o+g);if(u!==n.charCodeAt(a+g))break;47===u&&(d=g)}var p="";for(g=o+d+1;g<=s;++g)g!==s&&47!==e.charCodeAt(g)||(0===p.length?p+="..":p+="/..");return p.length>0?p+n.slice(a+d):(a+=d,47===n.charCodeAt(a)&&++a,n.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,o=-1,s=!0,i=e.length-1;i>=1;--i)if(47===(n=e.charCodeAt(i))){if(!s){o=i;break}}else s=!1;return-1===o?r?"/":".":r&&1===o?"//":e.slice(0,o)},basename:function(e,n){if(void 0!==n&&"string"!==typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,o=0,s=-1,i=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var a=n.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!i){o=r+1;break}}else-1===l&&(i=!1,l=r+1),a>=0&&(c===n.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return o===s?s=l:-1===s&&(s=e.length),e.slice(o,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!i){o=r+1;break}}else-1===s&&(i=!1,s=r+1);return-1===s?"":e.slice(o,s)},extname:function(e){t(e);for(var n=-1,r=0,o=-1,s=!0,i=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===o&&(s=!1,o=a+1),46===l?-1===n?n=a:1!==i&&(i=1):-1!==n&&(i=-1);else if(!s){r=a+1;break}}return-1===n||-1===o||0===i||1===i&&n===o-1&&n===r+1?"":e.slice(n,o)},format:function(e){if(null===e||"object"!==typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+e+r:r}("/",e)},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,o=e.charCodeAt(0),s=47===o;s?(n.root="/",r=1):r=0;for(var i=-1,a=0,l=-1,c=!0,d=e.length-1,g=0;d>=r;--d)if(47!==(o=e.charCodeAt(d)))-1===l&&(c=!1,l=d+1),46===o?-1===i?i=d:1!==g&&(g=1):-1!==i&&(g=-1);else if(!c){a=d+1;break}return-1===i||-1===l||0===g||1===g&&i===l-1&&i===a+1?-1!==l&&(n.base=n.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(n.name=e.slice(1,i),n.base=e.slice(1,l)):(n.name=e.slice(a,i),n.base=e.slice(a,l)),n.ext=e.slice(i,l)),a>0?n.dir=e.slice(0,a-1):s&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e;!function(e){function t(e){return null===e||"boolean"===typeof e||"number"===typeof e||"string"===typeof e}function n(e){return Array.isArray(e)}function r(e,o){if(e===o)return!0;if(t(e)||t(o))return!1;var s=n(e),i=n(o);return s===i&&(s&&i?function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0,o=e.length;n<o;++n)if(!r(e[n],t[n]))return!1;return!0}(e,o):function(e,t){if(e===t)return!0;for(var n in e)if(void 0!==e[n]&&!(n in t))return!1;for(var n in t)if(void 0!==t[n]&&!(n in e))return!1;for(var n in e){var o=e[n],s=t[n];if(void 0!==o||void 0!==s){if(void 0===o||void 0===s)return!1;if(!r(o,s))return!1}}return!0}(e,o))}function o(e){return t(e)?e:n(e)?function(e){for(var t=new Array(e.length),n=0,r=e.length;n<r;++n)t[n]=o(e[n]);return t}(e):function(e){var t={};for(var n in e){var r=e[n];void 0!==r&&(t[n]=o(r))}return t}(e)}e.emptyObject=Object.freeze({}),e.emptyArray=Object.freeze([]),e.isPrimitive=t,e.isArray=n,e.isObject=function(e){return!t(e)&&!n(e)},e.deepEqual=r,e.deepCopy=o}(e||(e={}));!function(){function e(){this._types=[],this._values=[]}e.prototype.types=function(){return this._types.slice()},e.prototype.hasData=function(e){return-1!==this._types.indexOf(e)},e.prototype.getData=function(e){var t=this._types.indexOf(e);return-1!==t?this._values[t]:void 0},e.prototype.setData=function(e,t){this.clearData(e),this._types.push(e),this._values.push(t)},e.prototype.clearData=function(e){var t=this._types.indexOf(e);-1!==t&&(this._types.splice(t,1),this._values.splice(t,1))},e.prototype.clear=function(){this._types.length=0,this._values.length=0}}();var t,r,o=function(){function e(){var e=this;this.promise=new Promise((function(t,n){e._resolve=t,e._reject=n}))}return e.prototype.resolve=function(e){(0,this._resolve)(e)},e.prototype.reject=function(e){(0,this._reject)(e)},e}();function s(e){for(var t=0,n=0,r=e.length;n<r;++n)n%4===0&&(t=4294967295*Math.random()>>>0),e[n]=255&t,t>>>=8}!function(e){e.getRandomValues=function(){var e="undefined"!==typeof window&&(window.crypto||window.msCrypto)||null;return e&&"function"===typeof e.getRandomValues?function(t){return e.getRandomValues(t)}:s}()}(t||(t={})),function(e){e.uuid4=function(e){for(var t=new Uint8Array(16),n=new Array(256),r=0;r<16;++r)n[r]="0"+r.toString(16);for(r=16;r<256;++r)n[r]=r.toString(16);return function(){return e(t),t[6]=64|15&t[6],t[8]=128|63&t[8],n[t[0]]+n[t[1]]+n[t[2]]+n[t[3]]+"-"+n[t[4]]+n[t[5]]+"-"+n[t[6]]+n[t[7]]+"-"+n[t[8]]+n[t[9]]+"-"+n[t[10]]+n[t[11]]+n[t[12]]+n[t[13]]+n[t[14]]+n[t[15]]}}(t.getRandomValues)}(r||(r={}));var i=n(56977),a=n.n(i);function l(e,t){const n=a().normalize(t),r=a().dirname(n).split("/"),o=[];for(const i of r){o.push(i);const t=o.join("/");if(e.FS.analyzePath(t).exists){if(e.FS.isDir(t))throw new Error(`"${t}" already exists and is not a directory.`)}else try{e.FS.mkdir(t)}catch(s){throw console.error(`Failed to create a directory "${t}"`),s}}}function c(e,t,n,r){l(e,t),e.FS.writeFile(t,n,r)}function d(e){e.forEach((e=>{let t;try{t=new URL(e)}catch(n){return}if("emfs:"===t.protocol||"file:"===t.protocol)throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${e})`)}))}function g(e){e.runPython('\nimport micropip\nmicropip.add_mock_package(\n "pyarrow", "0.0.1",\n modules={\n "pyarrow": """\n__version__ = \'0.0.1\' # TODO: Update when releasing\n\n\nclass Table:\n @classmethod\n def from_pandas(*args, **kwargs):\n raise NotImplementedError("stlite is not supporting this method.")\n"""\n }\n)\n')}var u=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{l(r.next(e))}catch(t){s(t)}}function a(e){try{l(r.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}l((r=r.apply(e,t||[])).next())}))};let p,f;const h=self,m=new o;function y(e){h.postMessage({type:"event:progress",data:{message:e}})}const v=function(){return u(this,void 0,void 0,(function*(){const{entrypoint:e,files:t,requirements:n,wheels:r,mountedSitePackagesSnapshotFilePath:o,pyodideEntrypointUrl:s}=yield m.promise;if(y("Loading Pyodide."),console.debug("Import the entrypoint script."),importScripts(null!==s&&void 0!==s?s:"https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js"),console.debug("Loading Pyodide"),p=yield loadPyodide({stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide"),y("Mounting files."),Object.keys(t).forEach((e=>{const{data:n,opts:r}=t[e];console.debug(`Write a file "${e}"`),c(p,e,n,r)})),o)y("Restoring the snapshot."),yield p.runPythonAsync("import tarfile, shutil, site"),yield p.runPythonAsync("\n site_packages_dirs = site.getsitepackages()\n for site_packages in site_packages_dirs:\n shutil.rmtree(site_packages)\n "),console.debug(`Unarchive ${o}`),yield p.runPythonAsync(`\n with tarfile.open("${o}", "r") as tar_gz_file:\n tar_gz_file.extractall("/")\n `),console.debug("Restored the snapshot"),y("Mocking some packages."),console.debug("Mock pyarrow"),g(p),console.debug("Mocked pyarrow");else{if(!r)throw new Error("Neither snapshot nor wheel files are provided.");{y("Installing streamlit and its dependencies."),console.debug("Loading stlite-server, and streamlit"),yield p.loadPackage("micropip");const e=p.pyimport("micropip");yield e.install.callKwargs([r.stliteServer],{keep_going:!0}),yield e.install.callKwargs([r.streamlit],{keep_going:!0}),console.debug("Loaded stlite-server, and streamlit"),y("Mocking some packages."),console.debug("Mock pyarrow"),g(p),console.debug("Mocked pyarrow"),y("Installing the requirements."),console.debug("Installing the requirements:",n),d(n),yield e.install.callKwargs(n,{keep_going:!0}),console.debug("Installed the requirements:",n)}}yield p.runPythonAsync("\n import importlib\n importlib.invalidate_caches()\n "),y("Loading streamlit package."),console.debug("Loading the Streamlit package"),yield p.runPythonAsync("\n import streamlit.runtime\n import streamlit.web\n "),console.debug("Loaded the Streamlit package"),y("Setting up the loggers."),console.debug("Setting the loggers"),yield p.runPythonAsync("\n import logging\n import streamlit.logger\n\n streamlit.logger.get_logger = logging.getLogger\n streamlit.logger.setup_formatter = None\n streamlit.logger.update_formatter = lambda *a, **k: None\n streamlit.logger.set_log_level = lambda *a, **k: None\n ");self.__logCallback__=e=>{e.startsWith("CRITICAL")||e.startsWith("ERROR")?console.error(e):e.startsWith("WARNING")?console.warn(e):e.startsWith("INFO")?console.info(e):e.startsWith("DEBUG")?console.debug(e):console.log(e)},yield p.runPythonAsync('\n from js import __logCallback__\n\n\n class JsHandler(logging.Handler):\n def emit(self, record):\n msg = self.format(record)\n __logCallback__(msg)\n\n\n main_formatter = logging.Formatter("%(levelname)s:%(name)s:%(message)s")\n\n js_handler = JsHandler()\n js_handler.setFormatter(main_formatter)\n\n root_logger = logging.getLogger()\n root_logger.handlers.clear()\n root_logger.addHandler(js_handler)\n root_logger.setLevel(logging.DEBUG)\n\n streamlit_handler = logging.getLogger("streamlit")\n streamlit_handler.setLevel(logging.DEBUG)\n '),console.debug("Set the loggers"),y("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),yield p.runPythonAsync("\n import streamlit\n import contextlib\n\n @contextlib.contextmanager\n def spinner(*args, **kwargs):\n yield\n\n streamlit.spinner = spinner\n streamlit.runtime.caching.cache_utils.spinner = spinner\n streamlit.runtime.legacy_caching.caching.spinner = spinner\n "),yield p.runPythonAsync("\n def is_cacheable_msg(msg):\n return False\n\n streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg\n "),console.debug("Mocked some Streamlit functions"),y("Booting up the Streamlit server."),console.debug("Booting up the Streamlit server"),yield p.runPythonAsync(`\n from stlite_server.bootstrap import load_config_options, prepare\n from stlite_server.server import Server\n\n load_config_options({\n "global.dataFrameSerialization": "legacy", # Not to use PyArrow\n "browser.gatherUsageStats": False,\n })\n\n main_script_path = "${e}"\n command_line = None\n args = []\n\n prepare(main_script_path, args)\n\n server = Server(main_script_path, command_line)\n server.start()\n `),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),f=p.globals.get("server").copy(),console.debug("Set up the HTTP server"),h.postMessage({type:"event:loaded"})}))}().catch((e=>{throw h.postMessage({type:"event:error",data:{error:e}}),e}));self.onmessage=e=>u(void 0,void 0,void 0,(function*(){const t=e.data;if("initData"===t.type)return void m.resolve(t.data);yield v;const n=e.ports[0];try{switch(t.type){case"websocket:connect":{console.debug("websocket:connect",t.data);const{path:e}=t.data;f.start_websocket(e,((e,t)=>{if(t){const t=e.getBuffer("u8");e.destroy();const n=new Uint8ClampedArray(t.data.buffer,t.data.byteOffset,t.data.byteLength);h.postMessage({type:"websocket:message",data:{payload:new Uint8Array(n)}})}else h.postMessage({type:"websocket:message",data:{payload:e}})})),n.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",t.data);const{payload:e}=t.data;f.receive_websocket_from_js(e);break}case"http:request":{console.debug("http:request",t.data);const{request:e}=t.data,r=(e,t,r)=>{const o=t.toJs(),s=r.toJs();console.debug({statusCode:e,headers:o,body:s});const i={type:"http:response",data:{response:{statusCode:e,headers:o,body:s}}};n.postMessage(i)};f.receive_http_from_js(e.method,e.path,e.headers,e.body,r);break}case"file:write":{const{path:e,data:r,opts:o}=t.data;console.debug(`Write a file "${e}"`),c(p,e,r,o),n.postMessage({type:"reply"});break}case"file:rename":{const{oldPath:e,newPath:r}=t.data;console.debug(`Rename "${e}" to ${r}`),function(e,t,n){l(e,n),e.FS.rename(t,n)}(p,e,r),n.postMessage({type:"reply"});break}case"file:unlink":{const{path:e}=t.data;console.debug(`Remove "${e}`),p.FS.unlink(e),n.postMessage({type:"reply"});break}case"install":{const{requirements:e}=t.data,r=p.pyimport("micropip");console.debug("Install the requirements:",e),d(e),yield r.install.callKwargs(e,{keep_going:!0}).then((()=>{if(e.includes("matplotlib"))return p.runPythonAsync("\n from stlite_server.bootstrap import _fix_matplotlib_crash\n _fix_matplotlib_crash()\n ")})).then((()=>{console.debug("Successfully installed"),n.postMessage({type:"reply"})}))}}}catch(r){n.postMessage({type:"reply",error:r})}})),h.postMessage({type:"event:start"})})()})();
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[9462],{69462:(t,e,s)=>{s.r(e),s.d(e,{default:()=>n});var r=s(5057),u=s(85493),i=s(22199),a=s(84584),l=s(96266);function n({element:t,width:e}){const s=(0,r.useRef)(null),{getBaseUriParts:n}=(0,r.useContext)(u.Z);(0,r.useEffect)((()=>{s.current&&(s.current.currentTime=t.startTime)}),[t.startTime]);const c=(0,a.O0)(t.url),o=(0,i.Bz)(c,n());return(0,l.jsx)("audio",{id:"audio",ref:s,controls:!0,src:o,className:"stAudio",style:{width:e}})}}}]);
1
+ "use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[9462],{69462:(t,e,s)=>{s.r(e),s.d(e,{default:()=>n});var r=s(5057),u=s(85493),i=s(22199),a=s(70460),l=s(96266);function n({element:t,width:e}){const s=(0,r.useRef)(null),{getBaseUriParts:n}=(0,r.useContext)(u.Z);(0,r.useEffect)((()=>{s.current&&(s.current.currentTime=t.startTime)}),[t.startTime]);const c=(0,a.O0)(t.url),o=(0,i.Bz)(c,n());return(0,l.jsx)("audio",{id:"audio",ref:s,controls:!0,src:o,className:"stAudio",style:{width:e}})}}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[9551],{29551:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var s=r(5057),a=r(85493),n=r(32291),i=r(22199),l=r(84584),o=r(96266);const d=528;function c({element:e,width:t}){const r=(0,s.useRef)(null),{getBaseUriParts:c}=(0,s.useContext)(a.Z),{type:u,url:h}=e,m=(0,l.O0)(h);(0,s.useEffect)((()=>{const t=r.current,s=()=>{t&&(t.currentTime=e.startTime)};return t&&t.addEventListener("loadedmetadata",s),()=>{t&&t.removeEventListener("loadedmetadata",s)}}),[e]);const f=t=>{const{startTime:r}=e;return r?`${t}?start=${r}`:t};if(u===n.nk.Type.YOUTUBE_IFRAME){const e=0!==t?.75*t:d;return(0,o.jsx)("iframe",{title:m,src:f(m),width:t,height:e,frameBorder:"0",allow:"autoplay; encrypted-media",allowFullScreen:!0})}return(0,o.jsx)("video",{ref:r,controls:!0,src:(0,i.Bz)(m,c()),className:"stVideo",style:{width:t,height:0===t?d:void 0}})}}}]);
1
+ "use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[9551],{29551:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var s=r(5057),a=r(85493),n=r(32291),i=r(22199),l=r(70460),o=r(96266);const d=528;function c({element:e,width:t}){const r=(0,s.useRef)(null),{getBaseUriParts:c}=(0,s.useContext)(a.Z),{type:u,url:h}=e,m=(0,l.O0)(h);(0,s.useEffect)((()=>{const t=r.current,s=()=>{t&&(t.currentTime=e.startTime)};return t&&t.addEventListener("loadedmetadata",s),()=>{t&&t.removeEventListener("loadedmetadata",s)}}),[e]);const f=t=>{const{startTime:r}=e;return r?`${t}?start=${r}`:t};if(u===n.nk.Type.YOUTUBE_IFRAME){const e=0!==t?.75*t:d;return(0,o.jsx)("iframe",{title:m,src:f(m),width:t,height:e,frameBorder:"0",allow:"autoplay; encrypted-media",allowFullScreen:!0})}return(0,o.jsx)("video",{ref:r,controls:!0,src:(0,i.Bz)(m,c()),className:"stVideo",style:{width:t,height:0===t?d:void 0}})}}}]);