@homedev/framework 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export declare type ColorValue = string | {
2
+ r: number;
3
+ g: number;
4
+ b: number;
5
+ } | [number, number, number] | number;
6
+
1
7
  /**
2
8
  * Parses and queries command-line arguments.
3
9
  *
@@ -206,6 +212,13 @@ export declare class Logger {
206
212
  * @param args - Log payload values.
207
213
  */
208
214
  write(className: string, ...args: any[]): void;
215
+ /**
216
+ * Wraps a text in an RGB color code for console output.
217
+ * @param text - The text to color.
218
+ * @param color - The RGB color.
219
+ * @returns The colored text for console output.
220
+ */
221
+ color(text: string, color: ColorValue): string;
209
222
  /**
210
223
  * Writes an INFO level log entry.
211
224
  *
@@ -244,11 +257,15 @@ export declare class Logger {
244
257
  export declare interface LoggerOptions {
245
258
  level: string;
246
259
  showClass: boolean;
260
+ useColors: boolean;
247
261
  levels: string[];
248
262
  timeStamp: boolean;
249
263
  timeLocale?: string;
250
264
  timeOptions?: Intl.DateTimeFormatOptions;
251
265
  logFunction: LogFunction;
266
+ onClass: (className: string) => string;
267
+ onTime: (time: string, className: string) => string;
268
+ onPrefix: (prefix: string, className: string) => string;
252
269
  }
253
270
 
254
271
  /**
@@ -599,18 +616,6 @@ declare global {
599
616
  }
600
617
  }
601
618
 
602
- declare global {
603
- interface ObjectConstructor {
604
- mapEntries<T extends object, U>(obj: T, callback: (key: keyof T, value: T[keyof T]) => [string | number | symbol, U]): Record<string | number | symbol, U>;
605
- toList<T extends object, U extends object, X extends string>(obj: T, key: X): (Record<X, string> & U)[];
606
- deepClone<T extends object>(obj: T): T;
607
- merge(source: any, target: any, options?: MergeOptions): void;
608
- navigate(o: any, cb: NavigateCallback): Promise<void>;
609
- find(from: any, cb: (path: string, value: any) => boolean): Promise<any[]>;
610
- select(from: any, path: string, options?: SelectOptions): any;
611
- }
612
- }
613
-
614
619
  declare global {
615
620
  interface Array<T> {
616
621
  mapAsync<U>(callback: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]>;
@@ -633,3 +638,15 @@ declare global {
633
638
  }
634
639
  }
635
640
 
641
+ declare global {
642
+ interface ObjectConstructor {
643
+ mapEntries<T extends object, U>(obj: T, callback: (key: keyof T, value: T[keyof T]) => [string | number | symbol, U]): Record<string | number | symbol, U>;
644
+ toList<T extends object, U extends object, X extends string>(obj: T, key: X): (Record<X, string> & U)[];
645
+ deepClone<T extends object>(obj: T): T;
646
+ merge(source: any, target: any, options?: MergeOptions): void;
647
+ navigate(o: any, cb: NavigateCallback): Promise<void>;
648
+ find(from: any, cb: (path: string, value: any) => boolean): Promise<any[]>;
649
+ select(from: any, path: string, options?: SelectOptions): any;
650
+ }
651
+ }
652
+
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- Array.prototype.findOrFail=function(T,U,x){let b=this.find(T,x);if(b===void 0)throw Error(U??"Element not found");return b};Array.flat=function(T){if(Array.isArray(T))return T.flat(2);else return[T]};Array.prototype.forEachAsync=async function(T){for(let U=0;U<this.length;U++)await T(this[U],U,this)};Array.prototype.groupBy=function(T){return this.reduce((U,x)=>{let b=T(x);if(!U[b])U[b]=[];return U[b].push(x),U},{})};Array.prototype.createInstances=function(T,...U){return this.map((x,b)=>new T(...U,x,b))};Array.prototype.mapAsync=async function(T){return Promise.all(this.map(T))};Array.prototype.nonNullMap=function(T){let U=[];for(let x=0;x<this.length;x++){let b=T(this[x],x,this);if(b!=null)U.push(b)}return U};Array.prototype.nonNullMapAsync=async function(T){let U=[];for(let x=0;x<this.length;x++){let b=await T(this[x],x,this);if(b!=null)U.push(b)}return U};Array.prototype.mergeAll=function(T){let U={};for(let x of this.slice().reverse())Object.merge(x,U,T);return U};Array.prototype.toObject=function(T,U){return Object.fromEntries(this.map((x)=>{let b=T(x),O=U?U(x):x;return[b,O]}))};Array.prototype.toObjectWithKey=function(T){return Object.fromEntries(this.map((U)=>[String(U[T]),U]))};Array.prototype.selectFor=function(T,U,x,b){let O=this.find(T,b);if(O===void 0)throw Error(x??"Element not found");return U(O)};Array.prototype.sortBy=function(T,U=!0){return this.slice().sort((x,b)=>{let O=T(x),A=T(b);if(O<A)return U?-1:1;if(O>A)return U?1:-1;return 0})};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(T){let U=new Set;return this.filter((x)=>{let b=T(x);if(U.has(b))return!1;else return U.add(b),!0})};var w;((E)=>{E[E.Explore=0]="Explore";E[E.SkipSiblings=1]="SkipSiblings";E[E.NoExplore=2]="NoExplore";E[E.ReplaceParent=3]="ReplaceParent";E[E.DeleteParent=4]="DeleteParent";E[E.MergeParent=5]="MergeParent";E[E.ReplaceItem=6]="ReplaceItem";E[E.DeleteItem=7]="DeleteItem"})(w||={});class X{action;by;skipSiblings;reexplore;constructor(T,U,x,b){this.action=T;this.by=U;this.skipSiblings=x;this.reexplore=b}static _explore=new X(0);static _noExplore=new X(2);static _skipSiblings=new X(1);static _deleteParent=new X(4);static ReplaceParent(T,U){return new X(3,T,void 0,U)}static SkipSiblings(){return X._skipSiblings}static Explore(){return X._explore}static NoExplore(){return X._noExplore}static DeleteParent(){return X._deleteParent}static MergeParent(T){return new X(5,T)}static ReplaceItem(T,U){return new X(6,T,U)}static DeleteItem(T){return new X(7,void 0,T)}}Object.navigate=async(T,U)=>{let x=new WeakSet,b=[],O=[],A=async(F,E,j)=>{let B=F===null,Y=B?X.Explore():await U({key:F,value:E,path:b,parent:j,parents:O});if(E&&typeof E==="object"&&Y.action===0){if(x.has(E))return Y;if(x.add(E),!B)b.push(F),O.push(j);let f=E;while(await K(f,F,j))f=j[F];if(!B)O.pop(),b.pop()}return Y},K=async(F,E,j)=>{let B=Object.keys(F),$=B.length;for(let Y=0;Y<$;Y++){let Z=B[Y],Q=F[Z],f=await A(Z,Q,F),G=f.action;if(G===0||G===2)continue;if(G===6){if(F[Z]=f.by,f.skipSiblings)return;continue}if(G===7){if(delete F[Z],f.skipSiblings)return;continue}if(G===1)return;if(G===3){if(E===null)throw Error("Cannot replace root object");if(j[E]=f.by,f.reexplore)return!0;return}if(G===4){if(E===null)throw Error("Cannot delete root object");delete j[E];return}if(G===5)delete F[Z],Object.assign(F,f.by)}};await A(null,T,null)};Object.find=async function(T,U){let x=[];return await Object.navigate(T,(b)=>{if(U([...b.path,b.key].join("."),b.value))x.push(b.value);return X.Explore()}),x};Object.merge=(T,U,x)=>{for(let b of Object.keys(U)){if(T[b]===void 0)continue;let O=U[b],A=T[b];if(typeof A!==typeof O||Array.isArray(A)!==Array.isArray(O)){let F=x?.mismatch?.(b,A,O,T,U);if(F!==void 0){U[b]=F;continue}throw Error(`Type mismatch: ${b}`)}let K=x?.mode?.(b,A,O,T,U)??U[".merge"]??"merge";switch(K){case"source":U[b]=A;continue;case"target":continue;case"skip":delete U[b],delete T[b];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${K}`)}if(typeof A==="object")if(Array.isArray(A))O.push(...A);else{if(x?.navigate?.(b,A,O,T,U)===!1)continue;Object.merge(A,O,x)}else{if(A===O)continue;let F=x?.conflict?.(b,A,O,T,U);U[b]=F===void 0?O:F}}for(let b of Object.keys(T))if(U[b]===void 0)U[b]=T[b]};var L=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,V=/^([^[\]]*)\[([^\]]*)]$/,m=(T,U,x,b)=>{if(T.startsWith("{")&&T.endsWith("}")){let O=T.substring(1,T.length-1);return Object.select(U,O,x)?.toString()}return b?T:void 0},P=(T,U,x,b)=>{let O=m(U,x,b);if(O)return Object.select(T,O,b);let A=L.exec(U);if(A){let[,F,E,j]=A,B=m(F.trim(),x,b,!0),$=m(j.trim(),x,b,!0);if(Array.isArray(T)&&(E==="="||E==="==")&&B)return T.find((Y)=>Y?.[B]==$)}let K=V.exec(U);if(K){let[,F,E]=K;return T?.[F]?.[E]}return T?.[U]};Object.select=(T,U,x)=>{let b=void 0,O=void 0,A=U??"",K=($)=>{if(!$)return[$,!1];return $.endsWith("?")?[$.substring(0,$.length-1),!0]:[$,!1]},F=($,Y)=>{let[Z,Q]=K(Y.pop());if(!Z){if(x?.set!==void 0&&O!==void 0&&b!==void 0)b[O]=x.set;return $}let f=P($,Z,T,x);if(f===void 0){if(Q||x?.optional||x?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${Z}" in "${A}"`)}return b=$,O=Z,F(f,Y)},E=A.splitNested(x?.separator??".","{","}"),j=void 0;if(E.length>0&&E[E.length-1].startsWith("?="))j=E.pop()?.substring(2);E.reverse();let B=F(T,E);if(B===void 0)return j??x?.defaultValue;return B};Object.deepClone=function(T){if(typeof structuredClone<"u")try{return structuredClone(T)}catch{}return JSON.parse(JSON.stringify(T))};Object.toList=function(T,U){return Object.entries(T).map(([x,b])=>({[U]:x,...b}))};Object.mapEntries=function(T,U){let b=Object.entries(T).map(([O,A])=>U(O,A));return Object.fromEntries(b)};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;global.defined=(T,U="Value is undefined")=>{if(T===void 0||T===null)throw Error(U);return T};String.prototype.tokenize=function(T,U=/\${([^}]+)}/g){return this.replace(U,(x,b)=>{let O=T[b];if(O===null||O===void 0)return"";if(typeof O==="string")return O;if(typeof O==="number"||typeof O==="boolean")return String(O);return String(O)})};String.prototype.toPascal=function(){return this.replace(/((?:[_ ]+)\w|^\w)/g,(T,U)=>U.toUpperCase()).replace(/[^a-zA-Z0-9 ]/g,"").replace(/[_ ]/g,"")};String.prototype.capitalize=function(){return this.replace(/((?:[ ]+)\w|^\w)/g,(T,U)=>U.toUpperCase())};String.prototype.toCamel=function(){return this.toPascal().replace(/((?:[ ]+\w)|^\w)/g,(T,U)=>U.toLowerCase())};String.prototype.toSnake=function(){return this.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/\s+/g,"_")};String.prototype.toKebab=function(){return this.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-")};String.prototype.changeCase=function(T){switch(T){case"upper":return this.toUpperCase();case"lower":return this.toLowerCase();case"pascal":return this.toPascal();case"camel":return this.toCamel();case"snake":return this.toSnake();case"kebab":return this.toKebab();default:throw Error(`Unsupported case type: ${T}`)}};String.prototype.splitWithQuotes=function(T=","){let U=[],x=this.length,b=T.length,O=0,A=(K)=>{if(K+b>x)return!1;for(let F=0;F<b;F++)if(this[K+F]!==T[F])return!1;return!0};while(O<x){while(O<x&&this[O]===" ")O++;if(O>=x)break;let K="",F=this[O]==='"'||this[O]==="'";if(F){let E=this[O++];while(O<x&&this[O]!==E)K+=this[O++];if(O<x)O++}else{while(O<x&&!A(O)){let E=this[O];if(E==='"'||E==="'"){K+=E,O++;while(O<x&&this[O]!==E)K+=this[O++];if(O<x)K+=this[O++]}else K+=this[O++]}K=K.trim()}if(K)U.push({value:K,quoted:F});if(A(O))O+=b}return U};String.prototype.splitNested=function(T,U,x){let b=0,O="",A=[];for(let K of this){if(O+=K,K===U)b++;if(K===x)b--;if(b===0&&K===T)A.push(O.slice(0,-1)),O=""}if(O)A.push(O);return A};String.prototype.toStringBuilder=function(){return new J(this.split(`
1
+ Array.prototype.findOrFail=function(T,U,O){let b=this.find(T,O);if(b===void 0)throw Error(U??"Element not found");return b};Array.flat=function(T){if(Array.isArray(T))return T.flat(2);else return[T]};Array.prototype.forEachAsync=async function(T){for(let U=0;U<this.length;U++)await T(this[U],U,this)};Array.prototype.groupBy=function(T){return this.reduce((U,O)=>{let b=T(O);if(!U[b])U[b]=[];return U[b].push(O),U},{})};Array.prototype.createInstances=function(T,...U){return this.map((O,b)=>new T(...U,O,b))};Array.prototype.mapAsync=async function(T){return Promise.all(this.map(T))};Array.prototype.nonNullMap=function(T){let U=[];for(let O=0;O<this.length;O++){let b=T(this[O],O,this);if(b!=null)U.push(b)}return U};Array.prototype.nonNullMapAsync=async function(T){let U=[];for(let O=0;O<this.length;O++){let b=await T(this[O],O,this);if(b!=null)U.push(b)}return U};Array.prototype.mergeAll=function(T){let U={};for(let O of this.slice().reverse())Object.merge(O,U,T);return U};Array.prototype.toObject=function(T,U){return Object.fromEntries(this.map((O)=>{let b=T(O),A=U?U(O):O;return[b,A]}))};Array.prototype.toObjectWithKey=function(T){return Object.fromEntries(this.map((U)=>[String(U[T]),U]))};Array.prototype.selectFor=function(T,U,O,b){let A=this.find(T,b);if(A===void 0)throw Error(O??"Element not found");return U(A)};Array.prototype.sortBy=function(T,U=!0){return this.slice().sort((O,b)=>{let A=T(O),E=T(b);if(A<E)return U?-1:1;if(A>E)return U?1:-1;return 0})};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(T){let U=new Set;return this.filter((O)=>{let b=T(O);if(U.has(b))return!1;else return U.add(b),!0})};var w;((F)=>{F[F.Explore=0]="Explore";F[F.SkipSiblings=1]="SkipSiblings";F[F.NoExplore=2]="NoExplore";F[F.ReplaceParent=3]="ReplaceParent";F[F.DeleteParent=4]="DeleteParent";F[F.MergeParent=5]="MergeParent";F[F.ReplaceItem=6]="ReplaceItem";F[F.DeleteItem=7]="DeleteItem"})(w||={});class ${action;by;skipSiblings;reexplore;constructor(T,U,O,b){this.action=T;this.by=U;this.skipSiblings=O;this.reexplore=b}static _explore=new $(0);static _noExplore=new $(2);static _skipSiblings=new $(1);static _deleteParent=new $(4);static ReplaceParent(T,U){return new $(3,T,void 0,U)}static SkipSiblings(){return $._skipSiblings}static Explore(){return $._explore}static NoExplore(){return $._noExplore}static DeleteParent(){return $._deleteParent}static MergeParent(T){return new $(5,T)}static ReplaceItem(T,U){return new $(6,T,U)}static DeleteItem(T){return new $(7,void 0,T)}}Object.navigate=async(T,U)=>{let O=new WeakSet,b=[],A=[],E=async(X,F,f)=>{let B=X===null,Y=B?$.Explore():await U({key:X,value:F,path:b,parent:f,parents:A});if(F&&typeof F==="object"&&Y.action===0){if(O.has(F))return Y;if(O.add(F),!B)b.push(X),A.push(f);let x=F;while(await K(x,X,f))x=f[X];if(!B)A.pop(),b.pop()}return Y},K=async(X,F,f)=>{let B=Object.keys(X),j=B.length;for(let Y=0;Y<j;Y++){let Z=B[Y],Q=X[Z],x=await E(Z,Q,X),G=x.action;if(G===0||G===2)continue;if(G===6){if(X[Z]=x.by,x.skipSiblings)return;continue}if(G===7){if(delete X[Z],x.skipSiblings)return;continue}if(G===1)return;if(G===3){if(F===null)throw Error("Cannot replace root object");if(f[F]=x.by,x.reexplore)return!0;return}if(G===4){if(F===null)throw Error("Cannot delete root object");delete f[F];return}if(G===5)delete X[Z],Object.assign(X,x.by)}};await E(null,T,null)};Object.find=async function(T,U){let O=[];return await Object.navigate(T,(b)=>{if(U([...b.path,b.key].join("."),b.value))O.push(b.value);return $.Explore()}),O};Object.merge=(T,U,O)=>{for(let b of Object.keys(U)){if(T[b]===void 0)continue;let A=U[b],E=T[b];if(typeof E!==typeof A||Array.isArray(E)!==Array.isArray(A)){let X=O?.mismatch?.(b,E,A,T,U);if(X!==void 0){U[b]=X;continue}throw Error(`Type mismatch: ${b}`)}let K=O?.mode?.(b,E,A,T,U)??U[".merge"]??"merge";switch(K){case"source":U[b]=E;continue;case"target":continue;case"skip":delete U[b],delete T[b];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${K}`)}if(typeof E==="object")if(Array.isArray(E))A.push(...E);else{if(O?.navigate?.(b,E,A,T,U)===!1)continue;Object.merge(E,A,O)}else{if(E===A)continue;let X=O?.conflict?.(b,E,A,T,U);U[b]=X===void 0?A:X}}for(let b of Object.keys(T))if(U[b]===void 0)U[b]=T[b]};var L=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,V=/^([^[\]]*)\[([^\]]*)]$/,C=(T,U,O,b)=>{if(T.startsWith("{")&&T.endsWith("}")){let A=T.substring(1,T.length-1);return Object.select(U,A,O)?.toString()}return b?T:void 0},P=(T,U,O,b)=>{let A=C(U,O,b);if(A)return Object.select(T,A,b);let E=L.exec(U);if(E){let[,X,F,f]=E,B=C(X.trim(),O,b,!0),j=C(f.trim(),O,b,!0);if(Array.isArray(T)&&(F==="="||F==="==")&&B)return T.find((Y)=>Y?.[B]==j)}let K=V.exec(U);if(K){let[,X,F]=K;return T?.[X]?.[F]}return T?.[U]};Object.select=(T,U,O)=>{let b=void 0,A=void 0,E=U??"",K=(j)=>{if(!j)return[j,!1];return j.endsWith("?")?[j.substring(0,j.length-1),!0]:[j,!1]},X=(j,Y)=>{let[Z,Q]=K(Y.pop());if(!Z){if(O?.set!==void 0&&A!==void 0&&b!==void 0)b[A]=O.set;return j}let x=P(j,Z,T,O);if(x===void 0){if(Q||O?.optional||O?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${Z}" in "${E}"`)}return b=j,A=Z,X(x,Y)},F=E.splitNested(O?.separator??".","{","}"),f=void 0;if(F.length>0&&F[F.length-1].startsWith("?="))f=F.pop()?.substring(2);F.reverse();let B=X(T,F);if(B===void 0)return f??O?.defaultValue;return B};Object.deepClone=function(T){if(typeof structuredClone<"u")try{return structuredClone(T)}catch{}return JSON.parse(JSON.stringify(T))};Object.toList=function(T,U){return Object.entries(T).map(([O,b])=>({[U]:O,...b}))};Object.mapEntries=function(T,U){let b=Object.entries(T).map(([A,E])=>U(A,E));return Object.fromEntries(b)};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;global.defined=(T,U="Value is undefined")=>{if(T===void 0||T===null)throw Error(U);return T};String.prototype.tokenize=function(T,U=/\${([^}]+)}/g){return this.replace(U,(O,b)=>{let A=T[b];if(A===null||A===void 0)return"";if(typeof A==="string")return A;if(typeof A==="number"||typeof A==="boolean")return String(A);return String(A)})};String.prototype.toPascal=function(){return this.replace(/((?:[_ ]+)\w|^\w)/g,(T,U)=>U.toUpperCase()).replace(/[^a-zA-Z0-9 ]/g,"").replace(/[_ ]/g,"")};String.prototype.capitalize=function(){return this.replace(/((?:[ ]+)\w|^\w)/g,(T,U)=>U.toUpperCase())};String.prototype.toCamel=function(){return this.toPascal().replace(/((?:[ ]+\w)|^\w)/g,(T,U)=>U.toLowerCase())};String.prototype.toSnake=function(){return this.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/\s+/g,"_")};String.prototype.toKebab=function(){return this.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-")};String.prototype.changeCase=function(T){switch(T){case"upper":return this.toUpperCase();case"lower":return this.toLowerCase();case"pascal":return this.toPascal();case"camel":return this.toCamel();case"snake":return this.toSnake();case"kebab":return this.toKebab();default:throw Error(`Unsupported case type: ${T}`)}};String.prototype.splitWithQuotes=function(T=","){let U=[],O=this.length,b=T.length,A=0,E=(K)=>{if(K+b>O)return!1;for(let X=0;X<b;X++)if(this[K+X]!==T[X])return!1;return!0};while(A<O){while(A<O&&this[A]===" ")A++;if(A>=O)break;let K="",X=this[A]==='"'||this[A]==="'";if(X){let F=this[A++];while(A<O&&this[A]!==F)K+=this[A++];if(A<O)A++}else{while(A<O&&!E(A)){let F=this[A];if(F==='"'||F==="'"){K+=F,A++;while(A<O&&this[A]!==F)K+=this[A++];if(A<O)K+=this[A++]}else K+=this[A++]}K=K.trim()}if(K)U.push({value:K,quoted:X});if(E(A))A+=b}return U};String.prototype.splitNested=function(T,U,O){let b=0,A="",E=[];for(let K of this){if(A+=K,K===U)b++;if(K===O)b--;if(b===0&&K===T)E.push(A.slice(0,-1)),A=""}if(A)E.push(A);return E};String.prototype.toStringBuilder=function(){return new J(this.split(`
2
2
  `))};String.prototype.padBlock=function(T,U=`
3
- `,x=" "){let b=x.repeat(T);return this.split(U).map((O)=>b+O).join(U)};String.prototype.stripIndent=function(){let T=this.split(/\r?\n/),U=T.filter((b)=>b.trim().length>0).map((b)=>/^[ \t]*/.exec(b)?.[0].length??0),x=U.length>0?Math.min(...U):0;if(x===0)return this;return T.map((b)=>b.slice(x)).join(`
4
- `)};String.prototype.toHtmlLink=function(T){return`<a href="${T??this.toString()}">${this.toString()}</a>`};String.prototype.toRgb=function(){let T=this.toString().replace("#","");if(T.length!==6)throw Error("Invalid hex color");let U=parseInt(T.substring(0,2),16),x=parseInt(T.substring(2,4),16),b=parseInt(T.substring(4,6),16);return`rgb(${U.toString()}, ${x.toString()}, ${b.toString()})`};String.prototype.toArgb=function(){let T=this.toString().replace("#","");if(T.length!==8)throw Error("Invalid hex color");let U=parseInt(T.substring(0,2),16),x=parseInt(T.substring(2,4),16),b=parseInt(T.substring(4,6),16),O=parseInt(T.substring(6,8),16);return`argb(${U.toString()}, ${x.toString()}, ${b.toString()}, ${O.toString()})`};String.prototype.single=function(T){return this.replaceAll(new RegExp(`(${T})+`,"g"),"$1")};String.prototype.remove=function(T){return this.replaceAll(new RegExp(T,"g"),"")};String.prototype.toAlphanum=function(T=""){return this.replace(/[^a-z0-9]/gi,T)};String.prototype.toAlpha=function(T=""){return this.replace(/[^a-z]/gi,T)};class R{options;constructor(T){this.options={level:"INFO",showClass:!1,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},logFunction:(U,...x)=>{switch(U){case"ERROR":console.error(...x);break;case"WARN":console.warn(...x);break;case"DEBUG":console.debug(...x);break;case"VERBOSE":console.log(...x);break;default:console.log(...x)}},...T}}write(T,...U){if(this.options.level){let O=this.options.levels.indexOf(this.options.level),A=this.options.levels.indexOf(T);if(O===-1)throw Error(`Unknown configured log level: ${this.options.level}`);if(A===-1)throw Error(`Unknown log level: ${T}`);if(A<O)return}let x=[],b=[];if(this.options.timeStamp)b.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)b.push(T);if(b.length>0)x.push(`[${b.join(" ")}]`);x.push(...U),this.options.logFunction(T,...x)}info(...T){this.write("INFO",...T)}error(...T){this.write("ERROR",...T)}warn(...T){this.write("WARN",...T)}debug(...T){this.write("DEBUG",...T)}verbose(...T){this.write("VERBOSE",...T)}}class J{#T=[];#U=0;options;constructor(T,U){if(T instanceof J)this.options={...T.options,...U},this.#T.push(...T.#T);else if(this.options=U??{},T)if(Array.isArray(T))this.#T.push(...T);else this.#T.push(T)}setOptions(T){return this.options=T,this}clear(){return this.#T.length=0,this}isEmpty(){return this.#T.length===0}toString(){return this.#T.join("")}indent(){return this.#U+=1,this}dedent(){if(this.#U>0)this.#U-=1;return this}getCurrentIndent(){return this.#U}getLines(){return this.toString().split(`
3
+ `,O=" "){let b=O.repeat(T);return this.split(U).map((A)=>b+A).join(U)};String.prototype.stripIndent=function(){let T=this.split(/\r?\n/),U=T.filter((b)=>b.trim().length>0).map((b)=>/^[ \t]*/.exec(b)?.[0].length??0),O=U.length>0?Math.min(...U):0;if(O===0)return this;return T.map((b)=>b.slice(O)).join(`
4
+ `)};String.prototype.toHtmlLink=function(T){return`<a href="${T??this.toString()}">${this.toString()}</a>`};String.prototype.toRgb=function(){let T=this.toString().replace("#","");if(T.length!==6)throw Error("Invalid hex color");let U=parseInt(T.substring(0,2),16),O=parseInt(T.substring(2,4),16),b=parseInt(T.substring(4,6),16);return`rgb(${U.toString()}, ${O.toString()}, ${b.toString()})`};String.prototype.toArgb=function(){let T=this.toString().replace("#","");if(T.length!==8)throw Error("Invalid hex color");let U=parseInt(T.substring(0,2),16),O=parseInt(T.substring(2,4),16),b=parseInt(T.substring(4,6),16),A=parseInt(T.substring(6,8),16);return`argb(${U.toString()}, ${O.toString()}, ${b.toString()}, ${A.toString()})`};String.prototype.single=function(T){return this.replaceAll(new RegExp(`(${T})+`,"g"),"$1")};String.prototype.remove=function(T){return this.replaceAll(new RegExp(T,"g"),"")};String.prototype.toAlphanum=function(T=""){return this.replace(/[^a-z0-9]/gi,T)};String.prototype.toAlpha=function(T=""){return this.replace(/[^a-z]/gi,T)};class R{options;constructor(T){this.options={level:"INFO",showClass:!1,useColors:!0,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},onClass:(U)=>{return U},onTime:(U,O)=>{return U},onPrefix:(U,O)=>{return U},logFunction:(U,...O)=>{switch(U){case"ERROR":console.error(...O);break;case"WARN":console.warn(...O);break;case"DEBUG":console.debug(...O);break;case"VERBOSE":console.log(...O);break;default:console.log(...O)}},...T}}write(T,...U){if(this.options.level){let E=this.options.levels.indexOf(this.options.level),K=this.options.levels.indexOf(T);if(E===-1)throw Error(`Unknown configured log level: ${this.options.level}`);if(K===-1)throw Error(`Unknown log level: ${T}`);if(K<E)return}let O=[],b=[];if(this.options.timeStamp)b.push(this.options.onTime(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions),T));if(this.options.showClass)b.push(this.options.onClass(T));if(b.length>0)O.push(this.options.onPrefix(`[${b.join(" ")}]`,T));O.push(...U);let A=O.map((E)=>{if(this.options.useColors&&typeof E==="string"){let K=/<color=([^>]+)>(.*?)<\/color>/g;return E=E.replace(K,(X,F,f)=>this.color(f,F)),E}return E});this.options.logFunction(T,...A)}color(T,U){let O,b,A;if(typeof U==="string"){let E={red:"#FF0000",green:"#00FF00",blue:"#0000FF",yellow:"#FFFF00",cyan:"#00FFFF",magenta:"#FF00FF",white:"#FFFFFF",black:"#000000",orange:"#FFA500",purple:"#800080",pink:"#FFC0CB",gray:"#808080",grey:"#808080"};if(E[U])U=E[U];if(U.startsWith("#")){let K=U.slice(1);if(K.length===3)O=parseInt(K[0]+K[0],16),b=parseInt(K[1]+K[1],16),A=parseInt(K[2]+K[2],16);else if(K.length===6)O=parseInt(K.slice(0,2),16),b=parseInt(K.slice(2,4),16),A=parseInt(K.slice(4,6),16);else throw Error(`Invalid hex color: ${U}`)}else if(U.includes(";")){let K=U.split(";").map(Number);if(K.length!==3||K.some(isNaN))throw Error(`Invalid RGB color string: ${U}`);[O,b,A]=K}else throw Error(`Unsupported color string format: ${U}`)}else if(Array.isArray(U))[O,b,A]=U;else if(typeof U==="number")O=U>>16&255,b=U>>8&255,A=U&255;else({r:O,g:b,b:A}=U);return`\x1B[38;2;${O.toString()};${b.toString()};${A.toString()}m${T}\x1B[0m`}info(...T){this.write("INFO",...T)}error(...T){this.write("ERROR",...T)}warn(...T){this.write("WARN",...T)}debug(...T){this.write("DEBUG",...T)}verbose(...T){this.write("VERBOSE",...T)}}class J{#T=[];#U=0;options;constructor(T,U){if(T instanceof J)this.options={...T.options,...U},this.#T.push(...T.#T);else if(this.options=U??{},T)if(Array.isArray(T))this.#T.push(...T);else this.#T.push(T)}setOptions(T){return this.options=T,this}clear(){return this.#T.length=0,this}isEmpty(){return this.#T.length===0}toString(){return this.#T.join("")}indent(){return this.#U+=1,this}dedent(){if(this.#U>0)this.#U-=1;return this}getCurrentIndent(){return this.#U}getLines(){return this.toString().split(`
5
5
  `)}formatLine(T){T??=`
6
6
  `;let U=(this.options.indentChar??" ").repeat(this.#U*(this.options.indentSize??2));if(this.options.trim)T=T.trim();return U+(this.options.linePrefix??"")+T+(this.options.lineSuffix??"")+(this.options.lineSeparator??`
7
7
  `)}write(...T){return this.#T.push(...T.flatMap((U)=>{if(U!==void 0){if(typeof U==="string")return U;if(Array.isArray(U))return U.flat();if(U instanceof J)return U.toString();if(typeof U==="function")return U(this);return String(U)}}).filter((U)=>U!==void 0)),this}writeLine(...T){return this.write(T.length>0?T.map((U)=>this.formatLine(U)):`
8
- `)}writeMap(T,U){return T.forEach((x,b)=>U(x,b,this)),this}}class S extends J{#T=0;#U="```";#x(T){return Math.min(6,Math.max(1,Math.floor(T)))}#b(T){if(T===void 0)return"```";let U=0;for(let x of T.matchAll(/`+/g))U=Math.max(U,x[0].length);return"`".repeat(Math.max(3,U+1))}header(T,U=1){let x=this.#x(U);return this.writeLine(`${"#".repeat(x)} ${T}`,"")}codeBlock(T,U){let x=this.#b(T);if(this.#U=x,U??="",this.writeLine(x+U),T!==void 0)this.writeLine(T).endCodeBlock();return this}endCodeBlock(){let T=this.#U;return this.#U="```",this.writeLine(T)}link(T,U,x){if(x)return this.write(`[${T}](${U} "${x}")`);return this.write(`[${T}](${U})`)}table(T,U){if(T.length===0)throw Error("Table requires at least one header");let x=T.map((A,K)=>{let F=A.length;return U.forEach((E)=>{if(E[K])F=Math.max(F,E[K].length)}),F}),b=T.map((A,K)=>A.padEnd(x[K]));this.writeLine("| "+b.join(" | ")+" |");let O=x.map((A)=>"-".repeat(A));return this.writeLine("| "+O.join(" | ")+" |"),U.forEach((A)=>{let K=T.map((F,E)=>(A[E]??"").padEnd(x[E]));this.writeLine("| "+K.join(" | ")+" |")}),this}blockquote(T){return T.split(`
9
- `).forEach((x)=>this.writeLine("> "+x)),this}bold(T){return this.write(`**${T}**`)}italic(T){return this.write(`*${T}*`)}item(T){return this.writeLine(`- ${T}`)}items(T){if(Array.isArray(T))T.forEach((U)=>this.item(U));else Object.entries(T).forEach(([U,x])=>x!==void 0&&this.item(`${U}: ${x!==void 0?String(x):""}`));return this}orderedList(T,U=1){return T.forEach((x,b)=>this.writeLine(`${(b+U).toString()}. ${x}`)),this}code(T){return this.write(`\`${T}\``)}horizontalRule(){return this.writeLine("---")}image(T,U){return this.writeLine(`![${T}](${U})`)}strikethrough(T){return this.write(`~~${T}~~`)}highlight(T){return this.write(`==${T}==`)}subscript(T){return this.write(`~${T}~`)}superscript(T){return this.write(`^${T}^`)}taskList(T){return T.forEach((U)=>this.writeLine(`- [${U.checked?"x":" "}] ${U.text}`)),this}section(T,U){if(U!==void 0)this.#T=this.#x(U);else this.#T=Math.min(6,this.#T+1);return this.header(T,this.#T)}endSection(){if(this.#T>0)this.#T--;return this}setSectionLevel(T){return this.#T=Math.min(6,Math.max(0,Math.floor(T))),this}}class k{#T;#U;#x=new Map;#b=[];constructor(T,U=[]){this.#T=[...T],this.#U=[...U],this.#E()}get args(){return[...this.#T]}get positionals(){return[...this.#b]}has(T){return this.#x.has(this.#O(T))}getArgs(T){return[...this.#x.get(this.#O(T))?.values??[]]}get(T){let U=this.#x.get(this.#O(T))?.values;if(!U)return;if(U.length===0)return!0;return U[0]}toObject(){let T={};for(let[U,x]of this.#x.entries())T[U]=x.values.length>0?[...x.values]:!0;return T}usage(T="command"){let U=[`Usage: ${T} [options]`];if(this.#b.length>0)U[0]+=" [values]";if(this.#U.length===0)return U.join(`
10
- `);U.push("","Options:");for(let x of this.#U){let b=`--${x.name}`,O=x.alias?`-${x.alias}`:void 0,A=x.valueName??"value",K=x.takesValue?x.multiple?` <${A}...>`:` <${A}>`:"",F=O?`${O}, ${b}`:b,E=x.description?` ${x.description}`:"";U.push(` ${F}${K}${E}`)}return U.join(`
11
- `)}#E(){for(let T=0;T<this.#T.length;T++){let U=this.#T[T];if(!U.startsWith("-")||U==="-"){this.#b.push(U);continue}if(U.startsWith("--")&&U.includes("=")){let O=U.indexOf("="),A=this.#O(U.slice(0,O)),K=U.slice(O+1);this.#A(A,K.length>0?[K]:[""],!0);continue}let x=this.#O(U),b=[];while(T+1<this.#T.length){let O=this.#T[T+1];if(O.startsWith("-")&&O!=="-")break;b.push(O),T++}this.#A(x,b,!1)}}#A(T,U,x){let b=this.#x.get(T);if(!b){this.#x.set(T,{values:[...U],sawEqualsStyle:x});return}b.values.push(...U),b.sawEqualsStyle=b.sawEqualsStyle||x}#O(T){return T.replace(/^-+/,"").trim()}}import M from"fs/promises";var q=async(T)=>{try{return await M.access(T,M.constants.R_OK),!0}catch{return!1}};import C from"path";var D=async(T,U)=>{let x=!C.isAbsolute(T)&&U?["",...U]:[""];for(let b of x){let O=C.join(b,T);if(await q(O))return C.resolve(O)}throw Error(`File not found: "${T}"`)};import N from"fs/promises";import d from"path";var h=(T,U)=>U?.some((x)=>new RegExp(x).test(T))===!0,vT=async(T,U)=>{let x=await D(T,U?.dirs),b=await N.readFile(x,"utf-8"),O=d.dirname(x),A={text:{fn:(E)=>E,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...U?.parsers},K=U?.format?A[U.format]:Object.values(A).find((E)=>h(T,E.matching));if(!K)throw Error(`Unsupported format for file "${T}" and no matching parser found`);return{content:await K.fn(b),fullPath:x,folderPath:O}};import r from"fs/promises";var g=(T,U)=>U?.some((x)=>new RegExp(x).test(T))===!0,I=async(T,U,x)=>{let b={text:{fn:(A)=>A,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...x?.encoders},O=x?.format?b[x.format]:Object.values(b).find((A)=>g(T,A.matching));if(!O)throw Error(`Unsupported format for file "${T}" and no matching encoder found`);await r.writeFile(T,await O.fn(U))};import v from"fs/promises";var nT=async(T,U)=>{if(typeof T==="string"&&!T.includes("*"))return await U.map(T,0,[]);let x=await Array.fromAsync(v.glob(T,{cwd:U.cwd})),b=U.filter?x.filter(U.filter):x;return await Promise.all(b.map(U.map))};import W from"fs/promises";import z from"path";var aT=async(T,U)=>{if(U?.targetDirectory&&U?.removeFirst)try{await W.rm(U?.targetDirectory,{recursive:!0,force:!0})}catch(x){throw Error(`Failed to clean the output directory: ${x.message}`,{cause:x})}for(let x of T)await c(x,U)},c=async(T,U)=>{let x=z.join(U?.targetDirectory??".",T.name),b=z.dirname(x);if(U?.classes){if(T.class!==void 0&&!U.classes.includes(T.class))return;if(U.classRequired&&T.class===void 0)throw Error(`Output "${T.name}" is missing class field`)}if(U?.writing?.(T)===!1)return;try{await W.mkdir(b,{recursive:!0})}catch(O){throw Error(`Failed to create target directory "${b}" for output "${x}": ${O.message}`,{cause:O})}try{await I(x,T.value,{format:T.type??"text"})}catch(O){throw Error(`Failed to write output "${x}": ${O.message}`,{cause:O})}};import p from"fs/promises";import H from"path";import y from"path";var _=(T)=>T?y.isAbsolute(T)?T:y.join(process.cwd(),T):process.cwd();var u=async(T,U)=>{let x=[];for(let b of T)try{let O=!H.isAbsolute(b)?H.join(_(U?.cwd),b):b;if(U?.filter?.(O)===!1)continue;let A=await import(O);if(U?.resolveDefault==="only"&&!A.default)throw Error(`Module ${b} does not have a default export`);let K=U?.resolveDefault?A.default??A:A,F=U?.map?await U.map(K,b):K;if(F!==void 0)x.push(F)}catch(O){if(U?.fail?.(b,O)===!1)continue;throw Error(`Failed to import module ${b}: ${O.message??O}`,{cause:O})}return x},AU=async(T,U)=>{let x=[],b=_(U?.cwd);for(let O of T){let A=(await Array.fromAsync(p.glob(O,{cwd:b}))).map((K)=>H.join(b,K));x.push(...await u(A,U))}return x};export{aT as writeOutputs,c as writeOutput,I as writeFormat,D as locate,vT as loadFormat,u as importList,AU as importGlob,nT as globMap,_ as getCwd,q as exists,J as StringBuilder,X as NavigateResult,w as NavigateAction,S as Markdown,R as Logger,k as CommandLineArgs};
8
+ `)}writeMap(T,U){return T.forEach((O,b)=>U(O,b,this)),this}}class S extends J{#T=0;#U="```";#O(T){return Math.min(6,Math.max(1,Math.floor(T)))}#b(T){if(T===void 0)return"```";let U=0;for(let O of T.matchAll(/`+/g))U=Math.max(U,O[0].length);return"`".repeat(Math.max(3,U+1))}header(T,U=1){let O=this.#O(U);return this.writeLine(`${"#".repeat(O)} ${T}`,"")}codeBlock(T,U){let O=this.#b(T);if(this.#U=O,U??="",this.writeLine(O+U),T!==void 0)this.writeLine(T).endCodeBlock();return this}endCodeBlock(){let T=this.#U;return this.#U="```",this.writeLine(T)}link(T,U,O){if(O)return this.write(`[${T}](${U} "${O}")`);return this.write(`[${T}](${U})`)}table(T,U){if(T.length===0)throw Error("Table requires at least one header");let O=T.map((E,K)=>{let X=E.length;return U.forEach((F)=>{if(F[K])X=Math.max(X,F[K].length)}),X}),b=T.map((E,K)=>E.padEnd(O[K]));this.writeLine("| "+b.join(" | ")+" |");let A=O.map((E)=>"-".repeat(E));return this.writeLine("| "+A.join(" | ")+" |"),U.forEach((E)=>{let K=T.map((X,F)=>(E[F]??"").padEnd(O[F]));this.writeLine("| "+K.join(" | ")+" |")}),this}blockquote(T){return T.split(`
9
+ `).forEach((O)=>this.writeLine("> "+O)),this}bold(T){return this.write(`**${T}**`)}italic(T){return this.write(`*${T}*`)}item(T){return this.writeLine(`- ${T}`)}items(T){if(Array.isArray(T))T.forEach((U)=>this.item(U));else Object.entries(T).forEach(([U,O])=>O!==void 0&&this.item(`${U}: ${O!==void 0?String(O):""}`));return this}orderedList(T,U=1){return T.forEach((O,b)=>this.writeLine(`${(b+U).toString()}. ${O}`)),this}code(T){return this.write(`\`${T}\``)}horizontalRule(){return this.writeLine("---")}image(T,U){return this.writeLine(`![${T}](${U})`)}strikethrough(T){return this.write(`~~${T}~~`)}highlight(T){return this.write(`==${T}==`)}subscript(T){return this.write(`~${T}~`)}superscript(T){return this.write(`^${T}^`)}taskList(T){return T.forEach((U)=>this.writeLine(`- [${U.checked?"x":" "}] ${U.text}`)),this}section(T,U){if(U!==void 0)this.#T=this.#O(U);else this.#T=Math.min(6,this.#T+1);return this.header(T,this.#T)}endSection(){if(this.#T>0)this.#T--;return this}setSectionLevel(T){return this.#T=Math.min(6,Math.max(0,Math.floor(T))),this}}class k{#T;#U;#O=new Map;#b=[];constructor(T,U=[]){this.#T=[...T],this.#U=[...U],this.#K()}get args(){return[...this.#T]}get positionals(){return[...this.#b]}has(T){return this.#O.has(this.#A(T))}getArgs(T){return[...this.#O.get(this.#A(T))?.values??[]]}get(T){let U=this.#O.get(this.#A(T))?.values;if(!U)return;if(U.length===0)return!0;return U[0]}toObject(){let T={};for(let[U,O]of this.#O.entries())T[U]=O.values.length>0?[...O.values]:!0;return T}usage(T="command"){let U=[`Usage: ${T} [options]`];if(this.#b.length>0)U[0]+=" [values]";if(this.#U.length===0)return U.join(`
10
+ `);U.push("","Options:");for(let O of this.#U){let b=`--${O.name}`,A=O.alias?`-${O.alias}`:void 0,E=O.valueName??"value",K=O.takesValue?O.multiple?` <${E}...>`:` <${E}>`:"",X=A?`${A}, ${b}`:b,F=O.description?` ${O.description}`:"";U.push(` ${X}${K}${F}`)}return U.join(`
11
+ `)}#K(){for(let T=0;T<this.#T.length;T++){let U=this.#T[T];if(!U.startsWith("-")||U==="-"){this.#b.push(U);continue}if(U.startsWith("--")&&U.includes("=")){let A=U.indexOf("="),E=this.#A(U.slice(0,A)),K=U.slice(A+1);this.#E(E,K.length>0?[K]:[""],!0);continue}let O=this.#A(U),b=[];while(T+1<this.#T.length){let A=this.#T[T+1];if(A.startsWith("-")&&A!=="-")break;b.push(A),T++}this.#E(O,b,!1)}}#E(T,U,O){let b=this.#O.get(T);if(!b){this.#O.set(T,{values:[...U],sawEqualsStyle:O});return}b.values.push(...U),b.sawEqualsStyle=b.sawEqualsStyle||O}#A(T){return T.replace(/^-+/,"").trim()}}import D from"fs/promises";var I=async(T)=>{try{return await D.access(T,D.constants.R_OK),!0}catch{return!1}};import _ from"path";var M=async(T,U)=>{let O=!_.isAbsolute(T)&&U?["",...U]:[""];for(let b of O){let A=_.join(b,T);if(await I(A))return _.resolve(A)}throw Error(`File not found: "${T}"`)};import N from"fs/promises";import d from"path";var h=(T,U)=>U?.some((O)=>new RegExp(O).test(T))===!0,pT=async(T,U)=>{let O=await M(T,U?.dirs),b=await N.readFile(O,"utf-8"),A=d.dirname(O),E={text:{fn:(F)=>F,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...U?.parsers},K=U?.format?E[U.format]:Object.values(E).find((F)=>h(T,F.matching));if(!K)throw Error(`Unsupported format for file "${T}" and no matching parser found`);return{content:await K.fn(b),fullPath:O,folderPath:A}};import g from"fs/promises";var v=(T,U)=>U?.some((O)=>new RegExp(O).test(T))===!0,m=async(T,U,O)=>{let b={text:{fn:(E)=>E,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...O?.encoders},A=O?.format?b[O.format]:Object.values(b).find((E)=>v(T,E.matching));if(!A)throw Error(`Unsupported format for file "${T}" and no matching encoder found`);await g.writeFile(T,await A.fn(U))};import p from"fs/promises";var oT=async(T,U)=>{if(typeof T==="string"&&!T.includes("*"))return await U.map(T,0,[]);let O=await Array.fromAsync(p.glob(T,{cwd:U.cwd})),b=U.filter?O.filter(U.filter):O;return await Promise.all(b.map(U.map))};import W from"fs/promises";import z from"path";var aT=async(T,U)=>{if(U?.targetDirectory&&U?.removeFirst)try{await W.rm(U?.targetDirectory,{recursive:!0,force:!0})}catch(O){throw Error(`Failed to clean the output directory: ${O.message}`,{cause:O})}for(let O of T)await u(O,U)},u=async(T,U)=>{let O=z.join(U?.targetDirectory??".",T.name),b=z.dirname(O);if(U?.classes){if(T.class!==void 0&&!U.classes.includes(T.class))return;if(U.classRequired&&T.class===void 0)throw Error(`Output "${T.name}" is missing class field`)}if(U?.writing?.(T)===!1)return;try{await W.mkdir(b,{recursive:!0})}catch(A){throw Error(`Failed to create target directory "${b}" for output "${O}": ${A.message}`,{cause:A})}try{await m(O,T.value,{format:T.type??"text"})}catch(A){throw Error(`Failed to write output "${O}": ${A.message}`,{cause:A})}};import r from"fs/promises";import q from"path";import y from"path";var H=(T)=>T?y.isAbsolute(T)?T:y.join(process.cwd(),T):process.cwd();var c=async(T,U)=>{let O=[];for(let b of T)try{let A=!q.isAbsolute(b)?q.join(H(U?.cwd),b):b;if(U?.filter?.(A)===!1)continue;let E=await import(A);if(U?.resolveDefault==="only"&&!E.default)throw Error(`Module ${b} does not have a default export`);let K=U?.resolveDefault?E.default??E:E,X=U?.map?await U.map(K,b):K;if(X!==void 0)O.push(X)}catch(A){if(U?.fail?.(b,A)===!1)continue;throw Error(`Failed to import module ${b}: ${A.message??A}`,{cause:A})}return O},EU=async(T,U)=>{let O=[],b=H(U?.cwd);for(let A of T){let E=(await Array.fromAsync(r.glob(A,{cwd:b}))).map((K)=>q.join(b,K));O.push(...await c(E,U))}return O};export{aT as writeOutputs,u as writeOutput,m as writeFormat,M as locate,pT as loadFormat,c as importList,EU as importGlob,oT as globMap,H as getCwd,I as exists,J as StringBuilder,$ as NavigateResult,w as NavigateAction,S as Markdown,R as Logger,k as CommandLineArgs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homedev/framework",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "homedev framework",
5
5
  "author": "julzor",
6
6
  "license": "ISC",