@homedev/framework 0.0.5 → 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
@@ -43,6 +43,34 @@ export declare interface LoggerOptions {
43
43
  logFunction: LogFunction;
44
44
  }
45
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
+
46
74
  /**
47
75
  * @public
48
76
  */
@@ -128,6 +156,16 @@ export declare interface SelectOptions {
128
156
  optional?: boolean;
129
157
  }
130
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
+
131
169
  export { }
132
170
 
133
171
  /* Global declarations */
@@ -190,6 +228,8 @@ declare global {
190
228
  padBlock(indent: number, separator?: string, padder?: string): string;
191
229
  tokenize(from: Record<string, unknown>, tokenizer?: RegExp): string;
192
230
  stripIndent(): string;
231
+ toHtmlLink(path?: string): string;
232
+ toStringBuilder(): StringBuilder;
193
233
  }
194
234
  }
195
235
 
package/dist/index.js CHANGED
@@ -1,3 +1,9 @@
1
- Array.prototype.findOrFail=function(n,r,T){let o=this.find(n,T);if(o===void 0)throw Error(r??"Element not found");return o};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 o=n(T);if(!r[o])r[o]=[];return r[o].push(T),r},{})};Array.prototype.createInstances=function(n,...r){return this.map((T,o)=>new n(...r,T,o))};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 o=n(this[T],T,this);if(o!=null)r.push(o)}return r};Array.prototype.nonNullMapAsync=async function(n){let r=[];for(let T=0;T<this.length;T++){let o=await n(this[T],T,this);if(o!=null)r.push(o)}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 o=n(T),f=r?r(T):T;return[o,f]}))};Array.prototype.toObjectWithKey=function(n){return Object.fromEntries(this.map((r)=>[String(r[n]),r]))};Array.prototype.selectFor=function(n,r,T,o){let f=this.find(n,o);if(f===void 0)throw Error(T??"Element not found");return r(f)};Array.prototype.sortBy=function(n,r=!0){return this.slice().sort((T,o)=>{let f=n(T),m=n(o);if(f<m)return r?-1:1;if(f>m)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 o=n(T);if(r.has(o))return!1;else return r.add(o),!0})};var e;((s)=>{s[s.Explore=0]="Explore";s[s.SkipSiblings=1]="SkipSiblings";s[s.NoExplore=2]="NoExplore";s[s.ReplaceParent=3]="ReplaceParent";s[s.DeleteParent=4]="DeleteParent";s[s.MergeParent=5]="MergeParent";s[s.ReplaceItem=6]="ReplaceItem";s[s.DeleteItem=7]="DeleteItem"})(e||={});class x{action;by;skipSiblings;reexplore;constructor(n,r,T,o){this.action=n;this.by=r;this.skipSiblings=T;this.reexplore=o}static _explore=new x(0);static _noExplore=new x(2);static _skipSiblings=new x(1);static _deleteParent=new x(4);static ReplaceParent(n,r){return new x(3,n,void 0,r)}static SkipSiblings(){return x._skipSiblings}static Explore(){return x._explore}static NoExplore(){return x._noExplore}static DeleteParent(){return x._deleteParent}static MergeParent(n){return new x(5,n)}static ReplaceItem(n,r){return new x(6,n,r)}static DeleteItem(n){return new x(7,void 0,n)}}Object.navigate=async(n,r)=>{let T=new WeakSet,o=[],f=[],m=async(d,s,h)=>{let w=d===null,E=w?x.Explore():await r({key:d,value:s,path:o,parent:h,parents:f});if(s&&typeof s==="object"&&E.action===0){if(T.has(s))return E;if(T.add(s),!w)o.push(d),f.push(h);let b=s;while(await t(b,d,h))b=h[d];if(!w)f.pop(),o.pop()}return E},t=async(d,s,h)=>{let w=Object.keys(d),i=w.length;for(let E=0;E<i;E++){let O=w[E],U=d[O],b=await m(O,U,d),F=b.action;if(F===0||F===2)continue;if(F===6){if(d[O]=b.by,b.skipSiblings)return;continue}if(F===7){if(delete d[O],b.skipSiblings)return;continue}if(F===1)return;if(F===3){if(s===null)throw Error("Cannot replace root object");if(h[s]=b.by,b.reexplore)return!0;return}if(F===4){if(s===null)throw Error("Cannot delete root object");delete h[s];return}if(F===5)delete d[O],Object.assign(d,b.by)}};await m(null,n,null)};Object.find=async function(n,r){let T=[];return await Object.navigate(n,(o)=>{if(r([...o.path,o.key].join("."),o.value))T.push(o.value);return x.Explore()}),T};Object.merge=(n,r,T)=>{for(let o of Object.keys(r)){if(n[o]===void 0)continue;let f=r[o],m=n[o];if(typeof m!==typeof f||Array.isArray(m)!==Array.isArray(f)){let d=T?.mismatch?.(o,m,f,n,r);if(d!==void 0){r[o]=d;continue}throw Error(`Type mismatch: ${o}`)}let t=T?.mode?.(o,m,f,n,r)??r[".merge"]??"merge";switch(t){case"source":r[o]=m;continue;case"target":continue;case"skip":delete r[o],delete n[o];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${t}`)}if(typeof m==="object")if(Array.isArray(m))f.push(...m);else{if(T?.navigate?.(o,m,f,n,r)===!1)continue;Object.merge(m,f,T)}else{if(m===f)continue;let d=T?.conflict?.(o,m,f,n,r);r[o]=d===void 0?f:d}}for(let o of Object.keys(n))if(r[o]===void 0)r[o]=n[o]};var c=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,g=/^([^[\]]*)\[([^\]]*)]$/,p=(n,r,T,o)=>{if(n.startsWith("{")&&n.endsWith("}")){let f=n.substring(1,n.length-1);return Object.select(r,f,T)?.toString()}return o?n:void 0},y=(n,r,T,o)=>{let f=p(r,T,o);if(f)return Object.select(n,f,o);let m=c.exec(r);if(m){let[,d,s,h]=m,w=p(d.trim(),T,o,!0),i=p(h.trim(),T,o,!0);if(Array.isArray(n)&&(s==="="||s==="==")&&w)return n.find((E)=>E?.[w]==i)}let t=g.exec(r);if(t){let[,d,s]=t;return n?.[d]?.[s]}return n?.[r]};Object.select=(n,r,T)=>{let o=void 0,f=void 0,m=r??"",t=(i)=>{if(!i)return[i,!1];return i.endsWith("?")?[i.substring(0,i.length-1),!0]:[i,!1]},d=(i,E)=>{let[O,U]=t(E.pop());if(!O){if(T?.set!==void 0&&f!==void 0&&o!==void 0)o[f]=T.set;return i}let b=y(i,O,n,T);if(b===void 0){if(U||T?.optional||T?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${O}" in "${m}"`)}return o=i,f=O,d(b,E)},s=m.splitNested(T?.separator??".","{","}"),h=void 0;if(s.length>0&&s[s.length-1].startsWith("?="))h=s.pop()?.substring(2);s.reverse();let w=d(n,s);if(w===void 0)return h??T?.defaultValue;return w};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,o])=>({[r]:T,...o}))};Object.mapEntries=function(n,r){let o=Object.entries(n).map(([f,m])=>r(f,m));return Object.fromEntries(o)};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,o)=>{let f=n[o];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,(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,o=n.length,f=0,m=(t)=>{if(t+o>T)return!1;for(let d=0;d<o;d++)if(this[t+d]!==n[d])return!1;return!0};while(f<T){while(f<T&&this[f]===" ")f++;if(f>=T)break;let t="",d=this[f]==='"'||this[f]==="'";if(d){let s=this[f++];while(f<T&&this[f]!==s)t+=this[f++];if(f<T)f++}else{while(f<T&&!m(f)){let s=this[f];if(s==='"'||s==="'"){t+=s,f++;while(f<T&&this[f]!==s)t+=this[f++];if(f<T)t+=this[f++]}else t+=this[f++]}t=t.trim()}if(t)r.push({value:t,quoted:d});if(m(f))f+=o}return r};String.prototype.splitNested=function(n,r,T){let o=0,f="",m=[];for(let t of this){if(f+=t,t===r)o++;if(t===T)o--;if(o===0&&t===n)m.push(f.slice(0,-1)),f=""}if(f)m.push(f);return m};String.prototype.padBlock=function(n,r=`
2
- `,T=" "){let o=T.repeat(n);return this.split(r).map((f)=>o+f).join(r)};String.prototype.stripIndent=function(){let n=this.split(/\r?\n/),r=n.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),T=r.length>0?Math.min(...r):0;if(T===0)return this;return n.map((o)=>o.slice(T)).join(`
3
- `)};function V(n,r="Value is undefined"){if(n===void 0||n===null)throw Error(r);return n}class B{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 f=this.options.levels.indexOf(this.options.level)??-1,m=this.options.levels.indexOf(n);if(m===-1)throw Error(`Unknown log level: ${n}`);if(m<f)return}let T=[],o=[];if(this.options.timeStamp)o.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)o.push(n);if(o.length>0)T.push(`[${o.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)}}export{V as defined,x as NavigateResult,e as NavigateAction,B as Logger};
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.5",
3
+ "version": "0.0.6",
4
4
  "description": "homedev framework",
5
5
  "author": "julzor",
6
6
  "license": "ISC",