mancha 0.9.4 → 0.9.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/mancha.js CHANGED
@@ -68,7 +68,7 @@ const F=["this"],K=["+","-","!"],Y=["=","+","-","*","/","%","^","==","!=",">","<
68
68
  * @license
69
69
  * Portions Copyright (c) 2013, the Dart project authors.
70
70
  */
71
- const ee={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),"|>":(e,t)=>t(e)},te={"+":e=>e,"-":e=>-e,"!":e=>!e};class re{timeouts=new Map;debounce(e,t){return new Promise(((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout((()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}}),e))}))}}const ie=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=te[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const i=ee[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,i;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.argument.evaluate(e)):"ID"===this.left.type&&(r=e,i=this.left.value),void 0===r?void 0:r[i]=t}return i(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t){return{type:"Getter",receiver:e,name:t,evaluate(e){return this.receiver.evaluate(e)?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,evaluate(e){const r=this.receiver.evaluate(e),i=this.method?r:e?.this??e,n=this.method?r?.[t]:r,s=(this.arguments??[]).map((t=>t?.evaluate(e)));return n?.apply?.(i,s)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",entries:e,evaluate(t){const r={};if(e&&this.entries)for(const i in e){const e=this.entries[i];e&&(r[i]=e.evaluate(t))}return r},getIds(t){if(e&&this.entries)for(const r in e){const e=this.entries[r];e&&e.getIds(t)}return t}}}list(e){return{type:"List",items:e,evaluate(e){return this.items?.map((t=>t?.evaluate(e)))},getIds(e){return this.items?.forEach((t=>t?.getIds(e))),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...i){const n=Object.fromEntries(t.map(((e,t)=>[e,i[t]]))),s=new Proxy(e??{},{set:(e,t,r)=>(n.hasOwnProperty(t)&&(n[t]=r),e[t]=r),get:(e,t)=>n.hasOwnProperty(t)?n[t]:e[t]});return r.evaluate(s)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};class ne extends re{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof ne||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),this.store.get(e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),this.store.set(e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&this.store.has(r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes("=")){const[r,i]=e.split("=");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new J(e,t).parse())(e,ie),s=n?.getIds([])?.map((e=>[e,i[e]??r[e]??globalThis[e]])),o=n?.evaluate(Object.fromEntries(s||[]));if(!t)return o;r[t]=o}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this.store.has(e))return r[e];return this.cachedExpressionFunction(e)(r,t)}}class se extends ne{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}clone(){const e=Object.fromEntries(this.store.entries()),t=new this.constructor(e).debug(this.debugging);return t._customElements=this._customElements,Array.from(this.store.keys()).forEach((e=>this.watch(e,(()=>t.set(e,this.get(e)))))),t}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new d(O(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",j(e,128)),await G.resolveIncludes.call(this,e,t),await G.rebaseRelativePaths.call(this,e,t),await G.registerCustomElements.call(this,e,t),await G.resolveCustomElements.call(this,e,t)}));return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of O(e,this._skipNodes))this.log("Rendering node:\n",j(r,128)),await G.resolveDataAttribute.call(this,r,t),await G.resolveForAttribute.call(this,r,t),await G.resolveTextAttributes.call(this,r,t),await G.resolveHtmlAttribute.call(this,r,t),await G.resolveShowAttribute.call(this,r,t),await G.resolveClassAttribute.call(this,r,t),await G.resolveBindAttribute.call(this,r,t),await G.resolveEventAttributes.call(this,r,t),await G.resolveTextNodeExpressions.call(this,r,t),await G.resolveCustomAttribute.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},await this.preprocessNode(e,t),await this.renderNode(e,t),e.renderer=this}}class oe extends se{dirpath=z(self.location.href);parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}new oe;const ae={sm:640,md:768,lg:1024,xl:1280},ce=.25,le=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],he=[...le,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,112,128,144,160,192,224,256,288,320,384,448,512,...Object.values(ae)],ue=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],de=["hover","focus","disabled","focus","active"],pe={margin:"m",padding:"p"},fe={width:"w",height:"h"},me={top:"top",right:"right",bottom:"bottom",left:"left"},_e={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Ee={bold:{"font-weight":"bold"},semibold:{"font-weight":600},italic:{"font-style":"italic"},underline:{"text-decoration":"underline"},"no-underline":{"text-decoration":"none"},"decoration-none":{"text-decoration":"none"},"line-through":{"text-decoration":"line-through"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},"text-xs":{"font-size":".75rem"},"text-sm":{"font-size":".875rem"},"text-base":{"font-size":"1rem"},"text-lg":{"font-size":"1.125rem"},"text-xl":{"font-size":"1.25rem"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"overflow-auto":{overflow:"auto"},"overflow-x-auto":{"overflow-x":"auto"},"overflow-y-auto":{"overflow-y":"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-visible":{overflow:"visible"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},ge=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],$e={red:{50:16772078,100:16764370,200:15702682,300:15037299,400:15684432,500:16007990,600:15022389,700:13840175,800:12986408,900:12000284},pink:{50:16573676,100:16301008,200:16027569,300:15753874,400:15483002,500:15277667,600:14162784,700:12720219,800:11342935,900:8916559},purple:{50:15984117,100:14794471,200:13538264,300:12216520,400:11225020,500:10233776,600:9315498,700:8069026,800:6953882,900:4854924},"deep-purple":{50:15591414,100:13747433,200:11771355,300:9795021,400:8280002,500:6765239,600:6174129,700:5320104,800:4532128,900:3218322},indigo:{50:15264502,100:12962537,200:10463450,300:7964363,400:6056896,500:4149685,600:3754411,700:3162015,800:2635155,900:1713022},blue:{50:14938877,100:12312315,200:9489145,300:6600182,400:4367861,500:2201331,600:2001125,700:1668818,800:1402304,900:870305},"light-blue":{50:14808574,100:11789820,200:8508666,300:5227511,400:2733814,500:240116,600:236517,700:166097,800:161725,900:87963},cyan:{50:14743546,100:11725810,200:8445674,300:5099745,400:2541274,500:48340,600:44225,700:38823,800:33679,900:24676},teal:{50:14742257,100:11722715,200:8440772,300:5093036,400:2533018,500:38536,600:35195,700:31083,800:26972,900:19776},green:{50:15267305,100:13166281,200:10868391,300:8505220,400:6732650,500:5025616,600:4431943,700:3706428,800:3046706,900:1793568},"light-green":{50:15857897,100:14478792,200:12968357,300:11457921,400:10275941,500:9159498,600:8172354,700:6856504,800:5606191,900:3369246},lime:{50:16382951,100:15791299,200:15134364,300:14477173,400:13951319,500:13491257,600:12634675,700:11514923,800:10394916,900:8550167},yellow:{50:16776679,100:16775620,200:16774557,300:16773494,400:16772696,500:16771899,600:16635957,700:16498733,800:16361509,900:16088855},amber:{50:16775393,100:16772275,200:16769154,300:16766287,400:16763432,500:16761095,600:16757504,700:16752640,800:16748288,900:16740096},orange:{50:16774112,100:16769202,200:16764032,300:16758605,400:16754470,500:16750592,600:16485376,700:16088064,800:15690752,900:15094016},"deep-orange":{50:16509415,100:16764092,200:16755601,300:16747109,400:16740419,500:16733986,600:16011550,700:15092249,800:14172949,900:12531212},brown:{50:15723497,100:14142664,200:12364452,300:10586239,400:9268835,500:7951688,600:7162945,700:6111287,800:5125166,900:4073251},gray:{50:16448250,100:16119285,200:15658734,300:14737632,400:12434877,500:10395294,600:7697781,700:6381921,800:4342338,900:2171169},"blue-gray":{50:15527921,100:13621468,200:11583173,300:9479342,400:7901340,500:6323595,600:5533306,700:4545124,800:3622735,900:2503224}};function ve(e){return de.map((t=>`.${t}\\:${e}:${t}`))}function be(e,t){return Object.entries(ae).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function ye(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function we(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...he.map((r=>[`${t}-${r}`,`${e}: ${r*ce}rem`])),...he.map((r=>[`-${t}-${r}`,`${e}: -${r*ce}rem`])),...he.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...he.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...ue.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...ue.map((r=>[`-${t}-${r}\\%`,` ${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ve(e).join(",")} { ${t} }`,...be(e,t)]))}function xe(e){return Object.entries(e).flatMap((([e,t])=>[`.${t}-auto { ${e}: auto; }`,`.${t}x-auto { ${e}-left: auto; ${e}-right: auto; }`,`.${t}y-auto { ${e}-top: auto; ${e}-bottom: auto; }`,`.${t}x-0 { ${e}-left: 0; ${e}-right: 0; }`,`.${t}y-0 { ${e}-top: 0; ${e}-bottom: 0; }`,...he.map((e=>[e,e*ce])).map((([r,i])=>`.${t}x-${r} { ${e}-left: ${i}rem; ${e}-right: ${i}rem; }`)),...he.map((e=>[e,e*ce])).map((([r,i])=>`.${t}y-${r} { ${e}-top: ${i}rem; ${e}-bottom: ${i}rem; }`)),...he.map((r=>`.${t}x-${r}px { ${e}-left: ${r}px; ${e}-right: ${r}px; }`)),...he.map((r=>`.${t}y-${r}px { ${e}-top: ${r}px; ${e}-bottom: ${r}px; }`)),...ue.map((r=>`.${t}x-${r}\\% { ${e}-left: ${r}%; ${e}-right: ${r}%; }`)),...ue.map((r=>`.${t}y-${r}\\% { ${e}-top: ${r}%; ${e}-bottom: ${r}%; }`))]))}function Ae(){const e=[["white","#fff"],["black","#000"],["transparent","transparent"]].flatMap((([e,t])=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]])),t=Object.entries($e).flatMap((([e,t])=>[[`text-${e}`,`color: #${t[500].toString(16)}`],[`fill-${e}`,`fill: #${t[500].toString(16)}`],[`bg-${e}`,`background-color: #${t[500].toString(16)}`],[`border-${e}`,`border-color: #${t[500].toString(16)}`]])),r=Object.entries($e).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: #${r.toString(16)}`],[`fill-${e}-${t}`,`fill: #${r.toString(16)}`],[`bg-${e}-${t}`,`background-color: #${r.toString(16)}`],[`border-${e}-${t}`,`border-color: #${r.toString(16)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ve(e).join(",")} { ${t} }`,...be(e,t)]))}const Oe=new oe;globalThis.Mancha=Oe;const Re=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=Re?.hasAttribute("debug"),t=Re?.getAttribute("cache"),r=Re?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await Oe.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=Re?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":u(e,x`
71
+ const ee={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),"|>":(e,t)=>t(e)},te={"+":e=>e,"-":e=>-e,"!":e=>!e};class re{timeouts=new Map;debounce(e,t){return new Promise(((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout((()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}}),e))}))}}const ie=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=te[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const i=ee[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,i;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.argument.evaluate(e)):"ID"===this.left.type&&(r=e,i=this.left.value),void 0===r?void 0:r[i]=t}return i(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t){return{type:"Getter",receiver:e,name:t,evaluate(e){return this.receiver.evaluate(e)?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,evaluate(e){const r=this.receiver.evaluate(e),i=this.method?r:e?.this??e,n=this.method?r?.[t]:r,s=(this.arguments??[]).map((t=>t?.evaluate(e)));return n?.apply?.(i,s)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",entries:e,evaluate(t){const r={};if(e&&this.entries)for(const i in e){const e=this.entries[i];e&&(r[i]=e.evaluate(t))}return r},getIds(t){if(e&&this.entries)for(const r in e){const e=this.entries[r];e&&e.getIds(t)}return t}}}list(e){return{type:"List",items:e,evaluate(e){return this.items?.map((t=>t?.evaluate(e)))},getIds(e){return this.items?.forEach((t=>t?.getIds(e))),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...i){const n=Object.fromEntries(t.map(((e,t)=>[e,i[t]]))),s=new Proxy(e??{},{set:(e,t,r)=>(n.hasOwnProperty(t)&&(n[t]=r),e[t]=r),get:(e,t)=>n.hasOwnProperty(t)?n[t]:e[t]});return r.evaluate(s)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};class ne extends re{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof ne||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),this.store.get(e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),this.store.set(e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&this.store.has(r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes("=")){const[r,i]=e.split("=");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new J(e,t).parse())(e,ie),s=n?.getIds([])?.map((e=>[e,i[e]??r[e]??globalThis[e]])),o=n?.evaluate(Object.fromEntries(s||[]));if(!t)return o;r[t]=o}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this.store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class se extends ne{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}clone(){const e=Object.fromEntries(this.store.entries()),t=new this.constructor(e).debug(this.debugging);return t._customElements=this._customElements,Array.from(this.store.keys()).forEach((e=>this.watch(e,(()=>t.set(e,this.get(e)))))),t}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new d(O(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",j(e,128)),await G.resolveIncludes.call(this,e,t),await G.rebaseRelativePaths.call(this,e,t),await G.registerCustomElements.call(this,e,t),await G.resolveCustomElements.call(this,e,t)}));return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of O(e,this._skipNodes))this.log("Rendering node:\n",j(r,128)),await G.resolveDataAttribute.call(this,r,t),await G.resolveForAttribute.call(this,r,t),await G.resolveTextAttributes.call(this,r,t),await G.resolveHtmlAttribute.call(this,r,t),await G.resolveShowAttribute.call(this,r,t),await G.resolveClassAttribute.call(this,r,t),await G.resolveBindAttribute.call(this,r,t),await G.resolveEventAttributes.call(this,r,t),await G.resolveTextNodeExpressions.call(this,r,t),await G.resolveCustomAttribute.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},await this.preprocessNode(e,t),await this.renderNode(e,t),e.renderer=this}}class oe extends se{dirpath=z(self.location.href);parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}new oe;const ae={sm:640,md:768,lg:1024,xl:1280},ce=.25,le=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],he=[...le,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,112,128,144,160,192,224,256,288,320,384,448,512,...Object.values(ae)],ue=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],de=["hover","focus","disabled","focus","active"],pe={margin:"m",padding:"p"},fe={width:"w",height:"h"},me={top:"top",right:"right",bottom:"bottom",left:"left"},_e={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Ee={bold:{"font-weight":"bold"},semibold:{"font-weight":600},italic:{"font-style":"italic"},underline:{"text-decoration":"underline"},"no-underline":{"text-decoration":"none"},"decoration-none":{"text-decoration":"none"},"line-through":{"text-decoration":"line-through"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},"text-xs":{"font-size":".75rem"},"text-sm":{"font-size":".875rem"},"text-base":{"font-size":"1rem"},"text-lg":{"font-size":"1.125rem"},"text-xl":{"font-size":"1.25rem"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"overflow-auto":{overflow:"auto"},"overflow-x-auto":{"overflow-x":"auto"},"overflow-y-auto":{"overflow-y":"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-visible":{overflow:"visible"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},ge=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],$e={red:{50:16772078,100:16764370,200:15702682,300:15037299,400:15684432,500:16007990,600:15022389,700:13840175,800:12986408,900:12000284},pink:{50:16573676,100:16301008,200:16027569,300:15753874,400:15483002,500:15277667,600:14162784,700:12720219,800:11342935,900:8916559},purple:{50:15984117,100:14794471,200:13538264,300:12216520,400:11225020,500:10233776,600:9315498,700:8069026,800:6953882,900:4854924},"deep-purple":{50:15591414,100:13747433,200:11771355,300:9795021,400:8280002,500:6765239,600:6174129,700:5320104,800:4532128,900:3218322},indigo:{50:15264502,100:12962537,200:10463450,300:7964363,400:6056896,500:4149685,600:3754411,700:3162015,800:2635155,900:1713022},blue:{50:14938877,100:12312315,200:9489145,300:6600182,400:4367861,500:2201331,600:2001125,700:1668818,800:1402304,900:870305},"light-blue":{50:14808574,100:11789820,200:8508666,300:5227511,400:2733814,500:240116,600:236517,700:166097,800:161725,900:87963},cyan:{50:14743546,100:11725810,200:8445674,300:5099745,400:2541274,500:48340,600:44225,700:38823,800:33679,900:24676},teal:{50:14742257,100:11722715,200:8440772,300:5093036,400:2533018,500:38536,600:35195,700:31083,800:26972,900:19776},green:{50:15267305,100:13166281,200:10868391,300:8505220,400:6732650,500:5025616,600:4431943,700:3706428,800:3046706,900:1793568},"light-green":{50:15857897,100:14478792,200:12968357,300:11457921,400:10275941,500:9159498,600:8172354,700:6856504,800:5606191,900:3369246},lime:{50:16382951,100:15791299,200:15134364,300:14477173,400:13951319,500:13491257,600:12634675,700:11514923,800:10394916,900:8550167},yellow:{50:16776679,100:16775620,200:16774557,300:16773494,400:16772696,500:16771899,600:16635957,700:16498733,800:16361509,900:16088855},amber:{50:16775393,100:16772275,200:16769154,300:16766287,400:16763432,500:16761095,600:16757504,700:16752640,800:16748288,900:16740096},orange:{50:16774112,100:16769202,200:16764032,300:16758605,400:16754470,500:16750592,600:16485376,700:16088064,800:15690752,900:15094016},"deep-orange":{50:16509415,100:16764092,200:16755601,300:16747109,400:16740419,500:16733986,600:16011550,700:15092249,800:14172949,900:12531212},brown:{50:15723497,100:14142664,200:12364452,300:10586239,400:9268835,500:7951688,600:7162945,700:6111287,800:5125166,900:4073251},gray:{50:16448250,100:16119285,200:15658734,300:14737632,400:12434877,500:10395294,600:7697781,700:6381921,800:4342338,900:2171169},"blue-gray":{50:15527921,100:13621468,200:11583173,300:9479342,400:7901340,500:6323595,600:5533306,700:4545124,800:3622735,900:2503224}};function ve(e){return de.map((t=>`.${t}\\:${e}:${t}`))}function be(e,t){return Object.entries(ae).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function ye(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function we(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...he.map((r=>[`${t}-${r}`,`${e}: ${r*ce}rem`])),...he.map((r=>[`-${t}-${r}`,`${e}: -${r*ce}rem`])),...he.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...he.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...ue.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...ue.map((r=>[`-${t}-${r}\\%`,` ${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ve(e).join(",")} { ${t} }`,...be(e,t)]))}function xe(e){return Object.entries(e).flatMap((([e,t])=>[`.${t}-auto { ${e}: auto; }`,`.${t}x-auto { ${e}-left: auto; ${e}-right: auto; }`,`.${t}y-auto { ${e}-top: auto; ${e}-bottom: auto; }`,`.${t}x-0 { ${e}-left: 0; ${e}-right: 0; }`,`.${t}y-0 { ${e}-top: 0; ${e}-bottom: 0; }`,...he.map((e=>[e,e*ce])).map((([r,i])=>`.${t}x-${r} { ${e}-left: ${i}rem; ${e}-right: ${i}rem; }`)),...he.map((e=>[e,e*ce])).map((([r,i])=>`.${t}y-${r} { ${e}-top: ${i}rem; ${e}-bottom: ${i}rem; }`)),...he.map((r=>`.${t}x-${r}px { ${e}-left: ${r}px; ${e}-right: ${r}px; }`)),...he.map((r=>`.${t}y-${r}px { ${e}-top: ${r}px; ${e}-bottom: ${r}px; }`)),...ue.map((r=>`.${t}x-${r}\\% { ${e}-left: ${r}%; ${e}-right: ${r}%; }`)),...ue.map((r=>`.${t}y-${r}\\% { ${e}-top: ${r}%; ${e}-bottom: ${r}%; }`))]))}function Ae(){const e=[["white","#fff"],["black","#000"],["transparent","transparent"]].flatMap((([e,t])=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]])),t=Object.entries($e).flatMap((([e,t])=>[[`text-${e}`,`color: #${t[500].toString(16)}`],[`fill-${e}`,`fill: #${t[500].toString(16)}`],[`bg-${e}`,`background-color: #${t[500].toString(16)}`],[`border-${e}`,`border-color: #${t[500].toString(16)}`]])),r=Object.entries($e).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: #${r.toString(16)}`],[`fill-${e}-${t}`,`fill: #${r.toString(16)}`],[`bg-${e}-${t}`,`background-color: #${r.toString(16)}`],[`border-${e}-${t}`,`border-color: #${r.toString(16)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ve(e).join(",")} { ${t} }`,...be(e,t)]))}const Oe=new oe;globalThis.Mancha=Oe;const Re=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=Re?.hasAttribute("debug"),t=Re?.getAttribute("cache"),r=Re?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await Oe.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=Re?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":u(e,x`
72
72
  html {
73
73
  max-width: 70ch;
74
74
  padding: 2em 1em;
@@ -1,7 +1,11 @@
1
- import { Renderer as BrowserRenderer } from "./browser.js";
2
- import { ParserParams } from "./interfaces.js";
3
- export declare class Renderer extends BrowserRenderer {
1
+ import { ParserParams, RenderParams } from "./interfaces.js";
2
+ import { IRenderer } from "./core.js";
3
+ export declare class Renderer extends IRenderer {
4
4
  protected readonly dirpath: string;
5
5
  parseHTML(content: string, params?: ParserParams): Document | DocumentFragment;
6
+ serializeHTML(root: Node | DocumentFragment): string;
7
+ preprocessLocal(fpath: string, params?: RenderParams & ParserParams): Promise<Document | DocumentFragment>;
8
+ createElement(tag: string, owner?: Document | null): Element;
9
+ textContent(node: Node, content: string): void;
6
10
  }
7
11
  export declare const Mancha: Renderer;
@@ -1,8 +1,8 @@
1
1
  import { sanitizeHtml } from "safevalues";
2
2
  import { safeRange, safeDomParser } from "safevalues/dom";
3
- import { Renderer as BrowserRenderer } from "./browser.js";
4
3
  import { dirname } from "./dome.js";
5
- export class Renderer extends BrowserRenderer {
4
+ import { IRenderer } from "./core.js";
5
+ export class Renderer extends IRenderer {
6
6
  dirpath = dirname(self.location.href);
7
7
  parseHTML(content, params = { rootDocument: false }) {
8
8
  if (params.rootDocument) {
@@ -15,5 +15,18 @@ export class Renderer extends BrowserRenderer {
15
15
  return safeRange.createContextualFragment(range, sanitizeHtml(content));
16
16
  }
17
17
  }
18
+ serializeHTML(root) {
19
+ return new XMLSerializer().serializeToString(root).replace(/\s?xmlns="[^"]+"/gm, "");
20
+ }
21
+ preprocessLocal(fpath, params) {
22
+ // In the browser, "local" paths (i.e., relative paths) can still be fetched.
23
+ return this.preprocessRemote(fpath, params);
24
+ }
25
+ createElement(tag, owner) {
26
+ return (owner || document).createElement(tag);
27
+ }
28
+ textContent(node, content) {
29
+ node.textContent = content;
30
+ }
18
31
  }
19
32
  export const Mancha = new Renderer();
package/dist/store.js CHANGED
@@ -196,7 +196,14 @@ export class SignalStore extends IDebouncer {
196
196
  else {
197
197
  // Otherwise, perform the expression evaluation.
198
198
  const fn = this.cachedExpressionFunction(expr);
199
- return fn(thisArg, args);
199
+ try {
200
+ return fn(thisArg, args);
201
+ }
202
+ catch (exc) {
203
+ console.error(`Failed to evaluate expression: ${expr}`);
204
+ console.error(exc);
205
+ return null;
206
+ }
200
207
  }
201
208
  }
202
209
  }
package/gulpfile.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as fs from "fs/promises";
2
- import run from "gulp-run";
3
2
  import GulpClient from "gulp";
4
3
  import csso from "gulp-csso";
4
+ import { exec } from "child_process";
5
5
 
6
6
  // Clean tasks
7
7
 
@@ -11,9 +11,10 @@ GulpClient.task("clean", function (done) {
11
11
 
12
12
  // Build tasks
13
13
 
14
- GulpClient.task("ts", function () {
15
- // The gulp-typescript plugin is deprecated.
16
- return run("tsec -p .").exec();
14
+ GulpClient.task("ts", function (done) {
15
+ return exec("tsec -p .", (err, stdout, stderr) => {
16
+ done(err || stderr);
17
+ });
17
18
  });
18
19
 
19
20
  GulpClient.task("css", function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mancha",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Javscript HTML rendering engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -44,14 +44,13 @@
44
44
  "csso": "^5.0.5",
45
45
  "gulp": "^5.0.0",
46
46
  "gulp-csso": "^4.0.1",
47
- "gulp-run": "^1.7.1",
48
47
  "gulp-typescript": "^6.0.0-alpha.1",
49
48
  "static-server": "^3.0.0",
50
49
  "terser-webpack-plugin": "^5.3.10",
51
50
  "ts-node": "^10.9.2",
52
51
  "tsec": "^0.2.8",
53
52
  "typescript": "5.4.5",
54
- "webpack": "5.91.0",
53
+ "webpack": "^5.94.0",
55
54
  "webpack-cli": "^5.1.4",
56
55
  "yargs": "^17.7.2"
57
56
  }