@joker.front/core 1.3.76 → 1.3.81

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/bundle.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@joker.front/ast");const t=new Map,s=new Map,r=new Map;let n={recordRender:(e,t)=>{s.set(e,t)},recordComponent:(e,t)=>{r.set(e,t)},record:(e,s)=>{void 0===t.get(e)&&t.set(e,new Set),t.get(e).add(s),s.$on("destroy",(()=>{t.get(e)?.delete(s)}))},reload:(e,s)=>{let n=r.get(e);if(!n)return;n.component=s;let i=t.get(e);if(!i)return;let o=Array.from(i);i.clear(),o.forEach((e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof exports.VNode.Component&&t[exports.VNode.PARSERKEY]&&t[exports.VNode.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[exports.VNode.PARSERKEY].reload()}}}))},rerender:(e,r)=>{let n=s.get(e);n&&(n.render=r),t.get(e)?.forEach((e=>{e.$render(r)}))}};function i(e){return null!==e&&"object"==typeof e}function o(e,t){Object.getOwnPropertyNames(e).forEach((s=>{t(s,e[s])}))}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}function h(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let s=Object.keys(e);for(let r of s){let s=e[r];t[r]="object"==typeof s?h(s):s}return t}function d(e,t,s){return Array.isArray(e)&&Array.isArray(t)?function(e,t,s){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(s){if(e[r]!==t[r])return!1}else if(!1===l(e[r],t[r],s))return!1;return!0}(e,t,s):l(e,t,s)}function l(e,t,s){if(e===t)return!0;let r=i(e),n=i(t);if(r&&n){if(a(e)&&a(t)){let r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;if(s){for(let s of r)if(e[s]!==t[s])return!1;return!0}return JSON.stringify(e)===JSON.stringify(t)}return e===t}return!r&&!n&&String(e)===String(t)}function c(e,t){let s=e.indexOf(t);return s>-1&&e.splice(s,1),e}function p(e,t){let s=e.findIndex((e=>t(e)));return s>-1&&e.splice(s,1),e}function u(e){return!e||""===e.trim()}function f(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map((e=>e.toLowerCase())).join(t)}let m=(...e)=>{},E="warn";const y=["silent","error","warn","info"];function N(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function v(e,t,s,r){y.indexOf(e)<=y.indexOf(E)&&(void 0===r?console[e](`${N()} [${t}]:`,s):console[e](`${N()} [${t}]:`,s,r))}let g={info:function(e,t,s){v("info",e,t,s)},warn:function(e,t,s){v("warn",e,t,s)},error:function(e,t,s){v("error",e,t,s)},setLoggerLeve:function(e){E=e}};const x={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function b(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,((e,t)=>x[t]||""))}class w{static target;watchers=new Map;depend(e){w.target?.addDep(this,e)}addWatcher(e,t){let s=this.watchers.get(e)||[];s.push(t),this.watchers.set(e,s)}removeWatcher(e,t){let s=this.watchers.get(e);s&&c(s,t)}notify(e){let t=this.watchers.get(e);if(t){p(t,(e=>e.isDestroy)),[...t].forEach((e=>{!1===e.isDestroy&&e.update()}))}}}const R=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),A=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),C=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function O(e){try{return null!=e&&i(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof I==!1&&e instanceof We==!1&&e instanceof ge==!1&&(Array.isArray(e)||a(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(L in e)&&!(T in e)&&!(_e in e)}catch{return!1}}function S(e){if($(e))return e;if(e&&e.hasOwnProperty(A)){let t=Reflect.get(e,A);if(t)return t}let t=new w,s=!0,r=new Proxy(e,{get(e,s,r){if(e instanceof Set||e instanceof Map){if("add"===s){let r=Reflect.get(e,s);return s=>{O(s)&&(s=V(s));let n=r.call(e,s);return K(t,"size"),K(t,C),n}}if("set"===s){let r=Reflect.get(e,s);return(s,n)=>{O(n)&&(n=V(n));let i=r.call(e,s,n);return K(t,"size"),K(t,C),i}}if("delete"===s||"clear"===s){let r=Reflect.get(e,s);return n=>{let i=r.call(e,n);return("clear"===s||i)&&(K(t,"size"),K(t,C)),i}}let r=Reflect.get(e,s);if("function"==typeof r)return r.bind(e)}if(s===A)return;if(s===R)return t;if(s===C)return;let n=Reflect.get(e,s);return s===Symbol.toStringTag||!1===function(e,t){return t in e}(e,s)&&"length"!==s&&"size"!==s||(t.depend(s),O(n)&&$(n)?.depend(C)),n},set(e,r,n){if(s)return Reflect.set(e,r,n),!0;O(n)&&(n=V(n));let i=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,r),o=Reflect.get(e,r)!==n;return Reflect.set(e,r,n),(o||"length"===r&&Array.isArray(e))&&K(t,r),Array.isArray(e)?"length"===r&&K(t,C):i&&K(t,C),!0},deleteProperty:(e,s)=>(Reflect.deleteProperty(e,s),!1===Array.isArray(e)&&K(t,C),!0)});var n,i,o,a;n=e,i=A,o=r,a=!1,Object.defineProperty(n,i,{value:o,enumerable:a,writable:!0,configurable:!0});for(let t in e){let s=e[t];O(s)&&!$(s)&&(r[t]=S(e[t]))}return s=!1,r}function $(e){if(i(e))return Reflect.get(e,R)}function V(e,t=!1){if(!1===O(e))throw new Error("当前传入的数据不是正确的数据类型,必须是数组或者对象");return S(t?h(e):e)}function P(e,t,s){let r=s;O(s)&&(r=V(s));let n=new w;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(n.depend(t),$(r)?.depend(C),r),set:e=>{e!==r&&(O(e)&&(e=V(e)),r=e,K(n,t))}})}const T=Symbol.for("JOKER_SHALLOW_OBSERVER");let D=!1,_=new Map;function K(e,t){if(!1===D)e.notify(t);else{let s=_.get(e);void 0===s&&(s=[],_.set(e,s)),!1===s.includes(t)&&s.push(t)}}const k="数据观察",W=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class I{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,s,r){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=r,void 0===e)throw new Error("无法对underfind进行变更观察");if(void 0===s)this.getter=e=>e;else if("function"==typeof s)this.getter=s;else{let e=function(e){if(/[^\w.$]/.test(e))return;let t=e.split(".");return function(e){let s=e;return t.forEach((e=>{s&&(s=s[e])})),s}}(s);if(void 0===e)throw new Error(s+"解析失败,无法明确读取表达式,请检查expOrFn参数,或采用function模式");this.getter=e}void 0===this.getter&&g.error(k,"getter创建失败",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;w.target=this;let e,t="function"==typeof this.ob?this.ob():this.ob;try{e=this.getter.call(t,t)}catch(e){throw g.error(k,`获取值失败,执行方法:${this.getter.toString()}`),e}return w.target=void 0,this.clearnDeps(),e}addDep(e,t){let s=this.runRelations.get(e);if(void 0===s||!1===s.includes(t)){s=s||[],s.push(t),this.runRelations.set(e,s);let r=this.relations.get(e);void 0!==r&&!1!==r.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;let e=this.getValue();if(e===W)return;let t=this.value;if(this.forceCallBack||e!==t||i(e)){this.value=e;let s=e!==t&&d(e,t,!0);if(s&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,s,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach(((e,t)=>{for(let s of e)t.removeWatcher(s,this)})),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0}clearnDeps(){this.relations.forEach(((e,t)=>{let s=this.runRelations.get(t);for(let r of e)s?!1===s.includes(r)&&t.removeWatcher(r,this):t.removeWatcher(r,this)})),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}exports.IContainer=void 0,function(e){let t=new Map;e.bind=function(e){return{to:s=>{if(t.has(e))throw new Error(`TagId:${e.toString()}已注入实现类,请勿重复注入。`);t.set(e,s)}}},e.get=function(e,...s){let r=t.get(e);if(r)return new r(...s)}}(exports.IContainer||(exports.IContainer={}));const L=Symbol.for("JOKER_VNODE_TAG");exports.VNode=void 0,function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[L]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let s=this.parent;for(;s;){if(!0===e(s))return s;if(!0===t?.(s))break;s=s.parent}}find(e,t,s,r,n){let i=n??[];if(r??=this.childrens,r)for(let n of r){(!0!==e(n)||(i.push(n),s))&&(!0!==t?.(n)&&n.childrens&&this.find(e,t,s,n.childrens,i))}return i}contains(e,t){if(t??=this.childrens,t)for(let s of t){if(!0===e(s))return!0;if(s.childrens&&s.childrens.length&&this.contains(e,s.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let s of t){if(!0===e(s))return s;if(s.childrens&&s.childrens.length){let t=this.first(e,s.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;constructor(e,t,s){super(t),this.html=e,this.notShadow=s}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=s=>{for(let r of s){if(r instanceof e.Element)return r;if(r.childrens){let e=t(r.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],s=r=>{for(let n of r)n instanceof e.Element||n instanceof e.Html?t.push(n):n.childrens&&s(n.childrens)};return s(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(exports.VNode||(exports.VNode={}));const M="DOM渲染",j=["script","style","textarea","pre"];let H=0;const Y=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];function B(e,t,s){return`${e}-${t}-${s}`}function J(e,t,s,r){e._assistEventCache??=[],e._assistEventCache.push([t,s]),document.body.addEventListener(t,s,r)}function G(e,t,s){e._assistEventCache&&t&&s?(p(e._assistEventCache,(e=>e[0]===t&&e[1]===s)),document.body.removeEventListener(t,s)):(e._assistEventCache?.forEach((e=>{document.body.removeEventListener(e[0],e[1])})),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}exports.Render=void 0,function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof exports.VNode.Component)if(e.parent)if(e.output){let t=e.output,s=U(e)||t.parentNode;s&&s.insertBefore(this.elements,t)}else g.error(M,"组件挂载渲染时发现该节点未定义DOM定位节点",e);else g.error(M,"mount子组件时,发现该组件无父级",e);else g.error(M,"mount只支持挂载到Element或VNode.Node类型数据中",e)}appendNode(e,t){if(this.renderNode(e),e.output){let s=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(let r of s)this.appendNodeChildren(e,r,e.parent,t)}else g.error(M,"未找自身节点的el属性,无法进行dom挂载",e)}updateNode(e,t){if(e instanceof exports.VNode.Element)for(let t in e.attributes){let s=e.attributes[t];this.setAttribute(e.output,t,s)}else e instanceof exports.VNode.Text?e.parent&&e.parent instanceof exports.VNode.Element&&j.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=b(e.text||""):e instanceof exports.VNode.Html?e.notShadow?e.output.innerHTML=e.html:e.output.root.innerHTML=e.html:g.error(M,`该节点不支持${t}的更新`,e)}removeNode(e,t){let s=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];s?.forEach((e=>{e?.remove()})),t||(e instanceof exports.VNode.Element&&G(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,s,r){e.output&&this.transitionFrame(e,t,"enter",s,r)}elementToLeave(e,t,s,r){e.output&&this.transitionFrame(e,t,"leave",s,r)}triggerEvent(e,t,s){let r=[];for(let n of e.events){let[i,o]=n;if(i===t){let t=o.modifiers?.includes("self"),a=o.modifiers?.includes("outside");if(t||a){g.warn(M,"事件修饰符:self、outside在组件事件中无法使用,组件无法确认元素",e);continue}let h=s.event;if((h instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(i)||h instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(i))&&!1===X(h,o.modifiers))continue;if(o.callBack(s),o.modifiers?.includes("prevent")&&s.preventDefault(),o.modifiers?.includes("once")&&r.push(n),o.modifiers?.includes("stop"))return s.stopPropagation(),!1}}r.length&&r.forEach((t=>{c(e.events,t)}))}transitionFrame(e,t,s,r,n){q(e,B(t,s,"from")),r||="transition";let i=e.output.__TRANSITION_EVNETID__=H++;requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(!e.output)return;q(e,B(t,s,"active")),z(e,B(t,s,"from")),q(e,B(t,s,"to"));let o=function(e,t){let s=window.getComputedStyle(e),r=e=>(s[e]||"").split(", ");if("transition"===t){let e=r("transitionDelay"),t=r("transitionDuration"),s=Q(e,t);if(s>0)return{timeout:s,count:t.length}}else if("animation"===t){let e=r("animationDelay"),t=r("animationDuration"),s=Q(e,t);if(s>0)return{timeout:s,count:t.length}}}(e.output,r);if(!o)return void n?.();let a=0,h=()=>{z(e,B(t,s,"to")),z(e,B(t,s,"active")),e.output&&(e.output.removeEventListener(`${r}end`,d),i===e.output.__TRANSITION_EVNETID__&&n?.())},d=t=>{t.target===e.output&&++a>=o.count&&h()};setTimeout((()=>{a<o.count&&h()}),o.timeout+1),e.output?.addEventListener(`${r}end`,d)}))}))}renderNode(e){if(!e.output)if(e instanceof exports.VNode.Text)e.parent&&e.parent instanceof exports.VNode.Element&&j.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(b(e.text||""));else if(e instanceof exports.VNode.Html)if(e.notShadow){let t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.output=t}else{let t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof exports.VNode.Element){let t,s=e.tagName.toLowerCase();"svg"===s||Y.includes(s)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(let s in e.attributes)this.setAttribute(t,s,e.attributes[s]);t.JOKER_NODE=e,e.output=t,e.events.some((e=>"click"===e[0]&&e[1].modifiers?.includes("outside")))?setTimeout((()=>{this.initElementEvents(t,e)})):this.initElementEvents(t,e)}else e instanceof exports.VNode.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(let[s,r]of t.events){let n=r.modifiers?.includes("self"),i=r.modifiers?.includes("outside");n&&i&&(g.warn(M,"事件修饰符:self、outside不可以同时存在,将按照self处理",t),i=!1);let o,a=function(o){if(!(t.sleep||n&&o.target!==e)){if(i){if(o.target===e||e.contains(o.target))return;if(!1===document.contains(o.target))return;if(t.contains((e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(o.target))))return!0}(o instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(s)||o instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(s))&&!1===X(o,r.modifiers)||(r.callBack({eventName:s,event:o,target:t,preventDefault:()=>o.preventDefault(),stopPropagation:()=>o.stopPropagation(),data:void 0}),r.modifiers?.includes("prevent")&&o.preventDefault(),r.modifiers?.includes("stop")&&o.stopPropagation(),r.modifiers?.includes("once")&&(i?G(t,s,a):e.removeEventListener(s,a)))}};r.modifiers?.includes("passive")&&(o={passive:!0}),i?J(t,s,a,o):e.addEventListener(s,a,o)}}parserHtml(e){var t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof exports.VNode.Component||e instanceof exports.VNode.Condition||e instanceof exports.VNode.List||e instanceof exports.VNode.ListItem||e instanceof exports.VNode.RenderSection}appendNodeChildren(e,t,s,r){let n=U(e);if(n)n.appendChild(t);else if(void 0===s)this.elements?.appendChild(t);else if(s)if(s instanceof exports.VNode.Root){let e=s.parent;if(e&&e instanceof exports.VNode.Component&&e.output){let s=e.output,r=s?.parentNode;if(r)return void r.insertBefore(t,s)}this.elements?.appendChild(t)}else if(s instanceof exports.VNode.Element){let e=s.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(s)){let n=s.output?.parentNode;if(void 0!==r&&s.childrens?.length&&n){let i=r-1;if(i<0){let s=ee(e);return void(s&&n.contains(s.output)?s.output.after(t):n.insertBefore(t,n.firstChild))}{let e=s.childrens[i];if(e){let s=e.output;if(s)return void s.after(t)}}}n&&n.insertBefore(t,s.output)}else g.error(M,"该节点不支持嵌套子集,请检查。",{node:e,parent:s})}setAttribute(e,t,s){if(e)if("boolean"!=typeof s){if("class"===t){if(Array.isArray(s)){let e=[];for(let t of s)if(i(t))for(let s in t)t[s]&&e.push(s);else t&&e.push(t);s=e.join(" ")}else if(i(s)){for(let t in s)t=t.trim(),t&&(s[t]?e.classList.add(t):e.classList.remove(t));return}}else if("style"===t&&i(s)){e.removeAttribute("style");for(let t in s){let r=!1;void 0!==s[t]&&!1!==s[t]||(r=!0);let n=String(s[t]);u(n)&&(r=!0),r||(e.style[t]=n)}return}s=(s??"").toString().trim(),"class"===t&&(s=s.split(/\s/).filter((e=>e.trim())).join(" ")),"value"===t&&"value"in e?e.value=s:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s):e.setAttribute(t,s)}else s?e.setAttribute(t,""):e.removeAttribute(t)}}}(exports.Render||(exports.Render={}));const F={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function X(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(let s in F)if(t?.includes(F[s])&&e.key.toLowerCase()!==s)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function q(e,t){e.output&&e.output.classList.add(t)}function z(e,t){e.output&&e.output.classList.remove(t)}function U(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof exports.VNode.Element)return t.output;if("string"==typeof t){exports.Render.ROOT_CONTAINER&&(t="body"===t?exports.Render.ROOT_CONTAINER:`${exports.Render.ROOT_CONTAINER} ${t}`);let e=document.querySelector(t);if(e)return e}g.warn(M,"appendTo类型不支持",{appendTo:t,node:e})}}}function Q(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map(((t,s)=>Z(t)+Z(e[s]))))}function Z(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function ee(e,t){let s=e.prev;for(;s;){if(s instanceof exports.VNode.ListItem==!1)return s;s=s.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof exports.VNode.Element)return;let e=ee(t,!0);if(e)return e;t=t.parent}}}class te extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",te);const se={};const re="Global",ne="渲染核心";function ie(t){try{return new Function(e.EXPRESSHANDLERTAG,re,`return ${t};`)}catch{throw new Error("创建表达式运行方法时出现未知错误,表达式为"+t)}}class oe{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,s,r){this.ast=e,this.ob=t,this.parent=s,this.ext=r}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof exports.VNode.Element||this.node instanceof exports.VNode.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&c(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,(()=>{t()})))return c(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.isDestroy=!0,this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[exports.VNode.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):c(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[exports.VNode.PARSERKEY]&&(t[exports.VNode.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[exports.VNode.PARSERKEY]=this,this.node instanceof exports.VNode.Element&&this.ob[De]&&(this.node.attributes["data-scoped-"+this.ob[De]]=void 0),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t){try{return ie(e).call(t,t,se)}catch(s){g.error(ne,"运行表达式出现错误:"+e,{ob:t}),console.error(s)}}runExpressWithWatcher(e,t,s,r){if(this.isDestroy)return;let n="string"==typeof e?ie(e):e,i=new I((()=>{if(this.isDestroy||t[Pe])return W;try{return n.call(t,t,se)}catch(s){return g.error(ne,"运行表达式出现错误",{ob:t,express:e,node:this.node}),console.error(s),W}}),s,void 0,r);return this.addWatch(i),i.value===W?void 0:i.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach((e=>{e.destroy()})),this.watchers.length=0}}class ae extends oe{parser(){this.node=new exports.VNode.Text(this.ast.text,this.parent),this.appendNode()}}class he extends oe{parser(){this.node=new exports.VNode.Comment(this.ast.text,this.parent),this.appendNode()}}class de extends oe{parser(){if(this.node=new exports.VNode.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){u(this.ast.condition)&&g.error("条件命令",`当前条件命令${this.ast.kind}没有判断条件,请检查`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,(e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[exports.VNode.PARSERKEY];t&&t instanceof de&&t.renderConditionChildren()}}this.reloadAllCondition()}}));this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof exports.VNode.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof de&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof de&&t.renderConditionChildren(),e=e.next}}}class le extends oe{parser(){this.node=new exports.VNode.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,s=Object.create(this.ob),r=!!this.runExpressWithWatcher(function(t,s,r){try{return new Function(e.EXPRESSHANDLERTAG,`${e.EXPRESSHANDLERTAG}.${t}=${s}; return ${r};`)}catch{throw new Error(`For循环命令,表达式运行依赖采集出现未知错误,其中letKey:${t},keyVal:${s},condition:${r}`)}}(t.letKey,t.defaultKeyVal,t.condition),s,(()=>{this.clearWatchers(),this.renderChildrens()}),!0),n=0;for(;r;){let e=Object.create(this.ob);P(e,t.letKey,s[t.letKey]);let i=n++;this.renderItem(e,i),this.runExpressWithWatcher((()=>s[t.letKey]),s,(async(s,r,n,o)=>{await Promise.resolve(),o.isDestroy||(e[t.letKey]=s,n||this.updateListItemOb(e,i))}),!0),this.runExpress(t.step,s),r=!!this.runExpress(t.condition,s)}this.destroyOldChildrens(n)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,(()=>{this.clearWatchers(),this.renderChildrens()})),s=0;if(t&&(Array.isArray(t)||a(t)))for(let r in t){let n=Object.create(this.ob),i=Array.isArray(t)?Number(r):r;e.indexKey&&P(n,e.indexKey,i),e.itemKey&&P(n,e.itemKey,t[r]);let o=s++;this.renderItem(n,o,e.indexKey),e.itemKey&&this.runExpressWithWatcher((()=>t[i]),t,(async(s,r,a,h)=>{await Promise.resolve(),h.isDestroy||i in t&&(n[e.itemKey]=s,a||this.updateListItemOb(n,o))}),!0)}this.destroyOldChildrens(s)}findIndexByIndex(e,t,s){let r=-1;if(this.node)for(let n=t;n<this.node.childrens.length;n++)if(this.checkObEqual(e,this.node.childrens[n]?.ob,s?[s]:void 0)){r=n;break}return r}renderItem(e,t,s){if(!this.ast.childrens?.length||!this.node)return;let r=this.node.childrens?.[t];if(r){if(this.checkObEqual(e,r.ob,s?[s]:void 0))return void(s&&r.ob[s]!==e[s]&&(r.ob[s]=e[s]));let n=this.findIndexByIndex(e,t+1,s);if(n>-1){if(t+1===n)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();else for(let e=0;e<n-t-1;e++)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();return this.renderItem(e,t,s)}return new ce(this.ast,e,this.node,this.ext).init(t)}return new ce(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let s=this.node.childrens?.[t];o(e,((e,t)=>{s.ob[e]!==t&&(s.ob[e]=t)}))}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[exports.VNode.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,s){let r=!0;return void 0!==t&&(o(e,((e,n)=>{s?.includes(e)||t?.[e]===n||(r=!1)})),r)}}class ce extends oe{parser(e){this.node=new exports.VNode.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class pe extends oe{parser(){if(u(this.ast.cmdName))throw g.error("模板指令","解析AST转换VNode时发生错误,未找到指令名称",this.ast),new Error("解析AST转换VNode时发生错误,未找到指令名称");let t;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?t=this.ast.param:this.ast.cmdName.startsWith(re+".")?t=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(t=`${e.createFuntionBody(this.ast.cmdName)}(${this.ast.param})`),t){let e=this.runExpressWithWatcher(`[${t}]`,this.ob,(e=>{this.changeValue(e?.[0])}));return e||=[],"Html"===this.ast.cmdName?this.node=new exports.VNode.Html(ue(e[0]),this.parent,e[1]):this.node=new exports.VNode.Text(ue(e[0]),this.parent),void this.appendNode()}throw new Error(`未找到命令:${this.ast.cmdName}`)}changeValue(e){this.node&&(this.node instanceof exports.VNode.Html?this.node.html=ue(e):this.node.text=ue(e),this.ext.render?.updateNode(this.node))}}function ue(e){return null==e||"function"==typeof e?"":e.toString()}const fe="default";class me extends oe{parser(){let e=this.transformParam();this.node=new exports.VNode.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach(((e,t)=>{P(this.node.ob,e,this.node.params[t])}))):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,(e=>{let t=e?.[0]||fe;if("string"==typeof t&&t!==this.node.id)throw new Error("section id 不可动态变更");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach(((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])}))}),!0);return{id:e?.[0]||fe,params:e?.slice(1)||[]}}return{id:fe,params:[]}}}const Ee="组件解析";function ye(e,t){return!!t.components[e]||!!Me(e)}class Ne extends oe{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new exports.VNode.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally((()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)}))}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):g.warn(Ee,"当前组件无法实现reload",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,(t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)}),!0);this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(u(e.value)){g.warn(Ee,"元素的ref值不可以为空");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=V(this.node.propValues)}initEvent(){this.ast.events.forEach((e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:m}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:s=>{let r=[];e.functionParam&&(r=this.runExpress(`[${e.functionParam}]`,this.ob)),t.call(this.ext.ob,s,...r)}}]):g.error(Ee,`${"tagName"in this.ast?this.ast.tagName:""}元素中${e.name}事件所指定的回调(${e.functionName})方法未找到,请检查`)}))}async renderChildren(){return new Promise((async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||Me(this.ast.tagName);if(void 0===e)return void g.error(Ee,`渲染组件失败,未找到名称为'${this.ast.tagName}'的私有组件/全局组件`);if(_e in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let s=this,r=function(){s.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",(()=>{this.node?.component.$off("beforeDestroy",r),e(void 0)})),this.node.component.$on("beforeDestroy",r),this.node.component.$mount(this.node),!this.node)return;let n=this.node?.component;n.isKeepAlive&&(this.ast.node=this.node)}))}getSections(){let t={},s=[];return this.ast.childrens.forEach((t=>{if(t.type===e.AST.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let r=t,n=t.childrens.some((t=>t.type===e.AST.NodeType.COMMAND&&"section"===t.cmdName)),i=r.condition.startsWith(e.EXPRESSHANDLERTAG+".$sections");if(i){return this.runExpress(r.condition,this.ob)?void s.push(...t.childrens):void 0}if(n&&"if"===r.kind&&!i)return void g.warn(Ee,"在解析section时,发现该section包裹在一个条件语句中,该条件语句仅支持以$sections进行if判断,已作排出")}s.push(t)})),s.forEach((s=>{if(s.type===e.AST.NodeType.COMMAND&&"section"===s.cmdName){let e=s,r=e.id||fe;/^(\'|\")(.*?)((\'|\"))$/.test(r)&&(r=r.slice(1,-1)),t[r]=t[r]||{asts:[],ob:this.ob,params:e.paramKeys,parser:this.ext},t[r].asts.push(...s.childrens||[])}else t[fe]=t[fe]||{asts:[],ob:this.ob,parser:this.ext},t[fe].asts.push(s)})),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0)}}class ve extends oe{parser(){this.node=new exports.VNode.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},s=this.runExpressWithWatcher(e.express,this.ob,(e=>{t(e)}));this.node.attributes[e.name]=this.transformAttrVal(s)}else this.node.attributes[e.name]=e.value;else{if(u(e.value)){g.warn("Element解析","元素的ref值不可以为空");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`${this.ast.tagName}元素中${e.name}事件所指定的回调(${e.functionName})方法未找到,请检查`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:s=>{if(void 0===t)return;let r=[];e.functionParam&&(r=this.runExpress(`[${e.functionParam}]`,this.ob)),t&&t.call(this.ext.ob,s,...r)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class ge{asts;ob;root=new exports.VNode.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,s){this.asts=e,this.ob=t,this.root.component=t,this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,s&&s instanceof exports.VNode.Node&&(this.root.parent=s,s.childrens??=[],s.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(t,s,r){if(0!==this.asts.length)for(let n of t)if(n.type===e.AST.NodeType.TEXT)new ae(n,r??this.ob,s,this).init();else if(n.type===e.AST.NodeType.COMMENT)new he(n,r??this.ob,s,this).init();else if(n.type===e.AST.NodeType.COMPONENT)new Ne(n,r??this.ob,s,this).init();else if(n.type===e.AST.NodeType.ELEMENT){let e=n;ye(e.tagName,r??this.ob)?new Ne(e,r??this.ob,s,this).init():new ve(e,r??this.ob,s,this).init()}else if(n.type===e.AST.NodeType.COMMAND){let e=n;switch(e.cmdName){case"if":case"elseif":case"else":new de(e,r??this.ob,s,this).init();break;case"for":new le(e,r??this.ob,s,this).init();break;case"RenderSection":new me(e,r??this.ob,s,this).init();break;case"section":break;default:new pe(e,r??this.ob,s,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&c(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){c(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,s,r){this.nodeWatcherEvents[e]?.forEach((e=>{e(t,s,r)}))}sleep(e){let t=e||this.root;t.childrens?.forEach((e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,(()=>{t()}))||t()})),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach((e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")})),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):c(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[exports.VNode.PARSERKEY]&&e[exports.VNode.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,this.asts=e}nodeTransition(e,t,s,r,n){if(e&&e.parent?.childrens&&(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component)){let i=function(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(s??=i?.name,n??=i?.type,!s)return!1;let o=xe(e);if(o)return"enter"===t?this.render.elementToEnter(o,s,n,(()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),r?.()})):this.render.elementToLeave(o,s,n,(()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),r?.()})),!0;g.warn("渲染核心","在执行node动画时,发现数据不完备,请检查")}return!1}}function xe(e){if(e instanceof exports.VNode.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof exports.VNode.Element?t:xe(t)}function be(e,t,s){if(void 0===t)return;let r=Array.isArray(s)?s:[s];for(let e of r){if(e===Array&&t instanceof Array)return t;if(typeof t===e.name.toLocaleLowerCase())return t}switch(r[0]){case Number:let e=Number(t);if(!1===isNaN(e))return e;break;case String:return String(t)}throw new Error(`props中${e.toString()}的类型不符合约束类型`)}function we(e,t,s){let r,n,i;if("symbol"!=typeof t&&(r=f(t)),t in e?n=e[t]:r&&(n=e[r]),s&&(t in s?i=s[t]:r&&r in s&&(i=s[r])),void 0!==i){if(a(i)&&("type"in i||"required"in i||"default"in i||"validate"in i)){let e=i;if(e.required&&void 0===n)throw new Error(`props中key:${t.toString()}是必须项,请检查`);if(e.type&&(n=be(t,n,e.type)),e.validate&&!1===e.validate(n))throw new Error(`props中key${t.toString()}的值校验错误`);n=n??e.default}else n=Re(i)?be(t,n,i):n??i;return n}return n}function Re(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||e instanceof Array&&Re(e[0])}function Ae(e,t){if(!e.constructor)return!1;let s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return s&&s.get}const Ce="组件",Oe=Symbol.for("JOKER_PROPS_DATA_KEY"),Se=Symbol.for("JOKER_PROPS_DATA_PROXY"),$e=Symbol.for("JOKER_PRIVATE_WATCHERS"),Ve=Symbol.for("JOKER_EVENT_DATA_KEY"),Pe=Symbol.for("JOKER_IS_DESTROY"),Te=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),De=Symbol.for("JOKER_SCOPE_ID"),_e=Symbol.for("JOKER_COMPONENT_TAG"),Ke=Symbol();let ke=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class We{$sections;isKeepAlive;static[_e]=!0;[De];model={};template;$root;isSleeped=!1;components={};propsOption;[Oe]={};[Te];[Se];[$e]=[];[Ve]=new Map;[Pe]=!1;[Ke]=!1;constructor(e,t={},s){this.$sections=t,this.isKeepAlive=s,this[Oe]=e||{}}get props(){if(void 0===this[Se]){let e=this;this[Se]=new Proxy(e[Oe],{get:(t,s)=>we(e[Oe],s,e.propsOption),set(){throw new Error("props 参数不允许变更,只允许单向数据传递")}})}return this[Se]}$mount(e){if(!1===this[Ke]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach((s=>{!1!==ke.includes(s)||Ae(t,s)||"function"!=typeof t[s]||t[s].prototype?.hasOwnProperty("constructor")||e.push(s)})),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[Ke]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[Te]&&this.$root?(this[Te].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&He(this.$rootVNode),this):(g.error(Ce,"当前组件在唤醒时,发现渲染处理程序已被销毁,无法进行唤醒操作",[this,this.$root]),this);this.isSleeped=!1,this.model=V(this.model);let t=this.created(),s=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[Pe]||(await this.mounted(),this[Pe]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then((()=>{this[Pe]||s()})):s(),this}$nextUpdatedRender(e){if(this[Pe])return;let t=[...this[Te]?.promiseQueue||[]],s=this.$rootVNode?.find((e=>e instanceof exports.VNode.Component));if(s?.forEach((e=>{e?.component&&t.push(...e.component[Te]?.promiseQueue||[])})),t.length)return Promise.all(t).finally((()=>{this[Pe]||e?.()}));this[Pe]||e?.()}$nodeTransition(e,t,s,r,n){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void g.error(Ce,`执行节点动画是找不到ref=${e}的节点`);e=t}this[Te]?.nodeTransition(e,t,s,r,n)}$destroy(e){if(!e&&this.isKeepAlive)return this[Te]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&je(this.$rootVNode));this[Pe]=!0;for(let e of this[$e])e.destroy();this[$e].length=0,this[Te]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[Te]?.destroy(),this[Te]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[Ve].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[Se]=void 0,this[Oe]={},this.destroyed()}get $refs(){return this[Te]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,s){"function"==typeof t&&(s=t,t=void 0),t??=e,s??=e=>e,this.model[t]=s(this.props[e]),this.$watch((()=>this.props[e]),(()=>{this.model[t]=s?.(this.props[e])}))}get $rootVNode(){return this[Te]?.root}$watchNode(e,t){if(this[Te])return this[Te]?.addNodeWatcher(e,t),()=>{this[Te]?.removeNodeWatcher(e,t)};g.warn(Ce,"该组件还未挂载,不可以进行节点观察监听")}$watch(e,t,s){let r=new I((()=>{if(this[Pe]){for(let e of this[$e])e.destroy();return W}return e()}),((e,s)=>{this[Pe]||t(e,s)}),void 0,s);return this[$e].push(r),[r.value,()=>{r.destroy(),c(this[$e],r)}]}$on(e,t){let s=this[Ve].get(e);void 0===s&&(s=new Set,this[Ve].set(e,s)),!1===s?.has(t)&&s.add(t)}$off(e,t){let s=this[Ve].get(e);s&&(t?s.delete(t):s.clear())}$trigger(e,t,s){if(!this.$root)return;let r={eventName:e,stopPropagation:s?.stopPropagation??(()=>{}),preventDefault:s?.preventDefault??(()=>{}),data:t,target:s?.target??this.$rootVNode,event:s?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof exports.VNode.Component&&!1===this[Te]?.render.triggerEvent(this.$rootVNode.parent,e,r))return;let n=this[Ve].get(e);n?.size&&[...n].forEach((e=>{e(r)}));let i=this[Ve].get("*");i?.size&&[...i].forEach((e=>{e(r)}))}$render(t,s){t??=this.template,this.template="function"==typeof t?t(e.RENDER_HANDLER):t,this.$root&&(this.template??=[],this[Te]?.reSetAsts(this.template,s),this[Te]??=new ge(this.template,this,this.$root),this[Te].parser(),this.$root&&this[Te].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Ie={};function Le(e,t){if("string"==typeof e)t&&(Ie[e]=t);else for(let t in e)Ie[t]=e[t]}function Me(e){return Ie[e]}function je(e){e.childrens?.forEach((e=>{e instanceof exports.VNode.Component&&e.component?.sleeped(),je(e)}))}function He(e){e.childrens?.forEach((e=>{e instanceof exports.VNode.Component&&e.component?.wakeup(),He(e)}))}class Ye extends We{template=[];cache=new Map;async mounted(){this.$watch((()=>this.props.name),(async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)})),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach((t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch((()=>this.props[t]),(()=>{this.propsVaule[t]=this.props[t]})))})),this.propsVaule=V(e))}filterProps(e){if("string"!=typeof e)return!1;let t=f(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(t){if(!t)return void this.$render([],this.isKeepAlive);let s;if(this.isKeepAlive){let s=this.cache.get(t);if(s)return void this.$render([e.createComponent(s,{"transition-name":this.props["transition-name"]})],!0)}let r=this.$rootVNode?.parent?.[exports.VNode.PARSERKEY]?.ob.components,n=r?.[t];void 0===n&&(n=Me(t)),n?(_e in n||(n=(await n()).default),s=new n(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),s.$on("*",(e=>{this.$trigger(e.eventName,e.data,e)})),this.isKeepAlive&&this.cache.set(t,s),this.$render([e.createComponent(s,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):g.warn("component",`未找到${t}的组件`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach((e=>{e.$destroy(!0)})),this.cache.clear()}}class Be extends We{template=function(){return[e.createCommand("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}Le({template:Be,component:Ye});Object.defineProperty(exports,"AST",{enumerable:!0,get:function(){return e.AST}}),Object.defineProperty(exports,"EXPRESSHANDLERTAG",{enumerable:!0,get:function(){return e.EXPRESSHANDLERTAG}}),Object.defineProperty(exports,"RENDER_HANDLER",{enumerable:!0,get:function(){return e.RENDER_HANDLER}}),Object.defineProperty(exports,"createCodeFunction",{enumerable:!0,get:function(){return e.createCodeFunction}}),Object.defineProperty(exports,"createCommand",{enumerable:!0,get:function(){return e.createCommand}}),Object.defineProperty(exports,"createComment",{enumerable:!0,get:function(){return e.createComment}}),Object.defineProperty(exports,"createComponent",{enumerable:!0,get:function(){return e.createComponent}}),Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return e.createElement}}),Object.defineProperty(exports,"createFuntionBody",{enumerable:!0,get:function(){return e.createFuntionBody}}),Object.defineProperty(exports,"createText",{enumerable:!0,get:function(){return e.createText}}),exports.BREAK_WATCH_UPDATE=W,exports.Component=We,exports.ComponentContainer=Ye,exports.Dep=w,exports.EventBus=class{eventDatas=new Map;on(e,t){let s=this.eventDatas.get(e);void 0===s&&(s=[],this.eventDatas.set(e,s));let r={callBack:t};return s.push(r),()=>{s&&c(s,r)}}once(e,t){let s=this.eventDatas.get(e);void 0===s&&(s=[],this.eventDatas.set(e,s));let r={callBack:t,once:!0};return s.push(r),()=>{s&&c(s,r)}}off(e,t){if(void 0!==e)if(t){let s=this.eventDatas.get(e),r=s?.find((e=>e.callBack===t));r&&c(s,r)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let s=[...this.eventDatas.get(e)||[]];if(s.push(...this.eventDatas.get("*")||[]),s&&s.length){let r=0,n=0,i=!1;for(;s[r];){let o=s[r],a=await o.callBack({stopPropagation:()=>i=!0,callTimes:n,eventName:e},t);if(o.once?c(s,o):r++,!1===a||i)return!1}}}},exports.IS_DESTROY=Pe,exports.JOKER_COMPONENT_TAG=_e,exports.JOKER_VNODE_TAG=L,exports.OBJECTPROXY_DEPID=R,exports.PARSER_TEMPLATE_TARGET=Te,exports.ParserTemplate=ge,exports.SCOPE_ID=De,exports.ShallowObserver=class{data;[T]=!0;dep=new w;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(C),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,K(this.dep,C))}},exports.Template=Be,exports.Watcher=I,exports.__GLONAL_FUNTIONS__=se,exports.__JOKER_HMR_RUNTIME=n,exports.combinedReply=function(e){D=!0;try{e()}catch(e){return D=!1,_.clear(),void g.error("数据劫持","数据劫持组合回复在做变更采集时,遇到了阻塞错误,不做响应,请检查",e)}D=!1,function(e){let t=[],s=[];e.forEach(((e,s)=>{e.forEach((e=>{t.push(...s.watchers.get(e)||[])}))})),t.forEach((e=>{s.includes(e)||(!1===e.isDestroy&&e.update(),s.push(e))}))}(_),_.clear()},exports.defineObserverProperty=P,exports.getGlobalComponent=Me,exports.isObserverData=function(e){return void 0!==$(e)},exports.observer=V,exports.registerGlobalComponent=Le,exports.registerGlobalFunction=function(e){for(let t in e)se[t]=e[t]};
1
+ "use strict";var e=require("@joker.front/ast");const t=new Map,n=new Map,o=new Map;let s={recordRender:(e,t)=>{n.set(e,t)},recordComponent:(e,t)=>{o.set(e,t)},record:(e,n)=>{void 0===t.get(e)&&t.set(e,new Set),t.get(e).add(n),n.$on("destroy",(()=>{t.get(e)?.delete(n)}))},reload:(e,n)=>{let s=o.get(e);if(!s)return;s.component=n;let r=t.get(e);if(!r)return;let i=Array.from(r);r.clear(),i.forEach((e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof exports.VNode.Component&&t[exports.VNode.PARSERKEY]&&t[exports.VNode.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[exports.VNode.PARSERKEY].reload()}}}))},rerender:(e,o)=>{let s=n.get(e);s&&(s.render=o),t.get(e)?.forEach((e=>{e.$render(o)}))}};function r(e){return null!==e&&"object"==typeof e}function i(e,t){Object.getOwnPropertyNames(e).forEach((n=>{t(n,e[n])}))}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}function d(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let n=Object.keys(e);for(let o of n){let n=e[o];t[o]="object"==typeof n?d(n):n}return t}function h(e,t,n){return Array.isArray(e)&&Array.isArray(t)?function(e,t,n){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(n){if(e[o]!==t[o])return!1}else if(!1===c(e[o],t[o],n))return!1;return!0}(e,t,n):c(e,t,n)}function c(e,t,n){if(e===t)return!0;let o=r(e),s=r(t);if(o&&s){if(a(e)&&a(t)){let o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;if(n){for(let n of o)if(e[n]!==t[n])return!1;return!0}return JSON.stringify(e)===JSON.stringify(t)}return e===t}return!o&&!s&&String(e)===String(t)}function l(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),e}function p(e,t){let n=e.findIndex((e=>t(e)));return n>-1&&e.splice(n,1),e}function u(e){return!e||""===e.trim()}function f(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map((e=>e.toLowerCase())).join(t)}let m=(...e)=>{},y="warn";const E=["silent","error","warn","info"];function N(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function g(e,t,n,o){E.indexOf(e)<=E.indexOf(y)&&(void 0===o?console[e](`${N()} [${t}]:`,n):console[e](`${N()} [${t}]:`,n,o))}let v={info:function(e,t,n){g("info",e,t,n)},warn:function(e,t,n){g("warn",e,t,n)},error:function(e,t,n){g("error",e,t,n)},setLoggerLeve:function(e){y=e}};const x={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function b(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,((e,t)=>x[t]||""))}class w{static target;watchers=new Map;depend(e){w.target?.addDep(this,e)}addWatcher(e,t){let n=this.watchers.get(e)||[];n.push(t),this.watchers.set(e,n)}removeWatcher(e,t){const n=this.watchers.get(e);n&&l(n,t)}notify(e){const t=this.watchers.get(e);if(t){p(t,(e=>e.isDestroy));[...t].forEach((e=>{e.isDestroy||e.update()}))}}}const R=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),A=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),C=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function $(e){try{return null!=e&&r(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof I==!1&&e instanceof Ie==!1&&e instanceof xe==!1&&(Array.isArray(e)||a(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(L in e)&&!(P in e)&&!(ke in e)}catch{return!1}}function O(e){if(S(e))return e;if(e&&e.hasOwnProperty(A)){let t=Reflect.get(e,A);if(t)return t}let t=new w,n=!0,o=new Proxy(e,{get(e,n,o){if(e instanceof Set||e instanceof Map){if("add"===n){let o=Reflect.get(e,n);return n=>{$(n)&&(n=T(n));let s=o.call(e,n);return k(t,"size"),k(t,C),s}}if("set"===n){let o=Reflect.get(e,n);return(n,s)=>{$(s)&&(s=T(s));let r=o.call(e,n,s);return k(t,"size"),k(t,C),r}}if("delete"===n||"clear"===n){let o=Reflect.get(e,n);return s=>{let r=o.call(e,s);return("clear"===n||r)&&(k(t,"size"),k(t,C)),r}}let o=Reflect.get(e,n);if("function"==typeof o)return o.bind(e)}if(n===A)return;if(n===R)return t;if(n===C)return;let s=Reflect.get(e,n);return n===Symbol.toStringTag||!1===function(e,t){return t in e}(e,n)&&"length"!==n&&"size"!==n||(t.depend(n),$(s)&&S(s)?.depend(C)),s},set(e,o,s){if(n)return Reflect.set(e,o,s),!0;$(s)&&(s=T(s));let r=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,o),i=Reflect.get(e,o)!==s;return Reflect.set(e,o,s),(i||"length"===o&&Array.isArray(e))&&k(t,o),Array.isArray(e)?"length"===o&&k(t,C):r&&k(t,C),!0},deleteProperty:(e,n)=>(Reflect.deleteProperty(e,n),!1===Array.isArray(e)&&k(t,C),!0)});var s,r,i,a;s=e,r=A,i=o,a=!1,Object.defineProperty(s,r,{value:i,enumerable:a,writable:!0,configurable:!0});for(let t in e){let n=e[t];$(n)&&!S(n)&&(o[t]=O(e[t]))}return n=!1,o}function S(e){if(r(e))return Reflect.get(e,R)}function T(e,t=!1){if(!1===$(e))throw new Error("The provided data is not of the correct type. It must be an array or an object.");return O(t?d(e):e)}function V(e,t,n){let o=n;$(n)&&(o=T(n));let s=new w;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(s.depend(t),S(o)?.depend(C),o),set:e=>{e!==o&&($(e)&&(e=T(e)),o=e,k(s,t))}})}const P=Symbol.for("JOKER_SHALLOW_OBSERVER");let D=!1,_=new Map;function k(e,t){if(!1===D)e.notify(t);else{let n=_.get(e);void 0===n&&(n=[],_.set(e,n)),n.includes(t)||n.push(t)}}const K="Data Observation",W=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class I{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,n,o){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=o,void 0===e)throw new Error("Cannot observe changes on undefined");if(void 0===n)this.getter=e=>e;else if("function"==typeof n)this.getter=n;else{const e=function(e){if(/[^\w.$]/.test(e))return;const t=e.split(".");return function(e){let n=e;return t.forEach((e=>{n&&(n=n[e])})),n}}(n);if(void 0===e)throw new Error(`${n} failed to parse. Unable to interpret the expression. Please check the expOrFn parameter or use the function mode instead.`);this.getter=e}void 0===this.getter&&v.error(K,"Failed to create getter",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;w.target=this;const e="function"==typeof this.ob?this.ob():this.ob;let t;try{t=this.getter.call(e,e)}catch(e){throw v.error(K,"Failed to retrieve value. Executed method: "+this.getter.toString()),e}return w.target=void 0,this.clearnDeps(),t}addDep(e,t){let n=this.runRelations.get(e);if(void 0===n||!n.includes(t)){n=n||[],n.push(t),this.runRelations.set(e,n);const o=this.relations.get(e);void 0!==o&&o.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;const e=this.getValue();if(e===W)return;const t=this.value;if(this.forceCallBack||e!==t||r(e)){this.value=e;const n=e!==t&&h(e,t,!0);if(n&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,n,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach(((e,t)=>{for(const n of e)t.removeWatcher(n,this)})),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0}clearnDeps(){this.relations.forEach(((e,t)=>{const n=this.runRelations.get(t);for(const o of e)n&&n.includes(o)||t.removeWatcher(o,this)})),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}exports.IContainer=void 0,function(e){let t=new Map;e.bind=function(e){return{to:n=>{if(t.has(e))throw new Error(`TagId:${e.toString()} already has an implementation bound. Do not bind again.`);t.set(e,n)}}},e.get=function(e,...n){const o=t.get(e);if(o)return new o(...n)}}(exports.IContainer||(exports.IContainer={}));const L=Symbol.for("JOKER_VNODE_TAG");exports.VNode=void 0,function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[L]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let n=this.parent;for(;n;){if(!0===e(n))return n;if(!0===t?.(n))break;n=n.parent}}find(e,t,n,o,s){let r=s??[];if(o??=this.childrens,o)for(let s of o){(!0!==e(s)||(r.push(s),n))&&(!0!==t?.(s)&&s.childrens&&this.find(e,t,n,s.childrens,r))}return r}contains(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return!0;if(n.childrens&&n.childrens.length&&this.contains(e,n.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return n;if(n.childrens&&n.childrens.length){let t=this.first(e,n.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;scopedId;constructor(e,t,n){super(t),this.html=e,this.notShadow=n}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=n=>{for(let o of n){if(o instanceof e.Element)return o;if(o.childrens){let e=t(o.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],n=o=>{for(let s of o)s instanceof e.Element||s instanceof e.Html?t.push(s):s.childrens&&n(s.childrens)};return n(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(exports.VNode||(exports.VNode={}));const j="DOM Rendering",M=["script","style","textarea","pre"];let H=0;const Y=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];function B(e,t,n){return`${e}-${t}-${n}`}function J(e,t,n,o){e._assistEventCache??=[],e._assistEventCache.push([t,n]),document.body.addEventListener(t,n,o)}function G(e,t,n){e._assistEventCache&&t&&n?(p(e._assistEventCache,(e=>e[0]===t&&e[1]===n)),document.body.removeEventListener(t,n)):(e._assistEventCache?.forEach((e=>{document.body.removeEventListener(e[0],e[1])})),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}exports.Render=void 0,function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof exports.VNode.Component)if(e.parent)if(e.output){const t=e.output,n=z(e)||t.parentNode;n&&n.insertBefore(this.elements,t)}else v.error(j,"Component mount found no DOM target node",e);else v.error(j,"Mounting child component with no parent",e);else v.error(j,"Mount only supports Element or VNode.Node",e)}appendNode(e,t){if(this.renderNode(e),e.output){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(const o of n)this.appendNodeChildren(e,o,e.parent,t)}else v.error(j,"No output found for node, cannot mount",e)}updateNode(e,t){if(e instanceof exports.VNode.Element)for(const t in e.attributes){const n=e.attributes[t];this.setAttribute(e.output,t,n)}else e instanceof exports.VNode.Text?e.parent&&e.parent instanceof exports.VNode.Element&&M.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=b(e.text||""):e instanceof exports.VNode.Html?e.notShadow?(e.output.innerHTML=e.html,e.scopedId&&ne(e.output,e.scopedId)):e.output.root.innerHTML=e.html:v.error(j,`Node does not support ${t} update`,e)}removeNode(e,t){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];n?.forEach((e=>e?.remove())),t||(e instanceof exports.VNode.Element&&G(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,n,o){e.output&&this.transitionFrame(e,t,"enter",n,o)}elementToLeave(e,t,n,o){e.output&&this.transitionFrame(e,t,"leave",n,o)}triggerEvent(e,t,n){const o=[];for(const s of e.events){const[r,i]=s;if(r===t){const t=i.modifiers?.includes("self"),a=i.modifiers?.includes("outside");if(t||a){v.warn(j,"Event modifiers 'self' and 'outside' not supported in components",e);continue}const d=n.event;if((d instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(r)||d instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(r))&&!1===q(d,i.modifiers))continue;if(i.callBack(n),i.modifiers?.includes("prevent")&&n.preventDefault(),i.modifiers?.includes("once")&&o.push(s),i.modifiers?.includes("stop"))return n.stopPropagation(),!1}}o.length&&o.forEach((t=>l(e.events,t)))}transitionFrame(e,t,n,o,s){X(e,B(t,n,"from")),o||="transition";const r=e.output.__TRANSITION_EVNETID__=H++;requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(!e.output)return;X(e,B(t,n,"active")),U(e,B(t,n,"from")),X(e,B(t,n,"to"));const i=function(e,t){const n=window.getComputedStyle(e),o=e=>(n[e]||"").split(", ");if("transition"===t){const e=o("transitionDelay"),t=o("transitionDuration"),n=Q(e,t);if(n>0)return{timeout:n,count:t.length}}else if("animation"===t){const e=o("animationDelay"),t=o("animationDuration"),n=Q(e,t);if(n>0)return{timeout:n,count:t.length}}}(e.output,o);if(!i)return void s?.();let a=0;const d=()=>{U(e,B(t,n,"to")),U(e,B(t,n,"active")),e.output&&(e.output.removeEventListener(`${o}end`,h),r===e.output.__TRANSITION_EVNETID__&&s?.())},h=t=>{t.target===e.output&&++a>=i.count&&d()};setTimeout((()=>{a<i.count&&d()}),i.timeout+1),e.output?.addEventListener(`${o}end`,h)}))}))}renderNode(e){if(!e.output)if(e instanceof exports.VNode.Text)e.parent&&e.parent instanceof exports.VNode.Element&&M.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(b(e.text||""));else if(e instanceof exports.VNode.Html)if(e.notShadow){const t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.scopedId&&(t.setAttribute("data-scoped-"+e.scopedId,""),ne(t,e.scopedId)),e.output=t}else{const t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof exports.VNode.Element){let t;const n=e.tagName.toLowerCase();"svg"===n||Y.includes(n)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(const n in e.attributes)this.setAttribute(t,n,e.attributes[n]);t.JOKER_NODE=e,e.output=t,e.events.some((e=>"click"===e[0]&&e[1].modifiers?.includes("outside")))?setTimeout((()=>{this.initElementEvents(t,e)})):this.initElementEvents(t,e)}else e instanceof exports.VNode.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(const[n,o]of t.events){const s=o.modifiers?.includes("self");let r=o.modifiers?.includes("outside");s&&r&&(v.warn(j,"Event modifiers 'self' and 'outside' cannot coexist, using 'self'",t),r=!1);const i=a=>{if(!(t.sleep||s&&a.target!==e)){if(r){if(a.target===e||e.contains(a.target))return;if(!1===document.contains(a.target))return;if(t.contains((e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(a.target))))return!0}(a instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(n)||a instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(n))&&!1===q(a,o.modifiers)||(o.callBack({eventName:n,event:a,target:t,preventDefault:()=>a.preventDefault(),stopPropagation:()=>a.stopPropagation(),data:void 0}),o.modifiers?.includes("prevent")&&a.preventDefault(),o.modifiers?.includes("stop")&&a.stopPropagation(),o.modifiers?.includes("once")&&(r?G(t,n,i):e.removeEventListener(n,i)))}};let a;o.modifiers?.includes("passive")&&(a={passive:!0}),r?J(t,n,i,a):e.addEventListener(n,i,a)}}parserHtml(e){const t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof exports.VNode.Component||e instanceof exports.VNode.Condition||e instanceof exports.VNode.List||e instanceof exports.VNode.ListItem||e instanceof exports.VNode.RenderSection}appendNodeChildren(e,t,n,o){let s=z(e);if(s)s.appendChild(t);else if(void 0===n)this.elements?.appendChild(t);else if(n)if(n instanceof exports.VNode.Root){const e=n.parent;if(e&&e instanceof exports.VNode.Component&&e.output){const n=e.output,o=n?.parentNode;if(o)return void o.insertBefore(t,n)}this.elements?.appendChild(t)}else if(n instanceof exports.VNode.Element){const e=n.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(n)){const s=n.output?.parentNode;if(void 0!==o&&n.childrens?.length&&s){const r=o-1;if(r<0){const n=ee(e);return void(n&&s.contains(n.output)?n.output.after(t):s.insertBefore(t,s.firstChild))}{const e=n.childrens[r];if(e){const n=e.output;if(n)return void n.after(t)}}}s&&s.insertBefore(t,n.output)}else v.error(j,"Node does not support nested children",{node:e,parent:n})}setAttribute(e,t,n){if(e)if("boolean"!=typeof n){if("class"===t){if(Array.isArray(n)){const e=[];for(const t of n)if(r(t))for(const n in t)t[n]&&e.push(n);else t&&e.push(t);n=e.join(" ")}else if(r(n)){for(const t in n){const o=t.trim();o&&(n[t]?e.classList.add(o):e.classList.remove(o))}return}}else if("style"===t&&r(n)){e.removeAttribute("style");for(const t in n){let o=!1;void 0!==n[t]&&!1!==n[t]||(o=!0);const s=String(n[t]);u(s)&&(o=!0),o||(e.style[t]=s)}return}n=(n??"").toString().trim(),"class"===t&&(n=n.split(/\s/).filter((e=>e.trim())).join(" ")),"value"===t&&"value"in e?e.value=n:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n):e.setAttribute(t,n)}else n?e.setAttribute(t,""):e.removeAttribute(t)}}}(exports.Render||(exports.Render={}));const F={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function q(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(const n in F)if(t?.includes(F[n])&&e.key.toLowerCase()!==n)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function X(e,t){e.output&&e.output.classList.add(t)}function U(e,t){e.output&&e.output.classList.remove(t)}function z(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof exports.VNode.Element)return t.output;if("string"==typeof t){exports.Render.ROOT_CONTAINER&&(t="body"===t?exports.Render.ROOT_CONTAINER:`${exports.Render.ROOT_CONTAINER} ${t}`);const e=document.querySelector(t);if(e)return e}v.warn(j,"Unsupported appendTo type",{appendTo:t,node:e})}}}function Q(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map(((t,n)=>Z(t)+Z(e[n]))))}function Z(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function ee(e,t){let n=e.prev;for(;n;){if(n instanceof exports.VNode.ListItem==!1)return n;n=n.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof exports.VNode.Element)return;const e=ee(t,!0);if(e)return e;t=t.parent}}}class te extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}function ne(e,t){const n=e.childNodes;for(let e=0;e<n.length;e++){const o=n[e];if(1===o.nodeType){const e=o;e.setAttribute("data-scoped-"+t,""),ne(e,t)}}}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",te);const oe={};const se="Global",re="Render Core";function ie(t,n){try{return new Function(e.EXPRESSHANDLERTAG,se,`return ${t};`)}catch(e){throw new Error(`An unknown error occurred while creating the expression execution method. The expression is:${e.message} \n${n?.()||t}`)}}class ae{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,n,o){this.ast=e,this.ob=t,this.parent=n,this.ext=o}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof exports.VNode.Element||this.node instanceof exports.VNode.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&l(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,(()=>{t()})))return l(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.isDestroy=!0,this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[exports.VNode.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):l(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[exports.VNode.PARSERKEY]&&(t[exports.VNode.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[exports.VNode.PARSERKEY]=this,this.node instanceof exports.VNode.Element&&this.ob[_e]?this.node.attributes["data-scoped-"+this.ob[_e]]=void 0:this.node instanceof exports.VNode.Html&&this.ob[_e]&&(this.node.scopedId=this.ob[_e]),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t,n){try{return ie(e,n).call(t,t,oe)}catch(o){v.error(re,`Expression error:${o.message}\n`+(n?.()||e),{ob:t}),console.error(o)}}runExpressWithWatcher(e,t,n,o,s){if(this.isDestroy)return;let r="string"==typeof e?ie(e,s):e,i=new I((()=>{if(this.isDestroy||t[Pe])return W;try{return r.call(t,t,oe)}catch(n){return v.error(re,`Expression error:${n.message}\n${s?.()||e}`,{ob:t,express:e,node:this.node}),console.error(n),W}}),n,void 0,o);return this.addWatch(i),i.value===W?void 0:i.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach((e=>{e.destroy()})),this.watchers.length=0}}class de extends ae{parser(){this.node=new exports.VNode.Text(this.ast.text,this.parent),this.appendNode()}}class he extends ae{parser(){this.node=new exports.VNode.Comment(this.ast.text,this.parent),this.appendNode()}}class ce extends ae{parser(){if(this.node=new exports.VNode.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){u(this.ast.condition)&&v.error("Conditional Command",`The current conditional command ${this.ast.kind} has no judgment condition, please check`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,(e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[exports.VNode.PARSERKEY];t&&t instanceof ce&&t.renderConditionChildren()}}this.reloadAllCondition()}}),!1,(()=>this.ast._code));this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob,(()=>{this.ast._code})),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof exports.VNode.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof ce&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof ce&&t.renderConditionChildren(),e=e.next}}}class le extends ae{parser(){this.node=new exports.VNode.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,n=Object.create(this.ob),o=!!this.runExpressWithWatcher(function(t,n,o){try{return new Function(e.EXPRESSHANDLERTAG,`${e.EXPRESSHANDLERTAG}.${t}=${n}; return ${o};`)}catch{throw new Error(`Dependency collection for the For loop command expression execution encountered an unknown error. Details: letKey: ${t}, keyVal: ${n}, condition: ${o}`)}}(t.letKey,t.defaultKeyVal,t.condition),n,(()=>{this.clearWatchers(),this.renderChildrens()}),!0,(()=>this.ast._code)),s=0;for(;o;){let e=Object.create(this.ob);V(e,t.letKey,n[t.letKey]);let r=s++;this.renderItem(e,r),this.runExpressWithWatcher((()=>n[t.letKey]),n,(async(n,o,s,i)=>{await Promise.resolve(),i.isDestroy||(e[t.letKey]=n,s||this.updateListItemOb(e,r))}),!0,(()=>this.ast._code)),this.runExpress(t.step,n,(()=>{this.ast._code})),o=!!this.runExpress(t.condition,n,(()=>this.ast._code))}this.destroyOldChildrens(s)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,(()=>{this.clearWatchers(),this.renderChildrens()}),!1,(()=>this.ast._code)),n=0;if(t&&(Array.isArray(t)||a(t)))for(let o in t){let s=Object.create(this.ob),r=Array.isArray(t)?Number(o):o;e.indexKey&&V(s,e.indexKey,r),e.itemKey&&V(s,e.itemKey,t[o]);let i=n++;this.renderItem(s,i,e.indexKey),e.itemKey&&this.runExpressWithWatcher((()=>t[r]),t,(async(n,o,a,d)=>{await Promise.resolve(),d.isDestroy||r in t&&(s[e.itemKey]=n,a||this.updateListItemOb(s,i))}),!0,(()=>this.ast._code))}this.destroyOldChildrens(n)}findIndexByIndex(e,t,n){let o=-1;if(this.node)for(let s=t;s<this.node.childrens.length;s++)if(this.checkObEqual(e,this.node.childrens[s]?.ob,n?[n]:void 0)){o=s;break}return o}renderItem(e,t,n){if(!this.ast.childrens?.length||!this.node)return;let o=this.node.childrens?.[t];if(o){if(this.checkObEqual(e,o.ob,n?[n]:void 0))return void(n&&o.ob[n]!==e[n]&&(o.ob[n]=e[n]));let s=this.findIndexByIndex(e,t+1,n);if(s>-1){if(t+1===s)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();else for(let e=0;e<s-t-1;e++)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();return this.renderItem(e,t,n)}return new pe(this.ast,e,this.node,this.ext).init(t)}return new pe(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let n=this.node.childrens?.[t];i(e,((e,t)=>{n.ob[e]!==t&&(n.ob[e]=t)}))}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[exports.VNode.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,n){let o=!0;return void 0!==t&&(i(e,((e,s)=>{n?.includes(e)||t?.[e]===s||(o=!1)})),o)}}class pe extends ae{parser(e){this.node=new exports.VNode.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class ue extends ae{parser(){if(u(this.ast.cmdName))throw v.error("Template Directive","Error occurred while converting AST to VNode: Directive name not found",this.ast),new Error("Error converting AST to VNode: Directive name not found");let t;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?t=this.ast.param:this.ast.cmdName.startsWith(se+".")?t=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(t=`${e.createFuntionBody(this.ast.cmdName)}(${this.ast.param})`),t){let e=this.runExpressWithWatcher(`[${t}]`,this.ob,(e=>{this.changeValue(e?.[0])}),!1,(()=>this.ast._code));return e||=[],"Html"===this.ast.cmdName?this.node=new exports.VNode.Html(fe(e[0]),this.parent,e[1]):this.node=new exports.VNode.Text(fe(e[0]),this.parent),void this.appendNode()}throw new Error("Command not found: "+this.ast.cmdName)}changeValue(e){this.node&&(this.node instanceof exports.VNode.Html?this.node.html=fe(e):this.node.text=fe(e),this.ext.render?.updateNode(this.node))}}function fe(e){return null==e||"function"==typeof e?"":e.toString()}const me="default";class ye extends ae{parser(){let e=this.transformParam();this.node=new exports.VNode.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach(((e,t)=>{V(this.node.ob,e,this.node.params[t])}))):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,(e=>{let t=e?.[0]||me;if("string"==typeof t&&t!==this.node.id)throw new Error("The section ID cannot be dynamically changed");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach(((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])}))}),!0,(()=>this.ast._code));return{id:e?.[0]||me,params:e?.slice(1)||[]}}return{id:me,params:[]}}}const Ee="Component Parsing";function Ne(e,t){return!!t.components[e]||!!Me(e)}class ge extends ae{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new exports.VNode.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally((()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)}))}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):v.warn(Ee,"Reload operation is not supported for the current component",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,(t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)}),!0,(()=>{if(e.value)return`express:${e.value} \nfrom <${"tagName"in this.ast?this.ast.tagName:"Component"} ${e.name}="${e.value}" ... /> `}));this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(u(e.value)){v.warn(Ee,"The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=T(this.node.propValues)}initEvent(){this.ast.events.forEach((e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:m}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{let o=[];e.functionParam&&(o=this.runExpress(`[${e.functionParam}]`,this.ob,(()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code} \nfrom: <${"tagName"in this.ast?this.ast.tagName:"Component"} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}}))),t.call(this.ext.ob,n,...o)}}]):v.error(Ee,`The callback method (${e.functionName}) specified for the ${e.name} event in the ${"tagName"in this.ast?this.ast.tagName:""} element was not found. Please check.`)}))}async renderChildren(){return new Promise((async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||Me(this.ast.tagName);if(void 0===e)return void v.error(Ee,`Failed to render component. Private or global component named '${this.ast.tagName}' not found.`);if(ke in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let n=this,o=function(){n.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",(()=>{this.node?.component.$off("beforeDestroy",o),e(void 0)})),this.node.component.$on("beforeDestroy",o),this.node.component.$mount(this.node),!this.node)return;let s=this.node?.component;s.isKeepAlive&&(this.ast.node=this.node)}))}getSections(){let t={},n=[];return this.ast.childrens.forEach((t=>{if(t.type===e.AST.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let o=t,s=t.childrens.some((t=>t.type===e.AST.NodeType.COMMAND&&"section"===t.cmdName)),r=o.condition.startsWith(e.EXPRESSHANDLERTAG+".$sections");if(r){return this.runExpress(o.condition,this.ob,(()=>o._code))?void n.push(...t.childrens):void 0}if(s&&"if"===o.kind&&!r)return void v.warn(Ee,"While parsing the section, it was found that this section is wrapped in a conditional statement. This conditional statement only supports if judgments using $sections. It has been excluded.")}n.push(t)})),n.forEach((n=>{if(n.type===e.AST.NodeType.COMMAND&&"section"===n.cmdName){let e=n,o=e.id||me;/^(\'|\")(.*?)((\'|\"))$/.test(o)&&(o=o.slice(1,-1)),t[o]=t[o]||{asts:[],ob:this.ob,params:e.paramKeys,parser:this.ext},t[o].asts.push(...n.childrens||[])}else t[me]=t[me]||{asts:[],ob:this.ob,parser:this.ext},t[me].asts.push(n)})),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0)}}class ve extends ae{parser(){this.node=new exports.VNode.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},n=this.runExpressWithWatcher(e.express,this.ob,(e=>{t(e)}),!1,(()=>{if(e.value)return`express:${e.value} \nfrom <${this.ast.tagName} ${e.name}="${e.value}" ... /> `}));this.node.attributes[e.name]=this.transformAttrVal(n)}else this.node.attributes[e.name]=e.value;else{if(u(e.value)){v.warn("Element","The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`The callback method (${e.functionName}) specified for the ${e.name} event in the ${this.ast.tagName} element was not found. Please check.`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{if(void 0===t)return;let o=[];e.functionParam&&(o=this.runExpress(`[${e.functionParam}]`,this.ob,(()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code}\nfrom <${this.ast.tagName} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}}))),t&&t.call(this.ext.ob,n,...o)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class xe{asts;ob;root=new exports.VNode.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,n){this.asts=e,this.ob=t,this.root.component=t,this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,n&&n instanceof exports.VNode.Node&&(this.root.parent=n,n.childrens??=[],n.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(t,n,o){if(0!==this.asts.length)for(let s of t)if(s.type===e.AST.NodeType.TEXT)new de(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.COMMENT)new he(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.COMPONENT)new ge(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.ELEMENT){let e=s;Ne(e.tagName,o??this.ob)?new ge(e,o??this.ob,n,this).init():new ve(e,o??this.ob,n,this).init()}else if(s.type===e.AST.NodeType.COMMAND){let e=s;switch(e.cmdName){case"if":case"elseif":case"else":new ce(e,o??this.ob,n,this).init();break;case"for":new le(e,o??this.ob,n,this).init();break;case"RenderSection":new ye(e,o??this.ob,n,this).init();break;case"section":break;default:new ue(e,o??this.ob,n,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&l(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){l(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,n,o){this.nodeWatcherEvents[e]?.forEach((e=>{e(t,n,o)}))}sleep(e){let t=e||this.root;t.childrens?.forEach((e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,(()=>{t()}))||t()})),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach((e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")})),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):l(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[exports.VNode.PARSERKEY]&&e[exports.VNode.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,this.asts=e}nodeTransition(e,t,n,o,s){if(e&&e.parent?.childrens&&(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component)){let r=function(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(n??=r?.name,s??=r?.type,!n)return!1;let i=be(e);if(i)return"enter"===t?this.render.elementToEnter(i,n,s,(()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),o?.()})):this.render.elementToLeave(i,n,s,(()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),o?.()})),!0;v.warn("Render Core","Incomplete data found when executing node animation, please check")}return!1}}function be(e){if(e instanceof exports.VNode.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof exports.VNode.Element?t:be(t)}function we(e,t,n){if(void 0===t)return;const o=Array.isArray(n)?n:[n];for(const e of o){if(e===Array&&Array.isArray(t))return t;if(typeof t===e.name.toLowerCase())return t}switch(o[0]){case Number:const e=Number(t);if(!isNaN(e))return e;break;case String:return String(t)}throw new Error(`The type of ${e.toString()} in props does not match the constrained type`)}function Re(e,t,n){let o,s,r;if("symbol"!=typeof t&&(o=f(t)),t in e?s=e[t]:o&&(s=e[o]),n&&(t in n?r=n[t]:o&&o in n&&(r=n[o])),void 0!==r){if(a(r)&&("type"in r||"required"in r||"default"in r||"validate"in r)){const e=r;if(e.required&&void 0===s)throw new Error(`props key:${t.toString()} is required, please check`);if(e.type&&(s=we(t,s,e.type)),e.validate&&!1===e.validate(s))throw new Error(`Validation failed for props key ${t.toString()}`);s=s??e.default}else s=Ae(r)?we(t,s,r):s??r;return s}return s}function Ae(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||!!Array.isArray(e)&&Ae(e[0])}function Ce(e,t){if(!e.constructor)return!1;let n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return n&&n.get}const $e="Component",Oe=Symbol.for("JOKER_PROPS_DATA_KEY"),Se=Symbol.for("JOKER_PROPS_DATA_PROXY"),Te=Symbol.for("JOKER_PRIVATE_WATCHERS"),Ve=Symbol.for("JOKER_EVENT_DATA_KEY"),Pe=Symbol.for("JOKER_IS_DESTROY"),De=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),_e=Symbol.for("JOKER_SCOPE_ID"),ke=Symbol.for("JOKER_COMPONENT_TAG"),Ke=Symbol();let We=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class Ie{$sections;isKeepAlive;static[ke]=!0;[_e];model={};template;$root;isSleeped=!1;components={};propsOption;[Oe]={};[De];[Se];[Te]=[];[Ve]=new Map;[Pe]=!1;[Ke]=!1;constructor(e,t={},n){this.$sections=t,this.isKeepAlive=n,this[Oe]=e||{}}get props(){if(void 0===this[Se]){let e=this;this[Se]=new Proxy(e[Oe],{get:(t,n)=>Re(e[Oe],n,e.propsOption),set(){throw new Error("props parameters are not allowed to be changed, only one-way data transfer is allowed")}})}return this[Se]}$mount(e){if(!1===this[Ke]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach((n=>{!1!==We.includes(n)||Ce(t,n)||"function"!=typeof t[n]||t[n].prototype?.hasOwnProperty("constructor")||e.push(n)})),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[Ke]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[De]&&this.$root?(this[De].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&Ye(this.$rootVNode),this):(v.error($e,"When attempting to wake up the current component, it was found that the rendering handler has been destroyed. The wake-up operation cannot proceed.",[this,this.$root]),this);this.isSleeped=!1,this.model=T(this.model);let t=this.created(),n=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[Pe]||(await this.mounted(),this[Pe]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then((()=>{this[Pe]||n()})):n(),this}$nextUpdatedRender(e){if(this[Pe])return;let t=[...this[De]?.promiseQueue||[]],n=this.$rootVNode?.find((e=>e instanceof exports.VNode.Component));if(n?.forEach((e=>{e?.component&&t.push(...e.component[De]?.promiseQueue||[])})),t.length)return Promise.all(t).finally((()=>{this[Pe]||e?.()}));this[Pe]||e?.()}$nodeTransition(e,t,n,o,s){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void v.error($e,`Node with ref=${e} not found when executing node animation`);e=t}this[De]?.nodeTransition(e,t,n,o,s)}$destroy(e){if(!e&&this.isKeepAlive)return this[De]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&He(this.$rootVNode));this[Pe]=!0;for(let e of this[Te])e.destroy();this[Te].length=0,this[De]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[De]?.destroy(),this[De]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[Ve].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[Se]=void 0,this[Oe]={},this.destroyed()}get $refs(){return this[De]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,n){"function"==typeof t&&(n=t,t=void 0),t??=e,n??=e=>e,this.model[t]=n(this.props[e]),this.$watch((()=>this.props[e]),(()=>{this.model[t]=n?.(this.props[e])}))}get $rootVNode(){return this[De]?.root}$watchNode(e,t){if(this[De])return this[De]?.addNodeWatcher(e,t),()=>{this[De]?.removeNodeWatcher(e,t)};v.warn($e,"Component is not yet mounted. Node observation and monitoring cannot be performed.")}$watch(e,t,n){let o=new I((()=>{if(this[Pe]){for(let e of this[Te])e.destroy();return W}return e()}),((e,n)=>{this[Pe]||t(e,n)}),void 0,n);return this[Te].push(o),[o.value,()=>{o.destroy(),l(this[Te],o)}]}$on(e,t){let n=this[Ve].get(e);void 0===n&&(n=new Set,this[Ve].set(e,n)),!1===n?.has(t)&&n.add(t)}$off(e,t){let n=this[Ve].get(e);n&&(t?n.delete(t):n.clear())}$trigger(e,t,n){if(!this.$root)return;let o={eventName:e,stopPropagation:n?.stopPropagation??(()=>{}),preventDefault:n?.preventDefault??(()=>{}),data:t,target:n?.target??this.$rootVNode,event:n?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof exports.VNode.Component&&!1===this[De]?.render.triggerEvent(this.$rootVNode.parent,e,o))return;let s=this[Ve].get(e);s?.size&&[...s].forEach((e=>{e(o)}));let r=this[Ve].get("*");r?.size&&[...r].forEach((e=>{e(o)}))}$render(t,n){t??=this.template,this.template="function"==typeof t?t(e.RENDER_HANDLER):t,this.$root&&(this.template??=[],this[De]?.reSetAsts(this.template,n),this[De]??=new xe(this.template,this,this.$root),this[De].parser(),this.$root&&this[De].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Le={};function je(e,t){if("string"==typeof e)t&&(Le[e]=t);else for(let t in e)Le[t]=e[t]}function Me(e){return Le[e]}function He(e){e.childrens?.forEach((e=>{e instanceof exports.VNode.Component&&e.component?.sleeped(),He(e)}))}function Ye(e){e.childrens?.forEach((e=>{e instanceof exports.VNode.Component&&e.component?.wakeup(),Ye(e)}))}class Be extends Ie{template=[];cache=new Map;async mounted(){this.$watch((()=>this.props.name),(async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)})),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach((t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch((()=>this.props[t]),(()=>{this.propsVaule[t]=this.props[t]})))})),this.propsVaule=T(e))}filterProps(e){if("string"!=typeof e)return!1;let t=f(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(t){if(!t)return void this.$render([],this.isKeepAlive);let n;if(this.isKeepAlive){let n=this.cache.get(t);if(n)return void this.$render([e.createComponent(n,{"transition-name":this.props["transition-name"]})],!0)}let o=this.$rootVNode?.parent?.[exports.VNode.PARSERKEY]?.ob.components,s=o?.[t];void 0===s&&(s=Me(t)),s?(ke in s||(s=(await s()).default),n=new s(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),n.$on("*",(e=>{this.$trigger(e.eventName,e.data,e)})),this.isKeepAlive&&this.cache.set(t,n),this.$render([e.createComponent(n,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):v.warn("component",`Component ${t} not found`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach((e=>{e.$destroy(!0)})),this.cache.clear()}}class Je extends Ie{template=function(){return[e.createCommand("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}je({template:Je,component:Be});Object.defineProperty(exports,"AST",{enumerable:!0,get:function(){return e.AST}}),Object.defineProperty(exports,"EXPRESSHANDLERTAG",{enumerable:!0,get:function(){return e.EXPRESSHANDLERTAG}}),Object.defineProperty(exports,"RENDER_HANDLER",{enumerable:!0,get:function(){return e.RENDER_HANDLER}}),Object.defineProperty(exports,"createCodeFunction",{enumerable:!0,get:function(){return e.createCodeFunction}}),Object.defineProperty(exports,"createCommand",{enumerable:!0,get:function(){return e.createCommand}}),Object.defineProperty(exports,"createComment",{enumerable:!0,get:function(){return e.createComment}}),Object.defineProperty(exports,"createComponent",{enumerable:!0,get:function(){return e.createComponent}}),Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return e.createElement}}),Object.defineProperty(exports,"createFuntionBody",{enumerable:!0,get:function(){return e.createFuntionBody}}),Object.defineProperty(exports,"createText",{enumerable:!0,get:function(){return e.createText}}),exports.BREAK_WATCH_UPDATE=W,exports.Component=Ie,exports.ComponentContainer=Be,exports.Dep=w,exports.EventBus=class{eventDatas=new Map;on(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const o={callBack:t};return n.push(o),()=>{n&&l(n,o)}}once(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const o={callBack:t,once:!0};return n.push(o),()=>{n&&l(n,o)}}off(e,t){if(void 0!==e)if(t){const n=this.eventDatas.get(e),o=n?.find((e=>e.callBack===t));o&&l(n,o)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let n=[...this.eventDatas.get(e)||[]];if(n.push(...this.eventDatas.get("*")||[]),n&&n.length){let o=0,s=0,r=!1;for(;n[o];){const i=n[o],a=await i.callBack({stopPropagation:()=>r=!0,callTimes:s,eventName:e},t);if(i.once?l(n,i):o++,!1===a||r)return!1}}}},exports.IS_DESTROY=Pe,exports.JOKER_COMPONENT_TAG=ke,exports.JOKER_VNODE_TAG=L,exports.OBJECTPROXY_DEPID=R,exports.PARSER_TEMPLATE_TARGET=De,exports.ParserTemplate=xe,exports.SCOPE_ID=_e,exports.ShallowObserver=class{data;[P]=!0;dep=new w;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(C),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,k(this.dep,C))}},exports.Template=Je,exports.Watcher=I,exports.__GLONAL_FUNTIONS__=oe,exports.__JOKER_HMR_RUNTIME=s,exports.combinedReply=function(e){D=!0;try{e()}catch(e){return D=!1,_.clear(),void v.error("Data Hijacking","Encountered a blocking error while collecting changes for data hijacking composite responses. No action will be taken. Please investigate.",e)}D=!1,function(e){const t=[],n=[];e.forEach(((e,n)=>{e.forEach((e=>{t.push(...n.watchers.get(e)||[])}))})),t.forEach((e=>{n.includes(e)||(!e.isDestroy&&e.update(),n.push(e))}))}(_),_.clear()},exports.defineObserverProperty=V,exports.getGlobalComponent=Me,exports.isObserverData=function(e){return void 0!==S(e)},exports.observer=T,exports.registerGlobalComponent=je,exports.registerGlobalFunction=function(e){for(const t in e)oe[t]=e[t]};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joker.front/core",
3
- "version": "1.3.76",
3
+ "version": "1.3.81",
4
4
  "description": "",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.es.js",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "test": "jest",
23
- "test:temp": "jest test/other/for-update.spec.ts",
23
+ "test:temp": "jest test/parser/html.spec.ts",
24
24
  "build": "joker_build_library --sourcemap=false",
25
25
  "build:prod": "joker_build_library --sourcemap=false --terser",
26
26
  "release": "npm run test && npm run build && joker_release_library",
@@ -38,7 +38,7 @@
38
38
  "url": "git+https://github.com/jokers-pub/front-core.git"
39
39
  },
40
40
  "dependencies": {
41
- "@joker.front/ast": "^1.3.25"
41
+ "@joker.front/ast": "^1.3.30"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@joker.front/library-cli": "^1.2.14",
@@ -24,40 +24,40 @@ export type SectionType = {
24
24
  };
25
25
  type DefaultKeyVal = Record<string | symbol, any>;
26
26
  /**
27
- * Joker组件
27
+ * Joker component
28
28
  */
29
29
  export declare class Component<T extends DefaultKeyVal = {}> implements IComponent {
30
30
  $sections: Record<string, SectionType>;
31
31
  readonly isKeepAlive?: boolean | undefined;
32
32
  static [JOKER_COMPONENT_TAG]: boolean;
33
33
  /**
34
- * scopeId 配合css:Scoped
34
+ * scopeId for css scoping
35
35
  */
36
36
  [SCOPE_ID]?: string;
37
37
  /**
38
- * 可观察数据(具备劫持观察能力)
38
+ * Observable data (with hijacking observation capability)
39
39
  */
40
40
  model: DefaultKeyVal;
41
41
  /**
42
- * 渲染模板
42
+ * Render template
43
43
  */
44
44
  template?: TemplateType;
45
45
  /**
46
- * 挂载根
46
+ * Mount root
47
47
  */
48
48
  $root: any;
49
49
  /**
50
- * 是否已睡眠
50
+ * Whether it is slept
51
51
  */
52
52
  isSleeped: boolean;
53
53
  /**
54
- * 可用的声明组件
54
+ * Available declared components
55
55
  */
56
56
  components: Record<string, ComponentConstructor | ImportComponentConstructor>;
57
57
  /**
58
- * props辅助约束
59
- * @example { name:"默认值",age:Number }
60
- * 可以配置默认值,也可以配置为约束,类型参考PropType
58
+ * Props auxiliary constraints
59
+ * @example { name:"default value", age:Number }
60
+ * Can configure default values or constraints, type reference PropType
61
61
  */
62
62
  propsOption?: Partial<Record<keyof T, PropType | any>>;
63
63
  private [PROPS_DATA_KEY];
@@ -68,136 +68,136 @@ export declare class Component<T extends DefaultKeyVal = {}> implements ICompone
68
68
  private [IS_DESTROY];
69
69
  private [TRANSFORM_FUNCTION_FLAG];
70
70
  /**
71
- * @param propData prop参数
72
- * @param sections 渲染部分区域
73
- * @param isKeepAlive 是否要保持存活,启用时再destroy时只会销毁UI部分,不会销毁数据,直到使用destroy(true)才会销毁
71
+ * @param propData prop parameters
72
+ * @param sections Render partial area
73
+ * @param isKeepAlive Whether to keep alive, when enabled, only the UI part will be destroyed during destroy, and the data will not be destroyed until destroy(true) is used
74
74
  */
75
75
  constructor(propData?: T, $sections?: Record<string, SectionType>, isKeepAlive?: boolean | undefined);
76
76
  /**
77
- * 主动声明接受的参数
77
+ * Actively declare accepted parameters
78
78
  * @returns
79
79
  */
80
80
  get props(): Readonly<T>;
81
81
  /**
82
- * 挂载
82
+ * Mount
83
83
  * @param root
84
84
  */
85
85
  $mount(root: any | VNode.Component): this;
86
86
  $nextUpdatedRender(callBack?: Function): Promise<any[]> | undefined;
87
87
  /**
88
- * 节点动画,仅支持 element及组件节点
88
+ * Node animation, only supports element and component nodes
89
89
  */
90
90
  $nodeTransition(nodeOrRef: string | VNode.Node, mode: "enter" | "leave", name?: string, callBack?: Function, type?: "transition" | "animation"): void;
91
91
  /**
92
- * 销毁
92
+ * Destroy
93
93
  */
94
94
  $destroy(force?: boolean): void;
95
95
  /**
96
- * VNode ref索引集
96
+ * VNode ref index set
97
97
  */
98
98
  get $refs(): Readonly<Record<string, Array<VNode.Node>>>;
99
99
  /**
100
- * 根据ref获取单个VNode
100
+ * Get a single VNode by ref
101
101
  */
102
102
  $getRef<T extends VNode.Node = VNode.Element & VNode.Component>(ref: string): T | undefined;
103
103
  /**
104
- * 获取相同ref的VNode集合
104
+ * Get the VNode collection with the same ref
105
105
  */
106
106
  $getRefs<T extends VNode.Node = VNode.Element & VNode.Component>(ref: string): Array<T> | undefined;
107
107
  /**
108
- * 单向同步prop值,并监听变更后重新同步
109
- * @param propKey 需要观察同步的props key
110
- * @param modelKey 要赋值的model key,不传案prop key 进行赋值
111
- * @param convertVal 值转换方法
108
+ * Unidirectionally synchronize prop values and listen for changes to resynchronize
109
+ * @param propKey The props key to observe and synchronize
110
+ * @param modelKey The model key to assign, if not passed, assign by prop key
111
+ * @param convertVal Value conversion method
112
112
  */
113
113
  $syncProp(propKey: keyof T): void;
114
114
  $syncProp(propKey: keyof T, modelKey: string): void;
115
115
  $syncProp(propKey: keyof T, convertVal: (val: any) => any): void;
116
116
  $syncProp(propKey: keyof T, modelKey: string, convertVal: (val: any) => any): void;
117
117
  /**
118
- * 根节点(虚拟DOM
118
+ * Root node (virtual DOM)
119
119
  */
120
120
  get $rootVNode(): Readonly<VNode.Root> | undefined;
121
121
  /**
122
- * 添加节点变更监听
123
- * @param ref ref标记
122
+ * Add node change listening
123
+ * @param ref ref mark
124
124
  * @param callBack
125
- * @returns 销毁方法
125
+ * @returns Destroy method
126
126
  */
127
127
  $watchNode(ref: string, callBack: (node: VNode.Node, type: NodeChangeType, property?: string) => void): (() => void) | undefined;
128
128
  /**
129
- * 观察值变更
129
+ * Observe value changes
130
130
  * @param express
131
131
  * @param callBack
132
- * @param forceCallBack 即使值相同也要强制触发callback
133
- * @returns [wathcer值, 销毁watcher]
132
+ * @param forceCallBack Force trigger callback even if the value is the same
133
+ * @returns [wathcer value, destroy watcher]
134
134
  */
135
135
  $watch(express: () => any, callBack: (nv?: any, ov?: any) => void, forceCallBack?: boolean): [any, () => void];
136
136
  /**
137
- * 事件注册
137
+ * Event registration
138
138
  * @param eventName
139
139
  * @param callBack
140
140
  */
141
141
  $on(eventName: string, callBack: VNode.EventCallBack): void;
142
142
  /**
143
- * 事件卸载
143
+ * Event unload
144
144
  * @param eventName
145
145
  * @param callBack
146
146
  */
147
147
  $off(eventName: string, callBack?: VNode.EventCallBack): void;
148
148
  /**
149
- * 触发事件
150
- * @param eventName 事件名称
151
- * @param param 参数
149
+ * Trigger event
150
+ * @param eventName Event name
151
+ * @param param Parameters
152
152
  * @param targetEvent event
153
153
  */
154
154
  $trigger(eventName: string, param?: any, targetEvent?: VNode.Event<any>): void;
155
155
  /**
156
- * 主动渲染(仅渲染,一般适用于模板区域的热更新使用/或动态装载等复杂场景)
157
- * @param newTemplate 可指定新的模板,否则按照原模板
158
- * @param keepalive 渲染新模板时,是否要保留之前的存活组件(高级用法)
156
+ * Active rendering (only rendering, generally suitable for complex scenarios such as hot updates of template areas/dynamic loading, etc.)
157
+ * @param newTemplate Can specify a new template, otherwise use the original template
158
+ * @param keepalive When rendering a new template, whether to retain the previous live components (advanced usage)
159
159
  * @returns
160
160
  */
161
161
  $render(newTemplate?: TemplateType, keepalive?: boolean): void;
162
162
  /**
163
- * 生命周期函数(完成初始化)
163
+ * Lifecycle function (initialization completed)
164
164
  */
165
165
  protected created(): void | Promise<void>;
166
166
  /**
167
- * 生命周期函数(完成挂载)
167
+ * Lifecycle function (mounting completed)
168
168
  */
169
169
  protected mounted(): void | Promise<void>;
170
170
  /**
171
- * 生命周期函数(销毁前)
171
+ * Lifecycle function (before destruction)
172
172
  */
173
173
  protected beforeDestroy(): void;
174
174
  /**
175
- * 睡眠时,在启用keepalive属性时才会触发该周期
175
+ * When sleeping, this cycle is only triggered when the keepalive attribute is enabled
176
176
  */
177
177
  protected sleeped(): void;
178
178
  /**
179
- * 唤醒时,在启用keepalive属性时才会触发该周期
179
+ * When waking up, this cycle is only triggered when the keepalive attribute is enabled
180
180
  */
181
181
  protected wakeup(): void;
182
182
  /**
183
- * 生命周期函数(销毁后)
183
+ * Lifecycle function (after destruction)
184
184
  */
185
185
  protected destroyed(): void;
186
186
  }
187
187
  /**
188
- * 注册全局组件
189
- * @param componentsOrName 组件名/列表
190
- * @param component 组件
188
+ * Register global components
189
+ * @param componentsOrName Component name/list
190
+ * @param component Component
191
191
  */
192
192
  export declare function registerGlobalComponent(componentsOrName: Record<string, ComponentConstructor | ImportComponentConstructor> | string, component?: ComponentConstructor | ImportComponentConstructor): void;
193
193
  /**
194
- * 根据注册key获取组件
195
- * @param name 组件名称
196
- * @returns 组件
194
+ * Get component by registration key
195
+ * @param name Component name
196
+ * @returns Component
197
197
  */
198
198
  export declare function getGlobalComponent(key: string): ComponentConstructor | ImportComponentConstructor | undefined;
199
199
  /**
200
- * 动态组件容器
200
+ * Dynamic component container
201
201
  */
202
202
  export declare class ComponentContainer extends Component<{
203
203
  [key: string]: any;
@@ -217,7 +217,7 @@ export declare class ComponentContainer extends Component<{
217
217
  removeCache(componentName?: string): void;
218
218
  }
219
219
  /**
220
- * 虚拟模板容器,用于进行归组,作为组件配置属性
220
+ * Virtual template container, used for grouping, as a component configuration attribute
221
221
  */
222
222
  export declare class Template extends Component {
223
223
  template: () => AST.Command[];
@@ -10,31 +10,30 @@ export type EventCallBackType<T> = (e: {
10
10
  export declare class EventBus<T extends Record<string, any>> {
11
11
  private eventDatas;
12
12
  /**
13
- * 注册事件
14
- * @param eventName
15
- * @param callBack
16
- * @returns 事件销毁
13
+ * Register an event
14
+ * @param eventName Event name
15
+ * @param callBack Callback function
16
+ * @returns Event destruction function
17
17
  */
18
18
  on<K extends keyof T>(eventName: K | "*", callBack: EventCallBackType<T[K]>): () => void;
19
19
  /**
20
- * 注册一次性事件(指触发一次)
21
- * @param eventName
22
- * @param callBack
23
- * @returns 事件销毁
20
+ * Register a one-time event (triggers once)
21
+ * @param eventName Event name
22
+ * @param callBack Callback function
23
+ * @returns Event destruction function
24
24
  */
25
25
  once<K extends keyof T>(eventName: K, callBack: EventCallBackType<T[K]>): () => void;
26
26
  /**
27
- * 销毁事件
28
- * @param eventName
29
- * @param callBack
30
- * @returns
27
+ * Remove event listeners
28
+ * @param eventName Event name (optional)
29
+ * @param callBack Specific callback to remove (optional)
31
30
  */
32
31
  off<K extends keyof T>(eventName?: K, callBack?: EventCallBackType<T[K]>): void;
33
32
  /**
34
- * 触发事件
35
- * @param eventName
36
- * @param param
37
- * @returns
33
+ * Trigger an event
34
+ * @param eventName Event name
35
+ * @param param Event parameter
36
+ * @returns Whether the event was stopped (`false` if stopped)
38
37
  */
39
38
  trigger<K extends keyof T>(eventName: K, param?: T[K]): Promise<false | undefined>;
40
39
  }
package/types/global.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  export type GlobalFunctionType = (...args: any[]) => any;
2
2
  export declare const __GLONAL_FUNTIONS__: Record<string, GlobalFunctionType>;
3
3
  /**
4
- * 注册全局组件
5
- * @param components 组件
4
+ * Register global functions
5
+ * @param functions Object containing function names and implementations
6
6
  */
7
- export declare function registerGlobalFunction(filters: Record<string, GlobalFunctionType>): void;
7
+ export declare function registerGlobalFunction(functions: Record<string, GlobalFunctionType>): void;
8
8
  /**
9
- * 根据注册key获取组件
10
- * @param name 组件名称
11
- * @returns 组件
9
+ * Get a registered global function by key
10
+ * @param key Function name
11
+ * @returns Registered function or undefined if not found
12
12
  */
13
13
  export declare function getGlobalFunction(key: string): GlobalFunctionType | undefined;