pkgroll 2.25.0 → 2.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +2 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -20,7 +20,7 @@ var Mn=Object.defineProperty;var l=(e,t)=>Mn(e,"name",{value:t,configurable:!0})
|
|
|
20
20
|
`:"")+(u?this.indentText({text:this.render(u),spaces:n}):"")}
|
|
21
21
|
`}table({tableData:t,tableOptions:u,tableBreakpoints:n}){return qu(t.map(r=>r.map(s=>this.render(s))),n?Gu(n):u)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:u,flagFormatted:n,aliasesEnabled:r,aliasFormatted:s}=t;let o="";if(s?o+=`${s}, `:r&&(o+=" "),o+=n,"placeholder"in u&&typeof u.placeholder=="string")o+=`${this.flagOperator(t)}${u.placeholder}`;else{const i=this.flagParameter("type"in u?u.type:u);i&&(o+=`${this.flagOperator(t)}${i}`)}return o}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let u="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(u+=` (default: ${this.flagDefault(n)})`)}return u}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(u=>this.render(u)).join(`
|
|
22
22
|
`);if("type"in t&&this[t.type]){const u=this[t.type];if(typeof u=="function")return u.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Oe=A(e=>e.length>0&&!e.includes(" "),"isValidScriptName"),{stringify:L}=JSON,nr=/[|\\{}()[\]^$+*?.]/;function le(e){const t=[];let u,n;for(const r of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${L(n)} must be last`);const s=r[0],o=r.at(-1);let i;if(s==="<"&&o===">"&&(i=!0,u))throw new Error(`Invalid parameter: Required parameter ${L(r)} cannot come after optional parameter ${L(u)}`);if(s==="["&&o==="]"&&(i=!1,u=r),i===void 0)throw new Error(`Invalid parameter: ${L(r)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=r.slice(1,-1);const c=a.slice(-3)==="...";c&&(n=r,a=a.slice(0,-3));const D=a.match(nr);if(D)throw new Error(`Invalid parameter: ${L(r)}. Invalid character found ${L(D[0])}`);t.push({name:a,required:i,spread:c})}return t}l(le,"b"),A(le,"parseParameters");function ce(e,t,u,n){for(let r=0;r<t.length;r+=1){const{name:s,required:o,spread:i}=t[r],a=Yu(s);if(a in e)throw new Error(`Invalid parameter: ${L(s)} is used more than once.`);const c=i?u.slice(r):u[r];if(i&&(r=t.length),o&&(!c||i&&c.length===0))return console.error(`Error: Missing required parameter ${L(s)}
|
|
23
|
-
`),n(),process.exit(1);e[a]=c}}l(ce,"v$1"),A(ce,"mapParametersToArguments");function Mt(e){return e===void 0||e!==!1}l(Mt,"G$1"),A(Mt,"helpEnabled");function Te(e,t,u,n){const r={...t.flags},s=t.version&&!("version"in r);s&&(r.version={type:Boolean,description:"Show version"});const{help:o}=t,i=Mt(o);i&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const a=bu(r,n,{ignore:t.ignoreArgv}),c=A(()=>{console.log(t.version)},"showVersion");if(s&&a.flags.version===!0)return c(),process.exit(0);const D=new tr,F=i&&o?.render?o.render:g=>D.render(g),f=A(g=>{const B=Xu({...t,...g?{help:g}:{},flags:r});console.log(F(B,D))},"showHelp");if(i&&a.flags.help===!0)return f(),process.exit(0);if(t.parameters){let{parameters:g}=t,B=a._;const S=g.indexOf("--"),$=g.slice(S+1),d=Object.create(null);if(S>-1&&$.length>0){g=g.slice(0,S);const b=a._["--"];B=B.slice(0,-b.length||void 0),ce(d,le(g),B,f),ce(d,le($),b,f)}else ce(d,le(g),B,f);Object.assign(a._,d)}const p={...a,showVersion:c,showHelp:f},C={command:e,...p};if(typeof u=="function"){const g=u(p);if(g&&"then"in g)return Object.assign(Promise.resolve(g),C)}return C}l(Te,"j"),A(Te,"cliBase");function Ut(e,t){const u=new Map;for(const n of t){const r=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?r.push(...s):r.push(s));for(const o of r){if(u.has(o))throw new Error(`Duplicate command name found: ${L(o)}`);u.set(o,n)}}return u.get(e)}l(Ut,"K$1"),A(Ut,"getCommand");function Vt(e,t,u=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Oe(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const n=u[0];if(e.commands&&n&&Oe(n)){const r=Ut(n,e.commands);if(r)return Te(r.options.name,{...r.options,parent:e},r.callback,u.slice(1))}return Te(void 0,e,t,u)}l(Vt,"Q$1"),A(Vt,"cli");function ur(e,t){if(!e)throw new Error("Command options are required");const{name:u}=e;if(u===void 0)throw new Error("Command name is required");if(!Oe(u))throw new Error(`Invalid command name ${JSON.stringify(u)}. Command names must be one word.`);return{options:e,callback:t}}l(ur,"X$1"),A(ur,"command");var rr="2.25.0";const M=l(e=>_.promises.access(e).then(()=>!0,()=>!1),"fsExists");let V=!0;const J=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let X=0;if(J.process&&J.process.env&&J.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:u,TERM:n,COLORTERM:r}=J.process.env;t||u||e==="0"?V=!1:e==="1"||e==="2"||e==="3"?V=!0:n==="dumb"?V=!1:"CI"in J.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(s=>s in J.process.env)?V=!0:V=process.stdout.isTTY,V&&(process.platform==="win32"||r&&(r==="truecolor"||r==="24bit")?X=3:n&&(n.endsWith("-256color")||n.endsWith("256"))?X=2:X=1)}let zt={enabled:V,supportLevel:X};function sr(e,t,u=1){const n=`\x1B[${e}m`,r=`\x1B[${t}m`,s=new RegExp(`\\x1b\\[${t}m`,"g");return o=>zt.enabled&&zt.supportLevel>=u?n+(""+o).replace(s,n)+r:""+o}l(sr,"kolorist");const or=sr(2,22),De=l(e=>e.replaceAll("\\","/"),"slash"),T=l((e,t)=>(!m.isAbsolute(e)&&!e.startsWith(".")&&!e.startsWith("/")&&(e=`./${e}`),t&&!e.endsWith("/")&&(e+="/"),e),"normalizePath"),ir=l(()=>new Date().toLocaleTimeString(),"currentTime"),K=l((...e)=>console.log(or(ir()),...e),"log"),ar=process.cwd(),fe=l(e=>T(m.relative(ar,e)),"formatPath"),lr=l(async e=>{const t=await P.readFile(e,"utf8");try{return Zn(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageYaml"),qt=l(async e=>{const t=await P.readFile(e,"utf8");try{return JSON.parse(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageJson"),cr=l(async e=>{const t=m.join(e,"package.yaml");if(await M(t))return{packageJson:await lr(t),packageJsonPath:t};const u=m.join(e,"package.json");if(await M(u))return{packageJson:await qt(u),packageJsonPath:u};throw new Error(`package.json not found at: ${u} (also checked for package.yaml)`)},"readPackage"),Dr=l(e=>{let t=!1;if(e.includes("=")){const[u,n]=e.split("=");e=n,t=u==="bin"||u==="binary"}return{type:"legacy",source:"cli",outputPath:T(e),isExecutable:t}},"parseCliInputFlag"),fr=l(({imports:e},t)=>{const u={};if(e)for(const n in e){if(n.startsWith("#"))continue;const r=e[n];typeof r=="string"&&(u[n]=m.join(t,r))}return u},"getAliases"),dr=l(e=>{const{publishConfig:t}=e;if(!t)return;const u=["bin","main","exports","types","module"];for(const n of u)t[n]&&(e[n]=t[n])},"applyPublishConfig"),z=l(e=>{if(e.endsWith(".mjs"))return"module";if(e.endsWith(".cjs"))return"commonjs";if(e.endsWith(".d.ts")||e.endsWith(".d.cts")||e.endsWith(".d.mts"))return"types"},"getFileType"),pr=l(e=>e[0]===".","isPath"),Jt=l(e=>e.slice(1).filter(t=>typeof t=="string"&&t[0]!=="."),"getConditions"),de=l((e,t,u,n=[u])=>{if(!e)return[];if(typeof e=="string")return[{source:{type:"package.json",path:[...n]},type:u,conditions:[],format:z(e)||t,outputPath:T(e)}];if(Array.isArray(e))return e.flatMap((s,o)=>{const i=[...n,o];return typeof s=="string"?pr(s)?{source:{type:"package.json",path:[...i]},type:u,conditions:Jt(i),format:z(s)||t,outputPath:T(s)}:[]:de(s,t,u,i)});const r=u==="imports"&&n.length===1;return Object.entries(e).flatMap(([s,o])=>{if(r&&s[0]!=="#")return[];const i=[...n,s];if(typeof o=="string"){const a=Jt(i),c={type:u,source:{type:"package.json",path:i},outputPath:T(o),conditions:a};return a.includes("types")?{...c,format:"types"}:{...c,format:z(o)||t}}return de(o,t,u,i)})},"parsePackageMap"),Fr=l((e,t)=>{const u=[],n=e.main;n&&u.push({source:{type:"package.json",path:["main"]},type:"legacy",format:z(n)??t,outputPath:T(n)});const r=e.module;r&&u.push({source:{type:"package.json",path:["module"]},type:"legacy",format:"module",outputPath:T(r)});const s=e.types;s&&u.push({source:{type:"package.json",path:["types"]},type:"legacy",format:"types",outputPath:T(s)});const{bin:o}=e;if(o)if(typeof o=="string")u.push({source:{type:"package.json",path:["bin"]},type:"binary",format:z(o)??t,outputPath:T(o)});else for(const[i,a]of Object.entries(o))u.push({source:{type:"package.json",path:["bin",i]},type:"binary",format:z(a)??t,outputPath:T(a)});if(e.exports){const i=de(e.exports,t,"exports");u.push(...i)}if(e.imports){const i=de(e.imports,t,"imports");u.push(...i)}return u},"getPkgEntryPoints"),mr=l(async(e,t)=>{for(const u of t){const n=e+u;if(await M(n))return{srcExtension:u,sourcePath:n}}},"tryExtensions"),Pe={".d.ts":[".d.ts",".d.mts",".d.cts",".ts",".tsx",".mts",".cts"],".d.mts":[".d.mts",".d.ts",".d.cts",".ts",".tsx",".mts",".cts"],".d.cts":[".d.cts",".d.ts",".d.mts",".ts",".tsx",".mts",".cts"],".js":[".js",".ts",".tsx",".mts",".cts"],".mjs":[".mjs",".js",".cjs",".mts",".cts",".ts",".tsx"],".cjs":[".cjs",".js",".mjs",".mts",".cts",".ts",".tsx"]},Kt=Object.keys(Pe),hr=l(async(e,t)=>{const{outputPath:u}=e,n=Kt.find(o=>u.endsWith(o));if(!n)return{error:`Unsupported extension (must be ${Kt.join("|")})`,exportEntry:e};const r=u.slice(t.dist.length,-n.length),s=await mr(Z.join(t.srcResolved,r),Pe[n]);return s?{exportEntry:e,distExtension:n,srcdist:t,...s}:{error:`Source file not found: ${Z.join(t.src,r)}(${Pe[n].join("|")})`,exportEntry:e}},"getSourcePath"),gr=l(async e=>{try{return await P.readdir(e,{withFileTypes:!0})}catch(t){const{code:u}=t;if(u==="ENOENT")return[];throw t}},"safeReaddir"),Gt=l(async(e,t)=>{const u=await gr(e);return(await Promise.all(u.map(async r=>{const s=Z.join(e,r.name);return r.isDirectory()?Gt(s,t):r.isFile()?Z.relative(t,s):[]}))).flat()},"getDirectoryFilesRecursive"),Ht=new Map,Yt=l(async e=>{let t=Ht.get(e);return t||(t=Gt(e,e),Ht.set(e,t)),t},"getDirectoryFiles"),pe=/\.[^./]+$/,Zt=l((e,t)=>{const u=t.at(-1);if(!e.endsWith(u))return;if(t.some(r=>r.includes("/"))){const r=e.split("/").filter(Boolean);for(let s=1;s<=r.length;s+=1){const o=r.slice(0,s).join("/"),i=o+t.join(o);if(i===e)return i}}else for(let r=1;r<=e.length;r+=1){const s=e.slice(0,r),o=s+t.join(s);if(o===e)return o}},"extractWildcardMatch"),Cr=l(async(e,t)=>{const u=Array.from(t).sort((r,s)=>s.dist.length-r.dist.length);return(await Promise.all(e.map(async r=>{if(typeof r.source=="string"||r.source.path[0]!=="exports"&&r.source.path[0]!=="imports"||!r.outputPath.includes("*"))return[r];const s=r.source.path[1];if(!s.includes("*"))return[r];const o=r.outputPath.match(/\.d\.[cm]?ts$/)||r.outputPath.match(pe);if(!o)return[{exportEntry:r,error:`Wildcard pattern must include a file extension (e.g., ".mjs", ".cjs"). Pattern: ${s}`}];const[i]=o,a=r.outputPath.slice(0,-i.length),[c,...D]=a.split("*"),F=c.lastIndexOf("/"),f=F===-1?c:c.slice(0,F+1),p=F>=0?c.slice(F+1):"",C=l($=>{const d=$.replace(pe,""),b=d.split("/").at(-1)||"";if(p&&!b.startsWith(p))return!1;if(D.length===1){const w=D[0];return!(w&&!(w.includes("/")?d:b).endsWith(w))}const k=p?b.slice(p.length):d;return!!Zt(k,D)},"matchesPattern");if(f==="./")return(await Promise.all(u.map(async d=>{const b=d.srcResolved;return(await Yt(b)).flatMap(w=>{if(!C(w))return[];const E=w.replace(pe,"");return[{...r,outputPath:d.dist+E+i}]})}))).flat();const g=u.find(({dist:$})=>f===$||f.startsWith($));if(!g)return[];const B=m.posix.join(g.srcResolved,f.slice(g.dist.length));return(await Yt(B)).flatMap($=>{if(!C($))return[];const d=$.replace(pe,"");if(D.length>1){const b=Zt(d,D);return[{...r,outputPath:f+b+i}]}return[{...r,outputPath:f+d+i}]})}))).flat()},"expandBuildOutputWildcards"),Er=l(async(e,t,u)=>{dr(t);const n=t.type??"commonjs",r=await Cr(Fr(t,n),e);u.length>0&&r.push(...u.map(o=>({...o,format:z(o.outputPath)??n})));const s=new Map;return await Promise.all(r.map(async o=>{if("error"in o)return o;const i=e.find(({dist:c})=>o.outputPath.startsWith(c));if(!i)return{exportEntry:o,error:"Ignoring file outside of dist directories"};const a=s.get(o.outputPath);if(a){if(a.format!==o.format)throw new Error(`Conflicting export types "${a.format}" & "${o.format}" found for ${o.outputPath}`)}else s.set(o.outputPath,o);return await hr(o,i)}))},"getBuildEntryPoints"),ee=Symbol("entry"),yr=l(e=>({name:"esbuild-transform",transform:{filter:{id:/\.([cm]?[jt]s|[jt]sx)$/},async handler(t,u){const n=await st(t,{...e,supported:{"import-meta":!0,"import-attributes":!0},loader:"default",sourcefile:u.replace(/\.[cm]ts/,".ts")});return{code:n.code,map:n.map||null}}}}),"esbuildTransform"),wr=l(e=>{if(e==="es")return"esm";if(e==="cjs"||e==="iife")return e},"getEsbuildFormat"),Br=l(e=>({name:"esbuild-minify",renderChunk:l(async(t,u,n)=>{const r=await st(t,{...e,format:wr(n.format),minify:!0,keepNames:!0});return{code:r.code,map:r.map||null}},"renderChunk")}),"esbuildMinify"),Ie=l((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],"compareSemver"),Qt=l(({target:e})=>{const t=e.some(u=>{if(u=u.trim(),!u.startsWith("node"))return;const n=u.slice(4).split(".").map(Number),r=[n[0],n[1]??0,n[2]??0];return!(Ie(r,[12,20,0])>=0&&Ie(r,[13,0,0])<0||Ie(r,[14,13,1])>=0)});return{name:"node-builtins",resolveId:l(u=>{const n=u.startsWith("node:");if(t&&n&&(u=u.slice(5)),ru.includes(u)||n)return{id:u,external:!0}},"resolveId")}},"nodeBuiltins"),br=l(e=>{const t=e.filter(n=>n.exportEntry.type==="binary");if(t.length===0)return{name:"patch-binary"};let u;return{name:"patch-binary",options:l(()=>{u=new Set(t.flatMap(n=>n.inputNames))},"options"),renderChunk:l((n,r,s)=>{if(!r.isEntry||!r.facadeModuleId||!u.has(r.name))return;const o=new se(n);return o.prepend(`#!/usr/bin/env node
|
|
23
|
+
`),n(),process.exit(1);e[a]=c}}l(ce,"v$1"),A(ce,"mapParametersToArguments");function Mt(e){return e===void 0||e!==!1}l(Mt,"G$1"),A(Mt,"helpEnabled");function Te(e,t,u,n){const r={...t.flags},s=t.version&&!("version"in r);s&&(r.version={type:Boolean,description:"Show version"});const{help:o}=t,i=Mt(o);i&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const a=bu(r,n,{ignore:t.ignoreArgv}),c=A(()=>{console.log(t.version)},"showVersion");if(s&&a.flags.version===!0)return c(),process.exit(0);const D=new tr,F=i&&o?.render?o.render:g=>D.render(g),f=A(g=>{const B=Xu({...t,...g?{help:g}:{},flags:r});console.log(F(B,D))},"showHelp");if(i&&a.flags.help===!0)return f(),process.exit(0);if(t.parameters){let{parameters:g}=t,B=a._;const S=g.indexOf("--"),$=g.slice(S+1),d=Object.create(null);if(S>-1&&$.length>0){g=g.slice(0,S);const b=a._["--"];B=B.slice(0,-b.length||void 0),ce(d,le(g),B,f),ce(d,le($),b,f)}else ce(d,le(g),B,f);Object.assign(a._,d)}const p={...a,showVersion:c,showHelp:f},C={command:e,...p};if(typeof u=="function"){const g=u(p);if(g&&"then"in g)return Object.assign(Promise.resolve(g),C)}return C}l(Te,"j"),A(Te,"cliBase");function Ut(e,t){const u=new Map;for(const n of t){const r=[n.options.name],{alias:s}=n.options;s&&(Array.isArray(s)?r.push(...s):r.push(s));for(const o of r){if(u.has(o))throw new Error(`Duplicate command name found: ${L(o)}`);u.set(o,n)}}return u.get(e)}l(Ut,"K$1"),A(Ut,"getCommand");function Vt(e,t,u=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Oe(e.name)))throw new Error(`Invalid script name: ${L(e.name)}`);const n=u[0];if(e.commands&&n&&Oe(n)){const r=Ut(n,e.commands);if(r)return Te(r.options.name,{...r.options,parent:e},r.callback,u.slice(1))}return Te(void 0,e,t,u)}l(Vt,"Q$1"),A(Vt,"cli");function ur(e,t){if(!e)throw new Error("Command options are required");const{name:u}=e;if(u===void 0)throw new Error("Command name is required");if(!Oe(u))throw new Error(`Invalid command name ${JSON.stringify(u)}. Command names must be one word.`);return{options:e,callback:t}}l(ur,"X$1"),A(ur,"command");var rr="2.25.1";const M=l(e=>_.promises.access(e).then(()=>!0,()=>!1),"fsExists");let V=!0;const J=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let X=0;if(J.process&&J.process.env&&J.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:u,TERM:n,COLORTERM:r}=J.process.env;t||u||e==="0"?V=!1:e==="1"||e==="2"||e==="3"?V=!0:n==="dumb"?V=!1:"CI"in J.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(s=>s in J.process.env)?V=!0:V=process.stdout.isTTY,V&&(process.platform==="win32"||r&&(r==="truecolor"||r==="24bit")?X=3:n&&(n.endsWith("-256color")||n.endsWith("256"))?X=2:X=1)}let zt={enabled:V,supportLevel:X};function sr(e,t,u=1){const n=`\x1B[${e}m`,r=`\x1B[${t}m`,s=new RegExp(`\\x1b\\[${t}m`,"g");return o=>zt.enabled&&zt.supportLevel>=u?n+(""+o).replace(s,n)+r:""+o}l(sr,"kolorist");const or=sr(2,22),De=l(e=>e.replaceAll("\\","/"),"slash"),T=l((e,t)=>(!m.isAbsolute(e)&&!e.startsWith(".")&&!e.startsWith("/")&&(e=`./${e}`),t&&!e.endsWith("/")&&(e+="/"),e),"normalizePath"),ir=l(()=>new Date().toLocaleTimeString(),"currentTime"),K=l((...e)=>console.log(or(ir()),...e),"log"),ar=process.cwd(),fe=l(e=>T(m.relative(ar,e)),"formatPath"),lr=l(async e=>{const t=await P.readFile(e,"utf8");try{return Zn(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageYaml"),qt=l(async e=>{const t=await P.readFile(e,"utf8");try{return JSON.parse(t)}catch(u){throw new Error(`Failed to parse ${fe(e)}: ${u.message}`)}},"readPackageJson"),cr=l(async e=>{const t=m.join(e,"package.yaml");if(await M(t))return{packageJson:await lr(t),packageJsonPath:t};const u=m.join(e,"package.json");if(await M(u))return{packageJson:await qt(u),packageJsonPath:u};throw new Error(`package.json not found at: ${u} (also checked for package.yaml)`)},"readPackage"),Dr=l(e=>{let t=!1;if(e.includes("=")){const[u,n]=e.split("=");e=n,t=u==="bin"||u==="binary"}return{type:"legacy",source:"cli",outputPath:T(e),isExecutable:t}},"parseCliInputFlag"),fr=l(({imports:e},t)=>{const u={};if(e)for(const n in e){if(n.startsWith("#"))continue;const r=e[n];typeof r=="string"&&(u[n]=m.join(t,r))}return u},"getAliases"),dr=l(e=>{const{publishConfig:t}=e;if(!t)return;const u=["bin","main","exports","types","module"];for(const n of u)t[n]&&(e[n]=t[n])},"applyPublishConfig"),z=l(e=>{if(e.endsWith(".mjs"))return"module";if(e.endsWith(".cjs"))return"commonjs";if(e.endsWith(".d.ts")||e.endsWith(".d.cts")||e.endsWith(".d.mts"))return"types"},"getFileType"),pr=l(e=>e[0]===".","isPath"),Jt=l(e=>e.slice(1).filter(t=>typeof t=="string"&&t[0]!=="."),"getConditions"),de=l((e,t,u,n=[u])=>{if(!e)return[];if(typeof e=="string")return[{source:{type:"package.json",path:[...n]},type:u,conditions:[],format:z(e)||t,outputPath:T(e)}];if(Array.isArray(e))return e.flatMap((s,o)=>{const i=[...n,o];return typeof s=="string"?pr(s)?{source:{type:"package.json",path:[...i]},type:u,conditions:Jt(i),format:z(s)||t,outputPath:T(s)}:[]:de(s,t,u,i)});const r=u==="imports"&&n.length===1;return Object.entries(e).flatMap(([s,o])=>{if(r&&s[0]!=="#")return[];const i=[...n,s];if(typeof o=="string"){const a=Jt(i),c={type:u,source:{type:"package.json",path:i},outputPath:T(o),conditions:a};return a.includes("types")?{...c,format:"types"}:{...c,format:z(o)||t}}return de(o,t,u,i)})},"parsePackageMap"),Fr=l((e,t)=>{const u=[],n=e.main;n&&u.push({source:{type:"package.json",path:["main"]},type:"legacy",format:z(n)??t,outputPath:T(n)});const r=e.module;r&&u.push({source:{type:"package.json",path:["module"]},type:"legacy",format:"module",outputPath:T(r)});const s=e.types;s&&u.push({source:{type:"package.json",path:["types"]},type:"legacy",format:"types",outputPath:T(s)});const{bin:o}=e;if(o)if(typeof o=="string")u.push({source:{type:"package.json",path:["bin"]},type:"binary",format:z(o)??t,outputPath:T(o)});else for(const[i,a]of Object.entries(o))u.push({source:{type:"package.json",path:["bin",i]},type:"binary",format:z(a)??t,outputPath:T(a)});if(e.exports){const i=de(e.exports,t,"exports");u.push(...i)}if(e.imports){const i=de(e.imports,t,"imports");u.push(...i)}return u},"getPkgEntryPoints"),mr=l(async(e,t)=>{for(const u of t){const n=e+u;if(await M(n))return{srcExtension:u,sourcePath:n}}},"tryExtensions"),Pe={".d.ts":[".d.ts",".d.mts",".d.cts",".ts",".tsx",".mts",".cts"],".d.mts":[".d.mts",".d.ts",".d.cts",".ts",".tsx",".mts",".cts"],".d.cts":[".d.cts",".d.ts",".d.mts",".ts",".tsx",".mts",".cts"],".js":[".js",".ts",".tsx",".mts",".cts"],".mjs":[".mjs",".js",".cjs",".mts",".cts",".ts",".tsx"],".cjs":[".cjs",".js",".mjs",".mts",".cts",".ts",".tsx"]},Kt=Object.keys(Pe),hr=l(async(e,t)=>{const{outputPath:u}=e,n=Kt.find(o=>u.endsWith(o));if(!n)return{error:`Unsupported extension (must be ${Kt.join("|")})`,exportEntry:e};const r=u.slice(t.dist.length,-n.length),s=await mr(Z.join(t.srcResolved,r),Pe[n]);return s?{exportEntry:e,distExtension:n,srcdist:t,...s}:{error:`Source file not found: ${Z.join(t.src,r)}(${Pe[n].join("|")})`,exportEntry:e}},"getSourcePath"),gr=l(async e=>{try{return await P.readdir(e,{withFileTypes:!0})}catch(t){const{code:u}=t;if(u==="ENOENT")return[];throw t}},"safeReaddir"),Gt=l(async(e,t)=>{const u=await gr(e);return(await Promise.all(u.map(async r=>{const s=Z.join(e,r.name);return r.isDirectory()?Gt(s,t):r.isFile()?Z.relative(t,s):[]}))).flat()},"getDirectoryFilesRecursive"),Ht=new Map,Yt=l(async e=>{let t=Ht.get(e);return t||(t=Gt(e,e),Ht.set(e,t)),t},"getDirectoryFiles"),pe=/\.[^./]+$/,Zt=l((e,t)=>{const u=t.at(-1);if(!e.endsWith(u))return;if(t.some(r=>r.includes("/"))){const r=e.split("/").filter(Boolean);for(let s=1;s<=r.length;s+=1){const o=r.slice(0,s).join("/"),i=o+t.join(o);if(i===e)return i}}else for(let r=1;r<=e.length;r+=1){const s=e.slice(0,r),o=s+t.join(s);if(o===e)return o}},"extractWildcardMatch"),Cr=l(async(e,t)=>{const u=Array.from(t).sort((r,s)=>s.dist.length-r.dist.length);return(await Promise.all(e.map(async r=>{if(typeof r.source=="string"||r.source.path[0]!=="exports"&&r.source.path[0]!=="imports"||!r.outputPath.includes("*"))return[r];const s=r.source.path[1];if(!s.includes("*"))return[r];const o=r.outputPath.match(/\.d\.[cm]?ts$/)||r.outputPath.match(pe);if(!o)return[{exportEntry:r,error:`Wildcard pattern must include a file extension (e.g., ".mjs", ".cjs"). Pattern: ${s}`}];const[i]=o,a=r.outputPath.slice(0,-i.length),[c,...D]=a.split("*"),F=c.lastIndexOf("/"),f=F===-1?c:c.slice(0,F+1),p=F>=0?c.slice(F+1):"",C=l($=>{const d=$.replace(pe,""),b=d.split("/").at(-1)||"";if(p&&!b.startsWith(p))return!1;if(D.length===1){const w=D[0];return!(w&&!(w.includes("/")?d:b).endsWith(w))}const k=p?b.slice(p.length):d;return!!Zt(k,D)},"matchesPattern");if(f==="./")return(await Promise.all(u.map(async d=>{const b=d.srcResolved;return(await Yt(b)).flatMap(w=>{if(!C(w))return[];const E=w.replace(pe,"");return[{...r,outputPath:d.dist+E+i}]})}))).flat();const g=u.find(({dist:$})=>f===$||f.startsWith($));if(!g)return[];const B=m.posix.join(g.srcResolved,f.slice(g.dist.length));return(await Yt(B)).flatMap($=>{if(!C($))return[];const d=$.replace(pe,"");if(D.length>1){const b=Zt(d,D);return[{...r,outputPath:f+b+i}]}return[{...r,outputPath:f+d+i}]})}))).flat()},"expandBuildOutputWildcards"),Er=l(async(e,t,u)=>{dr(t);const n=t.type??"commonjs",r=await Cr(Fr(t,n),e);u.length>0&&r.push(...u.map(o=>({...o,format:z(o.outputPath)??n})));const s=new Map;return await Promise.all(r.map(async o=>{if("error"in o)return o;const i=e.find(({dist:c})=>o.outputPath.startsWith(c));if(!i)return{exportEntry:o,error:"Ignoring file outside of dist directories"};const a=s.get(o.outputPath);if(a){if(a.format!==o.format)throw new Error(`Conflicting export types "${a.format}" & "${o.format}" found for ${o.outputPath}`)}else s.set(o.outputPath,o);return await hr(o,i)}))},"getBuildEntryPoints"),ee=Symbol("entry"),yr=l(e=>({name:"esbuild-transform",transform:{filter:{id:/\.([cm]?[jt]s|[jt]sx)$/},async handler(t,u){const n=await st(t,{...e,supported:{"import-meta":!0,"import-attributes":!0},loader:"default",sourcefile:u.replace(/\.[cm]ts/,".ts")});return{code:n.code,map:n.map||null}}}}),"esbuildTransform"),wr=l(e=>{if(e==="es")return"esm";if(e==="cjs"||e==="iife")return e},"getEsbuildFormat"),Br=l(e=>({name:"esbuild-minify",renderChunk:l(async(t,u,n)=>{const r=await st(t,{...e,format:wr(n.format),minify:!0,keepNames:!0});return{code:r.code,map:r.map||null}},"renderChunk")}),"esbuildMinify"),Ie=l((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2],"compareSemver"),Qt=l(({target:e})=>{const t=e.some(u=>{if(u=u.trim(),!u.startsWith("node"))return;const n=u.slice(4).split(".").map(Number),r=[n[0],n[1]??0,n[2]??0];return!(Ie(r,[12,20,0])>=0&&Ie(r,[13,0,0])<0||Ie(r,[14,13,1])>=0)});return{name:"node-builtins",resolveId:l(u=>{const n=u.startsWith("node:");if(t&&n&&(u=u.slice(5)),ru.includes(u)||n)return{id:u,external:!0}},"resolveId")}},"nodeBuiltins"),br=l(e=>{const t=e.filter(n=>n.exportEntry.type==="binary");if(t.length===0)return{name:"patch-binary"};let u;return{name:"patch-binary",options:l(()=>{u=new Set(t.flatMap(n=>n.inputNames))},"options"),renderChunk:l((n,r,s)=>{if(!r.isEntry||!r.facadeModuleId||!u.has(r.name))return;const o=new se(n);return o.prepend(`#!/usr/bin/env node
|
|
24
24
|
`),{code:o.toString(),map:s.sourcemap?o.generateMap({hires:!0}):void 0}},"renderChunk"),writeBundle:l(async(n,r)=>{const s=new Set(Object.keys(r).map(o=>T(Z.join(n.dir,o))));await Promise.all(t.map(async({exportEntry:o})=>{const{outputPath:i}=o;s.has(i)&&await _.promises.chmod(i,493)}))},"writeBundle")}},"patchBinary"),Xt=l(e=>{const t=e.indexOf("/");if(t===-1)return[e,void 0];if(e[0]==="@"){const u=e.indexOf("/",t+1);return u===-1?[e,void 0]:[e.slice(0,u),e.slice(u+1)]}return[e.slice(0,t),e.slice(t+1)]},"parseSpecifier"),en=l(e=>{const t=e[0];return!(t==="."||t==="/"||t==="#"||m.isAbsolute(e))},"isBareSpecifier"),Ne=l((e,t=process.cwd())=>De(m.relative(t,e)).split("/").includes("node_modules"),"isFromNodeModules"),tn=l(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"resolve-js-to-ts",async resolveId(t,u,n){if(u&&e.test(t)){if(!Ne(u)){const i=t.replace(/js(x?)$/,"ts$1");return this.resolve(i,u,{...n,skipSelf:!0})}const r=await this.resolve(t,u,{...n,skipSelf:!0});if(r)return r;const s=t.replace(/js(x?)$/,"ts$1"),o=await this.resolve(s,u,{...n,skipSelf:!0});if(o)return o}return null}}},"resolveJsToTs"),nn=l(e=>e!==null&&typeof e=="object","A"),G=l((e,t)=>Object.assign(new Error(`[${e}]: ${t}`),{code:e}),"a"),un="ERR_INVALID_PACKAGE_CONFIG",Re="ERR_INVALID_PACKAGE_TARGET",vr="ERR_PACKAGE_PATH_NOT_EXPORTED",Ar=/^\d+$/,$r=/^(\.{1,2}|node_modules)$/i,xr=/\/|\\/;var rn=(e=>(e.Export="exports",e.Import="imports",e))(rn||{});const _e=l((e,t,u,n,r)=>{if(t==null)return[];if(typeof t=="string"){const[s,...o]=t.split(xr);if(s===".."||o.some(i=>$r.test(i)))throw G(Re,`Invalid "${e}" target "${t}" defined in the package config`);return[r?t.replace(/\*/g,r):t]}if(Array.isArray(t))return t.flatMap(s=>_e(e,s,u,n,r));if(nn(t)){for(const s of Object.keys(t)){if(Ar.test(s))throw G(un,"Cannot contain numeric property keys");if(s==="default"||n.includes(s))return _e(e,t[s],u,n,r)}return[]}throw G(Re,`Invalid "${e}" target "${t}"`)},"f"),te="*",kr=l((e,t)=>{const u=e.indexOf(te),n=t.indexOf(te);return u===n?t.length>e.length:n>u},"m");function jr(e,t){if(!t.includes(te)&&e.hasOwnProperty(t))return[t];let u,n;for(const r of Object.keys(e))if(r.includes(te)){const[s,o,i]=r.split(te);if(i===void 0&&t.startsWith(s)&&t.endsWith(o)){const a=t.slice(s.length,-o.length||void 0);a&&(!u||kr(u,r))&&(u=r,n=a)}}return[u,n]}l(jr,"d");const Sr=l(e=>Object.keys(e).reduce((t,u)=>{const n=u===""||u[0]!==".";if(t===void 0||t===n)return n;throw G(un,'"exports" cannot contain some keys starting with "." and some not')},void 0),"p"),Or=/^\w+:/,Tr=l((e,t,u)=>{if(!e)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof e=="string"||Array.isArray(e)||nn(e)&&Sr(e))&&(e={".":e});const[n,r]=jr(e,t),s=_e(rn.Export,e[n],t,u,r);if(s.length===0)throw G(vr,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const o of s)if(!o.startsWith("./")&&!Or.test(o))throw G(Re,`Invalid "exports" target "${o}" defined in the package config`);return s},"v");var Pr=Object.defineProperty,h=l((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"o");function I(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}l(I,"h"),h(I,"slash");const Le=h(e=>{const t=_[e];return(u,...n)=>{const r=`${e}:${n.join(":")}`;let s=u?.get(r);return s===void 0&&(s=Reflect.apply(t,_,n),u?.set(r,s)),s}},"cacheFs"),N=Le("existsSync"),Ir=Le("readFileSync"),Fe=Le("statSync"),sn=h((e,t,u)=>{for(;;){const n=m.posix.join(e,t);if(N(u,n))return n;const r=m.dirname(e);if(r===e)return;e=r}},"findUp"),We=/^\.{1,2}(\/.*)?$/,Me=h(e=>{const t=I(e);return We.test(t)?t:`./${t}`},"normalizeRelativePath");function on(e,t=!1){const u=e.length;let n=0,r="",s=0,o=16,i=0,a=0,c=0,D=0,F=0;function f(d,b){let k=0,w=0;for(;k<d;){let E=e.charCodeAt(n);if(E>=48&&E<=57)w=w*16+E-48;else if(E>=65&&E<=70)w=w*16+E-65+10;else if(E>=97&&E<=102)w=w*16+E-97+10;else break;n++,k++}return k<d&&(w=-1),w}l(f,"y"),h(f,"scanHexDigits");function p(d){n=d,r="",s=0,o=16,F=0}l(p,"v"),h(p,"setPosition");function C(){let d=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&q(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&q(e.charCodeAt(n)))for(n++;n<e.length&&q(e.charCodeAt(n));)n++;else return F=3,e.substring(d,n);let b=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&q(e.charCodeAt(n))){for(n++;n<e.length&&q(e.charCodeAt(n));)n++;b=n}else F=3;return e.substring(d,b)}l(C,"j"),h(C,"scanNumber");function g(){let d="",b=n;for(;;){if(n>=u){d+=e.substring(b,n),F=2;break}const k=e.charCodeAt(n);if(k===34){d+=e.substring(b,n),n++;break}if(k===92){if(d+=e.substring(b,n),n++,n>=u){F=2;break}switch(e.charCodeAt(n++)){case 34:d+='"';break;case 92:d+="\\";break;case 47:d+="/";break;case 98:d+="\b";break;case 102:d+="\f";break;case 110:d+=`
|
|
25
25
|
`;break;case 114:d+="\r";break;case 116:d+=" ";break;case 117:const w=f(4);w>=0?d+=String.fromCharCode(w):F=4;break;default:F=5}b=n;continue}if(k>=0&&k<=31)if(H(k)){d+=e.substring(b,n),F=2;break}else F=6;n++}return d}l(g,"d"),h(g,"scanString");function B(){if(r="",F=0,s=n,a=i,D=c,n>=u)return s=u,o=17;let d=e.charCodeAt(n);if(me(d)){do n++,r+=String.fromCharCode(d),d=e.charCodeAt(n);while(me(d));return o=15}if(H(d))return n++,r+=String.fromCharCode(d),d===13&&e.charCodeAt(n)===10&&(n++,r+=`
|
|
26
26
|
`),i++,c=n,o=14;switch(d){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,r=g(),o=10;case 47:const b=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<u&&!H(e.charCodeAt(n));)n++;return r=e.substring(b,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;const k=u-1;let w=!1;for(;n<k;){const E=e.charCodeAt(n);if(E===42&&e.charCodeAt(n+1)===47){n+=2,w=!0;break}n++,H(E)&&(E===13&&e.charCodeAt(n)===10&&n++,i++,c=n)}return w||(n++,F=1),r=e.substring(b,n),o=13}return r+=String.fromCharCode(d),n++,o=16;case 45:if(r+=String.fromCharCode(d),n++,n===u||!q(e.charCodeAt(n)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=C(),o=11;default:for(;n<u&&S(d);)n++,d=e.charCodeAt(n);if(s!==n){switch(r=e.substring(s,n),r){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return r+=String.fromCharCode(d),n++,o=16}}l(B,"A"),h(B,"scanNext");function S(d){if(me(d)||H(d))return!1;switch(d){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}l(S,"E"),h(S,"isUnknownContentCharacter");function $(){let d;do d=B();while(d>=12&&d<=15);return d}return l($,"B"),h($,"scanNextNonTrivia"),{setPosition:p,getPosition:h(()=>n,"getPosition"),scan:t?$:B,getToken:h(()=>o,"getToken"),getTokenValue:h(()=>r,"getTokenValue"),getTokenOffset:h(()=>s,"getTokenOffset"),getTokenLength:h(()=>n-s,"getTokenLength"),getTokenStartLine:h(()=>a,"getTokenStartLine"),getTokenStartCharacter:h(()=>s-D,"getTokenStartCharacter"),getTokenError:h(()=>F,"getTokenError")}}l(on,"Le"),h(on,"createScanner");function me(e){return e===32||e===9}l(me,"X"),h(me,"isWhiteSpace");function H(e){return e===10||e===13}l(H,"S"),h(H,"isLineBreak");function q(e){return e>=48&&e<=57}l(q,"$"),h(q,"isDigit");var an;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(an||(an={})),new Array(20).fill(0).map((e,t)=>" ".repeat(t));const Y=200;new Array(Y).fill(0).map((e,t)=>`
|
|
@@ -42,4 +42,4 @@ No bundled dependencies.`;const n=e.slice().sort((r,s)=>r.name!==s.name?r.name<s
|
|
|
42
42
|
|
|
43
43
|
${n}`},"formatLicenseContent"),xs=l(async(e,t)=>{const u=$s(t);if(!await Ze(e)){await P.mkdir(m.dirname(e),{recursive:!0}),await P.writeFile(e,u,"utf8"),console.log(`License file created: ${e}`);return}const n=await P.readFile(e,"utf8"),r=ys.exec(n);let s;r?s=n.slice(0,r.index)+u:s=`${n.trimEnd()}
|
|
44
44
|
|
|
45
|
-
${u}`,n!==s&&(await P.writeFile(e,s,"utf8"),console.log(`License file updated: ${e}`))},"writeLicenseFile"),ks=l(e=>{const t=process.cwd();let u=!1;return{name:"pkgroll-license",async generateBundle(n,r){if(this.meta.watchMode||u)return;u=!0;const s=await vs(r);let o;typeof e=="string"?o=m.resolve(t,e):o=await Pn(t)??m.join(t,"LICENSE"),await xs(o,s)}}},"licensePlugin"),js=l((e,t,u,n,r,s)=>{const o=Object.fromEntries(e.env.map(({key:c,value:D})=>[`process.env.${c}`,JSON.stringify(D)])),i=Object.fromEntries(e.define.map(({key:c,value:D})=>[c,D])),a={target:e.target,sourcemap:e.sourcemap,tsconfigRaw:r?.config,define:{...o,...i}};return{input:{},preserveEntrySignatures:"strict",plugins:[rt(),Qt(e),...r?[An(r)]:[],tu({entries:u}),kn(),Fs(),On(t),
|
|
45
|
+
${u}`,n!==s&&(await P.writeFile(e,s,"utf8"),console.log(`License file updated: ${e}`))},"writeLicenseFile"),ks=l(e=>{const t=process.cwd();let u=!1;return{name:"pkgroll-license",async generateBundle(n,r){if(this.meta.watchMode||u)return;u=!0;const s=await vs(r);let o;typeof e=="string"?o=m.resolve(t,e):o=await Pn(t)??m.join(t,"LICENSE"),await xs(o,s)}}},"licensePlugin"),js=l((e,t,u,n,r,s)=>{const o=Object.fromEntries(e.env.map(({key:c,value:D})=>[`process.env.${c}`,JSON.stringify(D)])),i=Object.fromEntries(e.define.map(({key:c,value:D})=>[c,D])),a={target:e.target,sourcemap:e.sourcemap,tsconfigRaw:r?.config,define:{...o,...i}};return{input:{},preserveEntrySignatures:"strict",plugins:[rt(),Qt(e),...r?[An(r)]:[],tu({entries:u}),kn(),Fs(),On(t),Ds(),tn(),Qn({extensions:[".mjs",".js",".ts",".jsx",".tsx",".json"],exportConditions:e.exportCondition}),ss(),eu(),yr(a),Cs(),Xn({ignoreDynamicRequires:!0,extensions:[".js",".ts",".jsx",".tsx"],transformMixedEsModules:!0}),nu({warnOnError:!0}),ls(),cs(s),...e.minify?[Br(a)]:[],br(n),...e.license?[ks(e.license)]:[]],output:[]}},"getPkgConfig"),Ss=l(async(e,t,u)=>{const[n,r]=await Promise.all([import("./rollup-plugin-dts-B-10yM9-.mjs"),import("./local-typescript-loader-CSvrvK-x.mjs")]);return{input:{},preserveEntrySignatures:"strict",plugins:[rt(),kn(),Qt(e),...u?[An(u)]:[],On(t,{skipUnlistedWarnings:!0,forTypes:!0}),tn(),n.default({respectExternal:!0,compilerOptions:{composite:!1,preserveSymlinks:!1,module:r.default.ModuleKind.Preserve,moduleResolution:r.default.ModuleResolutionKind.Bundler},tsconfig:u?.path,sourcemap:!!(e.sourcemap||u?.config.compilerOptions?.declarationMap)})],output:[]}},"getDtsConfig"),Os=l(e=>{if(e.length===0)return"";const t=e.map(s=>s.split("/")),u=t[0],n=Math.min(...t.map(s=>s.length)),r=[];for(let s=0;s<n;s+=1){const o=u[s];if(t.every(i=>i[s]===o))r.push(o);else break}return r.length===0?"/":r.join("/")||"/"},"getCommonPath"),Ts=l(async(e,t,u,n,r,s)=>{const o=T(Os(e.map(({dist:c})=>c)),!0);for(const c of e)c.distPrefix=c.dist.slice(o.length);const i=e,a=Object.create(null);for(const c of t){const{sourcePath:D,srcExtension:F,distExtension:f,exportEntry:p}=c,C=c.srcdist,g=C.distPrefix+D.slice(C.srcResolved.length,-F.length);if(c.inputNames=[g],p.format==="types"){let d=a.dts;d||(d=await Ss(u,r,s),a.dts=d),d.input[g]||(d.input[g]=D);const b=d.output;if(b[f])b[f][ee].inputNames.push(g);else{const k={dir:o,entryFileNames:`[name]${f}`,chunkFileNames:`${C.distPrefix}[name]-[hash]${f}`,exports:"auto",format:"esm",sourcemap:u.sourcemap||s?.config.compilerOptions?.declarationMap,[ee]:c};b.push(k),b[f]=k}continue}let B=a.pkg;if(!B){const d=i[0].dist;B=js(u,r,n,t,s,d),a.pkg=B}B.input[g]||(B.input[g]=D);const S=B.output,$=`${p.format}-${f}`;if(S[$])S[$][ee].inputNames.push(g);else{const d={dir:o,exports:"auto",format:p.format,sourcemap:u.sourcemap,entryFileNames:`[name]${f}`,chunkFileNames:`${C.distPrefix}[name]-[hash]${f}`,[ee]:c};S.push(d),S[$]=d}}return Object.values(a)},"getRollupConfigs"),Ps=l(e=>{if(!e)return zr();const t=m.resolve(e),u=gn(t);return{path:t,config:u}},"getTsconfig"),Is=l(async e=>{await M(e)&&await _.promises.rm(e,{recursive:!0,force:!0})},"cleanDist"),Ns=/^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u,Rs=new Set(["do","if","in","for","int","new","try","var","byte","case","char","else","enum","goto","long","null","this","true","void","with","break","catch","class","const","false","final","float","short","super","throw","while","delete","double","export","import","native","public","return","static","switch","throws","typeof","boolean","default","extends","finally","package","private","abstract","continue","debugger","function","volatile","interface","protected","transient","implements","instanceof","synchronized"]),_s=l(e=>!Ns.test(e)||Rs.has(e),"propertyNeedsQuotes"),Ls=l(e=>e.map((t,u)=>typeof t=="number"?`[${t}]`:_s(t)?`[${JSON.stringify(t)}]`:u>0?`.${t}`:t).join(""),"prettyPath"),Ws=l(e=>({name:"filter-unnecessary-outputs",generateBundle:l((t,u)=>{const n=Object.keys(u).filter(o=>u[o].type==="chunk"),r=[];for(const o of n){const i=u[o];i.isEntry&&e.includes(i.name)&&r.push(o)}const s=new Set;for(;r.length>0;){const o=r.shift(),i=u[o];if(!i||s.has(o))continue;s.add(o);const a=[...i.imports,...i.dynamicImports];for(const c of a)r.push(c)}for(const o of n)s.has(o)||delete u[o]},"generateBundle")}),"filterUnnecessaryOutputs"),{stringify:Nn}=JSON,Rn=l(e=>{const[t,u]=e.split("=",2);return{key:t,value:u}},"keyValue"),R=Vt({name:"pkgroll",version:rr,flags:{input:{type:[Dr],alias:"i",description:"Dist paths for source files to bundle (Only use if you cannot use package.json entries)"},src:{type:String,description:"Source directory (Deprecated, use `srcdist` instead)",default:"./src"},dist:{type:String,description:"Distribution directory (Deprecated, use `srcdist` instead)",default:"./dist"},srcdist:{type:[String],description:"Source and distribution folder pairs (eg. default `src:dist`)"},minify:{type:Boolean,description:"Minify output",alias:"m",default:!1},target:{type:[String],default:[`node${process.versions.node}`],description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",alias:"t"},tsconfig:{type:String,description:"Custom tsconfig.json file path",alias:"p"},watch:{type:Boolean,description:"Watch mode",alias:"w",default:!1},env:{type:[Rn],description:"Compile-time environment variables (eg. --env.NODE_ENV=production)"},define:{type:[Rn],description:"Targeted strings to replace (eg. --define.process.env.NODE_ENV='production')"},exportCondition:{type:[String],description:"Export conditions for resolving dependency export and import maps (eg. --export-condition=node)"},sourcemap:{type:l(e=>{if(e==="")return!0;if(e==="inline")return e;throw new Error(`Invalid sourcemap option ${Nn(e)}`)},"type"),description:"Sourcemap generation. Provide `inline` option for inline sourcemap (eg. --sourcemap, --sourcemap=inline)"},cleanDist:{type:Boolean,description:"Clean dist before bundling",default:!1},license:{type:l(e=>e===""?!0:e,"type"),description:"Generate licenses for bundled dependencies. Optionally specify output path (eg. --license, --license=NOTICES.txt)"}},help:{description:"Minimalistic package bundler",render:l((e,t)=>(t.flagOperator=u=>u.name==="env"?".key=":" ",t.render(e)),"render")}}),Qe=process.cwd(),ne=[];if(R.flags.srcdist.length>0)for(const e of R.flags.srcdist){const[t,u]=e.split(":",2);if(!t||!u)throw new Error(`Invalid src:dist pair ${Nn(e)}. Expected format: src:dist`);ne.push({src:T(t,!0),srcResolved:T(_.realpathSync.native(t),!0),dist:T(u,!0)})}else ne.push({src:T(R.flags.src,!0),srcResolved:T(_.realpathSync.native(R.flags.src),!0),dist:T(R.flags.dist,!0)});const _n=Ps(R.flags.tsconfig),Ln=_n?.config.compilerOptions?.target;Ln&&R.flags.target.push(Ln);const Wn=l(async()=>{const{packageJson:e}=await cr(Qe),t=await Er(ne,e,R.flags.input);for(const n of t)if("error"in n){const{exportEntry:r}=n,s=typeof r.source=="string"?r.source:`${r.source.type}#${Ls(r.source.path)}`;console.warn(`Warning (${s}):`,n.error)}const u=t.filter(n=>!("error"in n));if(u.length===0)throw new Error("No entry points found");return Ts(ne,u,R.flags,fr(e,Qe),e,_n)},"generateRollupConfigs");(async()=>{if(R.flags.cleanDist&&await Promise.all(ne.map(({dist:e})=>Is(e))),R.flags.watch){K("Watch initialized");let e=[];const t=l(async()=>{e=(await Wn()).map(s=>{const o=Hn(s);return o.on("event",async i=>{if(i.code==="BUNDLE_START"){const a=Array.isArray(i.input)?i.input:Object.values(i.input);K("Building",...a.map(fe))}if(i.code==="BUNDLE_END")try{await Promise.all(s.output.map(c=>i.result.write(c)));const a=Array.isArray(i.input)?i.input:Object.values(i.input);K("Built",...a.map(fe))}finally{await i.result.close()}i.code==="ERROR"&&(K("Error:",i.error.message),await i.result?.close())}),o})},"startWatchers"),u=l(async()=>{await Promise.all(e.map(r=>r.close())),e=[]},"closeWatchers");await t();let n;_.watch(m.join(Qe,"package.json"),()=>{clearTimeout(n),n=setTimeout(async()=>{K("package.json changed, restarting...");try{await u(),await t()}catch(r){K("Error:",r.message)}},100)})}else{const e=await Wn();await Promise.all(e.map(async t=>{const u=await Gn(t);try{await Promise.all(t.output.map(n=>{const r=n[ee].inputNames;return n.plugins=[Ws(r)],u.write(n)}))}finally{await u.close()}}))}})().catch(e=>{Yn(e),console.error("Error:",e instanceof Error?e.message:String(e)),process.exit(1)});
|