@kupola/kupola 2.0.0-beta.6 → 2.0.0-beta.7

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.
@@ -1 +1 @@
1
- "use strict";const t=new Set;let n=!1;function o(o){t.add(o),n||(n=!0,queueMicrotask(e))}function e(){for(n=!1;t.size>0;){const n=[...t];t.clear();for(const t of n)t()}}let s=null;const c=[];function r(t){c.push(s),s=t}function i(){s=c.pop()??null}let u=0;const f=new Set;function l(t){u=t}function a(t){s&&(t.t.add(s),s.o.add(t))}function p(t){for(const n of t.t)n.i?n.u():u>0?f.add(n.u):o(n.u)}class h{constructor(t){this.l=t,this.t=new Set}get value(){return a(this),this.l}set value(t){Object.is(this.l,t)||(this.l=t,p(this))}peek(){return this.l}toString(){return String(this.l)}toJSON(){return JSON.stringify(this.l)}}function d(t){return new h(t)}function y(t){const n={p:t,o:new Set,u:null,h:!1};return n.u=()=>{n.h||g(n)},g(n),()=>function(t){if(t.h)return;t.h=!0,m(t)}(n)}function g(t){m(t),r(t);try{t.p()}finally{i()}}function m(t){for(const n of t.o)n.t.delete(t);t.o.clear()}class k{constructor(t,n){this.strings=t,this.values=n}}function b(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function x(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const S=t=>`຿${t}຿`;function w(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof k?n.push(w(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof k?n.push(e.map(w).join("")):x(e)?n.push(b(e.value)):"function"!=typeof e&&n.push(b(e??""))}return n.join("")}function _(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const e=t.substring(0,o).lastIndexOf("<");if(-1===e)return{type:"text"};if(t.substring(e,o).includes(">"))return{type:"text"};const s=t.substring(e+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!s)return{type:"text"};const c=s[1];return c.startsWith("on")&&c.length>2?{type:"event",attrName:c}:{type:"attr",attrName:c}}class O{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.m=null}mount(){const t=document.createTextNode("");if(this.k?this.container.insertBefore(t,this.k):this.container.appendChild(t),this.node=t,x(this.rawValue)){const t=this.rawValue;this.m=y(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof k?this.node.textContent=w(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.m?.(),this.node?.remove()}}class v{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.m=null}mount(){if(x(this.rawValue)){const t=this.rawValue;this.m=y(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.m?.()}}class j{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.S=null}mount(){"function"==typeof this.handler&&(this.S=t=>this.handler(t),this.element.addEventListener(this.eventName,this.S))}destroy(){this.S&&(this.element.removeEventListener(this.eventName,this.S),this.S=null)}}class N{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function $(t,n){const o=new N,e=function(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof k?n.push(w(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof k?n.push(e.map(w).join("")):"function"==typeof e||x(e)?n.push(S(o)):n.push(b(e??""))}return n.join("")}(t),s=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);o.fragment=s,J(s,t.values,e,o);for(const t of o.parts)t.mount();return n.appendChild(s),o}function J(t,n,o,e){const s=[...t.childNodes];for(const c of s)3===c.nodeType?A(c,n,o,e,t):1===c.nodeType&&M(c,n,o,e)}function A(t,n,o,e,s){const c=t.textContent||"";for(let r=0;r<n.length;r++){const i=S(r),u=c.indexOf(i);if(-1===u)continue;if("text"!==_(o,i).type)continue;const f=c.substring(0,u),l=c.substring(u+i.length);f&&s.insertBefore(document.createTextNode(f),t);const a=new O(s,n[r]);e.parts.push(a);let p=t;return l&&(p=document.createTextNode(l),s.insertBefore(p,t)),s.removeChild(t),a.k=p!==t?p:null,void(l&&A(p,n,o,e,s))}}function M(t,n,o,e){const s=[...t.attributes];for(const c of s)for(let s=0;s<n.length;s++){const r=S(s);if(!c.value.includes(r))continue;const i=_(o,r);if("event"===i.type&&i.attrName===c.name){t.removeAttribute(c.name);const o=new j(t,c.name,n[s]);e.parts.push(o)}else if("attr"===i.type&&i.attrName===c.name){const o=c.value.replace(r,"");o?t.setAttribute(c.name,o):t.removeAttribute(c.name);const i=new v(t,c.name,n[s]);e.parts.push(i)}}J(t,n,o,e)}function C(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof k?n.push(C(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof k?n.push(e.map(t=>C(t)).join("")):x(e)?n.push(b(e.value)):"function"!=typeof e&&n.push(b(e??""))}return n.join("")}function F(t){const n=t.join("");let o=!1,e="",s=-1,c=!1;for(let t=0;t<n.length;t++){const r=n[t];o?r===e&&(o=!1):'"'===r||"'"===r?(o=!0,e=r):"<"===r?(s=t,c=!1):">"===r&&s>=0&&!o&&(c=!0)}return s>=0&&!c}function D(t,n,o,e){const s=[...t.childNodes];for(const c of s)8===c.nodeType?P(c,n,t,o,e):1===c.nodeType&&q(c,n,o,e)}function P(t,n,o,e,s){const c=s.indices[s.nextIdx++]??-1,r=t.previousSibling;let i;if(r&&3===r.nodeType?i=r:(i=document.createTextNode(""),o.insertBefore(i,t)),c>=0&&c<n.length){const t=n[c];if(x(t)){const n=y(()=>{i.textContent=null!=t.value?String(t.value):""});e.parts.push({destroy(){n(),i.remove()}})}else i.textContent=null!=t?String(t):""}o.removeChild(t)}function q(t,n,o,e){const s=t.getAttribute("data-kp");if(s){const e=s.split(",");for(const s of e){const e=s.indexOf(":"),c=s.indexOf(":",e+1),r=parseInt(s.substring(0,e),10),i=s.substring(e+1,c),u=s.substring(c+1);if(r>=0&&r<n.length)if("e"===i){const e=new j(t,u,n[r]);e.mount(),o.parts.push(e)}else if("a"===i){const e=new v(t,u,n[r]);e.mount(),o.parts.push(e)}}t.removeAttribute("data-kp")}D(t,n,o,e)}const I=new Map;function K(t){const n={};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=d(t[o]));const o=Object.keys(n);return new Proxy({},{get(t,o){if("symbol"==typeof o)return;const e=n[o];return e?e.value:void 0},set(t,e,s){const c=n[e];return c?c.value=s:(n[e]=d(s),o.push(e)),!0},has:(t,o)=>o in n,ownKeys:()=>o,getOwnPropertyDescriptor(t,o){if(o in n)return{enumerable:!0,configurable:!0}}})}const T=new Map;function U(t,n){let o=T.get(t);return o||(o=new Function("__s__",`with(__s__){return(${t})}`),T.set(t,o)),o(n)}function z(t){const n=t.split("."),o=n[0],e=n.slice(1),s=o.indexOf(":");return-1===s?{base:o,arg:null,modifiers:e}:{base:o.substring(0,s),arg:o.substring(s+1),modifiers:e}}function B(t,n,o,e){const s=y(()=>{const e=U(n,o);t.style.display=e?"":"none"});e.push(s)}function E(t,n,o,e){const s=y(()=>{t.textContent=String(U(n,o)??"")});e.push(s)}function W(t,n,o,e){const s=y(()=>{t.innerHTML=String(U(n,o)??"")});e.push(s)}function G(t,n,o,e,s){const c=y(()=>{const s=U(n,e);!1===s||null==s?t.removeAttribute(o):!0===s?t.setAttribute(o,""):t.setAttribute(o,String(s))});s.push(c)}function H(t,n,o,s,c,r){const i=s.includes("stop"),u=s.includes("prevent"),f=s.includes("once"),l=s.includes("self"),a=o=>{l&&o.target!==t||(i&&o.stopPropagation(),u&&o.preventDefault(),function(t,n){const o="$$"+t;let e=T.get(o);e||(e=new Function("__s__",`with(__s__){${t}}`),T.set(o,e)),e(n)}(n,c),e())};t.addEventListener(o,a,{once:f}),r.push(()=>t.removeEventListener(o,a))}function L(t,n,o,s){const c=y(()=>{const e=U(n,o);t.value=null!=e?String(e):""});s.push(c);const r=()=>{const s=n.trim().split(".");if(1===s.length)o[s[0]]=t.value;else{const e=s.slice(0,-1).join("."),c=s[s.length-1];try{const n=U(e,o);n&&"object"==typeof n&&(n[c]=t.value)}catch(e){o[n]=t.value}}e()};t.addEventListener("input",r),s.push(()=>t.removeEventListener("input",r))}function Q(t){return t.startsWith("k-")||t.startsWith(":")||t.startsWith("@")}function R(t){return t.startsWith(":")?"k-bind:"+t.substring(1):t.startsWith("@")?"k-on:"+t.substring(1):t}function V(t,n,o){const e=[...t.attributes];for(const s of e){const e=s.name,c=s.value;if(!Q(e))continue;const r=R(e),{base:i,arg:u,modifiers:f}=z(r);switch(i){case"k-show":B(t,c,n,o);break;case"k-text":E(t,c,n,o);break;case"k-html":W(t,c,n,o);break;case"k-bind":u&&G(t,c,u,n,o);break;case"k-on":u&&H(t,c,u,f,n,o);break;case"k-model":L(t,c,n,o)}}}function X(t,n,o){for(const e of t.children)e.hasAttribute("k-data")||(V(e,n,o),X(e,n,o))}function Y(t,n){const o=t.getAttribute("k-data");let e={};try{e=U(o,K({}))||{}}catch(t){}const s=K(e);V(t,s,n),X(t,s,n);for(const o of t.children)o.hasAttribute("k-data")&&Y(o,n)}const Z={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};let tt="en-US";exports.ErrorBoundary=function(t,n={}){const{fallback:o=null,onError:e=null}=n;try{return t()}catch(t){if(e)try{e(t)}catch(t){}const n=document.createDocumentFragment();if(o)try{const e="function"==typeof o?o(t):o;if("string"==typeof e){const t=document.createElement("div");t.className="ds-error-boundary",t.textContent=e,n.appendChild(t)}else $(e,n)}catch(o){const e=document.createElement("div");e.className="ds-error-boundary",e.textContent=`Component error: ${t.message}`,n.appendChild(e)}else{const o=document.createElement("div");o.className="ds-error-boundary",o.textContent=`Component error: ${t.message}`,n.appendChild(o)}return{element:n,error:t}}},exports.Signal=h,exports.TemplateResult=k,exports.addMessages=function(t,n){Z[t]||(Z[t]={}),Object.assign(Z[t],n)},exports.batch=function(t){l(u+1);try{return t()}finally{if(l(u-1),0===u){const t=f,n=[...t];t.clear();for(const t of n)t();e()}}},exports.clearRegistry=function(){I.clear()},exports.computed=function(t){const n=new h(void 0);let o=!0,e=new Set;const s={p:null,o:e,i:!0,u:null,h:!1};function c(){for(const t of e)t.t.delete(s);e.clear(),s.o=e,r(s);try{const o=t();Object.is(n.l,o)||(n.l=o)}finally{i()}o=!1}return s.u=()=>{o||(o=!0,p(n))},{get value(){return o&&c(),a(n),n.l},peek:()=>(o&&c(),n.l),toString(){return String(this.value)},toJSON(){return JSON.stringify(this.value)}}},exports.defineComponent=function(t){const{props:n=[],setup:o}=t;function e(t={},e=null){const s={};for(const o of n)s[o]=d(t[o]);const c=o(s,e)(),r=document.createDocumentFragment(),i=$(c,r);return{get element(){return r},_:i,destroy(){i.destroy()},update(t){for(const o of n)o in t&&s[o]&&(s[o].value=t[o])}}}return e.O=!0,e.v=n,e},exports.effect=y,exports.flushJobs=e,exports.getComponent=function(t){return I.get(t)},exports.getLocale=function(){return tt},exports.hasComponent=function(t){return I.has(t)},exports.html=function(t,...n){return new k(t,n)},exports.hydrate=function(t,n){const o=new N,e=function(t){const n=[],o=[];let e=!1;for(let s=0;s<t.strings.length;s++)if(o.push(t.strings[s]),e=F(o),s<t.values.length){const c=t.values[s];if(c instanceof k)o.push(C(c));else if(Array.isArray(c)&&c.length>0&&c[0]instanceof k)o.push(c.map(t=>C(t)).join(""));else if("function"==typeof c);else if(x(c))if(e){const t=c.value;o.push(null!=t?b(t):"")}else{n.push(s);const t=c.value;o.push(null!=t?b(t):"")}else o.push(b(c??""))}return{indices:n,nextIdx:0}}(t);return D(n,t.values,o,e),o},exports.register=function(t,n){I.set(t,n)},exports.render=$,exports.resetScheduler=function(){t.clear(),n=!1},exports.setLocale=function(t){tt=t},exports.signal=d,exports.t=function(t,n={}){let o=(Z[tt]||Z["en-US"])[t]||t;for(const[t,e]of Object.entries(n))o=o.replace(`{${t}}`,e);return o},exports.walk=function(t){const n=[];if(t.hasAttribute&&t.hasAttribute("k-data"))Y(t,n);else{const o=t.querySelectorAll?t.querySelectorAll("[k-data]"):[];if(o.length>0)for(const e of o){let o=!1,s=e.parentElement;for(;s&&s!==t;){if(s.hasAttribute("k-data")){o=!0;break}s=s.parentElement}o||Y(e,n)}else{const o=K({});for(const e of t.children)V(e,o,n),X(e,o,n)}}return{destroy(){for(const t of n)t();n.length=0}}};
1
+ "use strict";const t=new Set;let n=!1;function o(o){t.add(o),n||(n=!0,queueMicrotask(e))}function e(){for(n=!1;t.size>0;){const n=[...t];t.clear();for(const t of n)t()}}let s=!1,r=0;const c=new Map,i=new Map,f=new Map;let u=0,l=0,a=0,p=0,h=0;const d=new WeakMap;function m(t,n){return d.has(t)?d.get(t):(d.set(t,n),n)}function y(){return s}function g(){const t=r>0?performance.now()-r:0,n=[];for(const[,t]of c)n.push({label:t.label,reads:t.reads,writes:t.writes,triggers:t.triggers});const o=[];for(const[,t]of i){const n=t.runs>0?t.totalTime/t.runs:0;o.push({label:t.label,runs:t.runs,totalTime:t.totalTime.toFixed(2)+"ms",maxTime:t.maxTime.toFixed(3)+"ms",avgTime:n.toFixed(3)+"ms"})}const e=[];for(const[,t]of f){const n=t.recomputes>0?t.totalTime/t.recomputes:0;e.push({label:t.label,recomputes:t.recomputes,totalTime:t.totalTime.toFixed(2)+"ms",maxTime:t.maxTime.toFixed(3)+"ms",avgTime:n.toFixed(3)+"ms"})}return{duration:Math.round(t),totalTriggers:a,totalEffectRuns:p,totalComputedRecomputes:h,signals:n,effects:o,computeds:e}}let w=null;const b=[];function x(t){b.push(w),w=t}function k(){w=b.pop()??null}let S=0;const _=new Set;function v(t){S=t}function O(t){w&&(t.t.add(w),w.o.add(t))}function j(t){for(const n of t.t)n.i?n.u():S>0?_.add(n.u):o(n.u)}class T{constructor(t){this.l=t,this.t=new Set}get value(){return O(this),y()&&function(t){if(!s)return;const n=m(t,u);c.has(n)||(c.set(n,{reads:0,writes:0,triggers:0,label:`signal#${n}`}),n>=u&&(u=n+1)),c.get(n).reads++}(this),this.l}set value(t){Object.is(this.l,t)||(this.l=t,y()&&function(t){if(!s)return;const n=m(t,u);c.has(n)||(c.set(n,{reads:0,writes:0,triggers:0,label:`signal#${n}`}),n>=u&&(u=n+1)),c.get(n).writes++}(this),j(this))}peek(){return this.l}toString(){return String(this.l)}toJSON(){return JSON.stringify(this.l)}}function $(t){return new T(t)}function M(t){const n={p:t,o:new Set,u:null,h:!1};return n.u=()=>{n.h||N(n)},N(n),()=>function(t){if(t.h)return;t.h=!0,A(t)}(n)}function N(t){A(t),x(t);try{y()?function(t,n){if(!s)return n();const o=m(t,l);i.has(o)||(i.set(o,{runs:0,totalTime:0,maxTime:0,label:`effect#${o}`}),o>=l&&(l=o+1));const e=i.get(o),r=performance.now(),c=n(),f=performance.now()-r;e.runs++,e.totalTime+=f,f>e.maxTime&&(e.maxTime=f),p++}(t,t.p):t.p()}finally{k()}}function A(t){for(const n of t.o)n.t.delete(t);t.o.clear()}class C{constructor(t,n){this.strings=t,this.values=n}}function J(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function z(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const E=t=>`຿${t}຿`;function F(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof C?n.push(F(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof C?n.push(e.map(F).join("")):z(e)?n.push(J(e.value)):"function"!=typeof e&&n.push(J(e??""))}return n.join("")}function K(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const e=t.substring(0,o).lastIndexOf("<");if(-1===e)return{type:"text"};if(t.substring(e,o).includes(">"))return{type:"text"};const s=t.substring(e+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!s)return{type:"text"};const r=s[1];return r.startsWith("on")&&r.length>2?{type:"event",attrName:r}:{type:"attr",attrName:r}}class D{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.m=null}mount(){const t=document.createTextNode("");if(this.k?this.container.insertBefore(t,this.k):this.container.appendChild(t),this.node=t,z(this.rawValue)){const t=this.rawValue;this.m=M(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof C?this.node.textContent=F(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.m?.(),this.node?.remove()}}class P{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.m=null}mount(){if(z(this.rawValue)){const t=this.rawValue;this.m=M(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.m?.()}}class q{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.S=null}mount(){"function"==typeof this.handler&&(this.S=t=>this.handler(t),this.element.addEventListener(this.eventName,this.S))}destroy(){this.S&&(this.element.removeEventListener(this.eventName,this.S),this.S=null)}}class I{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function R(t,n){const o=new I,e=function(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof C?n.push(F(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof C?n.push(e.map(F).join("")):"function"==typeof e||z(e)?n.push(E(o)):n.push(J(e??""))}return n.join("")}(t),s=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);o.fragment=s,U(s,t.values,e,o);for(const t of o.parts)t.mount();return n.appendChild(s),o}function U(t,n,o,e){const s=[...t.childNodes];for(const r of s)3===r.nodeType?W(r,n,o,e,t):1===r.nodeType&&B(r,n,o,e)}function W(t,n,o,e,s){const r=t.textContent||"";for(let c=0;c<n.length;c++){const i=E(c),f=r.indexOf(i);if(-1===f)continue;if("text"!==K(o,i).type)continue;const u=r.substring(0,f),l=r.substring(f+i.length);u&&s.insertBefore(document.createTextNode(u),t);const a=new D(s,n[c]);e.parts.push(a);let p=t;return l&&(p=document.createTextNode(l),s.insertBefore(p,t)),s.removeChild(t),a.k=p!==t?p:null,void(l&&W(p,n,o,e,s))}}function B(t,n,o,e){const s=[...t.attributes];for(const r of s)for(let s=0;s<n.length;s++){const c=E(s);if(!r.value.includes(c))continue;const i=K(o,c);if("event"===i.type&&i.attrName===r.name){t.removeAttribute(r.name);const o=new q(t,r.name,n[s]);e.parts.push(o)}else if("attr"===i.type&&i.attrName===r.name){const o=r.value.replace(c,"");o?t.setAttribute(r.name,o):t.removeAttribute(r.name);const i=new P(t,r.name,n[s]);e.parts.push(i)}}U(t,n,o,e)}function G(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof C?n.push(G(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof C?n.push(e.map(t=>G(t)).join("")):z(e)?n.push(J(e.value)):"function"!=typeof e&&n.push(J(e??""))}return n.join("")}function H(t){const n=t.join("");let o=!1,e="",s=-1,r=!1;for(let t=0;t<n.length;t++){const c=n[t];o?c===e&&(o=!1):'"'===c||"'"===c?(o=!0,e=c):"<"===c?(s=t,r=!1):">"===c&&s>=0&&!o&&(r=!0)}return s>=0&&!r}function L(t,n,o,e){const s=[...t.childNodes];for(const r of s)8===r.nodeType?Q(r,n,t,o,e):1===r.nodeType&&V(r,n,o,e)}function Q(t,n,o,e,s){const r=s.indices[s.nextIdx++]??-1,c=t.previousSibling;let i;if(c&&3===c.nodeType?i=c:(i=document.createTextNode(""),o.insertBefore(i,t)),r>=0&&r<n.length){const t=n[r];if(z(t)){const n=M(()=>{i.textContent=null!=t.value?String(t.value):""});e.parts.push({destroy(){n(),i.remove()}})}else i.textContent=null!=t?String(t):""}o.removeChild(t)}function V(t,n,o,e){const s=t.getAttribute("data-kp");if(s){const e=s.split(",");for(const s of e){const e=s.indexOf(":"),r=s.indexOf(":",e+1),c=parseInt(s.substring(0,e),10),i=s.substring(e+1,r),f=s.substring(r+1);if(c>=0&&c<n.length)if("e"===i){const e=new q(t,f,n[c]);e.mount(),o.parts.push(e)}else if("a"===i){const e=new P(t,f,n[c]);e.mount(),o.parts.push(e)}}t.removeAttribute("data-kp")}L(t,n,o,e)}const X=new Map;function Y(t){const n={};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=$(t[o]));const o=Object.keys(n);return new Proxy({},{get(t,o){if("symbol"==typeof o)return;const e=n[o];return e?e.value:void 0},set(t,e,s){const r=n[e];return r?r.value=s:(n[e]=$(s),o.push(e)),!0},has:(t,o)=>o in n,ownKeys:()=>o,getOwnPropertyDescriptor(t,o){if(o in n)return{enumerable:!0,configurable:!0}}})}const Z=new Map;function tt(t,n){let o=Z.get(t);return o||(o=new Function("__s__",`with(__s__){return(${t})}`),Z.set(t,o)),o(n)}function nt(t){const n=t.split("."),o=n[0],e=n.slice(1),s=o.indexOf(":");return-1===s?{base:o,arg:null,modifiers:e}:{base:o.substring(0,s),arg:o.substring(s+1),modifiers:e}}function ot(t,n,o,e){const s=M(()=>{const e=tt(n,o);t.style.display=e?"":"none"});e.push(s)}function et(t,n,o,e){const s=M(()=>{t.textContent=String(tt(n,o)??"")});e.push(s)}function st(t,n,o,e){const s=M(()=>{t.innerHTML=String(tt(n,o)??"")});e.push(s)}function rt(t,n,o,e,s){const r=M(()=>{const s=tt(n,e);!1===s||null==s?t.removeAttribute(o):!0===s?t.setAttribute(o,""):t.setAttribute(o,String(s))});s.push(r)}function ct(t,n,o,s,r,c){const i=s.includes("stop"),f=s.includes("prevent"),u=s.includes("once"),l=s.includes("self"),a=o=>{l&&o.target!==t||(i&&o.stopPropagation(),f&&o.preventDefault(),function(t,n){const o="$$"+t;let e=Z.get(o);e||(e=new Function("__s__",`with(__s__){${t}}`),Z.set(o,e)),e(n)}(n,r),e())};t.addEventListener(o,a,{once:u}),c.push(()=>t.removeEventListener(o,a))}function it(t,n,o,s){const r=M(()=>{const e=tt(n,o);t.value=null!=e?String(e):""});s.push(r);const c=()=>{const s=n.trim().split(".");if(1===s.length)o[s[0]]=t.value;else{const e=s.slice(0,-1).join("."),r=s[s.length-1];try{const n=tt(e,o);n&&"object"==typeof n&&(n[r]=t.value)}catch(e){o[n]=t.value}}e()};t.addEventListener("input",c),s.push(()=>t.removeEventListener("input",c))}function ft(t){return t.startsWith("k-")||t.startsWith(":")||t.startsWith("@")}function ut(t){return t.startsWith(":")?"k-bind:"+t.substring(1):t.startsWith("@")?"k-on:"+t.substring(1):t}function lt(t,n,o){const e=[...t.attributes];for(const s of e){const e=s.name,r=s.value;if(!ft(e))continue;const c=ut(e),{base:i,arg:f,modifiers:u}=nt(c);switch(i){case"k-show":ot(t,r,n,o);break;case"k-text":et(t,r,n,o);break;case"k-html":st(t,r,n,o);break;case"k-bind":f&&rt(t,r,f,n,o);break;case"k-on":f&&ct(t,r,f,u,n,o);break;case"k-model":it(t,r,n,o)}}}function at(t,n,o){for(const e of t.children)e.hasAttribute("k-data")||(lt(e,n,o),at(e,n,o))}function pt(t,n){const o=t.getAttribute("k-data");let e={};try{e=tt(o,Y({}))||{}}catch(t){}const s=Y(e);lt(t,s,n),at(t,s,n);for(const o of t.children)o.hasAttribute("k-data")&&pt(o,n)}const ht={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};let dt="en-US";exports.ErrorBoundary=function(t,n={}){const{fallback:o=null,onError:e=null}=n;try{return t()}catch(t){if(e)try{e(t)}catch(t){}const n=document.createDocumentFragment();if(o)try{const e="function"==typeof o?o(t):o;if("string"==typeof e){const t=document.createElement("div");t.className="ds-error-boundary",t.textContent=e,n.appendChild(t)}else R(e,n)}catch(o){const e=document.createElement("div");e.className="ds-error-boundary",e.textContent=`Component error: ${t.message}`,n.appendChild(e)}else{const o=document.createElement("div");o.className="ds-error-boundary",o.textContent=`Component error: ${t.message}`,n.appendChild(o)}return{element:n,error:t}}},exports.Signal=T,exports.TemplateResult=C,exports.addMessages=function(t,n){ht[t]||(ht[t]={}),Object.assign(ht[t],n)},exports.batch=function(t){v(S+1);try{return t()}finally{if(v(S-1),0===S){const t=_,n=[...t];t.clear();for(const t of n)t();e()}}},exports.clearRegistry=function(){X.clear()},exports.computed=function(t){const n=new T(void 0);let o=!0,e=new Set;const s={p:null,o:e,i:!0,u:null,h:!1};function r(){for(const t of e)t.t.delete(s);e.clear(),s.o=e,x(s);try{const o=t();Object.is(n.l,o)||(n.l=o)}finally{k()}o=!1}return s.u=()=>{o||(o=!0,j(n))},{get value(){return o&&r(),O(n),n.l},peek:()=>(o&&r(),n.l),toString(){return String(this.value)},toJSON(){return JSON.stringify(this.value)}}},exports.defineComponent=function(t){const{props:n=[],setup:o}=t;function e(t={},e=null){const s={};for(const o of n)s[o]=$(t[o]);const r=o(s,e)(),c=document.createDocumentFragment(),i=R(r,c);return{get element(){return c},_:i,destroy(){i.destroy()},update(t){for(const o of n)o in t&&s[o]&&(s[o].value=t[o])}}}return e.v=!0,e.O=n,e},exports.disableProfiler=function(){s=!1},exports.effect=M,exports.enableProfiler=function(t={}){s=!0,r=performance.now(),c.clear(),i.clear(),f.clear(),u=0,l=0,a=0,p=0,h=0,t.console},exports.flushJobs=e,exports.getComponent=function(t){return X.get(t)},exports.getLocale=function(){return dt},exports.getProfileReport=g,exports.hasComponent=function(t){return X.has(t)},exports.html=function(t,...n){return new C(t,n)},exports.hydrate=function(t,n){const o=new I,e=function(t){const n=[],o=[];let e=!1;for(let s=0;s<t.strings.length;s++)if(o.push(t.strings[s]),e=H(o),s<t.values.length){const r=t.values[s];if(r instanceof C)o.push(G(r));else if(Array.isArray(r)&&r.length>0&&r[0]instanceof C)o.push(r.map(t=>G(t)).join(""));else if("function"==typeof r);else if(z(r))if(e){const t=r.value;o.push(null!=t?J(t):"")}else{n.push(s);const t=r.value;o.push(null!=t?J(t):"")}else o.push(J(r??""))}return{indices:n,nextIdx:0}}(t);return L(n,t.values,o,e),o},exports.lazyComponent=function(t,n="default"){let o=null,e=null;async function s(){return o||(e||(e=t().then(t=>{if("function"==typeof t.default)o=t.default;else if("default"!==n&&"function"==typeof t[n])o=t[n];else{const n=Object.keys(t);for(const e of n)if("function"==typeof t[e]){o=t[e];break}}if(!o)throw new Error("[Kupola lazy] No component factory found in module");return e=null,o}),e))}async function r(...t){return(await s())(...t)}return r.j=t,r.T=()=>null!==o,r.$=s,r},exports.preloadComponent=async function(t){if("function"!=typeof t.$)throw new TypeError("[Kupola preload] Argument must be a lazy component from lazyComponent()");await t.$()},exports.printProfileReport=function(){const t=g();t.signals.length,t.effects.length,t.computeds.length},exports.register=function(t,n){X.set(t,n)},exports.render=R,exports.resetProfiler=function(){s=!1,r=0,c.clear(),i.clear(),f.clear(),a=0,p=0,h=0},exports.resetScheduler=function(){t.clear(),n=!1},exports.setLocale=function(t){dt=t},exports.signal=$,exports.t=function(t,n={}){let o=(ht[dt]||ht["en-US"])[t]||t;for(const[t,e]of Object.entries(n))o=o.replace(`{${t}}`,e);return o},exports.walk=function(t){const n=[];if(t.hasAttribute&&t.hasAttribute("k-data"))pt(t,n);else{const o=t.querySelectorAll?t.querySelectorAll("[k-data]"):[];if(o.length>0)for(const e of o){let o=!1,s=e.parentElement;for(;s&&s!==t;){if(s.hasAttribute("k-data")){o=!0;break}s=s.parentElement}o||pt(e,n)}else{const o=Y({});for(const e of t.children)lt(e,o,n),at(e,o,n)}}return{destroy(){for(const t of n)t();n.length=0}}};
@@ -1 +1 @@
1
- const t=new Set;let n=!1;function o(o){t.add(o),n||(n=!0,queueMicrotask(e))}function e(){for(n=!1;t.size>0;){const n=[...t];t.clear();for(const t of n)t()}}function c(){t.clear(),n=!1}let s=null;const i=[];function r(t){i.push(s),s=t}function f(){s=i.pop()??null}let u=0;const l=new Set;function a(t){u=t}function h(t){s&&(t.t.add(s),s.o.add(t))}function d(t){for(const n of t.t)n.i?n.u():u>0?l.add(n.u):o(n.u)}class p{constructor(t){this.l=t,this.t=new Set}get value(){return h(this),this.l}set value(t){Object.is(this.l,t)||(this.l=t,d(this))}peek(){return this.l}toString(){return String(this.l)}toJSON(){return JSON.stringify(this.l)}}function y(t){return new p(t)}function g(t){const n=new p(void 0);let o=!0,e=new Set;const c={h:null,o:e,i:!0,u:null,p:!1};function s(){for(const t of e)t.t.delete(c);e.clear(),c.o=e,r(c);try{const o=t();Object.is(n.l,o)||(n.l=o)}finally{f()}o=!1}return c.u=()=>{o||(o=!0,d(n))},{get value(){return o&&s(),h(n),n.l},peek:()=>(o&&s(),n.l),toString(){return String(this.value)},toJSON(){return JSON.stringify(this.value)}}}function m(t){const n={h:t,o:new Set,u:null,p:!1};return n.u=()=>{n.p||k(n)},k(n),()=>function(t){if(t.p)return;t.p=!0,b(t)}(n)}function k(t){b(t),r(t);try{t.h()}finally{f()}}function b(t){for(const n of t.o)n.t.delete(t);t.o.clear()}function S(t){a(u+1);try{return t()}finally{if(a(u-1),0===u){const t=l,n=[...t];t.clear();for(const t of n)t();e()}}}class w{constructor(t,n){this.strings=t,this.values=n}}function _(t,...n){return new w(t,n)}function O(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function v(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const x=t=>`຿${t}຿`;function j(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof w?n.push(j(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof w?n.push(e.map(j).join("")):v(e)?n.push(O(e.value)):"function"!=typeof e&&n.push(O(e??""))}return n.join("")}function N(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const e=t.substring(0,o).lastIndexOf("<");if(-1===e)return{type:"text"};if(t.substring(e,o).includes(">"))return{type:"text"};const c=t.substring(e+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!c)return{type:"text"};const s=c[1];return s.startsWith("on")&&s.length>2?{type:"event",attrName:s}:{type:"attr",attrName:s}}class ${constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.m=null}mount(){const t=document.createTextNode("");if(this.k?this.container.insertBefore(t,this.k):this.container.appendChild(t),this.node=t,v(this.rawValue)){const t=this.rawValue;this.m=m(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof w?this.node.textContent=j(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.m?.(),this.node?.remove()}}class J{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.m=null}mount(){if(v(this.rawValue)){const t=this.rawValue;this.m=m(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.m?.()}}class A{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.S=null}mount(){"function"==typeof this.handler&&(this.S=t=>this.handler(t),this.element.addEventListener(this.eventName,this.S))}destroy(){this.S&&(this.element.removeEventListener(this.eventName,this.S),this.S=null)}}class M{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function C(t,n){const o=new M,e=function(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof w?n.push(j(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof w?n.push(e.map(j).join("")):"function"==typeof e||v(e)?n.push(x(o)):n.push(O(e??""))}return n.join("")}(t),c=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);o.fragment=c,F(c,t.values,e,o);for(const t of o.parts)t.mount();return n.appendChild(c),o}function F(t,n,o,e){const c=[...t.childNodes];for(const s of c)3===s.nodeType?D(s,n,o,e,t):1===s.nodeType&&P(s,n,o,e)}function D(t,n,o,e,c){const s=t.textContent||"";for(let i=0;i<n.length;i++){const r=x(i),f=s.indexOf(r);if(-1===f)continue;if("text"!==N(o,r).type)continue;const u=s.substring(0,f),l=s.substring(f+r.length);u&&c.insertBefore(document.createTextNode(u),t);const a=new $(c,n[i]);e.parts.push(a);let h=t;return l&&(h=document.createTextNode(l),c.insertBefore(h,t)),c.removeChild(t),a.k=h!==t?h:null,void(l&&D(h,n,o,e,c))}}function P(t,n,o,e){const c=[...t.attributes];for(const s of c)for(let c=0;c<n.length;c++){const i=x(c);if(!s.value.includes(i))continue;const r=N(o,i);if("event"===r.type&&r.attrName===s.name){t.removeAttribute(s.name);const o=new A(t,s.name,n[c]);e.parts.push(o)}else if("attr"===r.type&&r.attrName===s.name){const o=s.value.replace(i,"");o?t.setAttribute(s.name,o):t.removeAttribute(s.name);const r=new J(t,s.name,n[c]);e.parts.push(r)}}F(t,n,o,e)}function q(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof w?n.push(q(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof w?n.push(e.map(t=>q(t)).join("")):v(e)?n.push(O(e.value)):"function"!=typeof e&&n.push(O(e??""))}return n.join("")}function I(t){const n=t.join("");let o=!1,e="",c=-1,s=!1;for(let t=0;t<n.length;t++){const i=n[t];o?i===e&&(o=!1):'"'===i||"'"===i?(o=!0,e=i):"<"===i?(c=t,s=!1):">"===i&&c>=0&&!o&&(s=!0)}return c>=0&&!s}function K(t,n){const o=new M,e=function(t){const n=[],o=[];let e=!1;for(let c=0;c<t.strings.length;c++)if(o.push(t.strings[c]),e=I(o),c<t.values.length){const s=t.values[c];if(s instanceof w)o.push(q(s));else if(Array.isArray(s)&&s.length>0&&s[0]instanceof w)o.push(s.map(t=>q(t)).join(""));else if("function"==typeof s);else if(v(s))if(e){const t=s.value;o.push(null!=t?O(t):"")}else{n.push(c);const t=s.value;o.push(null!=t?O(t):"")}else o.push(O(s??""))}return{indices:n,nextIdx:0}}(t);return T(n,t.values,o,e),o}function T(t,n,o,e){const c=[...t.childNodes];for(const s of c)8===s.nodeType?U(s,n,t,o,e):1===s.nodeType&&z(s,n,o,e)}function U(t,n,o,e,c){const s=c.indices[c.nextIdx++]??-1,i=t.previousSibling;let r;if(i&&3===i.nodeType?r=i:(r=document.createTextNode(""),o.insertBefore(r,t)),s>=0&&s<n.length){const t=n[s];if(v(t)){const n=m(()=>{r.textContent=null!=t.value?String(t.value):""});e.parts.push({destroy(){n(),r.remove()}})}else r.textContent=null!=t?String(t):""}o.removeChild(t)}function z(t,n,o,e){const c=t.getAttribute("data-kp");if(c){const e=c.split(",");for(const c of e){const e=c.indexOf(":"),s=c.indexOf(":",e+1),i=parseInt(c.substring(0,e),10),r=c.substring(e+1,s),f=c.substring(s+1);if(i>=0&&i<n.length)if("e"===r){const e=new A(t,f,n[i]);e.mount(),o.parts.push(e)}else if("a"===r){const e=new J(t,f,n[i]);e.mount(),o.parts.push(e)}}t.removeAttribute("data-kp")}T(t,n,o,e)}function B(t){const{props:n=[],setup:o}=t;function e(t={},e=null){const c={};for(const o of n)c[o]=y(t[o]);const s=o(c,e)(),i=document.createDocumentFragment(),r=C(s,i);return{get element(){return i},_:r,destroy(){r.destroy()},update(t){for(const o of n)o in t&&c[o]&&(c[o].value=t[o])}}}return e.O=!0,e.v=n,e}const E=new Map;function W(t,n){E.set(t,n)}function G(t){return E.get(t)}function H(t){return E.has(t)}function L(){E.clear()}function Q(t){const n={};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=y(t[o]));const o=Object.keys(n);return new Proxy({},{get(t,o){if("symbol"==typeof o)return;const e=n[o];return e?e.value:void 0},set(t,e,c){const s=n[e];return s?s.value=c:(n[e]=y(c),o.push(e)),!0},has:(t,o)=>o in n,ownKeys:()=>o,getOwnPropertyDescriptor(t,o){if(o in n)return{enumerable:!0,configurable:!0}}})}const R=new Map;function V(t,n){let o=R.get(t);return o||(o=new Function("__s__",`with(__s__){return(${t})}`),R.set(t,o)),o(n)}function X(t){const n=t.split("."),o=n[0],e=n.slice(1),c=o.indexOf(":");return-1===c?{base:o,arg:null,modifiers:e}:{base:o.substring(0,c),arg:o.substring(c+1),modifiers:e}}function Y(t,n,o,e){const c=m(()=>{const e=V(n,o);t.style.display=e?"":"none"});e.push(c)}function Z(t,n,o,e){const c=m(()=>{t.textContent=String(V(n,o)??"")});e.push(c)}function tt(t,n,o,e){const c=m(()=>{t.innerHTML=String(V(n,o)??"")});e.push(c)}function nt(t,n,o,e,c){const s=m(()=>{const c=V(n,e);!1===c||null==c?t.removeAttribute(o):!0===c?t.setAttribute(o,""):t.setAttribute(o,String(c))});c.push(s)}function ot(t,n,o,c,s,i){const r=c.includes("stop"),f=c.includes("prevent"),u=c.includes("once"),l=c.includes("self"),a=o=>{l&&o.target!==t||(r&&o.stopPropagation(),f&&o.preventDefault(),function(t,n){const o="$$"+t;let e=R.get(o);e||(e=new Function("__s__",`with(__s__){${t}}`),R.set(o,e)),e(n)}(n,s),e())};t.addEventListener(o,a,{once:u}),i.push(()=>t.removeEventListener(o,a))}function et(t,n,o,c){const s=m(()=>{const e=V(n,o);t.value=null!=e?String(e):""});c.push(s);const i=()=>{const c=n.trim().split(".");if(1===c.length)o[c[0]]=t.value;else{const e=c.slice(0,-1).join("."),s=c[c.length-1];try{const n=V(e,o);n&&"object"==typeof n&&(n[s]=t.value)}catch(e){o[n]=t.value}}e()};t.addEventListener("input",i),c.push(()=>t.removeEventListener("input",i))}function ct(t){return t.startsWith("k-")||t.startsWith(":")||t.startsWith("@")}function st(t){return t.startsWith(":")?"k-bind:"+t.substring(1):t.startsWith("@")?"k-on:"+t.substring(1):t}function it(t,n,o){const e=[...t.attributes];for(const c of e){const e=c.name,s=c.value;if(!ct(e))continue;const i=st(e),{base:r,arg:f,modifiers:u}=X(i);switch(r){case"k-show":Y(t,s,n,o);break;case"k-text":Z(t,s,n,o);break;case"k-html":tt(t,s,n,o);break;case"k-bind":f&&nt(t,s,f,n,o);break;case"k-on":f&&ot(t,s,f,u,n,o);break;case"k-model":et(t,s,n,o)}}}function rt(t,n,o){for(const e of t.children)e.hasAttribute("k-data")||(it(e,n,o),rt(e,n,o))}function ft(t,n){const o=t.getAttribute("k-data");let e={};try{e=V(o,Q({}))||{}}catch(t){}const c=Q(e);it(t,c,n),rt(t,c,n);for(const o of t.children)o.hasAttribute("k-data")&&ft(o,n)}function ut(t){const n=[];if(t.hasAttribute&&t.hasAttribute("k-data"))ft(t,n);else{const o=t.querySelectorAll?t.querySelectorAll("[k-data]"):[];if(o.length>0)for(const e of o){let o=!1,c=e.parentElement;for(;c&&c!==t;){if(c.hasAttribute("k-data")){o=!0;break}c=c.parentElement}o||ft(e,n)}else{const o=Q({});for(const e of t.children)it(e,o,n),rt(e,o,n)}}return{destroy(){for(const t of n)t();n.length=0}}}const lt={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};let at="en-US";function ht(t){at=t}function dt(){return at}function pt(t,n={}){let o=(lt[at]||lt["en-US"])[t]||t;for(const[t,e]of Object.entries(n))o=o.replace(`{${t}}`,e);return o}function yt(t,n){lt[t]||(lt[t]={}),Object.assign(lt[t],n)}function gt(t,n={}){const{fallback:o=null,onError:e=null}=n;try{return t()}catch(t){if(e)try{e(t)}catch(t){}const n=document.createDocumentFragment();if(o)try{const e="function"==typeof o?o(t):o;if("string"==typeof e){const t=document.createElement("div");t.className="ds-error-boundary",t.textContent=e,n.appendChild(t)}else C(e,n)}catch(o){const e=document.createElement("div");e.className="ds-error-boundary",e.textContent=`Component error: ${t.message}`,n.appendChild(e)}else{const o=document.createElement("div");o.className="ds-error-boundary",o.textContent=`Component error: ${t.message}`,n.appendChild(o)}return{element:n,error:t}}}export{gt as ErrorBoundary,p as Signal,w as TemplateResult,yt as addMessages,S as batch,L as clearRegistry,g as computed,B as defineComponent,m as effect,e as flushJobs,G as getComponent,dt as getLocale,H as hasComponent,_ as html,K as hydrate,W as register,C as render,c as resetScheduler,ht as setLocale,y as signal,pt as t,ut as walk};
1
+ const t=new Set;let n=!1;function o(o){t.add(o),n||(n=!0,queueMicrotask(e))}function e(){for(n=!1;t.size>0;){const n=[...t];t.clear();for(const t of n)t()}}function c(){t.clear(),n=!1}let s=!1,r=0;const i=new Map,f=new Map,u=new Map;let l=0,a=0,h=0,p=0,d=0;const m=new WeakMap;function y(t,n){return m.has(t)?m.get(t):(m.set(t,n),n)}function g(t={}){s=!0,r=performance.now(),i.clear(),f.clear(),u.clear(),l=0,a=0,h=0,p=0,d=0,t.console}function w(){s=!1}function b(){s=!1,r=0,i.clear(),f.clear(),u.clear(),h=0,p=0,d=0}function k(){return s}function S(){const t=r>0?performance.now()-r:0,n=[];for(const[,t]of i)n.push({label:t.label,reads:t.reads,writes:t.writes,triggers:t.triggers});const o=[];for(const[,t]of f){const n=t.runs>0?t.totalTime/t.runs:0;o.push({label:t.label,runs:t.runs,totalTime:t.totalTime.toFixed(2)+"ms",maxTime:t.maxTime.toFixed(3)+"ms",avgTime:n.toFixed(3)+"ms"})}const e=[];for(const[,t]of u){const n=t.recomputes>0?t.totalTime/t.recomputes:0;e.push({label:t.label,recomputes:t.recomputes,totalTime:t.totalTime.toFixed(2)+"ms",maxTime:t.maxTime.toFixed(3)+"ms",avgTime:n.toFixed(3)+"ms"})}return{duration:Math.round(t),totalTriggers:h,totalEffectRuns:p,totalComputedRecomputes:d,signals:n,effects:o,computeds:e}}function _(){const t=S();t.signals.length,t.effects.length,t.computeds.length}let v=null;const O=[];function x(t){O.push(v),v=t}function j(){v=O.pop()??null}let T=0;const $=new Set;function M(t){T=t}function N(t){v&&(t.t.add(v),v.o.add(t))}function A(t){for(const n of t.t)n.i?n.u():T>0?$.add(n.u):o(n.u)}class C{constructor(t){this.l=t,this.t=new Set}get value(){return N(this),k()&&function(t){if(!s)return;const n=y(t,l);i.has(n)||(i.set(n,{reads:0,writes:0,triggers:0,label:`signal#${n}`}),n>=l&&(l=n+1)),i.get(n).reads++}(this),this.l}set value(t){Object.is(this.l,t)||(this.l=t,k()&&function(t){if(!s)return;const n=y(t,l);i.has(n)||(i.set(n,{reads:0,writes:0,triggers:0,label:`signal#${n}`}),n>=l&&(l=n+1)),i.get(n).writes++}(this),A(this))}peek(){return this.l}toString(){return String(this.l)}toJSON(){return JSON.stringify(this.l)}}function J(t){return new C(t)}function z(t){const n=new C(void 0);let o=!0,e=new Set;const c={h:null,o:e,i:!0,u:null,p:!1};function s(){for(const t of e)t.t.delete(c);e.clear(),c.o=e,x(c);try{const o=t();Object.is(n.l,o)||(n.l=o)}finally{j()}o=!1}return c.u=()=>{o||(o=!0,A(n))},{get value(){return o&&s(),N(n),n.l},peek:()=>(o&&s(),n.l),toString(){return String(this.value)},toJSON(){return JSON.stringify(this.value)}}}function E(t){const n={h:t,o:new Set,u:null,p:!1};return n.u=()=>{n.p||F(n)},F(n),()=>function(t){if(t.p)return;t.p=!0,K(t)}(n)}function F(t){K(t),x(t);try{k()?function(t,n){if(!s)return n();const o=y(t,a);f.has(o)||(f.set(o,{runs:0,totalTime:0,maxTime:0,label:`effect#${o}`}),o>=a&&(a=o+1));const e=f.get(o),c=performance.now(),r=n(),i=performance.now()-c;e.runs++,e.totalTime+=i,i>e.maxTime&&(e.maxTime=i),p++}(t,t.h):t.h()}finally{j()}}function K(t){for(const n of t.o)n.t.delete(t);t.o.clear()}function D(t){M(T+1);try{return t()}finally{if(M(T-1),0===T){const t=$,n=[...t];t.clear();for(const t of n)t();e()}}}class P{constructor(t,n){this.strings=t,this.values=n}}function q(t,...n){return new P(t,n)}function I(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function R(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const U=t=>`຿${t}຿`;function W(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof P?n.push(W(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof P?n.push(e.map(W).join("")):R(e)?n.push(I(e.value)):"function"!=typeof e&&n.push(I(e??""))}return n.join("")}function B(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const e=t.substring(0,o).lastIndexOf("<");if(-1===e)return{type:"text"};if(t.substring(e,o).includes(">"))return{type:"text"};const c=t.substring(e+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!c)return{type:"text"};const s=c[1];return s.startsWith("on")&&s.length>2?{type:"event",attrName:s}:{type:"attr",attrName:s}}class G{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.m=null}mount(){const t=document.createTextNode("");if(this.k?this.container.insertBefore(t,this.k):this.container.appendChild(t),this.node=t,R(this.rawValue)){const t=this.rawValue;this.m=E(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof P?this.node.textContent=W(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.m?.(),this.node?.remove()}}class H{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.m=null}mount(){if(R(this.rawValue)){const t=this.rawValue;this.m=E(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.m?.()}}class L{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.S=null}mount(){"function"==typeof this.handler&&(this.S=t=>this.handler(t),this.element.addEventListener(this.eventName,this.S))}destroy(){this.S&&(this.element.removeEventListener(this.eventName,this.S),this.S=null)}}class Q{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function V(t,n){const o=new Q,e=function(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof P?n.push(W(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof P?n.push(e.map(W).join("")):"function"==typeof e||R(e)?n.push(U(o)):n.push(I(e??""))}return n.join("")}(t),c=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);o.fragment=c,X(c,t.values,e,o);for(const t of o.parts)t.mount();return n.appendChild(c),o}function X(t,n,o,e){const c=[...t.childNodes];for(const s of c)3===s.nodeType?Y(s,n,o,e,t):1===s.nodeType&&Z(s,n,o,e)}function Y(t,n,o,e,c){const s=t.textContent||"";for(let r=0;r<n.length;r++){const i=U(r),f=s.indexOf(i);if(-1===f)continue;if("text"!==B(o,i).type)continue;const u=s.substring(0,f),l=s.substring(f+i.length);u&&c.insertBefore(document.createTextNode(u),t);const a=new G(c,n[r]);e.parts.push(a);let h=t;return l&&(h=document.createTextNode(l),c.insertBefore(h,t)),c.removeChild(t),a.k=h!==t?h:null,void(l&&Y(h,n,o,e,c))}}function Z(t,n,o,e){const c=[...t.attributes];for(const s of c)for(let c=0;c<n.length;c++){const r=U(c);if(!s.value.includes(r))continue;const i=B(o,r);if("event"===i.type&&i.attrName===s.name){t.removeAttribute(s.name);const o=new L(t,s.name,n[c]);e.parts.push(o)}else if("attr"===i.type&&i.attrName===s.name){const o=s.value.replace(r,"");o?t.setAttribute(s.name,o):t.removeAttribute(s.name);const i=new H(t,s.name,n[c]);e.parts.push(i)}}X(t,n,o,e)}function tt(t){const n=[];for(let o=0;o<t.strings.length;o++)if(n.push(t.strings[o]),o<t.values.length){const e=t.values[o];e instanceof P?n.push(tt(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof P?n.push(e.map(t=>tt(t)).join("")):R(e)?n.push(I(e.value)):"function"!=typeof e&&n.push(I(e??""))}return n.join("")}function nt(t){const n=t.join("");let o=!1,e="",c=-1,s=!1;for(let t=0;t<n.length;t++){const r=n[t];o?r===e&&(o=!1):'"'===r||"'"===r?(o=!0,e=r):"<"===r?(c=t,s=!1):">"===r&&c>=0&&!o&&(s=!0)}return c>=0&&!s}function ot(t,n){const o=new Q,e=function(t){const n=[],o=[];let e=!1;for(let c=0;c<t.strings.length;c++)if(o.push(t.strings[c]),e=nt(o),c<t.values.length){const s=t.values[c];if(s instanceof P)o.push(tt(s));else if(Array.isArray(s)&&s.length>0&&s[0]instanceof P)o.push(s.map(t=>tt(t)).join(""));else if("function"==typeof s);else if(R(s))if(e){const t=s.value;o.push(null!=t?I(t):"")}else{n.push(c);const t=s.value;o.push(null!=t?I(t):"")}else o.push(I(s??""))}return{indices:n,nextIdx:0}}(t);return et(n,t.values,o,e),o}function et(t,n,o,e){const c=[...t.childNodes];for(const s of c)8===s.nodeType?ct(s,n,t,o,e):1===s.nodeType&&st(s,n,o,e)}function ct(t,n,o,e,c){const s=c.indices[c.nextIdx++]??-1,r=t.previousSibling;let i;if(r&&3===r.nodeType?i=r:(i=document.createTextNode(""),o.insertBefore(i,t)),s>=0&&s<n.length){const t=n[s];if(R(t)){const n=E(()=>{i.textContent=null!=t.value?String(t.value):""});e.parts.push({destroy(){n(),i.remove()}})}else i.textContent=null!=t?String(t):""}o.removeChild(t)}function st(t,n,o,e){const c=t.getAttribute("data-kp");if(c){const e=c.split(",");for(const c of e){const e=c.indexOf(":"),s=c.indexOf(":",e+1),r=parseInt(c.substring(0,e),10),i=c.substring(e+1,s),f=c.substring(s+1);if(r>=0&&r<n.length)if("e"===i){const e=new L(t,f,n[r]);e.mount(),o.parts.push(e)}else if("a"===i){const e=new H(t,f,n[r]);e.mount(),o.parts.push(e)}}t.removeAttribute("data-kp")}et(t,n,o,e)}function rt(t){const{props:n=[],setup:o}=t;function e(t={},e=null){const c={};for(const o of n)c[o]=J(t[o]);const s=o(c,e)(),r=document.createDocumentFragment(),i=V(s,r);return{get element(){return r},_:i,destroy(){i.destroy()},update(t){for(const o of n)o in t&&c[o]&&(c[o].value=t[o])}}}return e.v=!0,e.O=n,e}const it=new Map;function ft(t,n){it.set(t,n)}function ut(t){return it.get(t)}function lt(t){return it.has(t)}function at(){it.clear()}function ht(t){const n={};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=J(t[o]));const o=Object.keys(n);return new Proxy({},{get(t,o){if("symbol"==typeof o)return;const e=n[o];return e?e.value:void 0},set(t,e,c){const s=n[e];return s?s.value=c:(n[e]=J(c),o.push(e)),!0},has:(t,o)=>o in n,ownKeys:()=>o,getOwnPropertyDescriptor(t,o){if(o in n)return{enumerable:!0,configurable:!0}}})}const pt=new Map;function dt(t,n){let o=pt.get(t);return o||(o=new Function("__s__",`with(__s__){return(${t})}`),pt.set(t,o)),o(n)}function mt(t){const n=t.split("."),o=n[0],e=n.slice(1),c=o.indexOf(":");return-1===c?{base:o,arg:null,modifiers:e}:{base:o.substring(0,c),arg:o.substring(c+1),modifiers:e}}function yt(t,n,o,e){const c=E(()=>{const e=dt(n,o);t.style.display=e?"":"none"});e.push(c)}function gt(t,n,o,e){const c=E(()=>{t.textContent=String(dt(n,o)??"")});e.push(c)}function wt(t,n,o,e){const c=E(()=>{t.innerHTML=String(dt(n,o)??"")});e.push(c)}function bt(t,n,o,e,c){const s=E(()=>{const c=dt(n,e);!1===c||null==c?t.removeAttribute(o):!0===c?t.setAttribute(o,""):t.setAttribute(o,String(c))});c.push(s)}function kt(t,n,o,c,s,r){const i=c.includes("stop"),f=c.includes("prevent"),u=c.includes("once"),l=c.includes("self"),a=o=>{l&&o.target!==t||(i&&o.stopPropagation(),f&&o.preventDefault(),function(t,n){const o="$$"+t;let e=pt.get(o);e||(e=new Function("__s__",`with(__s__){${t}}`),pt.set(o,e)),e(n)}(n,s),e())};t.addEventListener(o,a,{once:u}),r.push(()=>t.removeEventListener(o,a))}function St(t,n,o,c){const s=E(()=>{const e=dt(n,o);t.value=null!=e?String(e):""});c.push(s);const r=()=>{const c=n.trim().split(".");if(1===c.length)o[c[0]]=t.value;else{const e=c.slice(0,-1).join("."),s=c[c.length-1];try{const n=dt(e,o);n&&"object"==typeof n&&(n[s]=t.value)}catch(e){o[n]=t.value}}e()};t.addEventListener("input",r),c.push(()=>t.removeEventListener("input",r))}function _t(t){return t.startsWith("k-")||t.startsWith(":")||t.startsWith("@")}function vt(t){return t.startsWith(":")?"k-bind:"+t.substring(1):t.startsWith("@")?"k-on:"+t.substring(1):t}function Ot(t,n,o){const e=[...t.attributes];for(const c of e){const e=c.name,s=c.value;if(!_t(e))continue;const r=vt(e),{base:i,arg:f,modifiers:u}=mt(r);switch(i){case"k-show":yt(t,s,n,o);break;case"k-text":gt(t,s,n,o);break;case"k-html":wt(t,s,n,o);break;case"k-bind":f&&bt(t,s,f,n,o);break;case"k-on":f&&kt(t,s,f,u,n,o);break;case"k-model":St(t,s,n,o)}}}function xt(t,n,o){for(const e of t.children)e.hasAttribute("k-data")||(Ot(e,n,o),xt(e,n,o))}function jt(t,n){const o=t.getAttribute("k-data");let e={};try{e=dt(o,ht({}))||{}}catch(t){}const c=ht(e);Ot(t,c,n),xt(t,c,n);for(const o of t.children)o.hasAttribute("k-data")&&jt(o,n)}function Tt(t){const n=[];if(t.hasAttribute&&t.hasAttribute("k-data"))jt(t,n);else{const o=t.querySelectorAll?t.querySelectorAll("[k-data]"):[];if(o.length>0)for(const e of o){let o=!1,c=e.parentElement;for(;c&&c!==t;){if(c.hasAttribute("k-data")){o=!0;break}c=c.parentElement}o||jt(e,n)}else{const o=ht({});for(const e of t.children)Ot(e,o,n),xt(e,o,n)}}return{destroy(){for(const t of n)t();n.length=0}}}const $t={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};let Mt="en-US";function Nt(t){Mt=t}function At(){return Mt}function Ct(t,n={}){let o=($t[Mt]||$t["en-US"])[t]||t;for(const[t,e]of Object.entries(n))o=o.replace(`{${t}}`,e);return o}function Jt(t,n){$t[t]||($t[t]={}),Object.assign($t[t],n)}function zt(t,n={}){const{fallback:o=null,onError:e=null}=n;try{return t()}catch(t){if(e)try{e(t)}catch(t){}const n=document.createDocumentFragment();if(o)try{const e="function"==typeof o?o(t):o;if("string"==typeof e){const t=document.createElement("div");t.className="ds-error-boundary",t.textContent=e,n.appendChild(t)}else V(e,n)}catch(o){const e=document.createElement("div");e.className="ds-error-boundary",e.textContent=`Component error: ${t.message}`,n.appendChild(e)}else{const o=document.createElement("div");o.className="ds-error-boundary",o.textContent=`Component error: ${t.message}`,n.appendChild(o)}return{element:n,error:t}}}function Et(t,n="default"){let o=null,e=null;async function c(){return o||(e||(e=t().then(t=>{if("function"==typeof t.default)o=t.default;else if("default"!==n&&"function"==typeof t[n])o=t[n];else{const n=Object.keys(t);for(const e of n)if("function"==typeof t[e]){o=t[e];break}}if(!o)throw new Error("[Kupola lazy] No component factory found in module");return e=null,o}),e))}async function s(...t){return(await c())(...t)}return s.j=t,s.T=()=>null!==o,s.$=c,s}async function Ft(t){if("function"!=typeof t.$)throw new TypeError("[Kupola preload] Argument must be a lazy component from lazyComponent()");await t.$()}export{zt as ErrorBoundary,C as Signal,P as TemplateResult,Jt as addMessages,D as batch,at as clearRegistry,z as computed,rt as defineComponent,w as disableProfiler,E as effect,g as enableProfiler,e as flushJobs,ut as getComponent,At as getLocale,S as getProfileReport,lt as hasComponent,q as html,ot as hydrate,Et as lazyComponent,Ft as preloadComponent,_ as printProfileReport,ft as register,V as render,b as resetProfiler,c as resetScheduler,Nt as setLocale,J as signal,Ct as t,Tt as walk};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kupola/kupola",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.7",
4
4
  "description": "A modern, modular UI component library for any web project. Zero framework dependencies, tree-shakeable imports. 这是一个现代、模块化的 UI 组件库,适用于任何 Web 项目。零框架依赖,支持按需引入(tree-shakeable)。",
5
5
  "main": "dist/kupola-core.esm.js",
6
6
  "module": "dist/kupola-core.esm.js",
@@ -0,0 +1,303 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * @kupola/core — DevTools: Signal reactivity profiler.
4
+ *
5
+ * Provides performance profiling for the Kupola reactivity system.
6
+ * Tracks signal reads, writes, effect runs, and computed recomputes.
7
+ *
8
+ * Usage:
9
+ * ```js
10
+ * import { enableProfiler, getProfileReport, resetProfiler } from '@kupola/kupola/devtools';
11
+ *
12
+ * enableProfiler();
13
+ * // ... run your app ...
14
+ * const report = getProfileReport();
15
+ * console.table(report.signals);
16
+ * console.table(report.effects);
17
+ * resetProfiler();
18
+ * ```
19
+ *
20
+ * @module devtools
21
+ */
22
+
23
+ // ── Profiler state ──────────────────────────────────────────────────────────
24
+
25
+ let _enabled = false;
26
+ let _startTime = 0;
27
+
28
+ /** @type {Map<number, {reads: number, writes: number, triggers: number, label: string}>} */
29
+ const _signalStats = new Map();
30
+
31
+ /** @type {Map<number, {runs: number, totalTime: number, maxTime: number, label: string}>} */
32
+ const _effectStats = new Map();
33
+
34
+ /** @type {Map<number, {recomputes: number, totalTime: number, maxTime: number, label: string}>} */
35
+ const _computedStats = new Map();
36
+
37
+ let _nextSignalId = 0;
38
+ let _nextEffectId = 0;
39
+ let _nextComputedId = 0;
40
+
41
+ /** @type {number} Total trigger count across all signals. */
42
+ let _totalTriggers = 0;
43
+
44
+ /** @type {number} Total effect runs. */
45
+ let _totalEffectRuns = 0;
46
+
47
+ /** @type {number} Total computed recomputes. */
48
+ let _totalComputedRecomputes = 0;
49
+
50
+ // ── Signal ID registry ──────────────────────────────────────────────────────
51
+
52
+ /** @type {WeakMap<Object, number>} Maps signal/computed/effect instances to IDs. */
53
+ const _idMap = new WeakMap();
54
+
55
+ function getOrCreateId(obj, counter) {
56
+ if (!_idMap.has(obj)) {
57
+ _idMap.set(obj, counter);
58
+ return counter;
59
+ }
60
+ return _idMap.get(obj);
61
+ }
62
+
63
+ // ── Public API ──────────────────────────────────────────────────────────────
64
+
65
+ /**
66
+ * Enable the reactivity profiler. Call this before running your application
67
+ * to start collecting performance data.
68
+ *
69
+ * @param {Object} [options]
70
+ * @param {boolean} [options.console=false] Log events to console in real-time
71
+ */
72
+ export function enableProfiler(options = {}) {
73
+ _enabled = true;
74
+ _startTime = performance.now();
75
+ _signalStats.clear();
76
+ _effectStats.clear();
77
+ _computedStats.clear();
78
+ _nextSignalId = 0;
79
+ _nextEffectId = 0;
80
+ _nextComputedId = 0;
81
+ _totalTriggers = 0;
82
+ _totalEffectRuns = 0;
83
+ _totalComputedRecomputes = 0;
84
+ if (options.console) {
85
+ console.log('[Kupola Profiler] Enabled');
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Disable the profiler and stop collecting data.
91
+ */
92
+ export function disableProfiler() {
93
+ _enabled = false;
94
+ }
95
+
96
+ /**
97
+ * Reset all profiler data. Call between profiling sessions.
98
+ */
99
+ export function resetProfiler() {
100
+ _enabled = false;
101
+ _startTime = 0;
102
+ _signalStats.clear();
103
+ _effectStats.clear();
104
+ _computedStats.clear();
105
+ _totalTriggers = 0;
106
+ _totalEffectRuns = 0;
107
+ _totalComputedRecomputes = 0;
108
+ }
109
+
110
+ /**
111
+ * Check if profiler is enabled.
112
+ * @returns {boolean}
113
+ */
114
+ export function isProfilerEnabled() {
115
+ return _enabled;
116
+ }
117
+
118
+ // ── Tracking functions (called by signal/effect/computed internals) ──────────
119
+
120
+ /**
121
+ * Record a signal write (set .value).
122
+ * @param {Object} sig The Signal instance
123
+ * @param {string} [label] Optional label for the signal
124
+ */
125
+ export function profileSignalWrite(sig, label) {
126
+ if (!_enabled) {return;}
127
+ const id = getOrCreateId(sig, _nextSignalId);
128
+ if (!_signalStats.has(id)) {
129
+ _signalStats.set(id, { reads: 0, writes: 0, triggers: 0, label: label || `signal#${id}` });
130
+ if (id >= _nextSignalId) {_nextSignalId = id + 1;}
131
+ }
132
+ const stats = _signalStats.get(id);
133
+ stats.writes++;
134
+ }
135
+
136
+ /**
137
+ * Record a signal read (get .value inside effect).
138
+ * @param {Object} sig The Signal instance
139
+ * @param {string} [label] Optional label
140
+ */
141
+ export function profileSignalRead(sig, label) {
142
+ if (!_enabled) {return;}
143
+ const id = getOrCreateId(sig, _nextSignalId);
144
+ if (!_signalStats.has(id)) {
145
+ _signalStats.set(id, { reads: 0, writes: 0, triggers: 0, label: label || `signal#${id}` });
146
+ if (id >= _nextSignalId) {_nextSignalId = id + 1;}
147
+ }
148
+ _signalStats.get(id).reads++;
149
+ }
150
+
151
+ /**
152
+ * Record a trigger (signal notifying subscribers).
153
+ * @param {Object} sig The Signal instance
154
+ * @param {number} subscriberCount Number of subscribers notified
155
+ */
156
+ export function profileTrigger(sig, subscriberCount) {
157
+ if (!_enabled) {return;}
158
+ const id = getOrCreateId(sig, _nextSignalId);
159
+ if (_signalStats.has(id)) {
160
+ _signalStats.get(id).triggers += subscriberCount;
161
+ }
162
+ _totalTriggers += subscriberCount;
163
+ }
164
+
165
+ /**
166
+ * Record an effect execution with timing.
167
+ * @param {Object} eff The EffectRecord
168
+ * @param {Function} fn The effect function to run
169
+ * @param {string} [label] Optional label
170
+ * @returns {*} The return value of fn
171
+ */
172
+ export function profileEffectRun(eff, fn, label) {
173
+ if (!_enabled) {
174
+ return fn();
175
+ }
176
+ const id = getOrCreateId(eff, _nextEffectId);
177
+ if (!_effectStats.has(id)) {
178
+ _effectStats.set(id, { runs: 0, totalTime: 0, maxTime: 0, label: label || `effect#${id}` });
179
+ if (id >= _nextEffectId) {_nextEffectId = id + 1;}
180
+ }
181
+ const stats = _effectStats.get(id);
182
+ const t0 = performance.now();
183
+ const result = fn();
184
+ const elapsed = performance.now() - t0;
185
+ stats.runs++;
186
+ stats.totalTime += elapsed;
187
+ if (elapsed > stats.maxTime) {stats.maxTime = elapsed;}
188
+ _totalEffectRuns++;
189
+ return result;
190
+ }
191
+
192
+ /**
193
+ * Record a computed recomputation with timing.
194
+ * @param {Object} comp The computed instance
195
+ * @param {Function} fn The compute function
196
+ * @param {string} [label] Optional label
197
+ * @returns {*} The computed result
198
+ */
199
+ export function profileComputedRun(comp, fn, label) {
200
+ if (!_enabled) {
201
+ return fn();
202
+ }
203
+ const id = getOrCreateId(comp, _nextComputedId);
204
+ if (!_computedStats.has(id)) {
205
+ _computedStats.set(id, { recomputes: 0, totalTime: 0, maxTime: 0, label: label || `computed#${id}` });
206
+ if (id >= _nextComputedId) {_nextComputedId = id + 1;}
207
+ }
208
+ const stats = _computedStats.get(id);
209
+ const t0 = performance.now();
210
+ const result = fn();
211
+ const elapsed = performance.now() - t0;
212
+ stats.recomputes++;
213
+ stats.totalTime += elapsed;
214
+ if (elapsed > stats.maxTime) {stats.maxTime = elapsed;}
215
+ _totalComputedRecomputes++;
216
+ return result;
217
+ }
218
+
219
+ // ── Report generation ───────────────────────────────────────────────────────
220
+
221
+ /**
222
+ * Generate a profiling report.
223
+ *
224
+ * @returns {{
225
+ * duration: number,
226
+ * totalTriggers: number,
227
+ * totalEffectRuns: number,
228
+ * totalComputedRecomputes: number,
229
+ * signals: Array<{label: string, reads: number, writes: number, triggers: number}>,
230
+ * effects: Array<{label: string, runs: number, totalTime: string, maxTime: string, avgTime: string}>,
231
+ * computeds: Array<{label: string, recomputes: number, totalTime: string, maxTime: string, avgTime: string}>,
232
+ * }}
233
+ */
234
+ export function getProfileReport() {
235
+ const duration = _startTime > 0 ? performance.now() - _startTime : 0;
236
+
237
+ const signals = [];
238
+ for (const [, s] of _signalStats) {
239
+ signals.push({ label: s.label, reads: s.reads, writes: s.writes, triggers: s.triggers });
240
+ }
241
+
242
+ const effects = [];
243
+ for (const [, s] of _effectStats) {
244
+ const avg = s.runs > 0 ? s.totalTime / s.runs : 0;
245
+ effects.push({
246
+ label: s.label,
247
+ runs: s.runs,
248
+ totalTime: s.totalTime.toFixed(2) + 'ms',
249
+ maxTime: s.maxTime.toFixed(3) + 'ms',
250
+ avgTime: avg.toFixed(3) + 'ms',
251
+ });
252
+ }
253
+
254
+ const computeds = [];
255
+ for (const [, s] of _computedStats) {
256
+ const avg = s.recomputes > 0 ? s.totalTime / s.recomputes : 0;
257
+ computeds.push({
258
+ label: s.label,
259
+ recomputes: s.recomputes,
260
+ totalTime: s.totalTime.toFixed(2) + 'ms',
261
+ maxTime: s.maxTime.toFixed(3) + 'ms',
262
+ avgTime: avg.toFixed(3) + 'ms',
263
+ });
264
+ }
265
+
266
+ return {
267
+ duration: Math.round(duration),
268
+ totalTriggers: _totalTriggers,
269
+ totalEffectRuns: _totalEffectRuns,
270
+ totalComputedRecomputes: _totalComputedRecomputes,
271
+ signals,
272
+ effects,
273
+ computeds,
274
+ };
275
+ }
276
+
277
+ /**
278
+ * Print a human-readable profiling summary to the console.
279
+ */
280
+ export function printProfileReport() {
281
+ const report = getProfileReport();
282
+ console.log('═══════════════════════════════════════════════════════');
283
+ console.log(' Kupola Reactivity Profile Report');
284
+ console.log('═══════════════════════════════════════════════════════');
285
+ console.log(` Duration: ${report.duration}ms`);
286
+ console.log(` Total triggers: ${report.totalTriggers}`);
287
+ console.log(` Total effect runs: ${report.totalEffectRuns}`);
288
+ console.log(` Total recomputes: ${report.totalComputedRecomputes}`);
289
+ console.log('───────────────────────────────────────────────────────');
290
+ if (report.signals.length > 0) {
291
+ console.log(' Signals:');
292
+ console.table(report.signals);
293
+ }
294
+ if (report.effects.length > 0) {
295
+ console.log(' Effects:');
296
+ console.table(report.effects);
297
+ }
298
+ if (report.computeds.length > 0) {
299
+ console.log(' Computeds:');
300
+ console.table(report.computeds);
301
+ }
302
+ console.log('═══════════════════════════════════════════════════════');
303
+ }
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import { pushEffect, popEffect } from './signal.js';
12
+ import { isProfilerEnabled, profileEffectRun } from './devtools.js';
12
13
 
13
14
  /**
14
15
  * @typedef {Object} EffectRecord
@@ -70,7 +71,11 @@ function runEffect(eff) {
70
71
 
71
72
  pushEffect(eff);
72
73
  try {
73
- eff._fn();
74
+ if (isProfilerEnabled()) {
75
+ profileEffectRun(eff, eff._fn);
76
+ } else {
77
+ eff._fn();
78
+ }
74
79
  } finally {
75
80
  popEffect();
76
81
  }
@@ -43,3 +43,9 @@ export { setLocale, getLocale, t, addMessages } from './i18n.js';
43
43
 
44
44
  // ── Error Boundary ───────────────────────────────────────────────────────────
45
45
  export { ErrorBoundary } from './errors.js';
46
+
47
+ // ── DevTools (profiler) ──────────────────────────────────────────────────────
48
+ export { enableProfiler, disableProfiler, resetProfiler, getProfileReport, printProfileReport } from './devtools.js';
49
+
50
+ // ── Lazy Load ────────────────────────────────────────────────────────────────
51
+ export { lazyComponent, preloadComponent } from './lazy.js';
@@ -0,0 +1,128 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * @kupola/core — Lazy component loading.
4
+ *
5
+ * Provides async component initialization for code-splitting and
6
+ * on-demand loading of heavy components (Table, Calendar, etc.).
7
+ *
8
+ * Usage:
9
+ * ```js
10
+ * import { lazyComponent } from '@kupola/kupola';
11
+ *
12
+ * // Lazy-load a component — only fetches the bundle when first used
13
+ * const LazyTable = lazyComponent(() => import('@kupola/kupola/components/table'));
14
+ *
15
+ * // Later, when you need it:
16
+ * const table = await LazyTable({ columns: [...], data: [...] });
17
+ * container.appendChild(table.element);
18
+ * ```
19
+ *
20
+ * Or with preloading:
21
+ * ```js
22
+ * import { lazyComponent, preloadComponent } from '@kupola/kupola';
23
+ *
24
+ * const LazyCalendar = lazyComponent(() => import('@kupola/kupola/components/calendar'));
25
+ *
26
+ * // Start loading in the background
27
+ * preloadComponent(LazyCalendar);
28
+ *
29
+ * // Later — resolves instantly if already loaded
30
+ * const cal = await LazyCalendar({ ... });
31
+ * ```
32
+ *
33
+ * @module lazy
34
+ */
35
+
36
+ // ── Component cache ─────────────────────────────────────────────────────────
37
+
38
+ /** @type {Map<Function, Promise<any>>} Cache for in-flight and resolved imports. */
39
+ const _cache = new Map();
40
+
41
+ /**
42
+ * Create a lazy-loaded component wrapper.
43
+ *
44
+ * The dynamic import is only executed on first call. Subsequent calls
45
+ * return the cached component factory.
46
+ *
47
+ * @param {() => Promise<{default?: Function, [key: string]: Function}>} loader
48
+ * Dynamic import function returning the component module.
49
+ * @param {string} [exportName='default']
50
+ * Named export to use (default: 'default' or first exported function).
51
+ * @returns {Function}
52
+ * An async factory: `async (options, ...args) => ComponentResult`.
53
+ * Resolves to the same shape as calling the component directly.
54
+ */
55
+ export function lazyComponent(loader, exportName = 'default') {
56
+ /** @type {Function|null} Resolved component factory. */
57
+ let _resolved = null;
58
+
59
+ /** @type {Promise<Function>|null} In-flight import promise. */
60
+ let _pending = null;
61
+
62
+ async function resolve() {
63
+ if (_resolved) {return _resolved;}
64
+ if (_pending) {return _pending;}
65
+
66
+ _pending = loader().then(mod => {
67
+ // Find the component factory in the module
68
+ if (typeof mod.default === 'function') {
69
+ _resolved = mod.default;
70
+ } else if (exportName !== 'default' && typeof mod[exportName] === 'function') {
71
+ _resolved = mod[exportName];
72
+ } else {
73
+ // First exported function
74
+ const keys = Object.keys(mod);
75
+ for (const key of keys) {
76
+ if (typeof mod[key] === 'function') {
77
+ _resolved = mod[key];
78
+ break;
79
+ }
80
+ }
81
+ }
82
+
83
+ if (!_resolved) {
84
+ throw new Error(`[Kupola lazy] No component factory found in module`);
85
+ }
86
+
87
+ _pending = null;
88
+ return _resolved;
89
+ });
90
+
91
+ return _pending;
92
+ }
93
+
94
+ /**
95
+ * Async component factory. Awaits the dynamic import on first call,
96
+ * then delegates to the resolved component.
97
+ *
98
+ * @param {...any} args Arguments forwarded to the component factory.
99
+ * @returns {Promise<any>} The component result (same as direct call).
100
+ */
101
+ async function lazyFactory(...args) {
102
+ const factory = await resolve();
103
+ return factory(...args);
104
+ }
105
+
106
+ // Attach metadata for debugging and preload support
107
+ lazyFactory._lazyLoader = loader;
108
+ lazyFactory._isResolved = () => _resolved !== null;
109
+ lazyFactory._preload = resolve;
110
+
111
+ return lazyFactory;
112
+ }
113
+
114
+ /**
115
+ * Preload a lazy component in the background.
116
+ *
117
+ * Call this during idle time or route transitions to warm up the cache
118
+ * before the component is actually needed.
119
+ *
120
+ * @param {Function} lazyFactory A function returned by `lazyComponent()`.
121
+ * @returns {Promise<void>} Resolves when the component module is loaded.
122
+ */
123
+ export async function preloadComponent(lazyFactory) {
124
+ if (typeof lazyFactory._preload !== 'function') {
125
+ throw new TypeError('[Kupola preload] Argument must be a lazy component from lazyComponent()');
126
+ }
127
+ await lazyFactory._preload();
128
+ }
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import { queueJob } from './scheduler.js';
13
+ import { isProfilerEnabled, profileSignalWrite, profileSignalRead, profileTrigger } from './devtools.js';
13
14
 
14
15
  // ─── Global dependency-tracking state ────────────────────────────────────────
15
16
 
@@ -103,6 +104,7 @@ export class Signal {
103
104
  */
104
105
  get value() {
105
106
  track(this);
107
+ if (isProfilerEnabled()) {profileSignalRead(this);}
106
108
  return this._value;
107
109
  }
108
110
 
@@ -113,6 +115,7 @@ export class Signal {
113
115
  set value(newValue) {
114
116
  if (!Object.is(this._value, newValue)) {
115
117
  this._value = newValue;
118
+ if (isProfilerEnabled()) {profileSignalWrite(this);}
116
119
  trigger(this);
117
120
  }
118
121
  }