@stlite/desktop 0.53.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -16
- package/bin/dump_artifacts.js +8 -6
- package/build/asset-manifest.json +3 -3
- package/build/electron/main.js +2 -2
- package/build/electron/preload.js +1 -1
- package/build/electron/worker.js +2 -2
- package/build/index.html +1 -1
- package/build/static/js/3936.cd554a7f.chunk.js +1 -0
- package/build/static/js/main.444261b4.js +28 -0
- package/package.json +5 -4
- package/wheels/streamlit-1.33.0-cp311-none-any.whl +0 -0
- package/build/static/js/3936.370f1d0a.chunk.js +0 -1
- package/build/static/js/main.2c9aee1e.js +0 -28
- /package/build/static/js/{main.2c9aee1e.js.LICENSE.txt → main.444261b4.js.LICENSE.txt} +0 -0
package/README.md
CHANGED
|
@@ -30,29 +30,66 @@ Convert your [Streamlit](https://streamlit.io/) application into a desktop app w
|
|
|
30
30
|
"cross-env": "^7.0.3",
|
|
31
31
|
"electron": "^30.0.1",
|
|
32
32
|
"electron-builder": "^24.13.3"
|
|
33
|
+
},
|
|
34
|
+
"stlite": {
|
|
35
|
+
"desktop": {
|
|
36
|
+
"files": ["app.py"],
|
|
37
|
+
"entrypoint": "app.py"
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
41
|
```
|
|
36
42
|
2. Run `npm install` or `yarn install`.
|
|
37
|
-
3. Create `
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
3. Create `app.py` and write your Streamlit app code in it.
|
|
44
|
+
The file name `app.py` is specified both in the `stlite.desktop.files` field in the `package.json` and the `stlite.desktop.entrypoint` field. If you want to use a different file name, change the file name in both fields.
|
|
45
|
+
- `stlite.desktop.files` specifies the files and directories to be copied to the bundled desktop app.
|
|
46
|
+
- `stlite.desktop.entrypoint` specifies the entry point of the Streamlit app.
|
|
47
|
+
4. You can add more files and directories, such as `pages/*.py` for multi-page apps, any data files, and so on, by adding them to the `stlite.desktop.files` field in the `package.json`.
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
// ...other fields...
|
|
51
|
+
"stlite": {
|
|
52
|
+
"desktop": {
|
|
53
|
+
// ...other fields...
|
|
54
|
+
"files": ["app.py", "pages/*.py", "assets"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
5. You can specify the packages to install in the desktop app by adding `stlite.desktop.dependencies` and/or `stlite.desktop.requirementsTxtFiles` fields in the `package.json`.
|
|
60
|
+
- `stlite.desktop.dependencies` is an array of package names to install.
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
// ...other fields...
|
|
64
|
+
"stlite": {
|
|
65
|
+
"desktop": {
|
|
66
|
+
// ...other fields...
|
|
67
|
+
"dependencies": ["numpy", "pandas"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
- `stlite.desktop.requirementsTxtFiles` is an array of paths to `requirements.txt` files to install the packages listed in the files.
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
// ...other fields...
|
|
76
|
+
"stlite": {
|
|
77
|
+
"desktop": {
|
|
78
|
+
// ...other fields...
|
|
79
|
+
"requirementsTxtFiles": ["requirements.txt"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
6. Run `npm run dump` or `yarn dump`.
|
|
85
|
+
- This `dump` command creates `./build` directory that contains the copied Streamlit app files, dumped installed packages, Pyodide runtime, Electron app files, etc.
|
|
86
|
+
7. Run `npm run serve` or `yarn serve` for preview.
|
|
52
87
|
- This command is just a wrapper of `electron` command as you can see at the `"scripts"` field in the `package.json`. It launches Electron and starts the app with `./build/electron/main.js`, which is specified at the `"main"` field in the `package.json`.
|
|
53
|
-
|
|
88
|
+
8. Run `npm run dist` or `yarn dist` for packaging.
|
|
54
89
|
- This command bundles the `./build` directory created in the step above into application files (`.app`, `.exe`, `.dmg` etc.) in the `./dist` directory. To customize the built app, e.g. setting the icon, follow the [`electron-builder`](https://www.electron.build/) instructions.
|
|
55
90
|
|
|
91
|
+
See the [./samples](./samples) directory for sample projects.
|
|
92
|
+
|
|
56
93
|
## Use the latest version of Electron
|
|
57
94
|
|
|
58
95
|
To make your app secure, be sure to use the latest version of Electron.
|
package/bin/dump_artifacts.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
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 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
|
-
|
|
2
|
+
"use strict";var Hi=Object.create;var es=Object.defineProperty;var Ji=Object.getOwnPropertyDescriptor;var Ki=Object.getOwnPropertyNames;var Vi=Object.getPrototypeOf,Yi=Object.prototype.hasOwnProperty;var gt=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var Xi=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ki(t))!Yi.call(i,n)&&n!==e&&es(i,n,{get:()=>t[n],enumerable:!(s=Ji(t,n))||s.enumerable});return i};var U=(i,t,e)=>(e=i!=null?Hi(Vi(i)):{},Xi(t||!i||!i.__esModule?es(e,"default",{value:i,enumerable:!0}):e,i));var te=gt((Qt,ns)=>{(function(i,t){typeof Qt=="object"&&typeof ns<"u"?t(Qt):typeof define=="function"&&define.amd?define(["exports"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.Superstruct={}))})(Qt,function(i){"use strict";class t extends TypeError{constructor(c,f){let p,{message:S,explanation:v,...A}=c,{path:_}=c,F=_.length===0?S:`At path: ${_.join(".")} -- ${S}`;super(v??F),v!=null&&(this.cause=F),Object.assign(this,A),this.name=this.constructor.name,this.failures=()=>p??(p=[c,...f()])}}function e(l){return s(l)&&typeof l[Symbol.iterator]=="function"}function s(l){return typeof l=="object"&&l!=null}function n(l){if(Object.prototype.toString.call(l)!=="[object Object]")return!1;let c=Object.getPrototypeOf(l);return c===null||c===Object.prototype}function r(l){return typeof l=="symbol"?l.toString():typeof l=="string"?JSON.stringify(l):`${l}`}function o(l){let{done:c,value:f}=l.next();return c?void 0:f}function a(l,c,f,p){if(l===!0)return;l===!1?l={}:typeof l=="string"&&(l={message:l});let{path:S,branch:v}=c,{type:A}=f,{refinement:_,message:F=`Expected a value of type \`${A}\`${_?` with refinement \`${_}\``:""}, but received: \`${r(p)}\``}=l;return{value:p,type:A,refinement:_,key:S[S.length-1],path:S,branch:v,...l,message:F}}function*h(l,c,f,p){e(l)||(l=[l]);for(let S of l){let v=a(S,c,f,p);v&&(yield v)}}function*u(l,c,f={}){let{path:p=[],branch:S=[l],coerce:v=!1,mask:A=!1}=f,_={path:p,branch:S};if(v&&(l=c.coercer(l,_),A&&c.type!=="type"&&s(c.schema)&&s(l)&&!Array.isArray(l)))for(let D in l)c.schema[D]===void 0&&delete l[D];let F="valid";for(let D of c.validator(l,_))D.explanation=f.message,F="not_valid",yield[D,void 0];for(let[D,Y,qi]of c.entries(l,_)){let Gi=u(Y,qi,{path:D===void 0?p:[...p,D],branch:D===void 0?S:[...S,Y],coerce:v,mask:A,message:f.message});for(let Xt of Gi)Xt[0]?(F=Xt[0].refinement!=null?"not_refined":"not_valid",yield[Xt[0],void 0]):v&&(Y=Xt[1],D===void 0?l=Y:l instanceof Map?l.set(D,Y):l instanceof Set?l.add(Y):s(l)&&(Y!==void 0||D in l)&&(l[D]=Y))}if(F!=="not_valid")for(let D of c.refiner(l,_))D.explanation=f.message,F="not_refined",yield[D,void 0];F==="valid"&&(yield[void 0,l])}class d{constructor(c){let{type:f,schema:p,validator:S,refiner:v,coercer:A=F=>F,entries:_=function*(){}}=c;this.type=f,this.schema=p,this.entries=_,this.coercer=A,S?this.validator=(F,D)=>{let Y=S(F,D);return h(Y,D,this,F)}:this.validator=()=>[],v?this.refiner=(F,D)=>{let Y=v(F,D);return h(Y,D,this,F)}:this.refiner=()=>[]}assert(c,f){return m(c,this,f)}create(c,f){return g(c,this,f)}is(c){return k(c,this)}mask(c,f){return w(c,this,f)}validate(c,f={}){return y(c,this,f)}}function m(l,c,f){let p=y(l,c,{message:f});if(p[0])throw p[0]}function g(l,c,f){let p=y(l,c,{coerce:!0,message:f});if(p[0])throw p[0];return p[1]}function w(l,c,f){let p=y(l,c,{coerce:!0,mask:!0,message:f});if(p[0])throw p[0];return p[1]}function k(l,c){return!y(l,c)[0]}function y(l,c,f={}){let p=u(l,c,f),S=o(p);return S[0]?[new t(S[0],function*(){for(let A of p)A[0]&&(yield A[0])}),void 0]:[void 0,S[1]]}function E(...l){let c=l[0].type==="type",f=l.map(S=>S.schema),p=Object.assign({},...f);return c?Ft(p):_t(p)}function b(l,c){return new d({type:l,schema:null,validator:c})}function O(l,c){return new d({...l,refiner:(f,p)=>f===void 0||l.refiner(f,p),validator(f,p){return f===void 0?!0:(c(f,p),l.validator(f,p))}})}function x(l){return new d({type:"dynamic",schema:null,*entries(c,f){yield*l(c,f).entries(c,f)},validator(c,f){return l(c,f).validator(c,f)},coercer(c,f){return l(c,f).coercer(c,f)},refiner(c,f){return l(c,f).refiner(c,f)}})}function T(l){let c;return new d({type:"lazy",schema:null,*entries(f,p){c??(c=l()),yield*c.entries(f,p)},validator(f,p){return c??(c=l()),c.validator(f,p)},coercer(f,p){return c??(c=l()),c.coercer(f,p)},refiner(f,p){return c??(c=l()),c.refiner(f,p)}})}function P(l,c){let{schema:f}=l,p={...f};for(let S of c)delete p[S];switch(l.type){case"type":return Ft(p);default:return _t(p)}}function R(l){let c=l instanceof d,f=c?{...l.schema}:{...l};for(let p in f)f[p]=Xe(f[p]);return c&&l.type==="type"?Ft(f):_t(f)}function H(l,c){let{schema:f}=l,p={};for(let S of c)p[S]=f[S];switch(l.type){case"type":return Ft(p);default:return _t(p)}}function bt(l,c){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),b(l,c)}function V(){return b("any",()=>!0)}function St(l){return new d({type:"array",schema:l,*entries(c){if(l&&Array.isArray(c))for(let[f,p]of c.entries())yield[f,p,l]},coercer(c){return Array.isArray(c)?c.slice():c},validator(c){return Array.isArray(c)||`Expected an array value, but received: ${r(c)}`}})}function bi(){return b("bigint",l=>typeof l=="bigint")}function Si(){return b("boolean",l=>typeof l=="boolean")}function ki(){return b("date",l=>l instanceof Date&&!isNaN(l.getTime())||`Expected a valid \`Date\` object, but received: ${r(l)}`)}function Ei(l){let c={},f=l.map(p=>r(p)).join();for(let p of l)c[p]=p;return new d({type:"enums",schema:c,validator(p){return l.includes(p)||`Expected one of \`${f}\`, but received: ${r(p)}`}})}function vi(){return b("func",l=>typeof l=="function"||`Expected a function, but received: ${r(l)}`)}function Ti(l){return b("instance",c=>c instanceof l||`Expected a \`${l.name}\` instance, but received: ${r(c)}`)}function xi(){return b("integer",l=>typeof l=="number"&&!isNaN(l)&&Number.isInteger(l)||`Expected an integer, but received: ${r(l)}`)}function Oi(l){return new d({type:"intersection",schema:null,*entries(c,f){for(let p of l)yield*p.entries(c,f)},*validator(c,f){for(let p of l)yield*p.validator(c,f)},*refiner(c,f){for(let p of l)yield*p.refiner(c,f)}})}function Ai(l){let c=r(l),f=typeof l;return new d({type:"literal",schema:f==="string"||f==="number"||f==="boolean"?l:null,validator(p){return p===l||`Expected the literal \`${c}\`, but received: ${r(p)}`}})}function Pi(l,c){return new d({type:"map",schema:null,*entries(f){if(l&&c&&f instanceof Map)for(let[p,S]of f.entries())yield[p,p,l],yield[p,S,c]},coercer(f){return f instanceof Map?new Map(f):f},validator(f){return f instanceof Map||`Expected a \`Map\` object, but received: ${r(f)}`}})}function xe(){return b("never",()=>!1)}function Ri(l){return new d({...l,validator:(c,f)=>c===null||l.validator(c,f),refiner:(c,f)=>c===null||l.refiner(c,f)})}function Di(){return b("number",l=>typeof l=="number"&&!isNaN(l)||`Expected a number, but received: ${r(l)}`)}function _t(l){let c=l?Object.keys(l):[],f=xe();return new d({type:"object",schema:l||null,*entries(p){if(l&&s(p)){let S=new Set(Object.keys(p));for(let v of c)S.delete(v),yield[v,p[v],l[v]];for(let v of S)yield[v,p[v],f]}},validator(p){return s(p)||`Expected an object, but received: ${r(p)}`},coercer(p){return s(p)?{...p}:p}})}function Xe(l){return new d({...l,validator:(c,f)=>c===void 0||l.validator(c,f),refiner:(c,f)=>c===void 0||l.refiner(c,f)})}function _i(l,c){return new d({type:"record",schema:null,*entries(f){if(s(f))for(let p in f){let S=f[p];yield[p,p,l],yield[p,S,c]}},validator(f){return s(f)||`Expected an object, but received: ${r(f)}`}})}function Fi(){return b("regexp",l=>l instanceof RegExp)}function Ci(l){return new d({type:"set",schema:null,*entries(c){if(l&&c instanceof Set)for(let f of c)yield[f,f,l]},coercer(c){return c instanceof Set?new Set(c):c},validator(c){return c instanceof Set||`Expected a \`Set\` object, but received: ${r(c)}`}})}function Ze(){return b("string",l=>typeof l=="string"||`Expected a string, but received: ${r(l)}`)}function Mi(l){let c=xe();return new d({type:"tuple",schema:null,*entries(f){if(Array.isArray(f)){let p=Math.max(l.length,f.length);for(let S=0;S<p;S++)yield[S,f[S],l[S]||c]}},validator(f){return Array.isArray(f)||`Expected an array, but received: ${r(f)}`}})}function Ft(l){let c=Object.keys(l);return new d({type:"type",schema:l,*entries(f){if(s(f))for(let p of c)yield[p,f[p],l[p]]},validator(f){return s(f)||`Expected an object, but received: ${r(f)}`},coercer(f){return s(f)?{...f}:f}})}function ji(l){let c=l.map(f=>f.type).join(" | ");return new d({type:"union",schema:null,coercer(f){for(let p of l){let[S,v]=p.validate(f,{coerce:!0});if(!S)return v}return f},validator(f,p){let S=[];for(let v of l){let[...A]=u(f,v,p),[_]=A;if(_[0])for(let[F]of A)F&&S.push(F);else return[]}return[`Expected the value to satisfy a union of \`${c}\`, but received: ${r(f)}`,...S]}})}function Qe(){return b("unknown",()=>!0)}function Oe(l,c,f){return new d({...l,coercer:(p,S)=>k(p,c)?l.coercer(f(p,S),S):l.coercer(p,S)})}function Ni(l,c,f={}){return Oe(l,Qe(),p=>{let S=typeof c=="function"?c():c;if(p===void 0)return S;if(!f.strict&&n(p)&&n(S)){let v={...p},A=!1;for(let _ in S)v[_]===void 0&&(v[_]=S[_],A=!0);if(A)return v}return p})}function $i(l){return Oe(l,Ze(),c=>c.trim())}function Ii(l){return mt(l,"empty",c=>{let f=ts(c);return f===0||`Expected an empty ${l.type} but received one with a size of \`${f}\``})}function ts(l){return l instanceof Map||l instanceof Set?l.size:l.length}function Li(l,c,f={}){let{exclusive:p}=f;return mt(l,"max",S=>p?S<c:S<=c||`Expected a ${l.type} less than ${p?"":"or equal to "}${c} but received \`${S}\``)}function Wi(l,c,f={}){let{exclusive:p}=f;return mt(l,"min",S=>p?S>c:S>=c||`Expected a ${l.type} greater than ${p?"":"or equal to "}${c} but received \`${S}\``)}function zi(l){return mt(l,"nonempty",c=>ts(c)>0||`Expected a nonempty ${l.type} but received an empty one`)}function Bi(l,c){return mt(l,"pattern",f=>c.test(f)||`Expected a ${l.type} matching \`/${c.source}/\` but received "${f}"`)}function Ui(l,c,f=c){let p=`Expected a ${l.type}`,S=c===f?`of \`${c}\``:`between \`${c}\` and \`${f}\``;return mt(l,"size",v=>{if(typeof v=="number"||v instanceof Date)return c<=v&&v<=f||`${p} ${S} but received \`${v}\``;if(v instanceof Map||v instanceof Set){let{size:A}=v;return c<=A&&A<=f||`${p} with a size ${S} but received one with a size of \`${A}\``}else{let{length:A}=v;return c<=A&&A<=f||`${p} with a length ${S} but received one with a length of \`${A}\``}})}function mt(l,c,f){return new d({...l,*refiner(p,S){yield*l.refiner(p,S);let v=f(p,S),A=h(v,S,l,p);for(let _ of A)yield{..._,refinement:c}}})}i.Struct=d,i.StructError=t,i.any=V,i.array=St,i.assert=m,i.assign=E,i.bigint=bi,i.boolean=Si,i.coerce=Oe,i.create=g,i.date=ki,i.defaulted=Ni,i.define=b,i.deprecated=O,i.dynamic=x,i.empty=Ii,i.enums=Ei,i.func=vi,i.instance=Ti,i.integer=xi,i.intersection=Oi,i.is=k,i.lazy=T,i.literal=Ai,i.map=Pi,i.mask=w,i.max=Li,i.min=Wi,i.never=xe,i.nonempty=zi,i.nullable=Ri,i.number=Di,i.object=_t,i.omit=P,i.optional=Xe,i.partial=R,i.pattern=Bi,i.pick=H,i.record=_i,i.refine=mt,i.regexp=Fi,i.set=Ci,i.size=Ui,i.string=Ze,i.struct=bt,i.trimmed=$i,i.tuple=Mi,i.type=Ft,i.union=ji,i.unknown=Qe,i.validate=y})});var fs=gt(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.validateRequirements=void 0;var sn="[",nn="(<=>!~",rn=";",on="@",an=new RegExp(`[${sn+nn+rn+on}]`);function hn(i){return i.split(an)[0].trim()}function ln(i){return i.forEach(e=>{let s;try{s=new URL(e)}catch{return}if(s.protocol==="emfs:"||s.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${e})`)}),i.filter(e=>hn(e)==="streamlit"?(console.warn(`Streamlit is specified in the requirements ("${e}"), but it will be ignored. A built-in version of Streamlit will be used.`),!1):!0)}ee.validateRequirements=ln});var us=gt(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.parseRequirementsTxt=void 0;var cn=/\s#.*$/;function fn(i){return i.split(`
|
|
3
|
+
`).filter(t=>!t.startsWith("#")).map(t=>t.replace(cn,"")).map(t=>t.trim()).filter(t=>t!=="")}se.parseRequirementsTxt=fn});var ds=gt(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.PromiseDelegate=void 0;var Ae=class{constructor(){this.promise=new Promise((t,e)=>{this.resolveInternal=t,this.rejectInternal=e})}resolve(t){this.resolveInternal(t)}reject(t){this.rejectInternal(t)}};ie.PromiseDelegate=Ae});var ps=gt(ht=>{"use strict";var un=ht&&ht.__createBinding||(Object.create?function(i,t,e,s){s===void 0&&(s=e);var n=Object.getOwnPropertyDescriptor(t,e);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,s,n)}:function(i,t,e,s){s===void 0&&(s=e),i[s]=t[e]}),Pe=ht&&ht.__exportStar||function(i,t){for(var e in i)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&un(t,i,e)};Object.defineProperty(ht,"__esModule",{value:!0});Pe(fs(),ht);Pe(us(),ht);Pe(ds(),ht)});var bs=gt((Vr,ys)=>{"use strict";ys.exports=gs;function gs(i,t,e){i instanceof RegExp&&(i=ms(i,e)),t instanceof RegExp&&(t=ms(t,e));var s=ws(i,t,e);return s&&{start:s[0],end:s[1],pre:e.slice(0,s[0]),body:e.slice(s[0]+i.length,s[1]),post:e.slice(s[1]+t.length)}}function ms(i,t){var e=t.match(i);return e?e[0]:null}gs.range=ws;function ws(i,t,e){var s,n,r,o,a,h=e.indexOf(i),u=e.indexOf(t,h+1),d=h;if(h>=0&&u>0){if(i===t)return[h,u];for(s=[],r=e.length;d>=0&&!a;)d==h?(s.push(d),h=e.indexOf(i,d+1)):s.length==1?a=[s.pop(),u]:(n=s.pop(),n<r&&(r=n,o=u),u=e.indexOf(t,d+1)),d=h<u&&h>=0?h:u;s.length&&(a=[r,o])}return a}});var As=gt((Yr,Os)=>{var Ss=bs();Os.exports=mn;var ks="\0SLASH"+Math.random()+"\0",Es="\0OPEN"+Math.random()+"\0",De="\0CLOSE"+Math.random()+"\0",vs="\0COMMA"+Math.random()+"\0",Ts="\0PERIOD"+Math.random()+"\0";function Re(i){return parseInt(i,10)==i?parseInt(i,10):i.charCodeAt(0)}function dn(i){return i.split("\\\\").join(ks).split("\\{").join(Es).split("\\}").join(De).split("\\,").join(vs).split("\\.").join(Ts)}function pn(i){return i.split(ks).join("\\").split(Es).join("{").split(De).join("}").split(vs).join(",").split(Ts).join(".")}function xs(i){if(!i)return[""];var t=[],e=Ss("{","}",i);if(!e)return i.split(",");var s=e.pre,n=e.body,r=e.post,o=s.split(",");o[o.length-1]+="{"+n+"}";var a=xs(r);return r.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function mn(i){return i?(i.substr(0,2)==="{}"&&(i="\\{\\}"+i.substr(2)),Mt(dn(i),!0).map(pn)):[]}function gn(i){return"{"+i+"}"}function wn(i){return/^-?0\d/.test(i)}function yn(i,t){return i<=t}function bn(i,t){return i>=t}function Mt(i,t){var e=[],s=Ss("{","}",i);if(!s)return[i];var n=s.pre,r=s.post.length?Mt(s.post,!1):[""];if(/\$$/.test(s.pre))for(var o=0;o<r.length;o++){var a=n+"{"+s.body+"}"+r[o];e.push(a)}else{var h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),d=h||u,m=s.body.indexOf(",")>=0;if(!d&&!m)return s.post.match(/,.*\}/)?(i=s.pre+"{"+s.body+De+s.post,Mt(i)):[i];var g;if(d)g=s.body.split(/\.\./);else if(g=xs(s.body),g.length===1&&(g=Mt(g[0],!1).map(gn),g.length===1))return r.map(function(St){return s.pre+g[0]+St});var w;if(d){var k=Re(g[0]),y=Re(g[1]),E=Math.max(g[0].length,g[1].length),b=g.length==3?Math.abs(Re(g[2])):1,O=yn,x=y<k;x&&(b*=-1,O=bn);var T=g.some(wn);w=[];for(var P=k;O(P,y);P+=b){var R;if(u)R=String.fromCharCode(P),R==="\\"&&(R="");else if(R=String(P),T){var H=E-R.length;if(H>0){var bt=new Array(H+1).join("0");P<0?R="-"+bt+R.slice(1):R=bt+R}}w.push(R)}}else{w=[];for(var V=0;V<g.length;V++)w.push.apply(w,Mt(g[V],!1))}for(var V=0;V<w.length;V++)for(var o=0;o<r.length;o++){var a=n+w[V]+r[o];(!t||d||a)&&e.push(a)}}return e}});var mi=U(require("yargs")),gi=require("yargs/helpers"),W=U(require("node:path")),at=U(require("node:fs/promises")),Ke=U(require("fs-extra")),Ve=U(require("node-fetch")),Ye=require("pyodide");var ss=require("pyodide");function Zt(i){return`https://cdn.jsdelivr.net/pyodide/v${ss.version}/full/${i}`}var is=U(require("node-fetch"));var Ct=class i{static _instance;_data=null;constructor(){}static async loadPrebuiltPackageData(){let t=Zt("pyodide-lock.json");return console.log(`Load the Pyodide pyodide-lock.json from ${t}`),(await(await(0,is.default)(t,void 0)).json()).packages}static async getInstance(){return this._instance==null&&(this._instance=new i,this._instance._data=await this.loadPrebuiltPackageData()),this._instance}getPackageInfoByName(t){if(this._data==null)throw new Error("The package data is not loaded yet.");let e=Object.values(this._data).find(s=>s.name===t);if(e==null)throw new Error(`Package ${t} is not found in the lock file.`);return e}};var os=U(require("node:fs/promises")),as=U(te());var C=U(te()),rs=C.object({entrypoint:C.string(),embed:C.defaulted(C.boolean(),!1),idbfsMountpoints:C.optional(C.array(C.string())),nodeJsWorker:C.defaulted(C.boolean(),!1),nodefsMountpoints:C.optional(C.record(C.string(),C.string()))});function Zi(i){let t=as.mask(i??{},rs);if(t.nodeJsWorker){if(t.idbfsMountpoints!=null)throw new Error("The `idbfsMountpoints` field is not allowed when `nodeJsWorker` is true.")}else if(t.nodefsMountpoints!=null)throw new Error("The `nodefsMountpoints` field is not allowed when `nodeJsWorker` is false.");return t}async function hs(i){let t=Zi({...i.packageJsonStliteDesktopField,...i.fallbacks}),e=JSON.stringify(t,null,2);console.log(`Dump the manifest file -> ${i.manifestFilePath}`),console.log(e),await os.default.writeFile(i.manifestFilePath,e,{encoding:"utf-8"})}var ls=U(require("node:path")),I=U(te());async function cs(i){let{files:t,entrypoint:e}=Qi(i),s=await tn(i),n=await en(i);return{files:t,entrypoint:e,dependencies:s,requirementsTxtFilePaths:n}}function Qi(i){let{packageJsonStliteDesktopField:t,fallbacks:{appHomeDirSource:e}}=i,s=t?.files,n=t?.entrypoint;if(s==null||n==null){console.warn("`stlite.desktop.files` and `stlite.desktop.entrypoint` are not found in `package.json`. Read the `appHomeDirSource` argument as the app directory. This behavior will be deprecated in the future.");let r=e;if(typeof r!="string")throw new Error("The `appHomeDirSource` argument is required when `stlite.desktop.files` and `stlite.desktop.entrypoint` are not found in the package.json.\nNote that `appHomeDirSource` is deprecated and will be removed in the future, so please specify `stlite.desktop.files` and `stlite.desktop.entrypoint` in the package.json.");s=[r],n=`./${r}/streamlit_app.py`}else e!=null&&console.warn("[Deprecated] `appHomeDirSource` is ignored because `stlite.desktop.files` is found in `package.json`.");return I.assert(n,I.string(),"The `stlite.desktop.entrypoint` field must be a string."),I.assert(s,I.array(I.string()),"The `stlite.desktop.files` field must be an array of strings."),{files:s,entrypoint:n}}async function tn(i){let{packageJsonStliteDesktopField:t,fallbacks:{packages:e}}=i,s=t?.dependencies;I.assert(s,I.optional(I.array(I.string())),"The `stlite.desktop.dependencies` field must be an array of strings.");let n=[];return e!=null&&(console.warn("The `packages` argument is deprecated and will be removed in the future. Please specify `stlite.desktop.dependencies` in the package.json for that purpose."),n=e),[...s??[],...n]}async function en(i){let{pathResolutionRoot:t,packageJsonStliteDesktopField:e,fallbacks:{requirementsTxtFilePaths:s}}=i,n=e?.requirementsTxtFiles;I.assert(n,I.optional(I.array(I.string())),"The `stlite.desktop.requirementsTxtFiles` field must be an array of strings.");let r=n?.map(a=>ls.default.resolve(t,a)),o=[];return s!=null&&s.length>0&&(console.warn("The `requirement` argument is deprecated and will be removed in the future. Please specify `stlite.desktop.requirementsTxtFiles` in the package.json for that purpose."),o=s),[...r??[],...o]}var Te=U(ps());var js=U(As(),1);var jt=i=>{if(typeof i!="string")throw new TypeError("invalid pattern");if(i.length>65536)throw new TypeError("pattern is too long")};var Sn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Nt=i=>i.replace(/[[\]\\-]/g,"\\$&"),kn=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ps=i=>i.join(""),Rs=(i,t)=>{let e=t;if(i.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],n=[],r=e+1,o=!1,a=!1,h=!1,u=!1,d=e,m="";t:for(;r<i.length;){let y=i.charAt(r);if((y==="!"||y==="^")&&r===e+1){u=!0,r++;continue}if(y==="]"&&o&&!h){d=r+1;break}if(o=!0,y==="\\"&&!h){h=!0,r++;continue}if(y==="["&&!h){for(let[E,[b,O,x]]of Object.entries(Sn))if(i.startsWith(E,r)){if(m)return["$.",!1,i.length-e,!0];r+=E.length,x?n.push(b):s.push(b),a=a||O;continue t}}if(h=!1,m){y>m?s.push(Nt(m)+"-"+Nt(y)):y===m&&s.push(Nt(y)),m="",r++;continue}if(i.startsWith("-]",r+1)){s.push(Nt(y+"-")),r+=2;continue}if(i.startsWith("-",r+1)){m=y,r+=2;continue}s.push(Nt(y)),r++}if(d<r)return["",!1,0,!1];if(!s.length&&!n.length)return["$.",!1,i.length-e,!0];if(n.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!u){let y=s[0].length===2?s[0].slice(-1):s[0];return[kn(y),!1,d-e,!1]}let g="["+(u?"^":"")+Ps(s)+"]",w="["+(u?"":"^")+Ps(n)+"]";return[s.length&&n.length?"("+g+"|"+w+")":s.length?g:w,a,d-e,!0]};var tt=(i,{windowsPathsNoEscape:t=!1}={})=>t?i.replace(/\[([^\/\\])\]/g,"$1"):i.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var En=new Set(["!","?","+","*","@"]),Ds=i=>En.has(i),vn="(?!(?:^|/)\\.\\.?(?:$|/))",ne="(?!\\.)",Tn=new Set(["[","."]),xn=new Set(["..","."]),On=new Set("().*{}+?[]^$\\!"),An=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),_e="[^/]",_s=_e+"*?",Fs=_e+"+?",kt=class i{type;#t;#s;#r=!1;#i=[];#a;#l;#f;#h=!1;#o;#e;#m=!1;constructor(t,e,s={}){this.type=t,t&&(this.#s=!0),this.#a=e,this.#t=this.#a?this.#a.#t:this,this.#o=this.#t===this?s:this.#t.#o,this.#f=this.#t===this?[]:this.#t.#f,t==="!"&&!this.#t.#h&&this.#f.push(this),this.#l=this.#a?this.#a.#i.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#i)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#e!==void 0?this.#e:this.type?this.#e=this.type+"("+this.#i.map(t=>String(t)).join("|")+")":this.#e=this.#i.map(t=>String(t)).join("")}#w(){if(this!==this.#t)throw new Error("should only call on root");if(this.#h)return this;this.toString(),this.#h=!0;let t;for(;t=this.#f.pop();){if(t.type!=="!")continue;let e=t,s=e.#a;for(;s;){for(let n=e.#l+1;!s.type&&n<s.#i.length;n++)for(let r of t.#i){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(s.#i[n])}e=s,s=e.#a}}return this}push(...t){for(let e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof i&&e.#a===this))throw new Error("invalid part: "+e);this.#i.push(e)}}toJSON(){let t=this.type===null?this.#i.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#i.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#h&&this.#a?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#a?.isStart())return!1;if(this.#l===0)return!0;let t=this.#a;for(let e=0;e<this.#l;e++){let s=t.#i[e];if(!(s instanceof i&&s.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let t=this.#a?this.#a.#i.length:0;return this.#l===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let e=new i(this.type,t);for(let s of this.#i)e.copyIn(s);return e}static#d(t,e,s,n){let r=!1,o=!1,a=-1,h=!1;if(e.type===null){let w=s,k="";for(;w<t.length;){let y=t.charAt(w++);if(r||y==="\\"){r=!r,k+=y;continue}if(o){w===a+1?(y==="^"||y==="!")&&(h=!0):y==="]"&&!(w===a+2&&h)&&(o=!1),k+=y;continue}else if(y==="["){o=!0,a=w,h=!1,k+=y;continue}if(!n.noext&&Ds(y)&&t.charAt(w)==="("){e.push(k),k="";let E=new i(y,e);w=i.#d(t,E,w,n),e.push(E);continue}k+=y}return e.push(k),w}let u=s+1,d=new i(null,e),m=[],g="";for(;u<t.length;){let w=t.charAt(u++);if(r||w==="\\"){r=!r,g+=w;continue}if(o){u===a+1?(w==="^"||w==="!")&&(h=!0):w==="]"&&!(u===a+2&&h)&&(o=!1),g+=w;continue}else if(w==="["){o=!0,a=u,h=!1,g+=w;continue}if(Ds(w)&&t.charAt(u)==="("){d.push(g),g="";let k=new i(w,d);d.push(k),u=i.#d(t,k,u,n);continue}if(w==="|"){d.push(g),g="",m.push(d),d=new i(null,e);continue}if(w===")")return g===""&&e.#i.length===0&&(e.#m=!0),d.push(g),g="",e.push(...m,d),u;g+=w}return e.type=null,e.#s=void 0,e.#i=[t.substring(s-1)],u}static fromGlob(t,e={}){let s=new i(null,void 0,e);return i.#d(t,s,0,e),s}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[e,s,n,r]=this.toRegExpSource();if(!(n||this.#s||this.#o.nocase&&!this.#o.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return s;let a=(this.#o.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}toRegExpSource(t){let e=t??!!this.#o.dot;if(this.#t===this&&this.#w(),!this.type){let h=this.isStart()&&this.isEnd(),u=this.#i.map(w=>{let[k,y,E,b]=typeof w=="string"?i.#S(w,this.#s,h):w.toRegExpSource(t);return this.#s=this.#s||E,this.#r=this.#r||b,k}).join(""),d="";if(this.isStart()&&typeof this.#i[0]=="string"&&!(this.#i.length===1&&xn.has(this.#i[0]))){let k=Tn,y=e&&k.has(u.charAt(0))||u.startsWith("\\.")&&k.has(u.charAt(2))||u.startsWith("\\.\\.")&&k.has(u.charAt(4)),E=!e&&!t&&k.has(u.charAt(0));d=y?vn:E?ne:""}let m="";return this.isEnd()&&this.#t.#h&&this.#a?.type==="!"&&(m="(?:$|\\/)"),[d+u+m,tt(u),this.#s=!!this.#s,this.#r]}let s=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#u(e);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let h=this.toString();return this.#i=[h],this.type=null,this.#s=void 0,[h,tt(this.toString()),!1,!1]}let o=!s||t||e||!ne?"":this.#u(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!e?ne:"")+Fs;else{let h=this.type==="!"?"))"+(this.isStart()&&!e&&!t?ne:"")+_s+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=n+r+h}return[a,tt(r),this.#s=!!this.#s,this.#r]}#u(t){return this.#i.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,n,r,o]=e.toRegExpSource(t);return this.#r=this.#r||o,s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#S(t,e,s=!1){let n=!1,r="",o=!1;for(let a=0;a<t.length;a++){let h=t.charAt(a);if(n){n=!1,r+=(On.has(h)?"\\":"")+h;continue}if(h==="\\"){a===t.length-1?r+="\\\\":n=!0;continue}if(h==="["){let[u,d,m,g]=Rs(t,a);if(m){r+=u,o=o||d,a+=m-1,e=e||g;continue}}if(h==="*"){s&&t==="*"?r+=Fs:r+=_s,e=!0;continue}if(h==="?"){r+=_e,e=!0;continue}r+=An(h)}return[r,tt(t),!!e,o]}};var Et=(i,{windowsPathsNoEscape:t=!1}={})=>t?i.replace(/[?*()[\]]/g,"[$&]"):i.replace(/[?*()[\]\\]/g,"\\$&");var q=(i,t,e={})=>(jt(t),!e.nocomment&&t.charAt(0)==="#"?!1:new J(t,e).match(i)),Pn=/^\*+([^+@!?\*\[\(]*)$/,Rn=i=>t=>!t.startsWith(".")&&t.endsWith(i),Dn=i=>t=>t.endsWith(i),_n=i=>(i=i.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(i)),Fn=i=>(i=i.toLowerCase(),t=>t.toLowerCase().endsWith(i)),Cn=/^\*+\.\*+$/,Mn=i=>!i.startsWith(".")&&i.includes("."),jn=i=>i!=="."&&i!==".."&&i.includes("."),Nn=/^\.\*+$/,$n=i=>i!=="."&&i!==".."&&i.startsWith("."),In=/^\*+$/,Ln=i=>i.length!==0&&!i.startsWith("."),Wn=i=>i.length!==0&&i!=="."&&i!=="..",zn=/^\?+([^+@!?\*\[\(]*)?$/,Bn=([i,t=""])=>{let e=Ns([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},Un=([i,t=""])=>{let e=$s([i]);return t?(t=t.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(t)):e},qn=([i,t=""])=>{let e=$s([i]);return t?s=>e(s)&&s.endsWith(t):e},Gn=([i,t=""])=>{let e=Ns([i]);return t?s=>e(s)&&s.endsWith(t):e},Ns=([i])=>{let t=i.length;return e=>e.length===t&&!e.startsWith(".")},$s=([i])=>{let t=i.length;return e=>e.length===t&&e!=="."&&e!==".."},Is=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Cs={win32:{sep:"\\"},posix:{sep:"/"}},Hn=Is==="win32"?Cs.win32.sep:Cs.posix.sep;q.sep=Hn;var L=Symbol("globstar **");q.GLOBSTAR=L;var Jn="[^/]",Kn=Jn+"*?",Vn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Yn="(?:(?!(?:\\/|^)\\.).)*?",Xn=(i,t={})=>e=>q(e,i,t);q.filter=Xn;var X=(i,t={})=>Object.assign({},i,t),Zn=i=>{if(!i||typeof i!="object"||!Object.keys(i).length)return q;let t=q;return Object.assign((s,n,r={})=>t(s,n,X(i,r)),{Minimatch:class extends t.Minimatch{constructor(n,r={}){super(n,X(i,r))}static defaults(n){return t.defaults(X(i,n)).Minimatch}},AST:class extends t.AST{constructor(n,r,o={}){super(n,r,X(i,o))}static fromGlob(n,r={}){return t.AST.fromGlob(n,X(i,r))}},unescape:(s,n={})=>t.unescape(s,X(i,n)),escape:(s,n={})=>t.escape(s,X(i,n)),filter:(s,n={})=>t.filter(s,X(i,n)),defaults:s=>t.defaults(X(i,s)),makeRe:(s,n={})=>t.makeRe(s,X(i,n)),braceExpand:(s,n={})=>t.braceExpand(s,X(i,n)),match:(s,n,r={})=>t.match(s,n,X(i,r)),sep:t.sep,GLOBSTAR:L})};q.defaults=Zn;var Ls=(i,t={})=>(jt(i),t.nobrace||!/\{(?:(?!\{).)*\}/.test(i)?[i]:(0,js.default)(i));q.braceExpand=Ls;var Qn=(i,t={})=>new J(i,t).makeRe();q.makeRe=Qn;var tr=(i,t,e={})=>{let s=new J(t,e);return i=i.filter(n=>s.match(n)),s.options.nonull&&!i.length&&i.push(t),i};q.match=tr;var Ms=/[?*]|[+@!]\(.*?\)|\[|\]/,er=i=>i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),J=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){jt(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Is,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let n=this.globParts.map((r,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=r[0]===""&&r[1]===""&&(r[2]==="?"||!Ms.test(r[2]))&&!Ms.test(r[3]),u=/^[a-z]:/i.test(r[0]);if(h)return[...r.slice(0,4),...r.slice(4).map(d=>this.parse(d))];if(u)return[r[0],...r.slice(1).map(d=>this.parse(d))]}return r.map(h=>this.parse(h))});if(this.debug(this.pattern,n),this.set=n.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let s=0;s<t.length;s++)for(let n=0;n<t[s].length;n++)t[s][n]==="**"&&(t[s][n]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let n=s;for(;e[n+1]==="**";)n++;n!==s&&e.splice(s,n-s)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((s,n)=>{let r=s[s.length-1];return n==="**"&&r==="**"?s:n===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(n),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){let r=t[n];n===1&&r===""&&t[0]===""||(r==="."||r==="")&&(e=!0,t.splice(n,1),n--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let s=0;for(;(s=t.indexOf("..",s+1))!==-1;){let n=t[s-1];n&&n!=="."&&n!==".."&&n!=="**"&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let n=-1;for(;(n=s.indexOf("**",n+1))!==-1;){let o=n;for(;s[o+1]==="**";)o++;o>n&&s.splice(n+1,o-n);let a=s[n+1],h=s[n+2],u=s[n+3];if(a!==".."||!h||h==="."||h===".."||!u||u==="."||u==="..")continue;e=!0,s.splice(n,1);let d=s.slice(0);d[n]="**",t.push(d),n--}if(!this.preserveMultipleSlashes){for(let o=1;o<s.length-1;o++){let a=s[o];o===1&&a===""&&s[0]===""||(a==="."||a==="")&&(e=!0,s.splice(o,1),o--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let o=s[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;let h=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...h),s.length===0&&s.push(""),r-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){let n=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);n&&(t[e]=n,t[s]=[])}return t.filter(e=>e.length)}partsMatch(t,e,s=!1){let n=0,r=0,o=[],a="";for(;n<t.length&&r<e.length;)if(t[n]===e[r])o.push(a==="b"?e[r]:t[n]),n++,r++;else if(s&&t[n]==="**"&&e[r]===t[n+1])o.push(t[n]),n++;else if(s&&e[r]==="**"&&t[n]===e[r+1])o.push(e[r]),r++;else if(t[n]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(a==="b")return!1;a="a",o.push(t[n]),n++,r++}else if(e[r]==="*"&&t[n]&&(this.options.dot||!t[n].startsWith("."))&&t[n]!=="**"){if(a==="a")return!1;a="b",o.push(e[r]),n++,r++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,s=0;for(let n=0;n<t.length&&t.charAt(n)==="!";n++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){let n=this.options;if(this.isWindows){let y=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),E=!y&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),b=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),O=!b&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),x=E?3:y?0:void 0,T=O?3:b?0:void 0;if(typeof x=="number"&&typeof T=="number"){let[P,R]=[t[x],e[T]];P.toLowerCase()===R.toLowerCase()&&(e[T]=P,T>x?e=e.slice(T):x>T&&(t=t.slice(x)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var o=0,a=0,h=t.length,u=e.length;o<h&&a<u;o++,a++){this.debug("matchOne loop");var d=e[a],m=t[o];if(this.debug(e,d,m),d===!1)return!1;if(d===L){this.debug("GLOBSTAR",[e,d,m]);var g=o,w=a+1;if(w===u){for(this.debug("** at the end");o<h;o++)if(t[o]==="."||t[o]===".."||!n.dot&&t[o].charAt(0)===".")return!1;return!0}for(;g<h;){var k=t[g];if(this.debug(`
|
|
4
|
+
globstar while`,t,g,e,w,k),this.matchOne(t.slice(g),e.slice(w),s))return this.debug("globstar found match!",g,h,k),!0;if(k==="."||k===".."||!n.dot&&k.charAt(0)==="."){this.debug("dot detected!",t,g,e,w);break}this.debug("globstar swallow a segment, and continue"),g++}return!!(s&&(this.debug(`
|
|
5
|
+
>>> no match, partial?`,t,g,e,w),g===h))}let y;if(typeof d=="string"?(y=m===d,this.debug("string match",d,m,y)):(y=d.test(m),this.debug("pattern match",d,m,y)),!y)return!1}if(o===h&&a===u)return!0;if(o===h)return s;if(a===u)return o===h-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Ls(this.pattern,this.options)}parse(t){jt(t);let e=this.options;if(t==="**")return L;if(t==="")return"";let s,n=null;(s=t.match(In))?n=e.dot?Wn:Ln:(s=t.match(Pn))?n=(e.nocase?e.dot?Fn:_n:e.dot?Dn:Rn)(s[1]):(s=t.match(zn))?n=(e.nocase?e.dot?Un:Bn:e.dot?qn:Gn)(s):(s=t.match(Cn))?n=e.dot?jn:Mn:(s=t.match(Nn))&&(n=$n);let r=kt.fromGlob(t,this.options).toMMPattern();return n?Object.assign(r,{test:n}):r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Kn:e.dot?Vn:Yn,n=new Set(e.nocase?["i"]:[]),r=t.map(h=>{let u=h.map(d=>{if(d instanceof RegExp)for(let m of d.flags.split(""))n.add(m);return typeof d=="string"?er(d):d===L?L:d._src});return u.forEach((d,m)=>{let g=u[m+1],w=u[m-1];d!==L||w===L||(w===void 0?g!==void 0&&g!==L?u[m+1]="(?:\\/|"+s+"\\/)?"+g:u[m]=s:g===void 0?u[m-1]=w+"(?:\\/|"+s+")?":g!==L&&(u[m-1]=w+"(?:\\/|\\/"+s+"\\/)"+g,u[m+1]=L))}),u.filter(d=>d!==L).join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+a+"$",this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...n].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let n=this.slashSplit(t);this.debug(this.pattern,"split",n);let r=this.set;this.debug(this.pattern,"set",r);let o=n[n.length-1];if(!o)for(let a=n.length-2;!o&&a>=0;a--)o=n[a];for(let a=0;a<r.length;a++){let h=r[a],u=n;if(s.matchBase&&h.length===1&&(u=[o]),this.matchOne(u,h,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return q.defaults(t).Minimatch}};q.AST=kt;q.Minimatch=J;q.escape=Et;q.unescape=tt;var vt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,zs=new Set,Fe=typeof process=="object"&&process?process:{},Bs=(i,t,e,s)=>{typeof Fe.emitWarning=="function"?Fe.emitWarning(i,t,e,s):console.error(`[${e}] ${t}: ${i}`)},re=globalThis.AbortController,Ws=globalThis.AbortSignal;if(typeof re>"u"){Ws=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,n){this._onabort.push(n)}},re=class{constructor(){t()}signal=new Ws;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let n of this.signal._onabort)n(s);this.signal.onabort?.(s)}}};let i=Fe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{i&&(i=!1,Bs("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var sr=i=>!zs.has(i),wo=Symbol("type"),ft=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),Us=i=>ft(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?Tt:null:null,Tt=class extends Array{constructor(t){super(t),this.fill(0)}},Ce=class i{heap;length;static#t=!1;static create(t){let e=Us(t);if(!e)return[];i.#t=!0;let s=new i(t,e);return i.#t=!1,s}constructor(t,e){if(!i.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},$t=class i{#t;#s;#r;#i;#a;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#f;#h;#o;#e;#m;#w;#d;#u;#S;#g;#x;#O;#k;#b;#P;#p;static unsafeExposeInternals(t){return{starts:t.#O,ttls:t.#k,sizes:t.#x,keyMap:t.#h,keyList:t.#o,valList:t.#e,next:t.#m,prev:t.#w,get head(){return t.#d},get tail(){return t.#u},free:t.#S,isBackgroundFetch:e=>t.#c(e),backgroundFetch:(e,s,n,r)=>t.#M(e,s,n,r),moveToTail:e=>t.#C(e),indexes:e=>t.#T(e),rindexes:e=>t.#R(e),isStale:e=>t.#y(e)}}get max(){return this.#t}get maxSize(){return this.#s}get calculatedSize(){return this.#f}get size(){return this.#l}get fetchMethod(){return this.#a}get dispose(){return this.#r}get disposeAfter(){return this.#i}constructor(t){let{max:e=0,ttl:s,ttlResolution:n=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:h,dispose:u,disposeAfter:d,noDisposeOnSet:m,noUpdateTTL:g,maxSize:w=0,maxEntrySize:k=0,sizeCalculation:y,fetchMethod:E,noDeleteOnFetchRejection:b,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:T,ignoreFetchAbort:P}=t;if(e!==0&&!ft(e))throw new TypeError("max option must be a nonnegative integer");let R=e?Us(e):Array;if(!R)throw new Error("invalid max value: "+e);if(this.#t=e,this.#s=w,this.maxEntrySize=k||this.#s,this.sizeCalculation=y,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(E!==void 0&&typeof E!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#a=E,this.#P=!!E,this.#h=new Map,this.#o=new Array(e).fill(void 0),this.#e=new Array(e).fill(void 0),this.#m=new R(e),this.#w=new R(e),this.#d=0,this.#u=0,this.#S=Ce.create(e),this.#l=0,this.#f=0,typeof u=="function"&&(this.#r=u),typeof d=="function"?(this.#i=d,this.#g=[]):(this.#i=void 0,this.#g=void 0),this.#b=!!this.#r,this.#p=!!this.#i,this.noDisposeOnSet=!!m,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!b,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!T,this.ignoreFetchAbort=!!P,this.maxEntrySize!==0){if(this.#s!==0&&!ft(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!ft(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#_()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=ft(n)||n===0?n:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!ft(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#D()}if(this.#t===0&&this.ttl===0&&this.#s===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#s){let H="LRU_CACHE_UNBOUNDED";sr(H)&&(zs.add(H),Bs("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",H,i))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#D(){let t=new Tt(this.#t),e=new Tt(this.#t);this.#k=t,this.#O=e,this.#n=(r,o,a=vt.now())=>{if(e[r]=o!==0?a:0,t[r]=o,o!==0&&this.ttlAutopurge){let h=setTimeout(()=>{this.#y(r)&&this.delete(this.#o[r])},o+1);h.unref&&h.unref()}},this.#A=r=>{e[r]=t[r]!==0?vt.now():0},this.#E=(r,o)=>{if(t[o]){let a=t[o],h=e[o];if(!a||!h)return;r.ttl=a,r.start=h,r.now=s||n();let u=r.now-h;r.remainingTTL=a-u}};let s=0,n=()=>{let r=vt.now();if(this.ttlResolution>0){s=r;let o=setTimeout(()=>s=0,this.ttlResolution);o.unref&&o.unref()}return r};this.getRemainingTTL=r=>{let o=this.#h.get(r);if(o===void 0)return 0;let a=t[o],h=e[o];if(!a||!h)return 1/0;let u=(s||n())-h;return a-u},this.#y=r=>{let o=e[r],a=t[r];return!!a&&!!o&&(s||n())-o>a}}#A=()=>{};#E=()=>{};#n=()=>{};#y=()=>!1;#_(){let t=new Tt(this.#t);this.#f=0,this.#x=t,this.#v=e=>{this.#f-=t[e],t[e]=0},this.#N=(e,s,n,r)=>{if(this.#c(s))return 0;if(!ft(n))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(n=r(s,e),!ft(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.#j=(e,s,n)=>{if(t[e]=s,this.#s){let r=this.#s-t[e];for(;this.#f>r;)this.#F(!0)}this.#f+=t[e],n&&(n.entrySize=s,n.totalCalculatedSize=this.#f)}}#v=t=>{};#j=(t,e,s)=>{};#N=(t,e,s,n)=>{if(s||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:t=this.allowStale}={}){if(this.#l)for(let e=this.#u;!(!this.#$(e)||((t||!this.#y(e))&&(yield e),e===this.#d));)e=this.#w[e]}*#R({allowStale:t=this.allowStale}={}){if(this.#l)for(let e=this.#d;!(!this.#$(e)||((t||!this.#y(e))&&(yield e),e===this.#u));)e=this.#m[e]}#$(t){return t!==void 0&&this.#h.get(this.#o[t])===t}*entries(){for(let t of this.#T())this.#e[t]!==void 0&&this.#o[t]!==void 0&&!this.#c(this.#e[t])&&(yield[this.#o[t],this.#e[t]])}*rentries(){for(let t of this.#R())this.#e[t]!==void 0&&this.#o[t]!==void 0&&!this.#c(this.#e[t])&&(yield[this.#o[t],this.#e[t]])}*keys(){for(let t of this.#T()){let e=this.#o[t];e!==void 0&&!this.#c(this.#e[t])&&(yield e)}}*rkeys(){for(let t of this.#R()){let e=this.#o[t];e!==void 0&&!this.#c(this.#e[t])&&(yield e)}}*values(){for(let t of this.#T())this.#e[t]!==void 0&&!this.#c(this.#e[t])&&(yield this.#e[t])}*rvalues(){for(let t of this.#R())this.#e[t]!==void 0&&!this.#c(this.#e[t])&&(yield this.#e[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let s of this.#T()){let n=this.#e[s],r=this.#c(n)?n.__staleWhileFetching:n;if(r!==void 0&&t(r,this.#o[s],this))return this.get(this.#o[s],e)}}forEach(t,e=this){for(let s of this.#T()){let n=this.#e[s],r=this.#c(n)?n.__staleWhileFetching:n;r!==void 0&&t.call(e,r,this.#o[s],this)}}rforEach(t,e=this){for(let s of this.#R()){let n=this.#e[s],r=this.#c(n)?n.__staleWhileFetching:n;r!==void 0&&t.call(e,r,this.#o[s],this)}}purgeStale(){let t=!1;for(let e of this.#R({allowStale:!0}))this.#y(e)&&(this.delete(this.#o[e]),t=!0);return t}info(t){let e=this.#h.get(t);if(e===void 0)return;let s=this.#e[e],n=this.#c(s)?s.__staleWhileFetching:s;if(n===void 0)return;let r={value:n};if(this.#k&&this.#O){let o=this.#k[e],a=this.#O[e];if(o&&a){let h=o-(vt.now()-a);r.ttl=h,r.start=Date.now()}}return this.#x&&(r.size=this.#x[e]),r}dump(){let t=[];for(let e of this.#T({allowStale:!0})){let s=this.#o[e],n=this.#e[e],r=this.#c(n)?n.__staleWhileFetching:n;if(r===void 0||s===void 0)continue;let o={value:r};if(this.#k&&this.#O){o.ttl=this.#k[e];let a=vt.now()-this.#O[e];o.start=Math.floor(Date.now()-a)}this.#x&&(o.size=this.#x[e]),t.unshift([s,o])}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let n=Date.now()-s.start;s.start=vt.now()-n}this.set(e,s.value,s)}}set(t,e,s={}){if(e===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:u=this.noUpdateTTL}=s,d=this.#N(t,e,s.size||0,a);if(this.maxEntrySize&&d>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this.delete(t),this;let m=this.#l===0?void 0:this.#h.get(t);if(m===void 0)m=this.#l===0?this.#u:this.#S.length!==0?this.#S.pop():this.#l===this.#t?this.#F(!1):this.#l,this.#o[m]=t,this.#e[m]=e,this.#h.set(t,m),this.#m[this.#u]=m,this.#w[m]=this.#u,this.#u=m,this.#l++,this.#j(m,d,h),h&&(h.set="add"),u=!1;else{this.#C(m);let g=this.#e[m];if(e!==g){if(this.#P&&this.#c(g)){g.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=g;w!==void 0&&!o&&(this.#b&&this.#r?.(w,t,"set"),this.#p&&this.#g?.push([w,t,"set"]))}else o||(this.#b&&this.#r?.(g,t,"set"),this.#p&&this.#g?.push([g,t,"set"]));if(this.#v(m),this.#j(m,d,h),this.#e[m]=e,h){h.set="replace";let w=g&&this.#c(g)?g.__staleWhileFetching:g;w!==void 0&&(h.oldValue=w)}}else h&&(h.set="update")}if(n!==0&&!this.#k&&this.#D(),this.#k&&(u||this.#n(m,n,r),h&&this.#E(h,m)),!o&&this.#p&&this.#g){let g=this.#g,w;for(;w=g?.shift();)this.#i?.(...w)}return this}pop(){try{for(;this.#l;){let t=this.#e[this.#d];if(this.#F(!0),this.#c(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#p&&this.#g){let t=this.#g,e;for(;e=t?.shift();)this.#i?.(...e)}}}#F(t){let e=this.#d,s=this.#o[e],n=this.#e[e];return this.#P&&this.#c(n)?n.__abortController.abort(new Error("evicted")):(this.#b||this.#p)&&(this.#b&&this.#r?.(n,s,"evict"),this.#p&&this.#g?.push([n,s,"evict"])),this.#v(e),t&&(this.#o[e]=void 0,this.#e[e]=void 0,this.#S.push(e)),this.#l===1?(this.#d=this.#u=0,this.#S.length=0):this.#d=this.#m[e],this.#h.delete(s),this.#l--,e}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:n}=e,r=this.#h.get(t);if(r!==void 0){let o=this.#e[r];if(this.#c(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#y(r))n&&(n.has="stale",this.#E(n,r));else return s&&this.#A(r),n&&(n.has="hit",this.#E(n,r)),!0}else n&&(n.has="miss");return!1}peek(t,e={}){let{allowStale:s=this.allowStale}=e,n=this.#h.get(t);if(n===void 0||!s&&this.#y(n))return;let r=this.#e[n];return this.#c(r)?r.__staleWhileFetching:r}#M(t,e,s,n){let r=e===void 0?void 0:this.#e[e];if(this.#c(r))return r;let o=new re,{signal:a}=s;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let h={signal:o.signal,options:s,context:n},u=(y,E=!1)=>{let{aborted:b}=o.signal,O=s.ignoreFetchAbort&&y!==void 0;if(s.status&&(b&&!E?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,O&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),b&&!O&&!E)return m(o.signal.reason);let x=w;return this.#e[e]===w&&(y===void 0?x.__staleWhileFetching?this.#e[e]=x.__staleWhileFetching:this.delete(t):(s.status&&(s.status.fetchUpdated=!0),this.set(t,y,h.options))),y},d=y=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=y),m(y)),m=y=>{let{aborted:E}=o.signal,b=E&&s.allowStaleOnFetchAbort,O=b||s.allowStaleOnFetchRejection,x=O||s.noDeleteOnFetchRejection,T=w;if(this.#e[e]===w&&(!x||T.__staleWhileFetching===void 0?this.delete(t):b||(this.#e[e]=T.__staleWhileFetching)),O)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),T.__staleWhileFetching;if(T.__returned===T)throw y},g=(y,E)=>{let b=this.#a?.(t,r,h);b&&b instanceof Promise&&b.then(O=>y(O===void 0?void 0:O),E),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=O=>u(O,!0)))})};s.status&&(s.status.fetchDispatched=!0);let w=new Promise(g).then(u,d),k=Object.assign(w,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,k,{...h.options,status:void 0}),e=this.#h.get(t)):this.#e[e]=k,k}#c(t){if(!this.#P)return!1;let e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof re}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:g=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:y,forceRefresh:E=!1,status:b,signal:O}=e;if(!this.#P)return b&&(b.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:r,status:b});let x={allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:a,size:h,sizeCalculation:u,noUpdateTTL:d,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:g,allowStaleOnFetchAbort:k,ignoreFetchAbort:w,status:b,signal:O},T=this.#h.get(t);if(T===void 0){b&&(b.fetch="miss");let P=this.#M(t,T,x,y);return P.__returned=P}else{let P=this.#e[T];if(this.#c(P)){let St=s&&P.__staleWhileFetching!==void 0;return b&&(b.fetch="inflight",St&&(b.returnedStale=!0)),St?P.__staleWhileFetching:P.__returned=P}let R=this.#y(T);if(!E&&!R)return b&&(b.fetch="hit"),this.#C(T),n&&this.#A(T),b&&this.#E(b,T),P;let H=this.#M(t,T,x,y),V=H.__staleWhileFetching!==void 0&&s;return b&&(b.fetch=R?"stale":"refresh",V&&R&&(b.returnedStale=!0)),V?H.__staleWhileFetching:H.__returned=H}}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=e,a=this.#h.get(t);if(a!==void 0){let h=this.#e[a],u=this.#c(h);return o&&this.#E(o,a),this.#y(a)?(o&&(o.get="stale"),u?(o&&s&&h.__staleWhileFetching!==void 0&&(o.returnedStale=!0),s?h.__staleWhileFetching:void 0):(r||this.delete(t),o&&s&&(o.returnedStale=!0),s?h:void 0)):(o&&(o.get="hit"),u?h.__staleWhileFetching:(this.#C(a),n&&this.#A(a),h))}else o&&(o.get="miss")}#I(t,e){this.#w[e]=t,this.#m[t]=e}#C(t){t!==this.#u&&(t===this.#d?this.#d=this.#m[t]:this.#I(this.#w[t],this.#m[t]),this.#I(this.#u,t),this.#u=t)}delete(t){let e=!1;if(this.#l!==0){let s=this.#h.get(t);if(s!==void 0)if(e=!0,this.#l===1)this.clear();else{this.#v(s);let n=this.#e[s];if(this.#c(n)?n.__abortController.abort(new Error("deleted")):(this.#b||this.#p)&&(this.#b&&this.#r?.(n,t,"delete"),this.#p&&this.#g?.push([n,t,"delete"])),this.#h.delete(t),this.#o[s]=void 0,this.#e[s]=void 0,s===this.#u)this.#u=this.#w[s];else if(s===this.#d)this.#d=this.#m[s];else{let r=this.#w[s];this.#m[r]=this.#m[s];let o=this.#m[s];this.#w[o]=this.#w[s]}this.#l--,this.#S.push(s)}}if(this.#p&&this.#g?.length){let s=this.#g,n;for(;n=s?.shift();)this.#i?.(...n)}return e}clear(){for(let t of this.#R({allowStale:!0})){let e=this.#e[t];if(this.#c(e))e.__abortController.abort(new Error("deleted"));else{let s=this.#o[t];this.#b&&this.#r?.(e,s,"delete"),this.#p&&this.#g?.push([e,s,"delete"])}}if(this.#h.clear(),this.#e.fill(void 0),this.#o.fill(void 0),this.#k&&this.#O&&(this.#k.fill(0),this.#O.fill(0)),this.#x&&this.#x.fill(0),this.#d=0,this.#u=0,this.#S.length=0,this.#f=0,this.#l=0,this.#p&&this.#g){let t=this.#g,e;for(;e=t?.shift();)this.#i?.(...e)}}};var At=require("path"),Qs=require("url"),ur=U(require("fs"),1),ot=require("fs"),pt=require("fs/promises");var ue=require("events"),We=U(require("stream"),1),Ks=require("string_decoder"),qs=typeof process=="object"&&process?process:{stdout:null,stderr:null},ir=i=>!!i&&typeof i=="object"&&(i instanceof dt||i instanceof We.default||nr(i)||rr(i)),nr=i=>!!i&&typeof i=="object"&&i instanceof ue.EventEmitter&&typeof i.pipe=="function"&&i.pipe!==We.default.Writable.prototype.pipe,rr=i=>!!i&&typeof i=="object"&&i instanceof ue.EventEmitter&&typeof i.write=="function"&&typeof i.end=="function",lt=Symbol("EOF"),ct=Symbol("maybeEmitEnd"),ut=Symbol("emittedEnd"),oe=Symbol("emittingEnd"),It=Symbol("emittedError"),ae=Symbol("closed"),Gs=Symbol("read"),he=Symbol("flush"),Hs=Symbol("flushChunk"),et=Symbol("encoding"),xt=Symbol("decoder"),j=Symbol("flowing"),Lt=Symbol("paused"),Ot=Symbol("resume"),N=Symbol("buffer"),G=Symbol("pipes"),$=Symbol("bufferLength"),Me=Symbol("bufferPush"),le=Symbol("bufferShift"),z=Symbol("objectMode"),M=Symbol("destroyed"),je=Symbol("error"),Ne=Symbol("emitData"),Js=Symbol("emitEnd"),$e=Symbol("emitEnd2"),nt=Symbol("async"),Ie=Symbol("abort"),ce=Symbol("aborted"),Wt=Symbol("signal"),wt=Symbol("dataListeners"),K=Symbol("discarded"),zt=i=>Promise.resolve().then(i),or=i=>i(),ar=i=>i==="end"||i==="finish"||i==="prefinish",hr=i=>i instanceof ArrayBuffer||!!i&&typeof i=="object"&&i.constructor&&i.constructor.name==="ArrayBuffer"&&i.byteLength>=0,lr=i=>!Buffer.isBuffer(i)&&ArrayBuffer.isView(i),fe=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[Ot](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Le=class extends fe{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=n=>e.emit("error",n),t.on("error",this.proxyErrors)}},cr=i=>!!i.objectMode,fr=i=>!i.objectMode&&!!i.encoding&&i.encoding!=="buffer",dt=class extends ue.EventEmitter{[j]=!1;[Lt]=!1;[G]=[];[N]=[];[z];[et];[nt];[xt];[lt]=!1;[ut]=!1;[oe]=!1;[ae]=!1;[It]=null;[$]=0;[M]=!1;[Wt];[ce]=!1;[wt]=0;[K]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");cr(e)?(this[z]=!0,this[et]=null):fr(e)?(this[et]=e.encoding,this[z]=!1):(this[z]=!1,this[et]=null),this[nt]=!!e.async,this[xt]=this[et]?new Ks.StringDecoder(this[et]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[N]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[G]});let{signal:s}=e;s&&(this[Wt]=s,s.aborted?this[Ie]():s.addEventListener("abort",()=>this[Ie]()))}get bufferLength(){return this[$]}get encoding(){return this[et]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[z]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[nt]}set async(t){this[nt]=this[nt]||!!t}[Ie](){this[ce]=!0,this.emit("abort",this[Wt]?.reason),this.destroy(this[Wt]?.reason)}get aborted(){return this[ce]}set aborted(t){}write(t,e,s){if(this[ce])return!1;if(this[lt])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let n=this[nt]?zt:or;if(!this[z]&&!Buffer.isBuffer(t)){if(lr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(hr(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[z]?(this[j]&&this[$]!==0&&this[he](!0),this[j]?this.emit("data",t):this[Me](t),this[$]!==0&&this.emit("readable"),s&&n(s),this[j]):t.length?(typeof t=="string"&&!(e===this[et]&&!this[xt]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[et]&&(t=this[xt].write(t)),this[j]&&this[$]!==0&&this[he](!0),this[j]?this.emit("data",t):this[Me](t),this[$]!==0&&this.emit("readable"),s&&n(s),this[j]):(this[$]!==0&&this.emit("readable"),s&&n(s),this[j])}read(t){if(this[M])return null;if(this[K]=!1,this[$]===0||t===0||t&&t>this[$])return this[ct](),null;this[z]&&(t=null),this[N].length>1&&!this[z]&&(this[N]=[this[et]?this[N].join(""):Buffer.concat(this[N],this[$])]);let e=this[Gs](t||null,this[N][0]);return this[ct](),e}[Gs](t,e){if(this[z])this[le]();else{let s=e;t===s.length||t===null?this[le]():typeof s=="string"?(this[N][0]=s.slice(t),e=s.slice(0,t),this[$]-=t):(this[N][0]=s.subarray(t),e=s.subarray(0,t),this[$]-=t)}return this.emit("data",e),!this[N].length&&!this[lt]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[lt]=!0,this.writable=!1,(this[j]||!this[Lt])&&this[ct](),this}[Ot](){this[M]||(!this[wt]&&!this[G].length&&(this[K]=!0),this[Lt]=!1,this[j]=!0,this.emit("resume"),this[N].length?this[he]():this[lt]?this[ct]():this.emit("drain"))}resume(){return this[Ot]()}pause(){this[j]=!1,this[Lt]=!0,this[K]=!1}get destroyed(){return this[M]}get flowing(){return this[j]}get paused(){return this[Lt]}[Me](t){this[z]?this[$]+=1:this[$]+=t.length,this[N].push(t)}[le](){return this[z]?this[$]-=1:this[$]-=this[N][0].length,this[N].shift()}[he](t=!1){do;while(this[Hs](this[le]())&&this[N].length);!t&&!this[N].length&&!this[lt]&&this.emit("drain")}[Hs](t){return this.emit("data",t),this[j]}pipe(t,e){if(this[M])return t;this[K]=!1;let s=this[ut];return e=e||{},t===qs.stdout||t===qs.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[G].push(e.proxyErrors?new Le(this,t,e):new fe(this,t,e)),this[nt]?zt(()=>this[Ot]()):this[Ot]()),t}unpipe(t){let e=this[G].find(s=>s.dest===t);e&&(this[G].length===1?(this[j]&&this[wt]===0&&(this[j]=!1),this[G]=[]):this[G].splice(this[G].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[K]=!1,this[wt]++,!this[G].length&&!this[j]&&this[Ot]();else if(t==="readable"&&this[$]!==0)super.emit("readable");else if(ar(t)&&this[ut])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[It]){let n=e;this[nt]?zt(()=>n.call(this,this[It])):n.call(this,this[It])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[wt]=this.listeners("data").length,this[wt]===0&&!this[K]&&!this[G].length&&(this[j]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[wt]=0,!this[K]&&!this[G].length&&(this[j]=!1)),e}get emittedEnd(){return this[ut]}[ct](){!this[oe]&&!this[ut]&&!this[M]&&this[N].length===0&&this[lt]&&(this[oe]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ae]&&this.emit("close"),this[oe]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==M&&this[M])return!1;if(t==="data")return!this[z]&&!s?!1:this[nt]?(zt(()=>this[Ne](s)),!0):this[Ne](s);if(t==="end")return this[Js]();if(t==="close"){if(this[ae]=!0,!this[ut]&&!this[M])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[It]=s,super.emit(je,s);let r=!this[Wt]||this.listeners("error").length?super.emit("error",s):!1;return this[ct](),r}else if(t==="resume"){let r=super.emit("resume");return this[ct](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let n=super.emit(t,...e);return this[ct](),n}[Ne](t){for(let s of this[G])s.dest.write(t)===!1&&this.pause();let e=this[K]?!1:super.emit("data",t);return this[ct](),e}[Js](){return this[ut]?!1:(this[ut]=!0,this.readable=!1,this[nt]?(zt(()=>this[$e]()),!0):this[$e]())}[$e](){if(this[xt]){let e=this[xt].end();if(e){for(let s of this[G])s.dest.write(e);this[K]||super.emit("data",e)}}for(let e of this[G])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[z]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[z]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[z])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[et]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(M,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[K]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[lt])return e();let r,o,a=m=>{this.off("data",h),this.off("end",u),this.off(M,d),e(),o(m)},h=m=>{this.off("error",a),this.off("end",u),this.off(M,d),this.pause(),r({value:m,done:!!this[lt]})},u=()=>{this.off("error",a),this.off("data",h),this.off(M,d),e(),r({done:!0,value:void 0})},d=()=>a(new Error("stream destroyed"));return new Promise((m,g)=>{o=g,r=m,this.once(M,d),this.once("error",a),this.once("end",u),this.once("data",h)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[K]=!1;let t=!1,e=()=>(this.pause(),this.off(je,e),this.off(M,e),this.off("end",e),t=!0,{done:!0,value:void 0}),s=()=>{if(t)return e();let n=this.read();return n===null?e():{done:!1,value:n}};return this.once("end",e),this.once(je,e),this.once(M,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[M])return t?this.emit("error",t):this.emit(M),this;this[M]=!0,this[K]=!0,this[N].length=0,this[$]=0;let e=this;return typeof e.close=="function"&&!this[ae]&&e.close(),t?this.emit("error",t):this.emit(M),this}static get isStream(){return ir}};var dr=ot.realpathSync.native,Ut={lstatSync:ot.lstatSync,readdir:ot.readdir,readdirSync:ot.readdirSync,readlinkSync:ot.readlinkSync,realpathSync:dr,promises:{lstat:pt.lstat,readdir:pt.readdir,readlink:pt.readlink,realpath:pt.realpath}},ti=i=>!i||i===Ut||i===ur?Ut:{...Ut,...i,promises:{...Ut.promises,...i.promises||{}}},ei=/^\\\\\?\\([a-z]:)\\?$/i,pr=i=>i.replace(/\//g,"\\").replace(ei,"$1\\"),mr=/[\\\/]/,Q=0,si=1,ii=2,rt=4,ni=6,ri=8,yt=10,oi=12,Z=15,Bt=~Z,ze=16,Vs=32,qt=64,st=128,de=256,me=512,Ys=qt|st|me,gr=1023,Be=i=>i.isFile()?ri:i.isDirectory()?rt:i.isSymbolicLink()?yt:i.isCharacterDevice()?ii:i.isBlockDevice()?ni:i.isSocket()?oi:i.isFIFO()?si:Q,Xs=new Map,Gt=i=>{let t=Xs.get(i);if(t)return t;let e=i.normalize("NFKD");return Xs.set(i,e),e},Zs=new Map,pe=i=>{let t=Zs.get(i);if(t)return t;let e=Gt(i.toLowerCase());return Zs.set(i,e),e},ge=class extends $t{constructor(){super({max:256})}},Ue=class extends $t{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},ai=Symbol("PathScurry setAsCwd"),B=class{name;root;roots;parent;nocase;#t;#s;get dev(){return this.#s}#r;get mode(){return this.#r}#i;get nlink(){return this.#i}#a;get uid(){return this.#a}#l;get gid(){return this.#l}#f;get rdev(){return this.#f}#h;get blksize(){return this.#h}#o;get ino(){return this.#o}#e;get size(){return this.#e}#m;get blocks(){return this.#m}#w;get atimeMs(){return this.#w}#d;get mtimeMs(){return this.#d}#u;get ctimeMs(){return this.#u}#S;get birthtimeMs(){return this.#S}#g;get atime(){return this.#g}#x;get mtime(){return this.#x}#O;get ctime(){return this.#O}#k;get birthtime(){return this.#k}#b;#P;#p;#D;#A;#E;#n;#y;#_;#v;get path(){return(this.parent||this).fullpath()}constructor(t,e=Q,s,n,r,o,a){this.name=t,this.#b=r?pe(t):Gt(t),this.#n=e&gr,this.nocase=r,this.roots=n,this.root=s||this,this.#y=o,this.#p=a.fullpath,this.#A=a.relative,this.#E=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=ti(a.fs)}depth(){return this.#P!==void 0?this.#P:this.parent?this.#P=this.parent.depth()+1:this.#P=0}childrenCache(){return this.#y}resolve(t){if(!t)return this;let e=this.getRootString(t),n=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#j(n):this.#j(n)}#j(t){let e=this;for(let s of t)e=e.child(s);return e}children(){let t=this.#y.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#y.set(this,e),this.#n&=~ze,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),n=this.nocase?pe(t):Gt(t);for(let h of s)if(h.#b===n)return h;let r=this.parent?this.sep:"",o=this.#p?this.#p+r+t:void 0,a=this.newChild(t,Q,{...e,parent:this,fullpath:o});return this.canReaddir()||(a.#n|=st),s.push(a),a}relative(){if(this.#A!==void 0)return this.#A;let t=this.name,e=this.parent;if(!e)return this.#A=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.#E!==void 0)return this.#E;let t=this.name,e=this.parent;if(!e)return this.#E=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(this.#p!==void 0)return this.#p;let t=this.name,e=this.parent;if(!e)return this.#p=this.name;let n=e.fullpath()+(e.parent?this.sep:"")+t;return this.#p=n}fullpathPosix(){if(this.#D!==void 0)return this.#D;if(this.sep==="/")return this.#D=this.fullpath();if(!this.parent){let n=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(n)?this.#D=`//?/${n}`:this.#D=n}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return this.#D=s}isUnknown(){return(this.#n&Z)===Q}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#n&Z)===ri}isDirectory(){return(this.#n&Z)===rt}isCharacterDevice(){return(this.#n&Z)===ii}isBlockDevice(){return(this.#n&Z)===ni}isFIFO(){return(this.#n&Z)===si}isSocket(){return(this.#n&Z)===oi}isSymbolicLink(){return(this.#n&yt)===yt}lstatCached(){return this.#n&Vs?this:void 0}readlinkCached(){return this.#_}realpathCached(){return this.#v}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#_)return!0;if(!this.parent)return!1;let t=this.#n&Z;return!(t!==Q&&t!==yt||this.#n&de||this.#n&st)}calledReaddir(){return!!(this.#n&ze)}isENOENT(){return!!(this.#n&st)}isNamed(t){return this.nocase?this.#b===pe(t):this.#b===Gt(t)}async readlink(){let t=this.#_;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#_=s}catch(e){this.#I(e.code);return}}readlinkSync(){let t=this.#_;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#_=s}catch(e){this.#I(e.code);return}}#N(t){this.#n|=ze;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#T()}}#T(){this.#n&st||(this.#n=(this.#n|st)&Bt,this.#R())}#R(){let t=this.children();t.provisional=0;for(let e of t)e.#T()}#$(){this.#n|=me,this.#F()}#F(){if(this.#n&qt)return;let t=this.#n;(t&Z)===rt&&(t&=Bt),this.#n=t|qt,this.#R()}#M(t=""){t==="ENOTDIR"||t==="EPERM"?this.#F():t==="ENOENT"?this.#T():this.children().provisional=0}#c(t=""){t==="ENOTDIR"?this.parent.#F():t==="ENOENT"&&this.#T()}#I(t=""){let e=this.#n;e|=de,t==="ENOENT"&&(e|=st),(t==="EINVAL"||t==="UNKNOWN")&&(e&=Bt),this.#n=e,t==="ENOTDIR"&&this.parent&&this.parent.#F()}#C(t,e){return this.#q(t,e)||this.#U(t,e)}#U(t,e){let s=Be(t),n=this.newChild(t.name,s,{parent:this}),r=n.#n&Z;return r!==rt&&r!==yt&&r!==Q&&(n.#n|=qt),e.unshift(n),e.provisional++,n}#q(t,e){for(let s=e.provisional;s<e.length;s++){let n=e[s];if((this.nocase?pe(t.name):Gt(t.name))===n.#b)return this.#G(t,n,s,e)}}#G(t,e,s,n){let r=e.name;return e.#n=e.#n&Bt|Be(t),r!==t.name&&(e.name=t.name),s!==n.provisional&&(s===n.length-1?n.pop():n.splice(s,1),n.unshift(e)),n.provisional++,e}async lstat(){if(!(this.#n&st))try{return this.#B(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#c(t.code)}}lstatSync(){if(!(this.#n&st))try{return this.#B(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#c(t.code)}}#B(t){let{atime:e,atimeMs:s,birthtime:n,birthtimeMs:r,blksize:o,blocks:a,ctime:h,ctimeMs:u,dev:d,gid:m,ino:g,mode:w,mtime:k,mtimeMs:y,nlink:E,rdev:b,size:O,uid:x}=t;this.#g=e,this.#w=s,this.#k=n,this.#S=r,this.#h=o,this.#m=a,this.#O=h,this.#u=u,this.#s=d,this.#l=m,this.#o=g,this.#r=w,this.#x=k,this.#d=y,this.#i=E,this.#f=b,this.#e=O,this.#a=x;let T=Be(t);this.#n=this.#n&Bt|T|Vs,T!==Q&&T!==rt&&T!==yt&&(this.#n|=qt)}#W=[];#z=!1;#H(t){this.#z=!1;let e=this.#W.slice();this.#W.length=0,e.forEach(s=>s(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);e?t(null,r):queueMicrotask(()=>t(null,r));return}if(this.#W.push(t),this.#z)return;this.#z=!0;let n=this.fullpath();this.#t.readdir(n,{withFileTypes:!0},(r,o)=>{if(r)this.#M(r.code),s.provisional=0;else{for(let a of o)this.#C(a,s);this.#N(s)}this.#H(s.slice(0,s.provisional))})}#L;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#L)await this.#L;else{let s=()=>{};this.#L=new Promise(n=>s=n);try{for(let n of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#C(n,t);this.#N(t)}catch(n){this.#M(n.code),t.provisional=0}this.#L=void 0,s()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let s of this.#t.readdirSync(e,{withFileTypes:!0}))this.#C(s,t);this.#N(t)}catch(s){this.#M(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#n&Ys)return!1;let t=Z&this.#n;return t===Q||t===rt||t===yt}shouldWalk(t,e){return(this.#n&rt)===rt&&!(this.#n&Ys)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#v)return this.#v;if(!((me|de|st)&this.#n))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#v=this.resolve(t)}catch{this.#$()}}realpathSync(){if(this.#v)return this.#v;if(!((me|de|st)&this.#n))try{let t=this.#t.realpathSync(this.fullpath());return this.#v=this.resolve(t)}catch{this.#$()}}[ai](t){if(t===this)return;let e=new Set([]),s=[],n=this;for(;n&&n.parent;)e.add(n),n.#A=s.join(this.sep),n.#E=s.join("/"),n=n.parent,s.push("..");for(n=t;n&&n.parent&&!e.has(n);)n.#A=void 0,n.#E=void 0,n=n.parent}},we=class i extends B{sep="\\";splitSep=mr;constructor(t,e=Q,s,n,r,o,a){super(t,e,s,n,r,o,a)}newChild(t,e=Q,s={}){return new i(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(t){return At.win32.parse(t).root}getRoot(t){if(t=pr(t.toUpperCase()),t===this.root.name)return this.root;for(let[e,s]of Object.entries(this.roots))if(this.sameRoot(t,e))return this.roots[t]=s;return this.roots[t]=new Pt(t,this).root}sameRoot(t,e=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(ei,"$1\\"),t===e}},ye=class i extends B{splitSep="/";sep="/";constructor(t,e=Q,s,n,r,o,a){super(t,e,s,n,r,o,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,e=Q,s={}){return new i(t,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},be=class{root;rootPath;roots;cwd;#t;#s;#r;nocase;#i;constructor(t=process.cwd(),e,s,{nocase:n,childrenCacheSize:r=16*1024,fs:o=Ut}={}){this.#i=ti(o),(t instanceof URL||t.startsWith("file://"))&&(t=(0,Qs.fileURLToPath)(t));let a=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new ge,this.#s=new ge,this.#r=new Ue(r);let h=a.substring(this.rootPath.length).split(s);if(h.length===1&&!h[0]&&h.pop(),n===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=n,this.root=this.newRoot(this.#i),this.roots[this.rootPath]=this.root;let u=this.root,d=h.length-1,m=e.sep,g=this.rootPath,w=!1;for(let k of h){let y=d--;u=u.child(k,{relative:new Array(y).fill("..").join(m),relativePosix:new Array(y).fill("..").join("/"),fullpath:g+=(w?"":m)+k}),w=!0}this.cwd=u}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#r}resolve(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#t.get(e);if(s!==void 0)return s;let n=this.cwd.resolve(e).fullpath();return this.#t.set(e,n),n}resolvePosix(...t){let e="";for(let r=t.length-1;r>=0;r--){let o=t[r];if(!(!o||o===".")&&(e=e?`${o}/${e}`:o,this.isAbsolute(o)))break}let s=this.#s.get(e);if(s!==void 0)return s;let n=this.cwd.resolve(e).fullpathPosix();return this.#s.set(e,n),n}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let n=await t.readdir();return s?n:n.map(r=>r.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd);let{withFileTypes:s=!0}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(n=>n.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:n=!1,filter:r,walkFilter:o}=e,a=[];(!r||r(t))&&a.push(s?t:t.fullpath());let h=new Set,u=(m,g)=>{h.add(m),m.readdirCB((w,k)=>{if(w)return g(w);let y=k.length;if(!y)return g();let E=()=>{--y===0&&g()};for(let b of k)(!r||r(b))&&a.push(s?b:b.fullpath()),n&&b.isSymbolicLink()?b.realpath().then(O=>O?.isUnknown()?O.lstat():O).then(O=>O?.shouldWalk(h,o)?u(O,E):E()):b.shouldWalk(h,o)?u(b,E):E()},!0)},d=t;return new Promise((m,g)=>{u(d,w=>{if(w)return g(w);m(a)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:n=!1,filter:r,walkFilter:o}=e,a=[];(!r||r(t))&&a.push(s?t:t.fullpath());let h=new Set([t]);for(let u of h){let d=u.readdirSync();for(let m of d){(!r||r(m))&&a.push(s?m:m.fullpath());let g=m;if(m.isSymbolicLink()){if(!(n&&(g=m.realpathSync())))continue;g.isUnknown()&&g.lstatSync()}g.shouldWalk(h,o)&&h.add(g)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:n=!1,filter:r,walkFilter:o}=e;(!r||r(t))&&(yield s?t:t.fullpath());let a=new Set([t]);for(let h of a){let u=h.readdirSync();for(let d of u){(!r||r(d))&&(yield s?d:d.fullpath());let m=d;if(d.isSymbolicLink()){if(!(n&&(m=d.realpathSync())))continue;m.isUnknown()&&m.lstatSync()}m.shouldWalk(a,o)&&a.add(m)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:n=!1,filter:r,walkFilter:o}=e,a=new dt({objectMode:!0});(!r||r(t))&&a.write(s?t:t.fullpath());let h=new Set,u=[t],d=0,m=()=>{let g=!1;for(;!g;){let w=u.shift();if(!w){d===0&&a.end();return}d++,h.add(w);let k=(E,b,O=!1)=>{if(E)return a.emit("error",E);if(n&&!O){let x=[];for(let T of b)T.isSymbolicLink()&&x.push(T.realpath().then(P=>P?.isUnknown()?P.lstat():P));if(x.length){Promise.all(x).then(()=>k(null,b,!0));return}}for(let x of b)x&&(!r||r(x))&&(a.write(s?x:x.fullpath())||(g=!0));d--;for(let x of b){let T=x.realpathCached()||x;T.shouldWalk(h,o)&&u.push(T)}g&&!a.flowing?a.once("drain",m):y||m()},y=!0;w.readdirCB(k,!0),y=!1}};return m(),a}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof B||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:n=!1,filter:r,walkFilter:o}=e,a=new dt({objectMode:!0}),h=new Set;(!r||r(t))&&a.write(s?t:t.fullpath());let u=[t],d=0,m=()=>{let g=!1;for(;!g;){let w=u.shift();if(!w){d===0&&a.end();return}d++,h.add(w);let k=w.readdirSync();for(let y of k)(!r||r(y))&&(a.write(s?y:y.fullpath())||(g=!0));d--;for(let y of k){let E=y;if(y.isSymbolicLink()){if(!(n&&(E=y.realpathSync())))continue;E.isUnknown()&&E.lstatSync()}E.shouldWalk(h,o)&&u.push(E)}}g&&!a.flowing&&a.once("drain",m)};return m(),a}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[ai](e)}},Pt=class extends be{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,At.win32,"\\",{...e,nocase:s}),this.nocase=s;for(let n=this.cwd;n;n=n.parent)n.nocase=this.nocase}parseRootPath(t){return At.win32.parse(t).root.toUpperCase()}newRoot(t){return new we(this.rootPath,rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},Rt=class extends be{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,At.posix,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new ye(this.rootPath,rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Ht=class extends Rt{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},Eo=process.platform==="win32"?we:ye,hi=process.platform==="win32"?Pt:process.platform==="darwin"?Ht:Rt;var li=require("url");var wr=i=>i.length>=1,yr=i=>i.length>=1,Dt=class i{#t;#s;#r;length;#i;#a;#l;#f;#h;#o;#e=!0;constructor(t,e,s,n){if(!wr(t))throw new TypeError("empty pattern list");if(!yr(e))throw new TypeError("empty glob list");if(e.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#s=e,this.#r=s,this.#i=n,this.#r===0){if(this.isUNC()){let[r,o,a,h,...u]=this.#t,[d,m,g,w,...k]=this.#s;u[0]===""&&(u.shift(),k.shift());let y=[r,o,a,h,""].join("/"),E=[d,m,g,w,""].join("/");this.#t=[y,...u],this.#s=[E,...k],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[r,...o]=this.#t,[a,...h]=this.#s;o[0]===""&&(o.shift(),h.shift());let u=r+"/",d=a+"/";this.#t=[u,...o],this.#s=[d,...h],this.length=this.#t.length}}}pattern(){return this.#t[this.#r]}isString(){return typeof this.#t[this.#r]=="string"}isGlobstar(){return this.#t[this.#r]===L}isRegExp(){return this.#t[this.#r]instanceof RegExp}globString(){return this.#l=this.#l||(this.#r===0?this.isAbsolute()?this.#s[0]+this.#s.slice(1).join("/"):this.#s.join("/"):this.#s.slice(this.#r).join("/"))}hasMore(){return this.length>this.#r+1}rest(){return this.#a!==void 0?this.#a:this.hasMore()?(this.#a=new i(this.#t,this.#s,this.#r+1,this.#i),this.#a.#o=this.#o,this.#a.#h=this.#h,this.#a.#f=this.#f,this.#a):this.#a=null}isUNC(){let t=this.#t;return this.#h!==void 0?this.#h:this.#h=this.#i==="win32"&&this.#r===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#f!==void 0?this.#f:this.#f=this.#i==="win32"&&this.#r===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#o!==void 0?this.#o:this.#o=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#r===0?t:""}checkFollowGlobstar(){return!(this.#r===0||!this.isGlobstar()||!this.#e)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#e?!1:(this.#e=!1,!0)}};var br=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Jt=class{relative;relativeChildren;absolute;absoluteChildren;constructor(t,{nobrace:e,nocase:s,noext:n,noglobstar:r,platform:o=br}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[];let a={dot:!0,nobrace:e,nocase:s,noext:n,noglobstar:r,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let h of t){let u=new J(h,a);for(let d=0;d<u.set.length;d++){let m=u.set[d],g=u.globParts[d];if(!m||!g)throw new Error("invalid pattern object");for(;m[0]==="."&&g[0]===".";)m.shift(),g.shift();let w=new Dt(m,g,0,o),k=new J(w.globString(),a),y=g[g.length-1]==="**",E=w.isAbsolute();E?this.absolute.push(k):this.relative.push(k),y&&(E?this.absoluteChildren.push(k):this.relativeChildren.push(k))}}}ignored(t){let e=t.fullpath(),s=`${e}/`,n=t.relative()||".",r=`${n}/`;for(let o of this.relative)if(o.match(n)||o.match(r))return!0;for(let o of this.absolute)if(o.match(e)||o.match(s))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let n of this.relativeChildren)if(n.match(s))return!0;for(let n of this.absoluteChildren)if(n.match(e))return!0;return!1}};var qe=class i{store;constructor(t=new Map){this.store=t}copy(){return new i(new Map(this.store))}hasWalked(t,e){return this.store.get(t.fullpath())?.has(e.globString())}storeWalked(t,e){let s=t.fullpath(),n=this.store.get(s);n?n.add(e.globString()):this.store.set(s,new Set([e.globString()]))}},Ge=class{store=new Map;add(t,e,s){let n=(e?2:0)|(s?1:0),r=this.store.get(t);this.store.set(t,r===void 0?n:n&r)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},He=class{store=new Map;add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(n=>n.globString()===e.globString())||s.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Kt=class i{hasWalkedCache;matches=new Ge;subwalks=new He;patterns;follow;dot;opts;constructor(t,e){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=e?e.copy():new qe}processPatterns(t,e){this.patterns=e;let s=e.map(n=>[t,n]);for(let[n,r]of s){this.hasWalkedCache.storeWalked(n,r);let o=r.root(),a=r.isAbsolute()&&this.opts.absolute!==!1;if(o){n=n.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let m=r.rest();if(m)r=m;else{this.matches.add(n,!0,!1);continue}}if(n.isENOENT())continue;let h,u,d=!1;for(;typeof(h=r.pattern())=="string"&&(u=r.rest());)n=n.resolve(h),r=u,d=!0;if(h=r.pattern(),u=r.rest(),d){if(this.hasWalkedCache.hasWalked(n,r))continue;this.hasWalkedCache.storeWalked(n,r)}if(typeof h=="string"){let m=h===".."||h===""||h===".";this.matches.add(n.resolve(h),a,m);continue}else if(h===L){(!n.isSymbolicLink()||this.follow||r.checkFollowGlobstar())&&this.subwalks.add(n,r);let m=u?.pattern(),g=u?.rest();if(!u||(m===""||m===".")&&!g)this.matches.add(n,a,m===""||m===".");else if(m===".."){let w=n.parent||n;g?this.hasWalkedCache.hasWalked(w,g)||this.subwalks.add(w,g):this.matches.add(w,a,!0)}}else h instanceof RegExp&&this.subwalks.add(n,r)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new i(this.opts,this.hasWalkedCache)}filterEntries(t,e){let s=this.subwalks.get(t),n=this.child();for(let r of e)for(let o of s){let a=o.isAbsolute(),h=o.pattern(),u=o.rest();h===L?n.testGlobstar(r,o,u,a):h instanceof RegExp?n.testRegExp(r,h,u,a):n.testString(r,h,u,a)}return n}testGlobstar(t,e,s,n){if((this.dot||!t.name.startsWith("."))&&(e.hasMore()||this.matches.add(t,n,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,e):t.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(t,s):e.markFollowGlobstar()&&this.subwalks.add(t,e)))),s){let r=s.pattern();if(typeof r=="string"&&r!==".."&&r!==""&&r!==".")this.testString(t,r,s.rest(),n);else if(r===".."){let o=t.parent||t;this.subwalks.add(o,s)}else r instanceof RegExp&&this.testRegExp(t,r,s.rest(),n)}}testRegExp(t,e,s,n){e.test(t.name)&&(s?this.subwalks.add(t,s):this.matches.add(t,n,!1))}testString(t,e,s,n){t.isNamed(e)&&(s?this.subwalks.add(t,s):this.matches.add(t,n,!1))}};var Sr=(i,t)=>typeof i=="string"?new Jt([i],t):Array.isArray(i)?new Jt(i,t):i,Se=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#s;#r;signal;maxDepth;constructor(t,e,s){this.patterns=t,this.path=e,this.opts=s,this.#r=!s.posix&&s.platform==="win32"?"\\":"/",s.ignore&&(this.#s=Sr(s.ignore,s)),this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#i(t){return this.seen.has(t)||!!this.#s?.ignored?.(t)}#a(t){return!!this.#s?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s}let r=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=await r.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(r,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#i(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s}let r=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let o=r.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(r,e)}matchFinish(t,e){if(this.#i(t))return;let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let n=this.opts.mark&&t.isDirectory()?this.#r:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let r=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(r+n)}else{let r=this.opts.posix?t.relativePosix():t.relative(),o=this.opts.dotRelative&&!r.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(r?o+r+n:"."+n)}}async match(t,e,s){let n=await this.matchCheck(t,s);n&&this.matchFinish(n,e)}matchSync(t,e,s){let n=this.matchCheckSync(t,s);n&&this.matchFinish(n,e)}walkCB(t,e,s){this.signal?.aborted&&s(),this.walkCB2(t,e,new Kt(this.opts),s)}walkCB2(t,e,s,n){if(this.#a(t))return n();if(this.signal?.aborted&&n(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,n));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&n()};for(let[a,h,u]of s.matches.entries())this.#i(a)||(r++,this.match(a,h,u).then(()=>o()));for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let h=a.readdirCached();a.calledReaddir()?this.walkCB3(a,h,s,o):a.readdirCB((u,d)=>this.walkCB3(a,d,s,o),!0)}o()}walkCB3(t,e,s,n){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&n()};for(let[a,h,u]of s.matches.entries())this.#i(a)||(r++,this.match(a,h,u).then(()=>o()));for(let[a,h]of s.subwalks.entries())r++,this.walkCB2(a,h,s.child(),o);o()}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new Kt(this.opts),s)}walkCB2Sync(t,e,s,n){if(this.#a(t))return n();if(this.signal?.aborted&&n(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,n));return}s.processPatterns(t,e);let r=1,o=()=>{--r===0&&n()};for(let[a,h,u]of s.matches.entries())this.#i(a)||this.matchSync(a,h,u);for(let a of s.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;r++;let h=a.readdirSync();this.walkCB3Sync(a,h,s,o)}o()}walkCB3Sync(t,e,s,n){s=s.filterEntries(t,e);let r=1,o=()=>{--r===0&&n()};for(let[a,h,u]of s.matches.entries())this.#i(a)||this.matchSync(a,h,u);for(let[a,h]of s.subwalks.entries())r++,this.walkCB2Sync(a,h,s.child(),o);o()}},Vt=class extends Se{matches;constructor(t,e,s){super(t,e,s),this.matches=new Set}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Yt=class extends Se{results;constructor(t,e,s){super(t,e,s),this.results=new dt({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var kr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",it=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;opts;patterns;constructor(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=(0,li.fileURLToPath)(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(h=>h.includes("/")?h:`./**/${h}`)}if(this.pattern=t,this.platform=e.platform||kr,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let h=e.platform==="win32"?Pt:e.platform==="darwin"?Ht:e.platform?Rt:hi;this.scurry=new h(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",n={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(h=>new J(h,n)),[o,a]=r.reduce((h,u)=>(h[0].push(...u.set),h[1].push(...u.globParts),h),[[],[]]);this.patterns=o.map((h,u)=>{let d=a[u];if(!d)throw new Error("invalid pattern object");return new Dt(h,d,0,this.platform)})}async walk(){return[...await new Vt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase}).walk()]}walkSync(){return[...new Vt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase}).walkSync()]}stream(){return new Yt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase}).stream()}streamSync(){return new Yt(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var Je=(i,t={})=>{Array.isArray(i)||(i=[i]);for(let e of i)if(new J(e,t).hasMagic())return!0;return!1};function Ee(i,t={}){return new it(i,t).streamSync()}function fi(i,t={}){return new it(i,t).stream()}function ui(i,t={}){return new it(i,t).walkSync()}async function ci(i,t={}){return new it(i,t).walk()}function ve(i,t={}){return new it(i,t).iterateSync()}function di(i,t={}){return new it(i,t).iterate()}var Er=Ee,vr=Object.assign(fi,{sync:Ee}),Tr=ve,xr=Object.assign(di,{sync:ve}),Or=Object.assign(ui,{stream:Ee,iterate:ve}),ke=Object.assign(ci,{glob:ci,globSync:ui,sync:Or,globStream:fi,stream:vr,globStreamSync:Ee,streamSync:Er,globIterate:di,iterate:xr,globIterateSync:ve,iterateSync:Tr,Glob:it,hasMagic:Je,escape:Et,unescape:tt});ke.glob=ke;global.fetch=Ve.default;var Ar="../build",Pr="../wheels";async function wi(i,t){let e=[],s=n=>{e.push(n)};if(await i.loadPackage(t,{errorCallback:s}),e.length>0)throw new Error(e.join(`
|
|
6
|
+
`))}async function Rr(i){console.info("Copy the build directory (the bare built app files) to this directory...");let t=W.default.resolve(__dirname,Ar);if(!(await at.default.stat(t)).isDirectory())throw new Error(`The source ${t} does not exist.`);if(t===i.copyTo){console.warn(`sourceDir == destDir (${t}). Are you in the development environment? Skip copying the directory.`);return}if(i.keepOld)try{await at.default.access(i.copyTo),console.info(`${i.copyTo} already exists. Use it and skip copying.`);return}catch{throw new Error(`${i.copyTo} does not exist even though the \`keepOld\` option is specified`)}console.log(`Copy ${t} to ${i.copyTo}`),await at.default.rm(i.copyTo,{recursive:!0,force:!0}),await Ke.default.copy(t,i.copyTo,{errorOnExist:!0})}async function Dr(i){if(i.requirements.length===0)return[];let t=await(0,Ye.loadPyodide)();return await yi(t,{requirements:i.requirements}),Object.entries(t.loadedPackages).filter(([,e])=>e==="default channel").map(([e])=>e)}async function pi(i,t){console.log(`Preparing the local wheel ${t}`);let e=await at.default.readFile(t),s="/tmp/"+W.default.basename(t);i.FS.writeFile(s,e);let n=`emfs:${s}`;return console.log(`The local wheel ${t} is prepared as ${n}`),n}async function yi(i,t){await wi(i,"micropip");let e=i.pyimport("micropip"),s=[...t.requirements],n=W.default.join(__dirname,Pr),r=await pi(i,W.default.join(n,"stlite_server-0.1.0-py3-none-any.whl"));s.push(r);let o=await pi(i,W.default.join(n,"streamlit-1.33.0-cp311-none-any.whl"));s.push(o),console.log("Install the packages:",s),await e.install.callKwargs(s,{keep_going:!0})}async function _r(i){console.info("Create the site-packages snapshot file...");let t=await(0,Ye.loadPyodide)();await wi(t,"micropip");let e=t.pyimport("micropip"),s=await Ct.getInstance(),n=[];i.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..."),i.usedPrebuiltPackages.forEach(a=>{let h=s.getPackageInfoByName(a);if(h==null)throw new Error(`Package ${a} is not found in the lock file.`);console.log(`Mock ${h.name} ${h.version}`),e.add_mock_package(h.name,h.version),n.push(h.name)})),console.log(`Install the requirements ${JSON.stringify(i.requirements)}`),await yi(t,{requirements:i.requirements}),console.log("Remove the mocked packages",n),n.forEach(a=>e.remove_mock_package(a)),console.log("Archive the site-packages director(y|ies)");let r="/tmp/site-packages-snapshot.tar.gz";await t.runPythonAsync(`
|
|
5
7
|
import os
|
|
6
8
|
import tarfile
|
|
7
9
|
import site
|
|
8
10
|
|
|
9
11
|
site_packages_dirs = site.getsitepackages()
|
|
10
12
|
|
|
11
|
-
tar_file_name = '${
|
|
13
|
+
tar_file_name = '${r}'
|
|
12
14
|
with tarfile.open(tar_file_name, mode='w:gz') as gzf:
|
|
13
15
|
for site_packages in site_packages_dirs:
|
|
14
16
|
print("Add site-package:", site_packages)
|
|
15
17
|
print(os.listdir(site_packages))
|
|
16
18
|
gzf.add(site_packages)
|
|
17
|
-
`),console.log("Extract the archive file from EMFS");let
|
|
18
|
-
`);await
|
|
19
|
+
`),console.log("Extract the archive file from EMFS");let o=t.FS.readFile(r);console.log(`Save the archive file (${i.saveTo})`),await at.default.writeFile(i.saveTo,o)}async function Fr(i){console.info("Copy the app directory..."),await Promise.all(i.filePathPatterns.map(async t=>{let e=await ke(t,{cwd:i.cwd,absolute:!1});if(e.length===0){console.warn(`No files match the pattern "${t}" in "${i.cwd}".`);return}await Promise.all(e.map(async s=>{let n=W.default.resolve(i.cwd,s),r=W.default.resolve(i.buildAppDirectory,s);console.log(`Copy ${n} to ${r}`),await Ke.default.copy(n,r,{errorOnExist:!0})}))}))}async function Cr(i,t){try{await at.default.access(W.default.resolve(i,t))}catch{throw new Error(`The entrypoint file "${t}" is not included in the bundled files.`)}}async function Mr(i){let t=await at.default.readFile(i,{encoding:"utf-8"});return(0,Te.parseRequirementsTxt)(t)}async function jr(i,t){let e=t.join(`
|
|
20
|
+
`);await at.default.writeFile(i,e,{encoding:"utf-8"})}async function Nr(i){let t=await Ct.getInstance(),s=i.packages.map(n=>t.getPackageInfoByName(n)).map(n=>Zt(n.file_name));console.log("Downloading the used prebuilt packages..."),await Promise.all(s.map(async n=>{let r=W.default.resolve(i.destDir,"./pyodide",W.default.basename(n));console.log(`Download ${n} to ${r}`);let o=await(0,Ve.default)(n);if(!o.ok)throw new Error(`Failed to download ${n}: ${o.status} ${o.statusText}`);let a=await o.arrayBuffer();await at.default.writeFile(r,Buffer.from(a))}))}(0,mi.default)((0,gi.hideBin)(process.argv)).command("* [appHomeDirSource] [packages..]","Put the user code and data and the snapshot of the required packages into the build artifact.",()=>{},i=>{console.info(i)}).positional("appHomeDirSource",{describe:"[Deprecated] The source directory of the user code and data that will be mounted in the Pyodide file system at app runtime",type:"string",demandOption:!1}).positional("packages",{describe:"[Deprecated] Package names to install.",type:"string",array:!0}).options("project",{describe:"The project directory",type:"string",alias:"p",default:process.cwd()}).options("requirement",{describe:"Install from the given requirements file. This option can be used multiple times.",array:!0,type:"string",alias:"r",default:[],deprecated:!0}).options("keepOldBuild",{type:"boolean",default:!1,alias:"k",describe:"Keep the existing build directory contents except appHomeDir."}).parseAsync().then(async i=>{let t=i.project,e=W.default.resolve(t,"./build"),s=W.default.resolve(t,"./package.json"),n=require(s),r=await cs({pathResolutionRoot:t,packageJsonStliteDesktopField:n.stlite?.desktop,fallbacks:{appHomeDirSource:i.appHomeDirSource,packages:i.packages,requirementsTxtFilePaths:i.requirement}});console.log("File/directory patterns to be included:",r.files),console.log("Entrypoint:",r.entrypoint),console.log("Dependencies:",r.dependencies),console.log("`requirements.txt` files:",r.requirementsTxtFilePaths);let o=await Promise.all(r.requirementsTxtFilePaths.map(async d=>Mr(d))).then(d=>d.flat());console.log("Dependencies from `requirements.txt` files:",o);let a=(0,Te.validateRequirements)([...r.dependencies,...o]);console.log("Validated dependency list:",a);let h=await Dr({requirements:a});console.log("The prebuilt packages loaded for the given requirements:"),console.log(h),await Rr({copyTo:e,keepOld:i.keepOldBuild});let u=W.default.resolve(e,"./app_files");await Fr({cwd:t,filePathPatterns:r.files,buildAppDirectory:u}),Cr(u,r.entrypoint),await _r({requirements:a,usedPrebuiltPackages:h,saveTo:W.default.resolve(e,"./site-packages-snapshot.tar.gz")}),await jr(W.default.resolve(e,"./prebuilt-packages.txt"),h),await Nr({packages:h,destDir:e}),await hs({packageJsonStliteDesktopField:n.stlite?.desktop,manifestFilePath:W.default.resolve(e,"./stlite-manifest.json"),fallbacks:{entrypoint:r.entrypoint}})});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/static/css/main.36ee06a0.css",
|
|
4
|
-
"main.js": "/static/js/main.
|
|
5
|
-
"static/js/3936.
|
|
4
|
+
"main.js": "/static/js/main.444261b4.js",
|
|
5
|
+
"static/js/3936.cd554a7f.chunk.js": "/static/js/3936.cd554a7f.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
8
|
"static/js/4785.f30c7c35.chunk.js": "/static/js/4785.f30c7c35.chunk.js",
|
|
@@ -164,6 +164,6 @@
|
|
|
164
164
|
},
|
|
165
165
|
"entrypoints": [
|
|
166
166
|
"static/css/main.36ee06a0.css",
|
|
167
|
-
"static/js/main.
|
|
167
|
+
"static/js/main.444261b4.js"
|
|
168
168
|
]
|
|
169
169
|
}
|
package/build/electron/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Ce=Object.create;var Y=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Le=(i,a)=>()=>(a||i((a={exports:{}}).exports,a),a.exports);var qe=(i,a,f,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let w of Ue(a))!He.call(i,w)&&w!==f&&Y(i,w,{get:()=>a[w],enumerable:!(c=Je(a,w))||c.enumerable});return i};var M=(i,a,f)=>(f=i!=null?Ce(Be(i)):{},qe(a||!i||!i.__esModule?Y(f,"default",{value:i,enumerable:!0}):f,i));var Z=Le((R,X)=>{(function(i,a){typeof R=="object"&&typeof X<"u"?a(R):typeof define=="function"&&define.amd?define(["exports"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.Superstruct={}))})(R,function(i){"use strict";class a extends TypeError{constructor(n,t){let r,{message:o,explanation:s,...d}=n,{path:y}=n,h=y.length===0?o:`At path: ${y.join(".")} -- ${o}`;super(s??h),s!=null&&(this.cause=h),Object.assign(this,d),this.name=this.constructor.name,this.failures=()=>r??(r=[n,...t()])}}function f(e){return c(e)&&typeof e[Symbol.iterator]=="function"}function c(e){return typeof e=="object"&&e!=null}function w(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||n===Object.prototype}function p(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function E(e){let{done:n,value:t}=e.next();return n?void 0:t}function _(e,n,t,r){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});let{path:o,branch:s}=n,{type:d}=t,{refinement:y,message:h=`Expected a value of type \`${d}\`${y?` with refinement \`${y}\``:""}, but received: \`${p(r)}\``}=e;return{value:r,type:d,refinement:y,key:o[o.length-1],path:o,branch:s,...e,message:h}}function*g(e,n,t,r){f(e)||(e=[e]);for(let o of e){let s=_(o,n,t,r);s&&(yield s)}}function*k(e,n,t={}){let{path:r=[],branch:o=[e],coerce:s=!1,mask:d=!1}=t,y={path:r,branch:o};if(s&&(e=n.coercer(e,y),d&&n.type!=="type"&&c(n.schema)&&c(e)&&!Array.isArray(e)))for(let m in e)n.schema[m]===void 0&&delete e[m];let h="valid";for(let m of n.validator(e,y))m.explanation=t.message,h="not_valid",yield[m,void 0];for(let[m,S,Re]of n.entries(e,y)){let ve=k(S,Re,{path:m===void 0?r:[...r,m],branch:m===void 0?o:[...o,S],coerce:s,mask:d,message:t.message});for(let W of ve)W[0]?(h=W[0].refinement!=null?"not_refined":"not_valid",yield[W[0],void 0]):s&&(S=W[1],m===void 0?e=S:e instanceof Map?e.set(m,S):e instanceof Set?e.add(S):c(e)&&(S!==void 0||m in e)&&(e[m]=S))}if(h!=="not_valid")for(let m of n.refiner(e,y))m.explanation=t.message,h="not_refined",yield[m,void 0];h==="valid"&&(yield[void 0,e])}class u{constructor(n){let{type:t,schema:r,validator:o,refiner:s,coercer:d=h=>h,entries:y=function*(){}}=n;this.type=t,this.schema=r,this.entries=y,this.coercer=d,o?this.validator=(h,m)=>{let S=o(h,m);return g(S,m,this,h)}:this.validator=()=>[],s?this.refiner=(h,m)=>{let S=s(h,m);return g(S,m,this,h)}:this.refiner=()=>[]}assert(n,t){return $(n,this,t)}create(n,t){return z(n,this,t)}is(n){return v(n,this)}mask(n,t){return T(n,this,t)}validate(n,t={}){return A(n,this,t)}}function $(e,n,t){let r=A(e,n,{message:t});if(r[0])throw r[0]}function z(e,n,t){let r=A(e,n,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function T(e,n,t){let r=A(e,n,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function v(e,n){return!A(e,n)[0]}function A(e,n,t={}){let r=k(e,n,t),o=E(r);return o[0]?[new a(o[0],function*(){for(let d of r)d[0]&&(yield d[0])}),void 0]:[void 0,o[1]]}function te(...e){let n=e[0].type==="type",t=e.map(o=>o.schema),r=Object.assign({},...t);return n?I(r):F(r)}function P(e,n){return new u({type:e,schema:null,validator:n})}function re(e,n){return new u({...e,refiner:(t,r)=>t===void 0||e.refiner(t,r),validator(t,r){return t===void 0?!0:(n(t,r),e.validator(t,r))}})}function ie(e){return new u({type:"dynamic",schema:null,*entries(n,t){yield*e(n,t).entries(n,t)},validator(n,t){return e(n,t).validator(n,t)},coercer(n,t){return e(n,t).coercer(n,t)},refiner(n,t){return e(n,t).refiner(n,t)}})}function oe(e){let n;return new u({type:"lazy",schema:null,*entries(t,r){n??(n=e()),yield*n.entries(t,r)},validator(t,r){return n??(n=e()),n.validator(t,r)},coercer(t,r){return n??(n=e()),n.coercer(t,r)},refiner(t,r){return n??(n=e()),n.refiner(t,r)}})}function se(e,n){let{schema:t}=e,r={...t};for(let o of n)delete r[o];switch(e.type){case"type":return I(r);default:return F(r)}}function ae(e){let n=e instanceof u,t=n?{...e.schema}:{...e};for(let r in t)t[r]=H(t[r]);return n&&e.type==="type"?I(t):F(t)}function ce(e,n){let{schema:t}=e,r={};for(let o of n)r[o]=t[o];switch(e.type){case"type":return I(r);default:return F(r)}}function fe(e,n){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),P(e,n)}function de(){return P("any",()=>!0)}function ue(e){return new u({type:"array",schema:e,*entries(n){if(e&&Array.isArray(n))for(let[t,r]of n.entries())yield[t,r,e]},coercer(n){return Array.isArray(n)?n.slice():n},validator(n){return Array.isArray(n)||`Expected an array value, but received: ${p(n)}`}})}function le(){return P("bigint",e=>typeof e=="bigint")}function pe(){return P("boolean",e=>typeof e=="boolean")}function me(){return P("date",e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${p(e)}`)}function ye(e){let n={},t=e.map(r=>p(r)).join();for(let r of e)n[r]=r;return new u({type:"enums",schema:n,validator(r){return e.includes(r)||`Expected one of \`${t}\`, but received: ${p(r)}`}})}function he(){return P("func",e=>typeof e=="function"||`Expected a function, but received: ${p(e)}`)}function be(e){return P("instance",n=>n instanceof e||`Expected a \`${e.name}\` instance, but received: ${p(n)}`)}function we(){return P("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${p(e)}`)}function ge(e){return new u({type:"intersection",schema:null,*entries(n,t){for(let r of e)yield*r.entries(n,t)},*validator(n,t){for(let r of e)yield*r.validator(n,t)},*refiner(n,t){for(let r of e)yield*r.refiner(n,t)}})}function ke(e){let n=p(e),t=typeof e;return new u({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?e:null,validator(r){return r===e||`Expected the literal \`${n}\`, but received: ${p(r)}`}})}function $e(e,n){return new u({type:"map",schema:null,*entries(t){if(e&&n&&t instanceof Map)for(let[r,o]of t.entries())yield[r,r,e],yield[r,o,n]},coercer(t){return t instanceof Map?new Map(t):t},validator(t){return t instanceof Map||`Expected a \`Map\` object, but received: ${p(t)}`}})}function C(){return P("never",()=>!1)}function Pe(e){return new u({...e,validator:(n,t)=>n===null||e.validator(n,t),refiner:(n,t)=>n===null||e.refiner(n,t)})}function je(){return P("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${p(e)}`)}function F(e){let n=e?Object.keys(e):[],t=C();return new u({type:"object",schema:e||null,*entries(r){if(e&&c(r)){let o=new Set(Object.keys(r));for(let s of n)o.delete(s),yield[s,r[s],e[s]];for(let s of o)yield[s,r[s],t]}},validator(r){return c(r)||`Expected an object, but received: ${p(r)}`},coercer(r){return c(r)?{...r}:r}})}function H(e){return new u({...e,validator:(n,t)=>n===void 0||e.validator(n,t),refiner:(n,t)=>n===void 0||e.refiner(n,t)})}function Ee(e,n){return new u({type:"record",schema:null,*entries(t){if(c(t))for(let r in t){let o=t[r];yield[r,r,e],yield[r,o,n]}},validator(t){return c(t)||`Expected an object, but received: ${p(t)}`}})}function Se(){return P("regexp",e=>e instanceof RegExp)}function _e(e){return new u({type:"set",schema:null,*entries(n){if(e&&n instanceof Set)for(let t of n)yield[t,t,e]},coercer(n){return n instanceof Set?new Set(n):n},validator(n){return n instanceof Set||`Expected a \`Set\` object, but received: ${p(n)}`}})}function L(){return P("string",e=>typeof e=="string"||`Expected a string, but received: ${p(e)}`)}function Me(e){let n=C();return new u({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let r=Math.max(e.length,t.length);for(let o=0;o<r;o++)yield[o,t[o],e[o]||n]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${p(t)}`}})}function I(e){let n=Object.keys(e);return new u({type:"type",schema:e,*entries(t){if(c(t))for(let r of n)yield[r,t[r],e[r]]},validator(t){return c(t)||`Expected an object, but received: ${p(t)}`},coercer(t){return c(t)?{...t}:t}})}function Ne(e){let n=e.map(t=>t.type).join(" | ");return new u({type:"union",schema:null,coercer(t){for(let r of e){let[o,s]=r.validate(t,{coerce:!0});if(!o)return s}return t},validator(t,r){let o=[];for(let s of e){let[...d]=k(t,s,r),[y]=d;if(y[0])for(let[h]of d)h&&o.push(h);else return[]}return[`Expected the value to satisfy a union of \`${n}\`, but received: ${p(t)}`,...o]}})}function q(){return P("unknown",()=>!0)}function J(e,n,t){return new u({...e,coercer:(r,o)=>v(r,n)?e.coercer(t(r,o),o):e.coercer(r,o)})}function Oe(e,n,t={}){return J(e,q(),r=>{let o=typeof n=="function"?n():n;if(r===void 0)return o;if(!t.strict&&w(r)&&w(o)){let s={...r},d=!1;for(let y in o)s[y]===void 0&&(s[y]=o[y],d=!0);if(d)return s}return r})}function Ae(e){return J(e,L(),n=>n.trim())}function De(e){return O(e,"empty",n=>{let t=V(n);return t===0||`Expected an empty ${e.type} but received one with a size of \`${t}\``})}function V(e){return e instanceof Map||e instanceof Set?e.size:e.length}function Fe(e,n,t={}){let{exclusive:r}=t;return O(e,"max",o=>r?o<n:o<=n||`Expected a ${e.type} less than ${r?"":"or equal to "}${n} but received \`${o}\``)}function Ie(e,n,t={}){let{exclusive:r}=t;return O(e,"min",o=>r?o>n:o>=n||`Expected a ${e.type} greater than ${r?"":"or equal to "}${n} but received \`${o}\``)}function ze(e){return O(e,"nonempty",n=>V(n)>0||`Expected a nonempty ${e.type} but received an empty one`)}function Te(e,n){return O(e,"pattern",t=>n.test(t)||`Expected a ${e.type} matching \`/${n.source}/\` but received "${t}"`)}function We(e,n,t=n){let r=`Expected a ${e.type}`,o=n===t?`of \`${n}\``:`between \`${n}\` and \`${t}\``;return O(e,"size",s=>{if(typeof s=="number"||s instanceof Date)return n<=s&&s<=t||`${r} ${o} but received \`${s}\``;if(s instanceof Map||s instanceof Set){let{size:d}=s;return n<=d&&d<=t||`${r} with a size ${o} but received one with a size of \`${d}\``}else{let{length:d}=s;return n<=d&&d<=t||`${r} with a length ${o} but received one with a length of \`${d}\``}})}function O(e,n,t){return new u({...e,*refiner(r,o){yield*e.refiner(r,o);let s=t(r,o),d=g(s,o,e,r);for(let y of d)yield{...y,refinement:n}}})}i.Struct=u,i.StructError=a,i.any=de,i.array=ue,i.assert=$,i.assign=te,i.bigint=le,i.boolean=pe,i.coerce=J,i.create=z,i.date=me,i.defaulted=Oe,i.define=P,i.deprecated=re,i.dynamic=ie,i.empty=De,i.enums=ye,i.func=he,i.instance=be,i.integer=we,i.intersection=ge,i.is=v,i.lazy=oe,i.literal=ke,i.map=$e,i.mask=T,i.max=Fe,i.min=Ie,i.never=C,i.nonempty=ze,i.nullable=Pe,i.number=je,i.object=F,i.omit=se,i.optional=H,i.partial=ae,i.pattern=Te,i.pick=ce,i.record=Ee,i.refine=O,i.regexp=Se,i.set=_e,i.size=We,i.string=L,i.struct=fe,i.trimmed=Ae,i.tuple=Me,i.type=I,i.union=Ne,i.unknown=q,i.validate=A})});var l=require("electron"),j=M(require("path")),U=M(require("fs/promises")),B=M(require("node:worker_threads"));var D=M(require("fs/promises")),N=M(require("path"));async function G(i){let a={},f=await D.readdir(i);return await Promise.all(f.map(async c=>{let w=N.join(i,c);if((await D.stat(w)).isDirectory()){let E=await G(w);Object.assign(a,E)}else{let E=await D.readFile(w);a[w]=E}})),a}async function Q(i){let a=await G(i),f={};return Object.keys(a).forEach(c=>{let p=N.relative(i,c).split(N.sep).join(N.posix.sep);f[p]=a[c]}),f}var K=M(require("path")),x=M(require("fs/promises")),b=M(Z()),Ve=b.object({embed:b.defaulted(b.boolean(),!1),idbfsMountpoints:b.optional(b.array(b.string())),nodeJsWorker:b.defaulted(b.boolean(),!1),nodefsMountpoints:b.optional(b.record(b.string(),b.string()))});async function ee(){let i=K.resolve(__dirname,"../stlite-manifest.json"),a=await x.readFile(i,{encoding:"utf-8"}),f=JSON.parse(a);return b.assert(f,Ve),f}var ne=async()=>{let i=await ee(),a=[];i.idbfsMountpoints&&a.push(`--idbfs-mountpoints=${JSON.stringify(i.idbfsMountpoints)}`),i.nodeJsWorker&&a.push("--nodejs-worker");let f=new l.BrowserWindow({width:1280,height:720,webPreferences:{preload:j.join(__dirname,"preload.js"),sandbox:!0,additionalArguments:a}}),c=new URL((l.app.isPackaged,"file:///index.html")),w=new URLSearchParams;i.embed&&w.set("embed","true"),c.search=w.toString();let p=c.toString(),E=g=>g.url===p;l.ipcMain.handle("readSitePackagesSnapshot",g=>{if(!E(g.senderFrame))throw new Error("Invalid IPC sender");let k=j.resolve(__dirname,"../site-packages-snapshot.tar.gz");return U.readFile(k)}),l.ipcMain.handle("readPrebuiltPackageNames",async g=>{if(!E(g.senderFrame))throw new Error("Invalid IPC sender");let k=j.resolve(__dirname,"../prebuilt-packages.txt");return(await U.readFile(k,{encoding:"utf-8"})).split(`
|
|
2
|
-
`).map($=>$.trim()).filter($=>$.length>0)}),l.ipcMain.handle("readStreamlitAppDirectory",async
|
|
1
|
+
var Je=Object.create;var Y=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Le=(i,a)=>()=>(a||i((a={exports:{}}).exports,a),a.exports);var qe=(i,a,f,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let g of Ue(a))!He.call(i,g)&&g!==f&&Y(i,g,{get:()=>a[g],enumerable:!(c=Ce(a,g))||c.enumerable});return i};var M=(i,a,f)=>(f=i!=null?Je(Be(i)):{},qe(a||!i||!i.__esModule?Y(f,"default",{value:i,enumerable:!0}):f,i));var Z=Le((R,X)=>{(function(i,a){typeof R=="object"&&typeof X<"u"?a(R):typeof define=="function"&&define.amd?define(["exports"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.Superstruct={}))})(R,function(i){"use strict";class a extends TypeError{constructor(n,t){let r,{message:o,explanation:s,...d}=n,{path:h}=n,b=h.length===0?o:`At path: ${h.join(".")} -- ${o}`;super(s??b),s!=null&&(this.cause=b),Object.assign(this,d),this.name=this.constructor.name,this.failures=()=>r??(r=[n,...t()])}}function f(e){return c(e)&&typeof e[Symbol.iterator]=="function"}function c(e){return typeof e=="object"&&e!=null}function g(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||n===Object.prototype}function p(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function E(e){let{done:n,value:t}=e.next();return n?void 0:t}function _(e,n,t,r){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});let{path:o,branch:s}=n,{type:d}=t,{refinement:h,message:b=`Expected a value of type \`${d}\`${h?` with refinement \`${h}\``:""}, but received: \`${p(r)}\``}=e;return{value:r,type:d,refinement:h,key:o[o.length-1],path:o,branch:s,...e,message:b}}function*w(e,n,t,r){f(e)||(e=[e]);for(let o of e){let s=_(o,n,t,r);s&&(yield s)}}function*k(e,n,t={}){let{path:r=[],branch:o=[e],coerce:s=!1,mask:d=!1}=t,h={path:r,branch:o};if(s&&(e=n.coercer(e,h),d&&n.type!=="type"&&c(n.schema)&&c(e)&&!Array.isArray(e)))for(let m in e)n.schema[m]===void 0&&delete e[m];let b="valid";for(let m of n.validator(e,h))m.explanation=t.message,b="not_valid",yield[m,void 0];for(let[m,S,Re]of n.entries(e,h)){let ve=k(S,Re,{path:m===void 0?r:[...r,m],branch:m===void 0?o:[...o,S],coerce:s,mask:d,message:t.message});for(let W of ve)W[0]?(b=W[0].refinement!=null?"not_refined":"not_valid",yield[W[0],void 0]):s&&(S=W[1],m===void 0?e=S:e instanceof Map?e.set(m,S):e instanceof Set?e.add(S):c(e)&&(S!==void 0||m in e)&&(e[m]=S))}if(b!=="not_valid")for(let m of n.refiner(e,h))m.explanation=t.message,b="not_refined",yield[m,void 0];b==="valid"&&(yield[void 0,e])}class u{constructor(n){let{type:t,schema:r,validator:o,refiner:s,coercer:d=b=>b,entries:h=function*(){}}=n;this.type=t,this.schema=r,this.entries=h,this.coercer=d,o?this.validator=(b,m)=>{let S=o(b,m);return w(S,m,this,b)}:this.validator=()=>[],s?this.refiner=(b,m)=>{let S=s(b,m);return w(S,m,this,b)}:this.refiner=()=>[]}assert(n,t){return $(n,this,t)}create(n,t){return z(n,this,t)}is(n){return v(n,this)}mask(n,t){return T(n,this,t)}validate(n,t={}){return A(n,this,t)}}function $(e,n,t){let r=A(e,n,{message:t});if(r[0])throw r[0]}function z(e,n,t){let r=A(e,n,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function T(e,n,t){let r=A(e,n,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function v(e,n){return!A(e,n)[0]}function A(e,n,t={}){let r=k(e,n,t),o=E(r);return o[0]?[new a(o[0],function*(){for(let d of r)d[0]&&(yield d[0])}),void 0]:[void 0,o[1]]}function te(...e){let n=e[0].type==="type",t=e.map(o=>o.schema),r=Object.assign({},...t);return n?I(r):F(r)}function P(e,n){return new u({type:e,schema:null,validator:n})}function re(e,n){return new u({...e,refiner:(t,r)=>t===void 0||e.refiner(t,r),validator(t,r){return t===void 0?!0:(n(t,r),e.validator(t,r))}})}function ie(e){return new u({type:"dynamic",schema:null,*entries(n,t){yield*e(n,t).entries(n,t)},validator(n,t){return e(n,t).validator(n,t)},coercer(n,t){return e(n,t).coercer(n,t)},refiner(n,t){return e(n,t).refiner(n,t)}})}function oe(e){let n;return new u({type:"lazy",schema:null,*entries(t,r){n??(n=e()),yield*n.entries(t,r)},validator(t,r){return n??(n=e()),n.validator(t,r)},coercer(t,r){return n??(n=e()),n.coercer(t,r)},refiner(t,r){return n??(n=e()),n.refiner(t,r)}})}function se(e,n){let{schema:t}=e,r={...t};for(let o of n)delete r[o];switch(e.type){case"type":return I(r);default:return F(r)}}function ae(e){let n=e instanceof u,t=n?{...e.schema}:{...e};for(let r in t)t[r]=H(t[r]);return n&&e.type==="type"?I(t):F(t)}function ce(e,n){let{schema:t}=e,r={};for(let o of n)r[o]=t[o];switch(e.type){case"type":return I(r);default:return F(r)}}function fe(e,n){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),P(e,n)}function de(){return P("any",()=>!0)}function ue(e){return new u({type:"array",schema:e,*entries(n){if(e&&Array.isArray(n))for(let[t,r]of n.entries())yield[t,r,e]},coercer(n){return Array.isArray(n)?n.slice():n},validator(n){return Array.isArray(n)||`Expected an array value, but received: ${p(n)}`}})}function le(){return P("bigint",e=>typeof e=="bigint")}function pe(){return P("boolean",e=>typeof e=="boolean")}function me(){return P("date",e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${p(e)}`)}function ye(e){let n={},t=e.map(r=>p(r)).join();for(let r of e)n[r]=r;return new u({type:"enums",schema:n,validator(r){return e.includes(r)||`Expected one of \`${t}\`, but received: ${p(r)}`}})}function he(){return P("func",e=>typeof e=="function"||`Expected a function, but received: ${p(e)}`)}function be(e){return P("instance",n=>n instanceof e||`Expected a \`${e.name}\` instance, but received: ${p(n)}`)}function ge(){return P("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${p(e)}`)}function we(e){return new u({type:"intersection",schema:null,*entries(n,t){for(let r of e)yield*r.entries(n,t)},*validator(n,t){for(let r of e)yield*r.validator(n,t)},*refiner(n,t){for(let r of e)yield*r.refiner(n,t)}})}function ke(e){let n=p(e),t=typeof e;return new u({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?e:null,validator(r){return r===e||`Expected the literal \`${n}\`, but received: ${p(r)}`}})}function $e(e,n){return new u({type:"map",schema:null,*entries(t){if(e&&n&&t instanceof Map)for(let[r,o]of t.entries())yield[r,r,e],yield[r,o,n]},coercer(t){return t instanceof Map?new Map(t):t},validator(t){return t instanceof Map||`Expected a \`Map\` object, but received: ${p(t)}`}})}function J(){return P("never",()=>!1)}function Pe(e){return new u({...e,validator:(n,t)=>n===null||e.validator(n,t),refiner:(n,t)=>n===null||e.refiner(n,t)})}function je(){return P("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${p(e)}`)}function F(e){let n=e?Object.keys(e):[],t=J();return new u({type:"object",schema:e||null,*entries(r){if(e&&c(r)){let o=new Set(Object.keys(r));for(let s of n)o.delete(s),yield[s,r[s],e[s]];for(let s of o)yield[s,r[s],t]}},validator(r){return c(r)||`Expected an object, but received: ${p(r)}`},coercer(r){return c(r)?{...r}:r}})}function H(e){return new u({...e,validator:(n,t)=>n===void 0||e.validator(n,t),refiner:(n,t)=>n===void 0||e.refiner(n,t)})}function Ee(e,n){return new u({type:"record",schema:null,*entries(t){if(c(t))for(let r in t){let o=t[r];yield[r,r,e],yield[r,o,n]}},validator(t){return c(t)||`Expected an object, but received: ${p(t)}`}})}function Se(){return P("regexp",e=>e instanceof RegExp)}function _e(e){return new u({type:"set",schema:null,*entries(n){if(e&&n instanceof Set)for(let t of n)yield[t,t,e]},coercer(n){return n instanceof Set?new Set(n):n},validator(n){return n instanceof Set||`Expected a \`Set\` object, but received: ${p(n)}`}})}function L(){return P("string",e=>typeof e=="string"||`Expected a string, but received: ${p(e)}`)}function Me(e){let n=J();return new u({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let r=Math.max(e.length,t.length);for(let o=0;o<r;o++)yield[o,t[o],e[o]||n]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${p(t)}`}})}function I(e){let n=Object.keys(e);return new u({type:"type",schema:e,*entries(t){if(c(t))for(let r of n)yield[r,t[r],e[r]]},validator(t){return c(t)||`Expected an object, but received: ${p(t)}`},coercer(t){return c(t)?{...t}:t}})}function Ne(e){let n=e.map(t=>t.type).join(" | ");return new u({type:"union",schema:null,coercer(t){for(let r of e){let[o,s]=r.validate(t,{coerce:!0});if(!o)return s}return t},validator(t,r){let o=[];for(let s of e){let[...d]=k(t,s,r),[h]=d;if(h[0])for(let[b]of d)b&&o.push(b);else return[]}return[`Expected the value to satisfy a union of \`${n}\`, but received: ${p(t)}`,...o]}})}function q(){return P("unknown",()=>!0)}function C(e,n,t){return new u({...e,coercer:(r,o)=>v(r,n)?e.coercer(t(r,o),o):e.coercer(r,o)})}function Oe(e,n,t={}){return C(e,q(),r=>{let o=typeof n=="function"?n():n;if(r===void 0)return o;if(!t.strict&&g(r)&&g(o)){let s={...r},d=!1;for(let h in o)s[h]===void 0&&(s[h]=o[h],d=!0);if(d)return s}return r})}function Ae(e){return C(e,L(),n=>n.trim())}function De(e){return O(e,"empty",n=>{let t=V(n);return t===0||`Expected an empty ${e.type} but received one with a size of \`${t}\``})}function V(e){return e instanceof Map||e instanceof Set?e.size:e.length}function Fe(e,n,t={}){let{exclusive:r}=t;return O(e,"max",o=>r?o<n:o<=n||`Expected a ${e.type} less than ${r?"":"or equal to "}${n} but received \`${o}\``)}function Ie(e,n,t={}){let{exclusive:r}=t;return O(e,"min",o=>r?o>n:o>=n||`Expected a ${e.type} greater than ${r?"":"or equal to "}${n} but received \`${o}\``)}function ze(e){return O(e,"nonempty",n=>V(n)>0||`Expected a nonempty ${e.type} but received an empty one`)}function Te(e,n){return O(e,"pattern",t=>n.test(t)||`Expected a ${e.type} matching \`/${n.source}/\` but received "${t}"`)}function We(e,n,t=n){let r=`Expected a ${e.type}`,o=n===t?`of \`${n}\``:`between \`${n}\` and \`${t}\``;return O(e,"size",s=>{if(typeof s=="number"||s instanceof Date)return n<=s&&s<=t||`${r} ${o} but received \`${s}\``;if(s instanceof Map||s instanceof Set){let{size:d}=s;return n<=d&&d<=t||`${r} with a size ${o} but received one with a size of \`${d}\``}else{let{length:d}=s;return n<=d&&d<=t||`${r} with a length ${o} but received one with a length of \`${d}\``}})}function O(e,n,t){return new u({...e,*refiner(r,o){yield*e.refiner(r,o);let s=t(r,o),d=w(s,o,e,r);for(let h of d)yield{...h,refinement:n}}})}i.Struct=u,i.StructError=a,i.any=de,i.array=ue,i.assert=$,i.assign=te,i.bigint=le,i.boolean=pe,i.coerce=C,i.create=z,i.date=me,i.defaulted=Oe,i.define=P,i.deprecated=re,i.dynamic=ie,i.empty=De,i.enums=ye,i.func=he,i.instance=be,i.integer=ge,i.intersection=we,i.is=v,i.lazy=oe,i.literal=ke,i.map=$e,i.mask=T,i.max=Fe,i.min=Ie,i.never=J,i.nonempty=ze,i.nullable=Pe,i.number=je,i.object=F,i.omit=se,i.optional=H,i.partial=ae,i.pattern=Te,i.pick=ce,i.record=Ee,i.refine=O,i.regexp=Se,i.set=_e,i.size=We,i.string=L,i.struct=fe,i.trimmed=Ae,i.tuple=Me,i.type=I,i.union=Ne,i.unknown=q,i.validate=A})});var l=require("electron"),j=M(require("path")),U=M(require("fs/promises")),B=M(require("node:worker_threads"));var D=M(require("fs/promises")),N=M(require("path"));async function G(i){let a={},f=await D.readdir(i);return await Promise.all(f.map(async c=>{let g=N.join(i,c);if((await D.stat(g)).isDirectory()){let E=await G(g);Object.assign(a,E)}else{let E=await D.readFile(g);a[g]=E}})),a}async function Q(i){let a=await G(i),f={};return Object.keys(a).forEach(c=>{let p=N.relative(i,c).split(N.sep).join(N.posix.sep);f[p]=a[c]}),f}var K=M(require("path")),x=M(require("fs/promises")),y=M(Z()),Ve=y.object({entrypoint:y.string(),embed:y.defaulted(y.boolean(),!1),idbfsMountpoints:y.optional(y.array(y.string())),nodeJsWorker:y.defaulted(y.boolean(),!1),nodefsMountpoints:y.optional(y.record(y.string(),y.string()))});async function ee(){let i=K.resolve(__dirname,"../stlite-manifest.json"),a=await x.readFile(i,{encoding:"utf-8"}),f=JSON.parse(a);return y.assert(f,Ve),f}var ne=async()=>{let i=await ee(),a=[];a.push(`--entrypoint=${JSON.stringify(i.entrypoint)}`),i.idbfsMountpoints&&a.push(`--idbfs-mountpoints=${JSON.stringify(i.idbfsMountpoints)}`),i.nodeJsWorker&&a.push("--nodejs-worker");let f=new l.BrowserWindow({width:1280,height:720,webPreferences:{preload:j.join(__dirname,"preload.js"),sandbox:!0,additionalArguments:a}}),c=new URL((l.app.isPackaged,"file:///index.html")),g=new URLSearchParams;i.embed&&g.set("embed","true"),c.search=g.toString();let p=c.toString(),E=w=>w.url===p;l.ipcMain.handle("readSitePackagesSnapshot",w=>{if(!E(w.senderFrame))throw new Error("Invalid IPC sender");let k=j.resolve(__dirname,"../site-packages-snapshot.tar.gz");return U.readFile(k)}),l.ipcMain.handle("readPrebuiltPackageNames",async w=>{if(!E(w.senderFrame))throw new Error("Invalid IPC sender");let k=j.resolve(__dirname,"../prebuilt-packages.txt");return(await U.readFile(k,{encoding:"utf-8"})).split(`
|
|
2
|
+
`).map($=>$.trim()).filter($=>$.length>0)}),l.ipcMain.handle("readStreamlitAppDirectory",async w=>{if(!E(w.senderFrame))throw new Error("Invalid IPC sender");let k=j.resolve(__dirname,"../app_files");return Q(k)}),f.on("closed",()=>{l.ipcMain.removeHandler("readSitePackagesSnapshot"),l.ipcMain.removeHandler("readPrebuiltPackageNames"),l.ipcMain.removeHandler("readStreamlitAppDirectory")});let _=null;l.ipcMain.handle("initializeNodeJsWorker",w=>{if(!E(w.senderFrame))throw new Error("Invalid IPC sender");let k=j.resolve(__dirname,"../pyodide/pyodide.mjs");function u($){f.webContents.send("messageFromNodeJsWorker",$)}_=new B.default.Worker(j.resolve(__dirname,"./worker.js"),{env:{PYODIDE_URL:k,...i.nodefsMountpoints&&{NODEFS_MOUNTPOINTS:JSON.stringify(i.nodefsMountpoints)}}}),_.on("message",$=>{u($)})}),l.ipcMain.on("messageToNodeJsWorker",(w,{data:k,portId:u})=>{if(!E(w.senderFrame))throw new Error("Invalid IPC sender");if(_==null)return;let $=new B.default.MessageChannel;$.port1.on("message",T=>{w.reply(`nodeJsWorker-portMessage-${u}`,T)});let z={data:k,port:$.port2};_.postMessage(z,[$.port2])}),l.ipcMain.handle("terminate",(w,{data:k,portId:u})=>{if(!E(w.senderFrame))throw new Error("Invalid IPC sender");_?.terminate(),_=null}),f.on("closed",()=>{l.ipcMain.removeHandler("initializeNodeJsWorker"),l.ipcMain.removeHandler("messageToNodeJsWorker"),l.ipcMain.removeHandler("terminate")}),f.loadURL(p),l.app.isPackaged||f.webContents.openDevTools()};l.app.enableSandbox();l.app.whenReady().then(()=>{let i=j.resolve(__dirname,"..");l.protocol.interceptFileProtocol("file",function(a,f){let c=new URL(a.url).pathname;if(j.isAbsolute(c)){let g=j.join(i,c);f(j.normalize(g))}else f(c)}),ne(),l.app.on("activate",()=>{l.BrowserWindow.getAllWindows().length===0&&ne()})});l.app.on("window-all-closed",()=>{process.platform!=="darwin"&&l.app.quit()});l.app.on("web-contents-created",(i,a)=>{a.on("will-attach-webview",(f,c,g)=>{f.preventDefault()}),a.on("will-navigate",(f,c)=>{console.debug("will-navigate",c),f.preventDefault()}),a.setWindowOpenHandler(({url:f})=>(console.error("Opening a new window is not allowed."),{action:"deny"}))});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var i=Object.defineProperty;var
|
|
1
|
+
var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var f=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of g(r))!k.call(e,n)&&n!==t&&i(e,n,{get:()=>r[n],enumerable:!(s=c(r,n))||s.enumerable});return e};var l=e=>f(i({},"__esModule",{value:!0}),e);var P={};module.exports=l(P);var o=require("electron"),a=process.argv.find(e=>e.startsWith("--entrypoint="))?.split("=")[1],d=a&&JSON.parse(a);if(typeof d!="string")throw new Error("The `entrypoint` field must be a string.");var p=process.argv.find(e=>e.startsWith("--idbfs-mountpoints="))?.split("=")[1],W=p&&JSON.parse(p),A={entrypoint:d,idbfsMountpoints:W};o.contextBridge.exposeInMainWorld("appConfig",A);var m={readSitePackagesSnapshot:()=>o.ipcRenderer.invoke("readSitePackagesSnapshot"),readPrebuiltPackageNames:()=>o.ipcRenderer.invoke("readPrebuiltPackageNames"),readStreamlitAppDirectory:()=>o.ipcRenderer.invoke("readStreamlitAppDirectory")};o.contextBridge.exposeInMainWorld("archivesAPI",m);function y(){return Math.floor(Math.random()*1e6)}var I={USE_NODEJS_WORKER:process.argv.includes("--nodejs-worker"),initialize:()=>o.ipcRenderer.invoke("initializeNodeJsWorker"),postMessage:({data:e,onPortMessage:r})=>{console.debug("nodeJsWorkerAPI.postMessage",{data:e,onPortMessage:r});let t=r&&y();o.ipcRenderer.send("messageToNodeJsWorker",{data:e,portId:t}),t&&o.ipcRenderer.on(`nodeJsWorker-portMessage-${t}`,(s,n)=>{r(n)})},onMessage:e=>o.ipcRenderer.on("messageFromNodeJsWorker",(r,t)=>{console.debug("nodeJsWorkerAPI.onMessage",t),e(t)}),terminate:()=>o.ipcRenderer.invoke("terminateNodeJsWorker")};o.contextBridge.exposeInMainWorld("nodeJsWorkerAPI",I);
|