@tochii/build 2.2.6 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ var _=Object.create;var F=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var Se=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var se=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ne(e))!re.call(n,s)&&s!==t&&F(n,s,{get:()=>e[s],enumerable:!(r=ee(e,s))||r.enumerable});return n};var ie=(n,e,t)=>(t=n!=null?_(te(n)):{},oe(e||!n||!n.__esModule?F(t,"default",{value:n,enumerable:!0}):t,n));var L=se((Je,H)=>{"use strict";var ye=function(e){return ge(e)&&!me(e)};function ge(n){return!!n&&typeof n=="object"}function me(n){var e=Object.prototype.toString.call(n);return e==="[object RegExp]"||e==="[object Date]"||Oe(n)}var be=typeof Symbol=="function"&&Symbol.for,he=be?Symbol.for("react.element"):60103;function Oe(n){return n.$$typeof===he}function Ee(n){return Array.isArray(n)?[]:{}}function C(n,e){return e.clone!==!1&&e.isMergeableObject(n)?h(Ee(n),n,e):n}function xe(n,e,t){return n.concat(e).map(function(r){return C(r,t)})}function je(n,e){if(!e.customMerge)return h;var t=e.customMerge(n);return typeof t=="function"?t:h}function Ce(n){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(n).filter(function(e){return Object.propertyIsEnumerable.call(n,e)}):[]}function q(n){return Object.keys(n).concat(Ce(n))}function z(n,e){try{return e in n}catch{return!1}}function Pe(n,e){return z(n,e)&&!(Object.hasOwnProperty.call(n,e)&&Object.propertyIsEnumerable.call(n,e))}function De(n,e,t){var r={};return t.isMergeableObject(n)&&q(n).forEach(function(s){r[s]=C(n[s],t)}),q(e).forEach(function(s){Pe(n,s)||(z(n,s)&&t.isMergeableObject(e[s])?r[s]=je(s,t)(n[s],e[s],t):r[s]=C(e[s],t))}),r}function h(n,e,t){t=t||{},t.arrayMerge=t.arrayMerge||xe,t.isMergeableObject=t.isMergeableObject||ye,t.cloneUnlessOtherwiseSpecified=C;var r=Array.isArray(e),s=Array.isArray(n),o=r===s;return o?r?t.arrayMerge(n,e,t):De(n,e,t):C(e,t)}h.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,s){return h(r,s,t)},{})};var ve=h;H.exports=ve});import l from"#ansi-styles";import ce from"#supports-color";function K(n,e,t){let r=n.indexOf(e);if(r===-1)return n;let s=e.length,o=0,c="";do c+=n.slice(o,r)+e+t,o=r+s,r=n.indexOf(e,o);while(r!==-1);return c+=n.slice(o),c}function W(n,e,t,r){let s=0,o="";do{let c=n[r-1]==="\r";o+=n.slice(s,c?r-1:r)+e+(c?`\r
2
+ `:`
3
+ `)+t,s=r+1,r=n.indexOf(`
4
+ `,s)}while(r!==-1);return o+=n.slice(s),o}var{stdout:Y,stderr:G}=ce,k=Symbol("GENERATOR"),m=Symbol("STYLER"),x=Symbol("IS_EMPTY"),V=["ansi","ansi","ansi256","ansi16m"],b=Object.create(null),ae=(n,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Y?Y.level:0;n.level=e.level===void 0?t:e.level};var le=n=>{let e=(...t)=>t.join(" ");return ae(e,n),Object.setPrototypeOf(e,j.prototype),e};function j(n){return le(n)}Object.setPrototypeOf(j.prototype,Function.prototype);for(let[n,e]of Object.entries(l))b[n]={get(){let t=v(this,T(e.open,e.close,this[m]),this[x]);return Object.defineProperty(this,n,{value:t}),t}};b.visible={get(){let n=v(this,this[m],!0);return Object.defineProperty(this,"visible",{value:n}),n}};var I=(n,e,t,...r)=>n==="rgb"?e==="ansi16m"?l[t].ansi16m(...r):e==="ansi256"?l[t].ansi256(l.rgbToAnsi256(...r)):l[t].ansi(l.rgbToAnsi(...r)):n==="hex"?I("rgb",e,t,...l.hexToRgb(...r)):l[t][n](...r),de=["rgb","hex","ansi256"];for(let n of de){b[n]={get(){let{level:t}=this;return function(...r){let s=T(I(n,V[t],"color",...r),l.color.close,this[m]);return v(this,s,this[x])}}};let e="bg"+n[0].toUpperCase()+n.slice(1);b[e]={get(){let{level:t}=this;return function(...r){let s=T(I(n,V[t],"bgColor",...r),l.bgColor.close,this[m]);return v(this,s,this[x])}}}}var fe=Object.defineProperties(()=>{},{...b,level:{enumerable:!0,get(){return this[k].level},set(n){this[k].level=n}}}),T=(n,e,t)=>{let r,s;return t===void 0?(r=n,s=e):(r=t.openAll+n,s=e+t.closeAll),{open:n,close:e,openAll:r,closeAll:s,parent:t}},v=(n,e,t)=>{let r=(...s)=>ue(r,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(r,fe),r[k]=n,r[m]=e,r[x]=t,r},ue=(n,e)=>{if(n.level<=0||!e)return n[x]?"":e;let t=n[m];if(t===void 0)return e;let{openAll:r,closeAll:s}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=K(e,t.close,t.open),t=t.parent;let o=e.indexOf(`
5
+ `);return o!==-1&&(e=W(e,s,r,o)),r+e+s};Object.defineProperties(j.prototype,b);var pe=j(),Me=j({level:G?G.level:0});var d=pe;var M=ie(L());import u from"node:fs";import S from"node:path";var R="tochibuild",P=d.cyan(R),f=class{};f.custom=(e,...t)=>{console[e](P,...t)},f.log=(...e)=>{console.log(P,...e)},f.debug=(...e)=>{console.debug(P,...e)},f.info=(...e)=>{console.info(P,...e)},f.warn=(...e)=>{console.warn(P,...[...e].map(t=>d.yellow(t)))},f.error=(e,...t)=>{console.error(d.red(R),d.bgRed(...t),e?.stack?`
6
+ ${d.gray(e.stack)}`:"")},f.success=(...e)=>{console.log(d.green(R),...e)};var y=f;var i=class i{};i.defaultConfigOptions={tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0},i.ignoredEntries=["!build/**","!dist/**","!node_modules/**","!**/build/**","!**/dist/**","!**/node_modules/**","!**/*.d.ts","!**/{tochibuild,tsup}.*"],i.entriesCommon=["**/*.{js,ts}"],i.entriesIndex=["**/index.{js,ts}"],i.defaultEntriesIndex=[...i.ignoredEntries,...i.entriesIndex],i.defaultEntriesCommon=[...i.ignoredEntries,...i.entriesCommon],i.defaultOptions=(e,t)=>w(e,r=>{let s=A(r.entry,t?.excludeIgnoredEntries?[]:["ignoredEntries"]);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:s}}),i.defaultOptionsWithIndexEntries=(e,t)=>w(e,r=>{let s=t?.excludeIgnoredEntries?["entriesIndex"]:["ignoredEntries","entriesIndex"],o=A(r.entry,s);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:o}}),i.defaultOptionsWithCommonEntries=(e,t)=>w(e,r=>{let s=t?.excludeIgnoredEntries?["entriesCommon"]:["ignoredEntries","entriesCommon"],o=A(r.entry,s);return{...i.defaultConfigOptions,...r,noExternal:[...r.noExternal||[],...i.getPackageJsonDepsEntriesFromConfig(t)],entry:o}}),i.generateConfig=Ae,i.ensureEntries=A,i.getPackageJson=(e,t)=>{let r,s;try{return r=S.join(Q(e),"package.json"),u.existsSync(r)&&(s=JSON.parse(u.readFileSync(r,"utf-8"))),{filePath:r,data:s}}catch(o){if(t)throw o;return{filePath:r,data:s}}},i.getPackageJsonDepsEntriesFromConfig=(e,t)=>{let r=e?.includePackageJsonDeps??!0,s=e?.includePackageJsonDevDeps??!1,o=e?.includePackageJsonPeerDeps??!1,c=[];return r&&c.push("dependencies"),s&&c.push("devDependencies"),o&&c.push("peerDependencies"),i.getPackageJsonDepsEntries(t??i.getPackageJson().filePath,c)},i.getPackageJsonDepsEntries=(e,t=["dependencies","devDependencies","peerDependencies"])=>i.getPackageJsonDeps(e).toArray(t),i.getPackageJsonDeps=e=>{let t={},r={},s={},o={dependencies:t,devDependencies:r,peerDependencies:s,toArray:(c=["dependencies","devDependencies","peerDependencies"])=>[]};try{if(!e)return o;if(!u.existsSync(e))return y.error(void 0,`could not find package.json at ${e}`),o;let c=u.readFileSync(e,"utf-8"),a=JSON.parse(c),O={dependencies:a.dependencies||{},devDependencies:a.devDependencies||{},peerDependencies:a.peerDependencies||{}};return{...O,toArray:(p=["dependencies","devDependencies","peerDependencies"])=>p.flatMap(E=>Object.keys(O[E]))}}catch(c){y.error(c,`could not read package.json at ${e}`);let a={dependencies:t||{},devDependencies:r||{},peerDependencies:s||{}};return{...a,toArray:(O=["dependencies","devDependencies","peerDependencies"])=>O.flatMap(p=>Object.keys(a[p]))}}};var D=i,qe=D;function w(n,e){let t=s=>Array.isArray(s)?s.map(o=>(0,M.default)(e(o),s)):(0,M.default)(e(s),s);if(typeof n=="function"){let s=n;async function o(c){let a=await s(c);return t(a)}return o}return t(n)}function A(n,e){if(Array.isArray(n)){let t=[],r=[];return e.forEach(s=>r.push(...D[s])),t.push(...Array.from(new Set([...r,...n]))),t}return n}function Q(n){let e=S.resolve(process.cwd(),n||".");return n&&S.isAbsolute(n||".")?n:e}function Ae(n,e,t,r){let s="";try{let o=e?.ext||".ts",a=`${e?.filename||"tochibuild.config"}${o}`;(e?.outDir?.length?e.outDir:["."]).forEach(p=>{s=Q(p),u.existsSync(p)||u.mkdirSync(p,{recursive:!0});let E=S.join(s,a),X=u.existsSync(E);!e?.overwrite&&X&&(y.warn(`the config '${a}' file already exists for this project.`),r&&process.exit(1));let Z=" ",g="",N={clean:!1,splitting:!0},J=$=>{g+=$==="esm"?`import build from '${n}';
7
+
8
+ `:`const build = require('${n}');
9
+
10
+ `,g+=$==="esm"?`export default build.defineConfigWithIndexEntries({
11
+ `:`module.exports = build.defineConfigWithIndexEntries({
12
+ `,Object.entries(N).forEach(([B,U])=>{g+=`${Z}${B}: ${JSON.stringify(U)},
13
+ `}),g+=`});
14
+ `};switch(o){case".ts":case".js":J("esm");break;case".cjs":J("cjs");break;case".json":g+=`${JSON.stringify({...N,entry:D.defaultEntriesIndex},null,2)}
15
+ `;break;default:y.error(void 0,`unsupported extension: ${o}`),process.exit(1)}u.writeFileSync(E,g),y.success(d.cyan("the config file has been created at:"),d.gray(E))})}catch(o){if(t)throw o;y.error(o,o.message?`failed to generate config file in ${s}: ${o.message}`:`failed to generate config file in ${s}`),r&&process.exit(1)}}export{Se as a,se as b,ie as c,d,y as e,D as f,qe as g};
package/dist/cli.mjs CHANGED
@@ -1,2 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import{a as d,c as J}from"./chunk-UOBRZ36U.mjs";import r from"chalk";import f from"node:fs";import c from"node:path";import{fileURLToPath as M}from"node:url";import{spawn as U}from"node:child_process";import{Command as q}from"commander";var E={name:"tochibuild",version:"2.2.6",description:"An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",repository:"https://github.com/tochiResources/project/tree/main/packages/build/tochibuild.git",license:"MIT",keywords:["bundler","build","typescript","javascript","tsup","esbuild","glob","cli","node","tochi","tochiResources"],bin:"./dist/cli.mjs",scripts:{dev:"tsx cli.ts",copybundler:"copyfiles ./tsup@8.4.0-minified/* ./dist",build:"tsx cli.ts && bun run copybundler","build:release":"bun run build && bun run release",release:"bun publish --access public --no-private"},dependencies:{chalk:"^5.4.1",commander:"^13.1.0",deepmerge:"^4.3.1",tsup:"8.4.0"},devDependencies:{"@types/node":"^22.15.17",copyfiles:"^2.4.1",tsx:"^4.19.4",typescript:"^5.8.3"},main:"dist/index.mjs",types:"dist/index.d.mts",exports:{".":{types:"./dist/index.d.mts",require:"./dist/index.mjs",import:"./dist/index.mjs"},"./utils":{types:"./dist/utils.d.mts",import:"./dist/utils.mjs",require:"./dist/utils.mjs"}},engines:{node:">=18.17.0"},files:["dist"]};var F=M(import.meta.url),L=c.dirname(F),j=c.resolve(process.cwd(),"."),x=j.replace(/\\/g,"/").includes("packages/build"),p=x?void 0:c.join(j,"package.json"),B=p?f.existsSync(p):!1,T=p&&B?f.readFileSync(p,"utf-8"):void 0,a=T?JSON.parse(T):void 0;async function A(u){let R={node:c.join(L,"tsup@8.4.0-minified/cli-node.js")},k=process.cwd(),N=[...[".ts",".js",".cjs",".json"].map(t=>c.join(k,`tochibuild.config${t}`)),...[".ts",".js",".cjs",".json"].map(t=>c.join(k,`tsup.config${t}`))],v=a?.tochibuild,w=a?.tsup,C=!!Object.keys(v||{}).length||!!Object.keys(w||{}).length,g=N.find(t=>f.existsSync(t)),$=C||g,P=new q("tochibuild").name("tochibuild <command>").description("bundle a Node.js project powered by tsup (https://tsup.egoist.dev)").allowUnknownOption(!0).version(E.version).argument("[args...]","arguments to pass to tsup").action(async(...t)=>O(t));P.command("config").description("generate config files").option("--ext <string>","the file extension to use excluding the file extension (defaults to .ts)",".ts").option("-f, --filename <string>","the file name to use (defaults to tochibuild.config)","tochibuild.config").option("-o, --overwrite","whether or not to overwrite the config file if it already exists (defaults to false)",!1).option("--outDir <string...>","the absolute/relative output directory paths to create the config files in (defaults to the working directory)").action(t=>J.generateConfig(u,t,!1,!0)),P.parseAsync(process.argv);async function O(t){let[i]=t;return new Promise((D,l)=>{try{let m="node",e=[],h=i.includes("--config"),S=i.includes("--no-config"),b=h?i.findIndex(s=>s==="--config")+1:void 0;if(!h&&!S&&!$){if(i[0]==null||i[0]?.startsWith("-")){d.custom("error",`${r.red("No input files, try")} '${r.magenta(u)} ${r.gray("[...files]")}' ${r.red("instead")}`),l();return}e.push(...i)}else if(!h&&!S&&$)if(C){let s=v||w;i.filter(n=>n.startsWith("-")).forEach(n=>{let o=i.findIndex(V=>V===n),G=n.startsWith("--")?n.slice(2):n.slice(1);if(s[G]||(e.push(n),e[o+1]?.startsWith("-")))return;let I=e[o+1];I&&e.push(I)}),Object.entries(s).forEach(([n,o])=>{typeof o=="boolean"||o==="true"||o==="false"?o&&e.push(`--${n}`):typeof o=="string"&&e.push(`--${n}`,o)}),e.push("--no-config")}else if(g){let s=c.relative(j,g).replace(/\\/g,"/");d.log(`using existing configuration file: ${r.gray(s)}`),e.push("--config",s),e.push(...i)}else e.push(...i);else{if(b!=null&&b>=0){let s=i[b]||"unspecified";f.existsSync(s)||(d.error(void 0,`config file '${s}' does not exist`),d.info(`try running '${r.magenta(u)} ${r.blue("config")} ${r.gray("-h")}' to get help on how to generate a config file`),process.exit(1))}e.push(...i)}d.log(`running build${x||a?.name?` for ${r.magenta(x?u:a.name)}`:""}...`);let y=U("node",[R[m],...e],{stdio:"inherit",shell:!0,cwd:process.cwd(),env:process.env});y.on("exit",s=>{process.exit(s??1)}),process.on("SIGINT",()=>{l(),y.kill("SIGINT")}),process.on("SIGTERM",()=>{l(),y.kill("SIGTERM")}),D()}catch(m){l(m)}})}}A("@tochii/build");
2
+ import{a as E,b as y,c as xt,d as C,e as x,g as F}from"./chunk-GKH6M3ZR.mjs";var v=y(I=>{"use strict";var S=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},j=class extends S{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};I.CommanderError=S;I.InvalidArgumentError=j});var V=y(q=>{"use strict";var{InvalidArgumentError:wt}=v(),N=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new wt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Et(u){let t=u.name()+(u.variadic===!0?"...":"");return u.required?"<"+t+">":"["+t+"]"}q.Argument=N;q.humanReadableArgName=Et});var L=y(R=>{"use strict";var{humanReadableArgName:vt}=V(),M=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(s=>!s._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((s,n)=>s.name().localeCompare(n.name())),e}compareOptions(t,e){let i=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(s=>!s.hidden),i=t._getHelpOption();if(i&&!i.hidden){let s=i.short&&t._findOption(i.short),n=i.long&&t._findOption(i.long);!s&&!n?e.push(i):i.long&&!n?e.push(t.createOption(i.long,i.description)):i.short&&!s&&e.push(t.createOption(i.short,i.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let s=i.options.filter(n=>!n.hidden);e.push(...s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(i=>vt(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(s)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(s)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let s=t.parent;s;s=s.parent)i=s.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];return t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){let i=e.padWidth(t,e),s=e.helpWidth??80;function n(c,p){return e.formatItem(c,i,p,e)}let r=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(r=r.concat([e.boxWrap(e.styleCommandDescription(a),s),""]));let o=e.visibleArguments(t).map(c=>n(e.styleArgumentTerm(e.argumentTerm(c)),e.styleArgumentDescription(e.argumentDescription(c))));o.length>0&&(r=r.concat([e.styleTitle("Arguments:"),...o,""]));let h=e.visibleOptions(t).map(c=>n(e.styleOptionTerm(e.optionTerm(c)),e.styleOptionDescription(e.optionDescription(c))));if(h.length>0&&(r=r.concat([e.styleTitle("Options:"),...h,""])),e.showGlobalOptions){let c=e.visibleGlobalOptions(t).map(p=>n(e.styleOptionTerm(e.optionTerm(p)),e.styleOptionDescription(e.optionDescription(p))));c.length>0&&(r=r.concat([e.styleTitle("Global Options:"),...c,""]))}let l=e.visibleCommands(t).map(c=>n(e.styleSubcommandTerm(e.subcommandTerm(c)),e.styleSubcommandDescription(e.subcommandDescription(c))));return l.length>0&&(r=r.concat([e.styleTitle("Commands:"),...l,""])),r.join(`
3
+ `)}displayWidth(t){return it(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e==="[command]"?this.styleSubcommandText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,i,s){let r=" ".repeat(2);if(!i)return r+t;let a=t.padEnd(e+t.length-s.displayWidth(t)),o=2,l=(this.helpWidth??80)-e-o-2,c;return l<this.minWidthToWrap||s.preformatted(i)?c=i:c=s.boxWrap(i,l).replace(/\n/g,`
4
+ `+" ".repeat(e+o)),r+a+" ".repeat(o)+c.replace(/\n/g,`
5
+ ${r}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,n=[];return i.forEach(r=>{let a=r.match(s);if(a===null){n.push("");return}let o=[a.shift()],h=this.displayWidth(o[0]);a.forEach(l=>{let c=this.displayWidth(l);if(h+c<=e){o.push(l),h+=c;return}n.push(o.join(""));let p=l.trimStart();o=[p],h=this.displayWidth(p)}),n.push(o.join(""))}),n.join(`
6
+ `)}};function it(u){let t=/\x1b\[\d*(;\d*)*m/g;return u.replace(t,"")}R.Help=M;R.stripColor=it});var J=y(B=>{"use strict";var{InvalidArgumentError:$t}=v(),U=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=St(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return typeof t=="string"&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new $t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?st(this.name().replace(/^no-/,"")):st(this.name())}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},G=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,e){let i=e.attributeName();if(!this.dualOptions.has(i))return!0;let s=this.negativeOptions.get(i).presetArg,n=s!==void 0?s:!1;return e.negate===(n===t)}};function st(u){return u.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}function St(u){let t,e,i=/^-[^-]$/,s=/^--[^-]/,n=u.split(/[ |,]+/).concat("guard");if(i.test(n[0])&&(t=n.shift()),s.test(n[0])&&(e=n.shift()),!t&&i.test(n[0])&&(t=n.shift()),!t&&s.test(n[0])&&(t=e,e=n.shift()),n[0].startsWith("-")){let r=n[0],a=`option creation failed due to '${r}' in option flags '${u}'`;throw/^-[^-][^-]/.test(r)?new Error(`${a}
7
+ - a short flag is a single dash and a single character
8
+ - either use a single dash and a single character (for a short flag)
9
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(r)?new Error(`${a}
10
+ - too many short flags`):s.test(r)?new Error(`${a}
11
+ - too many long flags`):new Error(`${a}
12
+ - unrecognised flag format`)}if(t===void 0&&e===void 0)throw new Error(`option creation failed due to no flags found in '${u}'.`);return{shortFlag:t,longFlag:e}}B.Option=U;B.DualOptions=G});var rt=y(nt=>{"use strict";function Vt(u,t){if(Math.abs(u.length-t.length)>3)return Math.max(u.length,t.length);let e=[];for(let i=0;i<=u.length;i++)e[i]=[i];for(let i=0;i<=t.length;i++)e[0][i]=i;for(let i=1;i<=t.length;i++)for(let s=1;s<=u.length;s++){let n=1;u[s-1]===t[i-1]?n=0:n=1,e[s][i]=Math.min(e[s-1][i]+1,e[s][i-1]+1,e[s-1][i-1]+n),s>1&&i>1&&u[s-1]===t[i-2]&&u[s-2]===t[i-1]&&(e[s][i]=Math.min(e[s][i],e[s-2][i-2]+1))}return e[u.length][t.length]}function kt(u,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let e=u.startsWith("--");e&&(u=u.slice(2),t=t.map(r=>r.slice(2)));let i=[],s=3,n=.4;return t.forEach(r=>{if(r.length<=1)return;let a=Vt(u,r),o=Math.max(u.length,r.length);(o-a)/o>n&&(a<s?(s=a,i=[r]):a===s&&i.push(r))}),i.sort((r,a)=>r.localeCompare(a)),e&&(i=i.map(r=>`--${r}`)),i.length>1?`
13
+ (Did you mean one of ${i.join(", ")}?)`:i.length===1?`
14
+ (Did you mean ${i[0]}?)`:""}nt.suggestSimilar=kt});var ut=y(X=>{"use strict";var Ht=E("node:events").EventEmitter,K=E("node:child_process"),A=E("node:path"),k=E("node:fs"),d=E("node:process"),{Argument:Tt,humanReadableArgName:Pt}=V(),{CommanderError:Y}=v(),{Help:Wt,stripColor:Dt}=L(),{Option:ot,DualOptions:Ft}=J(),{suggestSimilar:at}=rt(),z=class u extends Ht{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>d.stdout.write(e),writeErr:e=>d.stderr.write(e),outputError:(e,i)=>i(e),getOutHelpWidth:()=>d.stdout.isTTY?d.stdout.columns:void 0,getErrHelpWidth:()=>d.stderr.isTTY?d.stderr.columns:void 0,getOutHasColors:()=>Q()??(d.stdout.isTTY&&d.stdout.hasColors?.()),getErrHasColors:()=>Q()??(d.stderr.isTTY&&d.stderr.hasColors?.()),stripColor:e=>Dt(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let s=e,n=i;typeof s=="object"&&s!==null&&(n=s,s=null),n=n||{};let[,r,a]=t.match(/([^ ]+) *(.*)/),o=this.createCommand(r);return s&&(o.description(s),o._executableHandler=!0),n.isDefault&&(this._defaultCommandName=o._name),o._hidden=!!(n.noHelp||n.hidden),o._executableFile=n.executableFile||null,a&&o.arguments(a),this._registerCommand(o),o.parent=this,o.copyInheritedSettings(this),s?this:o}createCommand(t){return new u(t)}createHelp(){return Object.assign(new Wt,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);return e=e||{},e.isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new Tt(t,e)}argument(t,e,i,s){let n=this.createArgument(t,e);return typeof i=="function"?n.default(s).argParser(i):n.default(i),this.addArgument(n),this}arguments(t){return t.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,this;t=t??"help [command]";let[,i,s]=t.match(/([^ ]+) *(.*)/),n=e??"display help for command",r=this.createCommand(i);return r.helpOption(!1),s&&r.arguments(s),n&&r.description(n),this._addImplicitHelpCommand=!0,this._helpCommand=r,this}addHelpCommand(t,e){return typeof t!="object"?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
16
+ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync")throw e},this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new Y(t,e,i)),d.exit(t)}action(t){let e=i=>{let s=this.registeredArguments.length,n=i.slice(0,s);return this._storeOptionsAsProperties?n[s]=this:n[s]=this.opts(),n.push(this),t.apply(this,n)};return this._actionHandler=e,this}createOption(t,e){return new ot(t,e)}_callParseArg(t,e,i,s){try{return t.parseArg(e,i)}catch(n){if(n.code==="commander.invalidArgument"){let r=`${s} ${n.message}`;this.error(r,{exitCode:n.exitCode,code:n.code})}throw n}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
17
+ - already used by option '${e.flags}'`)}this.options.push(t)}_registerCommand(t){let e=s=>[s.name()].concat(s.aliases()),i=e(t).find(s=>this._findCommand(s));if(i){let s=e(this._findCommand(i)).join("|"),n=e(t).join("|");throw new Error(`cannot add command '${n}' as already have command '${s}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);let e=t.name(),i=t.attributeName();if(t.negate){let n=t.long.replace(/^--no-/,"--");this._findOption(n)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let s=(n,r,a)=>{n==null&&t.presetArg!==void 0&&(n=t.presetArg);let o=this.getOptionValue(i);n!==null&&t.parseArg?n=this._callParseArg(t,n,o,r):n!==null&&t.variadic&&(n=t._concatValue(n,o)),n==null&&(t.negate?n=!1:t.isBoolean()||t.optional?n=!0:n=""),this.setOptionValueWithSource(i,n,a)};return this.on("option:"+e,n=>{let r=`error: option '${t.flags}' argument '${n}' is invalid.`;s(n,r,"cli")}),t.envVar&&this.on("optionEnv:"+e,n=>{let r=`error: option '${t.flags}' value '${n}' from env '${t.envVar}' is invalid.`;s(n,r,"env")}),this}_optionEx(t,e,i,s,n){if(typeof e=="object"&&e instanceof ot)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(e,i);if(r.makeOptionMandatory(!!t.mandatory),typeof s=="function")r.default(n).argParser(s);else if(s instanceof RegExp){let a=s;s=(o,h)=>{let l=a.exec(o);return l?l[0]:h},r.default(n).argParser(s)}else r.default(s);return this.addOption(r)}option(t,e,i,s){return this._optionEx({},t,e,i,s)}requiredOption(t,e,i,s){return this._optionEx({mandatory:!0},t,e,i,s)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},t===void 0&&e.from===void 0){d.versions?.electron&&(e.from="electron");let s=d.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(e.from="eval")}t===void 0&&(t=d.argv),this.rawArgs=t.slice();let i;switch(e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":d.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,e,i){if(k.existsSync(t))return;let s=e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",n=`'${t}' does not exist
19
+ - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
+ - ${s}`;throw new Error(n)}_executeSubCommand(t,e){e=e.slice();let i=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function n(l,c){let p=A.resolve(l,c);if(k.existsSync(p))return p;if(s.includes(A.extname(c)))return;let m=s.find(H=>k.existsSync(`${p}${H}`));if(m)return`${p}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let l;try{l=k.realpathSync(this._scriptPath)}catch{l=this._scriptPath}a=A.resolve(A.dirname(l),a)}if(a){let l=n(a,r);if(!l&&!t._executableFile&&this._scriptPath){let c=A.basename(this._scriptPath,A.extname(this._scriptPath));c!==this._name&&(l=n(a,`${c}-${t._name}`))}r=l||r}i=s.includes(A.extname(r));let o;d.platform!=="win32"?i?(e.unshift(r),e=lt(d.execArgv).concat(e),o=K.spawn(d.argv[0],e,{stdio:"inherit"})):o=K.spawn(r,e,{stdio:"inherit"}):(this._checkForMissingExecutable(r,a,t._name),e.unshift(r),e=lt(d.execArgv).concat(e),o=K.spawn(d.execPath,e,{stdio:"inherit"})),o.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(c=>{d.on(c,()=>{o.killed===!1&&o.exitCode===null&&o.kill(c)})});let h=this._exitCallback;o.on("close",l=>{l=l??1,h?h(new Y(l,"commander.executeSubCommandAsync","(close)")):d.exit(l)}),o.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(r,a,t._name);else if(l.code==="EACCES")throw new Error(`'${r}' not executable`);if(!h)d.exit(1);else{let c=new Y(1,"commander.executeSubCommandAsync","(error)");c.nestedError=l,h(c)}}),this.runningCommand=o}_dispatchSubcommand(t,e,i){let s=this._findCommand(t);s||this.help({error:!0}),s._prepareForParse();let n;return n=this._chainOrCallSubCommandHook(n,s,"preSubcommand"),n=this._chainOrCall(n,()=>{if(s._executableHandler)this._executeSubCommand(s,e.concat(i));else return s._parseCommand(e,i)}),n}_dispatchHelpCommand(t){t||this.help();let e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&this.args[e]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(i,s,n)=>{let r=s;if(s!==null&&i.parseArg){let a=`error: command-argument value '${s}' is invalid for argument '${i.name()}'.`;r=this._callParseArg(i,s,n,a)}return r};this._checkNumberOfArguments();let e=[];this.registeredArguments.forEach((i,s)=>{let n=i.defaultValue;i.variadic?s<this.args.length?(n=this.args.slice(s),i.parseArg&&(n=n.reduce((r,a)=>t(i,a,r),i.defaultValue))):n===void 0&&(n=[]):s<this.args.length&&(n=this.args[s],i.parseArg&&(n=t(i,n,i.defaultValue))),e[s]=n}),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&typeof t.then=="function"?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t,s=[];return this._getCommandAndAncestors().reverse().filter(n=>n._lifeCycleHooks[e]!==void 0).forEach(n=>{n._lifeCycleHooks[e].forEach(r=>{s.push({hookedCommand:n,callback:r})})}),e==="postAction"&&s.reverse(),s.forEach(n=>{i=this._chainOrCall(i,()=>n.callback(n.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let s=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(n=>{s=this._chainOrCall(s,()=>n(this,e))}),s}_parseCommand(t,e){let i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(n,t,e)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent&&this.parent.listenerCount(n))s(),this._processArguments(),this.parent.emit(n,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&t.getOptionValue(e.attributeName())===void 0&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let s=i.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let s=t.find(n=>i.conflictsWith.includes(n.attributeName()));s&&this._conflictingOption(i,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let e=[],i=[],s=e,n=t.slice();function r(o){return o.length>1&&o[0]==="-"}let a=null;for(;n.length;){let o=n.shift();if(o==="--"){s===i&&s.push(o),s.push(...n);break}if(a&&!r(o)){this.emit(`option:${a.name()}`,o);continue}if(a=null,r(o)){let h=this._findOption(o);if(h){if(h.required){let l=n.shift();l===void 0&&this.optionMissingArgument(h),this.emit(`option:${h.name()}`,l)}else if(h.optional){let l=null;n.length>0&&!r(n[0])&&(l=n.shift()),this.emit(`option:${h.name()}`,l)}else this.emit(`option:${h.name()}`);a=h.variadic?h:null;continue}}if(o.length>2&&o[0]==="-"&&o[1]!=="-"){let h=this._findOption(`-${o[1]}`);if(h){h.required||h.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${h.name()}`,o.slice(2)):(this.emit(`option:${h.name()}`),n.unshift(`-${o.slice(2)}`));continue}}if(/^--[^=]+=/.test(o)){let h=o.indexOf("="),l=this._findOption(o.slice(0,h));if(l&&(l.required||l.optional)){this.emit(`option:${l.name()}`,o.slice(h+1));continue}}if(r(o)&&(s=i),(this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&i.length===0){if(this._findCommand(o)){e.push(o),n.length>0&&i.push(...n);break}else if(this._getHelpCommand()&&o===this._getHelpCommand().name()){e.push(o),n.length>0&&e.push(...n);break}else if(this._defaultCommandName){i.push(o),n.length>0&&i.push(...n);break}}if(this._passThroughOptions){s.push(o),n.length>0&&s.push(...n);break}s.push(o)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},e=this.options.length;for(let i=0;i<e;i++){let s=this.options[i].attributeName();t[s]=s===this._versionOptionName?this._version:this[s]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}
22
+ `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
+ `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
24
+ `),this.outputHelp({error:!0}));let i=e||{},s=i.exitCode||1,n=i.code||"commander.error";this._exit(s,n,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in d.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,d.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Ft(this.options),e=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(s=>!e(s)).forEach(s=>{this.setOptionValueWithSource(s,i.implied[s],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let i=r=>{let a=r.attributeName(),o=this.getOptionValue(a),h=this.options.find(c=>c.negate&&a===c.attributeName()),l=this.options.find(c=>!c.negate&&a===c.attributeName());return h&&(h.presetArg===void 0&&o===!1||h.presetArg!==void 0&&o===h.presetArg)?h:l||r},s=r=>{let a=i(r),o=a.attributeName();return this.getOptionValueSource(o)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},n=`error: ${s(t)} cannot be used with ${s(e)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let s=[],n=this;do{let r=n.createHelp().visibleOptions(n).filter(a=>a.long).map(a=>a.long);s=s.concat(r),n=n.parent}while(n&&!n._enablePositionalOptions);e=at(t,s)}let i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,i=e===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(n=>{s.push(n.name()),n.alias()&&s.push(n.alias())}),e=at(t,s)}let i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";let s=this.createOption(e,i);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
+ `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let s=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${s}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(i=>Pt(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=A.basename(t,A.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let s=e.formatHelp(this,e);return i.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(t){t=t||{};let e=!!t.error,i,s,n;return e?(i=a=>this._outputConfiguration.writeErr(a),s=this._outputConfiguration.getErrHasColors(),n=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),s=this._outputConfiguration.getOutHasColors(),n=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(s||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:s,helpWidth:n}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let i=this._getOutputContext(t),s={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let n=this.helpInformation({error:i.error});if(e&&(n=e(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",s))}helpOption(t,e){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",e=e??"display help for command",this._helpOption=this.createOption(t,e),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let e=Number(d.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
+ Expecting one of '${i.join("', '")}'`);let s=`${t}Help`;return this.on(s,n=>{let r;typeof e=="function"?r=e({error:n.error,command:n.command}):r=e,r&&n.write(`${r}
27
+ `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(s=>e.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function lt(u){return u.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",s="9229",n;return(n=t.match(/^(--inspect(-brk)?)$/))!==null?e=n[1]:(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=n[1],/^\d+$/.test(n[3])?s=n[3]:i=n[3]):(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=n[1],i=n[3],s=n[4]),e&&s!=="0"?`${e}=${i}:${parseInt(s)+1}`:t})}function Q(){if(d.env.NO_COLOR||d.env.FORCE_COLOR==="0"||d.env.FORCE_COLOR==="false")return!1;if(d.env.FORCE_COLOR||d.env.CLICOLOR_FORCE!==void 0)return!0}X.Command=z;X.useColor=Q});var pt=y(_=>{"use strict";var{Argument:ht}=V(),{Command:Z}=ut(),{CommanderError:jt,InvalidArgumentError:ct}=v(),{Help:It}=L(),{Option:dt}=J();_.program=new Z;_.createCommand=u=>new Z(u);_.createOption=(u,t)=>new dt(u,t);_.createArgument=(u,t)=>new ht(u,t);_.Command=Z;_.Option=dt;_.Argument=ht;_.Help=It;_.CommanderError=jt;_.InvalidArgumentError=ct;_.InvalidOptionArgumentError=ct});import _t from"node:fs";import w from"node:path";import{fileURLToPath as qt}from"node:url";import{spawn as Mt}from"node:child_process";var mt=xt(pt(),1),{program:Qt,createCommand:Xt,createArgument:Zt,createOption:te,CommanderError:ee,InvalidArgumentError:ie,InvalidOptionArgumentError:se,Command:ft,Argument:ne,Option:re,Help:oe}=mt.default;var gt={name:"tochibuild",version:"2.3.0",description:"An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",repository:"https://github.com/tochiResources/project/tree/main/packages/build/tochibuild.git",license:"MIT",keywords:["bundler","build","typescript","javascript","tsup","esbuild","glob","cli","node","tochi","tochiResources"],bin:"./dist/cli.mjs",scripts:{dev:"tsx cli.ts",copybundler:"copyfiles ./tsup@8.4.0-minified/* ./dist",build:"tsx cli.ts && bun run copybundler","build:release":"bun run build && bun run release",release:"bun publish --access public --no-private"},dependencies:{chalk:"^5.4.1",commander:"^13.1.0",deepmerge:"^4.3.1",tsup:"8.4.0"},devDependencies:{"@types/node":"^22.15.17",copyfiles:"^2.4.1",tsx:"^4.19.4",typescript:"^5.8.3"},main:"dist/index.mjs",types:"dist/index.d.mts",exports:{".":{types:"./dist/index.d.mts",require:"./dist/index.mjs",import:"./dist/index.mjs"},"./utils":{types:"./dist/utils.d.mts",import:"./dist/utils.mjs",require:"./dist/utils.mjs"}},engines:{node:">=18.17.0"},files:["dist"]};var Rt=qt(import.meta.url),Lt=w.dirname(Rt),Ct=w.resolve(process.cwd(),"."),Ot=Ct.replace(/\\/g,"/").includes("packages/build");async function bt(u){let t={node:w.join(Lt,"tsup@8.4.0-minified/cli-node.js")},e=process.cwd(),i=[...[".ts",".js",".cjs",".json"].map(p=>w.join(e,`tochibuild.config${p}`)),...[".ts",".js",".cjs",".json"].map(p=>w.join(e,`tsup.config${p}`))],s=F.getPackageJson(),n=s.data?.tochibuild,r=s.data?.tsup,a=!!Object.keys(n||{}).length||!!Object.keys(r||{}).length,o=i.find(p=>_t.existsSync(p)),h=a||o,l=new ft("tochibuild").name("tochibuild <command>").description("bundle a Node.js project powered by tsup (https://tsup.egoist.dev)").allowUnknownOption(!0).version(gt.version).argument("[args...]","arguments to pass to tsup").action(async(...p)=>c(p));l.command("config").description("generate config files").option("--ext <string>","the file extension to use excluding the file extension (defaults to .ts)",".ts").option("-f, --filename <string>","the file name to use (defaults to tochibuild.config)","tochibuild.config").option("-o, --overwrite","whether or not to overwrite the config file if it already exists (defaults to false)",!1).option("--outDir <string...>","the absolute/relative output directory paths to create the config files in (defaults to the working directory)").action(p=>F.generateConfig(u,p,!1,!0)),l.parseAsync(process.argv);async function c(p){let[m]=p;return new Promise((H,$)=>{try{let T="node",f=[],P=m.includes("--config"),tt=m.includes("--no-config"),W=P?m.findIndex(g=>g==="--config")+1:void 0;if(!P&&!tt&&!h){if(m[0]==null||m[0]?.startsWith("-")){x.custom("error",`${C.red("No input files, try")} '${C.magenta(u)} ${C.gray("[...files]")}' ${C.red("instead")}`),$();return}f.push(...m)}else if(!P&&!tt&&h)if(a){let g=n||r;m.filter(O=>O.startsWith("-")).forEach(O=>{let b=m.findIndex(yt=>yt===O),At=O.startsWith("--")?O.slice(2):O.slice(1);if(g[At]||(f.push(O),f[b+1]?.startsWith("-")))return;let et=f[b+1];et&&f.push(et)}),Object.entries(g).forEach(([O,b])=>{typeof b=="boolean"||b==="true"||b==="false"?b&&f.push(`--${O}`):typeof b=="string"&&f.push(`--${O}`,b)}),f.push("--no-config")}else if(o){let g=w.relative(Ct,o).replace(/\\/g,"/");x.log(`using existing configuration file: ${C.gray(g)}`),f.push("--config",g),f.push(...m)}else f.push(...m);else{if(W!=null&&W>=0){let g=m[W]||"unspecified";_t.existsSync(g)||(x.error(void 0,`config file '${g}' does not exist`),x.info(`try running '${C.magenta(u)} ${C.blue("config")} ${C.gray("-h")}' to get help on how to generate a config file`),process.exit(1))}f.push(...m)}x.log(`running build${Ot||s.data?.name?` for ${C.magenta(Ot?u:s.data.name)}`:""}...`);let D=Mt("node",[t[T],...f],{stdio:"inherit",shell:!0,cwd:process.cwd(),env:process.env});D.on("exit",g=>{process.exit(g??1)}),process.on("SIGINT",()=>{$(),D.kill("SIGINT")}),process.on("SIGTERM",()=>{$(),D.kill("SIGTERM")}),H()}catch(T){$(T)}})}}bt("@tochii/build");
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as tsup from 'tsup';
2
- import { B as BuildUtils$1, c as BuildOptionsParams } from './utils-BMzAmbjm.mjs';
2
+ import { B as BuildUtils$1 } from './utils-dsfZeRyj.mjs';
3
3
 
4
4
  type DefineConfigOptions = BuildOptionsParams<'entry' | 'clean' | 'splitting'>;
5
5
  type DefineConfigOptionsIndexEntries = BuildOptionsParams<'clean' | 'splitting'>;
package/dist/index.mjs CHANGED
@@ -1 +1,44 @@
1
- import{c as n}from"./chunk-UOBRZ36U.mjs";import{defineConfig as t}from"tsup";var l=n,e={utils:n,defineConfig:o,defineConfigWithIndexEntries:r,defineConfigWithCommonEntries:f};function o(i){return t(n.defaultOptions(i))}function r(i){return t(n.defaultOptionsWithIndexEntries(i))}function f(i){return t(n.defaultOptionsWithCommonEntries(i))}var a=e;export{l as BuildUtils,a as default,o as defineConfig,f as defineConfigWithCommonEntries,r as defineConfigWithIndexEntries};
1
+ import{a as m,b as L,c as Ie,g as q}from"./chunk-GKH6M3ZR.mjs";var me=L(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});var Be="8.4.0";V.version=Be});var se=L(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});function Q(e){return e&&e.__esModule?e:{default:e}}function X(e){let t,r=e[0],n=1;for(;n<e.length;){let s=e[n],i=e[n+1];if(n+=2,(s==="optionalAccess"||s==="optionalCall")&&r==null)return;s==="access"||s==="optionalAccess"?(t=r,r=i(r)):(s==="call"||s==="optionalCall")&&(r=i((...o)=>r.call(t,...o)),t=void 0)}return r}var We=Object.create,ge=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty,ve=(e=>typeof m<"u"?m:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof m<"u"?m:t)[r]}):e)(function(e){if(typeof m<"u")return m.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),He=(e,t)=>function(){return t||(0,e[ye(e)[0]])((t={exports:{}}).exports,t),t.exports},Ye=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ye(t))!Ue.call(e,s)&&s!==r&&ge(e,s,{get:()=>t[s],enumerable:!(n=Je(t,s))||n.enumerable});return e},Ge=(e,t,r)=>(r=e!=null?We(ze(e)):{},Ye(t||!e||!e.__esModule?ge(r,"default",{value:e,enumerable:!0}):r,e)),Ke=m("fs"),T=Q(Ke),Ve=m("path"),D=Q(Ve),Ze=m("resolve-from"),Xe=Q(Ze),Z=Symbol("singleComment"),he=Symbol("multiComment"),Qe=()=>"",et=(e,t,r)=>e.slice(t,r).replace(/\S/g," "),tt=(e,t)=>{let r=t-1,n=0;for(;e[r]==="\\";)r-=1,n+=1;return!!(n%2)};function rt(e,{whitespace:t=!0,trailingCommas:r=!1}={}){if(typeof e!="string")throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let n=t?et:Qe,s=!1,i=!1,o=0,a="",u="",c=-1;for(let l=0;l<e.length;l++){let f=e[l],h=e[l+1];if(!i&&f==='"'&&(tt(e,l)||(s=!s)),!s)if(!i&&f+h==="//")a+=e.slice(o,l),o=l,i=Z,l++;else if(i===Z&&f+h===`\r
2
+ `){l++,i=!1,a+=n(e,o,l),o=l;continue}else if(i===Z&&f===`
3
+ `)i=!1,a+=n(e,o,l),o=l;else if(!i&&f+h==="/*"){a+=e.slice(o,l),o=l,i=he,l++;continue}else if(i===he&&f+h==="*/"){l++,i=!1,a+=n(e,o,l+1),o=l+1;continue}else r&&!i&&(c!==-1?f==="}"||f==="]"?(a+=e.slice(o,l),u+=n(a,0,1)+a.slice(1),a="",o=l,c=-1):f!==" "&&f!==" "&&f!=="\r"&&f!==`
4
+ `&&(a+=e.slice(o,l),o=l,c=-1):f===","&&(u+=a+e.slice(o,l),a="",o=l,c=l))}return u+a+(i?n(e.slice(o)):e.slice(o))}var ee=m("tinyglobby");function st(){return te("postcss")}function nt(){return te("@microsoft/api-extractor")}function te(e){let t=Xe.default.silent(process.cwd(),e);return t&&ve(t)}async function it(e,t){(await ee.glob.call(void 0,e,{cwd:t,absolute:!0})).forEach(n=>T.default.existsSync(n)&&T.default.unlinkSync(n))}function at(e,t,r){let n,s,i;return function o(...a){s?i=()=>{o(...a),i=void 0}:(n!=null&&clearTimeout(n),n=setTimeout(()=>{n=void 0,s=e(...a).catch(r).finally(()=>{s=void 0,i&&i()})},t))}}function we(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function ot(e){return!!e}function lt(e){try{return new Function(`return ${rt(e).trim()}`)()}catch{return{}}}function ct({format:e,pkgType:t}){let r=".js",n=".d.ts",s=t==="module";return s&&e==="cjs"&&(r=".cjs",n=".d.cts"),!s&&e==="esm"&&(r=".mjs",n=".d.mts"),e==="iife"&&(r=".global.js"),{js:r,dts:n}}function ut(){let e=process.cwd(),t=D.default.join(e,".tsup","declaration");if(T.default.existsSync(t))return t;T.default.mkdirSync(t,{recursive:!0});let r=D.default.join(e,".tsup",".gitignore");return xe(r,`**/*
5
+ `),t}var ft=e=>{if(typeof e=="string"&&(e=[e]),!Array.isArray(e))return e;e=e.map(r=>r.replace(/\\/g,"/"));let t=dt(e);return e.reduce((r,n)=>{let s=n.replace(t,"").replace(/^\//,"").replace(/\.[a-z]+$/,"");return{...r,[s]:n}},{})},dt=e=>{if(e.length<=1)return"";let[t,...r]=e,n=t.split("/");for(let s of r){let i=s.split("/",n.length),o=0;for(let a of i)if(a===n[o])o+=1;else{n=n.slice(0,o);break}n=n.slice(0,o)}return n.length<=1&&n[0]===""?`/${n[0]}`:n.join("/")};function pt(e,t){return D.default.isAbsolute(e)?e:we(D.default.normalize(D.default.join(t||process.cwd(),e)))}function xe(e,t){T.default.mkdirSync(D.default.dirname(e),{recursive:!0}),T.default.writeFileSync(e,t)}function mt(e){return e.replace(/\.d\.(ts|mts|cts)$/,(t,r)=>{switch(r){case"ts":return".js";case"mts":return".mjs";case"cts":return".cjs";default:return""}})}var re=e=>Object.fromEntries(e.map(r=>[D.default.posix.join(...r.split(D.default.posix.sep).slice(1,-1).concat(D.default.parse(r).name)),r])),Ee=async e=>typeof e=="string"||Array.isArray(e)?re(await ee.glob.call(void 0,e)):e,ht=async(e,t)=>{let r=await Ee(X([e,"access",i=>i.experimentalDts,"optionalAccess",i=>i.entry])||e.entry),n=Object.keys(r).length===0?Array.isArray(e.entry)?re(e.entry):e.entry:r;return{compilerOptions:{...t.data.compilerOptions||{},...X([e,"access",i=>i.experimentalDts,"optionalAccess",i=>i.compilerOptions])||{}},entry:n}},gt=async e=>{if(e!=null)return typeof e=="boolean"?e?{entry:{}}:void 0:typeof e=="string"?{entry:re(await ee.glob.call(void 0,e))}:{...e,entry:X([e,"optionalAccess",t=>t.entry])==null?{}:await Ee(e.entry)}};y.__require=ve;y.__commonJS=He;y.__toESM=Ge;y.getPostcss=st;y.getApiExtractor=nt;y.localRequire=te;y.removeFiles=it;y.debouncePromise=at;y.slash=we;y.truthy=ot;y.jsoncParse=lt;y.defaultOutExtension=ct;y.ensureTempDeclarationDir=ut;y.toObjectEntry=ft;y.toAbsolutePath=pt;y.writeFileSync=xe;y.replaceDtsWithJsExtensions=mt;y.resolveExperimentalDtsConfig=ht;y.resolveInitialExperimentalDtsConfig=gt});var Ce=L($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});function B(e){return e&&e.__esModule?e:{default:e}}function Pe(e){let t,r=e[0],n=1;for(;n<e.length;){let s=e[n],i=e[n+1];if(n+=2,(s==="optionalAccess"||s==="optionalCall")&&r==null)return;s==="access"||s==="optionalAccess"?(t=r,r=i(r)):(s==="call"||s==="optionalCall")&&(r=i((...o)=>r.call(t,...o)),t=void 0)}return r}var yt=se(),vt=m("fs"),wt=B(vt),xt=m("path"),ie=B(xt),Et=m("joycon"),je=B(Et),Pt=m("bundle-require"),ne=new je.default,be=async e=>{try{return yt.jsoncParse.call(void 0,await wt.default.promises.readFile(e,"utf8"))}catch(t){throw t instanceof Error?new Error(`Failed to parse ${ie.default.relative(process.cwd(),e)}: ${t.message}`):t}},_t={test:/\.json$/,load(e){return be(e)}};ne.addLoader(_t);async function jt(e,t){let n=await new je.default().resolve({files:t?[t]:["tsup.config.ts","tsup.config.cts","tsup.config.mts","tsup.config.js","tsup.config.cjs","tsup.config.mjs","tsup.config.json","package.json"],cwd:e,stopDir:ie.default.parse(e).root,packageKey:"tsup"});if(n){if(n.endsWith(".json")){let i=await be(n);return n.endsWith("package.json")&&(i=i.tsup),i?{path:n,data:i}:{}}let s=await Pt.bundleRequire.call(void 0,{filepath:n});return{path:n,data:s.mod.tsup||s.mod.default||s.mod}}return{}}async function ae(e,t=!1){t&&ne.clearCache();let{data:r}=await ne.load(["package.json"],e,ie.default.dirname(e));return r||{}}async function bt(e,t=!1){let r=await ae(e,t);return Array.from(new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.peerDependencies||{})]))}async function Ot(e){let t=await ae(e,!0);return JSON.stringify({...t.dependencies,...t.peerDependencies,...t.devDependencies})}var Ct=m("util"),_e=B(Ct),J=m("worker_threads"),St=m("picocolors"),I=B(St),Oe=(e,t,r=!1)=>{if(r&&(e==="info"||e==="success"))return t;let n=e==="info"?"blue":e==="error"?"red":e==="warn"?"yellow":"green";return I.default[n](t)},$t=(e,t,r)=>[e&&`${I.default.dim("[")}${e.toUpperCase()}${I.default.dim("]")}`,Oe(r,t.toUpperCase())].filter(Boolean).join(" "),oe=!1;function Dt(e){oe=!!e}function kt(){return oe}var At=e=>({setName(t){e=t},success(t,...r){return this.log(t,"success",...r)},info(t,...r){return this.log(t,"info",...r)},error(t,...r){return this.log(t,"error",...r)},warn(t,...r){return this.log(t,"warn",...r)},log(t,r,...n){let s=[$t(e,t,r),...n.map(i=>Oe(r,i,!0))];switch(r){case"error":{if(!J.isMainThread){Pe([J.parentPort,"optionalAccess",i=>i.postMessage,"call",i=>i({type:"error",text:_e.default.format(...s)})]);return}return console.error(...s)}default:if(oe)return;if(!J.isMainThread){Pe([J.parentPort,"optionalAccess",i=>i.postMessage,"call",i=>i({type:"log",text:_e.default.format(...s)})]);return}console.log(...s)}}}),Mt=e=>{if(e===0)return"0 B";let t=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**r).toFixed(2)} ${t[r]}`},Ft=e=>e.reduce((t,r)=>Math.max(t,r.length),0),qt=(e,t)=>e+" ".repeat(t-e.length),Tt=(e,t,r)=>{let n=Object.keys(r),s=Ft(n)+1;for(let i of n)e.success(t,`${I.default.bold(qt(i,s))}${I.default.green(Mt(r[i]))}`)};$.loadTsupConfig=jt;$.loadPkg=ae;$.getProductionDeps=bt;$.getAllDepsHash=Ot;$.setSilent=Dt;$.getSilent=kt;$.createLogger=At;$.reportSize=Tt});var $e=L(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});function Nt(e){return e&&e.__esModule?e:{default:e}}var le=m("worker_threads"),Rt=m("picocolors"),N=Nt(Rt),Se=class extends Error{constructor(e){super(e),this.name=this.constructor.name,typeof Error.captureStackTrace=="function"?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}};function Lt(e){e.loc&&console.error(N.default.bold(N.default.red(`Error parsing: ${e.loc.file}:${e.loc.line}:${e.loc.column}`))),e.frame?(console.error(N.default.red(e.message)),console.error(N.default.dim(e.frame))):e instanceof Se?console.error(N.default.red(e.message)):console.error(N.default.red(e.stack)),process.exitCode=1,!le.isMainThread&&le.parentPort&&le.parentPort.postMessage("error")}z.PrettyError=Se;z.handleError=Lt});var Re=L(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});function qe(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function W(e){return e&&e.__esModule?e:{default:e}}function It(e,t){return e??t()}function x(e){let t,r=e[0],n=1;for(;n<e.length;){let s=e[n],i=e[n+1];if(n+=2,(s==="optionalAccess"||s==="optionalCall")&&r==null)return;s==="access"||s==="optionalAccess"?(t=r,r=i(r)):(s==="call"||s==="optionalCall")&&(r=i((...o)=>r.call(t,...o)),t=void 0)}return r}var ce,Bt=me(),j=Ce(),k=$e(),p=se(),Te=m("path"),d=W(Te),Wt=m("fs"),C=W(Wt),Jt=m("worker_threads"),A=m("bundle-require"),zt=m("tinyexec"),de=m("tinyglobby"),Ut=m("tree-kill"),Ht=W(Ut),H=m("esbuild"),Yt=m("consola"),Gt=W(Yt),Kt=()=>{let e="node:";return{name:"node-protocol-plugin",setup({onResolve:t}){t({filter:/^node:/},({path:r})=>({path:r.slice(e.length),external:!0}))}}},Vt=/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/,Zt=({external:e,noExternal:t,skipNodeModulesBundle:r,tsconfigResolvePaths:n})=>({name:"external",setup(s){if(r){let i=A.tsconfigPathsToRegExp.call(void 0,n||{});s.onResolve({filter:/.*/},o=>{if(!A.match.call(void 0,o.path,i)&&!A.match.call(void 0,o.path,t)){if(A.match.call(void 0,o.path,e))return{external:!0};if(!Vt.test(o.path))return{path:o.path,external:!0}}})}else s.onResolve({filter:/.*/},i=>{if(!A.match.call(void 0,i.path,t)&&A.match.call(void 0,i.path,e))return{external:!0}})}}),Xt=({css:e,inject:t,cssLoader:r})=>({name:"postcss",setup(n){let s,i=async()=>{let o=p.__require.call(void 0,"postcss-load-config");if(s)return s;try{let a=await o({},process.cwd());return s=a,a}catch(a){if(a.message.includes("No PostCSS Config found in"))return{plugins:[],options:{}};throw a}};n.onResolve({filter:/^#style-inject$/},()=>({path:"#style-inject",namespace:"#style-inject"})),n.onLoad({filter:/^#style-inject$/,namespace:"#style-inject"},()=>({contents:`
6
+ export default function styleInject(css, { insertAt } = {}) {
7
+ if (!css || typeof document === 'undefined') return
8
+
9
+ const head = document.head || document.getElementsByTagName('head')[0]
10
+ const style = document.createElement('style')
11
+ style.type = 'text/css'
12
+
13
+ if (insertAt === 'top') {
14
+ if (head.firstChild) {
15
+ head.insertBefore(style, head.firstChild)
16
+ } else {
17
+ head.appendChild(style)
18
+ }
19
+ } else {
20
+ head.appendChild(style)
21
+ }
22
+
23
+ if (style.styleSheet) {
24
+ style.styleSheet.cssText = css
25
+ } else {
26
+ style.appendChild(document.createTextNode(css))
27
+ }
28
+ }
29
+ `,loader:"js"})),n.onLoad({filter:/\.css$/},async o=>{let a;e&&o.path.endsWith(".svelte.css")?a=e.get(o.path):a=await C.default.promises.readFile(o.path,"utf8");let{plugins:u,options:c}=await i();if(u&&u.length>0){let l=p.getPostcss.call(void 0);if(!l)return{errors:[{text:"postcss is not installed"}]};a=(await x([l,"optionalAccess",h=>h.default,"call",h=>h(u),"access",h=>h.process,"call",h=>h(a,{...c,from:o.path})])).css}return t?(a=(await H.transform.call(void 0,a,{minify:n.initialOptions.minify,minifyIdentifiers:n.initialOptions.minifyIdentifiers,minifySyntax:n.initialOptions.minifySyntax,minifyWhitespace:n.initialOptions.minifyWhitespace,logLevel:n.initialOptions.logLevel,loader:"css"})).code,a=typeof t=="function"?await t(JSON.stringify(a),o.path):`import styleInject from '#style-inject';styleInject(${JSON.stringify(a)})`,{contents:a,loader:"js"}):{contents:a,loader:It(r,()=>"css")}})}}),De=e=>e.replace(/\.svelte$/,".svelte.css"),Qt=({css:e})=>({name:"svelte",setup(t){let r,n;t.onResolve({filter:/\.svelte\.css$/},s=>({path:d.default.relative(process.cwd(),d.default.join(s.resolveDir,s.path)),namespace:"svelte-css"})),t.onLoad({filter:/\.svelte$/},async s=>{if(r=r||p.localRequire.call(void 0,"svelte/compiler"),n=n||p.localRequire.call(void 0,"svelte-preprocess"),!r)return{errors:[{text:'You need to install "svelte" in your project'}]};let i=({message:u,start:c,end:l})=>{let f;if(c&&l){let h=o.split(/\r\n|\r|\n/g)[c.line-1],g=c.line===l.line?l.column:h.length;f={file:a,line:c.line,column:c.column,length:g-c.column,lineText:h}}return{text:u,location:f}},o=await C.default.promises.readFile(s.path,"utf8"),a=d.default.relative(process.cwd(),s.path);try{let u=await r.preprocess(o,n?n({sourceMap:!0,typescript:{compilerOptions:{verbatimModuleSyntax:!0}}}):{async script({content:f,attributes:h}){if(h.lang!=="ts")return{code:f};let{code:g,map:E}=await H.transform.call(void 0,f,{sourcefile:s.path,loader:"ts",sourcemap:!0,tsconfigRaw:{compilerOptions:{verbatimModuleSyntax:!0}},logLevel:t.initialOptions.logLevel});return{code:g,map:E}}},{filename:s.path}),c=r.compile(u.code,{filename:a,css:"external"}),l=c.js.code;if(e&&c.css&&c.css.code){let f=De(a);e.set(f,c.css.code),l=`import '${De(d.default.basename(s.path))}';${l}`}return{contents:l,warnings:c.warnings.map(i)}}catch(u){return{errors:[i(u)]}}})}}),er=({logger:e})=>({name:"swc",setup(t){let r=p.localRequire.call(void 0,"@swc/core");if(!r){e.warn(t.initialOptions.format,"You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin");return}t.initialOptions.keepNames=!0,t.onLoad({filter:/\.[jt]sx?$/},async n=>{let i={parser:{syntax:/\.tsx?$/.test(n.path)?"typescript":"ecmascript",decorators:!0},transform:{legacyDecorator:!0,decoratorMetadata:!0},keepClassNames:!0,target:"es2022"},o=await r.transformFile(n.path,{jsc:i,sourceMaps:!0,configFile:!1,swcrc:!1}),a=o.code;if(o.map){let u=JSON.parse(o.map);u.sources=u.sources.map(c=>d.default.isAbsolute(c)?d.default.relative(d.default.dirname(n.path),c):c),a+=`//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(u)).toString("base64")}`}return{contents:a}})}}),tr=()=>({name:"native-node-modules",setup(e){e.onResolve({filter:/\.node$/,namespace:"file"},r=>{let n=p.__require.resolve(r.path,{paths:[r.resolveDir]});return n.endsWith(".node")?{path:n,namespace:"node-file"}:{path:n}}),e.onLoad({filter:/.*/,namespace:"node-file"},r=>({contents:`
30
+ import path from ${JSON.stringify(r.path)}
31
+ try { module.exports = require(path) }
32
+ catch {}
33
+ `,resolveDir:d.default.dirname(r.path)})),e.onResolve({filter:/\.node$/,namespace:"node-file"},r=>({path:r.path,namespace:"file"}));let t=e.initialOptions;t.loader=t.loader||{},t.loader[".node"]="file"}}),rr=(e,t,r)=>{let n=e.outExtension||p.defaultOutExtension,s=p.defaultOutExtension.call(void 0,{format:t,pkgType:r});return{".js":n({options:e,format:t,pkgType:r}).js||s.js}},sr=async e=>{let t=[];for(let r of e){if(typeof r!="string"||!r.endsWith("package.json")){t.push(r);continue}let n=d.default.isAbsolute(r)?d.default.dirname(r):d.default.dirname(d.default.resolve(process.cwd(),r)),s=await j.getProductionDeps.call(void 0,n);t.push(...s)}return t};async function nr(e,{format:t,css:r,logger:n,buildDependencies:s,pluginContainer:i}){let o=await j.loadPkg.call(void 0,process.cwd()),u=[...(await j.getProductionDeps.call(void 0,process.cwd())).map(v=>new RegExp(`^${v}($|\\/|\\\\)`)),...await sr(e.external||[])],c=e.outDir,l=rr(e,t,o.type),f={...e.env};e.replaceNodeEnv&&(f.NODE_ENV=e.minify||e.minifyWhitespace?"production":"development"),n.info(t,"Build start");let h=Date.now(),g,E=t==="iife"?!1:typeof e.splitting=="boolean"?e.splitting:t==="esm",b=e.platform||"node",S=e.loader||{},F=e.shims;i.setContext({format:t,splitting:E,options:e,logger:n}),await i.buildStarted();let R=[t==="cjs"&&e.removeNodeProtocol&&Kt(),{name:"modify-options",setup(v){i.modifyEsbuildOptions(v.initialOptions),e.esbuildOptions&&e.esbuildOptions(v.initialOptions,{format:t})}},t!=="iife"&&Zt({external:u,noExternal:e.noExternal,skipNodeModulesBundle:e.skipNodeModulesBundle,tsconfigResolvePaths:e.tsconfigResolvePaths}),e.tsconfigDecoratorMetadata&&er({logger:n}),tr(),Xt({css:r,inject:e.injectStyle,cssLoader:S[".css"]}),Qt({css:r}),...e.esbuildPlugins||[]],P=typeof e.banner=="function"?e.banner({format:t}):e.banner,O=typeof e.footer=="function"?e.footer({format:t}):e.footer;try{g=await H.build.call(void 0,{entryPoints:e.entry,format:t==="cjs"&&E||e.treeshake?"esm":t,bundle:typeof e.bundle>"u"?!0:e.bundle,platform:b,globalName:e.globalName,jsxFactory:e.jsxFactory,jsxFragment:e.jsxFragment,sourcemap:e.sourcemap?"external":!1,target:e.target,banner:P,footer:O,tsconfig:e.tsconfig,loader:{".aac":"file",".css":"file",".eot":"file",".flac":"file",".gif":"file",".jpeg":"file",".jpg":"file",".mp3":"file",".mp4":"file",".ogg":"file",".otf":"file",".png":"file",".svg":"file",".ttf":"file",".wav":"file",".webm":"file",".webp":"file",".woff":"file",".woff2":"file",...S},mainFields:b==="node"?["module","main"]:["browser","module","main"],plugins:R.filter(p.truthy),define:{TSUP_FORMAT:JSON.stringify(t),...t==="cjs"&&F?{"import.meta.url":"importMetaUrl"}:{},...e.define,...Object.keys(f).reduce((v,_)=>{let w=JSON.stringify(f[_]);return{...v,[`process.env.${_}`]:w,[`import.meta.env.${_}`]:w}},{})},inject:[t==="cjs"&&F?d.default.join(__dirname,"../assets/cjs_shims.js"):"",t==="esm"&&F&&b==="node"?d.default.join(__dirname,"../assets/esm_shims.js"):"",...e.inject||[]].filter(Boolean),outdir:e.legacyOutput&&t!=="cjs"?d.default.join(c,t):c,outExtension:e.legacyOutput?void 0:l,write:!1,splitting:E,logLevel:"error",minify:e.minify==="terser"?!1:e.minify,minifyWhitespace:e.minifyWhitespace,minifyIdentifiers:e.minifyIdentifiers,minifySyntax:e.minifySyntax,keepNames:e.keepNames,pure:typeof e.pure=="string"?[e.pure]:e.pure,metafile:!0})}catch(v){throw n.error(t,"Build failed"),v}if(g&&g.warnings&&!j.getSilent.call(void 0)){let v=g.warnings.filter(w=>!(w.text.includes('This call to "require" will not be bundled because')||w.text.includes('Indirect calls to "require" will not be bundled')));(await H.formatMessages.call(void 0,v,{kind:"warning",color:!0})).forEach(w=>{Gt.default.warn(w)})}if(g&&g.outputFiles){await i.buildFinished({outputFiles:g.outputFiles,metafile:g.metafile});let v=Date.now()-h;n.success(t,`\u26A1\uFE0F Build success in ${Math.floor(v)}ms`)}if(g.metafile){for(let v of Object.keys(g.metafile.inputs))s.add(v);if(e.metafile){let v=d.default.resolve(c,`metafile-${t}.json`);await C.default.promises.mkdir(d.default.dirname(v),{recursive:!0}),await C.default.promises.writeFile(v,JSON.stringify(g.metafile),"utf8")}}}var ir=()=>({name:"shebang",renderChunk(e,t){t.type==="chunk"&&/\.(cjs|js|mjs)$/.test(t.path)&&t.code.startsWith("#!")&&(t.mode=493)}}),ar=()=>({name:"cjs-splitting",async renderChunk(e,t){if(!this.splitting||this.options.treeshake||this.format!=="cjs"||t.type!=="chunk"||!/\.(js|cjs)$/.test(t.path))return;let{transform:r}=await Promise.resolve().then(()=>qe(m("sucrase"))),n=r(e,{filePath:t.path,transforms:["imports"],sourceMapOptions:this.options.sourcemap?{compiledFilename:t.path}:void 0});return{code:n.code,map:n.sourceMap}}}),ue=m("source-map"),ke=async(e,t,r)=>{await C.default.promises.mkdir(d.default.dirname(e),{recursive:!0}),await C.default.promises.writeFile(e,t,r)};function Ne(e,t){if(C.default.existsSync(e)){C.default.mkdirSync(t,{recursive:!0});for(let r of C.default.readdirSync(e)){let n=d.default.resolve(e,r);if(n===t)continue;let s=d.default.resolve(t,r);C.default.statSync(n).isDirectory()?Ne(n,s):C.default.copyFileSync(n,s)}}}var Ae=e=>typeof e=="string"?JSON.parse(e):e,or=e=>/\.(js|mjs|cjs)$/.test(e),Me=e=>/\.css$/.test(e),lr=class{constructor(e){this.plugins=e}setContext(e){this.context=e}getContext(){if(!this.context)throw new Error("Plugin context is not set");return this.context}modifyEsbuildOptions(e){for(let t of this.plugins)t.esbuildOptions&&t.esbuildOptions.call(this.getContext(),e)}async buildStarted(){for(let e of this.plugins)e.buildStart&&await e.buildStart.call(this.getContext())}async buildFinished({outputFiles:e,metafile:t}){let r=e.filter(s=>!s.path.endsWith(".map")).map(s=>{if(or(s.path)||Me(s.path)){let i=p.slash.call(void 0,d.default.relative(process.cwd(),s.path)),o=x([t,"optionalAccess",a=>a.outputs,"access",a=>a[i]]);return{type:"chunk",path:s.path,code:s.text,map:x([e,"access",a=>a.find,"call",a=>a(u=>u.path===`${s.path}.map`),"optionalAccess",a=>a.text]),entryPoint:x([o,"optionalAccess",a=>a.entryPoint]),exports:x([o,"optionalAccess",a=>a.exports]),imports:x([o,"optionalAccess",a=>a.imports])}}else return{type:"asset",path:s.path,contents:s.contents}}),n=[];await Promise.all(r.map(async s=>{for(let a of this.plugins)if(s.type==="chunk"&&a.renderChunk){let u=await a.renderChunk.call(this.getContext(),s.code,s);if(u&&(s.code=u.code,u.map)){let c=await new ue.SourceMapConsumer(Ae(s.map)),l=await new ue.SourceMapConsumer(Ae(u.map)),f=ue.SourceMapGenerator.fromSourceMap(l);f.applySourceMap(c,s.path),s.map=f.toJSON(),c.destroy(),l.destroy()}}let i=this.context.options.sourcemap==="inline",o=s.type==="chunk"?s.code+cr(i,s.map,s.path,Me(s.path)):s.contents;if(await ke(s.path,o,{mode:s.type==="chunk"?s.mode:void 0}),n.push({get name(){return d.default.relative(process.cwd(),s.path)},get size(){return o.length}}),s.type==="chunk"&&s.map&&!i){let a=typeof s.map=="string"?JSON.parse(s.map):s.map,u=`${s.path}.map`,c=JSON.stringify(a);await ke(u,c),n.push({get name(){return d.default.relative(process.cwd(),u)},get size(){return c.length}})}}));for(let s of this.plugins)s.buildEnd&&await s.buildEnd.call(this.getContext(),{writtenFiles:n})}},cr=(e,t,r,n)=>{if(!t)return"";let s=n?"/*":"//",i=n?" */":"",o=e?`data:application/json;base64,${Buffer.from(typeof t=="string"?t:JSON.stringify(t)).toString("base64")}`:`${d.default.basename(r)}.map`;return`${s}# sourceMappingURL=${o}${i}`},ur=["es5","es3"],fr=()=>{let e=!1,t;return{name:"swc-target",esbuildOptions(r){typeof r.target=="string"&&ur.includes(r.target)&&(t=r.target,r.target="es2020",e=!0)},async renderChunk(r,n){if(!e||!/\.(cjs|mjs|js)$/.test(n.path))return;let s=p.localRequire.call(void 0,"@swc/core");if(!s)throw new k.PrettyError(`@swc/core is required for ${t} target. Please install it with \`npm install @swc/core -D\``);let i=await s.transform(r,{filename:n.path,sourceMaps:this.options.sourcemap,minify:!!this.options.minify,jsc:{target:t,parser:{syntax:"ecmascript"},minify:this.options.minify===!0?{compress:!1,mangle:{reserved:this.options.globalName?[this.options.globalName]:[]}}:void 0},module:{type:this.format==="cjs"?"commonjs":"es6"}});return{code:i.code,map:i.map}}}},dr=()=>({name:"size-reporter",buildEnd({writtenFiles:e}){j.reportSize.call(void 0,this.logger,this.format,e.reduce((t,r)=>({...t,[r.name]:r.size}),{}))}}),pr=m("rollup"),mr=({treeshake:e,name:t,silent:r})=>({name:"tree-shaking",async renderChunk(n,s){if(!e||!/\.(cjs|js|mjs)$/.test(s.path))return;let o=await(await pr.rollup.call(void 0,{input:[s.path],plugins:[{name:"tsup",resolveId(a){return a===s.path?a:!1},load(a){if(a===s.path)return{code:n,map:s.map}}}],treeshake:e,makeAbsoluteExternalsRelative:!1,preserveEntrySignatures:"exports-only",onwarn:r?()=>{}:void 0})).generate({interop:"auto",format:this.format,file:s.path,sourcemap:!!this.options.sourcemap,compact:!!this.options.minify,name:t});for(let a of o.output)if(a.type==="chunk"&&a.fileName===d.default.basename(s.path))return{code:a.code,map:a.map}}}),Fe=(e,t)=>{e&&Ne(d.default.resolve(e===!0?"public":e),t)},hr=(e,t)=>{if(!e)return!1;let r=p.slash.call(void 0,d.default.resolve(e===!0?"public":e));return p.slash.call(void 0,d.default.resolve(t)).startsWith(`${r}/`)},gr=({minifyOptions:e,format:t,terserOptions:r={},globalName:n,logger:s})=>({name:"terser",async renderChunk(i,o){if(e!=="terser"||!/\.(cjs|js|mjs)$/.test(o.path))return;let a=p.localRequire.call(void 0,"terser");if(!a)throw new k.PrettyError("terser is required for terser minification. Please install it with `npm install terser -D`");let{minify:u}=a,c={};t==="esm"?c.module=!0:t==="iife"&&n!==void 0||(c.toplevel=!0);try{let l=await u({[o.path]:i},{...c,...r});return s.info("TERSER","Minifying with Terser"),l.code||s.error("TERSER","Failed to minify with terser"),s.success("TERSER","Terser Minification success"),{code:l.code,map:l.map}}catch(l){s.error("TERSER","Failed to minify with terser"),s.error("TERSER",l)}return{code:i,map:o.map}}}),yr=m("typescript"),M=W(yr),U=j.createLogger.call(void 0),vr=(ce=class{constructor(){ce.prototype.__init.call(this)}__init(){this.seen=new Set}assign(e){let t=0,r=e==="default"?"default_alias":e;for(;this.seen.has(r);)if(r=`${e}_alias_${++t}`,t>=1e3)throw new Error("Alias generation exceeded limit. Possible infinite loop detected.");return this.seen.add(r),r}},ce);function wr(e,t){let r=e.getTypeChecker(),n=new vr,s=n.assign.bind(n);function i(o){let a=e.getCurrentDirectory();o=p.toAbsolutePath.call(void 0,o,a);let u=e.getSourceFile(o);if(!u)return[];let c=t.get(o);if(!c)return[];let l=r.getSymbolAtLocation(u);if(!l)return[];let f=[];return r.getExportsOfModule(l).forEach(g=>{let E=g.getName();f.push({kind:"named",sourceFileName:o,destFileName:c,name:E,alias:s(E),isTypeOnly:!1})}),f}return e.getRootFileNames().flatMap(i)}function xr(e,t){let r=new Map,n=(u,c,l,f,h,g)=>{let E=x([h,"optionalAccess",S=>S[0]]),b=x([E,"optionalAccess",S=>S.fileName]);if(b&&!u.endsWith(".map")){let S=e.getCurrentDirectory();r.set(p.toAbsolutePath.call(void 0,b,S),p.toAbsolutePath.call(void 0,u,S))}return t.writeFile(u,c,l,f,h,g)},s=e.emit(void 0,n,void 0,!0),i=M.default.getPreEmitDiagnostics(e).concat(s.diagnostics),o=[];i.forEach(u=>{if(u.file){let{line:c,character:l}=M.default.getLineAndCharacterOfPosition(u.file,u.start),f=M.default.flattenDiagnosticMessageText(u.messageText,`
34
+ `);o.push(`${u.file.fileName} (${c+1},${l+1}): ${f}`)}else{let c=M.default.flattenDiagnosticMessageText(u.messageText,`
35
+ `);o.push(c)}});let a=o.join(`
36
+ `);if(a)throw U.error("TSC",`Failed to emit declaration files.
37
+
38
+ ${a}`),new Error("TypeScript compilation failed");return r}function Er(e,t){let r=process.cwd(),n=A.loadTsConfig.call(void 0,r,t);if(!n)throw new Error(`Unable to find ${t||"tsconfig.json"} in ${r}`);let s=p.ensureTempDeclarationDir.call(void 0),i=M.default.parseJsonConfigFileContent({...n.data,compilerOptions:{...x([n,"access",l=>l.data,"optionalAccess",l=>l.compilerOptions]),...e,noEmit:!1,declaration:!0,declarationMap:!0,declarationDir:s,emitDeclarationOnly:!0}},M.default.sys,t?Te.dirname.call(void 0,t):"./"),o=i.options,a=M.default.createCompilerHost(o),u=M.default.createProgram(i.fileNames,o,a),c=xr(u,a);return wr(u,c)}function Pr(e){try{let t=Date.now(),r=()=>`${Math.floor(Date.now()-t)}ms`;U.info("tsc","Build start");let n=e.experimentalDts,s=Er(n.compilerOptions,e.tsconfig);return U.success("tsc",`\u26A1\uFE0F Build success in ${r()}`),s}catch(t){k.handleError.call(void 0,t),U.error("tsc","Build error")}}function _r(e,t){let r=e.map(n=>jr(n,t)).filter(p.truthy);return r.length===0&&r.push("export {};"),`${r.join(`
39
+ `)}
40
+ `}function jr(e,t){let r=p.replaceDtsWithJsExtensions.call(void 0,`./${d.default.posix.normalize(p.slash.call(void 0,d.default.relative(t,e.destFileName)))}`);if(e.kind==="module")return"";if(e.kind==="named")return["export",e.isTypeOnly?"type":"","{",e.name,e.name===e.alias?"":`as ${e.alias}`,"} from",`'${r}';`].filter(p.truthy).join(" ");throw new Error("Unknown declaration")}function br(e,t,r){let n=p.replaceDtsWithJsExtensions.call(void 0,d.default.posix.relative(d.default.posix.dirname(d.default.posix.normalize(p.slash.call(void 0,t))),d.default.posix.normalize(p.slash.call(void 0,r))));/^\.+\//.test(n)||(n=`./${n}`);let s={named:new Set,module:new Set},i=e.filter(o=>o.kind==="module"?s.module.has(o.moduleName)?!1:(s.module.add(o.moduleName),!0):o.kind==="named"?s.named.has(o.name)?!1:(s.named.add(o.name),!0):!1).map(o=>Or(o,n)).filter(p.truthy);return i.length===0&&i.push("export {};"),`${i.join(`
41
+ `)}
42
+ `}function Or(e,t){return e.kind==="named"?["export",e.isTypeOnly?"type":"","{",e.alias,e.name===e.alias?"":`as ${e.name}`,"} from",`'${t}';`].filter(p.truthy).join(" "):e.kind==="module"?`export * from '${e.moduleName}';`:""}var fe=j.createLogger.call(void 0);function Cr(e,t,r){let n=process.cwd(),s=d.default.join(n,"package.json"),o={configObject:{mainEntryPointFilePath:e,apiReport:{enabled:!1,reportFileName:"tsup-report.api.md"},docModel:{enabled:!1},dtsRollup:{enabled:!0,untrimmedFilePath:t},tsdocMetadata:{enabled:!1},compiler:{tsconfigFilePath:r},projectFolder:n,newlineKind:"lf"},configObjectFullPath:void 0,packageJsonFullPath:s},a=p.getApiExtractor.call(void 0);if(!a)throw new Error("@microsoft/api-extractor is not installed. Please install it first.");let{ExtractorConfig:u,Extractor:c}=a,l=u.prepare(o),f=c.invoke(l,{localBuild:!0,showVerboseMessages:!0});if(!f.succeeded)throw new Error(`API Extractor completed with ${f.errorCount} errors and ${f.warningCount} warnings when processing ${e}`)}async function Sr(e,t,r){if(!e.experimentalDts||!x([e,"access",l=>l.experimentalDts,"optionalAccess",l=>l.entry]))return;let n=p.ensureTempDeclarationDir.call(void 0),s=e.outDir||"dist",i=await j.loadPkg.call(void 0,process.cwd()),o=p.defaultOutExtension.call(void 0,{format:r,pkgType:i.type}).dts,a=e.tsconfig||"tsconfig.json",u=d.default.join(n,`_tsup-dts-aggregation${o}`);u=u.replace(/\.d\.mts$/,".dmts.d.ts").replace(/\.d\.cts$/,".dcts.d.ts");let c=d.default.join(s,`_tsup-dts-rollup${o}`);p.writeFileSync.call(void 0,u,_r(t,n)),Cr(u,c,a);for(let[l,f]of Object.entries(e.experimentalDts.entry)){f=p.toAbsolutePath.call(void 0,f);let h=d.default.join(s,l+o),g=t.filter(E=>E.sourceFileName===f);p.writeFileSync.call(void 0,h,br(g,h,c))}}async function $r(e){e.clean&&await p.removeFiles.call(void 0,["**/*.d.{ts,mts,cts}"],e.outDir)}async function Dr(e,t){try{let r=Date.now(),n=()=>`${Math.floor(Date.now()-r)}ms`;if(fe.info("dts","Build start"),!t)throw new Error("Unexpected internal error: dts exports is not define");await $r(e);for(let s of e.format)await Sr(e,t,s);fe.success("dts",`\u26A1\uFE0F Build success in ${n()}`)}catch(r){k.handleError.call(void 0,r),fe.error("dts","Build error")}}var kr=()=>({name:"cjs-interop",renderChunk(e,t){if(!(!this.options.cjsInterop||this.format!=="cjs"||t.type!=="chunk"||!/\.(js|cjs)$/.test(t.path)||!t.entryPoint||x([t,"access",r=>r.exports,"optionalAccess",r=>r.length])!==1||t.exports[0]!=="default"))return{code:`${e}
43
+ module.exports = exports.default;
44
+ `,map:t.map}}}),Ar=e=>e,Mr=e=>process.platform==="win32"&&"cmd"in e&&"code"in e&&typeof e.cmd=="string"&&e.cmd.startsWith("taskkill")&&e.code===128,Fr=({pid:e,signal:t})=>new Promise((r,n)=>{Ht.default.call(void 0,e,t,s=>{if(s&&!Mr(s))return n(s);r()})}),qr=async(e,t,r)=>{let n={...t,...r},s={outDir:"dist",removeNodeProtocol:!0,...n,format:typeof n.format=="string"?[n.format]:n.format||["cjs"],dts:typeof n.dts=="boolean"?n.dts?{}:void 0:typeof n.dts=="string"?{entry:n.dts}:n.dts,experimentalDts:await p.resolveInitialExperimentalDtsConfig.call(void 0,n.experimentalDts)};j.setSilent.call(void 0,s.silent);let i=s.entry||s.entryPoints;if(!i||Object.keys(i).length===0)throw new k.PrettyError('No input files, try "tsup <your-file>" instead');if(Array.isArray(i)){if(s.entry=await de.glob.call(void 0,i),!s.entry||s.entry.length===0)throw new k.PrettyError(`Cannot find ${i}`);e.info("CLI",`Building entry: ${s.entry.join(", ")}`)}else Object.keys(i).forEach(a=>{let u=i[a];if(!C.default.existsSync(u))throw new k.PrettyError(`Cannot find ${a}: ${u}`)}),s.entry=i,e.info("CLI",`Building entry: ${JSON.stringify(i)}`);let o=A.loadTsConfig.call(void 0,process.cwd(),s.tsconfig);if(o)e.info("CLI",`Using tsconfig: ${d.default.relative(process.cwd(),o.path)}`),s.tsconfig=o.path,s.tsconfigResolvePaths=x([o,"access",a=>a.data,"optionalAccess",a=>a.compilerOptions,"optionalAccess",a=>a.paths])||{},s.tsconfigDecoratorMetadata=x([o,"access",a=>a.data,"optionalAccess",a=>a.compilerOptions,"optionalAccess",a=>a.emitDecoratorMetadata]),s.dts&&(s.dts.compilerOptions={...o.data.compilerOptions||{},...s.dts.compilerOptions||{}}),s.experimentalDts&&(s.experimentalDts=await p.resolveExperimentalDtsConfig.call(void 0,s,o)),s.target||(s.target=x([o,"access",a=>a.data,"optionalAccess",a=>a.compilerOptions,"optionalAccess",a=>a.target,"optionalAccess",a=>a.toLowerCase,"call",a=>a()]));else if(s.tsconfig)throw new k.PrettyError(`Cannot find tsconfig: ${s.tsconfig}`);return s.target||(s.target="node16"),s};async function Tr(e){let t=e.config===!1?{}:await j.loadTsupConfig.call(void 0,process.cwd(),e.config===!0?void 0:e.config),r=typeof t.data=="function"?await t.data(e):t.data;await Promise.all([...Array.isArray(r)?r:[r]].map(async n=>{let s=j.createLogger.call(void 0,x([n,"optionalAccess",c=>c.name])),i=await qr(s,n,e);s.info("CLI",`tsup v${Bt.version}`),t.path&&s.info("CLI",`Using tsup config: ${t.path}`),i.watch&&s.info("CLI","Running in watch mode");let o=async()=>{if(!i.dts&&i.experimentalDts){let c=Pr(i);await Dr(i,c)}},a=async()=>{if(i.dts&&i.experimentalDts)throw new Error("You can't use both `dts` and `experimentalDts` at the same time");await o(),i.dts&&await new Promise((c,l)=>{let f=new Jt.Worker(d.default.join(__dirname,"./rollup.js")),h=()=>{i.watch||f.terminate()};f.postMessage({configName:x([n,"optionalAccess",g=>g.name]),options:{...i,injectStyle:typeof i.injectStyle=="function"?void 0:i.injectStyle,banner:void 0,footer:void 0,esbuildPlugins:void 0,esbuildOptions:void 0,plugins:void 0,treeshake:void 0,onSuccess:void 0,outExtension:void 0}}),f.on("message",g=>{if(g==="error")h(),l(new Error("error occurred in dts build"));else if(g==="success")h(),c();else{let{type:E,text:b}=g;E==="log"?console.log(b):E==="error"&&console.error(b)}})})},u=async()=>{if(!x([i,"access",c=>c.dts,"optionalAccess",c=>c.only])){let c,l,f=new Set,h=await j.getAllDepsHash.call(void 0,process.cwd()),g=async()=>{c?await Fr({pid:c.pid,signal:i.killSignal||"SIGTERM"}):l&&await l(),c=void 0,l=void 0},E=p.debouncePromise.call(void 0,()=>b(),100,k.handleError),b=async()=>{await g();let F=new Set(f);if(f.clear(),i.clean){let P=Array.isArray(i.clean)?i.clean:[];(i.dts||i.experimentalDts)&&P.unshift("!**/*.d.{ts,cts,mts}"),await p.removeFiles.call(void 0,["**/*",...P],i.outDir),s.info("CLI","Cleaning output folder")}let R=new Map;await Promise.all([...i.format.map(async(P,O)=>{let v=new lr([ir(),...i.plugins||[],mr({treeshake:i.treeshake,name:i.globalName,silent:i.silent}),ar(),kr(),fr(),dr(),gr({minifyOptions:i.minify,format:P,terserOptions:i.terserOptions,globalName:i.globalName,logger:s})]);await nr(i,{pluginContainer:v,format:P,css:O===0||i.injectStyle?R:void 0,logger:s,buildDependencies:f}).catch(_=>{throw F.forEach(w=>f.add(w)),_})})]),i.onSuccess&&(typeof i.onSuccess=="function"?l=await i.onSuccess():(c=zt.exec.call(void 0,i.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit"}}),x([c,"access",P=>P.process,"optionalAccess",P=>P.on,"call",P=>P("exit",O=>{O&&O!==0&&(process.exitCode=O)})])))},S=async()=>{if(!i.watch)return;let{watch:F}=await Promise.resolve().then(()=>qe(m("chokidar"))),R=i.ignoreWatch?Array.isArray(i.ignoreWatch)?i.ignoreWatch:[i.ignoreWatch]:[],P=["**/{.git,node_modules}/**",i.outDir,...R],O=typeof i.watch=="boolean"?".":Array.isArray(i.watch)?i.watch.filter(_=>typeof _=="string"):i.watch;s.info("CLI",`Watching for changes in ${Array.isArray(O)?O.map(_=>`"${_}"`).join(" | "):`"${O}"`}`),s.info("CLI",`Ignoring changes in ${P.map(_=>`"${_}"`).join(" | ")}`),F(await de.glob.call(void 0,O),{ignoreInitial:!0,ignorePermissionErrors:!0,ignored:_=>de.globSync.call(void 0,_,{ignore:P}).length===0}).on("all",async(_,w)=>{if(w=p.slash.call(void 0,w),i.publicDir&&hr(i.publicDir,w)){s.info("CLI",`Change in public dir: ${w}`),Fe(i.publicDir,i.outDir);return}let K=!1;if(i.watch===!0)if(w==="package.json"&&!f.has(w)){let pe=await j.getAllDepsHash.call(void 0,process.cwd());K=pe===h,h=pe}else f.has(w)||(K=!0);K||(s.info("CLI",`Change detected: ${_} ${w}`),E())})};s.info("CLI",`Target: ${i.target}`),await b(),Fe(i.publicDir,i.outDir),S()}};await Promise.all([a(),u()])}))}Y.build=Tr;Y.defineConfig=Ar});var G=Ie(Re());var Vr=q,Le={utils:q,defineConfig:Nr,defineConfigWithIndexEntries:Rr,defineConfigWithCommonEntries:Lr};function Nr(e){return(0,G.defineConfig)(q.defaultOptions(e))}function Rr(e){return(0,G.defineConfig)(q.defaultOptionsWithIndexEntries(e))}function Lr(e){return(0,G.defineConfig)(q.defaultOptionsWithCommonEntries(e))}var Qr=Le;export{Vr as BuildUtils,Qr as default,Nr as defineConfig,Lr as defineConfigWithCommonEntries,Rr as defineConfigWithIndexEntries};
@@ -0,0 +1,117 @@
1
+ declare class BuildUtils {
2
+ /**
3
+ * The default build options
4
+ */
5
+ static readonly defaultConfigOptions: BuildOptions;
6
+ /**
7
+ * Array of commonly ignored entries
8
+ */
9
+ static readonly ignoredEntries: string[];
10
+ /**
11
+ * Aray of commonly used entries
12
+ */
13
+ static readonly entriesCommon: string[];
14
+ /**
15
+ * Array of index entries
16
+ */
17
+ static readonly entriesIndex: string[];
18
+ /**
19
+ * Array of default entries including index files and commonly ignored entries
20
+ */
21
+ static readonly defaultEntriesIndex: string[];
22
+ /**
23
+ * Array of default entries including any .ts files and commonly ignored entries
24
+ */
25
+ static readonly defaultEntriesCommon: string[];
26
+ /**
27
+ * Default options
28
+ *
29
+ * See all available options here: https://www.jsdocs.io/package/tsup#Options
30
+ *
31
+ * @default '{ tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
32
+ * @param options configuration with entry, clean and splitting as required properties to avoid unintended behaviour
33
+ * @param config configure tochibuild behaviour
34
+ */
35
+ static readonly defaultOptions: (options: BuildOptionsParams<"entry" | "clean" | "splitting">, config?: TochibuildConfig) => ConfigResult<"entry" | "clean" | "splitting">;
36
+ /**
37
+ * Default options for index files as entry
38
+ *
39
+ * See all available options here: https://www.jsdocs.io/package/tsup#Options
40
+ *
41
+ * @default '{ entry: BuildUtils.defaultEntriesIndex, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
42
+ * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
43
+ * @param config configure tochibuild behaviour
44
+ */
45
+ static readonly defaultOptionsWithIndexEntries: (options: BuildOptionsParams<"clean" | "splitting">, config?: TochibuildConfig) => ConfigResult<"clean" | "splitting">;
46
+ /**
47
+ * Default options for common files as entry
48
+ *
49
+ * See all available options here: https://www.jsdocs.io/package/tsup#Options
50
+ *
51
+ * @default '{ entry: BuildUtils.defaultEntriesCommon, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
52
+ * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
53
+ * @param config configure tochibuild behaviour
54
+ */
55
+ static readonly defaultOptionsWithCommonEntries: (options: BuildOptionsParams<"clean" | "splitting">, config?: TochibuildConfig) => ConfigResult<"clean" | "splitting">;
56
+ /**
57
+ * Generate a config file
58
+ *
59
+ * @param module which module to use
60
+ * @param options (optional) `GenerateConfigOptions`
61
+ * @param throwErr (optional) whether or not to throw an error if something goes wrong
62
+ * @param cli (optional) whether or not this is being called from the CLI
63
+ */
64
+ static readonly generateConfig: typeof generateConfig;
65
+ /**
66
+ * Ensures that the passed entries includes the certain ones
67
+ *
68
+ * NOTE: only works for string arrays (otherwise will return the same entry) and will not overwrite or duplicate the entries
69
+ *
70
+ * @param entry the entries to check
71
+ * @param type the type of entries to ensure
72
+ */
73
+ static readonly ensureEntries: typeof ensureEntries;
74
+ /**
75
+ * Get the file path and json data from a package.json
76
+ *
77
+ * If no rootDir is passed or if it's undefined, then the current working directory will be used
78
+ *
79
+ * @param rootDir the directory the package.json is in
80
+ * @param throwErr whether or not to throw an error if something goes wrong
81
+ */
82
+ static readonly getPackageJson: <TPackageJson extends Record<string, any> = Record<string, any>>(rootDir?: string, throwErr?: boolean) => {
83
+ filePath: string | undefined;
84
+ data: TPackageJson | undefined;
85
+ };
86
+ /**
87
+ * Get dependencies from a package.json file using config
88
+ *
89
+ * @param config configuration from {@link TochibuildConfig}
90
+ * @param packageJsonPath the package.json file path
91
+ */
92
+ static readonly getPackageJsonDepsEntriesFromConfig: (config: TochibuildConfig | undefined, packageJsonPath?: string) => string[];
93
+ /**
94
+ * Get dependencies from a package.json file as entries
95
+ *
96
+ * @param packageJsonPath the package.json file path
97
+ * @param filter the types of dependencies to include
98
+ */
99
+ static readonly getPackageJsonDepsEntries: (packageJsonPath: string | undefined, filter?: ("dependencies" | "devDependencies" | "peerDependencies")[]) => string[];
100
+ /**
101
+ * Get dependencies from a package.json file
102
+ *
103
+ * @param packageJsonPath the package.json file path
104
+ * @param filter the types of dependencies to include
105
+ */
106
+ static readonly getPackageJsonDeps: (packageJsonPath: string | undefined) => {
107
+ toArray: (filter?: ("dependencies" | "devDependencies" | "peerDependencies")[]) => string[];
108
+ dependencies: any;
109
+ devDependencies: any;
110
+ peerDependencies: any;
111
+ };
112
+ }
113
+
114
+ declare function ensureEntries(entry: BuildOptions['entry'], type: ('ignoredEntries' | 'entriesIndex' | 'entriesCommon' | 'defaultEntriesIndex' | 'defaultEntriesCommon')[]): BuildOptions['entry'];
115
+ declare function generateConfig(module: '@tochii/build' | 'tochibuild', options?: GenerateConfigOptions, throwErr?: boolean, cli?: boolean): void;
116
+
117
+ export { BuildUtils as B };
package/dist/utils.d.mts CHANGED
@@ -1,6 +1,4 @@
1
- import { B as BuildUtils } from './utils-BMzAmbjm.mjs';
2
- export { b as BuildOptionsOverrideParam, a as BuildOptionsParam, c as BuildOptionsParams, C as ConfigResult } from './utils-BMzAmbjm.mjs';
3
- import 'tsup';
1
+ import { B as BuildUtils } from './utils-dsfZeRyj.mjs';
4
2
 
5
3
 
6
4
 
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- import{b as r,c as o}from"./chunk-UOBRZ36U.mjs";var e=o;export{r as BuildUtils,e as default};
1
+ import{f as r,g as o}from"./chunk-GKH6M3ZR.mjs";var e=o;export{r as BuildUtils,e as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tochii/build",
3
- "version": "2.2.6",
3
+ "version": "2.3.0",
4
4
  "description": "An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",
5
5
  "repository": "https://github.com/tochiResources/project/tree/main/packages/build.git",
6
6
  "license": "MIT",
@@ -36,6 +36,7 @@
36
36
  "chalk": "^5.4.1",
37
37
  "commander": "^13.1.0",
38
38
  "deepmerge": "^4.3.1",
39
+ "tochibuild": "^2.2.6",
39
40
  "tsup": "8.4.0"
40
41
  },
41
42
  "devDependencies": {
@@ -1,11 +0,0 @@
1
- import B from"chalk";import y from"node:fs";import E from"node:path";import K from"deepmerge";import d from"chalk";var x="tochibuild",u=d.cyan(x),o=class{};o.custom=(e,...t)=>{console[e](u,...t)},o.log=(...e)=>{console.log(u,...e)},o.debug=(...e)=>{console.debug(u,...e)},o.info=(...e)=>{console.info(u,...e)},o.warn=(...e)=>{console.warn(u,...[...e].map(t=>d.yellow(t)))},o.error=(e,...t)=>{console.error(d.red(x),d.bgRed(...t),e?.stack?`
2
- ${d.gray(e.stack)}`:"")},o.success=(...e)=>{console.log(d.green(x),...e)};var f=o;var n=class n{};n.defaultConfigOptions={tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0},n.ignoredEntries=["!build/**","!dist/**","!node_modules/**","!**/build/**","!**/dist/**","!**/node_modules/**","!**/*.d.ts","!**/{tochibuild,tsup}.*"],n.entriesCommon=["**/*.{js,ts}"],n.entriesIndex=["**/index.{js,ts}"],n.defaultEntriesIndex=[...n.ignoredEntries,...n.entriesIndex],n.defaultEntriesCommon=[...n.ignoredEntries,...n.entriesCommon],n.defaultOptions=e=>h(e,t=>{let a=m(t.entry,"ignoredEntries");return{...n.defaultConfigOptions,...t,entry:a}}),n.defaultOptionsWithIndexEntries=e=>h(e,t=>{let a=m(t.entry,"defaultEntriesIndex");return{...n.defaultConfigOptions,...t,entry:a}}),n.defaultOptionsWithCommonEntries=e=>h(e,t=>{let a=m(t.entry,"defaultEntriesCommon");return{...n.defaultConfigOptions,...t,entry:a}}),n.generateConfig=I,n.ensureEntries=m;var l=n,G=l;function h(i,e){let t=s=>Array.isArray(s)?s.map(r=>K(e(r),s)):K(e(s),s);if(typeof i=="function"){let s=i;async function r(b){let p=await s(b);return t(p)}return r}return t(i)}function m(i,e){return Array.isArray(i)?Array.from(new Set([...l[e],...i])):i}function w(i){return E.isAbsolute(i||".")?i:E.resolve(process.cwd(),i)}function I(i,e,t,a){let s="";try{let r=e?.ext||".ts",p=`${e?.filename||"tochibuild.config"}${r}`;(e?.outDir?.length?e.outDir:["."]).forEach(O=>{s=w(O),y.existsSync(O)||y.mkdirSync(O,{recursive:!0});let g=E.join(s,p),k=y.existsSync(g);!e?.overwrite&&k&&(f.warn(`the config '${p}' file already exists for this project.`),a&&process.exit(1));let q=" ",c="",C={clean:!1,splitting:!0},P=R=>{c+=R==="esm"?`import build from '${i}';
3
-
4
- `:`const build = require('${i}');
5
-
6
- `,c+=R==="esm"?`export default build.defineConfigWithIndexEntries({
7
- `:`module.exports = build.defineConfigWithIndexEntries({
8
- `,Object.entries(C).forEach(([$,j])=>{c+=`${q}${$}: ${JSON.stringify(j)},
9
- `}),c+=`});
10
- `};switch(r){case".ts":case".js":P("esm");break;case".cjs":P("cjs");break;case".json":c+=`${JSON.stringify({...C,entry:l.defaultEntriesIndex},null,2)}
11
- `;break;default:f.error(void 0,`unsupported extension: ${r}`),process.exit(1)}y.writeFileSync(g,c),f.success(B.cyan("the config file has been created at:"),B.gray(g))})}catch(r){if(t)throw r;f.error(r,r.message?`failed to generate config file in ${s}: ${r.message}`:`failed to generate config file in ${s}`),a&&process.exit(1)}}export{f as a,l as b,G as c};
@@ -1,96 +0,0 @@
1
- import { Options } from 'tsup';
2
-
3
- type BuildOptionsParam<RequiredKeys extends keyof Options> = WithRequired<Options, RequiredKeys> | WithRequired<Options, RequiredKeys>[];
4
- type BuildOptionsOverrideParam<RequiredKeys extends keyof Options> = (overrideOptions: Options) => MaybePromise<BuildOptionsParam<RequiredKeys>>;
5
- type BuildOptionsParams<RequiredKeys extends keyof Options> = BuildOptionsParam<RequiredKeys> | BuildOptionsOverrideParam<RequiredKeys>;
6
- type ConfigResult<RequiredKeys extends keyof Options> = BuildOptionsParam<RequiredKeys> | BuildOptionsOverrideParam<RequiredKeys>;
7
- declare class BuildUtils {
8
- static defaultConfigOptions: Options;
9
- /**
10
- * Array of commonly ignored entries
11
- *
12
- * @static
13
- * @memberof BuildUtils
14
- */
15
- static ignoredEntries: string[];
16
- /**
17
- * Aray of commonly used entries
18
- *
19
- * @static
20
- * @memberof BuildUtils
21
- */
22
- static entriesCommon: string[];
23
- /**
24
- * Array of index entries
25
- *
26
- * @static
27
- * @memberof BuildUtils
28
- */
29
- static entriesIndex: string[];
30
- /**
31
- * Array of default entries including index files and commonly ignored entries
32
- *
33
- * @static
34
- * @memberof BuildUtils
35
- */
36
- static defaultEntriesIndex: string[];
37
- /**
38
- * Array of default entries including any .ts files and commonly ignored entries
39
- *
40
- * @static
41
- * @memberof BuildUtils
42
- */
43
- static defaultEntriesCommon: string[];
44
- /**
45
- * Default options
46
- *
47
- * See all available options here: https://www.jsdocs.io/package/tsup#Options
48
- *
49
- * @default '{ tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
50
- * @param options configuration with entry, clean and splitting as required properties to avoid unintended behaviour
51
- */
52
- static defaultOptions: (options: BuildOptionsParams<"entry" | "clean" | "splitting">) => ConfigResult<"entry" | "clean" | "splitting">;
53
- /**
54
- * Default options for index files as entry
55
- *
56
- * See all available options here: https://www.jsdocs.io/package/tsup#Options
57
- *
58
- * @default '{ entry: BuildUtils.defaultEntriesIndex, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
59
- * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
60
- */
61
- static defaultOptionsWithIndexEntries: (options: BuildOptionsParams<"clean" | "splitting">) => ConfigResult<"clean" | "splitting">;
62
- /**
63
- * Default options for common files as entry
64
- *
65
- * See all available options here: https://www.jsdocs.io/package/tsup#Options
66
- *
67
- * @default '{ entry: BuildUtils.defaultEntriesCommon, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
68
- * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
69
- */
70
- static defaultOptionsWithCommonEntries: (options: BuildOptionsParams<"clean" | "splitting">) => ConfigResult<"clean" | "splitting">;
71
- /**
72
- * Generate a config file
73
- *
74
- * @param module which module to use
75
- * @param options (optional) `GenerateConfigOptions`
76
- * @param throwErr (optional) whether or not to throw an error if something goes wrong
77
- * @param cli (optional) whether or not this is being called from the CLI
78
- * @returns {void}
79
- */
80
- static generateConfig: typeof generateConfig;
81
- /**
82
- * Ensures that the passed entries includes the certain ones
83
- *
84
- * NOTE: only works for string arrays (otherwise will return the same entry) and will not overwrite or duplicate the entries
85
- *
86
- * @param entry the entries to check
87
- * @param type the type of entries to ensure
88
- * @memberof BuildUtils
89
- */
90
- static ensureEntries: typeof ensureEntries;
91
- }
92
-
93
- declare function ensureEntries(entry: Options['entry'], type: 'ignoredEntries' | 'entriesIndex' | 'entriesCommon' | 'defaultEntriesIndex' | 'defaultEntriesCommon'): Options['entry'];
94
- declare function generateConfig(module: '@tochii/build' | 'tochibuild', options?: GenerateConfigOptions, throwErr?: boolean, cli?: boolean): void;
95
-
96
- export { BuildUtils as B, type ConfigResult as C, type BuildOptionsParam as a, type BuildOptionsOverrideParam as b, type BuildOptionsParams as c };