@homedev/framework 0.0.4 → 0.0.6

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,16 +1,3 @@
1
- /**
2
- * Constructor for creating async functions dynamically from source code strings.
3
- * Equivalent to the built-in async function constructor.
4
- *
5
- * @example
6
- * ```typescript
7
- * const fn = new AsyncFunction('x', 'y', 'return x + y')
8
- * await fn(2, 3) // 5
9
- * ```
10
- */
11
- declare const AsyncFunction_2: any;
12
- export { AsyncFunction_2 as AsyncFunction }
13
-
14
1
  /**
15
2
  * Guards against undefined and null values.
16
3
  * Throws an error if the value is nullish, otherwise returns the value.
@@ -33,6 +20,57 @@ export { AsyncFunction_2 as AsyncFunction }
33
20
  declare function defined_2<T>(value: T | undefined | null, message?: string): T;
34
21
  export { defined_2 as defined }
35
22
 
23
+ export declare type LogFunction = (className: string, ...args: any[]) => void;
24
+
25
+ export declare class Logger {
26
+ options: LoggerOptions;
27
+ constructor(options?: Partial<LoggerOptions>);
28
+ write(className: string, ...args: any[]): void;
29
+ info(...args: any[]): void;
30
+ error(...args: any[]): void;
31
+ warn(...args: any[]): void;
32
+ debug(...args: any[]): void;
33
+ verbose(...args: any[]): void;
34
+ }
35
+
36
+ export declare interface LoggerOptions {
37
+ level: string;
38
+ showClass: boolean;
39
+ levels: string[];
40
+ timeStamp: boolean;
41
+ timeLocale?: string;
42
+ timeOptions?: Intl.DateTimeFormatOptions;
43
+ logFunction: LogFunction;
44
+ }
45
+
46
+ export declare class Markdown extends StringBuilder {
47
+ #private;
48
+ header(text: string, level?: number): this;
49
+ codeBlock(code: string, language?: string): this;
50
+ link(text: string, url: string): this;
51
+ table(headers: string[], rows: string[][]): this;
52
+ blockquote(text: string): this;
53
+ bold(text: string): this;
54
+ italic(text: string): this;
55
+ item(text: string): this;
56
+ list(items: string[]): this;
57
+ orderedList(items: string[], start?: number): this;
58
+ code(text: string): this;
59
+ horizontalRule(): this;
60
+ image(alt: string, url: string): this;
61
+ strikethrough(text: string): this;
62
+ highlight(text: string): this;
63
+ subscript(text: string): this;
64
+ superscript(text: string): this;
65
+ taskList(items: {
66
+ text: string;
67
+ checked: boolean;
68
+ }[]): this;
69
+ section(text: string): this;
70
+ endSection(): this;
71
+ setSectionLevel(level: number): this;
72
+ }
73
+
36
74
  /**
37
75
  * @public
38
76
  */
@@ -118,6 +156,16 @@ export declare interface SelectOptions {
118
156
  optional?: boolean;
119
157
  }
120
158
 
159
+ export declare class StringBuilder {
160
+ #private;
161
+ constructor(initial?: string | string[]);
162
+ append(...args: any[]): this;
163
+ appendLine(...args: any[]): this;
164
+ clear(): this;
165
+ isEmpty(): boolean;
166
+ toString(): string;
167
+ }
168
+
121
169
  export { }
122
170
 
123
171
  /* Global declarations */
@@ -180,6 +228,8 @@ declare global {
180
228
  padBlock(indent: number, separator?: string, padder?: string): string;
181
229
  tokenize(from: Record<string, unknown>, tokenizer?: RegExp): string;
182
230
  stripIndent(): string;
231
+ toHtmlLink(path?: string): string;
232
+ toStringBuilder(): StringBuilder;
183
233
  }
184
234
  }
185
235
 
package/dist/index.js CHANGED
@@ -1,3 +1,9 @@
1
- Array.prototype.findOrFail=function(T,n,m){let r=this.find(T,m);if(r===void 0)throw Error(n??"Element not found");return r};Array.flat=function(T){if(Array.isArray(T))return T.flat(2);else return[T]};Array.prototype.forEachAsync=async function(T){for(let n=0;n<this.length;n++)await T(this[n],n,this)};Array.prototype.groupBy=function(T){return this.reduce((n,m)=>{let r=T(m);if(!n[r])n[r]=[];return n[r].push(m),n},{})};Array.prototype.createInstances=function(T,...n){return this.map((m,r)=>new T(...n,m,r))};Array.prototype.mapAsync=async function(T){return Promise.all(this.map(T))};Array.prototype.nonNullMap=function(T){let n=[];for(let m=0;m<this.length;m++){let r=T(this[m],m,this);if(r!=null)n.push(r)}return n};Array.prototype.nonNullMapAsync=async function(T){let n=[];for(let m=0;m<this.length;m++){let r=await T(this[m],m,this);if(r!=null)n.push(r)}return n};Array.prototype.mergeAll=function(T){let n={};for(let m of this.toReversed())Object.merge(m,n,T);return n};Array.prototype.toObject=function(T,n){return Object.fromEntries(this.map((m)=>{let r=T(m),f=n?n(m):m;return[r,f]}))};Array.prototype.toObjectWithKey=function(T){return Object.fromEntries(this.map((n)=>[String(n[T]),n]))};Array.prototype.selectFor=function(T,n,m,r){let f=this.find(T,r);if(f===void 0)throw Error(m??"Element not found");return n(f)};Array.prototype.sortBy=function(T,n=!0){return this.slice().sort((m,r)=>{let f=T(m),b=T(r);if(f<b)return n?-1:1;if(f>b)return n?1:-1;return 0})};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(T){let n=new Set;return this.filter((m)=>{let r=T(m);if(n.has(r))return!1;else return n.add(r),!0})};var y;((x)=>{x[x.Explore=0]="Explore";x[x.SkipSiblings=1]="SkipSiblings";x[x.NoExplore=2]="NoExplore";x[x.ReplaceParent=3]="ReplaceParent";x[x.DeleteParent=4]="DeleteParent";x[x.MergeParent=5]="MergeParent";x[x.ReplaceItem=6]="ReplaceItem";x[x.DeleteItem=7]="DeleteItem"})(y||={});class F{action;by;skipSiblings;reexplore;constructor(T,n,m,r){this.action=T;this.by=n;this.skipSiblings=m;this.reexplore=r}static _explore=new F(0);static _noExplore=new F(2);static _skipSiblings=new F(1);static _deleteParent=new F(4);static ReplaceParent(T,n){return new F(3,T,void 0,n)}static SkipSiblings(){return F._skipSiblings}static Explore(){return F._explore}static NoExplore(){return F._noExplore}static DeleteParent(){return F._deleteParent}static MergeParent(T){return new F(5,T)}static ReplaceItem(T,n){return new F(6,T,n)}static DeleteItem(T){return new F(7,void 0,T)}}Object.navigate=async(T,n)=>{let m=new WeakSet,r=[],f=[],b=async(o,x,E)=>{let O=o===null,A=O?F.Explore():await n({key:o,value:x,path:r,parent:E,parents:f});if(x&&typeof x==="object"&&A.action===0){if(m.has(x))return A;if(m.add(x),!O)r.push(o),f.push(E);let w=x;while(await d(w,o,E))w=E[o];if(!O)f.pop(),r.pop()}return A},d=async(o,x,E)=>{let O=Object.keys(o),U=O.length;for(let A=0;A<U;A++){let B=O[A],C=o[B],w=await b(B,C,o),K=w.action;if(K===0||K===2)continue;if(K===6){if(o[B]=w.by,w.skipSiblings)return;continue}if(K===7){if(delete o[B],w.skipSiblings)return;continue}if(K===1)return;if(K===3){if(x===null)throw Error("Cannot replace root object");if(E[x]=w.by,w.reexplore)return!0;return}if(K===4){if(x===null)throw Error("Cannot delete root object");delete E[x];return}if(K===5)delete o[B],Object.assign(o,w.by)}};await b(null,T,null)};Object.find=async function(T,n){let m=[];return await Object.navigate(T,(r)=>{if(n([...r.path,r.key].join("."),r.value))m.push(r.value);return F.Explore()}),m};Object.merge=(T,n,m)=>{for(let r of Object.keys(n)){if(T[r]===void 0)continue;let f=n[r],b=T[r];if(typeof b!==typeof f||Array.isArray(b)!==Array.isArray(f)){let o=m?.mismatch?.(r,b,f,T,n);if(o!==void 0){n[r]=o;continue}throw Error(`Type mismatch: ${r}`)}let d=m?.mode?.(r,b,f,T,n)??n[".merge"]??"merge";switch(d){case"source":n[r]=b;continue;case"target":continue;case"skip":delete n[r],delete T[r];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${d}`)}if(typeof b==="object")if(Array.isArray(b))f.push(...b);else{if(m?.navigate?.(r,b,f,T,n)===!1)continue;Object.merge(b,f,m)}else{if(b===f)continue;let o=m?.conflict?.(r,b,f,T,n);n[r]=o===void 0?f:o}}for(let r of Object.keys(T))if(n[r]===void 0)n[r]=T[r]};var I=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,X=/^([^[\]]*)\[([^\]]*)]$/,P=(T,n,m,r)=>{if(T.startsWith("{")&&T.endsWith("}")){let f=T.substring(1,T.length-1);return Object.select(n,f,m)?.toString()}return r?T:void 0},j=(T,n,m,r)=>{let f=P(n,m,r);if(f)return Object.select(T,f,r);let b=I.exec(n);if(b){let[,o,x,E]=b,O=P(o.trim(),m,r,!0),U=P(E.trim(),m,r,!0);if(Array.isArray(T)&&(x==="="||x==="==")&&O)return T.find((A)=>A?.[O]==U)}let d=X.exec(n);if(d){let[,o,x]=d;return T?.[o]?.[x]}return T?.[n]};Object.select=(T,n,m)=>{let r=void 0,f=void 0,b=n??"",d=(U)=>{if(!U)return[U,!1];return U.endsWith("?")?[U.substring(0,U.length-1),!0]:[U,!1]},o=(U,A)=>{let[B,C]=d(A.pop());if(!B){if(m?.set!==void 0&&f!==void 0&&r!==void 0)r[f]=m.set;return U}let w=j(U,B,T,m);if(w===void 0){if(C||m?.optional||m?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${B}" in "${b}"`)}return r=U,f=B,o(w,A)},x=b.splitNested(m?.separator??".","{","}"),E=void 0;if(x.length>0&&x[x.length-1].startsWith("?="))E=x.pop()?.substring(2);x.reverse();let O=o(T,x);if(O===void 0)return E??m?.defaultValue;return O};Object.deepClone=function(T){if(typeof structuredClone<"u")try{return structuredClone(T)}catch{}return JSON.parse(JSON.stringify(T))};Object.toList=function(T,n){return Object.entries(T).map(([m,r])=>({[n]:m,...r}))};Object.mapEntries=function(T,n){let r=Object.entries(T).map(([f,b])=>n(f,b));return Object.fromEntries(r)};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;global.defined=(T,n="Value is undefined")=>{if(T===void 0||T===null)throw Error(n);return T};String.prototype.tokenize=function(T,n=/\${([^}]+)}/g){return this.replace(n,(m,r)=>{let f=T[r];if(f===null||f===void 0)return"";if(typeof f==="string")return f;if(typeof f==="number"||typeof f==="boolean")return String(f);return String(f)})};String.prototype.toPascal=function(){return this.replace(/((?:[_ ]+)\w|^\w)/g,(T,n)=>n.toUpperCase()).replace(/[_ ]/g,"")};String.prototype.capitalize=function(){return this.replace(/((?:[ ]+)\w|^\w)/g,(T,n)=>n.toUpperCase())};String.prototype.toCamel=function(){return this.toPascal().replace(/((?:[ ]+\w)|^\w)/g,(T,n)=>n.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 n=[],m=this.length,r=T.length,f=0,b=(d)=>{if(d+r>m)return!1;for(let o=0;o<r;o++)if(this[d+o]!==T[o])return!1;return!0};while(f<m){while(f<m&&this[f]===" ")f++;if(f>=m)break;let d="",o=this[f]==='"'||this[f]==="'";if(o){let x=this[f++];while(f<m&&this[f]!==x)d+=this[f++];if(f<m)f++}else{while(f<m&&!b(f)){let x=this[f];if(x==='"'||x==="'"){d+=x,f++;while(f<m&&this[f]!==x)d+=this[f++];if(f<m)d+=this[f++]}else d+=this[f++]}d=d.trim()}if(d)n.push({value:d,quoted:o});if(b(f))f+=r}return n};String.prototype.splitNested=function(T,n,m){let r=0,f="",b=[];for(let d of this){if(f+=d,d===n)r++;if(d===m)r--;if(r===0&&d===T)b.push(f.slice(0,-1)),f=""}if(f)b.push(f);return b};String.prototype.padBlock=function(T,n=`
2
- `,m=" "){let r=m.repeat(T);return this.split(n).map((f)=>r+f).join(n)};String.prototype.stripIndent=function(){let T=this.split(/\r?\n/),n=T.filter((r)=>r.trim().length>0).map((r)=>/^[ \t]*/.exec(r)?.[0].length??0),m=n.length>0?Math.min(...n):0;if(m===0)return this;return T.map((r)=>r.slice(m)).join(`
3
- `)};var W=Object.getPrototypeOf(async function(){}).constructor;function i(T,n="Value is undefined"){if(T===void 0||T===null)throw Error(n);return T}export{i as defined,F as NavigateResult,y as NavigateAction,W as AsyncFunction};
1
+ Array.prototype.findOrFail=function(n,r,t){let s=this.find(n,t);if(s===void 0)throw Error(r??"Element not found");return s};Array.flat=function(n){if(Array.isArray(n))return n.flat(2);else return[n]};Array.prototype.forEachAsync=async function(n){for(let r=0;r<this.length;r++)await n(this[r],r,this)};Array.prototype.groupBy=function(n){return this.reduce((r,t)=>{let s=n(t);if(!r[s])r[s]=[];return r[s].push(t),r},{})};Array.prototype.createInstances=function(n,...r){return this.map((t,s)=>new n(...r,t,s))};Array.prototype.mapAsync=async function(n){return Promise.all(this.map(n))};Array.prototype.nonNullMap=function(n){let r=[];for(let t=0;t<this.length;t++){let s=n(this[t],t,this);if(s!=null)r.push(s)}return r};Array.prototype.nonNullMapAsync=async function(n){let r=[];for(let t=0;t<this.length;t++){let s=await n(this[t],t,this);if(s!=null)r.push(s)}return r};Array.prototype.mergeAll=function(n){let r={};for(let t of this.toReversed())Object.merge(t,r,n);return r};Array.prototype.toObject=function(n,r){return Object.fromEntries(this.map((t)=>{let s=n(t),o=r?r(t):t;return[s,o]}))};Array.prototype.toObjectWithKey=function(n){return Object.fromEntries(this.map((r)=>[String(r[n]),r]))};Array.prototype.selectFor=function(n,r,t,s){let o=this.find(n,s);if(o===void 0)throw Error(t??"Element not found");return r(o)};Array.prototype.sortBy=function(n,r=!0){return this.slice().sort((t,s)=>{let o=n(t),e=n(s);if(o<e)return r?-1:1;if(o>e)return r?1:-1;return 0})};Array.prototype.unique=function(){return Array.from(new Set(this))};Array.prototype.uniqueBy=function(n){let r=new Set;return this.filter((t)=>{let s=n(t);if(r.has(s))return!1;else return r.add(s),!0})};var E;((i)=>{i[i.Explore=0]="Explore";i[i.SkipSiblings=1]="SkipSiblings";i[i.NoExplore=2]="NoExplore";i[i.ReplaceParent=3]="ReplaceParent";i[i.DeleteParent=4]="DeleteParent";i[i.MergeParent=5]="MergeParent";i[i.ReplaceItem=6]="ReplaceItem";i[i.DeleteItem=7]="DeleteItem"})(E||={});class T{action;by;skipSiblings;reexplore;constructor(n,r,t,s){this.action=n;this.by=r;this.skipSiblings=t;this.reexplore=s}static _explore=new T(0);static _noExplore=new T(2);static _skipSiblings=new T(1);static _deleteParent=new T(4);static ReplaceParent(n,r){return new T(3,n,void 0,r)}static SkipSiblings(){return T._skipSiblings}static Explore(){return T._explore}static NoExplore(){return T._noExplore}static DeleteParent(){return T._deleteParent}static MergeParent(n){return new T(5,n)}static ReplaceItem(n,r){return new T(6,n,r)}static DeleteItem(n){return new T(7,void 0,n)}}Object.navigate=async(n,r)=>{let t=new WeakSet,s=[],o=[],e=async(d,i,p)=>{let x=d===null,a=x?T.Explore():await r({key:d,value:i,path:s,parent:p,parents:o});if(i&&typeof i==="object"&&a.action===0){if(t.has(i))return a;if(t.add(i),!x)s.push(d),o.push(p);let m=i;while(await h(m,d,p))m=p[d];if(!x)o.pop(),s.pop()}return a},h=async(d,i,p)=>{let x=Object.keys(d),f=x.length;for(let a=0;a<f;a++){let g=x[a],c=d[g],m=await e(g,c,d),b=m.action;if(b===0||b===2)continue;if(b===6){if(d[g]=m.by,m.skipSiblings)return;continue}if(b===7){if(delete d[g],m.skipSiblings)return;continue}if(b===1)return;if(b===3){if(i===null)throw Error("Cannot replace root object");if(p[i]=m.by,m.reexplore)return!0;return}if(b===4){if(i===null)throw Error("Cannot delete root object");delete p[i];return}if(b===5)delete d[g],Object.assign(d,m.by)}};await e(null,n,null)};Object.find=async function(n,r){let t=[];return await Object.navigate(n,(s)=>{if(r([...s.path,s.key].join("."),s.value))t.push(s.value);return T.Explore()}),t};Object.merge=(n,r,t)=>{for(let s of Object.keys(r)){if(n[s]===void 0)continue;let o=r[s],e=n[s];if(typeof e!==typeof o||Array.isArray(e)!==Array.isArray(o)){let d=t?.mismatch?.(s,e,o,n,r);if(d!==void 0){r[s]=d;continue}throw Error(`Type mismatch: ${s}`)}let h=t?.mode?.(s,e,o,n,r)??r[".merge"]??"merge";switch(h){case"source":r[s]=e;continue;case"target":continue;case"skip":delete r[s],delete n[s];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${h}`)}if(typeof e==="object")if(Array.isArray(e))o.push(...e);else{if(t?.navigate?.(s,e,o,n,r)===!1)continue;Object.merge(e,o,t)}else{if(e===o)continue;let d=t?.conflict?.(s,e,o,n,r);r[s]=d===void 0?o:d}}for(let s of Object.keys(n))if(r[s]===void 0)r[s]=n[s]};var O=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,F=/^([^[\]]*)\[([^\]]*)]$/,w=(n,r,t,s)=>{if(n.startsWith("{")&&n.endsWith("}")){let o=n.substring(1,n.length-1);return Object.select(r,o,t)?.toString()}return s?n:void 0},U=(n,r,t,s)=>{let o=w(r,t,s);if(o)return Object.select(n,o,s);let e=O.exec(r);if(e){let[,d,i,p]=e,x=w(d.trim(),t,s,!0),f=w(p.trim(),t,s,!0);if(Array.isArray(n)&&(i==="="||i==="==")&&x)return n.find((a)=>a?.[x]==f)}let h=F.exec(r);if(h){let[,d,i]=h;return n?.[d]?.[i]}return n?.[r]};Object.select=(n,r,t)=>{let s=void 0,o=void 0,e=r??"",h=(f)=>{if(!f)return[f,!1];return f.endsWith("?")?[f.substring(0,f.length-1),!0]:[f,!1]},d=(f,a)=>{let[g,c]=h(a.pop());if(!g){if(t?.set!==void 0&&o!==void 0&&s!==void 0)s[o]=t.set;return f}let m=U(f,g,n,t);if(m===void 0){if(c||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${g}" in "${e}"`)}return s=f,o=g,d(m,a)},i=e.splitNested(t?.separator??".","{","}"),p=void 0;if(i.length>0&&i[i.length-1].startsWith("?="))p=i.pop()?.substring(2);i.reverse();let x=d(n,i);if(x===void 0)return p??t?.defaultValue;return x};Object.deepClone=function(n){if(typeof structuredClone<"u")try{return structuredClone(n)}catch{}return JSON.parse(JSON.stringify(n))};Object.toList=function(n,r){return Object.entries(n).map(([t,s])=>({[r]:t,...s}))};Object.mapEntries=function(n,r){let s=Object.entries(n).map(([o,e])=>r(o,e));return Object.fromEntries(s)};global.AsyncFunction=Object.getPrototypeOf(async function(){}).constructor;global.defined=(n,r="Value is undefined")=>{if(n===void 0||n===null)throw Error(r);return n};String.prototype.tokenize=function(n,r=/\${([^}]+)}/g){return this.replace(r,(t,s)=>{let o=n[s];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,(n,r)=>r.toUpperCase()).replace(/[_ ]/g,"")};String.prototype.capitalize=function(){return this.replace(/((?:[ ]+)\w|^\w)/g,(n,r)=>r.toUpperCase())};String.prototype.toCamel=function(){return this.toPascal().replace(/((?:[ ]+\w)|^\w)/g,(n,r)=>r.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(n){switch(n){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: ${n}`)}};String.prototype.splitWithQuotes=function(n=","){let r=[],t=this.length,s=n.length,o=0,e=(h)=>{if(h+s>t)return!1;for(let d=0;d<s;d++)if(this[h+d]!==n[d])return!1;return!0};while(o<t){while(o<t&&this[o]===" ")o++;if(o>=t)break;let h="",d=this[o]==='"'||this[o]==="'";if(d){let i=this[o++];while(o<t&&this[o]!==i)h+=this[o++];if(o<t)o++}else{while(o<t&&!e(o)){let i=this[o];if(i==='"'||i==="'"){h+=i,o++;while(o<t&&this[o]!==i)h+=this[o++];if(o<t)h+=this[o++]}else h+=this[o++]}h=h.trim()}if(h)r.push({value:h,quoted:d});if(e(o))o+=s}return r};String.prototype.splitNested=function(n,r,t){let s=0,o="",e=[];for(let h of this){if(o+=h,h===r)s++;if(h===t)s--;if(s===0&&h===n)e.push(o.slice(0,-1)),o=""}if(o)e.push(o);return e};String.prototype.toStringBuilder=function(){return new u(this.split(`
2
+ `))};String.prototype.padBlock=function(n,r=`
3
+ `,t=" "){let s=t.repeat(n);return this.split(r).map((o)=>s+o).join(r)};String.prototype.stripIndent=function(){let n=this.split(/\r?\n/),r=n.filter((s)=>s.trim().length>0).map((s)=>/^[ \t]*/.exec(s)?.[0].length??0),t=r.length>0?Math.min(...r):0;if(t===0)return this;return n.map((s)=>s.slice(t)).join(`
4
+ `)};String.prototype.toHtmlLink=function(n){return`<a href="${n??this.toString()}">${this.toString()}</a>`};function v(n,r="Value is undefined"){if(n===void 0||n===null)throw Error(r);return n}class L{options;constructor(n){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:(r,...t)=>{switch(r){case"ERROR":console.error(...t);break;case"WARN":console.warn(...t);break;case"DEBUG":console.debug(...t);break;case"VERBOSE":console.log(...t);break;default:console.log(...t)}},...n}}write(n,...r){if(this.options.level){let o=this.options.levels.indexOf(this.options.level)??-1,e=this.options.levels.indexOf(n);if(e===-1)throw Error(`Unknown log level: ${n}`);if(e<o)return}let t=[],s=[];if(this.options.timeStamp)s.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)s.push(n);if(s.length>0)t.push(`[${s.join(" ")}]`);t.push(...r),this.options.logFunction(n,...t)}info(...n){this.write("INFO",...n)}error(...n){this.write("ERROR",...n)}warn(...n){this.write("WARN",...n)}debug(...n){this.write("DEBUG",...n)}verbose(...n){this.write("VERBOSE",...n)}}class u{#n=[];constructor(n){if(n)if(Array.isArray(n))this.#n.push(...n);else this.#n.push(n)}append(...n){return this.#n.push(...n),this}appendLine(...n){return this.append(...n.map((r)=>{if(r===null||r===void 0)return`
5
+ `;return`${r.toString()}
6
+ `})),this}clear(){return this.#n.length=0,this}isEmpty(){return this.#n.length===0}toString(){return this.#n.join("")}}class $ extends u{header(n,r=1){return this.appendLine(`${"#".repeat(r)} ${n}`)}codeBlock(n,r=""){return this.appendLine(`\`\`\`${r}
7
+ ${n}
8
+ \`\`\``)}link(n,r){return this.append(`[${n}](${r})`)}table(n,r){let t=n.map((e,h)=>{let d=e.length;return r.forEach((i)=>{if(i[h])d=Math.max(d,i[h].length)}),d}),s=n.map((e,h)=>e.padEnd(t[h]));this.appendLine("| "+s.join(" | ")+" |");let o=t.map((e)=>"-".repeat(e));return this.appendLine("| "+o.join(" | ")+" |"),r.forEach((e)=>{let h=e.map((d,i)=>d.padEnd(t[i]));this.appendLine("| "+h.join(" | ")+" |")}),this}blockquote(n){let r=n.split(`
9
+ `);this.appendLine("> "+r[0]);for(let t=1;t<r.length;t++)this.appendLine("> "+r[t]);return this}bold(n){return this.append(`**${n}**`)}italic(n){return this.append(`*${n}*`)}item(n){return this.appendLine(`- ${n}`)}list(n){return n.forEach((r)=>this.item(r)),this}orderedList(n,r=1){return n.forEach((t,s)=>this.appendLine(`${(s+r).toString()}. ${t}`)),this}code(n){return this.append(`\`${n}\``)}horizontalRule(){return this.appendLine("---")}image(n,r){return this.appendLine(`![${n}](${r})`)}strikethrough(n){return this.append(`~~${n}~~`)}highlight(n){return this.append(`==${n}==`)}subscript(n){return this.append(`~${n}~`)}superscript(n){return this.append(`^${n}^`)}taskList(n){return n.forEach((r)=>this.appendLine(`- [${r.checked?"x":" "}] ${r.text}`)),this}#n=0;section(n){return this.#n++,this.header(n,this.#n)}endSection(){if(this.#n>0)this.#n--;return this}setSectionLevel(n){return this.#n=n,this}}export{v as defined,u as StringBuilder,T as NavigateResult,E as NavigateAction,$ as Markdown,L as Logger};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homedev/framework",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "homedev framework",
5
5
  "author": "julzor",
6
6
  "license": "ISC",