mutorjs 1.3.4 → 1.4.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.
package/dist/server.cjs CHANGED
@@ -1,17 +1,24 @@
1
- "use strict";var Q=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var be=(e,r)=>{for(var t in r)Q(e,t,{get:r[t],enumerable:!0})},Re=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Oe(r))!we.call(e,o)&&o!==t&&Q(e,o,{get:()=>r[o],enumerable:!(i=Ee(r,o))||i.enumerable});return e};var Pe=e=>Re(Q({},"__esModule",{value:!0}),e);var Ce={};be(Ce,{default:()=>Ne});module.exports=Pe(Ce);var ge=require("fs"),x=require("fs/promises"),M=require("path");function X(e,r){return`${" ".repeat(e+r)}^`}var m=class e extends Error{constructor(t){super(t);this.name="MutorError";Object.setPrototypeOf(this,e.prototype)}},j=class e extends m{constructor(t,i,o,c,f){let g=i.toString().length+2,s=`${t}
1
+ "use strict";var Q=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Oe=Object.prototype.hasOwnProperty;var be=(e,r)=>{for(var t in r)Q(e,t,{get:r[t],enumerable:!0})},Re=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!Oe.call(e,o)&&o!==t&&Q(e,o,{get:()=>r[o],enumerable:!(s=ye(r,o))||s.enumerable});return e};var Pe=e=>Re(Q({},"__esModule",{value:!0}),e);var Ce={};be(Ce,{default:()=>Ne});module.exports=Pe(Ce);var ge=require("fs"),x=require("fs/promises"),M=require("path");function X(e,r){return`${" ".repeat(e+r)}^`}var g=class e extends Error{constructor(t){super(t);this.name="MutorError";Object.setPrototypeOf(this,e.prototype)}},L=class e extends g{constructor(t,s,o,c,p){let m=s.toString().length+2,i=`${t}
2
2
 
3
- `;s+=`at ${f}:${i}:${c+1}
4
- `,i>1&&(s+=`${(i-1).toString().padStart(g-2)} | ...
5
- `),s+=`${i} | ${o}
6
- `,s+=X(c,g+1);super(s);this.name="MutorCompilerError";Object.setPrototypeOf(this,e.prototype)}};var ie=new Set(["for","if","else","true","false","null","undefined","end","in","of"]),W=new Set(["::","||","??","&&","**","^","|","&","!","-","%","+","*","/",">","<",">=","<=","==","!=",">>","<<",".","?.","(",")","[","]",",",":","?"]);var ae=new Set(["==","!="]),k=new Set([">","<",">=","<="]);var ce=new Set(["+","-"]),pe=new Set(["*","/","%"]),le=new Set([".","?.","[","::"]),ue=new Set(["-","+","!"]),fe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},S={build:{include:new Set([".html",".txt"]),exclude:new Set(["node_modules",".git"])},autoEscape:!0,allowedProps:new Set,forbiddenProps:new Set(["__proto__","constructor","prototype"]),allowFnCalls:!1,delimiters:{closingTag:"}}",openingTag:"{{",openingTagEscape:"\\",whitespaceTrim:"~",commentTag:"#"},keepOpeningTagEscapeDelimiter:!1,cache:{active:!0,maxSize:50*1024*1024}},he={JSON:{stringify(e){try{return JSON.stringify(e)}catch{throw new m("JSON.stringify failed: invalid value")}},parse(e){if(typeof e!="string")throw new m("JSON.parse expects a string");try{return JSON.parse(e)}catch{throw new m("JSON.parse failed: invalid JSON string")}}},Object:{keys(e){if(!e||typeof e!="object")throw new m("Object.keys expects an object");return Object.keys(e)},values(e){if(!e||typeof e!="object")throw new m("Object.values expects an object");return Object.values(e)},entries(e){if(!e||typeof e!="object")throw new m("Object.entries expects an object");return Object.entries(e)},hasOwn(e,r){if(!e||typeof e!="object")throw new m("Object.hasOwn expects an object");return Object.hasOwn(e,r)},freeze(e){if(!e||typeof e!="object")throw new m("Object.freeze expects an object");return Object.freeze(e)},seal(e){if(!e||typeof e!="object")throw new m("Object.seal expects an object");return Object.seal(e)},fromEntries(e){if(!Array.isArray(e))throw new m("Object.fromEntries expects an array");return Object.fromEntries(e)}},Array:{isArray(e){return Array.isArray(e)},from(e){return Array.from(e)}},Number:{isFinite(e){return Number.isFinite(e)},isNaN(e){return Number.isNaN(e)},parseInt(e,r=10){return Number.parseInt(e,r)},parseFloat(e){return Number.parseFloat(e)}},String:{fromCharCode(...e){return String.fromCharCode(...e)}},Math:{abs(e){return Math.abs(e)},floor(e){return Math.floor(e)},ceil(e){return Math.ceil(e)},round(e){return Math.round(e)},max(...e){return Math.max(...e)},min(...e){return Math.min(...e)},random(){return Math.random()}},Date:{now(){return Date.now()},parse(e){if(typeof e!="string")throw new m("Date.parse expects a string");return Date.parse(e)}},Boolean:{valueOf(e){return!!e}}};function z(e){return typeof e!="string"?e:/[&<>"']/.test(e)?e.replace(/[&<>"']/g,r=>fe[r]):e}var $=require("path");function v(e,...r){let t=(0,$.isAbsolute)(e)?e:(0,$.resolve)(process.cwd(),e);if(r.length){let i=(0,$.dirname)(t);return(0,$.resolve)(i,...r)}return t}function B(e,r,t){if(t.has(e)&&!r.has(e))throw new m(`Forbidden property access. Access to this computed property "${e}" is forbidden.`);return e}var Y="object",de=Symbol("__mutor_safe_context");function L(e){if(!e||typeof e!==Y||de in e)return e;let r=new WeakSet;function t(o,c=""){if(!o||typeof o!==Y||r.has(o))return o;r.add(o);let f=Object.getPrototypeOf(o);if(f&&f!==Object.prototype&&f!==Array.prototype)throw new m(`Unsafe prototype detected at ${c||"root"}`);if(Array.isArray(o)){for(let s=0;s<o.length;s++)o[s]=t(o[s],`${c}[${s}]`);return o}if(o instanceof Map){for(let[s,p]of o.entries())typeof s===Y&&t(s,`${c}.mapKey`),o.set(s,t(p,`${c}.mapValue`));return o}if(o instanceof Set){let s=new Set;for(let p of o.values())s.add(t(p,c));o.clear();for(let p of s)o.add(p);return o}let g=Object.getOwnPropertyDescriptors(o);for(let s of Object.keys(g)){let p=g[s];if(p.get||p.set)throw new m(`Getter/setter not allowed: ${c}.${s}`);let d=o[s];d&&typeof d===Y&&(o[s]=t(d,`${c}.${s}`))}return o}let i=t(e);return i&&typeof i===Y&&Object.defineProperty(i,de,{value:!0,enumerable:!1,writable:!1,configurable:!1}),i}function I(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$")}function G(e,r){let i=e.slice(0,r).split(`
3
+ `;i+=`at ${p}:${s}:${c+1}
4
+ `,s>1&&(i+=`${(s-1).toString().padStart(m-2)} | ...
5
+ `),i+=`${s} | ${o}
6
+ `,i+=X(c,m+1);super(i);this.name="MutorCompilerError";Object.setPrototypeOf(this,e.prototype)}};var ie=new Set(["for","if","else","true","false","null","undefined","end","in","of"]),W=new Set(["::","||","??","&&","**","^","|","&","!","-","%","+","*","/",">","<",">=","<=","==","!=",">>","<<",".","?.","(",")","[","]",",",":","?"]);var ae=new Set(["==","!="]),k=new Set([">","<",">=","<="]);var ce=new Set(["+","-"]),pe=new Set(["*","/","%"]),le=new Set([".","?.","[","::"]),ue=new Set(["-","+","!"]),fe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},R={build:{include:new Set([".html",".txt"]),exclude:new Set(["node_modules",".git"])},autoEscape:!0,allowedProps:new Set,forbiddenProps:new Set(["__proto__","constructor","prototype"]),allowFnCalls:!1,delimiters:{closingTag:"}}",openingTag:"{{",openingTagEscape:"\\",whitespaceTrim:"~",commentTag:"#"},keepOpeningTagEscapeDelimiter:!1,onIncludeFail:"throw",cache:{active:!0,maxSize:50*1024*1024}},he={JSON:{stringify(e){try{return JSON.stringify(e)}catch{throw new g("JSON::stringify failed")}},parse(e){if(typeof e!="string")throw new g("JSON::parse expects a string");try{return JSON.parse(e)}catch{throw new g("JSON::parse failed: invalid JSON string")}}},Object:{keys(e){if(!e||typeof e!="object")throw new g("Object::keys expects an object");return Object.keys(e)},values(e){if(!e||typeof e!="object")throw new g("Object::values expects an object");return Object.values(e)},entries(e){if(!e||typeof e!="object")throw new g("Object::entries expects an object");return Object.entries(e)},hasOwn(e,r){if(!e||typeof e!="object")throw new g("Object::hasOwn expects an object");return Object.hasOwn(e,r)},fromEntries(e){if(!Array.isArray(e))throw new g("Object::fromEntries expects an array");return Object.fromEntries(e)}},Array:{isArray(e){return Array.isArray(e)},from(e){return Array.from(e)}},Number:{isFinite(e){return Number.isFinite(e)},isNaN(e){return Number.isNaN(e)},parseInt(e,r=10){return Number.parseInt(e,r)},parseFloat(e){return Number.parseFloat(e)}},String:{fromCharCode(...e){return String.fromCharCode(...e)}},Math:{abs(e){return Math.abs(e)},floor(e){return Math.floor(e)},ceil(e){return Math.ceil(e)},round(e){return Math.round(e)},max(...e){return Math.max(...e)},min(...e){return Math.min(...e)},random(){return Math.random()}},Date:{now(){return Date.now()},parse(e){if(typeof e!="string")throw new g("Date::parse expects a string");return Date.parse(e)}},Boolean:{valueOf(e){return!!e}}};function j(e){return typeof e!="string"?e:/[&<>"']/.test(e)?e.replace(/[&<>"']/g,r=>fe[r]):e}var $=require("path");function I(e,...r){let t=(0,$.isAbsolute)(e)?e:(0,$.resolve)(process.cwd(),e);if(r.length){let s=(0,$.dirname)(t);return(0,$.resolve)(s,...r)}return t}function z(e,r,t){if(t.has(e)&&!r.has(e))throw new g(`Forbidden property access.
7
+ Access to this computed property '${e}' is forbidden.`);return e}var Y="object",de=Symbol("__mutor_safe_context");function B(e){if(!e||typeof e!==Y||de in e)return e;let r=new WeakSet;function t(o,c=""){if(!o||typeof o!==Y||r.has(o))return o;r.add(o);let p=Object.getPrototypeOf(o);if(p&&p!==Object.prototype&&p!==Array.prototype)throw new g(`Unsafe prototype detected at ${c||"root"} in context.`);if(Array.isArray(o)){for(let i=0;i<o.length;i++)o[i]=t(o[i],`${c}[${i}]`);return o}if(o instanceof Map){for(let[i,l]of o.entries())typeof i===Y&&t(i,`${c}.mapKey`),o.set(i,t(l,`${c}.mapValue`));return o}if(o instanceof Set){let i=new Set;for(let l of o.values())i.add(t(l,c));o.clear();for(let l of i)o.add(l);return o}let m=Object.getOwnPropertyDescriptors(o);for(let i of Object.keys(m)){let l=m[i];if(l.get||l.set)throw new g(`Getter/setter not allowed at '${c}.${i}' in context.`);let d=o[i];d&&typeof d===Y&&(o[i]=t(d,`${c}.${i}`))}return o}let s=t(e);return s&&typeof s===Y&&Object.defineProperty(s,de,{value:!0,enumerable:!1,writable:!1,configurable:!1}),s}function v(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$/g,"\\$")}function G(e,r){let s=e.slice(0,r).split(`
7
8
  `).length,o=e.lastIndexOf(`
8
- `,r-1)+1;return[i,o]}function K(e,r){let t=e.indexOf(`
9
- `,r);return e.slice(r,t===-1?void 0:t).replaceAll(" "," ")}function U(e,r){let{scope:t,forbiddenProps:i,allowedProps:o}=r;function c(a){return t.includes(a)?a:`ctx.${a}`}function f(a){switch(a.type){case 17:return"}";case 5:return a.value;case 4:return`\`${/\$\\/.test(a.value)?I(a.value):a.value}\``;case 10:return a.true?"true":"false";case 12:return"null";case 11:return"undefined";case 7:return c(a.value);case 9:return`(${f(a.expr)})`;case 2:return`${a.operator}${f(a.expr)}`;case 0:return`${f(a.left)} ${a.operator} ${f(a.right)}`;case 1:return`${f(a.condition)} ? ${f(a.left)} : ${f(a.right)}`;case 8:return s(a);case 3:return p(a);case 6:return g(a);case 13:return d(a);case 16:return"} else {";case 14:return _(a);case 15:return y(a);default:throw new m(`Unsupported expression type: ${a.type}`)}}function g(a){if(a.left.type!==7)throw{message:"Invalid usage of namespace operator.",pos:a.pos};return`namespaces.${a.left.value}.${a.right.value}`}function s(a){let O=f(a.left);if(a.bracketNotation){let h=f(a.right),w=a.optional?"?.":"";return a.right.type===4||a.right.type===5?`${O}${w}[${h}]`:`${O}${w}[validateComputedProps(${h}, allowedProps, forbiddenProps)]`}else{let h=a.right.value,w=a.optional?"?.":".";if(i.has(h)&&!o.has(h))throw{message:"Forbidden property access.",pos:a.right.pos};return`${O}${w}${h}`}}function p(a){let O=f(a.expr),h=a.optional?"?.":"",w=a.args.map(R=>f(R)).join(", ");return`${O}${h}(${w})`}function d(a){let{iterable:O,loopType:h,variable:w}=a;return`for(const ${w} ${h===1?"in":"of"} ${U(O,r)}){`}function _(a){let{condition:O}=a;return`if(${U(O,r)}){`}function y(a){let{condition:O}=a;return`}else if(${U(O,r)}){`}return f(e)}function J(e){switch(e){case 0:return"identifier";case 1:return"keyword";case 2:return"number";case 4:return"operator";case 3:return"string"}}function ee(e,r){let t=0,i=!1;function o(n,l){let u=e[t],N=e[e.length-1];if(!u)throw{message:`Unexpected end of expression. Expected ${l?`'${l}'`:`${n===0?"an":"a"} ${J(n)}`}.`,pos:N.pos+N.value.length-1};if(u.type!==n)throw{message:`Unexpected token type. Expected ${l?`'${l}'`:J(n)} but got ${J(u.type)} instead.`,pos:u.pos};if(l!==void 0&&u.value!==l)throw{message:`Unexpected token '${u?.value}'. Expected ${n===0?"an":"a"} ${J(n)} instead.`,pos:u.pos};return e[t++]}function c(){let n=e[t-1].pos,l=o(0).value,u;try{u=o(1,"in")}catch{u=o(1,"of")}let N=u.value==="in"?1:0,D=b();return{type:13,loopType:N,iterable:D,variable:l,pos:n}}function f(){let n=b();return{condition:n,pos:n.pos,type:14}}function g(){let n=e[t-1].pos;try{return o(1,"if"),{...f(),type:15,pos:n}}catch{return{type:16,pos:n}}}function s(){let n=[];if(e[t]?.type===4&&e[t]?.value===")")return n;for(n.push(b());e[t]?.type===4&&e[t]?.value===","&&e[t]?.value!==")";)t++,n.push(b());return n}function p(){let n=e[t++];if(n?.type===2)return{type:5,value:n.value,pos:n.pos};if(n?.type===3)return{type:4,value:n.value,pos:n.pos};if(n?.type===1){if(n.value==="for"&&t===1)return c();if(n.value==="true"||n.value==="false")return{type:10,true:n.value==="true",pos:n.pos};if(n.value==="undefined")return{type:11,pos:n.pos};if(n.value==="null")return{type:12,pos:n.pos};if(n.value==="end"&&e.length===1)return{type:17,pos:n.pos};if(n.value==="if"&&t===1)return f();if(n.value==="else"&&t===1)return g()}if(n?.type===0)return{type:7,value:n.value,pos:n.pos};if(n?.type===4&&n.value==="("){let l=b();return o(4,")"),{type:9,expr:l,pos:n.pos}}if(n?.type===4&&ue.has(n.value)){let l=n.value,u=b();return{type:2,operator:l,expr:u,pos:n.pos}}throw t>e.length?{message:"Unexpected end of expression.",pos:e[e.length-1].pos}:{message:`Unexpected token '${n?.value}'.`,pos:n.pos}}function d(){let n=p();for(;e[t];){let l=e[t];if(l?.type===4&&l?.value==="("){if(t++,!i&&!r.allowFnCalls)throw{message:"Function calls are not allowed.",pos:e[t-1].pos};let u=s();o(4,")"),n={type:3,expr:n,args:u,pos:e[t-1].pos}}else if(l?.type===4&&l?.value==="?."&&e[t+1]?.type===4&&e[t+1]?.value==="("){if(t++,t++,!i&&!r.allowFnCalls)throw{message:"Function calls are not allowed.",pos:e[t-1].pos};let u=s();o(4,")"),n={type:3,expr:n,args:u,optional:!0,pos:e[t-1].pos}}else if(l?.type===4&&le.has(l?.value)){let u=l?.value==="::",N=l?.value==="[",D=l?.value==="?.";if(t++,u&&(e[t-2]?.type!==0||e[t]?.type!==0))throw{message:`Invalid namespaces access. Expected syntax <IDENTIFIER>::<IDENTIFIER>, but got '${e[t-2]?.value}::${e[t]?.value}' instead.`,pos:e[t]?.pos};if(u){i=!0;let P=p();n={type:6,left:n,right:P,pos:e[t-1].pos}}else if(N){let P=b();o(4,"]"),n={type:8,right:P,left:n,bracketNotation:!0,pos:e[t-1].pos}}else if(D)if(e[t]?.type===4&&e[t]?.value==="["){t++;let P=b();o(4,"]"),n={type:8,left:n,right:P,bracketNotation:!0,optional:!0,pos:e[t-1].pos}}else{let P=p();n={type:8,left:n,right:P,optional:!0,pos:e[t-1].pos}}else{let P=p();n={type:8,left:n,right:P,pos:e[t-1].pos}}}else break}return i=!1,n}function _(){let n=d();for(;e[t]?.type===4&&pe.has(e[t]?.value);){let l=e[t++].value,u=d();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function y(){let n=_();for(;e[t]?.type===4&&ce.has(e[t]?.value);){let l=e[t++].value,u=_();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function a(){let n=y();for(;e[t]?.type===4&&k.has(e[t]?.value);){let l=e[t++].value,u=y();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function O(){let n=a();for(;e[t]?.type===4&&k.has(e[t]?.value);){let l=e[t++].value,u=a();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function h(){let n=O();for(;e[t]?.type===4&&ae.has(e[t]?.value);){let l=e[t++].value,u=O();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function w(){let n=R();for(;e[t]?.type===4&&e[t]?.value==="||";){let l=e[t++].value,u=R();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function R(){let n=F();for(;e[t]?.type===4&&e[t]?.value==="&&";){let l=e[t++].value,u=F();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function F(){let n=h();for(;e[t]?.type===4&&e[t]?.value==="??";){let l=e[t++].value,u=h();n={type:0,left:n,right:u,operator:l,pos:e[t-1].pos}}return n}function b(){let n=w();if(e[t]?.type!==4||e[t]?.value!=="?")return n;t++;let l=b();o(4,":");let u=b();return{type:1,left:l,right:u,condition:n,pos:e[t-1].pos}}let V=b();if(t!==e.length)throw{pos:e[t].pos,message:`Unexpected end of expression.
10
- Expected end of expression but found "${e[t].value}".`};return V}function te(e,{delimiters:r}){let t=`${r.openingTag}${r.whitespaceTrim}`,i=`${r.whitespaceTrim}${r.closingTag}`,o=e.startsWith(t),c=e.endsWith(i),f=e.startsWith(o?t+r.commentTag:r.openingTag+r.commentTag);if(f)return{isComment:f,leftTrim:o,rightTrim:c};let g=e.slice(o?t.length:r.openingTag.length,e.length-(c?i.length:r.closingTag.length)),s=g.trim(),p=s.startsWith("for")||s.startsWith("if")||s.startsWith("else"),d=s.startsWith("for")||s.startsWith("if"),_=s==="end",y=s.startsWith("for");return{leftTrim:o,rightTrim:c,inner:g,isBlock:p,isBlockEnd:_,hasContext:y,requiresBlockClose:d}}function re(e){let r=0,t="",i=[];function o(){let s="";if(/[a-zA-Z$_]/.test(t)){let p=r;for(;/[a-zA-Z$_0-9]/.test(e[p])&&p<e.length;)s+=e[p],p++;i.push({type:ie.has(s)?1:0,value:s,pos:r}),r=p,t=e[r]}}function c(){if(t!=='"'&&t!=="'"&&t!=="`")return!1;let s=t,p=r,d=r+1,_="";for(;d<e.length;){let y=e[d];if(y==="\\"){if(d+1>=e.length)throw{pos:d,message:"Unexpected end of string after escape character."};_+=y,_+=e[d+1],d+=2;continue}if(y===s)break;_+=y,d++}if(d>=e.length||e[d]!==s)throw{pos:p,message:`String literal missing closing ${s}.`};i.push({type:3,value:_,pos:p}),r=d}function f(){if(/[0-9]/.test(t)){let s=r,p="";for(;/[0-9.oxe]/.test(e[s])&&s<e.length;)p+=e[s],s++;let d=Number(p);if(Number.isNaN(d))throw{pos:r,message:"Found invalid number literal."};i.push({type:2,value:`${d}`,pos:r}),r=s-1,t=e[r]}}function g(){let s=`${t}${e[r+1]}`;if(W.has(s)){i.push({type:4,value:s,pos:r}),r++;return}if(W.has(t)){i.push({type:4,value:t,pos:r});return}}for(;r<e.length;){if(t=e[r],f(),o(),c(),g(),!/[a-zA-Z$_0-9\s\t\r\n'"`]/.test(t)&&!W.has(t)&&!W.has(e[r-1]+t))throw{message:`Unexpected token '${t}' in expression.`,pos:r};r++}return i}function ne(e,r,t){let i=[],o=[],{delimiters:c,keepOpeningTagEscapeDelimiter:f,allowFnCalls:g,allowedProps:s,forbiddenProps:p,autoEscape:d}=r,_=!1,y=0,a='let acc="";';for(;y<e.length;){let w=function(){let E=h,C=0;for(;E>=c.openingTagEscape.length&&e.slice(E-c.openingTagEscape.length,E)===c.openingTagEscape;)C++,E-=c.openingTagEscape.length;return C%2===1};var O=w;let h=e.indexOf(c.openingTag,y);if(h===-1){let E=e.slice(y);_&&(E=E.trimStart()),E&&(a+=`acc+=\`${I(E)}\`;`);break}if(w()){let E=e.slice(y,f?h+c.openingTagEscape.length+1:h-c.openingTag.length+1);_&&(E=E.trimStart(),_=!1),a+=`acc+=\`${I(E)}\`;`,f||(a+=`acc+=\`${c.openingTag}\`;`),y=h+c.openingTag.length;continue}let R=e.indexOf(c.closingTag,h);if(R===-1){let[E,C]=G(e,h),A=K(e,C);throw new j("No closing tag found.",E,A,h,t.path)}let F=e.slice(h,R+c.closingTag.length),{inner:b,leftTrim:V,rightTrim:n,isBlock:l,isBlockEnd:u,hasContext:N,requiresBlockClose:D,isComment:P}=te(F,{delimiters:c}),T=e.slice(y,h);T&&(_&&(T=T.trimStart()),V&&(T=T.trimEnd()),T&&(a+=`acc+=\`${I(T)}\`;`)),_=!1,y=R+c.closingTag.length;try{if(!P){let E=re(b),C=ee(E,{allowFnCalls:g});if(l&&D&&N?(i.push(C.variable),o.push({type:0,pos:h})):l&&D&&!N&&o.push({type:1,pos:h}),u){let H=o.pop();if(H?.type===0&&i.pop(),H===void 0)throw{message:"Unexpected end of block",pos:h}}let A=U(C,{allowedProps:s,forbiddenProps:p,scope:i});l||u?a+=A:a+=d&&!A.startsWith("namespaces.Mutor.include")?`acc+=escapeFn(${A});`:`acc+=${A};`}n&&(_=!0)}catch(E){let{message:C,pos:A}=E,H=V?c.whitespaceTrim.length+c.openingTag.length:c.openingTag.length,oe=h+A+H,[_e,se]=G(e,oe),ye=K(e,se);throw new j(C,_e,ye,oe-se,t.path)}}if(o.length){let h=o.pop()?.pos,[w,R]=G(e,h),F=K(e,R);throw new j("Unclosed block detected.",w,F,h-R,t.path)}return a+="return acc;",new Function("ctx","namespaces","allowedProps","forbiddenProps","escapeFn","validateComputedProps",a)}var q=class{constructor(r={}){this.__currentRenderedPath="";this.__includeStack=new Set;this.__cacheSize=0;this.__config={...S};this.__compiledTemplatesMap=new Map;this.__currentContext=null;this.__namespaces={...he,Mutor:{include:(r,t)=>{if(this.__includeStack.has(r))throw new m(`Circular include detected:
9
+ `,r-1)+1;return[s,o]}function K(e,r){let t=e.indexOf(`
10
+ `,r);return e.slice(r,t===-1?void 0:t).replaceAll(" "," ")}function U(e,r){let{scope:t,forbiddenProps:s,allowedProps:o}=r;function c(a){return t.includes(a)?a:`ctx.${a}`}function p(a){switch(a.type){case 17:return"}";case 5:return a.value;case 4:return`\`${/\$\\/.test(a.value)?v(a.value):a.value}\``;case 10:return a.true?"true":"false";case 12:return"null";case 11:return"undefined";case 7:return c(a.value);case 9:return`(${p(a.expr)})`;case 2:return`${a.operator}${p(a.expr)}`;case 0:return`${p(a.left)} ${a.operator} ${p(a.right)}`;case 1:return`${p(a.condition)} ? ${p(a.left)} : ${p(a.right)}`;case 8:return i(a);case 3:return l(a);case 6:return m(a);case 13:return d(a);case 16:return"} else {";case 14:return _(a);case 15:return E(a);default:throw new g(`Unsupported expression type '${a.type}'`)}}function m(a){if(a.left.type!==7)throw{message:"Invalid usage of namespace operator.",pos:a.pos};return`namespaces.${a.left.value}.${a.right.value}`}function i(a){let w=p(a.left);if(a.bracketNotation){let h=p(a.right),O=a.optional?"?.":"";return a.right.type===4||a.right.type===5?`${w}${O}[${h}]`:`${w}${O}[validateComputedProps(${h}, allowedProps, forbiddenProps)]`}else{let h=a.right.value,O=a.optional?"?.":".";if(s.has(h)&&!o.has(h))throw{message:"Forbidden property access.",pos:a.right.pos};return`${w}${O}${h}`}}function l(a){let w=p(a.expr),h=a.optional?"?.":"",O=a.args.map(P=>p(P)).join(", ");return`${w}${h}(${O})`}function d(a){let{iterable:w,loopType:h,variable:O}=a;return`for(const ${O} ${h===1?"in":"of"} ${U(w,r)}){`}function _(a){let{condition:w}=a;return`if(${U(w,r)}){`}function E(a){let{condition:w}=a;return`}else if(${U(w,r)}){`}return p(e)}function J(e){switch(e){case 0:return"identifier";case 1:return"keyword";case 2:return"number";case 4:return"operator";case 3:return"string"}}function ee(e,r){let t=0,s=!1;function o(n,u){let f=e[t],N=e[e.length-1];if(!f)throw{message:`Unexpected end of expression. Expected ${u?`'${u}'`:`${n===0?"an":"a"} ${J(n)}`}.`,pos:N.pos+N.value.length-1};if(f.type!==n)throw{message:`Unexpected token type. Expected ${u?`'${u}'`:J(n)} but got ${J(f.type)} instead.`,pos:f.pos};if(u!==void 0&&f.value!==u)throw{message:`Unexpected token '${f?.value}'. Expected ${n===0?"an":"a"} ${J(n)} instead.`,pos:f.pos};return e[t++]}function c(){let n=e[t-1].pos,u=o(0).value,f;try{f=o(1,"in")}catch{f=o(1,"of")}let N=f.value==="in"?1:0,D=b();return{type:13,loopType:N,iterable:D,variable:u,pos:n}}function p(){let n=b();return{condition:n,pos:n.pos,type:14}}function m(){let n=e[t-1].pos;try{return o(1,"if"),{...p(),type:15,pos:n}}catch{return{type:16,pos:n}}}function i(){let n=[];if(e[t]?.type===4&&e[t]?.value===")")return n;for(n.push(b());e[t]?.type===4&&e[t]?.value===","&&e[t]?.value!==")";)t++,n.push(b());return n}function l(){let n=e[t++];if(n?.type===2)return{type:5,value:n.value,pos:n.pos};if(n?.type===3)return{type:4,value:n.value,pos:n.pos};if(n?.type===1){if(n.value==="for"&&t===1)return c();if(n.value==="true"||n.value==="false")return{type:10,true:n.value==="true",pos:n.pos};if(n.value==="undefined")return{type:11,pos:n.pos};if(n.value==="null")return{type:12,pos:n.pos};if(n.value==="end"&&e.length===1)return{type:17,pos:n.pos};if(n.value==="if"&&t===1)return p();if(n.value==="else"&&t===1)return m()}if(n?.type===0)return{type:7,value:n.value,pos:n.pos};if(n?.type===4&&n.value==="("){let u=b();return o(4,")"),{type:9,expr:u,pos:n.pos}}if(n?.type===4&&ue.has(n.value)){let u=n.value,f=b();return{type:2,operator:u,expr:f,pos:n.pos}}throw t>e.length?{message:"Unexpected end of expression.",pos:e[e.length-1].pos}:{message:`Unexpected token '${n?.value}'.`,pos:n.pos}}function d(){let n=l();for(;e[t];){let u=e[t];if(u?.type===4&&u?.value==="("){if(t++,!s&&!r.allowFnCalls)throw{message:"Function calls are not allowed.",pos:e[t-1].pos};let f=i();o(4,")"),n={type:3,expr:n,args:f,pos:e[t-1].pos}}else if(u?.type===4&&u?.value==="?."&&e[t+1]?.type===4&&e[t+1]?.value==="("){if(t++,t++,!s&&!r.allowFnCalls)throw{message:"Function calls are not allowed.",pos:e[t-1].pos};let f=i();o(4,")"),n={type:3,expr:n,args:f,optional:!0,pos:e[t-1].pos}}else if(u?.type===4&&le.has(u?.value)){let f=u?.value==="::",N=u?.value==="[",D=u?.value==="?.";if(t++,f&&(e[t-2]?.type!==0||e[t]?.type!==0))throw{message:`Invalid namespaces access. Expected syntax <IDENTIFIER>::<IDENTIFIER>, but got '${e[t-2]?.value}::${e[t]?.value??""}' instead.`,pos:e[t]?.pos??e[t-1].pos};if(f){s=!0;let S=l();n={type:6,left:n,right:S,pos:e[t-1].pos}}else if(N){let S=b();o(4,"]"),n={type:8,right:S,left:n,bracketNotation:!0,pos:e[t-1].pos}}else if(D)if(e[t]?.type===4&&e[t]?.value==="["){t++;let S=b();o(4,"]"),n={type:8,left:n,right:S,bracketNotation:!0,optional:!0,pos:e[t-1].pos}}else{let S=l();n={type:8,left:n,right:S,optional:!0,pos:e[t-1].pos}}else{let S=l();n={type:8,left:n,right:S,pos:e[t-1].pos}}}else break}return s=!1,n}function _(){let n=d();for(;e[t]?.type===4&&pe.has(e[t]?.value);){let u=e[t++].value,f=d();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function E(){let n=_();for(;e[t]?.type===4&&ce.has(e[t]?.value);){let u=e[t++].value,f=_();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function a(){let n=E();for(;e[t]?.type===4&&k.has(e[t]?.value);){let u=e[t++].value,f=E();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function w(){let n=a();for(;e[t]?.type===4&&k.has(e[t]?.value);){let u=e[t++].value,f=a();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function h(){let n=w();for(;e[t]?.type===4&&ae.has(e[t]?.value);){let u=e[t++].value,f=w();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function O(){let n=P();for(;e[t]?.type===4&&e[t]?.value==="||";){let u=e[t++].value,f=P();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function P(){let n=F();for(;e[t]?.type===4&&e[t]?.value==="&&";){let u=e[t++].value,f=F();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function F(){let n=h();for(;e[t]?.type===4&&e[t]?.value==="??";){let u=e[t++].value,f=h();n={type:0,left:n,right:f,operator:u,pos:e[t-1].pos}}return n}function b(){let n=O();if(e[t]?.type!==4||e[t]?.value!=="?")return n;t++;let u=b();o(4,":");let f=b();return{type:1,left:u,right:f,condition:n,pos:e[t-1].pos}}let V=b();if(t!==e.length)throw{pos:e[t].pos,message:`Expected token '${e[t].value}'.
11
+ Expected an operator or the end of the expression.`};return V}function te(e,{delimiters:r}){let t=`${r.openingTag}${r.whitespaceTrim}`,s=`${r.whitespaceTrim}${r.closingTag}`,o=e.startsWith(t),c=e.endsWith(s),p=e.startsWith(o?t+r.commentTag:r.openingTag+r.commentTag);if(p)return{isComment:p,leftTrim:o,rightTrim:c};let m=e.slice(o?t.length:r.openingTag.length,e.length-(c?s.length:r.closingTag.length)),i=m.trim(),l=i.startsWith("for")||i.startsWith("if")||i.startsWith("else"),d=i.startsWith("for")||i.startsWith("if"),_=i==="end",E=i.startsWith("for");return{leftTrim:o,rightTrim:c,inner:m,isBlock:l,isBlockEnd:_,hasContext:E,requiresBlockClose:d}}function re(e){let r=0,t="",s=[];function o(){let i="";if(/[a-zA-Z$_]/.test(t)){let l=r;for(;/[a-zA-Z$_0-9]/.test(e[l])&&l<e.length;)i+=e[l],l++;s.push({type:ie.has(i)?1:0,value:i,pos:r}),r=l,t=e[r]}}function c(){if(t!=='"'&&t!=="'"&&t!=="`")return!1;let i=t,l=r,d=r+1,_="";for(;d<e.length;){let E=e[d];if(E==="\\"){if(d+1>=e.length)throw{pos:d,message:"Unexpected end of string after escape character."};_+=E,_+=e[d+1],d+=2;continue}if(E===i)break;_+=E,d++}if(d>=e.length||e[d]!==i)throw{pos:l,message:`String literal missing closing ${i}.`};s.push({type:3,value:_,pos:l}),r=d}function p(){if(/[0-9]/.test(t)){let i=r,l="";for(;/[0-9.oxe]/.test(e[i])&&i<e.length;)l+=e[i],i++;let d=Number(l);if(Number.isNaN(d))throw{pos:r,message:"Found invalid number literal."};s.push({type:2,value:`${d}`,pos:r}),r=i-1,t=e[r]}}function m(){let i=`${t}${e[r+1]}`;if(W.has(i)){s.push({type:4,value:i,pos:r}),r++;return}if(W.has(t)){s.push({type:4,value:t,pos:r});return}}for(;r<e.length;){if(t=e[r],p(),o(),c(),m(),!/[a-zA-Z$_0-9\s\t\r\n'"`]/.test(t)&&!W.has(t)&&!W.has(e[r-1]+t))throw{message:`Unexpected token '${t}' in expression.`,pos:r};r++}return s.length?s:[{type:3,value:"",pos:0}]}function ne(e,r,t){let s=[],o=[],{delimiters:c,keepOpeningTagEscapeDelimiter:p,allowFnCalls:m,allowedProps:i,forbiddenProps:l,autoEscape:d}=r,_=!1,E=0,a='let acc="";';for(;E<e.length;){let O=function(){let y=h,C=0;for(;y>=c.openingTagEscape.length&&e.slice(y-c.openingTagEscape.length,y)===c.openingTagEscape;)C++,y-=c.openingTagEscape.length;return C%2===1};var w=O;let h=e.indexOf(c.openingTag,E);if(h===-1){let y=e.slice(E);_&&(y=y.trimStart()),y&&(a+=`acc+=\`${v(y)}\`;`);break}if(O()){let y=e.slice(E,p?h+c.openingTagEscape.length+1:h-c.openingTag.length+1);_&&(y=y.trimStart(),_=!1),a+=`acc+=\`${v(y)}\`;`,p||(a+=`acc+=\`${c.openingTag}\`;`),E=h+c.openingTag.length;continue}let P=e.indexOf(c.closingTag,h);if(P===-1){let[y,C]=G(e,h),T=K(e,C);throw new L("No closing tag found.",y,T,h,t.path)}let F=e.slice(h,P+c.closingTag.length),{inner:b,leftTrim:V,rightTrim:n,isBlock:u,isBlockEnd:f,hasContext:N,requiresBlockClose:D,isComment:S}=te(F,{delimiters:c}),A=e.slice(E,h);A&&(_&&(A=A.trimStart()),V&&(A=A.trimEnd()),A&&(a+=`acc+=\`${v(A)}\`;`)),_=!1,E=P+c.closingTag.length;try{if(!S){let y=re(b),C=ee(y,{allowFnCalls:m});if(u&&D&&N?(s.push(C.variable),o.push({type:0,pos:h})):u&&D&&!N&&o.push({type:1,pos:h}),f){let H=o.pop();if(H?.type===0&&s.pop(),H===void 0)throw{message:"Unexpected end of block",pos:h}}let T=U(C,{allowedProps:i,forbiddenProps:l,scope:s});u||f?a+=T:a+=d&&!T.startsWith("namespaces.Mutor.include")?`acc+=escapeFn(${T});`:`acc+=${T};`}n&&(_=!0)}catch(y){let{message:C,pos:T}=y,H=V?c.whitespaceTrim.length+c.openingTag.length:c.openingTag.length,oe=h+T+H,[_e,se]=G(e,oe),Ee=K(e,se);throw new L(C,_e,Ee,oe-se,t.path)}}if(o.length){let h=o.pop()?.pos,[O,P]=G(e,h),F=K(e,P);throw new L("Unclosed block detected.",O,F,h-P,t.path)}return a+="return acc;",new Function("ctx","namespaces","allowedProps","forbiddenProps","escapeFn","validateComputedProps",a)}var q=class{constructor(r={}){this.__currentRenderedPath="";this.__includeStack=new Set;this.__cacheSize=0;this.__config={...R};this.__compiledTemplatesMap=new Map;this.__currentContext=null;this.__namespaces={...he,Mutor:{include:(r,t)=>{if(this.__includeStack.has(r))throw new g(`Circular include detected.
11
12
  ${Array.from(this.__includeStack).join(`
12
13
  `)}
13
- ${r}`);try{return this.__includeStack.add(r),this.renderComponent(r,t??this.__currentContext)}finally{this.__includeStack.delete(r)}}}};this.addConfig(r),Object.defineProperty(this.__namespaces.Mutor,"$$context",{get:()=>this.__currentContext})}addConfig(r){let{autoEscape:t,delimiters:i,allowedProps:o,forbiddenProps:c,keepOpeningTagEscapeDelimiter:f,allowFnCalls:g,cache:s,build:p}=r;return this.__config={build:{include:new Set([...p?.include||S.build.include]),exclude:new Set([...S.build.exclude,...p?.exclude||[]])},autoEscape:t===!0?!0:t!==!1,allowedProps:o||S.allowedProps,allowFnCalls:!!g,cache:{...S.cache,...s||{}},forbiddenProps:new Set([...S.forbiddenProps,...c||[]]),keepOpeningTagEscapeDelimiter:f===!0?!0:f!==!1,delimiters:{...S.delimiters,...i||{}}},this.__config}restoreDefaultConfig(){this.__config={...S}}compile(r){return ne(r,this.__config,{path:this.__currentRenderedPath||"anonymous"})}render(r,t){let i=this.__currentContext;i!==t&&(this.__currentContext=t);let o=this.compile(r)(L(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,z,B);return this.__currentContext=i,o}renderComponent(r,t){if(!this.__compiledTemplatesMap.has(r))throw new m(`No template exists with the identifier '${r}'`);let i=this.__currentRenderedPath,o=this.__currentContext,c=this.__compiledTemplatesMap.get(r);this.__currentContext=t,this.__currentRenderedPath=r;let f=c.fn(L(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,z,B);return this.__currentContext=o,this.__currentRenderedPath=i,f}registerComponent(r,t){let i=t.length*2+500;if(this.__cacheSize+i>this.__config.cache.maxSize&&!this.createEntrySpaceForTemplate(i))throw new m(`The template for the component '${r}' is too large. Consider increasing 'cache.maxSize' in the config`);this.__cacheSize+=t.length*2+500,this.__compiledTemplatesMap.set(r,{fn:this.compile(t),size:i})}reset(){this.__config={...S},this.__compiledTemplatesMap.clear(),this.__currentContext=null,this.__cacheSize=0}createEntrySpaceForTemplate(r){if(this.__cacheSize+r<this.__config.cache.maxSize)return!0;if(r>this.__config.cache.maxSize)return!1;let t=this.__compiledTemplatesMap.entries().next().value;if(t){let[i,o]=t;this.__compiledTemplatesMap.delete(i),this.__cacheSize-=o.size}return this.createEntrySpaceForTemplate(r)}getDiagnostics(){let r=this.__config.cache.maxSize;return{bytesUsed:this.__cacheSize,bytesMax:r,readableUsed:`${(this.__cacheSize/1024/1024).toFixed(2)} MB`,readableMax:`${(r/1024/1024).toFixed(2)} MB`,totalEntries:this.__compiledTemplatesMap.size,percentFull:r>0?Math.min(100,Math.round(this.__cacheSize/r*100)):0,avgTemplateSize:this.__compiledTemplatesMap.size>0?Math.round(this.__cacheSize/this.__compiledTemplatesMap.size):0}}};var Z=class extends q{constructor(r={}){super(r),this.__namespaces.Mutor.include=(t,i)=>{let o=v(this.__currentRenderedPath,t);if(this.__includeStack.has(o))throw new m(`Circular include detected:
14
+ ${r}`);let s=this.__currentRenderedPath,o=`[Mutor.js]
15
+ Component '${r}' not found.
16
+ The component was included from ${`'${s}'`||"an anonymous component"}.
17
+ `;try{return this.__includeStack.add(r),this.renderComponent(r,t??this.__currentContext)}catch(c){if(this.__config.onIncludeFail==="throw")throw new g(o);let p={from:s,path:r,absolutePath:void 0};return this.__config.onIncludeFail==="ignoreLog"&&!this.__config.onIncludeError&&console.log(o),this.__config.onIncludeError?.(p,c)??""}finally{this.__includeStack.delete(r),this.__currentRenderedPath=s}}}};this.addConfig(r),Object.defineProperty(this.__namespaces.Mutor,"$$context",{get:()=>this.__currentContext})}addConfig(r){let{autoEscape:t,delimiters:s,allowedProps:o,forbiddenProps:c,keepOpeningTagEscapeDelimiter:p,allowFnCalls:m,cache:i,build:l,onIncludeFail:d,onIncludeError:_}=r;return this.__config={build:{include:new Set([...l?.include||R.build.include]),exclude:new Set([...R.build.exclude,...l?.exclude||[]])},autoEscape:t===!0?!0:t!==!1,allowedProps:o||R.allowedProps,allowFnCalls:!!m,onIncludeFail:d||R.onIncludeFail,onIncludeError:_||R.onIncludeError,cache:{...R.cache,...i||{}},forbiddenProps:new Set([...R.forbiddenProps,...c||[]]),keepOpeningTagEscapeDelimiter:p===!0?!0:p!==!1,delimiters:{...R.delimiters,...s||{}}},this.__config}restoreDefaultConfig(){this.__config={...R}}compile(r){return ne(r,this.__config,{path:this.__currentRenderedPath||"anonymous"})}render(r,t){let s=this.__currentContext;s!==t&&(this.__currentContext=t);let o=this.compile(r)(B(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,j,z);return this.__currentContext=s,o}renderComponent(r,t){if(!this.__compiledTemplatesMap.has(r))throw new g(`No template exists with the identifier '${r}'`);let s=this.__currentRenderedPath,o=this.__currentContext,c=this.__compiledTemplatesMap.get(r);this.__currentContext=t,this.__currentRenderedPath=r;let p=c.fn(B(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,j,z);return this.__currentContext=o,this.__currentRenderedPath=s,p}registerComponent(r,t){let s=t.length*2+500;if(this.__cacheSize+s>this.__config.cache.maxSize&&!this.createEntrySpaceForTemplate(s))throw new g(`The template for the component '${r}' is too large and will not fit in the cache. Consider increasing 'cache.maxSize' in the config`);this.__cacheSize+=t.length*2+500,this.__compiledTemplatesMap.set(r,{fn:this.compile(t),size:s})}reset(){this.__config={...R},this.__compiledTemplatesMap.clear(),this.__currentContext=null,this.__cacheSize=0}createEntrySpaceForTemplate(r){if(this.__cacheSize+r<this.__config.cache.maxSize)return!0;if(r>this.__config.cache.maxSize)return!1;let t=this.__compiledTemplatesMap.entries().next().value;if(t){let[s,o]=t;this.__compiledTemplatesMap.delete(s),this.__cacheSize-=o.size}return this.createEntrySpaceForTemplate(r)}getDiagnostics(){let r=this.__config.cache.maxSize;return{bytesUsed:this.__cacheSize,bytesMax:r,readableUsed:`${(this.__cacheSize/1024/1024).toFixed(2)} MB`,readableMax:`${(r/1024/1024).toFixed(2)} MB`,totalEntries:this.__compiledTemplatesMap.size,percentFull:r>0?Math.min(100,Math.round(this.__cacheSize/r*100)):0,avgTemplateSize:this.__compiledTemplatesMap.size>0?Math.round(this.__cacheSize/this.__compiledTemplatesMap.size):0}}};var Z=class extends q{constructor(r={}){super(r),this.__namespaces.Mutor.include=(t,s)=>{let o=this.__currentRenderedPath,c=I(this.__currentRenderedPath,t),p=`[Mutor.js]
18
+ File '${c}' not found.
19
+ The file was included from ${`'${o}'`||"an anonymous template"}.
20
+ `;if(this.__includeStack.has(c))throw new g(`Circular include detected.
14
21
  ${Array.from(this.__includeStack).join(`
15
22
  `)}
16
- ${o}`);try{return this.__includeStack.add(o),this.renderFile(o,i??this.__currentContext)}finally{this.__includeStack.delete(o)}}}renderFile(r,t){let i=v(r),o,c=this.__currentContext,f=this.__currentRenderedPath;if(this.__currentContext=t,this.__currentRenderedPath=r,this.__config.cache.active&&this.__compiledTemplatesMap.has(i))o=this.__compiledTemplatesMap.get(i).fn;else{let s=(0,ge.readFileSync)(i,"utf-8");if(o=this.compile(s),this.__config.cache.active){let p=s.length*2+500;this.__cacheSize+p>this.__config.cache.maxSize?this.createEntrySpaceForTemplate(p)&&(this.__compiledTemplatesMap.set(i,{fn:o,size:p}),this.__cacheSize+=p):(this.__compiledTemplatesMap.set(i,{fn:o,size:p}),this.__cacheSize+=p)}}let g=o(L(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,z,B);return this.__currentContext=c,this.__currentRenderedPath=f,g}async buildDir(r,t,i){let o=v(t),c=v(r);await(0,x.mkdir)(o,{recursive:!0});let f=await(0,x.readdir)(c,{withFileTypes:!0});await Promise.all(f.map(async g=>{let s=(0,M.join)(c,g.name),p=(0,M.join)(o,g.name);if(this.__config.build.exclude.has(g.name))return;if(g.isDirectory())return this.buildDir(s,p,i);let d=(0,M.extname)(s);if(this.__config.build.include.has(d)){let _=this.renderFile(s,i);await(0,x.writeFile)(p,_,"utf-8")}else return await(0,x.copyFile)(s,p)}))}async compileDir(r){let t=v(r),i=await(0,x.readdir)(t,{withFileTypes:!0});await Promise.all(i.map(async o=>{let c=(0,M.join)(t,o.name);if(this.__config.build.exclude.has(o.name))return;if(o.isDirectory())return this.compileDir(c);let f=(0,M.extname)(c);if(this.__config.build.include.has(f))try{let g=await(0,x.readFile)(c,"utf-8");this.registerComponent(c,g)}catch{}}))}};var Ne=Z;
23
+ ${c}`);try{return this.__includeStack.add(c),this.renderFile(c,s??this.__currentContext)}catch(m){if(this.__config.onIncludeFail==="throw")throw new g(p);return this.__config.onIncludeFail==="ignoreLog"&&!this.__config.onIncludeError&&console.log(p),this.__config.onIncludeError?.({from:o,path:t,absolutePath:c},m)??""}finally{this.__includeStack.delete(c),this.__currentRenderedPath=o}}}renderFile(r,t){let s=I(r),o,c=this.__currentContext,p=this.__currentRenderedPath;if(this.__currentContext=t,this.__currentRenderedPath=r,this.__config.cache.active&&this.__compiledTemplatesMap.has(s))o=this.__compiledTemplatesMap.get(s).fn;else{let i=(0,ge.readFileSync)(s,"utf-8");if(o=this.compile(i),this.__config.cache.active){let l=i.length*2+500;this.__cacheSize+l>this.__config.cache.maxSize?this.createEntrySpaceForTemplate(l)&&(this.__compiledTemplatesMap.set(s,{fn:o,size:l}),this.__cacheSize+=l):(this.__compiledTemplatesMap.set(s,{fn:o,size:l}),this.__cacheSize+=l)}}let m=o(B(t),this.__namespaces,this.__config.allowedProps,this.__config.forbiddenProps,j,z);return this.__currentContext=c,this.__currentRenderedPath=p,m}async buildDir(r,t,s){let o=I(t),c=I(r);await(0,x.mkdir)(o,{recursive:!0});let p=await(0,x.readdir)(c,{withFileTypes:!0});await Promise.all(p.map(async m=>{let i=(0,M.join)(c,m.name),l=(0,M.join)(o,m.name);if(this.__config.build.exclude.has(m.name))return;if(m.isDirectory())return this.buildDir(i,l,s);let d=(0,M.extname)(i);if(this.__config.build.include.has(d)){let _=this.renderFile(i,s);await(0,x.writeFile)(l,_,"utf-8")}else return await(0,x.copyFile)(i,l)}))}async compileDir(r){let t=I(r),s=await(0,x.readdir)(t,{withFileTypes:!0});await Promise.all(s.map(async o=>{let c=(0,M.join)(t,o.name);if(this.__config.build.exclude.has(o.name))return;if(o.isDirectory())return this.compileDir(c);let p=(0,M.extname)(c);if(this.__config.build.include.has(p))try{let m=await(0,x.readFile)(c,"utf-8");this.registerComponent(c,m)}catch{}}))}};var Ne=Z;
17
24
  //# sourceMappingURL=server.cjs.map