@stlite/desktop 0.51.4 → 0.52.1
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 +5 -5
- package/build/asset-manifest.json +7 -7
- package/build/electron/worker.js +9 -9
- package/build/index.html +1 -1
- package/build/static/js/144.e3bb0311.chunk.js +1 -0
- package/build/static/js/1740.9ea891f4.chunk.js +1 -0
- package/build/static/js/3936.15716ddc.chunk.js +1 -0
- package/build/static/js/4785.0d35e4ac.chunk.js +1 -0
- package/build/static/js/6134.2d41a588.chunk.js +1 -0
- package/build/static/js/main.fe6eed7c.js +28 -0
- package/package.json +4 -4
- package/wheels/streamlit-1.32.2-cp311-none-any.whl +0 -0
- package/build/static/js/144.b10fb472.chunk.js +0 -1
- package/build/static/js/1740.c4ec1606.chunk.js +0 -1
- package/build/static/js/4681.2a5414e5.chunk.js +0 -1
- package/build/static/js/4785.63597083.chunk.js +0 -1
- package/build/static/js/6134.35028dd4.chunk.js +0 -1
- package/build/static/js/main.0c39d1eb.js +0 -28
- /package/build/static/js/{main.0c39d1eb.js.LICENSE.txt → main.fe6eed7c.js.LICENSE.txt} +0 -0
package/bin/dump_artifacts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var rt=Object.create;var re=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var M=(r,o)=>()=>(o||r((o={exports:{}}).exports,o),o.exports);var ct=(r,o,a,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let
|
|
3
|
-
`).filter(o=>!o.startsWith("#")).map(o=>o.replace(ut,"")).map(o=>o.trim()).filter(o=>o!=="")}F.parseRequirementsTxt=dt});var se=M(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.PromiseDelegate=void 0;var U=class{constructor(){this.promise=new Promise((o,a)=>{this.resolveInternal=o,this.rejectInternal=a})}resolve(o){this.resolveInternal(o)}reject(o){this.rejectInternal(o)}};z.PromiseDelegate=U});var ae=M(S=>{"use strict";var lt=S&&S.__createBinding||(Object.create?function(r,o,a,c){c===void 0&&(c=a);var f=Object.getOwnPropertyDescriptor(o,a);(!f||("get"in f?!o.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return o[a]}}),Object.defineProperty(r,c,f)}:function(r,o,a,c){c===void 0&&(c=a),r[c]=o[a]}),L=S&&S.__exportStar||function(r,o){for(var a in r)a!=="default"&&!Object.prototype.hasOwnProperty.call(o,a)&<(o,r,a)};Object.defineProperty(S,"__esModule",{value:!0});L(ie(),S);L(oe(),S);L(se(),S)});var K=M((B,ue)=>{(function(r,o){typeof B=="object"&&typeof ue<"u"?o(B):typeof define=="function"&&define.amd?define(["exports"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r.Superstruct={}))})(B,function(r){"use strict";class o extends TypeError{constructor(t,n){let i,{message:s,explanation:u,...l}=t,{path:y}=t,g=y.length===0?s:`At path: ${y.join(".")} -- ${s}`;super(u??g),u!=null&&(this.cause=g),Object.assign(this,l),this.name=this.constructor.name,this.failures=()=>i??(i=[t,...n()])}}function a(e){return c(e)&&typeof e[Symbol.iterator]=="function"}function c(e){return typeof e=="object"&&e!=null}function f(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function d(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function $(e){let{done:t,value:n}=e.next();return t?void 0:n}function j(e,t,n,i){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});let{path:s,branch:u}=t,{type:l}=n,{refinement:y,message:g=`Expected a value of type \`${l}\`${y?` with refinement \`${y}\``:""}, but received: \`${d(i)}\``}=e;return{value:i,type:l,refinement:y,key:s[s.length-1],path:s,branch:u,...e,message:g}}function*_(e,t,n,i){a(e)||(e=[e]);for(let s of e){let u=j(s,t,n,i);u&&(yield u)}}function*N(e,t,n={}){let{path:i=[],branch:s=[e],coerce:u=!1,mask:l=!1}=n,y={path:i,branch:s};if(u&&(e=t.coercer(e,y),l&&t.type!=="type"&&c(t.schema)&&c(e)&&!Array.isArray(e)))for(let p in e)t.schema[p]===void 0&&delete e[p];let g="valid";for(let p of t.validator(e,y))p.explanation=n.message,g="not_valid",yield[p,void 0];for(let[p,k,tt]of t.entries(e,y)){let nt=N(k,tt,{path:p===void 0?i:[...i,p],branch:p===void 0?s:[...s,k],coerce:u,mask:l,message:n.message});for(let I of nt)I[0]?(g=I[0].refinement!=null?"not_refined":"not_valid",yield[I[0],void 0]):u&&(k=I[1],p===void 0?e=k:e instanceof Map?e.set(p,k):e instanceof Set?e.add(k):c(e)&&(k!==void 0||p in e)&&(e[p]=k))}if(g!=="not_valid")for(let p of t.refiner(e,y))p.explanation=n.message,g="not_refined",yield[p,void 0];g==="valid"&&(yield[void 0,e])}class m{constructor(t){let{type:n,schema:i,validator:s,refiner:u,coercer:l=g=>g,entries:y=function*(){}}=t;this.type=n,this.schema=i,this.entries=y,this.coercer=l,s?this.validator=(g,p)=>{let k=s(g,p);return _(k,p,this,g)}:this.validator=()=>[],u?this.refiner=(g,p)=>{let k=u(g,p);return _(k,p,this,g)}:this.refiner=()=>[]}assert(t,n){return X(t,this,n)}create(t,n){return Y(t,this,n)}is(t){return W(t,this)}mask(t,n){return Z(t,this,n)}validate(t,n={}){return T(t,this,n)}}function X(e,t,n){let i=T(e,t,{message:n});if(i[0])throw i[0]}function Y(e,t,n){let i=T(e,t,{coerce:!0,message:n});if(i[0])throw i[0];return i[1]}function Z(e,t,n){let i=T(e,t,{coerce:!0,mask:!0,message:n});if(i[0])throw i[0];return i[1]}function W(e,t){return!T(e,t)[0]}function T(e,t,n={}){let i=N(e,t,n),s=$(i);return s[0]?[new o(s[0],function*(){for(let l of i)l[0]&&(yield l[0])}),void 0]:[void 0,s[1]]}function ke(...e){let t=e[0].type==="type",n=e.map(s=>s.schema),i=Object.assign({},...n);return t?E(i):v(i)}function b(e,t){return new m({type:e,schema:null,validator:t})}function Pe(e,t){return new m({...e,refiner:(n,i)=>n===void 0||e.refiner(n,i),validator(n,i){return n===void 0?!0:(t(n,i),e.validator(n,i))}})}function $e(e){return new m({type:"dynamic",schema:null,*entries(t,n){yield*e(t,n).entries(t,n)},validator(t,n){return e(t,n).validator(t,n)},coercer(t,n){return e(t,n).coercer(t,n)},refiner(t,n){return e(t,n).refiner(t,n)}})}function _e(e){let t;return new m({type:"lazy",schema:null,*entries(n,i){t??(t=e()),yield*t.entries(n,i)},validator(n,i){return t??(t=e()),t.validator(n,i)},coercer(n,i){return t??(t=e()),t.coercer(n,i)},refiner(n,i){return t??(t=e()),t.refiner(n,i)}})}function De(e,t){let{schema:n}=e,i={...n};for(let s of t)delete i[s];switch(e.type){case"type":return E(i);default:return v(i)}}function Se(e){let t=e instanceof m,n=t?{...e.schema}:{...e};for(let i in n)n[i]=x(n[i]);return t&&e.type==="type"?E(n):v(n)}function je(e,t){let{schema:n}=e,i={};for(let s of t)i[s]=n[s];switch(e.type){case"type":return E(i);default:return v(i)}}function Oe(e,t){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),b(e,t)}function Te(){return b("any",()=>!0)}function ve(e){return new m({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,i]of t.entries())yield[n,i,e]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${d(t)}`}})}function Ee(){return b("bigint",e=>typeof e=="bigint")}function Me(){return b("boolean",e=>typeof e=="boolean")}function qe(){return b("date",e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${d(e)}`)}function Ie(e){let t={},n=e.map(i=>d(i)).join();for(let i of e)t[i]=i;return new m({type:"enums",schema:t,validator(i){return e.includes(i)||`Expected one of \`${n}\`, but received: ${d(i)}`}})}function Ae(){return b("func",e=>typeof e=="function"||`Expected a function, but received: ${d(e)}`)}function Fe(e){return b("instance",t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${d(t)}`)}function ze(){return b("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${d(e)}`)}function Re(e){return new m({type:"intersection",schema:null,*entries(t,n){for(let i of e)yield*i.entries(t,n)},*validator(t,n){for(let i of e)yield*i.validator(t,n)},*refiner(t,n){for(let i of e)yield*i.refiner(t,n)}})}function Be(e){let t=d(e),n=typeof e;return new m({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?e:null,validator(i){return i===e||`Expected the literal \`${t}\`, but received: ${d(i)}`}})}function Je(e,t){return new m({type:"map",schema:null,*entries(n){if(e&&t&&n instanceof Map)for(let[i,s]of n.entries())yield[i,i,e],yield[i,s,t]},coercer(n){return n instanceof Map?new Map(n):n},validator(n){return n instanceof Map||`Expected a \`Map\` object, but received: ${d(n)}`}})}function C(){return b("never",()=>!1)}function Ne(e){return new m({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function We(){return b("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${d(e)}`)}function v(e){let t=e?Object.keys(e):[],n=C();return new m({type:"object",schema:e||null,*entries(i){if(e&&c(i)){let s=new Set(Object.keys(i));for(let u of t)s.delete(u),yield[u,i[u],e[u]];for(let u of s)yield[u,i[u],n]}},validator(i){return c(i)||`Expected an object, but received: ${d(i)}`},coercer(i){return c(i)?{...i}:i}})}function x(e){return new m({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function Ce(e,t){return new m({type:"record",schema:null,*entries(n){if(c(n))for(let i in n){let s=n[i];yield[i,i,e],yield[i,s,t]}},validator(n){return c(n)||`Expected an object, but received: ${d(n)}`}})}function He(){return b("regexp",e=>e instanceof RegExp)}function Ue(e){return new m({type:"set",schema:null,*entries(t){if(e&&t instanceof Set)for(let n of t)yield[n,n,e]},coercer(t){return t instanceof Set?new Set(t):t},validator(t){return t instanceof Set||`Expected a \`Set\` object, but received: ${d(t)}`}})}function ee(){return b("string",e=>typeof e=="string"||`Expected a string, but received: ${d(e)}`)}function Le(e){let t=C();return new m({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){let i=Math.max(e.length,n.length);for(let s=0;s<i;s++)yield[s,n[s],e[s]||t]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${d(n)}`}})}function E(e){let t=Object.keys(e);return new m({type:"type",schema:e,*entries(n){if(c(n))for(let i of t)yield[i,n[i],e[i]]},validator(n){return c(n)||`Expected an object, but received: ${d(n)}`},coercer(n){return c(n)?{...n}:n}})}function Ke(e){let t=e.map(n=>n.type).join(" | ");return new m({type:"union",schema:null,coercer(n){for(let i of e){let[s,u]=i.validate(n,{coerce:!0});if(!s)return u}return n},validator(n,i){let s=[];for(let u of e){let[...l]=N(n,u,i),[y]=l;if(y[0])for(let[g]of l)g&&s.push(g);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${d(n)}`,...s]}})}function te(){return b("unknown",()=>!0)}function H(e,t,n){return new m({...e,coercer:(i,s)=>W(i,t)?e.coercer(n(i,s),s):e.coercer(i,s)})}function Ge(e,t,n={}){return H(e,te(),i=>{let s=typeof t=="function"?t():t;if(i===void 0)return s;if(!n.strict&&f(i)&&f(s)){let u={...i},l=!1;for(let y in s)u[y]===void 0&&(u[y]=s[y],l=!0);if(l)return u}return i})}function Qe(e){return H(e,ee(),t=>t.trim())}function Ve(e){return O(e,"empty",t=>{let n=ne(t);return n===0||`Expected an empty ${e.type} but received one with a size of \`${n}\``})}function ne(e){return e instanceof Map||e instanceof Set?e.size:e.length}function Xe(e,t,n={}){let{exclusive:i}=n;return O(e,"max",s=>i?s<t:s<=t||`Expected a ${e.type} less than ${i?"":"or equal to "}${t} but received \`${s}\``)}function Ye(e,t,n={}){let{exclusive:i}=n;return O(e,"min",s=>i?s>t:s>=t||`Expected a ${e.type} greater than ${i?"":"or equal to "}${t} but received \`${s}\``)}function Ze(e){return O(e,"nonempty",t=>ne(t)>0||`Expected a nonempty ${e.type} but received an empty one`)}function xe(e,t){return O(e,"pattern",n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`)}function et(e,t,n=t){let i=`Expected a ${e.type}`,s=t===n?`of \`${t}\``:`between \`${t}\` and \`${n}\``;return O(e,"size",u=>{if(typeof u=="number"||u instanceof Date)return t<=u&&u<=n||`${i} ${s} but received \`${u}\``;if(u instanceof Map||u instanceof Set){let{size:l}=u;return t<=l&&l<=n||`${i} with a size ${s} but received one with a size of \`${l}\``}else{let{length:l}=u;return t<=l&&l<=n||`${i} with a length ${s} but received one with a length of \`${l}\``}})}function O(e,t,n){return new m({...e,*refiner(i,s){yield*e.refiner(i,s);let u=n(i,s),l=_(u,s,e,i);for(let y of l)yield{...y,refinement:t}}})}r.Struct=m,r.StructError=o,r.any=Te,r.array=ve,r.assert=X,r.assign=ke,r.bigint=Ee,r.boolean=Me,r.coerce=H,r.create=Y,r.date=qe,r.defaulted=Ge,r.define=b,r.deprecated=Pe,r.dynamic=$e,r.empty=Ve,r.enums=Ie,r.func=Ae,r.instance=Fe,r.integer=ze,r.intersection=Re,r.is=W,r.lazy=_e,r.literal=Be,r.map=Je,r.mask=Z,r.max=Xe,r.min=Ye,r.never=C,r.nonempty=Ze,r.nullable=Ne,r.number=We,r.object=v,r.omit=De,r.optional=x,r.partial=Se,r.pattern=xe,r.pick=je,r.record=Ce,r.refine=O,r.regexp=He,r.set=Ue,r.size=et,r.string=ee,r.struct=Oe,r.trimmed=Qe,r.tuple=Le,r.type=E,r.union=Ke,r.unknown=te,r.validate=T})});var ge=D(require("yargs")),he=require("yargs/helpers"),w=D(require("path")),P=D(require("fs/promises")),G=D(require("fs-extra")),Q=D(require("node-fetch")),V=require("pyodide"),J=D(ae());var ce=require("pyodide");function R(r){return`https://cdn.jsdelivr.net/pyodide/v${ce.version}/full/${r}`}var fe=D(require("node-fetch"));var q=class r{static _instance;_data=null;constructor(){}static async loadPrebuiltPackageData(){let o=R("pyodide-lock.json");return console.log(`Load the Pyodide pyodide-lock.json from ${o}`),(await(await(0,fe.default)(o,void 0)).json()).packages}static async getInstance(){return this._instance==null&&(this._instance=new r,this._instance._data=await this.loadPrebuiltPackageData()),this._instance}getPackageInfoByName(o){if(this._data==null)throw new Error("The package data is not loaded yet.");let a=Object.values(this._data).find(c=>c.name===o);if(a==null)throw new Error(`Package ${o} is not found in the lock file.`);return a}};var le=D(require("fs/promises")),pe=D(K());var h=D(K()),de=h.object({embed:h.defaulted(h.boolean(),!1),idbfsMountpoints:h.optional(h.array(h.string())),nodeJsWorker:h.defaulted(h.boolean(),!1),nodefsMountpoints:h.optional(h.record(h.string(),h.string()))});function pt(r){let o=pe.create(r??{},de);if(o.nodeJsWorker){if(o.idbfsMountpoints!=null)throw new Error("The `idbfsMountpoints` field is not allowed when `nodeJsWorker` is true.")}else if(o.nodefsMountpoints!=null)throw new Error("The `nodefsMountpoints` field is not allowed when `nodeJsWorker` is false.");return o}async function me(r){let a=require(r.packageJsonPath).stlite?.desktop,c=pt(a),f=JSON.stringify(c,null,2);console.log(`Dump the manifest file -> ${r.manifestFilePath}`),console.log(f),await le.default.writeFile(r.manifestFilePath,f,{encoding:"utf-8"})}global.fetch=Q.default;var mt="../build",yt="../wheels";async function be(r,o){let a=[],c=f=>{a.push(f)};if(await r.loadPackage(o,{errorCallback:c}),a.length>0)throw new Error(a.join(`
|
|
4
|
-
`))}async function
|
|
2
|
+
"use strict";var rt=Object.create;var re=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var M=(r,o)=>()=>(o||r((o={exports:{}}).exports,o),o.exports);var ct=(r,o,a,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of ot(o))!at.call(r,u)&&u!==a&&re(r,u,{get:()=>o[u],enumerable:!(c=it(o,u))||c.enumerable});return r};var S=(r,o,a)=>(a=r!=null?rt(st(r)):{},ct(o||!r||!r.__esModule?re(a,"default",{value:r,enumerable:!0}):a,r));var ie=M(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.validateRequirements=void 0;var ft="[",ut="(<=>!~",dt=";",lt="@",pt=new RegExp(`[${ft+ut+dt+lt}]`);function mt(r){return r.split(pt)[0].trim()}function yt(r){return r.forEach(a=>{let c;try{c=new URL(a)}catch{return}if(c.protocol==="emfs:"||c.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${a})`)}),r.filter(a=>mt(a)==="streamlit"?(console.warn(`Streamlit is specified in the requirements (${a}), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}A.validateRequirements=yt});var oe=M(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.parseRequirementsTxt=void 0;var gt=/\s#.*$/;function ht(r){return r.split(`
|
|
3
|
+
`).filter(o=>!o.startsWith("#")).map(o=>o.replace(gt,"")).map(o=>o.trim()).filter(o=>o!=="")}R.parseRequirementsTxt=ht});var se=M(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.PromiseDelegate=void 0;var U=class{constructor(){this.promise=new Promise((o,a)=>{this.resolveInternal=o,this.rejectInternal=a})}resolve(o){this.resolveInternal(o)}reject(o){this.rejectInternal(o)}};F.PromiseDelegate=U});var ae=M(O=>{"use strict";var bt=O&&O.__createBinding||(Object.create?function(r,o,a,c){c===void 0&&(c=a);var u=Object.getOwnPropertyDescriptor(o,a);(!u||("get"in u?!o.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return o[a]}}),Object.defineProperty(r,c,u)}:function(r,o,a,c){c===void 0&&(c=a),r[c]=o[a]}),L=O&&O.__exportStar||function(r,o){for(var a in r)a!=="default"&&!Object.prototype.hasOwnProperty.call(o,a)&&bt(o,r,a)};Object.defineProperty(O,"__esModule",{value:!0});L(ie(),O);L(oe(),O);L(se(),O)});var K=M((z,ue)=>{(function(r,o){typeof z=="object"&&typeof ue<"u"?o(z):typeof define=="function"&&define.amd?define(["exports"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r.Superstruct={}))})(z,function(r){"use strict";class o extends TypeError{constructor(t,n){let i,{message:s,explanation:f,...l}=t,{path:y}=t,g=y.length===0?s:`At path: ${y.join(".")} -- ${s}`;super(f??g),f!=null&&(this.cause=g),Object.assign(this,l),this.name=this.constructor.name,this.failures=()=>i??(i=[t,...n()])}}function a(e){return c(e)&&typeof e[Symbol.iterator]=="function"}function c(e){return typeof e=="object"&&e!=null}function u(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function d(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function k(e){let{done:t,value:n}=e.next();return t?void 0:n}function D(e,t,n,i){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});let{path:s,branch:f}=t,{type:l}=n,{refinement:y,message:g=`Expected a value of type \`${l}\`${y?` with refinement \`${y}\``:""}, but received: \`${d(i)}\``}=e;return{value:i,type:l,refinement:y,key:s[s.length-1],path:s,branch:f,...e,message:g}}function*_(e,t,n,i){a(e)||(e=[e]);for(let s of e){let f=D(s,t,n,i);f&&(yield f)}}function*W(e,t,n={}){let{path:i=[],branch:s=[e],coerce:f=!1,mask:l=!1}=n,y={path:i,branch:s};if(f&&(e=t.coercer(e,y),l&&t.type!=="type"&&c(t.schema)&&c(e)&&!Array.isArray(e)))for(let p in e)t.schema[p]===void 0&&delete e[p];let g="valid";for(let p of t.validator(e,y))p.explanation=n.message,g="not_valid",yield[p,void 0];for(let[p,P,tt]of t.entries(e,y)){let nt=W(P,tt,{path:p===void 0?i:[...i,p],branch:p===void 0?s:[...s,P],coerce:f,mask:l,message:n.message});for(let q of nt)q[0]?(g=q[0].refinement!=null?"not_refined":"not_valid",yield[q[0],void 0]):f&&(P=q[1],p===void 0?e=P:e instanceof Map?e.set(p,P):e instanceof Set?e.add(P):c(e)&&(P!==void 0||p in e)&&(e[p]=P))}if(g!=="not_valid")for(let p of t.refiner(e,y))p.explanation=n.message,g="not_refined",yield[p,void 0];g==="valid"&&(yield[void 0,e])}class m{constructor(t){let{type:n,schema:i,validator:s,refiner:f,coercer:l=g=>g,entries:y=function*(){}}=t;this.type=n,this.schema=i,this.entries=y,this.coercer=l,s?this.validator=(g,p)=>{let P=s(g,p);return _(P,p,this,g)}:this.validator=()=>[],f?this.refiner=(g,p)=>{let P=f(g,p);return _(P,p,this,g)}:this.refiner=()=>[]}assert(t,n){return V(t,this,n)}create(t,n){return Y(t,this,n)}is(t){return H(t,this)}mask(t,n){return Z(t,this,n)}validate(t,n={}){return j(t,this,n)}}function V(e,t,n){let i=j(e,t,{message:n});if(i[0])throw i[0]}function Y(e,t,n){let i=j(e,t,{coerce:!0,message:n});if(i[0])throw i[0];return i[1]}function Z(e,t,n){let i=j(e,t,{coerce:!0,mask:!0,message:n});if(i[0])throw i[0];return i[1]}function H(e,t){return!j(e,t)[0]}function j(e,t,n={}){let i=W(e,t,n),s=k(i);return s[0]?[new o(s[0],function*(){for(let l of i)l[0]&&(yield l[0])}),void 0]:[void 0,s[1]]}function ke(...e){let t=e[0].type==="type",n=e.map(s=>s.schema),i=Object.assign({},...n);return t?v(i):E(i)}function b(e,t){return new m({type:e,schema:null,validator:t})}function Pe(e,t){return new m({...e,refiner:(n,i)=>n===void 0||e.refiner(n,i),validator(n,i){return n===void 0?!0:(t(n,i),e.validator(n,i))}})}function $e(e){return new m({type:"dynamic",schema:null,*entries(t,n){yield*e(t,n).entries(t,n)},validator(t,n){return e(t,n).validator(t,n)},coercer(t,n){return e(t,n).coercer(t,n)},refiner(t,n){return e(t,n).refiner(t,n)}})}function _e(e){let t;return new m({type:"lazy",schema:null,*entries(n,i){t??(t=e()),yield*t.entries(n,i)},validator(n,i){return t??(t=e()),t.validator(n,i)},coercer(n,i){return t??(t=e()),t.coercer(n,i)},refiner(n,i){return t??(t=e()),t.refiner(n,i)}})}function Se(e,t){let{schema:n}=e,i={...n};for(let s of t)delete i[s];switch(e.type){case"type":return v(i);default:return E(i)}}function Oe(e){let t=e instanceof m,n=t?{...e.schema}:{...e};for(let i in n)n[i]=x(n[i]);return t&&e.type==="type"?v(n):E(n)}function De(e,t){let{schema:n}=e,i={};for(let s of t)i[s]=n[s];switch(e.type){case"type":return v(i);default:return E(i)}}function Te(e,t){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),b(e,t)}function je(){return b("any",()=>!0)}function Ee(e){return new m({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(let[n,i]of t.entries())yield[n,i,e]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${d(t)}`}})}function ve(){return b("bigint",e=>typeof e=="bigint")}function Me(){return b("boolean",e=>typeof e=="boolean")}function Ie(){return b("date",e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${d(e)}`)}function qe(e){let t={},n=e.map(i=>d(i)).join();for(let i of e)t[i]=i;return new m({type:"enums",schema:t,validator(i){return e.includes(i)||`Expected one of \`${n}\`, but received: ${d(i)}`}})}function Ae(){return b("func",e=>typeof e=="function"||`Expected a function, but received: ${d(e)}`)}function Re(e){return b("instance",t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${d(t)}`)}function Fe(){return b("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${d(e)}`)}function Ce(e){return new m({type:"intersection",schema:null,*entries(t,n){for(let i of e)yield*i.entries(t,n)},*validator(t,n){for(let i of e)yield*i.validator(t,n)},*refiner(t,n){for(let i of e)yield*i.refiner(t,n)}})}function ze(e){let t=d(e),n=typeof e;return new m({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?e:null,validator(i){return i===e||`Expected the literal \`${t}\`, but received: ${d(i)}`}})}function Ne(e,t){return new m({type:"map",schema:null,*entries(n){if(e&&t&&n instanceof Map)for(let[i,s]of n.entries())yield[i,i,e],yield[i,s,t]},coercer(n){return n instanceof Map?new Map(n):n},validator(n){return n instanceof Map||`Expected a \`Map\` object, but received: ${d(n)}`}})}function B(){return b("never",()=>!1)}function We(e){return new m({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function He(){return b("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${d(e)}`)}function E(e){let t=e?Object.keys(e):[],n=B();return new m({type:"object",schema:e||null,*entries(i){if(e&&c(i)){let s=new Set(Object.keys(i));for(let f of t)s.delete(f),yield[f,i[f],e[f]];for(let f of s)yield[f,i[f],n]}},validator(i){return c(i)||`Expected an object, but received: ${d(i)}`},coercer(i){return c(i)?{...i}:i}})}function x(e){return new m({...e,validator:(t,n)=>t===void 0||e.validator(t,n),refiner:(t,n)=>t===void 0||e.refiner(t,n)})}function Be(e,t){return new m({type:"record",schema:null,*entries(n){if(c(n))for(let i in n){let s=n[i];yield[i,i,e],yield[i,s,t]}},validator(n){return c(n)||`Expected an object, but received: ${d(n)}`}})}function Je(){return b("regexp",e=>e instanceof RegExp)}function Ue(e){return new m({type:"set",schema:null,*entries(t){if(e&&t instanceof Set)for(let n of t)yield[n,n,e]},coercer(t){return t instanceof Set?new Set(t):t},validator(t){return t instanceof Set||`Expected a \`Set\` object, but received: ${d(t)}`}})}function ee(){return b("string",e=>typeof e=="string"||`Expected a string, but received: ${d(e)}`)}function Le(e){let t=B();return new m({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){let i=Math.max(e.length,n.length);for(let s=0;s<i;s++)yield[s,n[s],e[s]||t]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${d(n)}`}})}function v(e){let t=Object.keys(e);return new m({type:"type",schema:e,*entries(n){if(c(n))for(let i of t)yield[i,n[i],e[i]]},validator(n){return c(n)||`Expected an object, but received: ${d(n)}`},coercer(n){return c(n)?{...n}:n}})}function Ke(e){let t=e.map(n=>n.type).join(" | ");return new m({type:"union",schema:null,coercer(n){for(let i of e){let[s,f]=i.validate(n,{coerce:!0});if(!s)return f}return n},validator(n,i){let s=[];for(let f of e){let[...l]=W(n,f,i),[y]=l;if(y[0])for(let[g]of l)g&&s.push(g);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${d(n)}`,...s]}})}function te(){return b("unknown",()=>!0)}function J(e,t,n){return new m({...e,coercer:(i,s)=>H(i,t)?e.coercer(n(i,s),s):e.coercer(i,s)})}function Xe(e,t,n={}){return J(e,te(),i=>{let s=typeof t=="function"?t():t;if(i===void 0)return s;if(!n.strict&&u(i)&&u(s)){let f={...i},l=!1;for(let y in s)f[y]===void 0&&(f[y]=s[y],l=!0);if(l)return f}return i})}function Ge(e){return J(e,ee(),t=>t.trim())}function Qe(e){return T(e,"empty",t=>{let n=ne(t);return n===0||`Expected an empty ${e.type} but received one with a size of \`${n}\``})}function ne(e){return e instanceof Map||e instanceof Set?e.size:e.length}function Ve(e,t,n={}){let{exclusive:i}=n;return T(e,"max",s=>i?s<t:s<=t||`Expected a ${e.type} less than ${i?"":"or equal to "}${t} but received \`${s}\``)}function Ye(e,t,n={}){let{exclusive:i}=n;return T(e,"min",s=>i?s>t:s>=t||`Expected a ${e.type} greater than ${i?"":"or equal to "}${t} but received \`${s}\``)}function Ze(e){return T(e,"nonempty",t=>ne(t)>0||`Expected a nonempty ${e.type} but received an empty one`)}function xe(e,t){return T(e,"pattern",n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`)}function et(e,t,n=t){let i=`Expected a ${e.type}`,s=t===n?`of \`${t}\``:`between \`${t}\` and \`${n}\``;return T(e,"size",f=>{if(typeof f=="number"||f instanceof Date)return t<=f&&f<=n||`${i} ${s} but received \`${f}\``;if(f instanceof Map||f instanceof Set){let{size:l}=f;return t<=l&&l<=n||`${i} with a size ${s} but received one with a size of \`${l}\``}else{let{length:l}=f;return t<=l&&l<=n||`${i} with a length ${s} but received one with a length of \`${l}\``}})}function T(e,t,n){return new m({...e,*refiner(i,s){yield*e.refiner(i,s);let f=n(i,s),l=_(f,s,e,i);for(let y of l)yield{...y,refinement:t}}})}r.Struct=m,r.StructError=o,r.any=je,r.array=Ee,r.assert=V,r.assign=ke,r.bigint=ve,r.boolean=Me,r.coerce=J,r.create=Y,r.date=Ie,r.defaulted=Xe,r.define=b,r.deprecated=Pe,r.dynamic=$e,r.empty=Qe,r.enums=qe,r.func=Ae,r.instance=Re,r.integer=Fe,r.intersection=Ce,r.is=H,r.lazy=_e,r.literal=ze,r.map=Ne,r.mask=Z,r.max=Ve,r.min=Ye,r.never=B,r.nonempty=Ze,r.nullable=We,r.number=He,r.object=E,r.omit=Se,r.optional=x,r.partial=Oe,r.pattern=xe,r.pick=De,r.record=Be,r.refine=T,r.regexp=Je,r.set=Ue,r.size=et,r.string=ee,r.struct=Te,r.trimmed=Ge,r.tuple=Le,r.type=v,r.union=Ke,r.unknown=te,r.validate=j})});var ge=S(require("yargs")),he=require("yargs/helpers"),w=S(require("path")),$=S(require("fs/promises")),X=S(require("fs-extra")),G=S(require("node-fetch")),Q=require("pyodide"),N=S(ae());var ce=require("pyodide");function C(r){return`https://cdn.jsdelivr.net/pyodide/v${ce.version}/full/${r}`}var fe=S(require("node-fetch"));var I=class r{static _instance;_data=null;constructor(){}static async loadPrebuiltPackageData(){let o=C("pyodide-lock.json");return console.log(`Load the Pyodide pyodide-lock.json from ${o}`),(await(await(0,fe.default)(o,void 0)).json()).packages}static async getInstance(){return this._instance==null&&(this._instance=new r,this._instance._data=await this.loadPrebuiltPackageData()),this._instance}getPackageInfoByName(o){if(this._data==null)throw new Error("The package data is not loaded yet.");let a=Object.values(this._data).find(c=>c.name===o);if(a==null)throw new Error(`Package ${o} is not found in the lock file.`);return a}};var le=S(require("fs/promises")),pe=S(K());var h=S(K()),de=h.object({embed:h.defaulted(h.boolean(),!1),idbfsMountpoints:h.optional(h.array(h.string())),nodeJsWorker:h.defaulted(h.boolean(),!1),nodefsMountpoints:h.optional(h.record(h.string(),h.string()))});function wt(r){let o=pe.create(r??{},de);if(o.nodeJsWorker){if(o.idbfsMountpoints!=null)throw new Error("The `idbfsMountpoints` field is not allowed when `nodeJsWorker` is true.")}else if(o.nodefsMountpoints!=null)throw new Error("The `nodefsMountpoints` field is not allowed when `nodeJsWorker` is false.");return o}async function me(r){let a=require(r.packageJsonPath).stlite?.desktop,c=wt(a),u=JSON.stringify(c,null,2);console.log(`Dump the manifest file -> ${r.manifestFilePath}`),console.log(u),await le.default.writeFile(r.manifestFilePath,u,{encoding:"utf-8"})}global.fetch=G.default;var kt="../build",Pt="../wheels";async function be(r,o){let a=[],c=u=>{a.push(u)};if(await r.loadPackage(o,{errorCallback:c}),a.length>0)throw new Error(a.join(`
|
|
4
|
+
`))}async function $t(r){console.info("Copy the build directory (the bare built app files) to this directory...");let o=w.default.resolve(__dirname,kt);if(!(await $.default.stat(o)).isDirectory())throw new Error(`The source ${o} does not exist.`);if(o===r.copyTo){console.warn(`sourceDir == destDir (${o}). Are you in the development environment? Skip copying the directory.`);return}if(r.keepOld)try{await $.default.access(r.copyTo),console.info(`${r.copyTo} already exists. Use it and skip copying.`);return}catch{throw new Error(`${r.copyTo} does not exist even though the \`keepOld\` option is specified`)}console.log(`Copy ${o} to ${r.copyTo}`),await $.default.rm(r.copyTo,{recursive:!0,force:!0}),await X.default.copy(o,r.copyTo)}async function _t(r){if(r.requirements.length===0)return[];let o=await(0,Q.loadPyodide)();return await we(o,{requirements:r.requirements}),Object.entries(o.loadedPackages).filter(([,a])=>a==="default channel").map(([a])=>a)}async function ye(r,o){console.log(`Preparing the local wheel ${o}`);let a=await $.default.readFile(o),c="/tmp/"+w.default.basename(o);r.FS.writeFile(c,a);let u=`emfs:${c}`;return console.log(`The local wheel ${o} is prepared as ${u}`),u}async function we(r,o){await be(r,"micropip");let a=r.pyimport("micropip"),c=[...o.requirements],u=w.default.join(__dirname,Pt),d=await ye(r,w.default.join(u,"stlite_server-0.1.0-py3-none-any.whl"));c.push(d);let k=await ye(r,w.default.join(u,"streamlit-1.32.2-cp311-none-any.whl"));c.push(k),console.log("Install the packages:",c),await a.install.callKwargs(c,{keep_going:!0})}async function St(r){console.info("Create the site-packages snapshot file...");let o=await(0,Q.loadPyodide)();await be(o,"micropip");let a=o.pyimport("micropip"),c=await I.getInstance(),u=[];r.usedPrebuiltPackages.length>0&&(console.log("Mocking prebuilt packages so that they will not be included in the site-packages snapshot because these will be installed from the vendored wheel files at runtime..."),r.usedPrebuiltPackages.forEach(D=>{let _=c.getPackageInfoByName(D);if(_==null)throw new Error(`Package ${D} is not found in the lock file.`);console.log(`Mock ${_.name} ${_.version}`),a.add_mock_package(_.name,_.version),u.push(_.name)})),console.log(`Install the requirements ${JSON.stringify(r.requirements)}`),await we(o,{requirements:r.requirements}),console.log("Remove the mocked packages",u),u.forEach(D=>a.remove_mock_package(D)),console.log("Archive the site-packages director(y|ies)");let d="/tmp/site-packages-snapshot.tar.gz";await o.runPythonAsync(`
|
|
5
5
|
import os
|
|
6
6
|
import tarfile
|
|
7
7
|
import site
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
print("Add site-package:", site_packages)
|
|
15
15
|
print(os.listdir(site_packages))
|
|
16
16
|
gzf.add(site_packages)
|
|
17
|
-
`),console.log("Extract the archive file from EMFS");let
|
|
18
|
-
`);await
|
|
17
|
+
`),console.log("Extract the archive file from EMFS");let k=o.FS.readFile(d);console.log(`Save the archive file (${r.saveTo})`),await $.default.writeFile(r.saveTo,k)}async function Ot(r){console.info("Copy the Streamlit app directory..."),console.log(`Copy ${r.sourceDir} to ${r.copyTo}`),await $.default.rm(r.copyTo,{recursive:!0,force:!0}),await X.default.copy(r.sourceDir,r.copyTo)}async function Dt(r){let o=await $.default.readFile(r,{encoding:"utf-8"});return(0,N.parseRequirementsTxt)(o)}async function Tt(r,o){let a=o.join(`
|
|
18
|
+
`);await $.default.writeFile(r,a,{encoding:"utf-8"})}async function jt(r){let o=await I.getInstance(),c=r.packages.map(u=>o.getPackageInfoByName(u)).map(u=>C(u.file_name));console.log("Downloading the used prebuilt packages..."),await Promise.all(c.map(async u=>{let d=w.default.resolve(r.destDir,"./pyodide",w.default.basename(u));console.log(`Download ${u} to ${d}`);let k=await(0,G.default)(u);if(!k.ok)throw new Error(`Failed to download ${u}: ${k.status} ${k.statusText}`);let D=await k.arrayBuffer();await $.default.writeFile(d,Buffer.from(D))}))}(0,ge.default)((0,he.hideBin)(process.argv)).command("* <appHomeDirSource> [packages..]","Put the user code and data and the snapshot of the required packages into the build artifact.",()=>{},r=>{console.info(r)}).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("keepOldBuild",{type:"boolean",default:!1,alias:"k",describe:"Keep the existing build directory contents except appHomeDir."}).parseAsync().then(async r=>{let o=process.cwd(),a=w.default.resolve(o,"./build");try{await $.default.access(r.appHomeDirSource)}catch{throw new Error(`${r.appHomeDirSource} does not exist.`)}let c=r.packages??[];for(let k of r.requirement)c=c.concat(await Dt(k));let u=(0,N.validateRequirements)(c),d=await _t({requirements:u});console.log("The prebuilt packages loaded for the given requirements:"),console.log(d),await $t({copyTo:a,keepOld:r.keepOldBuild}),await St({requirements:u,usedPrebuiltPackages:d,saveTo:w.default.resolve(a,"./site-packages-snapshot.tar.gz")}),await Tt(w.default.resolve(a,"./prebuilt-packages.txt"),d),await jt({packages:d,destDir:a}),await Ot({sourceDir:r.appHomeDirSource,copyTo:w.default.resolve(a,"./streamlit_app")}),await me({packageJsonPath:w.default.resolve(o,"./package.json"),manifestFilePath:w.default.resolve(a,"./stlite-manifest.json")})});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/static/css/main.fb5f4d99.css",
|
|
4
|
-
"main.js": "/static/js/main.
|
|
5
|
-
"static/js/
|
|
4
|
+
"main.js": "/static/js/main.fe6eed7c.js",
|
|
5
|
+
"static/js/3936.15716ddc.chunk.js": "/static/js/3936.15716ddc.chunk.js",
|
|
6
6
|
"static/js/4994.37361da4.chunk.js": "/static/js/4994.37361da4.chunk.js",
|
|
7
7
|
"static/js/3685.39209b63.chunk.js": "/static/js/3685.39209b63.chunk.js",
|
|
8
|
-
"static/js/4785.
|
|
8
|
+
"static/js/4785.0d35e4ac.chunk.js": "/static/js/4785.0d35e4ac.chunk.js",
|
|
9
9
|
"static/js/5299.478bd9da.chunk.js": "/static/js/5299.478bd9da.chunk.js",
|
|
10
10
|
"static/js/4482.6da0ecb0.chunk.js": "/static/js/4482.6da0ecb0.chunk.js",
|
|
11
11
|
"static/css/8957.cd5b39ce.chunk.css": "/static/css/8957.cd5b39ce.chunk.css",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"static/js/1122.9b0e508e.chunk.js": "/static/js/1122.9b0e508e.chunk.js",
|
|
18
18
|
"static/js/6802.615748ec.chunk.js": "/static/js/6802.615748ec.chunk.js",
|
|
19
19
|
"static/js/9311.26e5e737.chunk.js": "/static/js/9311.26e5e737.chunk.js",
|
|
20
|
-
"static/js/144.
|
|
20
|
+
"static/js/144.e3bb0311.chunk.js": "/static/js/144.e3bb0311.chunk.js",
|
|
21
21
|
"static/js/2940.b9c9a565.chunk.js": "/static/js/2940.b9c9a565.chunk.js",
|
|
22
22
|
"static/js/9001.5422e085.chunk.js": "/static/js/9001.5422e085.chunk.js",
|
|
23
23
|
"static/js/2873.69bb3f79.chunk.js": "/static/js/2873.69bb3f79.chunk.js",
|
|
24
|
-
"static/js/6134.
|
|
24
|
+
"static/js/6134.2d41a588.chunk.js": "/static/js/6134.2d41a588.chunk.js",
|
|
25
25
|
"static/js/1189.ff18a565.chunk.js": "/static/js/1189.ff18a565.chunk.js",
|
|
26
|
-
"static/js/1740.
|
|
26
|
+
"static/js/1740.9ea891f4.chunk.js": "/static/js/1740.9ea891f4.chunk.js",
|
|
27
27
|
"static/js/698.096ccf39.chunk.js": "/static/js/698.096ccf39.chunk.js",
|
|
28
28
|
"static/js/4724.444c1588.chunk.js": "/static/js/4724.444c1588.chunk.js",
|
|
29
29
|
"static/js/1729.3e10491c.chunk.js": "/static/js/1729.3e10491c.chunk.js",
|
|
@@ -162,6 +162,6 @@
|
|
|
162
162
|
},
|
|
163
163
|
"entrypoints": [
|
|
164
164
|
"static/css/main.fb5f4d99.css",
|
|
165
|
-
"static/js/main.
|
|
165
|
+
"static/js/main.fe6eed7c.js"
|
|
166
166
|
]
|
|
167
167
|
}
|
package/build/electron/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).filter(e=>!e.startsWith("#")).map(e=>e.replace(
|
|
1
|
+
var ce=Object.create;var J=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var F=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var me=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of ge(e))!ue.call(o,t)&&t!==r&&J(o,t,{get:()=>e[t],enumerable:!(s=de(e,t))||s.enumerable});return o};var K=(o,e,r)=>(r=o!=null?ce(fe(o)):{},me(e||!o||!o.__esModule?J(r,"default",{value:o,enumerable:!0}):r,o));var V=F(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.validateRequirements=void 0;var pe="[",_e="(<=>!~",ye=";",he="@",ve=new RegExp(`[${pe+_e+ye+he}]`);function be(o){return o.split(ve)[0].trim()}function Pe(o){return o.forEach(r=>{let s;try{s=new URL(r)}catch{return}if(s.protocol==="emfs:"||s.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${r})`)}),o.filter(r=>be(r)==="streamlit"?(console.warn(`Streamlit is specified in the requirements (${r}), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}E.validateRequirements=Pe});var X=F(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.parseRequirementsTxt=void 0;var we=/\s#.*$/;function Se(o){return o.split(`
|
|
2
|
+
`).filter(e=>!e.startsWith("#")).map(e=>e.replace(we,"")).map(e=>e.trim()).filter(e=>e!=="")}T.parseRequirementsTxt=Se});var G=F(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.PromiseDelegate=void 0;var D=class{constructor(){this.promise=new Promise((e,r)=>{this.resolveInternal=e,this.rejectInternal=r})}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}};M.PromiseDelegate=D});var Q=F(w=>{"use strict";var ke=w&&w.__createBinding||(Object.create?function(o,e,r,s){s===void 0&&(s=r);var t=Object.getOwnPropertyDescriptor(e,r);(!t||("get"in t?!e.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(o,s,t)}:function(o,e,r,s){s===void 0&&(s=r),o[s]=e[r]}),L=w&&w.__exportStar||function(o,e){for(var r in o)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ke(e,o,r)};Object.defineProperty(w,"__esModule",{value:!0});L(V(),w);L(X(),w);L(G(),w)});var ee=F((je,Z)=>{"use strict";function v(o){if(typeof o!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(o))}function Y(o,e){for(var r="",s=0,t=-1,a=0,n,i=0;i<=o.length;++i){if(i<o.length)n=o.charCodeAt(i);else{if(n===47)break;n=47}if(n===47){if(!(t===i-1||a===1))if(t!==i-1&&a===2){if(r.length<2||s!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){var d=r.lastIndexOf("/");if(d!==r.length-1){d===-1?(r="",s=0):(r=r.slice(0,d),s=r.length-1-r.lastIndexOf("/")),t=i,a=0;continue}}else if(r.length===2||r.length===1){r="",s=0,t=i,a=0;continue}}e&&(r.length>0?r+="/..":r="..",s=2)}else r.length>0?r+="/"+o.slice(t+1,i):r=o.slice(t+1,i),s=i-t-1;t=i,a=0}else n===46&&a!==-1?++a:a=-1}return r}function Re(o,e){var r=e.dir||e.root,s=e.base||(e.name||"")+(e.ext||"");return r?r===e.root?r+s:r+o+s:s}var k={resolve:function(){for(var e="",r=!1,s,t=arguments.length-1;t>=-1&&!r;t--){var a;t>=0?a=arguments[t]:(s===void 0&&(s=process.cwd()),a=s),v(a),a.length!==0&&(e=a+"/"+e,r=a.charCodeAt(0)===47)}return e=Y(e,!r),r?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(v(e),e.length===0)return".";var r=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;return e=Y(e,!r),e.length===0&&!r&&(e="."),e.length>0&&s&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return v(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,r=0;r<arguments.length;++r){var s=arguments[r];v(s),s.length>0&&(e===void 0?e=s:e+="/"+s)}return e===void 0?".":k.normalize(e)},relative:function(e,r){if(v(e),v(r),e===r||(e=k.resolve(e),r=k.resolve(r),e===r))return"";for(var s=1;s<e.length&&e.charCodeAt(s)===47;++s);for(var t=e.length,a=t-s,n=1;n<r.length&&r.charCodeAt(n)===47;++n);for(var i=r.length,d=i-n,p=a<d?a:d,f=-1,l=0;l<=p;++l){if(l===p){if(d>p){if(r.charCodeAt(n+l)===47)return r.slice(n+l+1);if(l===0)return r.slice(n+l)}else a>p&&(e.charCodeAt(s+l)===47?f=l:l===0&&(f=0));break}var _=e.charCodeAt(s+l),c=r.charCodeAt(n+l);if(_!==c)break;_===47&&(f=l)}var u="";for(l=s+f+1;l<=t;++l)(l===t||e.charCodeAt(l)===47)&&(u.length===0?u+="..":u+="/..");return u.length>0?u+r.slice(n+f):(n+=f,r.charCodeAt(n)===47&&++n,r.slice(n))},_makeLong:function(e){return e},dirname:function(e){if(v(e),e.length===0)return".";for(var r=e.charCodeAt(0),s=r===47,t=-1,a=!0,n=e.length-1;n>=1;--n)if(r=e.charCodeAt(n),r===47){if(!a){t=n;break}}else a=!1;return t===-1?s?"/":".":s&&t===1?"//":e.slice(0,t)},basename:function(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');v(e);var s=0,t=-1,a=!0,n;if(r!==void 0&&r.length>0&&r.length<=e.length){if(r.length===e.length&&r===e)return"";var i=r.length-1,d=-1;for(n=e.length-1;n>=0;--n){var p=e.charCodeAt(n);if(p===47){if(!a){s=n+1;break}}else d===-1&&(a=!1,d=n+1),i>=0&&(p===r.charCodeAt(i)?--i===-1&&(t=n):(i=-1,t=d))}return s===t?t=d:t===-1&&(t=e.length),e.slice(s,t)}else{for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===47){if(!a){s=n+1;break}}else t===-1&&(a=!1,t=n+1);return t===-1?"":e.slice(s,t)}},extname:function(e){v(e);for(var r=-1,s=0,t=-1,a=!0,n=0,i=e.length-1;i>=0;--i){var d=e.charCodeAt(i);if(d===47){if(!a){s=i+1;break}continue}t===-1&&(a=!1,t=i+1),d===46?r===-1?r=i:n!==1&&(n=1):r!==-1&&(n=-1)}return r===-1||t===-1||n===0||n===1&&r===t-1&&r===s+1?"":e.slice(r,t)},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 Re("/",e)},parse:function(e){v(e);var r={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return r;var s=e.charCodeAt(0),t=s===47,a;t?(r.root="/",a=1):a=0;for(var n=-1,i=0,d=-1,p=!0,f=e.length-1,l=0;f>=a;--f){if(s=e.charCodeAt(f),s===47){if(!p){i=f+1;break}continue}d===-1&&(p=!1,d=f+1),s===46?n===-1?n=f:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||d===-1||l===0||l===1&&n===d-1&&n===i+1?d!==-1&&(i===0&&t?r.base=r.name=e.slice(1,d):r.base=r.name=e.slice(i,d)):(i===0&&t?(r.name=e.slice(1,n),r.base=e.slice(1,d)):(r.name=e.slice(i,n),r.base=e.slice(i,d)),r.ext=e.slice(n,d)),i>0?r.dir=e.slice(0,i-1):t&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};k.posix=k;Z.exports=k});var j=require("node:worker_threads");var oe=K(Q());var U=K(ee());function re(o,e){let r=U.default.normalize(e),t=U.default.dirname(r).split("/"),a=[];for(let n of t){a.push(n);let i=a.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(d){throw console.error(`Failed to create a directory "${i}"`),d}}}function q(o,e,r,s){re(o,e),o.FS.writeFile(e,r,s)}function te(o,e,r){re(o,r),o.FS.rename(e,r)}var Ae="[",Fe="(<=>!~",Oe=";",Ie="@",Ce=new RegExp(`[${Ae+Fe+Oe+Ie}]`);function Ee(o){return o.split(Ce)[0].trim()}function H(o){return o.forEach(r=>{let s;try{s=new URL(r)}catch{return}if(s.protocol==="emfs:"||s.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${r})`)}),o.filter(r=>Ee(r)==="streamlit"?(console.warn(`Streamlit is specified in the requirements (${r}), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}function $(o){o.runPython(`
|
|
3
3
|
import micropip
|
|
4
4
|
micropip.add_mock_package(
|
|
5
5
|
"pyarrow", "0.0.1",
|
|
@@ -15,14 +15,14 @@ class Table:
|
|
|
15
15
|
"""
|
|
16
16
|
}
|
|
17
17
|
)
|
|
18
|
-
`)}async function
|
|
18
|
+
`)}async function Te(o,e){let r=o.slice(0,o.lastIndexOf("/")+1),s;return o.endsWith(".mjs")?s=(await import(o)).loadPyodide:(importScripts(o),s=N.loadPyodide),s({...e,indexURL:r})}var N=global;function se(o,e,r){function s(f){e({type:"event:progress",data:{message:f}})}let t,a,n=new oe.PromiseDelegate;async function i(){let f=await n.promise,l={...r,...f};console.debug("Initial data",l);let{entrypoint:_,files:c,archives:u,requirements:y,prebuiltPackageNames:S,wheels:h,mountedSitePackagesSnapshotFilePath:b,pyodideUrl:O=o,streamlitConfig:R,idbfsMountpoints:W,nodefsMountpoints:x}=l,I=H(y);s("Loading Pyodide."),console.debug("Loading Pyodide"),t=await Te(O,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide");let B=!1;if(W&&(B=!0,W.forEach(g=>{t.FS.mkdir(g),t.FS.mount(t.FS.filesystems.IDBFS,{},g)}),await new Promise((g,m)=>{t.FS.syncfs(!0,P=>{P?m(P):g()})})),x&&Object.entries(x).forEach(([g,m])=>{t.FS.mkdir(g),t.FS.mount(t.FS.filesystems.NODEFS,{root:m},g)}),s("Mounting files."),await Promise.all(Object.keys(c).map(async g=>{let m=c[g],P;"url"in m?(console.debug(`Fetch a file from ${m.url}`),P=await fetch(m.url).then(A=>A.arrayBuffer()).then(A=>new Uint8Array(A))):P=m.data;let{opts:C}=c[g];console.debug(`Write a file "${g}"`),q(t,g,P,C)})),s("Unpacking archives."),await Promise.all(u.map(async g=>{let m;"url"in g?(console.debug(`Fetch an archive from ${g.url}`),m=await fetch(g.url).then(A=>A.arrayBuffer())):m=g.buffer;let{format:P,options:C}=g;console.debug("Unpack an archive",{format:P,options:C}),t.unpackArchive(m,P,C)})),!b&&!h)throw new Error("Neither snapshot nor wheel files are provided.");b&&(s("Restoring the snapshot."),await t.runPythonAsync("import tarfile, shutil, site"),await t.runPythonAsync(`
|
|
19
19
|
site_packages_dirs = site.getsitepackages()
|
|
20
20
|
for site_packages in site_packages_dirs:
|
|
21
21
|
shutil.rmtree(site_packages)
|
|
22
22
|
`),console.debug(`Unarchive ${b}`),await t.runPythonAsync(`
|
|
23
23
|
with tarfile.open("${b}", "r") as tar_gz_file:
|
|
24
24
|
tar_gz_file.extractall("/")
|
|
25
|
-
`),console.debug("Restored the snapshot"),s("Mocking some packages."),console.debug("Mock pyarrow")
|
|
25
|
+
`),console.debug("Restored the snapshot"),s("Mocking some packages."),console.debug("Mock pyarrow"),$(t),console.debug("Mocked pyarrow")),s("Installing packages."),console.debug("Installing the prebuilt packages:",S),await t.loadPackage(S),console.debug("Installed the prebuilt packages"),await t.loadPackage("micropip");let z=t.pyimport("micropip");h?(console.debug("Installing the wheels:",h,"and the requirements:",I),await z.install.callKwargs([h.stliteServer,h.streamlit,...I],{keep_going:!0}),console.debug("Installed the wheels and the requirements"),s("Mocking some packages."),console.debug("Mock pyarrow"),$(t),console.debug("Mocked pyarrow")):(console.debug("Installing the requirements:",I),await z.install.callKwargs(I,{keep_going:!0}),console.debug("Installed the requirements")),await t.runPythonAsync(`
|
|
26
26
|
import importlib
|
|
27
27
|
importlib.invalidate_caches()
|
|
28
28
|
`),s("Loading streamlit package."),console.debug("Loading the Streamlit package"),await t.runPythonAsync(`
|
|
@@ -45,7 +45,7 @@ for name in streamlit.logger._loggers.keys():
|
|
|
45
45
|
logger.setLevel(logging.NOTSET)
|
|
46
46
|
|
|
47
47
|
streamlit.logger._loggers = {}
|
|
48
|
-
`);let
|
|
48
|
+
`);let ie=(g,m)=>{g>=40?console.error(m):g>=30?console.warn(m):g>=20?console.info(m):console.debug(m)};N.__logCallback__=ie,await t.runPythonAsync(`
|
|
49
49
|
def setup_loggers(streamlit_level, streamlit_message_format):
|
|
50
50
|
from js import __logCallback__
|
|
51
51
|
|
|
@@ -74,14 +74,14 @@ def setup_loggers(streamlit_level, streamlit_message_format):
|
|
|
74
74
|
streamlit_handler.setFormatter(streamlit_formatter)
|
|
75
75
|
streamlit_logger.addHandler(streamlit_handler)
|
|
76
76
|
streamlit_logger.setLevel(streamlit_level.upper())
|
|
77
|
-
`);let
|
|
77
|
+
`);let ae=(R?.["logger.level"]??"INFO").toString(),le=R?.["logger.messageFormat"]??"%(asctime)s %(message)s";if(t.globals.get("setup_loggers")(ae,le),console.debug("Set the loggers"),s("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),await t.runPythonAsync(`
|
|
78
78
|
import streamlit
|
|
79
79
|
|
|
80
80
|
def is_cacheable_msg(msg):
|
|
81
81
|
return False
|
|
82
82
|
|
|
83
83
|
streamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg
|
|
84
|
-
`),console.debug("Mocked some Streamlit functions"),
|
|
84
|
+
`),console.debug("Mocked some Streamlit functions"),B){s("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let g=!1;N.__scriptFinishedCallback__=()=>{console.debug("The script has finished. Syncing the filesystem."),g||(g=!0,t.FS.syncfs(!1,m=>{g=!1,m&&console.error(m)}))},await t.runPythonAsync(`
|
|
85
85
|
from streamlit.runtime.app_session import AppSession
|
|
86
86
|
from streamlit.runtime.scriptrunner import ScriptRunnerEvent
|
|
87
87
|
from js import __scriptFinishedCallback__
|
|
@@ -96,7 +96,7 @@ def wrap_app_session_on_scriptrunner_event(original_method):
|
|
|
96
96
|
return wrapped
|
|
97
97
|
|
|
98
98
|
AppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)
|
|
99
|
-
`),console.debug("Set up the IndexedDB filesystem synchronizer")}s("Booting up the Streamlit server."),console.debug("Booting up the Streamlit server"),
|
|
99
|
+
`),console.debug("Set up the IndexedDB filesystem synchronizer")}s("Booting up the Streamlit server."),console.debug("Booting up the Streamlit server"),N.__streamlitFlagOptions__={"browser.gatherUsageStats":!1,...R,"runner.fastReruns":!1},await t.runPythonAsync(`
|
|
100
100
|
from stlite_server.bootstrap import load_config_options, prepare
|
|
101
101
|
from stlite_server.server import Server
|
|
102
102
|
from js import __streamlitFlagOptions__
|
|
@@ -112,4 +112,4 @@ prepare(main_script_path, args)
|
|
|
112
112
|
|
|
113
113
|
server = Server(main_script_path, command_line)
|
|
114
114
|
server.start()
|
|
115
|
-
`),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),a=t.globals.get("server").copy(),console.debug("Set up the HTTP server"),e({type:"event:loaded"})}let
|
|
115
|
+
`),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),a=t.globals.get("server").copy(),console.debug("Set up the HTTP server"),e({type:"event:loaded"})}let d=i().catch(f=>{throw e({type:"event:error",data:{error:f}}),f}),p=async f=>{let l=f.data;if(l.type==="initData"){n.resolve(l.data);return}await d;let _=f.ports[0];try{switch(l.type){case"websocket:connect":{console.debug("websocket:connect",l.data);let{path:c}=l.data;a.start_websocket(c,(u,y)=>{if(y){let S=u,h=S.getBuffer("u8");S.destroy();let b=new Uint8ClampedArray(h.data.buffer,h.data.byteOffset,h.data.byteLength);e({type:"websocket:message",data:{payload:new Uint8Array(b)}})}else e({type:"websocket:message",data:{payload:u}})}),_.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",l.data);let{payload:c}=l.data;a.receive_websocket_from_js(c);break}case"http:request":{console.debug("http:request",l.data);let{request:c}=l.data,u=(y,S,h)=>{let b=S.toJs(),O=h.toJs();console.debug({statusCode:y,headers:b,body:O});let R={type:"http:response",data:{response:{statusCode:y,headers:b,body:O}}};_.postMessage(R)};a.receive_http_from_js(c.method,decodeURIComponent(c.path),c.headers,c.body,u);break}case"file:write":{let{path:c,data:u,opts:y}=l.data;console.debug(`Write a file "${c}"`),q(t,c,u,y),_.postMessage({type:"reply"});break}case"file:rename":{let{oldPath:c,newPath:u}=l.data;console.debug(`Rename "${c}" to ${u}`),te(t,c,u),_.postMessage({type:"reply"});break}case"file:unlink":{let{path:c}=l.data;console.debug(`Remove "${c}`),t.FS.unlink(c),_.postMessage({type:"reply"});break}case"install":{let{requirements:c}=l.data,u=t.pyimport("micropip"),y=H(c);console.debug("Install the requirements:",y),await u.install.callKwargs(y,{keep_going:!0}).then(()=>{console.debug("Successfully installed"),_.postMessage({type:"reply"})})}}}catch(c){if(console.error(c),!(c instanceof Error))throw c;let u=new Error(c.message);u.name=c.name,u.stack=c.stack,_.postMessage({type:"reply",error:u})}};return e({type:"event:start"}),p}function ne(){let o=process.env.NODEFS_MOUNTPOINTS;if(!o)return;let e;try{e=JSON.parse(o)}catch{console.error(`Failed to parse NODEFS_MOUNTPOINTS as JSON: ${o}`);return}if(typeof e!="object"){console.error(`NODEFS_MOUNTPOINTS is not an object: ${o}`);return}if(Array.isArray(e)){console.error(`NODEFS_MOUNTPOINTS is an array: ${o}`);return}if(Object.keys(e).some(r=>typeof r!="string")){console.error(`NODEFS_MOUNTPOINTS has non-string keys: ${o}`);return}if(Object.values(e).some(r=>typeof r!="string")){console.error(`NODEFS_MOUNTPOINTS has non-string values: ${o}`);return}return e}function Me(o){console.debug("[worker thread] postMessage from worker",o),j.parentPort?.postMessage(o)}var Ne=se(process.env.PYODIDE_URL,Me,{nodefsMountpoints:ne()});j.parentPort?.on("message",({data:o,port:e})=>{console.debug("[worker thread] parentPort.onMessage",{data:o,port:e}),Ne({data:o,ports:[e]})});
|
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><script defer="defer" src="/static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><script defer="defer" src="/static/js/main.fe6eed7c.js"></script><link href="/static/css/main.fb5f4d99.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[144],{10144:(t,e,i)=>{i.r(e),i.d(e,{default:()=>h});i(5057);var n=i(50651),o=i(75189),r=i(82160);const l=(0,r.Z)("div",{target:"e115fcil2"})((t=>{let{theme:e}=t;return{display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg}}),""),a=(0,r.Z)("div",{target:"e115fcil1"})((()=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0})),""),d=(0,r.Z)("div",{target:"e115fcil0"})((t=>{let{theme:e}=t;return{fontFamily:e.genericFonts.bodyFont,fontSize:e.fontSizes.sm,color:e.colors.fadedText60,textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:"0.125rem"}}),"");var s=i(96266),c=function(t){return t[t.OriginalWidth=-1]="OriginalWidth",t[t.ColumnWidth=-2]="ColumnWidth",t[t.AutoWidth=-3]="AutoWidth",t}(c||{});const h=(0,n.Z)((function(t){let{width:e,isFullScreen:i,element:n,height:r,endpoints:h}=t;const u=(0,o.$R)(n.imgs);let f;const g=n.width;if(g===c.OriginalWidth||g===c.AutoWidth)f=void 0;else if(g===c.ColumnWidth)f=e;else{if(!(g>0))throw Error("Invalid image width: ".concat(g));f=g}const m={};return r&&i?(m.maxHeight=r,m["object-fit"]="contain"):(m.width=f,g===c.AutoWidth&&(m.maxWidth="100%")),(0,s.jsx)(l,{style:{width:e},children:u.map(((t,e)=>{const i=t;return(0,s.jsxs)(a,{"data-testid":"stImage",children:[(0,s.jsx)("img",{style:m,src:h.buildMediaURL(i.url),alt:e.toString()}),i.caption&&(0,s.jsx)(d,{"data-testid":"stImageCaption",style:m,children:" ".concat(i.caption," ")})]},e)}))})}))}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[1740],{31740:(e,t,i)=>{i.r(t),i.d(t,{default:()=>o});i(5057);var s=i(44088),l=i(92649),d=i(38830),r=i(46403),n=i(75189),a=i(96266);const o=function(e){const{disabled:t,element:i,widgetMgr:o,width:u,endpoints:c}=e,h={width:u},b="primary"===i.type?s.nW.PRIMARY:s.nW.SECONDARY,p=(0,n.v_)(),w=!i.help||u;return(0,a.jsx)("div",{className:"row-widget stDownloadButton","data-testid":"stDownloadButton",style:h,children:(0,a.jsx)(l.t,{help:i.help,children:(0,a.jsx)(d.ZP,{kind:b,size:s.V5.SMALL,disabled:t,onClick:()=>{if(o.setTriggerValue(i,{fromUi:!0}),i.url.startsWith("/media"))return void(0,n.uP)(p,i.url);const e=document.createElement("a"),t=c.buildMediaURL(i.url);e.setAttribute("href",t),e.setAttribute("target","_self"),e.setAttribute("download",""),e.click()},fluidWidth:!!i.useContainerWidth&&w,children:(0,a.jsx)(r.ZP,{source:i.label,allowHTML:!1,isLabel:!0,largerLabel:!0,disableLinks:!0})})})})}}}]);
|
|
@@ -0,0 +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,a=0,i=0;i<=e.length;++i){if(i<e.length)n=e.charCodeAt(i);else{if(47===n)break;n=47}if(47===n){if(s===i-1||1===a);else if(s!==i-1&&2===a){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=i,a=0;continue}}else if(2===r.length||1===r.length){r="",o=0,s=i,a=0;continue}t&&(r.length>0?r+="/..":r="..",o=2)}else r.length>0?r+="/"+e.slice(s+1,i):r=e.slice(s+1,i),o=i-s-1;s=i,a=0}else 46===n&&-1!==a?++a:a=-1}return r}var r={resolve:function(){for(var e,r="",o=!1,s=arguments.length-1;s>=-1&&!o;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=process.cwd()),a=e),t(a),0!==a.length&&(r=a+"/"+r,o=47===a.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,a=s-o,i=1;i<n.length&&47===n.charCodeAt(i);++i);for(var l=n.length-i,c=a<l?a:l,g=-1,d=0;d<=c;++d){if(d===c){if(l>c){if(47===n.charCodeAt(i+d))return n.slice(i+d+1);if(0===d)return n.slice(i+d)}else a>c&&(47===e.charCodeAt(o+d)?g=d:0===d&&(g=0));break}var p=e.charCodeAt(o+d);if(p!==n.charCodeAt(i+d))break;47===p&&(g=d)}var u="";for(d=o+g+1;d<=s;++d)d!==s&&47!==e.charCodeAt(d)||(0===u.length?u+="..":u+="/..");return u.length>0?u+n.slice(i+g):(i+=g,47===n.charCodeAt(i)&&++i,n.slice(i))},_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,a=e.length-1;a>=1;--a)if(47===(n=e.charCodeAt(a))){if(!s){o=a;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,a=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var i=n.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!a){o=r+1;break}}else-1===l&&(a=!1,l=r+1),i>=0&&(c===n.charCodeAt(i)?-1===--i&&(s=r):(i=-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(!a){o=r+1;break}}else-1===s&&(a=!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,a=0,i=e.length-1;i>=0;--i){var l=e.charCodeAt(i);if(47!==l)-1===o&&(s=!1,o=i+1),46===l?-1===n?n=i:1!==a&&(a=1):-1!==n&&(a=-1);else if(!s){r=i+1;break}}return-1===n||-1===o||0===a||1===a&&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 a=-1,i=0,l=-1,c=!0,g=e.length-1,d=0;g>=r;--g)if(47!==(o=e.charCodeAt(g)))-1===l&&(c=!1,l=g+1),46===o?-1===a?a=g:1!==d&&(d=1):-1!==a&&(d=-1);else if(!c){i=g+1;break}return-1===a||-1===l||0===d||1===d&&a===l-1&&a===i+1?-1!==l&&(n.base=n.name=0===i&&s?e.slice(1,l):e.slice(i,l)):(0===i&&s?(n.name=e.slice(1,a),n.base=e.slice(1,l)):(n.name=e.slice(i,a),n.base=e.slice(i,l)),n.ext=e.slice(a,l)),i>0?n.dir=e.slice(0,i-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.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{new RegExp("[[(<=>!~;@]");class e{constructor(){this.promise=new Promise(((e,t)=>{this.resolveInternal=e,this.rejectInternal=t}))}resolve(e){this.resolveInternal(e)}reject(e){this.rejectInternal(e)}}var t=n(56977),r=n.n(t);function o(e,t){const n=r().normalize(t),o=r().dirname(n).split("/"),s=[];for(const r of o){s.push(r);const t=s.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(a){throw console.error(`Failed to create a directory "${t}"`),a}}}function s(e,t,n,r){o(e,t),e.FS.writeFile(t,n,r)}const a=new RegExp("[[(<=>!~;@]");function i(e){e.forEach((e=>{let t;try{t=new URL(e)}catch{return}if("emfs:"===t.protocol||"file:"===t.protocol)throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${e})`)}));return e.filter((e=>{const t="streamlit"===function(e){return e.split(a)[0].trim()}(e);return!t||(console.warn(`Streamlit is specified in the requirements (${e}), but it will be ignored. A built-in version of Streamlit will be used.`),!1)}))}function l(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 c=function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function a(e){try{l(r.next(e))}catch(t){s(t)}}function i(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(a,i)}l((r=r.apply(e,t||[])).next())}))};const g=n.g;self.onmessage=function(t,n,r){function a(e){n({type:"event:progress",data:{message:e}})}let d,p;const u=new e,h=function(){var e,o;return c(this,void 0,void 0,(function*(){const h=yield u.promise,m=Object.assign(Object.assign({},r),h);console.debug("Initial data",m);const{entrypoint:f,files:_,archives:y,requirements:b,prebuiltPackageNames:v,wheels:k,mountedSitePackagesSnapshotFilePath:w,pyodideUrl:S=t,streamlitConfig:A,idbfsMountpoints:P,nodefsMountpoints:C}=m,F=i(b);a("Loading Pyodide."),console.debug("Loading Pyodide"),d=yield function(e,t){return c(this,void 0,void 0,(function*(){const n=e.slice(0,e.lastIndexOf("/")+1);let r;return e.endsWith(".mjs")?r=(yield import(e)).loadPyodide:(importScripts(e),r=g.loadPyodide),r(Object.assign(Object.assign({},t),{indexURL:n}))}))}(S,{stdout:console.log,stderr:console.error}),console.debug("Loaded Pyodide");let O=!1;if(P&&(O=!0,P.forEach((e=>{d.FS.mkdir(e),d.FS.mount(d.FS.filesystems.IDBFS,{},e)})),yield new Promise(((e,t)=>{d.FS.syncfs(!0,(n=>{n?t(n):e()}))}))),C&&Object.entries(C).forEach((([e,t])=>{d.FS.mkdir(e),d.FS.mount(d.FS.filesystems.NODEFS,{root:t},e)})),a("Mounting files."),yield Promise.all(Object.keys(_).map((e=>c(this,void 0,void 0,(function*(){const t=_[e];let n;"url"in t?(console.debug(`Fetch a file from ${t.url}`),n=yield fetch(t.url).then((e=>e.arrayBuffer())).then((e=>new Uint8Array(e)))):n=t.data;const{opts:r}=_[e];console.debug(`Write a file "${e}"`),s(d,e,n,r)}))))),a("Unpacking archives."),yield Promise.all(y.map((e=>c(this,void 0,void 0,(function*(){let t;"url"in e?(console.debug(`Fetch an archive from ${e.url}`),t=yield fetch(e.url).then((e=>e.arrayBuffer()))):t=e.buffer;const{format:n,options:r}=e;console.debug("Unpack an archive",{format:n,options:r}),d.unpackArchive(t,n,r)}))))),!w&&!k)throw new Error("Neither snapshot nor wheel files are provided.");w&&(a("Restoring the snapshot."),yield d.runPythonAsync("import tarfile, shutil, site"),yield d.runPythonAsync("\nsite_packages_dirs = site.getsitepackages()\nfor site_packages in site_packages_dirs:\n shutil.rmtree(site_packages)\n"),console.debug(`Unarchive ${w}`),yield d.runPythonAsync(`\nwith tarfile.open("${w}", "r") as tar_gz_file:\n tar_gz_file.extractall("/")\n`),console.debug("Restored the snapshot"),a("Mocking some packages."),console.debug("Mock pyarrow"),l(d),console.debug("Mocked pyarrow")),a("Installing packages."),console.debug("Installing the prebuilt packages:",v),yield d.loadPackage(v),console.debug("Installed the prebuilt packages"),yield d.loadPackage("micropip");const j=d.pyimport("micropip");k?(console.debug("Installing the wheels:",k,"and the requirements:",F),yield j.install.callKwargs([k.stliteServer,k.streamlit,...F],{keep_going:!0}),console.debug("Installed the wheels and the requirements"),a("Mocking some packages."),console.debug("Mock pyarrow"),l(d),console.debug("Mocked pyarrow")):(console.debug("Installing the requirements:",F),yield j.install.callKwargs(F,{keep_going:!0}),console.debug("Installed the requirements")),yield d.runPythonAsync("\nimport importlib\nimportlib.invalidate_caches()\n"),a("Loading streamlit package."),console.debug("Loading the Streamlit package"),yield d.runPythonAsync("\nimport streamlit.runtime\n "),console.debug("Loaded the Streamlit package"),a("Setting up the loggers."),console.debug("Setting the loggers"),yield d.runPythonAsync('\nimport logging\nimport streamlit.logger\n\nstreamlit.logger.get_logger = logging.getLogger\nstreamlit.logger.setup_formatter = None\nstreamlit.logger.update_formatter = lambda *a, **k: None\nstreamlit.logger.set_log_level = lambda *a, **k: None\n\nfor name in streamlit.logger._loggers.keys():\n if name == "root":\n name = "streamlit"\n logger = logging.getLogger(name)\n logger.propagate = True\n logger.handlers.clear()\n logger.setLevel(logging.NOTSET)\n\nstreamlit.logger._loggers = {}\n');g.__logCallback__=(e,t)=>{e>=40?console.error(t):e>=30?console.warn(t):e>=20?console.info(t):console.debug(t)},yield d.runPythonAsync('\ndef setup_loggers(streamlit_level, streamlit_message_format):\n from js import __logCallback__\n\n\n class JsHandler(logging.Handler):\n def emit(self, record):\n msg = self.format(record)\n __logCallback__(record.levelno, msg)\n\n\n root_message_format = "%(levelname)s:%(name)s:%(message)s"\n\n root_logger = logging.getLogger()\n root_logger.handlers.clear()\n root_formatter = logging.Formatter(root_message_format)\n root_handler = JsHandler()\n root_handler.setFormatter(root_formatter)\n root_logger.addHandler(root_handler)\n root_logger.setLevel(logging.DEBUG)\n\n streamlit_logger = logging.getLogger("streamlit")\n streamlit_logger.propagate = False\n streamlit_logger.handlers.clear()\n streamlit_formatter = logging.Formatter(streamlit_message_format)\n streamlit_handler = JsHandler()\n streamlit_handler.setFormatter(streamlit_formatter)\n streamlit_logger.addHandler(streamlit_handler)\n streamlit_logger.setLevel(streamlit_level.upper())\n');const x=(null!==(e=null===A||void 0===A?void 0:A["logger.level"])&&void 0!==e?e:"INFO").toString(),I=null!==(o=null===A||void 0===A?void 0:A["logger.messageFormat"])&&void 0!==o?o:"%(asctime)s %(message)s";if(d.globals.get("setup_loggers")(x,I),console.debug("Set the loggers"),a("Mocking some Streamlit functions for the browser environment."),console.debug("Mocking some Streamlit functions"),yield d.runPythonAsync("\nimport streamlit\n\ndef is_cacheable_msg(msg):\n return False\n\nstreamlit.runtime.runtime.is_cacheable_msg = is_cacheable_msg\n"),console.debug("Mocked some Streamlit functions"),O){a("Setting up the IndexedDB filesystem synchronizer."),console.debug("Setting up the IndexedDB filesystem synchronizer");let e=!1;g.__scriptFinishedCallback__=()=>{console.debug("The script has finished. Syncing the filesystem."),e||(e=!0,d.FS.syncfs(!1,(t=>{e=!1,t&&console.error(t)})))},yield d.runPythonAsync('\nfrom streamlit.runtime.app_session import AppSession\nfrom streamlit.runtime.scriptrunner import ScriptRunnerEvent\nfrom js import __scriptFinishedCallback__\n\ndef wrap_app_session_on_scriptrunner_event(original_method):\n def wrapped(self, *args, **kwargs):\n if "event" in kwargs:\n event = kwargs["event"]\n if event == ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS or event == ScriptRunnerEvent.SCRIPT_STOPPED_FOR_RERUN or event == ScriptRunnerEvent.SHUTDOWN:\n __scriptFinishedCallback__()\n return original_method(self, *args, **kwargs)\n return wrapped\n\nAppSession._on_scriptrunner_event = wrap_app_session_on_scriptrunner_event(AppSession._on_scriptrunner_event)\n'),console.debug("Set up the IndexedDB filesystem synchronizer")}a("Booting up the Streamlit server."),console.debug("Booting up the Streamlit server"),g.__streamlitFlagOptions__=Object.assign(Object.assign({"browser.gatherUsageStats":!1},A),{"runner.fastReruns":!1}),yield d.runPythonAsync(`\nfrom stlite_server.bootstrap import load_config_options, prepare\nfrom stlite_server.server import Server\nfrom js import __streamlitFlagOptions__\n\nflag_options = __streamlitFlagOptions__.to_py()\nload_config_options(flag_options)\n\nmain_script_path = "${f}"\ncommand_line = None\nargs = []\n\nprepare(main_script_path, args)\n\nserver = Server(main_script_path, command_line)\nserver.start()\n`),console.debug("Booted up the Streamlit server"),console.debug("Setting up the HTTP server"),p=d.globals.get("server").copy(),console.debug("Set up the HTTP server"),n({type:"event:loaded"})}))}().catch((e=>{throw n({type:"event:error",data:{error:e}}),e}));return n({type:"event:start"}),e=>c(this,void 0,void 0,(function*(){const t=e.data;if("initData"===t.type)return void u.resolve(t.data);yield h;const r=e.ports[0];try{switch(t.type){case"websocket:connect":{console.debug("websocket:connect",t.data);const{path:e}=t.data;p.start_websocket(e,((e,t)=>{if(t){const t=e,r=t.getBuffer("u8");t.destroy();const o=new Uint8ClampedArray(r.data.buffer,r.data.byteOffset,r.data.byteLength);n({type:"websocket:message",data:{payload:new Uint8Array(o)}})}else{n({type:"websocket:message",data:{payload:e}})}})),r.postMessage({type:"reply"});break}case"websocket:send":{console.debug("websocket:send",t.data);const{payload:e}=t.data;p.receive_websocket_from_js(e);break}case"http:request":{console.debug("http:request",t.data);const{request:e}=t.data,n=(e,t,n)=>{const o=t.toJs(),s=n.toJs();console.debug({statusCode:e,headers:o,body:s});const a={type:"http:response",data:{response:{statusCode:e,headers:o,body:s}}};r.postMessage(a)};p.receive_http_from_js(e.method,decodeURIComponent(e.path),e.headers,e.body,n);break}case"file:write":{const{path:e,data:n,opts:o}=t.data;console.debug(`Write a file "${e}"`),s(d,e,n,o),r.postMessage({type:"reply"});break}case"file:rename":{const{oldPath:e,newPath:n}=t.data;console.debug(`Rename "${e}" to ${n}`),function(e,t,n){o(e,n),e.FS.rename(t,n)}(d,e,n),r.postMessage({type:"reply"});break}case"file:unlink":{const{path:e}=t.data;console.debug(`Remove "${e}`),d.FS.unlink(e),r.postMessage({type:"reply"});break}case"install":{const{requirements:e}=t.data,n=d.pyimport("micropip"),o=i(e);console.debug("Install the requirements:",o),yield n.install.callKwargs(o,{keep_going:!0}).then((()=>{console.debug("Successfully installed"),r.postMessage({type:"reply"})}))}}}catch(a){if(console.error(a),!(a instanceof Error))throw a;const e=new Error(a.message);e.name=a.name,e.stack=a.stack,r.postMessage({type:"reply",error:e})}}))}("https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.js",self.postMessage)})()})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[4785],{94785:(t,e,s)=>{s.r(e),s.d(e,{default:()=>d});var u=s(5057),i=s(75189),r=s(96266);function d(t){let{element:e,width:s,endpoints:d}=t;const n=(0,u.useRef)(null);(0,u.useEffect)((()=>{n.current&&(n.current.currentTime=e.startTime)}),[e.startTime]);const l=(0,i.O0)(e.url),a=d.buildMediaURL(l);return(0,r.jsx)("audio",{"data-testid":"stAudio",id:"audio",ref:n,controls:!0,src:a,className:"stAudio",style:{width:s}})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_stlite_desktop=self.webpackChunk_stlite_desktop||[]).push([[6134],{26134:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var s=r(5057),a=r(60913),i=r(94046),n=r(75189),d=r(96266);const l=528;function c(e){let{element:t,width:r,endpoints:c}=e;const o=(0,s.useRef)(null),{type:u,url:m,startTime:f,subtitles:h}=t,p=(0,n.O0)(m);(0,s.useEffect)((()=>{o.current&&(o.current.currentTime=f)}),[f]),(0,s.useEffect)((()=>{const e=o.current,r=()=>{e&&(e.currentTime=t.startTime)};return e&&e.addEventListener("loadedmetadata",r),()=>{e&&e.removeEventListener("loadedmetadata",r)}}),[t]);const k=e=>{const{startTime:r}=t;return r?"".concat(e,"?start=").concat(r):e};if(u===a.nk.Type.YOUTUBE_IFRAME){const e=0!==r?.75*r:l;return(0,d.jsx)("iframe",{"data-testid":"stVideo",title:p,src:k(p),width:r,height:e,style:{colorScheme:"light dark"},frameBorder:"0",allow:"autoplay; encrypted-media",allowFullScreen:!0})}return(0,d.jsx)("video",{"data-testid":"stVideo",ref:o,controls:!0,src:c.buildMediaURL(p),className:"stVideo",style:{width:r,height:0===r?l:void 0},crossOrigin:i.td&&h.length>0?"anonymous":void 0,children:h&&h.map(((e,t)=>(0,d.jsx)("track",{kind:"captions",src:c.buildMediaURL(e.url),label:e.label,default:0===t},t)))})}}}]);
|