@cxl/build 1.0.0-beta.1 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@ A flexible build system that executes configurable build tasks producing output
6
6
 
7
7
  ## Project Details
8
8
 
9
- - Branch Version: [1.0.0-beta.1](https://npmjs.com/package/@cxl/build/v/1.0.0-beta.1)
9
+ - Branch Version: [1.0.0-beta.3](https://npmjs.com/package/@cxl/build/v/1.0.0-beta.3)
10
10
  - License: GPL-3.0
11
11
  - Documentation: [Link](https://cxlio.github.io/cxl/build)
12
12
  - Report Issues: [Github](https://github.com/cxlio/cxl/issues)
@@ -0,0 +1,24 @@
1
+ import{e as G}from"./chunk-BJVTLF6O.js";import{basename as yr,join as re}from"path";import{readFileSync as ne}from"fs";var y={},br=Symbol("terminator");function qe(e,t){let r=!1,n={error:o,unsubscribe:s,get closed(){return r},signal:B(),next(i){if(!r)try{e.next?.(i)}catch(c){o(c)}},complete(){if(!r)try{e.complete?.()}finally{s()}}};e.signal?.subscribe(s);function o(i){if(r)throw i;if(!e.error)throw s(),i;try{e.error(i)}finally{s()}}function s(){r||(r=!0,n.signal.next())}try{if(t?.(n))throw new Error("Unsubscribe function result is deprectaed")}catch(i){o(i)}return n}function ie(...e){return t=>e.reduce((r,n)=>n(r),t)}var l=class{__subscribe;constructor(t){this.__subscribe=t}then(t,r){return ze(this).then(t,r)}pipe(...t){return t.reduce((r,n)=>n(r),this)}subscribe(t){return qe(!t||typeof t=="function"?{next:t}:t,this.__subscribe)}},D=class extends l{closed=!1;signal=B();observers=new Set;constructor(){super(t=>this.onSubscribe(t))}next(t){if(!this.closed)for(let r of Array.from(this.observers))r.closed||r.next(t)}error(t){if(!this.closed){this.closed=!0;let r=!1,n;for(let o of Array.from(this.observers))try{o.error(t)}catch(s){r=!0,n=s}if(r)throw n}}complete(){this.closed||(this.closed=!0,Array.from(this.observers).forEach(t=>t.complete()),this.observers.clear())}onSubscribe(t){this.closed?t.complete():(this.observers.add(t),t.signal.subscribe(()=>this.observers.delete(t)))}},O=class extends l{closed=!1;observers=new Set;constructor(){super(t=>{this.closed?(t.next(),t.complete()):this.observers.add(t)})}next(){if(!this.closed){this.closed=!0;for(let t of Array.from(this.observers))t.closed||(t.next(),t.complete());this.observers.clear()}}};var V=class extends D{bufferSize;buffer=[];hasError=!1;lastError;constructor(t=1/0){super(),this.bufferSize=t}error(t){this.hasError=!0,this.lastError=t,super.error(t)}next(t){return this.buffer.length===this.bufferSize&&this.buffer.shift(),this.buffer.push(t),super.next(t)}onSubscribe(t){this.observers.add(t),this.buffer.forEach(r=>t.next(r)),this.hasError?t.error(this.lastError):this.closed&&t.complete(),t.signal.subscribe(()=>this.observers.delete(t))}},M=class extends D{$value=y;get hasValue(){return this.$value!==y}get value(){if(this.$value===y)throw new Error("Reference not initialized");return this.$value}next(t){return this.$value=t,super.next(t)}onSubscribe(t){!this.closed&&this.$value!==y&&t.next(this.$value),super.onSubscribe(t)}},U=class extends Error{message="No elements in sequence"};function B(){return new O}function v(e){return new l(t=>{e().subscribe(t)})}function se(e){return new l(t=>{for(let r of e)t.closed||t.next(r);t.complete()})}function ce(e){return new l(t=>{e.then(r=>{t.closed||t.next(r),t.complete()}).catch(r=>t.error(r))})}function J(e){return v(()=>ce(e()))}function _e(e){return new l(t=>{for(let r of e)t.closed||t.next(r);t.complete()})}function ae(e){return e instanceof l?e:Array.isArray(e)?se(e):e instanceof Promise?ce(e):_e(e)}function q(...e){return se(e)}function We(e){return new Promise((t,r)=>{let n=y;e.subscribe({next:o=>n=o,error:o=>r(o),complete:()=>t(n)})})}function ze(e){return We(e).then(t=>t===y?void 0:t)}function E(e,t){return b(r=>({next:e(r),unsubscribe:t}))}function b(e){return t=>new l(r=>{let n=e(r,t);r.signal.subscribe(()=>n.unsubscribe?.()),n.error||(n.error=r.error),n.complete||(n.complete=r.complete),n.signal=r.signal,t.subscribe(n)})}function _(e){return E(t=>r=>t.next(e(r)))}function W(e,t){return b(r=>{let n=t,o=0;return{next(s){n=e(n,s,o++)},complete(){r.next(n),r.complete()}}})}function Ye(e){return b(t=>{let r=!0,n;return{next(o){r&&(r=!1,t.next(o),n=setTimeout(()=>r=!0,e))},unsubscribe:()=>clearTimeout(n)}})}function He(e){return new l(t=>{let r=setTimeout(()=>{t.next(),t.complete()},e);t.signal.subscribe(()=>clearTimeout(r))})}function Ke(e,t=He){return ue(r=>t(e).map(()=>r))}function ue(e){return t=>$(r=>{let n=!1,o=!1,s,i=()=>{s?.next(),n=!1,o&&r.complete()},c=B();r.signal.subscribe(()=>{i(),c.next()}),t.subscribe({next(a){i(),s=B(),n=!0,e(a).subscribe({next:r.next,error:r.error,complete:i,signal:s})},error:r.error,complete(){o=!0,n||r.complete()},signal:c})})}function Xe(e){return t=>$(r=>{let n=r.signal,o=0,s=0,i=!1;t.subscribe({next:c=>{o++,e(c).subscribe({next:r.next,error:r.error,complete:()=>{s++,i&&s===o&&r.complete()},signal:n})},error:r.error,complete(){i=!0,s===o&&r.complete()},signal:n})})}function Qe(e){return b(t=>{let r=!0;return{next(n){r&&(r=!1,e(n).subscribe({next:t.next,error:t.error,complete:()=>r=!0,signal:t.signal}))}}})}function z(e){return E(t=>r=>{e(r)&&t.next(r)})}function Ze(e){return E(t=>r=>{e-- >0&&!t.closed&&t.next(r),(e<=0||t.closed)&&t.complete()})}function et(e){return E(t=>r=>{!t.closed&&e(r)?t.next(r):t.complete()})}function tt(){let e=!1;return b(t=>({next(r){e||(e=!0,t.next(r),t.complete())},complete(){t.closed||t.error(new U)}}))}function Y(e){return E(t=>r=>{e(r),t.next(r)})}function rt(e){return b((t,r)=>{let n,o={next:t.next,error(s){try{if(t.closed)return;let i=e(s,r);i&&(n?.next(),n=B(),i.subscribe({...o,signal:n}))}catch(i){t.error(i)}},unsubscribe:()=>n?.next()};return o})}function nt(){return E(e=>{let t=y;return r=>{r!==t&&(t=r,e.next(r))}})}function ot(){return e=>{let t=new V(1),r=!1;return $(n=>{t.subscribe(n),r||(r=!0,e.subscribe(t))})}}function it(){return e=>{let t,r=0;function n(){--r===0&&t?.signal.next()}return $(o=>{o.signal.subscribe(n),r++===0?(t=ut(),t.subscribe(o),e.subscribe(t)):t.subscribe(o)})}}function st(){return e=>{let t=new D,r,n,o=!1,s=!1;return $(i=>{s?(i.next(n),i.complete()):t.subscribe(i),r??=e.subscribe({next:c=>{o=!0,n=c},error:i.error,complete(){s=!0,o&&t.next(n),t.complete()},signal:i.signal})})}}function le(...e){return e.length===1?e[0]:new l(t=>{let r=e.length;for(let n of e)t.closed||n.subscribe({next:t.next,error:t.error,complete(){r--===1&&t.complete()},signal:t.signal})})}function ct(e){return b(t=>({next:t.next,unsubscribe:e}))}function at(){return z(()=>!1)}var N=new l(e=>e.complete());function $(e){return new l(e)}function ut(){return new M}var oe={catchError:rt,debounceTime:Ke,distinctUntilChanged:nt,exhaustMap:Qe,filter:z,finalize:ct,first:tt,ignoreElements:at,map:_,mergeMap:Xe,publishLast:st,reduce:W,share:it,shareLatest:ot,switchMap:ue,take:Ze,takeWhile:et,tap:Y,throttleTime:Ye};for(let e in oe)l.prototype[e]=function(...t){return this.pipe(oe[e](...t))};import{resolve as mt}from"path";import*as x from"inspector";import{relative as lt}from"path";function ft(e){let t=[];for(let r of e){let n=0,o=0;for(let s of r.functions)for(let i of s.ranges){let c=i.endOffset-i.startOffset;n+=c,i.count&&(o+=c)}t.push({url:r.url,functions:r.functions,blockTotal:n,blockCovered:o})}return t}async function pt(e){let t=process.cwd(),r=[],n=/\/node_modules\//;for(let o of e){let s=o.url.replace(/^file:\/\//,"");if(s.startsWith(t)&&!n.test(s)){let i=lt(t,s);r.push({url:i,functions:o.functions})}}return ft(r)}function fe(e){let t=0,r=e.results.map(o=>(o.success===!1&&t++,{message:o.message,success:o.success,data:o.data,stack:o.stack})),n=(e.only.length?e.only:e.tests).map(o=>{let s=fe(o);return t+=s.failureCount,s});return r.length===0&&e.tests.length===0&&(t++,r.push({success:!1,message:"No assertions found"})),{name:e.name,failureCount:t,results:r,tests:n,runTime:e.runTime,timeout:e.timeout}}async function I(e,t){let r=fe(e),n=t&&await pt(t);return{success:r.failureCount===0,testReport:r,coverage:n}}function F(e,t,r={}){return new Promise((n,o)=>{e.post(t,r,(s,i)=>s?o(s):n(i))})}async function dt(e,t){await F(e,"Profiler.enable"),await F(e,"Profiler.startPreciseCoverage",{detailed:!0});let r=await t(),n=await F(e,"Profiler.takePreciseCoverage");return await F(e,"Profiler.stopPreciseCoverage"),await F(e,"Profiler.disable"),{coverage:n.result,result:r}}async function H(e){async function t(){let s=(await import(o)).default;return s.run().then(()=>s)}let r=e.entryFile,n=new x.Session;e.log(`Runner: Node ${process.version}`);let o=mt(r);if(e.log(`Suite: ${o}`),e.inspect&&(x.open(),console.log(`Waiting for debugger (${x.url()})`),x.waitForDebugger()),n.connect(),e.ignoreCoverage){let s=await t();return I(s)}else{let{result:s,coverage:i}=await dt(n,t);return process.argv.includes("--inspect")&&(console.log("Press any key to continue"),await new Promise(c=>process.stdin.once("data",c))),I(s,i)}}import*as he from"puppeteer";import{readFile as X,writeFile as pe,mkdir as me}from"fs/promises";import{resolve as gt,join as ht,relative as xt}from"path";import{createRequire as wt}from"module";async function yt(e){await Promise.all([e.coverage.startJSCoverage({reportAnonymousScripts:!0})])}async function bt(e,t){let r=e.type(),{url:n,lineNumber:o}=e.location(),s=o!==void 0?` (${o})`:"";t.log(`console ${r}: ${n}${s}`);for(let i of e.args())try{console.log(await i.evaluate(c=>c instanceof Error?{message:c.message,stack:c.stack}:JSON.stringify(c,null,2)))}catch{console.log(i.toString())}}async function $t(e){return await(await e.createBrowserContext()).newPage()}async function vt(e,t,r,n){let o=await $t(t);function s(a){let u=a.type;if(u==="figure")try{return Ct(o,a,e)}catch(f){return{success:!1,message:String(f)||"Unknown Error"}}else{if(u==="hover"||u==="tap"||u==="click")return o.$(a.element).then(f=>{if(!f)throw new Error(`Element for selector "${a.element}" not found.`);return f[u]()}).then(()=>({success:!0,message:"Element"}));if(u==="type"||u==="press")return o.$(a.element).then(f=>{if(!f)throw new Error(`Element for selector "${a.element}" not found.`);return f[u](a.value)}).then(()=>({success:!0,message:"Element"}));if(u==="testElement")return{success:!0,message:"testElement supported"};if(u==="concurrency")return{success:!0,message:"Concurrency",concurrency:n}}return{success:!1,message:`Feature not supported: ${u}`}}o.on("console",a=>bt(a,e)),o.on("pageerror",a=>e.log(a)),o.on("requestfailed",a=>{e.log(`requestfailed: ${a.method()} ${a.url()} ${a.failure()?.errorText}`)}),o.exposeFunction("__cxlRunner",s),await yt(o),e.browserUrl&&await xe(e,o,e.browserUrl),await o.bringToFront();let i=await Et(o,r,e);if(!i)throw new Error("Invalid suite");let c=e.ignoreCoverage?void 0:await St(o,r);return{suite:i,coverage:c}}function xe(e,t,r){return t.goto(r)}async function Et(e,t,r){let n=t[0].path,o=r.vfsRoot??process.cwd(),s=wt(process.cwd());await e.setRequestInterception(!0);function i(c){let a;try{if(a=s.resolve(c.slice(1)),a)return a}catch{}return ht(o,c)}return e.on("request",async c=>{try{let a=new URL(c.url());if(c.method()==="GET"&&a.hostname==="cxl-tester"){let u=i(a.pathname),f=a.pathname==="/"?"":await X(u,"utf8");u.endsWith(".js")&&!t.find(h=>h.source===f)&&t.push({path:u,source:f}),c.respond({status:200,contentType:u.endsWith(".js")?"text/javascript":"text/plain",body:f})}else c.continue()}catch{r.log(`Error handling request ${c.method()} ${c.url()}`),c.respond({status:500})}}),await xe(r,e,"https://cxl-tester"),r.importmap&&await e.addScriptTag({type:"importmap",content:r.importmap}),e.evaluate(`(async entry => {
2
+ const r = (await import(entry)).default;
3
+ await r.run();
4
+ return r.toJSON();
5
+ })('${n}')`)}function K(e,t,r){return{startOffset:e,endOffset:t,count:r}}function kt(e){let t=[],r=0;for(let n of e.ranges)n.start>r&&t.push(K(r,n.start,0)),t.push(K(n.start,n.end,1)),r=n.end;return r<e.text.length&&t.push(K(r,e.text.length,0)),t}async function St(e,t){return(await e.coverage.stopJSCoverage()).map(n=>{let o=t.find(s=>n.text.includes(s.source));return{url:o?.path?gt(o?.path):n.url,functions:[{functionName:"",ranges:kt(n),isBlockCoverage:!0}]}})}var de=Promise.resolve();async function ge(e){let t=(await import("./png-BPHNXF4V.js")).PNG;return new Promise((r,n)=>{new t().parse(Buffer.from(e),(s,i)=>{s?n(s):r(i)})})}function Pt(e,t,r){return new Promise((n,o)=>{let s=`#${t}`;de=de.then(()=>e.$eval(s,(i,c)=>{i.innerHTML=c,i.style.zIndex="10",i.getRootNode()?.activeElement?.blur?.()},r).then(async()=>(await e.waitForNetworkIdle({idleTime:120,timeout:5e3}),await e.waitForFunction("document.fonts?.ready"),await e.mouse.move(350,-100),(await e.$(s))?.screenshot({type:"png",encoding:"binary"}))).then(i=>{ArrayBuffer.isView(i)?n(i):o("Invalid value returned by screenshot()")},i=>o(i)))})}async function Ct(e,t,r){let{name:n,domId:o,html:s}=t,i=t.baseline=`${r.baselinePath||"spec"}/${n}.png`,c=`spec/${n}.png`,[a,u]=await Promise.all([X(i).catch(()=>{}),Pt(e,o,s)]);if(u&&me("spec").catch(()=>!1).then(()=>pe(c,u)),(!a||r.updateBaselines)&&u&&r.baselinePath)me(r.baselinePath).catch(()=>!1).then(()=>pe(i,u));else if(a&&u&&r.baselinePath){let[f,h]=await Promise.all([ge(a),ge(u)]),R=f.data,m=h.data,C=R.length;if(C!==m.length)return{success:!1,message:`Screenshot should match baseline: Different Size (${f.width}x${f.height} vs ${h.width}x${h.height})`,data:t};for(let T=0;T<C;T++)if(R.readUInt8(T)!==m.readUInt8(T))return{success:!1,message:"Screenshot should match baseline",data:t}}return{success:!0,message:"Screenshot should match baseline",data:t}}async function Q(e){let t=e.vfsRoot?`./${xt(e.vfsRoot,e.entryFile)}`:e.entryFile,r=["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--font-render-hinting=none","--disable-font-subpixel-positioning","--animation-duration-scale=0","--force-device-scale-factor=1","--window-size=1280,1024","--disable-infobars","--hide-scrollbars","--blink-settings=imagesEnabled=true","--enable-font-antialiasing","--disable-features=Translate,BackForwardCache,ColorPicker,SharedArrayBuffer,InterestCohort,NotificationIndicator,Prerender2","--disable-background-timer-throttling","--disable-backgrounding-occluded-windows","--disable-renderer-backgrounding","--mute-audio","--disable-extensions"];e.disableSecurity&&r.push("--disable-web-security");let n=await he.launch({headless:!0,args:r,timeout:5e3});try{e.log(`Puppeteer ${await n.version()}`);let o=await X(e.entryFile,"utf8"),s=[{path:t,source:o}],{suite:i,coverage:c}=await vt(e,n,s,0);return I(i,c)}finally{await n.close()}}function we(e){return e.node?H(e):Q(e)}import{spawn as Dt}from"child_process";var ye={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]},g=Object.keys(ye).reduce((e,t)=>{let r=ye[t],n="\x1B["+r[0]+"m",o="\x1B["+r[1]+"m";return e[t]=s=>n+s+o,e},{}),$e='"(?:[^"\\\\]|\\\\.)*"',Bt="-(\\w\\w+)",ve=`\\s*=?\\s*(${$e}|[^-][^\\s]*)?`,Nt=`-(\\w)${ve}`,It=`--(\\w+)${ve}`,Ar=new RegExp(`\\s*(?:${Bt}|${Nt}|${It}|(${$e}|[^\\s]+))`,"g");function be(){return process.hrtime.bigint()}async function Ee(e){let t=be(),r=await(typeof e=="function"?e():e),n=0,o=be(),s={start:t,tasks:++n,time:o-t,result:r};return t=o,s}function ke(e,...t){console.log(typeof e=="string"?e:e(),...t)}function p(e,t={}){return new Promise((r,n)=>{let o=Dt(e,[],{shell:!0,...t}),s="";o.stdout?.on("data",i=>s+=i?.toString()||""),o.stderr?.on("data",i=>s+=i?.toString()||""),o.on("exit",i=>{i!==0?n(s):r(s)})})}function Ft(e,t){let r=t.message;console.error(e,g.red(r)),t.stack&&console.error(t.stack)}function Se(e){let t="",r=e.results.filter(o=>(t+=o.success?g.green("."):g.red("X"),o.success===!1)),n=e.runTime>e.timeout?"brightYellow":e.runTime>e.timeout/2?"yellow":"gray";return console.group(`${e.name} ${g[n](`(${e.runTime.toFixed(2)} ms)`)} ${t}`),r.forEach(o=>Ft(e.name,o)),e.tests.forEach(Se),console.groupEnd(),r}function Rt(e){console.log("Coverage Report:");for(let t of e){let r=(t.blockCovered/t.blockTotal*100).toFixed(2);console.log(`${t.url}: ${r}% (${t.blockTotal}/${t.blockCovered})`)}}function Z(e){e.coverage&&Rt(e.coverage),Se(e.testReport)}import{dirname as zt,relative as Yt,resolve as Ht}from"path";import{existsSync as Kt,utimesSync as Xt,writeFileSync as Qt}from"fs";import{spawn as Zt,execSync as Te}from"child_process";import{createRequire as er}from"module";import{existsSync as Lt,readFileSync as Ne}from"fs";import{join as Gt,resolve as Ot}from"path";import{promises as Tt,readFileSync as Ur}from"fs";import{basename as jt,dirname as qr,resolve as At}from"path";async function Ce(e){let t=await Tt.readFile(e);return{path:e,source:t}}function k(e,t){return v(()=>ae(Ce(e).then(r=>({path:t||At(e),source:r.source}))))}function Wr(e){return Y(t=>t.path=(e||"")+jt(t.path))}function zr(e,t=`
6
+ `){return ie(W((r,n)=>`${r}${t}${n.source}`,""),_(r=>({path:e,source:Buffer.from(r)})))}function Yr(e){return new l(t=>{Promise.all(e.map(Ce)).then(r=>{r.forEach(n=>t.next(n)),t.complete()},r=>t.error(r))})}function De(e,t,r=""){return j(`mkdir -p ${t} && rsync -au -i --delete ${e}/${r} ${t}`)}function Hr(e,t){return Pe(`zip - ${e.join(" ")}`).map(r=>({path:t,source:r}))}import{execSync as Vt}from"child_process";import*as Ie from"esbuild";var Mt=process.cwd(),S=Vt("npm prefix",{cwd:Mt}).toString().trim(),Ut={"GPL-3.0":"license-GPL-3.0.txt","GPL-3.0-only":"license-GPL-3.0.txt","Apache-2.0":"license-Apache-2.0.txt","SEE LICENSE IN LICENSE.md":"",UNLICENSED:""};function Be(e,t,r){for(let n of e)if(!t[n])throw new Error(`Field "${n}" missing in "${r}"`)}function Fe(e){return new l(t=>{Ie.build({minify:!0,bundle:!0,splitting:!0,format:"esm",tsconfig:"tsconfig.json",platform:"browser",define:{CXL_DEBUG:"false"},...e}).then(()=>t.complete())})}function A(e=S){let t=Ot(e,"package.json");if(!Lt(t))throw new Error(`"${t}" not found`);let r=JSON.parse(Ne(t,"utf8"));return Be(["name","version","description"],r,t),r.private||Be(["license"],r,t),r}function Jt(e,t){return q({path:"package.json",source:Buffer.from(JSON.stringify({name:e.name,version:e.version,description:e.description,private:e.private,license:e.license,files:e.files||["*.js","*.d.ts","*.css","LICENSE.md","*.md"],main:t??e.main??"index.js",exports:e.exports,browser:e.browser,homepage:e.homepage,bugs:e.bugs,bin:e.bin,repository:e.repository,dependencies:e.dependencies,peerDependencies:e.peerDependencies,bundledDependencies:e.bundledDependencies,type:e.type},null,2))})}function qt(e){if(e==="UNLICENSED"||e==="SEE LICENSE IN LICENSE.md")return N;let t=Ut[e];if(!t)throw new Error(`Invalid license: "${e}"`);return k(Gt(import.meta.dirname,t),"LICENSE")}function _t(e,t){return`https://npmjs.com/package/${e}/v/${t}`}function Wt(e){try{return Ne(e,"utf8")}catch{return""}}function Re(){return v(()=>{let e=A(S),t=Wt("USAGE.md"),r=encodeURIComponent(e.name);return q({path:"README.md",source:Buffer.from(`# ${e.name}
7
+
8
+ [![npm version](https://badge.fury.io/js/${r}.svg)](https://badge.fury.io/js/${r})
9
+
10
+ ${e.description}
11
+
12
+ ## Project Details
13
+
14
+ - Branch Version: [${e.version}](${_t(e.name,e.version)})
15
+ - License: ${e.license}
16
+ - Documentation: [Link](${e.homepage})
17
+ - Report Issues: [Github](${e.bugs})
18
+
19
+ ## Installation
20
+
21
+ npm install ${e.name}
22
+
23
+ ${t}`)})})}function ee(e){return v(()=>{let t=A(),r=t.license,n=[Jt(t,e)];return r&&n.push(qt(r)),le(...n)})}var tr=g.green("build"),w=ke.bind(null,tr),je=er(import.meta.dirname);function rr(e){return(e/1e3).toFixed(2)+"kb"}function nr(e){let t=Number(e)/1e9,r=t.toFixed(4)+"s";return t>.1?t>.5?g.red(r):g.yellow(r):r}function L(e){return je(je.resolve(e,{paths:[process.cwd(),import.meta.dirname]}))}async function Ae(...e){if(!e)throw new Error("Invalid configuration");S!==process.cwd()&&(process.chdir(S),w(`chdir "${S}"`));let t=A();w(`${t.name} ${t.version}`);let r=[void 0,...process.argv];try{for(let n of r)for(let o of e)o.target===n&&await new te(w,o).build()}catch(n){console.error(n),process.exit(1)}}function j(e,t){return new l(r=>{w(`sh ${e}`),Ee(p(e,t)).then(n=>{w(`sh ${e}`,nr(n.time)),n.result&&console.log(n.result),r.complete()},n=>{r.error(n)})})}function Pe(e,t={}){return new l(r=>{let n=Zt(e,[],{shell:!0,...t}),o,s;n.stdout?.on("data",i=>o=o?Buffer.concat([o,Buffer.from(i)]):Buffer.from(i)),n.stderr?.on("data",i=>s=s?Buffer.concat([s,Buffer.from(i)]):Buffer.from(i)),n.on("close",i=>{i?r.error(s||o):(r.next(o),r.complete())})})}var te=class{log;config;outputDir;constructor(t,r){this.log=t,this.config=r,this.outputDir=r.outputDir||"."}async build(){try{let t=this.config.target||"";t&&this.log(`target ${t}`),Te(`mkdir -p ${this.outputDir}`),await Promise.all(this.config.tasks.map(r=>this.runTask(r)))}catch(t){throw console.log("BUILD: ",t),"Build finished with errors"}}async runTask(t){await t.tap(r=>{let n=Ht(this.outputDir,r.path),o=r.source,s=zt(n);Kt(s)||Te(`mkdir -p ${s}`),Qt(n,o),r.mtime&&Xt(n,r.mtime,r.mtime);let i=Yt(process.cwd(),n);this.log(`${i} ${rr((r.source||"").length)}`)})}};import{relative as or,join as ir}from"path";function sr(e){let t=[],r=!1;if(e.forEach(n=>{let o=n.errorCount,s=or(process.cwd(),n.filePath);w(`eslint ${s}`),o&&(r=!0,n.messages.forEach(i=>console.error(`${s}#${i.line}:${i.column}: ${i.message} (${i.ruleId})`)))}),r)throw new Error("eslint errors found.");return t}function Le(e){return new l(t=>{(async()=>{let{ESLint:r}=L("eslint");w(`eslint ${r.version}`),new r({cache:!0,cwd:process.cwd(),overrideConfigFile:ir(import.meta.dirname,"eslint-config.js"),...e}).lintFiles(["**/*.ts?(x)"]).then(sr).then(()=>t.complete(),o=>t.error(o))})()})}import{relative as cr}from"path";var d=L("typescript"),P=d.sys,ar={useCaseSensitiveFileNames:!0,readDirectory:P.readDirectory,getCurrentDirectory:P.getCurrentDirectory,fileExists:P.fileExists,readFile:P.readFile,onUnRecoverableConfigFileDiagnostic(e){throw e}},ur={getCurrentDirectory:P.getCurrentDirectory,getNewLine:()=>`
24
+ `,getCanonicalFileName:e=>e},yn=d.version;function lr(e){return[...e.getConfigFileParsingDiagnostics(),...e.getOptionsDiagnostics(),...e.getGlobalDiagnostics(),...e.getDeclarationDiagnostics()]}function Ge(e,t=ur){throw console.error(d.formatDiagnosticsWithColorAndContext(e,t)),new Error("Typescript compilation failed")}function fr(e="tsconfig.json",t={module:d.ModuleKind.CommonJS}){let r=d.createSolutionBuilderHost(P),n=mr(e);n.errors?.length&&Ge(n.errors);let o=n.options.outDir;if(!o)throw new Error(`No outDir field set in ${e}`);let s=d.createSolutionBuilder(r,[e],t);return{outputDir:o,builder:s,options:n}}function pr(e="tsconfig.json",t,r={module:d.ModuleKind.CommonJS}){let{outputDir:n,builder:o}=fr(e,r),s,i="";function c(a,u){i&&a.startsWith(i)?(a=cr(n,a),t.next({path:a,source:Buffer.from(u)})):console.warn(`File "${a}" is outside of outDir. Ignoring.`)}for(;s=o.getNextInvalidatedProject();){if(s.kind===d.InvalidatedProjectKind.Build){let u=s.getProgram();if(i=s.getCompilerOptions().outDir??"",u){let f=lr(u);f.length&&Ge(f)}}if(s.done(void 0,c)!==d.ExitStatus.Success)throw`${s.project}: Typescript compilation failed`}}function Oe(e="tsconfig.json",t){return new l(r=>{pr(e,r,t),r.complete()})}function mr(e){let t;try{t=d.getParsedCommandLineOfConfigFile(e,{},ar)}catch(r){if(r instanceof Error)throw r;let n=r?.message||r?.messageText||"Unknown Error";throw new Error(n)}if(!t)throw console.log(process.cwd()),new Error(`Could not parse config file "${e}"`);return t}import{readFile as dr}from"fs/promises";async function Ve(e){return(await p("git rev-parse --abbrev-ref HEAD",{cwd:e})).trim()}async function Me(e){return(await p("git remote show origin",{cwd:e})).match(/HEAD branch:\s+(\S+)/)?.[1]}import{resolve as gr}from"path";async function hr(e){return JSON.parse(await dr(e,"utf8"))}async function xr(e,t){let r=gr(t);try{await p("npm install --production",{cwd:r}),await p("npm test",{cwd:e})}finally{await p(`rm -rf ${r}/node_modules ${r}/package-lock.json`)}}async function Ue(e,t){let r=await Ve(process.cwd()),n=await Me(process.cwd());if(r!==n)throw`Active branch "${r}" is not main branch`;let o=await hr(`${e}/package.json`),s=o.name.split("/")[1],i=await wr(o.name);if(i.versions.includes(o.version))console.log(`Package "${o.name}" version "${o.version}" already published. Skipping.`);else{console.log(`Building ${o.name} ${o.version}`),await p(`npm run build package --prefix ${e}`),await xr(e,t);let a=o.version.includes("beta")?"beta":o.version.includes("alpha")?"alpha":"latest",u=a==="alpha"?i["dist-tags"].alpha:void 0;if(console.log(await p(`npm publish --access=public --tag ${a}`,{cwd:t})),a==="beta"||a==="alpha"){let f=`${o.version.split(".")[0]}-${a}`;console.log(await p(`npm dist-tag add ${o.name}@${o.version} ${f}`))}if(u)try{console.log(await p(`npm unpublish ${o.name}@${u}`))}catch(f){console.error(`Removing old version ${o.name}@${u} failed.`),console.error(f)}}let c=`${s}/${o.version}`;(await p(`git tag -l ${c}`)).trim()||(console.log(`Creating tag "${c}"`),await p(`git tag ${c} && git push origin ${c}`))}async function wr(e){return JSON.parse((await p(`npm show ${e} --json`)).trim())}function Je(e,t={}){for(let r in e)t[r]=`/${r}`;return t}function _n(...e){let t=process.cwd(),n=JSON.parse(ne(t+"/tsconfig.json","utf8"))?.compilerOptions?.outDir,o=yr(n),s=re(n,"package"),i=JSON.parse(ne("package.json","utf8")),c=JSON.parse(ne("../package.json","utf8")),a=!!i.browser,u=i.exports?.["."]??"index.bundle.js",f=i.dependencies?Object.keys(i.dependencies):void 0,h;if(a){let m={};c.devDependencies&&Je(c.devDependencies,m),i.dependencies&&Je(i.dependencies,m),h=JSON.stringify({imports:m})}let R=i.exports?Object.values(i.exports).flatMap(m=>m?[re(n,m)]:[]):[{out:"index.bundle",in:re(n,"index.js")}];return Ae({outputDir:n,tasks:[k("test-screenshot.html","test-screenshot.html").catchError(()=>N),Oe("tsconfig.test.json"),ee("index.js")]},{target:"test",outputDir:n,tasks:[J(async()=>{try{process.chdir(n);let m=await we({node:!a,mjs:!0,vfsRoot:"..",entryFile:"./test.js",importmap:h,log:console.log.bind(console)});Z(m)}finally{process.chdir(t)}}).ignoreElements()]},{target:"docs",outputDir:`../docs/${o}`,tasks:[$(m=>{G({$:[],clean:!0,summary:!0,markdown:!0,cxlExtensions:!0,debug:!0,outputDir:`../docs/${o}`},C=>{m.next({path:C.name,source:Buffer.from(C.content)})}).then(()=>m.complete())})]},{target:"package",outputDir:".",tasks:[Re(),Le(),j(`rm -rf ${s}`)]},{target:"package",outputDir:s,tasks:[k("README.md","README.md"),k("LICENSE.md","LICENSE.md").catchError(()=>N),ee(u),De(n,s,"*.d.ts"),Fe({entryPoints:R,platform:a?"browser":"node",outdir:s,external:f})]},{target:"publish",outputDir:n,tasks:[J(async()=>{await Ue(".",s)}).ignoreElements()]},...e)}export{Fe as a,Re as b,ee as c,Ae as d,j as e,Pe as f,k as g,Wr as h,zr as i,Yr as j,De as k,Hr as l,_n as m};
@@ -0,0 +1,4 @@
1
+ import{existsSync as Be}from"fs";import{dirname as X,join as Ue,resolve as Ke}from"path";import{readFile as Ne,stat as Le,mkdir as Ie}from"fs/promises";import{join as Wt,resolve as Re}from"path";import{spawn as $e}from"child_process";var z={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]},zt=Object.keys(z).reduce((e,t)=>{let r=z[t],i="\x1B["+r[0]+"m",a="\x1B["+r[1]+"m";return e[t]=s=>i+s+a,e},{}),Q='"(?:[^"\\\\]|\\\\.)*"',je="-(\\w\\w+)",Y=`\\s*=?\\s*(${Q}|[^-][^\\s]*)?`,Oe=`-(\\w)${Y}`,Me=`--(\\w+)${Y}`,Qt=new RegExp(`\\s*(?:${je}|${Oe}|${Me}|(${Q}|[^\\s]+))`,"g");async function A(e){await Le(e).catch(()=>A(Re(e,"..")).then(()=>Ie(e)))}async function O(e,t){try{return JSON.parse(await Ne(e,"utf8"))}catch(r){if(t!==void 0)return t;throw r}}function _(e,t={}){return new Promise((r,i)=>{let a=$e(e,[],{shell:!0,...t}),s="";a.stdout?.on("data",c=>s+=c?.toString()||""),a.stderr?.on("data",c=>s+=c?.toString()||""),a.on("exit",c=>{c!==0?i(s):r(s)})})}import{relative as oe,resolve as Ge}from"path";import{createRequire as Je}from"module";var o;(function(e){e[e.Unknown=0]="Unknown",e[e.Variable=1]="Variable",e[e.TypeAlias=2]="TypeAlias",e[e.TypeParameter=3]="TypeParameter",e[e.Interface=4]="Interface",e[e.TypeUnion=5]="TypeUnion",e[e.Reference=6]="Reference",e[e.Module=7]="Module",e[e.Class=8]="Class",e[e.Parameter=9]="Parameter",e[e.Property=10]="Property",e[e.Method=11]="Method",e[e.Getter=12]="Getter",e[e.Setter=13]="Setter",e[e.Constructor=14]="Constructor",e[e.Array=15]="Array",e[e.Function=16]="Function",e[e.FunctionType=17]="FunctionType",e[e.ConditionalType=18]="ConditionalType",e[e.Parenthesized=19]="Parenthesized",e[e.Infer=20]="Infer",e[e.IndexedType=21]="IndexedType",e[e.Enum=22]="Enum",e[e.Literal=23]="Literal",e[e.IndexSignature=24]="IndexSignature",e[e.Export=25]="Export",e[e.Keyof=26]="Keyof",e[e.Typeof=27]="Typeof",e[e.ConstructorType=28]="ConstructorType",e[e.Tuple=29]="Tuple",e[e.ThisType=30]="ThisType",e[e.Constant=31]="Constant",e[e.BaseType=32]="BaseType",e[e.ClassType=33]="ClassType",e[e.ObjectType=34]="ObjectType",e[e.Component=35]="Component",e[e.Attribute=36]="Attribute",e[e.Namespace=37]="Namespace",e[e.CallSignature=38]="CallSignature",e[e.ConstructSignature=39]="ConstructSignature",e[e.MappedType=40]="MappedType",e[e.TypeIntersection=41]="TypeIntersection",e[e.ReadonlyKeyword=42]="ReadonlyKeyword",e[e.UnknownType=43]="UnknownType",e[e.Event=44]="Event",e[e.Spread=45]="Spread",e[e.ImportType=46]="ImportType",e[e.Symbol=47]="Symbol"})(o||(o={}));var p;(function(e){e[e.None=0]="None",e[e.Export=1]="Export",e[e.Ambient=2]="Ambient",e[e.Public=4]="Public",e[e.Private=8]="Private",e[e.Protected=16]="Protected",e[e.Static=32]="Static",e[e.Readonly=64]="Readonly",e[e.Abstract=128]="Abstract",e[e.Async=256]="Async",e[e.Default=512]="Default",e[e.Deprecated=8192]="Deprecated",e[e.Overload=16384]="Overload",e[e.External=32768]="External",e[e.DefaultLibrary=65536]="DefaultLibrary",e[e.DeclarationMerge=131072]="DeclarationMerge",e[e.Rest=262144]="Rest",e[e.Optional=524288]="Optional",e[e.Internal=1048576]="Internal"})(p||(p={}));var le=Je(import.meta.dirname),Ve=le.resolve("typescript",{paths:[".",import.meta.dirname]}),l=le(Ve),{getParsedCommandLineOfConfigFile:He,NodeFlags:Z,sys:N}=l,n=l.SyntaxKind,d=l.TypeFlags,se={[n.Unknown]:o.Unknown,[n.VariableDeclaration]:o.Variable,[n.TypeAliasDeclaration]:o.TypeAlias,[n.TypeParameter]:o.TypeParameter,[n.InterfaceDeclaration]:o.Interface,[n.UnionType]:o.TypeUnion,[n.TypeReference]:o.Reference,[n.SourceFile]:o.Module,[n.ClassDeclaration]:o.Class,[n.Parameter]:o.Parameter,[n.PropertyDeclaration]:o.Property,[n.MethodDeclaration]:o.Method,[n.GetAccessor]:o.Getter,[n.SetAccessor]:o.Setter,[n.Constructor]:o.Constructor,[n.ArrayType]:o.Array,[n.FunctionDeclaration]:o.Function,[n.FunctionType]:o.FunctionType,[n.ConditionalType]:o.ConditionalType,[n.ParenthesizedType]:o.Parenthesized,[n.InferType]:o.Infer,[n.IndexedAccessType]:o.IndexedType,[n.EnumDeclaration]:o.Enum,[n.LiteralType]:o.Literal,[n.TemplateLiteralType]:o.Literal,[n.IndexSignature]:o.IndexSignature,[n.ExportSpecifier]:o.Export,[n.KeyOfKeyword]:o.Keyof,[n.TypeQuery]:o.Typeof,[n.ConstructorType]:o.ConstructorType,[n.TupleType]:o.Tuple,[n.ThisType]:o.ThisType,[n.ModuleDeclaration]:o.Namespace,[n.CallSignature]:o.CallSignature,[n.ConstructSignature]:o.ConstructSignature,[n.MappedType]:o.MappedType,[n.IntersectionType]:o.TypeIntersection,[n.ReadonlyKeyword]:o.ReadonlyKeyword,[n.UnknownKeyword]:o.UnknownType,[n.SpreadAssignment]:o.Spread,[n.ImportType]:o.ImportType,[n.SymbolKeyword]:o.Symbol},ce={exportsOnly:!0,rootDir:void 0,cxlExtensions:!1},pe=v("number"),ue=v("string"),fe=v("boolean"),de=v("undefined"),me=v("null"),ye=v("void"),ge=v("any"),We=v("unknown"),qe=v("BigInt"),he=v("never"),k=Symbol("dtsNode"),ze=l.createPrinter(),Te,g,P,B,u,Qe=1,C,R,h,E,U,K={useCaseSensitiveFileNames:!0,readDirectory:N.readDirectory,getCurrentDirectory:N.getCurrentDirectory,getNewLine:()=>`
2
+ `,fileExists:N.fileExists,getCanonicalFileName:e=>e,readFile:N.readFile,onUnRecoverableConfigFileDiagnostic(e){let t=l.formatDiagnosticsWithColorAndContext([e],K);throw new Error(t)}};function v(e){return{name:e,kind:o.BaseType,flags:0}}function be(e,t){let r;try{r=He(e,{},K)}catch(i){if(i instanceof Error)throw i;let a=typeof i=="string"?i:String(i);throw new Error(a)}if(!r)throw new Error(`Could not parse config file "${e}"`);return r}function Ye(e){switch(e.kind){case n.BindingElement:return e.parent.parent.parent.flags&Z.Const?o.Constant:o.Variable;case n.VariableDeclaration:return e.parent.flags&Z.Const?o.Constant:o.Variable;case n.TypeLiteral:case n.ObjectLiteralExpression:return o.ObjectType;case n.PropertySignature:case n.PropertyAssignment:case n.EnumMember:return o.Property}return se[e.kind]||o.Unknown}function G(e,t){return Qe++}function _e(e){let t=h.packageRoot||process.cwd(),r=e.getSourceFile(),i=r?{name:oe(t,r.fileName),index:e.pos,tsconfig:g.getCompilerOptions().configFilePath}:void 0;return i&&Object.defineProperty(i,"sourceFile",{value:r,enumerable:!1}),i}function J(e){return l.isSourceFile(e)?q(e.fileName):(e.name?e=e.name:e.typeName&&(e=e.typeName),e.escapedText!==void 0?e.escapedText:e.pos!==-1&&l.isStringLiteral(e)?e.getText():l.isTemplateLiteralTypeNode(e)||l.isLiteralTypeNode(e)||l.isLiteralExpression(e)?ze.printNode(l.EmitHint.Unspecified,e,e.getSourceFile()):e.text?e.text:l.isComputedPropertyName(e)||l.isQualifiedName(e)?e.pos===-1?e.text||"":e.getText():e.moduleName||"")}function m(e,t){let r=e[k]||{};r.source??=_e(e),r.kind=t?.kind??r.kind??Ye(e),r.name||=t?.name||J(e),r.flags??=rt(e);let i=lt(e,r);return i&&(r.docs=i),t&&Object.assign(r,t),e[k]=r}function V(e,t){let r=t[k];if(!r){let i=t.getSourceFile();if(!g.isSourceFileDefaultLibrary(i)&&!g.isSourceFileFromExternalLibrary(i)&&i.isDeclarationFile&&e){let a=W(e),s=R[a];if(s?.source)return s}return m(t)}return r.id??=G(t),r}function Xe(e){return e.kind===n.PropertyDeclaration||e.kind===n.MethodDeclaration||e.kind===n.GetAccessor||e.kind===n.SetAccessor||e.kind===n.PropertySignature||e.kind===n.MethodSignature}function f(e){return(Ot[e.kind]||m)(e)}function Ze(e){return e.getText()}function et(e,t){let r=e;if(e.kind===n.ModuleDeclaration)return!1;do{if(r.$$internal)return!0;if(r.$$internal===!1)continue;let i=l.getLeadingCommentRanges(t,r.pos);if(i){for(let a of i)if(t.substring(a.pos,a.end).indexOf("@internal")!==-1)return r.$$internal=!0}}while(r=r.parent);return e.$$internal=!1}function tt(e,t){let r=l.ModifierFlags,i=e.getSourceFile()?.isDeclarationFile,a=0;return(t&r.Export||i||e.kind===n.NamespaceExport)&&(a|=p.Export),t&r.Ambient&&(a|=p.Ambient),t&r.Public&&(a|=p.Public),t&r.Private&&(a|=p.Private),t&r.Protected&&(a|=p.Protected),t&r.Static&&(a|=p.Static),t&r.Readonly&&(a|=p.Readonly),t&r.Abstract&&(a|=p.Abstract),t&r.Async&&(a|=p.Async),t&r.Default&&(a|=p.Default),t&r.Deprecated&&(a|=p.Deprecated),Xe(e)&&(l.isPrivateIdentifier(e.name)?a|=p.Private:a&(p.Private|p.Protected)||(a|=p.Public)),a}function rt(e){let t=0;e.questionToken&&(t|=p.Optional);let r=l.isSourceFile(e)?e:e.getSourceFile();return r&&(et(e,r.getFullText())&&(t|=p.Internal),g.isSourceFileDefaultLibrary(r)&&(t|=p.DefaultLibrary),g.isSourceFileFromExternalLibrary(r)&&(t|=p.External)),t}function H(e){if(e.$$resolvedType)return;let t=u.getWidenedType(e);if(t===e)try{let r=u.typeToTypeNode(t,void 0,l.NodeBuilderFlags.NoTypeReduction|l.NodeBuilderFlags.InTypeAlias|l.NodeBuilderFlags.NoTruncation);return r&&(r.$$resolvedType=!0),r?f(r):void 0}catch(r){console.error(r);return}else t.$$resolvedType=!0;return T(t)}var nt=/<!--(.*?)-->/g;function ee(e){return e.replace(nt,"")}function te(e){if(e)return typeof e=="string"?ee(e):e.map(t=>t.kind===n.JSDocLink?{tag:"link",value:`${t.name?.getText()||""}${t.text}`}:{value:ee(t.text)})}var it=/^\s*\*\s/gm;function at(e){return e.getText().replace(it,"")}function ot(e,t){let r=`
3
+ ${at(t)}`;if(e.length>0){let i=e[e.length-1].value||"";typeof i=="string"?e[e.length-1].value=i+r:i.push({value:r})}else e.push({value:r})}function lt(e,t){let r=e.jsDoc,i=[],a={content:i};return r?.forEach(s=>{let c=te(s.comment);c&&i.push({value:c})}),l.getJSDocTags(e).forEach(s=>{let c=s.tagName.escapedText==="description"?void 0:s.tagName.escapedText,b=s.name?.getText(),w=s.comment?te(s.comment):b;if(h.cxlExtensions&&c==="tagName"){a.tagName=String(w);return}if(s.comment&&c&&!h?.customJsDocTags?.includes(c)&&c!==c.toLowerCase()&&i.length>0){ot(i,s);return}c==="deprecated"&&(t.flags|=p.Deprecated),c==="see"&&s.comment==="*"&&(w=b),c==="beta"&&(a.beta=!0),c==="alpha"&&(a.alpha=!0),h.cxlExtensions&&(c==="attribute"?t.kind=o.Attribute:c==="event"&&(t.kind=o.Event)),w&&!(c==="param"&&e.kind!==n.Parameter)&&i.push({tag:c==="desc"||c==="description"?void 0:c,value:w})}),i.length?a:void 0}function D(e){let t=m(e);t.id===void 0&&(t.id=G(e,t)),t.flags|=tt(e,l.getCombinedModifierFlags(e));let r=t.id,i=e.typeParameters;return i&&(t.typeParameters=i.map(f)),l.isEnumMember(e)?t.value=JSON.stringify(u.getConstantValue(e)):e.initializer&&(t.value=Ze(e.initializer)),r&&(Te[r]=t),t}function st(e){let t=D(e);return e.default&&e.getSourceFile()&&(t.value=e.default.getText()),e.constraint&&(t.children=[f(e.constraint)]),t}function ct(e){return{name:e.name,kind:o.Unknown,flags:0}}function pt(e){let t=e.valueDeclaration;if(!t)return ct(e);let r=y(t);return r.name||(r.name=t.name.getText()),r.flags&(p.Private|p.Public|p.Protected)&&(r.kind=o.Property),t.dotDotDotToken&&(r.flags=r.flags|p.Rest),t.questionToken&&(r.flags=r.flags|p.Optional),r}function L(e,t){let r=e.declarations?.[0]||e.valueDeclaration,i=e.flags&l.SymbolFlags.Namespace||r?.kind===n.EnumMember?ve(e):e.getName();return r?{name:i,flags:0,kind:o.Reference,type:V(e,r),typeParameters:t&&t.length?t.map(T):void 0}:{name:i,flags:0,kind:o.Reference,typeParameters:t&&t.length?t.map(T):void 0}}function ut(e){return e.flags&d.Enum||e.flags&d.EnumLiteral||e.flags&d.UniqueESSymbol||e.isClassOrInterface()||e.isTypeParameter()||e.objectFlags&l.ObjectFlags.Reference}function ft(e){return{name:"",kind:o.IndexedType,flags:0,children:[T(e.objectType),T(e.indexType)]}}function $(e){return e&&(e.declarations?.[0]||e.valueDeclaration)}function xe(e){let t=$(e),r=t?f(t):{name:e.name,kind:o.Unknown,flags:0};return r.kind!==o.Namespace&&(r.name=e.name),r}function dt(e){return{name:u.typeToString(e),kind:o.Keyof,type:T(e.type),resolvedType:H(e),flags:0}}function mt(e,t){return{name:u.typeToString(e),kind:o.Literal,type:t!==e?T(t):void 0,flags:0}}function re(e){let t=u.typeToTypeNode(e,void 0,l.NodeBuilderFlags.InObjectTypeLiteral|l.NodeBuilderFlags.NoTruncation);return t?f(t):{name:u.typeToString(e),kind:o.ObjectType,flags:0}}function yt(e){return u.isArrayType(e)}function T(e){if(e.aliasSymbol)return L(e.aliasSymbol,e.aliasTypeArguments);if(e.flags&d.Any)return ge;if(e.flags&d.Unknown)return We;if(e.flags&d.Void)return ye;if(e.flags&d.Boolean)return fe;if(e.flags&d.BigInt)return qe;if(e.flags&d.Null)return me;if(e.flags&d.Number)return pe;if(e.flags&d.String)return ue;if(e.flags&d.Undefined)return de;if(e.flags&d.Never)return he;if(e.flags&d.Index)return dt(e);if(e.flags&d.IndexedAccess)return ft(e);if(yt(e))return re(e);if(e.symbol?.flags&l.SymbolFlags.Namespace){let t=L(e.symbol);return t.kind=o.ImportType,t}if(ut(e)&&e.symbol)return L(e.symbol,u.getTypeArguments(e));if(e.flags&d.Literal||e.flags&d.TemplateLiteral){let t=u.getBaseTypeOfLiteralType(e);return e.isStringLiteral()||e.isNumberLiteral()||e.isLiteral()||e.flags&d.TemplateLiteral?mt(e,t):T(t)}return e.isUnionOrIntersection()?{name:"",flags:0,kind:e.isUnion()?o.TypeUnion:o.TypeIntersection,children:e.types.map(T)}:e.flags&d.Object?re(e):e.symbol?xe(e.symbol):{name:u.typeToString(e),kind:o.Unknown,flags:0}}function S(e){let t=D(e),r=u.getSignatureFromDeclaration(e);e.kind===n.ArrowFunction||e.kind===n.FunctionExpression?t.kind=o.Function:e.kind===n.MethodSignature&&(t.kind=o.Method),e.type&&(t.type=f(e.type)),e.typeParameters&&(t.typeParameters=e.typeParameters.map(f)),t.parameters=r?r.getParameters().map(pt):e.parameters.map(f);let i=u.getTypeAtLocation(e);if(u.getSignaturesOfType(i,l.SignatureKind.Call)?.length>1&&!u.isImplementationOfOverload(e)&&(t.flags=t.flags|p.Overload),r&&!t.type){let a=r.getReturnType();t.type=a&&T(a)}return t}function gt(e){let t=m(e,{name:"Array"});return t.type=f(e.elementType),t}function Se(e,t){if(!l.canHaveDecorators(e))return;let r=l.getDecorators(e);return r&&r.find(i=>l.isCallExpression(i.expression)&&l.isIdentifier(i.expression.expression)&&i.expression.expression.escapedText.endsWith(t))}function ht(e,t){let r=Se(e,"Attribute");if(r){let i=r.expression.expression.escapedText;t.kind=i==="EventAttribute"?o.Event:o.Attribute}}function Tt(e){let t=e.arguments[0];return l.isStringLiteral(t)?t.text:""}function bt(e){let t=u.getTypeAtLocation(e);for(;t;){let r=t.symbol.valueDeclaration;if(!r||!l.isClassDeclaration(r))return!1;let i=r.heritageClauses?.find(s=>s.token===l.SyntaxKind.ExtendsKeyword)?.types?.[0]?.expression,a=i&&u.getTypeAtLocation(i);if(!a||t===a)break;if(a.symbol?.name==="Component")return!0;t=a}}function xt(e,t,r){let i=Se(e,"Augment"),a=i?.expression?.arguments,s=r.docs||{};if(i||t&&bt(e))r.kind=o.Component;else return!1;if(r.children){let c=r.children.find(b=>b.name==="tagName"&&b.kind===o.Property&&b.flags&p.Static);c&&c.value&&(s.tagName=c.value.slice(1,-1))}return a&&a.forEach((c,b)=>{b===0&&l.isStringLiteral(c)?s.tagName=c.text:l.isCallExpression(c)&&l.isIdentifier(c.expression)&&c.expression.escapedText==="role"&&(s.role=Tt(c))}),(s.tagName||s.role)&&(r.docs=s),!!i}function y(e){let t=D(e);if(l.isVariableDeclaration(e)&&(l.isArrayBindingPattern(e.name)||l.isObjectBindingPattern(e.name))&&(t.children=e.name.elements.map(f)),h.cxlExtensions&&ht(e,t),!t.type){let r=e.type;if(r)t.type=f(r);else if(l.isFunctionDeclaration(e)||l.isMethodDeclaration(e)){let i=u.getSignatureFromDeclaration(e);i&&(t.type=T(i.getReturnType()))}else try{let i=u.getTypeAtLocation(e);i&&(t.type=T(i))}catch(i){console.error(i)}}if(l.isTypeAliasDeclaration(e)){let r=u.getTypeAtLocation(e);t.resolvedType=H(r)}return t}function F(e,t){e.children||=[];for(let r of t)r.parent||(Object.defineProperty(r,"parent",{value:e,enumerable:!1}),e.children.push(r))}function ne(e){let t=m(e);if(!t.children){let r=l.isObjectLiteralExpression(e)?e.properties.map(f):e.members.map(f);F(t,r)}return t}function St(e){let t=$(e),r=t&&De(t);return r?E[r]:void 0}function W(e){if(e.$$fqn)return e.$$fqn;let t=e.getDeclarations()?.[0]?.getSourceFile()?.path;return t?e.$$fqn=`${t}.${e.getName()}`:e.$$fqn=u.getFullyQualifiedName(e)}function vt(e){if(!e)return;if(h.followReferences){let r=St(e);if(r){let i=r.children?.find(a=>a.name===e.name);if(i)return i}}let t=e&&R[W(e)];return t?.source?t:void 0}function M(e){let t=u.getSymbolAtLocation(e)||e.name&&u.getSymbolAtLocation(e.name),r;if(e.kind===n.InterfaceDeclaration&&t&&!(t.flags&l.SymbolFlags.Class)){if(r=t[k],!r&&t.declarations){let i=t.declarations.find(a=>a[k]);i&&(r=D(i))}r??=vt(t),r&&!(r.flags&p.Export)&&l.getCombinedModifierFlags(e)&l.ModifierFlags.Export&&(r.flags|=p.Export),t&&(t[k]??=r)}if(r??=D(e),e.members&&(!r.children||e.kind===n.InterfaceDeclaration)&&F(r,e.members.map(f)),r.children){for(let i of r.children)if(i.kind===o.Constructor&&i.parameters)for(let a of i.parameters)a.kind===o.Property&&F(r,[a])}if(t&&l.isInterfaceDeclaration(e)&&t.flags&l.SymbolFlags.Class){let i=t.declarations?.[0]||t.valueDeclaration;if(r.flags|=p.DeclarationMerge,r.children&&i){let a=V(t,i);a&&F(a,r.children.map(s=>({...s})))}}if(l.isClassDeclaration(e)&&h.cxlExtensions&&xt(e,t,r),e.heritageClauses?.length){let i=r.type={flags:0,kind:o.ClassType,name:"",type:r};if(e.heritageClauses.forEach(a=>F(i,a.types.map(f))),i.children)for(let a of i.children)a.kind===o.Reference&&a.type&&(a.type.extendedBy||(a.type.extendedBy=[])).push({name:r.name,type:r,kind:o.Reference,flags:0})}return r}function kt(e,t){let r=l.ObjectFlags,i=e.objectFlags&r.Interface?n.InterfaceDeclaration:void 0;return i?t.declarations?.find(a=>a.kind===i):t.declarations?.[0]||t.valueDeclaration}function ie(e){let t=u.getTypeFromTypeNode(e),r=t.aliasSymbol||t.symbol;!r&&l.isTypeReferenceNode(e)&&(r=u.getSymbolAtLocation(e.typeName)),r&&r.flags&l.SymbolFlags.Alias&&(r=u.getAliasedSymbol(r)??r);let i=r&&kt(t,r),a=i&&r?V(r,i):e.flags&l.NodeFlags.Synthesized?void 0:T(t),s=J(l.isTypeReferenceNode(e)?e.typeName:e.expression);return a&&!a.name&&(a.name=s),m(e,{name:s,kind:o.Reference,type:a,typeParameters:e.typeArguments?.map(f)})}function Dt(e){return m(e,{children:[f(e.checkType),f(e.extendsType),f(e.trueType),f(e.falseType)]})}function ae(e){let t=S(e);return t.name="constructor",t}function wt(e){return m(e,{children:[f(e.objectType),f(e.indexType)]})}function Et(e){return m(e,{id:G(e),name:"__index",parameters:e.parameters.map(f),type:e.type&&f(e.type)})}function Ft(e){let t=m(e,{kind:se[e.operator],type:f(e.type)}),r=e.flags&l.NodeFlags.Synthesized?void 0:u.getTypeFromTypeNode(e);if(r){let i=r&&T(r);i&&i.kind!==t.kind&&(t.resolvedType=i)}return t}function Pt(e){let t=m(e);return t.name=J(e.exprName),t}function Ct(e){return m(e,{children:e.elements.map(f)})}function At(e){let t=f(e.type);return t.flags|=p.Rest,t}function Nt(e){let t=m(e);if(e.typeParameter){let r=f(e.typeParameter);t.children=[r],r.children?.[0]&&(t.children.push(r.children?.[0]),r.children=void 0)}return e.type&&(t.type=f(e.type)),t}function Lt(e){let t=u.getExportSpecifierLocalTargetSymbol(e);if(t){let r=xe(t);return r.name=e.name.text,r.flags|=p.Export,r.kind===o.Unknown&&(r.kind=o.Export),r}return y(e)}function q(e){let t=h.rootDir??P?.options.rootDir??"";return oe(t,e)}function ve(e){let t=e,r=[e.valueDeclaration?.kind===n.SourceFile&&e.name.startsWith('"')?`"${q(e.name.slice(1,-1))}"`:e.name];for(;t=t.parent;)t.valueDeclaration?.kind!==n.SourceFile&&r.unshift(t.name);return r.join(".")}function It(e,t){let r=t?ve(t):void 0;if(t){if(t.$$moduleResult)return t.$$moduleResult;if(r&&h.followReferences){let a=we(t,e.getSourceFile())||E[r];if(a)return t.$$moduleResult=a}}let i=D(e);return t&&(t.$$moduleResult=i),r&&(h.forceExports?.includes(r)&&(i.flags|=p.Export),i.name=r,E[r]=i),i}function Rt(e,t){if(!e||C.includes(t))return!1;if(h.exportsOnly){let r=e;do{if(r.valueDeclaration?.kind===n.SourceFile)break;let i=r.$$moduleResult;if(!i||!(i.flags&p.Export))return!1}while(r=r.parent)}return!0}function ke(e){let t=u.getSymbolAtLocation(e)||e.name&&u.getSymbolAtLocation(e.name),r=It(e,t);return e.body?.forEachChild(i=>Ee(i,r)),t&&r.flags&p.Export&&Fe(t),Rt(t,r)&&C.push(r),r}function $t(e){let t=u.getSymbolAtLocation(e);if(t){let r=L(t);return r.kind=o.ImportType,r}return m(e,{})}function jt(e){let t=m(e);return t.children=[f(e.expression)],t}var Ot={[n.AnyKeyword]:()=>ge,[n.StringKeyword]:()=>ue,[n.NumberKeyword]:()=>pe,[n.BooleanKeyword]:()=>fe,[n.VoidKeyword]:()=>ye,[n.NeverKeyword]:()=>he,[n.NullKeyword]:()=>me,[n.FunctionType]:S,[n.CallSignature]:S,[n.ConstructSignature]:S,[n.UndefinedKeyword]:()=>de,[n.ArrayType]:gt,[n.FunctionDeclaration]:S,[n.ArrowFunction]:S,[n.FunctionExpression]:S,[n.TypeReference]:ie,[n.ExpressionWithTypeArguments]:ie,[n.ConditionalType]:Dt,[n.ParenthesizedType]:y,[n.InferType](e){return m(e,{type:f(e.typeParameter)})},[n.TypeQuery]:Pt,[n.IndexedAccessType]:wt,[n.IntersectionType](e){return m(e,{kind:o.TypeIntersection,children:e.types.map(f)})},[n.UnionType](e){let t=e.$$resolvedType?void 0:u.getTypeAtLocation(e);return m(e,{kind:o.TypeUnion,children:e.types.map(f),resolvedType:t&&H(t)})},[n.TupleType]:Ct,[n.EnumDeclaration]:M,[n.EnumMember]:y,[n.RestType]:At,[n.PropertySignature]:y,[n.Constructor]:ae,[n.Parameter]:y,[n.PropertyDeclaration]:y,[n.MethodDeclaration]:S,[n.MethodSignature]:S,[n.ClassDeclaration]:M,[n.TypeAliasDeclaration]:y,[n.TypeParameter]:st,[n.InterfaceDeclaration]:M,[n.VariableDeclaration]:y,[n.BindingElement]:y,[n.ConstructorType]:ae,[n.GetAccessor]:S,[n.SetAccessor]:S,[n.TypeOperator]:Ft,[n.TypeLiteral]:ne,[n.TemplateLiteralType]:D,[n.ObjectLiteralExpression]:ne,[n.PropertyAssignment]:y,[n.ShorthandPropertyAssignment]:y,[n.IndexSignature]:Et,[n.MappedType]:Nt,[n.SpreadAssignment]:jt,[n.ModuleDeclaration]:ke,[n.NamespaceExport]:y,[n.NamespaceImport]:y,[n.ExportSpecifier]:Lt,[n.ImportType]:$t,[n.SymbolKeyword]:D};function Mt({options:e,errors:t,fileNames:r,projectReferences:i},a,s){e.noEmit=!0,s||(s=l.createCompilerHost(e)),g=l.createProgram({configFileParsingDiagnostics:t,rootNames:r,projectReferences:i,options:e,host:s}),u=g.getTypeChecker()}function De(e){let t=e.kind===n.SourceFile?e:e.getSourceFile();return t.isDeclarationFile?t.originalFileName:void 0}function Bt(e){let t=g.getResolvedProjectReferences();if(t)return t.find(r=>r?.commandLine.fileNames.includes(e))}function we(e,t){let r=$(e);if(r&&l.isSourceFile(r)&&!B.includes(r))if(r.isDeclarationFile){if(h.followReferences){let i=De(r),a=i&&Bt(i);if(a){Ce(a.commandLine);let s=q(i);return C.find(c=>c.name===s)}}if(t.isDeclarationFile)return I(r)}else return I(r)}function Ee(e,t){function r(i){let a=f(i);(!h.exportsOnly||a.flags&p.Export)&&F(t,[a])}if(l.isVariableStatement(e))e.declarationList.declarations.map(r);else if(l.isExportDeclaration(e)){if(e.exportClause)l.isNamedExports(e.exportClause)?e.exportClause.elements.forEach(r):r(e.exportClause);else if(e.moduleSpecifier){let i=u.getSymbolAtLocation(e.moduleSpecifier);i&&we(i,e.getSourceFile())}}else switch(e.kind){case n.InterfaceDeclaration:case n.TypeAliasDeclaration:case n.FunctionDeclaration:case n.EnumDeclaration:case n.VariableDeclaration:case n.ClassDeclaration:r(e);break;case n.ModuleDeclaration:ke(e)}}function Fe(e){e.exports?.forEach(t=>{let r=$(t);r?.[k]?.source&&!(r[k].flags&p.Internal)&&(R[W(t)]=r[k])})}function I(e){if(E[e.fileName])return E[e.fileName];let t=m(e);if(E[e.fileName]=t,t.flags&p.Internal)return t;e.forEachChild(i=>Ee(i,t));let r=u.getSymbolAtLocation(e);return r&&Fe(r),e.isDeclarationFile&&e.referencedFiles.forEach(i=>{let a=i.fileName;if(P?.fileNames.includes(a))return;let s=g.getSourceFile(a);s&&!g.isSourceFileDefaultLibrary(s)&&!g.isSourceFileFromExternalLibrary(s)&&I(s)}),t.children?.length&&C.push(t),t}function Pe(e){Mt(e),B=e.fileNames.flatMap(t=>g.getSourceFile(t)||[]),B.forEach(I)}function Ce(e){let t=e.options.configFilePath;if(!U.includes(t)){let r=g,i=u;U.push(t),Pe(e),g=r,u=i}}function Ae(e,t){h=t,E={},R={},U=[];let r={modules:C||=[],index:Te||={},config:e,env:{typescript:l.version}};return e.projectReferences?.forEach(i=>{i.prepend&&Ce(be(l.resolveProjectReferencePath(i)))}),Pe(e),r}function Ut(e,t,r){return P=l.parseJsonConfigFileContent(e,K,t),Ae(P,{...ce,...r})}function Kt(e=Ge("tsconfig.json"),t){let r={...ce,...t};return P=be(e,r),Ae(P,r)}var Gt=/[&<"]/g,Jt={"&":"&amp;","<":"&lt;",'"':"&quot;"};function rr(e){return e.replace(Gt,t=>Jt[t])}function nr(e){if(e.startsWith("<caption>")){let t=e.indexOf(`
4
+ `);return{title:e.slice(0,t).trim().replace("</caption>",""),value:e=e.slice(t).trim()}}return{title:"",value:e}}async function ir(e,t){let r={outputDir:"./docs",clean:!1,debug:!1,spa:!1,tsconfig:"tsconfig.json",packageJson:"package.json",packageRoot:"",summary:!1,...e};(r.docsJson||Be("docs.json"))&&Object.assign(r,await O(r.docsJson||"docs.json"));function i(x){return _(`rm -f ${x}/*.html ${x}/*.json ${x}/*.js`)}let a=r.outputDir,s=await O(r.packageJson);if(r.packageRoot??=X(Ke(r.packageJson)),await A(a),await A(a+"/"+s.version),r.clean&&(await i(a),await i(Ue(a,s.version))),r.repository===void 0&&s?.repository){let x=s.repository;r.repository=typeof x=="string"?x:x.url}let c={rootDir:r.rootDir,exportsOnly:!0,customJsDocTags:r.customJsDocTags,cxlExtensions:r.cxlExtensions||!1,forceExports:r.exports,followReferences:r.followReferences},b=r.file?.length?Ut({compilerOptions:{allowJs:!0,rootDir:X(r.file[0]),sourceMap:!1,typeRoots:r.typeRoots||[],noEmit:!0,lib:["es2021"]},files:r.file},process.cwd(),c):Kt(r.tsconfig,c),w={...r,modulePackage:s,repositoryLink:r.repository};if(r.summary){let x=await import("./render-summary-ULILIVXW-MBBMA5KL.js");await Promise.all(x.render(w,b).map(j=>t(j,a)))}if(!r.noHtml){let x=await import("./render-html-WNP2FSL3-HEUQV5A2.js");await Promise.all(x.render(w,b).map(j=>t(j,a)))}}export{o as a,p as b,rr as c,nr as d,ir as e};
@@ -0,0 +1 @@
1
+ var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),o=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0})},l=(a,b,c,f)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&e(a,d,{get:()=>b[d],enumerable:!(f=h(b,d))||f.enumerable});return a};var p=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c,p as d};
package/index.bundle.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as i,b as r,c as o,d as a,e as t,f as m,g as l,h as p,i as b,j as f,k as n,l as d,m as s}from"./chunk-ZYWVDQ3W.js";if(import.meta.main){let{buildLibrary:e}=await import("./library-MSWYOSE7.js");await e()}export{p as basename,a as build,s as buildLibrary,b as concatFile,n as copyDir,i as esbuild,t as exec,l as file,f as files,o as pkg,r as readme,m as shell,d as zip};
2
+ import{a as i,b as r,c as o,d as a,e as t,f as m,g as l,h as p,i as b,j as f,k as n,l as d,m as s}from"./chunk-2QIYZERK.js";import"./chunk-BJVTLF6O.js";import"./chunk-FSRPMVAS.js";if(import.meta.main){let{buildLibrary:e}=await import("./library-STR4IXQL.js");await e()}export{p as basename,a as build,s as buildLibrary,b as concatFile,n as copyDir,i as esbuild,t as exec,l as file,f as files,o as pkg,r as readme,m as shell,d as zip};
@@ -0,0 +1 @@
1
+ import{m as a}from"./chunk-2QIYZERK.js";import"./chunk-BJVTLF6O.js";import"./chunk-FSRPMVAS.js";export{a as buildLibrary};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cxl/build",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "A flexible build system that executes configurable build tasks producing output files, with logging and shell command support.",
5
5
  "license": "GPL-3.0",
6
6
  "files": [
@@ -25,7 +25,8 @@
25
25
  "@eslint/js": "^9.30.1",
26
26
  "esbuild": "*",
27
27
  "typescript": "^5.9.2",
28
- "typescript-eslint": "^8.39.0"
28
+ "typescript-eslint": "^8.39.0",
29
+ "puppeteer": "^24.22.3"
29
30
  },
30
31
  "type": "module"
31
32
  }
@@ -0,0 +1 @@
1
+ import{a as w,b as m}from"./chunk-FSRPMVAS.js";var x=m(($t,$)=>{"use strict";var Ve=w("util"),Q=w("stream"),I=$.exports=function(){Q.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};Ve.inherits(I,Q);I.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))};I.prototype.write=function(e,t){if(!this.writable)return this.emit("error",new Error("Stream not writable")),!1;let i;return Buffer.isBuffer(e)?i=e:i=Buffer.from(e,t||this._encoding),this._buffers.push(i),this._buffered+=i.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused};I.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))};I.prototype.destroySoon=I.prototype.end;I.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("Unexpected end of input")),this.destroy()};I.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))};I.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))};I.prototype._processRead=function(e){this._reads.shift();let t=0,i=0,r=Buffer.alloc(e.length);for(;t<e.length;){let l=this._buffers[i++],n=Math.min(l.length,e.length-t);l.copy(r,t,0,n),t+=n,n!==l.length&&(this._buffers[--i]=l.slice(n))}i>0&&this._buffers.splice(0,i),this._buffered-=e.length,e.func.call(this,r)};I.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit("error",e)}}});var N=m(q=>{"use strict";var A=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];q.getImagePasses=function(e,t){let i=[],r=e%8,l=t%8,n=(e-r)/8,s=(t-l)/8;for(let h=0;h<A.length;h++){let f=A[h],o=n*f.x.length,a=s*f.y.length;for(let u=0;u<f.x.length&&f.x[u]<r;u++)o++;for(let u=0;u<f.y.length&&f.y[u]<l;u++)a++;o>0&&a>0&&i.push({width:o,height:a,index:h})}return i};q.getInterlaceIterator=function(e){return function(t,i,r){let l=t%A[r].x.length,n=(t-l)/A[r].x.length*8+A[r].x[l],s=i%A[r].y.length,h=(i-s)/A[r].y.length*8+A[r].y[s];return n*4+h*e*4}}});var U=m((ei,X)=>{"use strict";X.exports=function(t,i,r){let l=t+i-r,n=Math.abs(l-t),s=Math.abs(l-i),h=Math.abs(l-r);return n<=s&&n<=h?t:s<=h?i:r}});var H=m((ti,te)=>{"use strict";var We=N(),Ke=U();function ee(e,t,i){let r=e*t;return i!==8&&(r=Math.ceil(r/(8/i))),r}var P=te.exports=function(e,t){let i=e.width,r=e.height,l=e.interlace,n=e.bpp,s=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],l){let h=We.getImagePasses(i,r);for(let f=0;f<h.length;f++)this._images.push({byteWidth:ee(h[f].width,n,s),height:h[f].height,lineIndex:0})}else this._images.push({byteWidth:ee(i,n,s),height:r,lineIndex:0});s===8?this._xComparison=n:s===16?this._xComparison=n*2:this._xComparison=1};P.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};P.prototype._unFilterType1=function(e,t,i){let r=this._xComparison,l=r-1;for(let n=0;n<i;n++){let s=e[1+n],h=n>l?t[n-r]:0;t[n]=s+h}};P.prototype._unFilterType2=function(e,t,i){let r=this._lastLine;for(let l=0;l<i;l++){let n=e[1+l],s=r?r[l]:0;t[l]=n+s}};P.prototype._unFilterType3=function(e,t,i){let r=this._xComparison,l=r-1,n=this._lastLine;for(let s=0;s<i;s++){let h=e[1+s],f=n?n[s]:0,o=s>l?t[s-r]:0,a=Math.floor((o+f)/2);t[s]=h+a}};P.prototype._unFilterType4=function(e,t,i){let r=this._xComparison,l=r-1,n=this._lastLine;for(let s=0;s<i;s++){let h=e[1+s],f=n?n[s]:0,o=s>l?t[s-r]:0,a=s>l&&n?n[s-r]:0,u=Ke(o,f,a);t[s]=h+u}};P.prototype._reverseFilterLine=function(e){let t=e[0],i,r=this._images[this._imageIndex],l=r.byteWidth;if(t===0)i=e.slice(1,l+1);else switch(i=Buffer.alloc(l),t){case 1:this._unFilterType1(e,i,l);break;case 2:this._unFilterType2(e,i,l);break;case 3:this._unFilterType3(e,i,l);break;case 4:this._unFilterType4(e,i,l);break;default:throw new Error("Unrecognised filter type - "+t)}this.write(i),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=i,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}});var ne=m((ii,re)=>{"use strict";var Je=w("util"),ie=x(),Qe=H(),$e=re.exports=function(e){ie.call(this);let t=[],i=this;this._filter=new Qe(e,{read:this.read.bind(this),write:function(r){t.push(r)},complete:function(){i.emit("complete",Buffer.concat(t))}}),this._filter.start()};Je.inherits($e,ie)});var S=m((ri,le)=>{"use strict";le.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var G=m((ni,se)=>{"use strict";var D=[];(function(){for(let e=0;e<256;e++){let t=e;for(let i=0;i<8;i++)t&1?t=3988292384^t>>>1:t=t>>>1;D[e]=t}})();var v=se.exports=function(){this._crc=-1};v.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=D[(this._crc^e[t])&255]^this._crc>>>8;return!0};v.prototype.crc32=function(){return this._crc^-1};v.crc32=function(e){let t=-1;for(let i=0;i<e.length;i++)t=D[(t^e[i])&255]^t>>>8;return t^-1}});var F=m((li,he)=>{"use strict";var b=S(),Xe=G(),E=he.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[b.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[b.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[b.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[b.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[b.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[b.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};E.prototype.start=function(){this.read(b.PNG_SIGNATURE.length,this._parseSignature.bind(this))};E.prototype._parseSignature=function(e){let t=b.PNG_SIGNATURE;for(let i=0;i<t.length;i++)if(e[i]!==t[i]){this.error(new Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};E.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),r="";for(let n=4;n<8;n++)r+=String.fromCharCode(e[n]);let l=!!(e[4]&32);if(!this._hasIHDR&&i!==b.TYPE_IHDR){this.error(new Error("Expected IHDR on beggining"));return}if(this._crc=new Xe,this._crc.write(Buffer.from(r)),this._chunks[i])return this._chunks[i](t);if(!l){this.error(new Error("Unsupported critical chunk type "+r));return}this.read(t+4,this._skipChunk.bind(this))};E.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};E.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};E.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),i=this._crc.crc32();if(this._options.checkCRC&&i!==t){this.error(new Error("Crc error - "+t+" - "+i));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))};E.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))};E.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),i=e.readUInt32BE(4),r=e[8],l=e[9],n=e[10],s=e[11],h=e[12];if(r!==8&&r!==4&&r!==2&&r!==1&&r!==16){this.error(new Error("Unsupported bit depth "+r));return}if(!(l in b.COLORTYPE_TO_BPP_MAP)){this.error(new Error("Unsupported color type"));return}if(n!==0){this.error(new Error("Unsupported compression method"));return}if(s!==0){this.error(new Error("Unsupported filter method"));return}if(h!==0&&h!==1){this.error(new Error("Unsupported interlace method"));return}this._colorType=l;let f=b.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:i,depth:r,interlace:!!h,palette:!!(l&b.COLORTYPE_PALETTE),color:!!(l&b.COLORTYPE_COLOR),alpha:!!(l&b.COLORTYPE_ALPHA),bpp:f,colorType:l}),this._handleChunkEnd()};E.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))};E.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let i=0;i<t;i++)this._palette.push([e[i*3],e[i*3+1],e[i*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};E.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))};E.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===b.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(new Error("Transparency chunk must be after palette"));return}if(e.length>this._palette.length){this.error(new Error("More transparent colors than palette size"));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===b.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===b.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()};E.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))};E.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/b.GAMMA_DIVISION),this._handleChunkEnd()};E.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))};E.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===b.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw new Error("Expected palette not found");this.inflateData(t);let i=e-t.length;i>0?this._handleIDAT(i):this._handleChunkEnd()};E.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))};E.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}});var z=m(oe=>{"use strict";var fe=N(),et=[function(){},function(e,t,i,r){if(r===t.length)throw new Error("Ran out of data");let l=t[r];e[i]=l,e[i+1]=l,e[i+2]=l,e[i+3]=255},function(e,t,i,r){if(r+1>=t.length)throw new Error("Ran out of data");let l=t[r];e[i]=l,e[i+1]=l,e[i+2]=l,e[i+3]=t[r+1]},function(e,t,i,r){if(r+2>=t.length)throw new Error("Ran out of data");e[i]=t[r],e[i+1]=t[r+1],e[i+2]=t[r+2],e[i+3]=255},function(e,t,i,r){if(r+3>=t.length)throw new Error("Ran out of data");e[i]=t[r],e[i+1]=t[r+1],e[i+2]=t[r+2],e[i+3]=t[r+3]}],tt=[function(){},function(e,t,i,r){let l=t[0];e[i]=l,e[i+1]=l,e[i+2]=l,e[i+3]=r},function(e,t,i){let r=t[0];e[i]=r,e[i+1]=r,e[i+2]=r,e[i+3]=t[1]},function(e,t,i,r){e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2],e[i+3]=r},function(e,t,i){e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2],e[i+3]=t[3]}];function it(e,t){let i=[],r=0;function l(){if(r===e.length)throw new Error("Ran out of data");let n=e[r];r++;let s,h,f,o,a,u,c,p;switch(t){default:throw new Error("unrecognised depth");case 16:c=e[r],r++,i.push((n<<8)+c);break;case 4:c=n&15,p=n>>4,i.push(p,c);break;case 2:a=n&3,u=n>>2&3,c=n>>4&3,p=n>>6&3,i.push(p,c,u,a);break;case 1:s=n&1,h=n>>1&1,f=n>>2&1,o=n>>3&1,a=n>>4&1,u=n>>5&1,c=n>>6&1,p=n>>7&1,i.push(p,c,u,a,o,f,h,s);break}}return{get:function(n){for(;i.length<n;)l();let s=i.slice(0,n);return i=i.slice(n),s},resetAfterLine:function(){i.length=0},end:function(){if(r!==e.length)throw new Error("extra data found")}}}function rt(e,t,i,r,l,n){let s=e.width,h=e.height,f=e.index;for(let o=0;o<h;o++)for(let a=0;a<s;a++){let u=i(a,o,f);et[r](t,l,u,n),n+=r}return n}function nt(e,t,i,r,l,n){let s=e.width,h=e.height,f=e.index;for(let o=0;o<h;o++){for(let a=0;a<s;a++){let u=l.get(r),c=i(a,o,f);tt[r](t,u,c,n)}l.resetAfterLine()}}oe.dataToBitMap=function(e,t){let i=t.width,r=t.height,l=t.depth,n=t.bpp,s=t.interlace,h;l!==8&&(h=it(e,l));let f;l<=8?f=Buffer.alloc(i*r*4):f=new Uint16Array(i*r*4);let o=Math.pow(2,l)-1,a=0,u,c;if(s)u=fe.getImagePasses(i,r),c=fe.getInterlaceIterator(i,r);else{let p=0;c=function(){let d=p;return p+=4,d},u=[{width:i,height:r}]}for(let p=0;p<u.length;p++)l===8?a=rt(u[p],f,c,n,e,a):nt(u[p],f,c,n,h,o);if(l===8){if(a!==e.length)throw new Error("extra data found")}else h.end();return f}});var j=m((hi,ae)=>{"use strict";function lt(e,t,i,r,l){let n=0;for(let s=0;s<r;s++)for(let h=0;h<i;h++){let f=l[e[n]];if(!f)throw new Error("index "+e[n]+" not in palette");for(let o=0;o<4;o++)t[n+o]=f[o];n+=4}}function st(e,t,i,r,l){let n=0;for(let s=0;s<r;s++)for(let h=0;h<i;h++){let f=!1;if(l.length===1?l[0]===e[n]&&(f=!0):l[0]===e[n]&&l[1]===e[n+1]&&l[2]===e[n+2]&&(f=!0),f)for(let o=0;o<4;o++)t[n+o]=0;n+=4}}function ht(e,t,i,r,l){let n=255,s=Math.pow(2,l)-1,h=0;for(let f=0;f<r;f++)for(let o=0;o<i;o++){for(let a=0;a<4;a++)t[h+a]=Math.floor(e[h+a]*n/s+.5);h+=4}}ae.exports=function(e,t,i=!1){let r=t.depth,l=t.width,n=t.height,s=t.colorType,h=t.transColor,f=t.palette,o=e;return s===3?lt(e,o,l,n,f):(h&&st(e,o,l,n,h),r!==8&&!i&&(r===16&&(o=Buffer.alloc(l*n*4)),ht(e,o,l,n,r))),o}});var _e=m((fi,ce)=>{"use strict";var ft=w("util"),Z=w("zlib"),ue=x(),ot=ne(),at=F(),ut=z(),ct=j(),k=ce.exports=function(e){ue.call(this),this._parser=new at(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};ft.inherits(k,ue);k.prototype._handleError=function(e){this.emit("error",e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0};k.prototype._inflateData=function(e){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=Z.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let i=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,r=Math.max(i,Z.Z_MIN_CHUNK);this._inflate=Z.createInflate({chunkSize:r});let l=i,n=this.emit.bind(this,"error");this._inflate.on("error",function(h){l&&n(h)}),this._filter.on("complete",this._complete.bind(this));let s=this._filter.write.bind(this._filter);this._inflate.on("data",function(h){l&&(h.length>l&&(h=h.slice(0,l)),l-=h.length,s(h))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(e)};k.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new ot(this._bitmapInfo)};k.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e};k.prototype._handlePalette=function(e){this._bitmapInfo.palette=e};k.prototype._simpleTransparency=function(){this._metaData.alpha=!0};k.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};k.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))};k.prototype._complete=function(e){if(this.errord)return;let t;try{let i=ut.dataToBitMap(e,this._bitmapInfo);t=ct(i,this._bitmapInfo,this._options.skipRescale),i=null}catch(i){this._handleError(i);return}this.emit("parsed",t)}});var de=m((oi,pe)=>{"use strict";var L=S();pe.exports=function(e,t,i,r){let l=[L.COLORTYPE_COLOR_ALPHA,L.COLORTYPE_ALPHA].indexOf(r.colorType)!==-1;if(r.colorType===r.inputColorType){let d=(function(){let y=new ArrayBuffer(2);return new DataView(y).setInt16(0,256,!0),new Int16Array(y)[0]!==256})();if(r.bitDepth===8||r.bitDepth===16&&d)return e}let n=r.bitDepth!==16?e:new Uint16Array(e.buffer),s=255,h=L.COLORTYPE_TO_BPP_MAP[r.inputColorType];h===4&&!r.inputHasAlpha&&(h=3);let f=L.COLORTYPE_TO_BPP_MAP[r.colorType];r.bitDepth===16&&(s=65535,f*=2);let o=Buffer.alloc(t*i*f),a=0,u=0,c=r.bgColor||{};c.red===void 0&&(c.red=s),c.green===void 0&&(c.green=s),c.blue===void 0&&(c.blue=s);function p(){let d,y,_,g=s;switch(r.inputColorType){case L.COLORTYPE_COLOR_ALPHA:g=n[a+3],d=n[a],y=n[a+1],_=n[a+2];break;case L.COLORTYPE_COLOR:d=n[a],y=n[a+1],_=n[a+2];break;case L.COLORTYPE_ALPHA:g=n[a+1],d=n[a],y=d,_=d;break;case L.COLORTYPE_GRAYSCALE:d=n[a],y=d,_=d;break;default:throw new Error("input color type:"+r.inputColorType+" is not supported at present")}return r.inputHasAlpha&&(l||(g/=s,d=Math.min(Math.max(Math.round((1-g)*c.red+g*d),0),s),y=Math.min(Math.max(Math.round((1-g)*c.green+g*y),0),s),_=Math.min(Math.max(Math.round((1-g)*c.blue+g*_),0),s))),{red:d,green:y,blue:_,alpha:g}}for(let d=0;d<i;d++)for(let y=0;y<t;y++){let _=p(n,a);switch(r.colorType){case L.COLORTYPE_COLOR_ALPHA:case L.COLORTYPE_COLOR:r.bitDepth===8?(o[u]=_.red,o[u+1]=_.green,o[u+2]=_.blue,l&&(o[u+3]=_.alpha)):(o.writeUInt16BE(_.red,u),o.writeUInt16BE(_.green,u+2),o.writeUInt16BE(_.blue,u+4),l&&o.writeUInt16BE(_.alpha,u+6));break;case L.COLORTYPE_ALPHA:case L.COLORTYPE_GRAYSCALE:{let g=(_.red+_.green+_.blue)/3;r.bitDepth===8?(o[u]=g,l&&(o[u+1]=_.alpha)):(o.writeUInt16BE(g,u),l&&o.writeUInt16BE(_.alpha,u+2));break}default:throw new Error("unrecognised color Type "+r.colorType)}a+=h,u+=f}return o}});var me=m((ai,ye)=>{"use strict";var ge=U();function _t(e,t,i,r,l){for(let n=0;n<i;n++)r[l+n]=e[t+n]}function pt(e,t,i){let r=0,l=t+i;for(let n=t;n<l;n++)r+=Math.abs(e[n]);return r}function dt(e,t,i,r,l,n){for(let s=0;s<i;s++){let h=s>=n?e[t+s-n]:0,f=e[t+s]-h;r[l+s]=f}}function gt(e,t,i,r){let l=0;for(let n=0;n<i;n++){let s=n>=r?e[t+n-r]:0,h=e[t+n]-s;l+=Math.abs(h)}return l}function yt(e,t,i,r,l){for(let n=0;n<i;n++){let s=t>0?e[t+n-i]:0,h=e[t+n]-s;r[l+n]=h}}function mt(e,t,i){let r=0,l=t+i;for(let n=t;n<l;n++){let s=t>0?e[n-i]:0,h=e[n]-s;r+=Math.abs(h)}return r}function bt(e,t,i,r,l,n){for(let s=0;s<i;s++){let h=s>=n?e[t+s-n]:0,f=t>0?e[t+s-i]:0,o=e[t+s]-(h+f>>1);r[l+s]=o}}function Et(e,t,i,r){let l=0;for(let n=0;n<i;n++){let s=n>=r?e[t+n-r]:0,h=t>0?e[t+n-i]:0,f=e[t+n]-(s+h>>1);l+=Math.abs(f)}return l}function wt(e,t,i,r,l,n){for(let s=0;s<i;s++){let h=s>=n?e[t+s-n]:0,f=t>0?e[t+s-i]:0,o=t>0&&s>=n?e[t+s-(i+n)]:0,a=e[t+s]-ge(h,f,o);r[l+s]=a}}function Tt(e,t,i,r){let l=0;for(let n=0;n<i;n++){let s=n>=r?e[t+n-r]:0,h=t>0?e[t+n-i]:0,f=t>0&&n>=r?e[t+n-(i+r)]:0,o=e[t+n]-ge(s,h,f);l+=Math.abs(o)}return l}var Ct={0:_t,1:dt,2:yt,3:bt,4:wt},Ot={0:pt,1:gt,2:mt,3:Et,4:Tt};ye.exports=function(e,t,i,r,l){let n;if(!("filterType"in r)||r.filterType===-1)n=[0,1,2,3,4];else if(typeof r.filterType=="number")n=[r.filterType];else throw new Error("unrecognised filter types");r.bitDepth===16&&(l*=2);let s=t*l,h=0,f=0,o=Buffer.alloc((s+1)*i),a=n[0];for(let u=0;u<i;u++){if(n.length>1){let c=1/0;for(let p=0;p<n.length;p++){let d=Ot[n[p]](e,f,s,l);d<c&&(a=n[p],c=d)}}o[h]=a,h++,Ct[a](e,f,s,o,h,l),h+=s,f+=s}return o}});var V=m((ui,be)=>{"use strict";var T=S(),Lt=G(),It=de(),kt=me(),At=w("zlib"),R=be.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32*1024,e.deflateLevel=e.deflateLevel!=null?e.deflateLevel:9,e.deflateStrategy=e.deflateStrategy!=null?e.deflateStrategy:3,e.inputHasAlpha=e.inputHasAlpha!=null?e.inputHasAlpha:!0,e.deflateFactory=e.deflateFactory||At.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType=="number"?e.colorType:T.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType=="number"?e.inputColorType:T.COLORTYPE_COLOR_ALPHA,[T.COLORTYPE_GRAYSCALE,T.COLORTYPE_COLOR,T.COLORTYPE_COLOR_ALPHA,T.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw new Error("option color type:"+e.colorType+" is not supported at present");if([T.COLORTYPE_GRAYSCALE,T.COLORTYPE_COLOR,T.COLORTYPE_COLOR_ALPHA,T.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw new Error("option input color type:"+e.inputColorType+" is not supported at present");if(e.bitDepth!==8&&e.bitDepth!==16)throw new Error("option bit depth:"+e.bitDepth+" is not supported at present")};R.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};R.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};R.prototype.filterData=function(e,t,i){let r=It(e,t,i,this._options),l=T.COLORTYPE_TO_BPP_MAP[this._options.colorType];return kt(r,t,i,this._options,l)};R.prototype._packChunk=function(e,t){let i=t?t.length:0,r=Buffer.alloc(i+12);return r.writeUInt32BE(i,0),r.writeUInt32BE(e,4),t&&t.copy(r,8),r.writeInt32BE(Lt.crc32(r.slice(4,r.length-4)),r.length-4),r};R.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*T.GAMMA_DIVISION),0),this._packChunk(T.TYPE_gAMA,t)};R.prototype.packIHDR=function(e,t){let i=Buffer.alloc(13);return i.writeUInt32BE(e,0),i.writeUInt32BE(t,4),i[8]=this._options.bitDepth,i[9]=this._options.colorType,i[10]=0,i[11]=0,i[12]=0,this._packChunk(T.TYPE_IHDR,i)};R.prototype.packIDAT=function(e){return this._packChunk(T.TYPE_IDAT,e)};R.prototype.packIEND=function(){return this._packChunk(T.TYPE_IEND,null)}});var Ce=m((ci,Te)=>{"use strict";var Rt=w("util"),Ee=w("stream"),Bt=S(),Pt=V(),we=Te.exports=function(e){Ee.call(this);let t=e||{};this._packer=new Pt(t),this._deflate=this._packer.createDeflate(),this.readable=!0};Rt.inherits(we,Ee);we.prototype.pack=function(e,t,i,r){this.emit("data",Buffer.from(Bt.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(t,i)),r&&this.emit("data",this._packer.packGAMA(r));let l=this._packer.filterData(e,t,i);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(n){this.emit("data",this._packer.packIDAT(n))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(l)}});var Re=m((Y,Ae)=>{"use strict";var Oe=w("assert").ok,M=w("zlib"),St=w("util"),Le=w("buffer").kMaxLength;function B(e){if(!(this instanceof B))return new B(e);e&&e.chunkSize<M.Z_MIN_CHUNK&&(e.chunkSize=M.Z_MIN_CHUNK),M.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function Mt(e){return new B(e)}function Ie(e,t){t&&process.nextTick(t),e._handle&&(e._handle.close(),e._handle=null)}B.prototype._processChunk=function(e,t,i){if(typeof i=="function")return M.Inflate._processChunk.call(this,e,t,i);let r=this,l=e&&e.length,n=this._chunkSize-this._offset,s=this._maxLength,h=0,f=[],o=0,a;this.on("error",function(d){a=d});function u(d,y){if(r._hadError)return;let _=n-y;if(Oe(_>=0,"have should not go down"),_>0){let g=r._buffer.slice(r._offset,r._offset+_);if(r._offset+=_,g.length>s&&(g=g.slice(0,s)),f.push(g),o+=g.length,s-=g.length,s===0)return!1}return(y===0||r._offset>=r._chunkSize)&&(n=r._chunkSize,r._offset=0,r._buffer=Buffer.allocUnsafe(r._chunkSize)),y===0?(h+=l-d,l=d,!0):!1}Oe(this._handle,"zlib binding closed");let c;do c=this._handle.writeSync(t,e,h,l,this._buffer,this._offset,n),c=c||this._writeState;while(!this._hadError&&u(c[0],c[1]));if(this._hadError)throw a;if(o>=Le)throw Ie(this),new RangeError("Cannot create final Buffer. It would be larger than 0x"+Le.toString(16)+" bytes");let p=Buffer.concat(f,o);return Ie(this),p};St.inherits(B,M.Inflate);function Yt(e,t){if(typeof t=="string"&&(t=Buffer.from(t)),!(t instanceof Buffer))throw new TypeError("Not a string or buffer");let i=e._finishFlushFlag;return i==null&&(i=M.Z_FINISH),e._processChunk(t,i)}function ke(e,t){return Yt(new B(t),e)}Ae.exports=Y=ke;Y.Inflate=B;Y.createInflate=Mt;Y.inflateSync=ke});var W=m((_i,Pe)=>{"use strict";var Be=Pe.exports=function(e){this._buffer=e,this._reads=[]};Be.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})};Be.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw new Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw new Error("unrecognised content at end of stream")}});var Me=m(Se=>{"use strict";var xt=W(),qt=H();Se.process=function(e,t){let i=[],r=new xt(e);return new qt(t,{read:r.read.bind(r),write:function(n){i.push(n)},complete:function(){}}).start(),r.process(),Buffer.concat(i)}});var Ne=m((di,qe)=>{"use strict";var Ye=!0,xe=w("zlib"),Nt=Re();xe.deflateSync||(Ye=!1);var Ut=W(),Ht=Me(),Dt=F(),vt=z(),Gt=j();qe.exports=function(e,t){if(!Ye)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let i;function r(O){i=O}let l;function n(O){l=O}function s(O){l.transColor=O}function h(O){l.palette=O}function f(){l.alpha=!0}let o;function a(O){o=O}let u=[];function c(O){u.push(O)}let p=new Ut(e);if(new Dt(t,{read:p.read.bind(p),error:r,metadata:n,gamma:a,palette:h,transColor:s,inflateData:c,simpleTransparency:f}).start(),p.process(),i)throw i;let y=Buffer.concat(u);u.length=0;let _;if(l.interlace)_=xe.inflateSync(y);else{let J=((l.width*l.bpp*l.depth+7>>3)+1)*l.height;_=Nt(y,{chunkSize:J,maxLength:J})}if(y=null,!_||!_.length)throw new Error("bad png - invalid inflate data response");let g=Ht.process(_,l);y=null;let je=vt.dataToBitMap(g,l);g=null;let Ze=Gt(je,l,t.skipRescale);return l.data=Ze,l.gamma=o||0,l}});var ve=m((gi,De)=>{"use strict";var Ue=!0,He=w("zlib");He.deflateSync||(Ue=!1);var Ft=S(),zt=V();De.exports=function(e,t){if(!Ue)throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let i=t||{},r=new zt(i),l=[];l.push(Buffer.from(Ft.PNG_SIGNATURE)),l.push(r.packIHDR(e.width,e.height)),e.gamma&&l.push(r.packGAMA(e.gamma));let n=r.filterData(e.data,e.width,e.height),s=He.deflateSync(n,r.getDeflateOptions());if(n=null,!s||!s.length)throw new Error("bad png - invalid compressed data response");return l.push(r.packIDAT(s)),l.push(r.packIEND()),Buffer.concat(l)}});var Ge=m(K=>{"use strict";var jt=Ne(),Zt=ve();K.read=function(e,t){return jt(e,t||{})};K.write=function(e,t){return Zt(e,t)}});var Qt=m(ze=>{var Vt=w("util"),Fe=w("stream"),Wt=_e(),Kt=Ce(),Jt=Ge(),C=ze.PNG=function(e){Fe.call(this),e=e||{},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new Wt(e),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new Kt(e),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};Vt.inherits(C,Fe);C.sync=Jt;C.prototype.pack=function(){return!this.data||!this.data.length?(this.emit("error","No data provided"),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)};C.prototype.parse=function(e,t){if(t){let i,r;i=function(l){this.removeListener("error",r),this.data=l,t(null,this)}.bind(this),r=function(l){this.removeListener("parsed",i),t(l,null)}.bind(this),this.once("parsed",i),this.once("error",r)}return this.end(e),this};C.prototype.write=function(e){return this._parser.write(e),!0};C.prototype.end=function(e){this._parser.end(e)};C.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit("metadata",e)};C.prototype._gamma=function(e){this.gamma=e};C.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit("close")};C.bitblt=function(e,t,i,r,l,n,s,h){if(i|=0,r|=0,l|=0,n|=0,s|=0,h|=0,i>e.width||r>e.height||i+l>e.width||r+n>e.height)throw new Error("bitblt reading outside image");if(s>t.width||h>t.height||s+l>t.width||h+n>t.height)throw new Error("bitblt writing outside image");for(let f=0;f<n;f++)e.data.copy(t.data,(h+f)*t.width+s<<2,(r+f)*e.width+i<<2,(r+f)*e.width+i+l<<2)};C.prototype.bitblt=function(e,t,i,r,l,n,s){return C.bitblt(this,e,t,i,r,l,n,s),this};C.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let i=0;i<e.width;i++){let r=e.width*t+i<<2;for(let l=0;l<3;l++){let n=e.data[r+l]/255;n=Math.pow(n,1/2.2/e.gamma),e.data[r+l]=Math.round(n*255)}}e.gamma=0}};C.prototype.adjustGamma=function(){C.adjustGamma(this)}});export default Qt();