opfs-worker 0.5.0 → 1.0.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/dist/assets/worker-XHCzp1qX.js.map +1 -0
- package/dist/{helpers-Bm2TWyPQ.js → helpers-CTCvNFs1.js} +215 -150
- package/dist/{helpers-Bm2TWyPQ.js.map → helpers-CTCvNFs1.js.map} +1 -1
- package/dist/helpers-Cvjm0f_r.cjs +4 -0
- package/dist/{helpers-BoLdVbGk.cjs.map → helpers-Cvjm0f_r.cjs.map} +1 -1
- package/dist/index.cjs +302 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +330 -255
- package/dist/index.js.map +1 -1
- package/dist/raw.cjs +1 -1
- package/dist/raw.cjs.map +1 -1
- package/dist/raw.js +110 -100
- package/dist/raw.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/encoder.d.ts +2 -1
- package/dist/utils/encoder.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +22 -3
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/worker.d.ts +14 -7
- package/dist/worker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-3SMz_DAt.js.map +0 -1
- package/dist/helpers-BoLdVbGk.cjs +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";class E extends Error{constructor(t,e,n,r){super(t,{cause:r}),this.code=e,this.path=n,this.name="OPFSError"}}class V extends E{constructor(t){super("OPFS is not supported in this browser","OPFS_NOT_SUPPORTED",void 0,t)}}class at extends E{constructor(t){super("OPFS is not mounted","OPFS_NOT_MOUNTED",void 0,t)}}class ht extends E{constructor(t,e,n){super(t,"INVALID_PATH",e,n)}}class lt extends E{constructor(t,e){super(`File not found: ${t}`,"FILE_NOT_FOUND",t,e)}}class ut extends E{constructor(t,e){super(`Directory not found: ${t}`,"DIRECTORY_NOT_FOUND",t,e)}}class ft extends E{constructor(t,e,n){super(`Permission denied for ${e} on: ${t}`,"PERMISSION_DENIED",t,n)}}class pt extends E{constructor(t,e,n){super(t,"STORAGE_ERROR",e,n)}}class dt extends E{constructor(t,e,n){super(`Operation timed out: ${t}`,"TIMEOUT_ERROR",e,n)}}const X=(s,t,e)=>{const n=s instanceof RegExp?_(s,e):s,r=t instanceof RegExp?_(t,e):t,i=n!==null&&r!=null&>(n,r,e);return i&&{start:i[0],end:i[1],pre:e.slice(0,i[0]),body:e.slice(i[0]+n.length,i[1]),post:e.slice(i[1]+r.length)}},_=(s,t)=>{const e=t.match(s);return e?e[0]:null},gt=(s,t,e)=>{let n,r,i,o,a,h=e.indexOf(s),l=e.indexOf(t,h+1),c=h;if(h>=0&&l>0){if(s===t)return[h,l];for(n=[],i=e.length;c>=0&&!a;){if(c===h)n.push(c),h=e.indexOf(s,c+1);else if(n.length===1){const p=n.pop();p!==void 0&&(a=[p,l])}else r=n.pop(),r!==void 0&&r<i&&(i=r,o=l),l=e.indexOf(t,c+1);c=h<l&&h>=0?h:l}n.length&&o!==void 0&&(a=[i,o])}return a},Y="\0SLASH"+Math.random()+"\0",K="\0OPEN"+Math.random()+"\0",W="\0CLOSE"+Math.random()+"\0",Q="\0COMMA"+Math.random()+"\0",tt="\0PERIOD"+Math.random()+"\0",mt=new RegExp(Y,"g"),yt=new RegExp(K,"g"),wt=new RegExp(W,"g"),Et=new RegExp(Q,"g"),St=new RegExp(tt,"g"),xt=/\\\\/g,Ot=/\\{/g,bt=/\\}/g,At=/\\,/g,Nt=/\\./g;function U(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function vt(s){return s.replace(xt,Y).replace(Ot,K).replace(bt,W).replace(At,Q).replace(Nt,tt)}function Pt(s){return s.replace(mt,"\\").replace(yt,"{").replace(wt,"}").replace(Et,",").replace(St,".")}function et(s){if(!s)return[""];const t=[],e=X("{","}",s);if(!e)return s.split(",");const{pre:n,body:r,post:i}=e,o=n.split(",");o[o.length-1]+="{"+r+"}";const a=et(i);return i.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function $t(s){return s?(s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),$(vt(s),!0).map(Pt)):[]}function Mt(s){return"{"+s+"}"}function Tt(s){return/^-?0\d/.test(s)}function Rt(s,t){return s<=t}function Ct(s,t){return s>=t}function $(s,t){const e=[],n=X("{","}",s);if(!n)return[s];const r=n.pre,i=n.post.length?$(n.post,!1):[""];if(/\$$/.test(n.pre))for(let o=0;o<i.length;o++){const a=r+"{"+n.body+"}"+i[o];e.push(a)}else{const o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),h=o||a,l=n.body.indexOf(",")>=0;if(!h&&!l)return n.post.match(/,(?!,).*\}/)?(s=n.pre+"{"+n.body+W+n.post,$(s)):[s];let c;if(h)c=n.body.split(/\.\./);else if(c=et(n.body),c.length===1&&c[0]!==void 0&&(c=$(c[0],!1).map(Mt),c.length===1))return i.map(f=>n.pre+c[0]+f);let p;if(h&&c[0]!==void 0&&c[1]!==void 0){const f=U(c[0]),u=U(c[1]),g=Math.max(c[0].length,c[1].length);let d=c.length===3&&c[2]!==void 0?Math.abs(U(c[2])):1,S=Rt;u<f&&(d*=-1,S=Ct);const N=c.some(Tt);p=[];for(let x=f;S(x,u);x+=d){let m;if(a)m=String.fromCharCode(x),m==="\\"&&(m="");else if(m=String(x),N){const v=g-m.length;if(v>0){const T=new Array(v+1).join("0");x<0?m="-"+T+m.slice(1):m=T+m}}p.push(m)}}else{p=[];for(let f=0;f<c.length;f++)p.push.apply(p,$(c[f],!1))}for(let f=0;f<p.length;f++)for(let u=0;u<i.length;u++){const g=r+p[f]+i[u];(!t||h||g)&&e.push(g)}}return e}const Dt=1024*64,C=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>Dt)throw new TypeError("pattern is too long")},Ft={"[: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]},P=s=>s.replace(/[[\]\\-]/g,"\\$&"),Lt=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),B=s=>s.join(""),Ut=(s,t)=>{const e=t;if(s.charAt(e)!=="[")throw new Error("not in a brace expression");const n=[],r=[];let i=e+1,o=!1,a=!1,h=!1,l=!1,c=e,p="";t:for(;i<s.length;){const d=s.charAt(i);if((d==="!"||d==="^")&&i===e+1){l=!0,i++;continue}if(d==="]"&&o&&!h){c=i+1;break}if(o=!0,d==="\\"&&!h){h=!0,i++;continue}if(d==="["&&!h){for(const[S,[A,N,x]]of Object.entries(Ft))if(s.startsWith(S,i)){if(p)return["$.",!1,s.length-e,!0];i+=S.length,x?r.push(A):n.push(A),a=a||N;continue t}}if(h=!1,p){d>p?n.push(P(p)+"-"+P(d)):d===p&&n.push(P(d)),p="",i++;continue}if(s.startsWith("-]",i+1)){n.push(P(d+"-")),i+=2;continue}if(s.startsWith("-",i+1)){p=d,i+=2;continue}n.push(P(d)),i++}if(c<i)return["",!1,0,!1];if(!n.length&&!r.length)return["$.",!1,s.length-e,!0];if(r.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){const d=n[0].length===2?n[0].slice(-1):n[0];return[Lt(d),!1,c-e,!1]}const f="["+(l?"^":"")+B(n)+"]",u="["+(l?"":"^")+B(r)+"]";return[n.length&&r.length?"("+f+"|"+u+")":n.length?f:u,a,c-e,!0]},M=(s,{windowsPathsNoEscape:t=!1}={})=>t?s.replace(/\[([^\/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"),Wt=new Set(["!","?","+","*","@"]),q=s=>Wt.has(s),kt="(?!(?:^|/)\\.\\.?(?:$|/))",R="(?!\\.)",jt=new Set(["[","."]),It=new Set(["..","."]),zt=new Set("().*{}+?[]^$\\!"),_t=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),k="[^/]",G=k+"*?",H=k+"+?";class w{type;#s;#n;#i=!1;#t=[];#e;#o;#a;#c=!1;#r;#h;#u=!1;constructor(t,e,n={}){this.type=t,t&&(this.#n=!0),this.#e=e,this.#s=this.#e?this.#e.#s:this,this.#r=this.#s===this?n:this.#s.#r,this.#a=this.#s===this?[]:this.#s.#a,t==="!"&&!this.#s.#c&&this.#a.push(this),this.#o=this.#e?this.#e.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(const t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#h!==void 0?this.#h:this.type?this.#h=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#h=this.#t.map(t=>String(t)).join("")}#p(){if(this!==this.#s)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let t;for(;t=this.#a.pop();){if(t.type!=="!")continue;let e=t,n=e.#e;for(;n;){for(let r=e.#o+1;!n.type&&r<n.#t.length;r++)for(const i of t.#t){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#t[r])}e=n,n=e.#e}}return this}push(...t){for(const e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof w&&e.#e===this))throw new Error("invalid part: "+e);this.#t.push(e)}}toJSON(){const t=this.type===null?this.#t.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#t.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#s||this.#s.#c&&this.#e?.type==="!")&&t.push({}),t}isStart(){if(this.#s===this)return!0;if(!this.#e?.isStart())return!1;if(this.#o===0)return!0;const t=this.#e;for(let e=0;e<this.#o;e++){const n=t.#t[e];if(!(n instanceof w&&n.type==="!"))return!1}return!0}isEnd(){if(this.#s===this||this.#e?.type==="!")return!0;if(!this.#e?.isEnd())return!1;if(!this.type)return this.#e?.isEnd();const t=this.#e?this.#e.#t.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){const e=new w(this.type,t);for(const n of this.#t)e.copyIn(n);return e}static#l(t,e,n,r){let i=!1,o=!1,a=-1,h=!1;if(e.type===null){let u=n,g="";for(;u<t.length;){const d=t.charAt(u++);if(i||d==="\\"){i=!i,g+=d;continue}if(o){u===a+1?(d==="^"||d==="!")&&(h=!0):d==="]"&&!(u===a+2&&h)&&(o=!1),g+=d;continue}else if(d==="["){o=!0,a=u,h=!1,g+=d;continue}if(!r.noext&&q(d)&&t.charAt(u)==="("){e.push(g),g="";const S=new w(d,e);u=w.#l(t,S,u,r),e.push(S);continue}g+=d}return e.push(g),u}let l=n+1,c=new w(null,e);const p=[];let f="";for(;l<t.length;){const u=t.charAt(l++);if(i||u==="\\"){i=!i,f+=u;continue}if(o){l===a+1?(u==="^"||u==="!")&&(h=!0):u==="]"&&!(l===a+2&&h)&&(o=!1),f+=u;continue}else if(u==="["){o=!0,a=l,h=!1,f+=u;continue}if(q(u)&&t.charAt(l)==="("){c.push(f),f="";const g=new w(u,c);c.push(g),l=w.#l(t,g,l,r);continue}if(u==="|"){c.push(f),f="",p.push(c),c=new w(null,e);continue}if(u===")")return f===""&&e.#t.length===0&&(e.#u=!0),c.push(f),f="",e.push(...p,c),l;f+=u}return e.type=null,e.#n=void 0,e.#t=[t.substring(n-1)],l}static fromGlob(t,e={}){const n=new w(null,void 0,e);return w.#l(t,n,0,e),n}toMMPattern(){if(this!==this.#s)return this.#s.toMMPattern();const t=this.toString(),[e,n,r,i]=this.toRegExpSource();if(!(r||this.#n||this.#r.nocase&&!this.#r.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;const a=(this.#r.nocase?"i":"")+(i?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return this.#r}toRegExpSource(t){const e=t??!!this.#r.dot;if(this.#s===this&&this.#p(),!this.type){const h=this.isStart()&&this.isEnd(),l=this.#t.map(u=>{const[g,d,S,A]=typeof u=="string"?w.#d(u,this.#n,h):u.toRegExpSource(t);return this.#n=this.#n||S,this.#i=this.#i||A,g}).join("");let c="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&It.has(this.#t[0]))){const g=jt,d=e&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),S=!e&&!t&&g.has(l.charAt(0));c=d?kt:S?R:""}let p="";return this.isEnd()&&this.#s.#c&&this.#e?.type==="!"&&(p="(?:$|\\/)"),[c+l+p,M(l),this.#n=!!this.#n,this.#i]}const n=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:";let i=this.#f(e);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){const h=this.toString();return this.#t=[h],this.type=null,this.#n=void 0,[h,M(this.toString()),!1,!1]}let o=!n||t||e||!R?"":this.#f(!0);o===i&&(o=""),o&&(i=`(?:${i})(?:${o})*?`);let a="";if(this.type==="!"&&this.#u)a=(this.isStart()&&!e?R:"")+H;else{const h=this.type==="!"?"))"+(this.isStart()&&!e&&!t?R:"")+G+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=r+i+h}return[a,M(i),this.#n=!!this.#n,this.#i]}#f(t){return this.#t.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");const[n,r,i,o]=e.toRegExpSource(t);return this.#i=this.#i||o,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#d(t,e,n=!1){let r=!1,i="",o=!1;for(let a=0;a<t.length;a++){const h=t.charAt(a);if(r){r=!1,i+=(zt.has(h)?"\\":"")+h;continue}if(h==="\\"){a===t.length-1?i+="\\\\":r=!0;continue}if(h==="["){const[l,c,p,f]=Ut(t,a);if(p){i+=l,o=o||c,a+=p-1,e=e||f;continue}}if(h==="*"){n&&t==="*"?i+=H:i+=G,e=!0;continue}if(h==="?"){i+=k,e=!0;continue}i+=_t(h)}return[i,M(t),!!e,o]}}const Bt=(s,{windowsPathsNoEscape:t=!1}={})=>t?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&"),y=(s,t,e={})=>(C(t),!e.nocomment&&t.charAt(0)==="#"?!1:new D(t,e).match(s)),qt=/^\*+([^+@!?\*\[\(]*)$/,Gt=s=>t=>!t.startsWith(".")&&t.endsWith(s),Ht=s=>t=>t.endsWith(s),Zt=s=>(s=s.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(s)),Jt=s=>(s=s.toLowerCase(),t=>t.toLowerCase().endsWith(s)),Vt=/^\*+\.\*+$/,Xt=s=>!s.startsWith(".")&&s.includes("."),Yt=s=>s!=="."&&s!==".."&&s.includes("."),Kt=/^\.\*+$/,Qt=s=>s!=="."&&s!==".."&&s.startsWith("."),te=/^\*+$/,ee=s=>s.length!==0&&!s.startsWith("."),se=s=>s.length!==0&&s!=="."&&s!=="..",ne=/^\?+([^+@!?\*\[\(]*)?$/,re=([s,t=""])=>{const e=st([s]);return t?(t=t.toLowerCase(),n=>e(n)&&n.toLowerCase().endsWith(t)):e},ie=([s,t=""])=>{const e=nt([s]);return t?(t=t.toLowerCase(),n=>e(n)&&n.toLowerCase().endsWith(t)):e},oe=([s,t=""])=>{const e=nt([s]);return t?n=>e(n)&&n.endsWith(t):e},ce=([s,t=""])=>{const e=st([s]);return t?n=>e(n)&&n.endsWith(t):e},st=([s])=>{const t=s.length;return e=>e.length===t&&!e.startsWith(".")},nt=([s])=>{const t=s.length;return e=>e.length===t&&e!=="."&&e!==".."},rt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Z={win32:{sep:"\\"},posix:{sep:"/"}},ae=rt==="win32"?Z.win32.sep:Z.posix.sep;y.sep=ae;const b=Symbol("globstar **");y.GLOBSTAR=b;const he="[^/]",le=he+"*?",ue="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",fe="(?:(?!(?:\\/|^)\\.).)*?",pe=(s,t={})=>e=>y(e,s,t);y.filter=pe;const O=(s,t={})=>Object.assign({},s,t),de=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return y;const t=y;return Object.assign((n,r,i={})=>t(n,r,O(s,i)),{Minimatch:class extends t.Minimatch{constructor(r,i={}){super(r,O(s,i))}static defaults(r){return t.defaults(O(s,r)).Minimatch}},AST:class extends t.AST{constructor(r,i,o={}){super(r,i,O(s,o))}static fromGlob(r,i={}){return t.AST.fromGlob(r,O(s,i))}},unescape:(n,r={})=>t.unescape(n,O(s,r)),escape:(n,r={})=>t.escape(n,O(s,r)),filter:(n,r={})=>t.filter(n,O(s,r)),defaults:n=>t.defaults(O(s,n)),makeRe:(n,r={})=>t.makeRe(n,O(s,r)),braceExpand:(n,r={})=>t.braceExpand(n,O(s,r)),match:(n,r,i={})=>t.match(n,r,O(s,i)),sep:t.sep,GLOBSTAR:b})};y.defaults=de;const it=(s,t={})=>(C(s),t.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:$t(s));y.braceExpand=it;const ge=(s,t={})=>new D(s,t).makeRe();y.makeRe=ge;const me=(s,t,e={})=>{const n=new D(t,e);return s=s.filter(r=>n.match(r)),n.options.nonull&&!s.length&&s.push(t),s};y.match=me;const J=/[?*]|[+@!]\(.*?\)|\[|\]/,ye=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class D{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){C(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||rt,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(const t of this.set)for(const e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){const 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=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);const n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((i,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){const h=i[0]===""&&i[1]===""&&(i[2]==="?"||!J.test(i[2]))&&!J.test(i[3]),l=/^[a-z]:/i.test(i[0]);if(h)return[...i.slice(0,4),...i.slice(4).map(c=>this.parse(c))];if(l)return[i[0],...i.slice(1).map(c=>this.parse(c))]}return i.map(h=>this.parse(h))});if(this.debug(this.pattern,r),this.set=r.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){const o=this.set[i];o[0]===""&&o[1]===""&&this.globParts[i][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 n=0;n<t.length;n++)for(let r=0;r<t[n].length;r++)t[n][r]==="**"&&(t[n][r]="*");const{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 n=-1;for(;(n=e.indexOf("**",n+1))!==-1;){let r=n;for(;e[r+1]==="**";)r++;r!==n&&e.splice(n,r-n)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((n,r)=>{const i=n[n.length-1];return r==="**"&&i==="**"?n:r===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(r),n)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){const i=t[r];r===1&&i===""&&t[0]===""||(i==="."||i==="")&&(e=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){const r=t[n-1];r&&r!=="."&&r!==".."&&r!=="**"&&(e=!0,t.splice(n-1,2),n-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let n of t){let r=-1;for(;(r=n.indexOf("**",r+1))!==-1;){let o=r;for(;n[o+1]==="**";)o++;o>r&&n.splice(r+1,o-r);let a=n[r+1];const h=n[r+2],l=n[r+3];if(a!==".."||!h||h==="."||h===".."||!l||l==="."||l==="..")continue;e=!0,n.splice(r,1);const c=n.slice(0);c[r]="**",t.push(c),r--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){const a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(e=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(e=!0,n.pop())}let i=0;for(;(i=n.indexOf("..",i+1))!==-1;){const o=n[i-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;const h=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...h),n.length===0&&n.push(""),i-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let n=e+1;n<t.length;n++){const r=this.partsMatch(t[e],t[n],!this.preserveMultipleSlashes);if(r){t[e]=[],t[n]=r;break}}return t.filter(e=>e.length)}partsMatch(t,e,n=!1){let r=0,i=0,o=[],a="";for(;r<t.length&&i<e.length;)if(t[r]===e[i])o.push(a==="b"?e[i]:t[r]),r++,i++;else if(n&&t[r]==="**"&&e[i]===t[r+1])o.push(t[r]),r++;else if(n&&e[i]==="**"&&t[r]===e[i+1])o.push(e[i]),i++;else if(t[r]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="b")return!1;a="a",o.push(t[r]),r++,i++}else if(e[i]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",o.push(e[i]),r++,i++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,n=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)e=!e,n++;n&&(this.pattern=t.slice(n)),this.negate=e}matchOne(t,e,n=!1){const r=this.options;if(this.isWindows){const d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),S=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),A=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),N=!A&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),x=S?3:d?0:void 0,m=N?3:A?0:void 0;if(typeof x=="number"&&typeof m=="number"){const[v,T]=[t[x],e[m]];v.toLowerCase()===T.toLowerCase()&&(e[m]=v,m>x?e=e.slice(m):x>m&&(t=t.slice(x)))}}const{optimizationLevel:i=1}=this.options;i>=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,l=e.length;o<h&&a<l;o++,a++){this.debug("matchOne loop");var c=e[a],p=t[o];if(this.debug(e,c,p),c===!1)return!1;if(c===b){this.debug("GLOBSTAR",[e,c,p]);var f=o,u=a+1;if(u===l){for(this.debug("** at the end");o<h;o++)if(t[o]==="."||t[o]===".."||!r.dot&&t[o].charAt(0)===".")return!1;return!0}for(;f<h;){var g=t[f];if(this.debug(`
|
|
2
|
-
globstar while`,t,f,e,u,g),this.matchOne(t.slice(f),e.slice(u),n))return this.debug("globstar found match!",f,h,g),!0;if(g==="."||g===".."||!r.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,f,e,u);break}this.debug("globstar swallow a segment, and continue"),f++}return!!(n&&(this.debug(`
|
|
3
|
-
>>> no match, partial?`,t,f,e,u),f===h))}let d;if(typeof c=="string"?(d=p===c,this.debug("string match",c,p,d)):(d=c.test(p),this.debug("pattern match",c,p,d)),!d)return!1}if(o===h&&a===l)return!0;if(o===h)return n;if(a===l)return o===h-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return it(this.pattern,this.options)}parse(t){C(t);const e=this.options;if(t==="**")return b;if(t==="")return"";let n,r=null;(n=t.match(te))?r=e.dot?se:ee:(n=t.match(qt))?r=(e.nocase?e.dot?Jt:Zt:e.dot?Ht:Gt)(n[1]):(n=t.match(ne))?r=(e.nocase?e.dot?ie:re:e.dot?oe:ce)(n):(n=t.match(Vt))?r=e.dot?Yt:Xt:(n=t.match(Kt))&&(r=Qt);const i=w.fromGlob(t,this.options).toMMPattern();return r&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const t=this.set;if(!t.length)return this.regexp=!1,this.regexp;const e=this.options,n=e.noglobstar?le:e.dot?ue:fe,r=new Set(e.nocase?["i"]:[]);let i=t.map(h=>{const l=h.map(c=>{if(c instanceof RegExp)for(const p of c.flags.split(""))r.add(p);return typeof c=="string"?ye(c):c===b?b:c._src});return l.forEach((c,p)=>{const f=l[p+1],u=l[p-1];c!==b||u===b||(u===void 0?f!==void 0&&f!==b?l[p+1]="(?:\\/|"+n+"\\/)?"+f:l[p]=n:f===void 0?l[p-1]=u+"(?:\\/|"+n+")?":f!==b&&(l[p-1]=u+"(?:\\/|\\/"+n+"\\/)"+f,l[p+1]=b))}),l.filter(c=>c!==b).join("/")}).join("|");const[o,a]=t.length>1?["(?:",")"]:["",""];i="^"+o+i+a+"$",this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...r].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;const n=this.options;this.isWindows&&(t=t.split("\\").join("/"));const r=this.slashSplit(t);this.debug(this.pattern,"split",r);const i=this.set;this.debug(this.pattern,"set",i);let o=r[r.length-1];if(!o)for(let a=r.length-2;!o&&a>=0;a--)o=r[a];for(let a=0;a<i.length;a++){const h=i[a];let l=r;if(n.matchBase&&h.length===1&&(l=[o]),this.matchOne(l,h,e))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return y.defaults(t).Minimatch}}y.AST=w;y.Minimatch=D;y.escape=Bt;y.unescape=M;function ot(s,t="utf-8"){switch(t){case"utf8":case"utf-8":return new TextEncoder().encode(s);case"utf16le":case"ucs2":case"ucs-2":return Ee(s);case"ascii":return Oe(s);case"latin1":return xe(s);case"binary":return Uint8Array.from(s,e=>e.charCodeAt(0));case"base64":return Uint8Array.from(atob(s),e=>e.charCodeAt(0));case"hex":if(!/^[\da-f]+$/i.test(s)||s.length%2!==0)throw new E("Invalid hex string","INVALID_HEX_FORMAT");return Uint8Array.from(s.match(/.{1,2}/g).map(e=>parseInt(e,16)));default:return console.warn("Encoding not supported, falling back to UTF-8"),new TextEncoder().encode(s)}}function we(s,t="utf-8"){switch(t){case"utf8":case"utf-8":return new TextDecoder().decode(s);case"utf16le":case"ucs2":case"ucs-2":return Se(s);case"latin1":return String.fromCharCode(...s);case"binary":return String.fromCharCode(...s);case"ascii":return String.fromCharCode(...s.map(e=>e&127));case"base64":return btoa(String.fromCharCode(...s));case"hex":return Array.from(s).map(e=>e.toString(16).padStart(2,"0")).join("");default:return console.warn("Unsupported encoding, falling back to UTF-8"),new TextDecoder().decode(s)}}function Ee(s){const t=new Uint8Array(s.length*2);for(let e=0;e<s.length;e++){const n=s.charCodeAt(e);t[e*2]=n&255,t[e*2+1]=n>>8}return t}function Se(s){s.length%2!==0&&(console.warn("Invalid UTF-16LE buffer length, truncating last byte"),s=s.slice(0,s.length-1));const t=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2);return String.fromCharCode(...t)}function xe(s){const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e)&255;return t}function Oe(s){const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e)&127;return t}function be(){if(!("storage"in navigator)||!("getDirectory"in navigator.storage))throw new V}async function F(s,t,e){return typeof navigator<"u"&&navigator.locks?.request?navigator.locks.request(`opfs:${s.replace(/\/+/g,"/").toLowerCase()}`,{mode:t},e):e()}function L(s){return Array.isArray(s)?s:(s.startsWith("~/")?s.slice(2):s).split("/").filter(Boolean)}function j(s){return typeof s=="string"?s??"/":`/${s.join("/")}`}function I(s){const t=L(s);return t[t.length-1]||""}function Ae(s){const t=L(s);return t.pop(),j(t)}function z(s){return!s||s==="/"?"/":s.startsWith("~/")?`/${s.slice(2)}`:s.startsWith("/")?s:`/${s}`}function Ne(s,t=!1){return s=s.replace(/\/$/,""),t&&!s.includes("*")?`${s}/**`:s}function ve(s,t){return y(s,t,{dot:!0,matchBase:!0})}function Pe(s,t){if(!t||Array.isArray(t)&&t.length===0)return!1;const e=z(s);return(Array.isArray(t)?t:[t]).some(r=>y(e,r,{dot:!0}))}function $e(s){const t=z(s),e=L(t),n=[];for(const r of e)if(!(r==="."||r===""))if(r===".."){if(n.length===0)continue;n.pop()}else n.push(r);return j(n)}function Me(s){const t=I(s),e=t.lastIndexOf(".");return e<=0||e===t.length-1?"":t.slice(e)}function ct(s,t="utf-8"){return typeof s=="string"?ot(s,t):s instanceof Uint8Array?s:new Uint8Array(s)}async function Te(s,t){return F(t,"shared",async()=>{const n=await(await s.getFile()).arrayBuffer();return new Uint8Array(n)})}async function Re(s,t,e,n={},r){const i=async()=>{let o=null;const a=n.append||!1,h=!a&&(n.truncate??!0);try{o=await s.createSyncAccessHandle();const l=ct(t,e),c=a?o.getSize():0;o.write(l,{at:c}),h&&o.truncate(l.byteLength),o.flush()}catch(l){console.error(l);const c=a?"append":"write";throw new E(`Failed to ${c} file`,`${c.toUpperCase()}_FAILED`,void 0,l)}finally{try{o?.close()}catch{}}};return r?F(r,"exclusive",i):i()}async function Ce(s,t="SHA-1",e=50*1024*1024){if(s instanceof File&&(s=await s.arrayBuffer()),s.byteLength>e)throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);const n=new Uint8Array(s),r=await crypto.subtle.digest(t,n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}function De(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}async function Fe(s){const t=await s.arrayBuffer();return new Uint8Array(t)}async function Le(s,t,e={}){const n=I(t);return F(t,"exclusive",async()=>{const r=e.recursive??!1,i=e.force??!1;try{await s.removeEntry(n,{recursive:r})}catch(o){if(o.name==="NotFoundError"){if(!i)throw new E(`No such file or directory: ${t}`,"ENOENT",void 0,o)}else throw o.name==="InvalidModificationError"?new E(`Directory not empty: ${t}. Use recursive option to force removal.`,"ENOTEMPTY",void 0,o):o.name==="TypeMismatchError"&&!r?new E(`Cannot remove directory without recursive option: ${t}`,"EISDIR",void 0,o):new E(`Failed to remove entry: ${t}`,"RM_FAILED",void 0,o)}})}exports.DirectoryNotFoundError=ut;exports.FileNotFoundError=lt;exports.OPFSError=E;exports.OPFSNotMountedError=at;exports.OPFSNotSupportedError=V;exports.PathError=ht;exports.PermissionError=ft;exports.StorageError=pt;exports.TimeoutError=dt;exports.basename=I;exports.buffersEqual=De;exports.calculateFileHash=Ce;exports.checkOPFSSupport=be;exports.convertBlobToUint8Array=Fe;exports.createBuffer=ct;exports.decodeBuffer=we;exports.dirname=Ae;exports.encodeString=ot;exports.extname=Me;exports.isPathExcluded=Pe;exports.joinPath=j;exports.matchMinimatch=ve;exports.normalizeMinimatch=Ne;exports.normalizePath=z;exports.readFileData=Te;exports.removeEntry=Le;exports.resolvePath=$e;exports.splitPath=L;exports.withLock=F;exports.writeFileData=Re;
|
|
4
|
-
//# sourceMappingURL=helpers-BoLdVbGk.cjs.map
|