@cat-of-summer/st-script 1.0.13 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/app/form.esm.min.js +1 -1
- package/dist/app/form.esm.min.js.map +3 -3
- package/dist/app/form.min.js +1 -1
- package/dist/app/form.min.js.map +3 -3
- package/dist/app.esm.min.js +1 -1
- package/dist/app.esm.min.js.map +3 -3
- package/dist/app.min.js +1 -1
- package/dist/app.min.js.map +3 -3
- package/dist/core.esm.min.js +1 -1
- package/dist/core.esm.min.js.map +3 -3
- package/dist/core.min.js +1 -1
- package/dist/core.min.js.map +3 -3
- package/dist/loader.esm.min.js +1 -1
- package/dist/loader.esm.min.js.map +3 -3
- package/dist/loader.min.js +1 -1
- package/dist/loader.min.js.map +3 -3
- package/dist/modal.esm.min.js +1 -1
- package/dist/modal.esm.min.js.map +3 -3
- package/dist/modal.min.js +1 -1
- package/dist/modal.min.js.map +3 -3
- package/dist/uploader.esm.min.js +1 -1
- package/dist/uploader.esm.min.js.map +3 -3
- package/dist/uploader.min.js +1 -1
- package/dist/uploader.min.js.map +3 -3
- package/package.json +1 -1
- package/src/app/index.js +193 -41
- package/src/core/index.js +51 -0
- package/src/index.js +1 -0
- package/src/modal/index.js +62 -6
- package/src/uploader/index.js +58 -15
package/dist/app.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var App=(()=>{var S=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var $=(c,e)=>{for(var t in e)S(c,t,{get:e[t],enumerable:!0})},W=(c,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of C(e))!k.call(c,s)&&s!==t&&S(c,s,{get:()=>e[s],enumerable:!(i=L(e,s))||i.enumerable});return c};var R=c=>W(S({},"__esModule",{value:!0}),c);var V={};$(V,{default:()=>x});var x=class c extends HTMLElement{static#X=new Set(["disabled","checked","readonly","required","selected","hidden","open","autofocus"]);static#b=new Map;static#c=new Set;static#M=new WeakMap;static create(e){let{app:t,setup:i=()=>{},template:s="",events:h={}}=e;if(c.#b.has(t))throw new Error(`Application "${t}" already exists!`);c.#b.set(t,{setup:i,template:s,events:h,config:e}),c.#c.forEach(r=>{r.#i!==!0&&r.#U()})}static extend(e,t={}){let i=c.#b.get(e);if(!i)throw new Error(`Application "${e}" not found!`);let s=i.config,h=Object.defineProperties({},{...Object.getOwnPropertyDescriptors(s),...Object.getOwnPropertyDescriptors(t)});return(s.events||t.events)&&(h.events={...s.events,...t.events}),c.create(h)}#i=!1;#p="";#L=!1;#s=new Map;#f=null;#o=new Set;#d=!1;#e=[];#r=null;#G=new Map;#l=null;#t=[];#g=new Set;#x=!1;#C=[];#k=new Map;#n=new Map;#$=0;#W="";#A=!1;#R=!1;constructor(){super(),c.#c.add(this)}#v(e){!e||!e.length||e.forEach(t=>{if(t.type==="event"&&t.element&&t.handler)t.element.removeEventListener(t.eventName,t.handler);else if(t.type==="model"&&t.element&&t.handler){let i=t.element.tagName==="SELECT"?"change":"input";t.element.removeEventListener(i,t.handler)}else t.type==="attrSync"&&t.unwatch&&t.unwatch();t.dispose?.(),t.effect&&(this.#s.forEach((i,s)=>{i.delete(t.effect),i.size===0&&this.#s.delete(s)}),this.#o.delete(t.effect))})}get template(){return this.#p}get attrs(){return{get:e=>this.getAttribute(e),set:(e,t)=>this.setAttribute(e,t),remove:e=>this.removeAttribute(e),has:e=>this.hasAttribute(e),toggle:(e,t)=>this.toggleAttribute(e,t),keys:()=>Array.from(this.attributes).map(e=>e.name),entries:()=>Array.from(this.attributes).map(e=>[e.name,e.value])}}addEventListener(e,t,i){if((e==="setup"||e==="rendered")&&this.#L){queueMicrotask(()=>{let s=new CustomEvent(e);typeof t=="function"?t.call(this,s):t?.handleEvent?.(s)});return}super.addEventListener(e,t,i)}dispatchEvent(e,t=null,i={}){if(typeof e=="string"){let s=new CustomEvent(e,{cancelable:!0,...i,detail:t});return super.dispatchEvent(s)}return super.dispatchEvent(e)}applyTemplate(e=""){let t=e||this.#p;if(this.#R=!0,this.#W=t,this.#v(this.#e),this.#e=[],this.innerHTML="",t){let s=document.createElement("template");s.innerHTML=t.trim();let h=s.content.cloneNode(!0);this.#K(h),this.#Q(h)}let i=++this.#$;new Promise(s=>{let h=null,r,l=()=>{clearTimeout(h),h=setTimeout(()=>{r.disconnect(),this.#j(Array.from(this.children)).then(s)},0)};r=new MutationObserver(n=>{n.some(a=>a.type==="childList")&&l()}),r.observe(this,{childList:!0}),l()}).then(()=>{i===this.#$&&(this.#L=!0,this.dispatchEvent("rendered"))})}#Q(e){HTMLElement.prototype.appendChild.call(this,e)}clone(e={}){let t=this.attrs.get("app");return c.extend(t,e)}watch(e,t,i={}){if(typeof t!="function")return()=>{};let{deep:s=!1,immediate:h=!1}=i;if(typeof e=="string"&&e.endsWith("()")){let r=e.slice(0,-2),l=this[r];if(typeof l!="function")return()=>{};let n=this.#n.get(r);if(!n){n={original:l,handlers:[]},this.#n.set(r,n);let o=(...u)=>{let f=l.apply(this,u),d=p=>{for(let b of[...n.handlers])b.callback(u,p,b.unwatch)};return f instanceof Promise?f.then(p=>(d(p),p)):(d(f),f)};this[r]=o}let a=()=>{let o=n.handlers.findIndex(u=>u.unwatch===a);o!==-1&&n.handlers.splice(o,1),n.handlers.length===0&&(this[r]=n.original,this.#n.delete(r))};return n.handlers.push({callback:t,unwatch:a}),a}if(typeof e=="string"){let r=e,l=()=>{let a=this.#t.findIndex(o=>o.unwatch===l);a!==-1&&this.#t.splice(a,1)},n={type:"key",key:r,callback:t,deep:s,immediate:h,lastValue:void 0,unwatch:l};if(this.#t.push(n),h){let a=this.#V(r);n.lastValue=s&&a!==null&&typeof a=="object"?JSON.parse(JSON.stringify(a)):a,t(a,void 0,l)}return l}if(typeof e=="function"){let r=e,l,n={type:"getter",getter:r,callback:t,deep:s,lastValue:l,effect:null,unwatch:null};this.#t.push(n);let a=()=>{let f=this.#t.indexOf(n);f!==-1&&this.#t.splice(f,1),n.effect&&(this.#s.forEach((d,p)=>{d.delete(n.effect),d.size===0&&this.#s.delete(p)}),this.#o.delete(n.effect))};n.unwatch=a;let o=()=>{let f=r.call(this);if(s?!this.#O(f,l):f!==l){let p=l;l=s&&f!==null&&typeof f=="object"?JSON.parse(JSON.stringify(f)):f,t(f,p,n.unwatch)}},u=this.#h(o);return n.effect=u,a}return()=>{}}unwatch(){[...this.#t].forEach(e=>e.unwatch()),this.#n.forEach(e=>{[...e.handlers].forEach(t=>t.unwatch())})}hasWatchers(){let e=0;return this.#n.forEach(t=>{e+=t.handlers.length}),this.#t.length+e}watched(e,t,i={}){if(typeof e=="string"&&e.endsWith("()")){let s=e.slice(0,-2),h=this.#n.get(s);h&&[...h.handlers].forEach(r=>r.unwatch())}else typeof e=="string"?this.#t.filter(s=>s.type==="key"&&s.key===e).forEach(s=>s.unwatch()):typeof e=="function"&&this.#t.filter(s=>s.type==="getter"&&s.getter===e).forEach(s=>s.unwatch());return this.watch(e,t,i)}#E(e){this.#f&&(this.#s.has(e)||this.#s.set(e,new Set),this.#s.get(e).add(this.#f))}#u(e){this.#g.add(e);let t=this.#s.get(e);if(t&&t.forEach(s=>this.#o.add(s)),this.#d){this.#x=!0;return}this.#d=!0;let i=()=>{this.#o.forEach(r=>{try{r()}catch(l){console.error("Effect execution error:",l)}}),this.#o.clear();let s=Array.from(this.#g),h=new Set;for(let r of s)for(let l of this.#t){if(l.type!=="key")continue;(l.key===r||l.deep&&(r===l.key||r.startsWith(l.key+".")))&&h.add(l)}for(let r of h){if(r.type!=="key")continue;let l=this.#V(r.key);if(!(r.deep?!this.#O(l,r.lastValue):l!==r.lastValue))continue;let a=r.lastValue;r.lastValue=r.deep&&l!==null&&typeof l=="object"?JSON.parse(JSON.stringify(l)):l;try{r.callback(l,a,r.unwatch)}catch(o){console.error("Watcher callback error:",o)}}this.#g.clear(),this.#d=!1,this.#x?(this.#x=!1,this.#d=!0,Promise.resolve().then(i)):this.#C.splice(0).forEach(r=>r())};Promise.resolve().then(i)}nextTick(){return this.#d?new Promise(e=>this.#C.push(e)):Promise.resolve()}#V(e){return e.split(".").reduce((t,i)=>t?.[i],this)}#O(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let h of i)if(!s.includes(h)||!this.#O(e[h],t[h]))return!1;return!0}static#I(e){return e!==null&&typeof e=="object"?e.__raw??e:e}#D=new WeakMap;#y(e,t=[]){if(e===null||typeof e!="object"||e.__isReactive)return e;let i=t.join("."),s=this.#D.get(e);if(s||this.#D.set(e,s=new Map),s.has(i))return s.get(i);let h=this,r=new Proxy(e,{get(l,n,a){if(n==="__isReactive")return!0;if(n==="__raw")return l;let o=typeof n=="symbol"?"<symbol>":n,u=[...t,o].join(".");h.#E(u);let f=Reflect.get(l,n,a);return f!==null&&typeof f=="object"&&!f.__isReactive?h.#y(f,[...t,o]):f},set(l,n,a,o){if(l[n]===a)return!0;let f=Reflect.set(l,n,a,o),d=typeof n=="symbol"?"<symbol>":n,p=[...t,d].join(".");if(h.#u(p),Array.isArray(l)&&(n==="length"||!isNaN(n))){let b=t.join(".");b&&h.#u(b)}return f},deleteProperty(l,n){let a=Reflect.deleteProperty(l,n),o=typeof n=="symbol"?"<symbol>":n,u=[...t,o].join(".");return h.#u(u),a}});return s.set(i,r),r}#H(e,t){let i=this;return new Proxy(e,{apply(s,h,r){let l=Reflect.apply(s,i,r);return i.#f?l:l instanceof Promise?l.then(n=>(i.#u(t),n)):(i.#u(t),l)}})}#h(e){let t=this.#r?{...this.#r}:null,i=()=>{let s=this.#f;this.#f=i;try{t?this.#m(t,e):e()}finally{this.#f=s}};return i(),i}static#B=new Map;static#S(e){let t=c.#B.get(e);return t||(t=new Function("$s","$event","$__v",`with($s) { ${e} }`),c.#B.set(e,t)),t}#Y=null;get#T(){return this.#Y??=new Proxy(this,{has:(e,t)=>typeof t=="string"&&t in e,get:(e,t)=>{if(t===Symbol.unscopables)return;let i=Reflect.get(e,t);return this.#Z(t,i),typeof i=="function"&&!Object.hasOwn(e,t)?i.bind(e):i},set:(e,t,i)=>Reflect.set(e,t,i)})}#J=new Set;#Z(e,t){if(typeof e!="string"||typeof t=="function"||this.#J.has(e)||this.#r&&e in this.#r)return;let i=Object.getOwnPropertyDescriptor(this,e);!i||!("value"in i)||(this.#J.add(e),console.warn(`<st-app app="${this.getAttribute("app")??""}">: \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E "${e}" \u043D\u0435 \u043E\u0431\u044A\u044F\u0432\u043B\u0435\u043D\u043E \u0432 \u043A\u043E\u043D\u0444\u0438\u0433\u0435 \u0438 \u043D\u0435 \u0440\u0435\u0430\u043A\u0442\u0438\u0432\u043D\u043E`))}#a(e){try{return c.#S(`return (${e});`).call(this,this.#T)}catch(t){console.warn("Expression evaluation error:",e,t);return}}#z(e,t=null){try{return c.#S(e).call(this,this.#T,t)}catch(i){console.error("Statement execution error:",e,i)}}#F(e,t){try{c.#S(`${e} = $__v;`).call(this,this.#T,null,t)}catch(i){console.error("Model binding error:",e,i)}}#_(e){let t=e.nodeValue,i=[],s=[],h=0,r=/\{\{(.+?)\}\}/g,l;for(;(l=r.exec(t))!==null;){l.index>h&&i.push(t.substring(h,l.index));let a=l[1].trim();i.push(null),s.push({index:i.length-1,expr:a}),h=r.lastIndex}h<t.length&&i.push(t.substring(h));let n=this.#h(()=>{s.forEach(({index:a,expr:o})=>{let u=this.#a(o);i[a]=u==null?"":String(u)}),e.nodeValue=i.join("")});this.#e.push({type:"text",node:e,effect:n})}#ee(e,t){let[i,...s]=t.name.slice(1).split("."),h=s.includes("self"),r=t.value,l=this.#r?{...this.#r}:null,n=a=>{h&&a.target!==e||(l?this.#m(l,()=>this.#z(r,a)):this.#z(r,a))};e.addEventListener(i,n),this.#e.push({type:"event",element:e,eventName:i,handler:n})}#te(e,t){let i=t.value,s=this.#h(()=>{let h=this.#a(i);e.innerHTML=h==null?"":String(h)});this.#e.push({type:"html",element:e,effect:s})}#ie(e,t){let i=t.value,s=this.#h(()=>{this.#a(i)?e.style.display="":e.style.display="none"});this.#e.push({type:"show",element:e,effect:s})}#se(e,t){let i=t.value,s=this.#h(()=>{let n=this.#a(i);if(e.tagName==="INPUT"&&e.type==="checkbox")e.checked=!!n;else if(e.tagName==="INPUT"&&e.type==="radio")e.checked=e.value===n;else if(e.tagName==="SELECT"){let a=()=>{e.value=n};c.#M.set(e,a),a(),queueMicrotask(a)}else e.value=n??""}),h=this.#r?{...this.#r}:null,r=e.tagName==="SELECT"?"change":"input",l=n=>{let a;e.type==="checkbox"?a=e.checked:e.type==="number"||e.type==="range"?a=e.valueAsNumber:a=e.value,h?this.#m(h,()=>this.#F(i,a)):this.#F(i,a)};e.addEventListener(r,l),this.#e.push({type:"model",element:e,effect:s,handler:l})}#re(e,t){let i=t.value,s=document.createComment(`if: ${i}`);e.parentNode.insertBefore(s,e),e.removeAttribute(t.name);let h=[{expr:i,template:e.cloneNode(!0)}],r=e.nextElementSibling;for(;r;)if(r.hasAttribute("#else-if")){let o=r.getAttribute("#else-if");r.removeAttribute("#else-if"),h.push({expr:o,template:r.cloneNode(!0)});let u=r.nextElementSibling;r.remove(),r=u}else if(r.hasAttribute("#else")){r.removeAttribute("#else"),h.push({expr:"true",template:r.cloneNode(!0)}),r.remove();break}else break;e.remove();let l={branch:null,node:null,bindings:[]},n=()=>{l.node?.remove(),this.#v(l.bindings),l.node=null,l.bindings=[]},a=this.#h(()=>{let o=h.find(f=>this.#a(f.expr))??null;if(l.branch===o||(n(),l.branch=o,!o))return;let u=o.template.cloneNode(!0);s.parentNode.insertBefore(u,s.nextSibling),l.bindings=this.#q(()=>this.#P(u)),l.node=u});this.#e.push({type:"conditional",placeholder:s,effect:a,dispose:n})}#q(e){let t=this.#e.length;return e(),this.#e.splice(t)}#m(e,t){let i={};for(let h of Object.keys(e))i[h]=this[h],this[h]=e[h];let s=this.#r;this.#r={...s,...e};try{return t()}finally{this.#r=s;for(let h of Object.keys(i))i[h]!==void 0?this[h]=i[h]:delete this[h]}}#le(e,t){let i=t.value,s=i.match(/^\s*(\w+)\s+in\s+(.+)$/);if(!s){console.error("Invalid for syntax:",i);return}let h=s[1],r=s[2],l=e.getAttribute("#key");e.removeAttribute(t.name),e.removeAttribute("#key");let n=document.createComment(`for: ${i}`);e.parentNode.insertBefore(n,e);let a=e.cloneNode(!0);e.remove();let o=a.outerHTML.includes("$index"),u=new Map,f=p=>{p.node.remove(),this.#v(p.bindings)},d=this.#h(()=>{let p=this.#a(r),b=[];Array.isArray(p)?b=p.map((m,y)=>({value:m,key:void 0,index:y})):p!==null&&typeof p=="object"&&(b=Object.entries(p).map(([m,y],E)=>({value:y,key:m,index:E})));let w=new Map,N=[];b.forEach(({value:m,key:y,index:E})=>{let O={[h]:m,$index:E};y!==void 0&&(O.$key=y);let g=l?this.#m(O,()=>this.#a(l)):Symbol();l&&w.has(g)&&console.warn("Duplicate #key in #for:",i,g);let v=u.get(g);if(v&&c.#I(v.value)===c.#I(m)&&(v.index===E||!o&&v.key===y&&!Array.isArray(p))){u.delete(g),w.set(g,v),N.push(v);return}let P=a.cloneNode(!0),M=this.#m(O,()=>this.#q(()=>this.#P(P))),j={node:P,bindings:M,value:m,index:E,key:y};w.set(g,j),N.push(j)}),u.forEach(f),u=w;let A=n;for(let m=N.length-1;m>=0;m--){let y=N[m].node;y.nextSibling!==A&&n.parentNode.insertBefore(y,A),A=y}let T=n.parentNode?.closest?.("select");T&&c.#M.get(T)?.()});this.#e.push({type:"loop",anchor:n,template:a,effect:d,dispose:()=>{u.forEach(f),u.clear()}})}#ne(e,t){let i=t.name,s=t.value,h=[],r=[],l=0,n=/\{\{(.+?)\}\}/g,a;for(;(a=n.exec(s))!==null;){a.index>l&&h.push(s.substring(l,a.index));let u=a[1].trim();h.push(null),r.push({index:h.length-1,expr:u}),l=n.lastIndex}l<s.length&&h.push(s.substring(l));let o=this.#h(()=>{r.forEach(({index:f,expr:d})=>{let p=this.#a(d);h[f]=p==null?"":String(p)});let u=h.join("");c.#X.has(i)?u===""||u==="false"||u==="0"||u==="null"||u==="undefined"||!u?e.removeAttribute(i):e.setAttribute(i,""):e.setAttribute(i,u)});this.#e.push({type:"attribute",element:e,attrName:i,effect:o})}#he(e){let t=Array.from(e.attributes);for(let i of t){if(i.name==="#if")return this.#re(e,i),e.removeAttribute(i.name),!0;if(i.name==="#for")return this.#le(e,i),e.removeAttribute(i.name),!0;if(i.name==="#html")return this.#te(e,i),e.removeAttribute(i.name),!0;if(i.name==="#show")this.#ie(e,i),e.removeAttribute(i.name);else if(i.name==="#model")this.#se(e,i),e.removeAttribute(i.name);else if(i.name==="#once")e.removeAttribute(i.name);else{if(i.name==="#pre")return e.removeAttribute(i.name),!0;i.name.startsWith("@")?(this.#ee(e,i),e.removeAttribute(i.name)):/\{\{.+?\}\}/.test(i.value)&&this.#ne(e,i)}}return!1}#P(e){if(e.nodeType===Node.ELEMENT_NODE){let t=this.#he(e);if(e.localName==="st-app")return;!t&&(e.parentNode||e.childNodes.length>0)&&this.#K(e)}else e.nodeType===Node.TEXT_NODE&&/\{\{.+?\}\}/.test(e.nodeValue)&&this.#_(e)}#K(e){for(let t of Array.from(e.childNodes))t.parentNode===e&&this.#P(t)}#U(){let e=this.attrs.get("app"),t=c.#b.get(e);if(t){this.addEventListener("setup",t.setup),Object.entries(t.events).forEach(([r,l])=>this.addEventListener(r,l)),this.#p=t.template;let i=t.config,s=Object.getOwnPropertyDescriptors(i),h=new Set(["app","setup","template","events"]);Object.entries(s).forEach(([r,l])=>{if(!h.has(r)){if(l.get){let n=l.get;this.#G.set(r,n),Object.defineProperty(this,r,{get(){return this.#E(r),n.call(this)},enumerable:l.enumerable,configurable:!0})}else if(l.value!==void 0){let n=l.value;n!==null&&this.#k.set(r,typeof n=="object"?"json":typeof n);let a=n;typeof n=="object"&&n!==null?a=this.#y(n,[r]):typeof n=="function"&&(a=this.#H(n,r)),Object.defineProperty(this,r,{get(){return this.#E(r),a},set(o){a!==o&&(typeof o=="object"&&o!==null?a=this.#y(o,[r]):a=o,this.#u(r))},enumerable:!0,configurable:!0})}}}),typeof this.#i=="function"&&this.#i(),this.#i=!0}else this.attrs.get("app")||(typeof this.#i=="function"&&this.#i(),this.#i=!0)}async#j(e){await Promise.all(e.map(t=>new Promise(i=>{let s=null,h=()=>{clearTimeout(s),s=setTimeout(()=>{r.disconnect(),this.#j(Array.from(t.children)).then(i)},0)},r=new MutationObserver(l=>{l.some(n=>n.type==="childList")&&h()});r.observe(t,{childList:!0}),h()})))}#w(e){return e==null?"":e===!0?"true":e===!1?"false":typeof e=="number"?String(e):typeof e=="object"?JSON.stringify(e):String(e)}#ae(e,t){if(e==="")return t&&t!=="string"?null:"";switch(t){case"string":return e;case"number":{let i=Number(e);return Number.isNaN(i)?e:i}case"boolean":return!["false","0","null","undefined"].includes(e);case"json":try{return JSON.parse(e)}catch{return e}}if(e==="true")return!0;if(e==="false")return!1;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);try{return JSON.parse(e)}catch{return e}}#N(e,t=!1){if(!e.startsWith(":"))return;let[i,s]=e.replace(/^:+/,"").split(".");i=i.replace(/-([a-z])/g,(n,a)=>a.toUpperCase());let h=this.getAttribute(e);if(h===null)return;let r=Object.getOwnPropertyDescriptor(this,i),l;if(h===""&&t&&r&&(r.get||r.value!==void 0)){l=this[i];let n=this.#w(l);h!==n&&this.setAttribute(e,n),r=null}else{if(r&&r.set===void 0&&r.writable===!1||r&&r.get!==void 0&&r.set===void 0||r&&this.#w(this[i])===h)return;l=this.#ae(h,s??this.#k.get(i))}if(!r||!r.set){let n=l;typeof l=="object"&&l!==null?n=this.#y(l,[i]):typeof l=="function"&&(n=this.#H(l,i));let a=e;if(Object.defineProperty(this,i,{get(){return this.#E(i),n},set(o){if(n!==o){typeof o=="object"&&o!==null?n=this.#y(o,[i]):n=o,this.#u(i);let u=this.#w(o);this.getAttribute(a)!==u&&this.setAttribute(a,u)}},enumerable:!0,configurable:!0}),typeof l=="object"&&l!==null){let o=this.watch(i,()=>{let u=this[i],f=this.#w(u);this.getAttribute(e)!==f&&this.setAttribute(e,f)},{deep:!0});this.#e.push({type:"attrSync",unwatch:o})}}else this[i]=l}attributeChangedCallback(e,t,i){e.startsWith(":")&&e!=="app"&&t!==i&&this.#i===!0&&this.#N(e)}connectedCallback(){if(c.#c.add(this),this.#i===!0){this.#A&&(this.#A=!1,this.applyTemplate(this.#W)),this.#l||(this.#l=new MutationObserver(t=>{for(let i of t)i.type==="attributes"&&i.attributeName&&i.attributeName.startsWith(":")&&i.attributeName!=="app"&&this.#N(i.attributeName)}),this.#l.observe(this,{attributes:!0}));return}let e=this.parentElement?.closest("st-app");if(e&&!e.#R){c.#c.delete(this);return}this.#U(),Promise.all([new Promise(t=>{if(this.#i===!0)return t();this.#i=t}),new Promise(t=>{let i=null,s=()=>{clearTimeout(i),i=setTimeout(()=>{h.disconnect(),this.#j(Array.from(this.children)).then(t)},0)},h=new MutationObserver(r=>{r.some(l=>l.type==="childList")&&s()});h.observe(this,{childList:!0}),s()})]).then(()=>{this.dispatchEvent("setup");for(let i of this.attrs.keys())i.startsWith(":")&&this.#N(i,!0);let t=!1;this.childNodes.length>0&&Array.from(this.childNodes).some(s=>s.nodeType===Node.ELEMENT_NODE||s.nodeType===Node.TEXT_NODE&&s.textContent.trim()!=="")&&(this.#p?(this.applyTemplate(this.innerHTML),t=!0):this.#p=this.innerHTML),t||this.applyTemplate(),this.#i===!0&&!this.#l&&(this.#l=new MutationObserver(i=>{for(let s of i)s.type==="attributes"&&s.attributeName&&s.attributeName.startsWith(":")&&s.attributeName!=="app"&&this.#N(s.attributeName)}),this.#l.observe(this,{attributes:!0}))})}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||this.#oe()})}#oe(){this.#A=!0,this.#l&&(this.#l.disconnect(),this.#l=null),this.#v(this.#e),this.#e=[];for(let e of this.#t)e.type==="getter"&&e.effect&&(this.#s.forEach((t,i)=>{t.delete(e.effect),t.size===0&&this.#s.delete(i)}),this.#o.delete(e.effect));this.#t=[],this.#n.forEach((e,t)=>{this[t]=e.original}),this.#n.clear(),this.#g.clear(),this.#s.clear(),this.#o.clear(),c.#c.delete(this)}toggleAttribute(e,...t){return t.length<=1&&(t[0]===void 0||typeof t[0]=="boolean")?super.toggleAttribute(e,...t):this.cycleAttribute(e,...t)}cycleAttribute(e,t="",i=""){let s=this.getAttribute(e);this[t==""&&i==""&&(s||this.hasAttribute(e))?"removeAttribute":"setAttribute"](e,s!=t?t:i)}static{customElements.define("st-app",this)}};return R(V);})();
|
|
1
|
+
var App=(()=>{var j=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var $=(f,e)=>{for(var t in e)j(f,t,{get:e[t],enumerable:!0})},W=(f,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of C(e))!k.call(f,s)&&s!==t&&j(f,s,{get:()=>e[s],enumerable:!(i=L(e,s))||i.enumerable});return f};var R=f=>W(j({},"__esModule",{value:!0}),f);var V={};$(V,{default:()=>N});var N=class f extends HTMLElement{static#_=new Set(["disabled","checked","readonly","required","selected","hidden","open","autofocus"]);static#ee=new Set(["checked","selected","value"]);static#v=new Map;static#c=new Set;static#$=new WeakMap;static#W=new WeakMap;static#p={};static helpers(e={}){return Object.assign(f.#p,e),f.#p}static toRaw(e){return f.#A(e)}static snapshot(e,t=new WeakMap){if(e=f.#A(e),e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);let i=Object.getPrototypeOf(e);if(Array.isArray(e)){let r=[];return t.set(e,r),e.forEach(l=>r.push(f.snapshot(l,t))),r}if(i!==Object.prototype&&i!==null)return e;let s={};t.set(e,s);for(let r of Object.keys(e))s[r]=f.snapshot(e[r],t);return s}static create(e){let{app:t,setup:i=()=>{},template:s="",events:r={}}=e;if(f.#v.has(t))throw new Error(`Application "${t}" already exists!`);f.#v.set(t,{setup:i,template:s,events:r,config:e}),f.#c.forEach(l=>{l.#i!==!0&&l.#Z()})}static extend(e,t={}){let i=f.#v.get(e);if(!i)throw new Error(`Application "${e}" not found!`);let s=i.config,r=Object.defineProperties({},{...Object.getOwnPropertyDescriptors(s),...Object.getOwnPropertyDescriptors(t)});return(s.events||t.events)&&(r.events={...s.events,...t.events}),(s.helpers||t.helpers)&&(r.helpers={...s.helpers,...t.helpers}),f.create(r)}#i=!1;#d="";#R=!1;#s=new Map;#u=null;#o=new Set;#y=!1;#e=[];#r=null;#te=new Map;#l=null;#t=[];#E=new Set;#S=!1;#V=[];#I=new Map;#a=new Map;#D=0;#B="";#T=!1;#H=!1;#w={};#b=new WeakMap;constructor(){super(),f.#c.add(this)}#N(e){!e||!e.length||e.forEach(t=>{if(t.type==="event"&&t.element&&t.handler)setTimeout(()=>t.element.removeEventListener(t.eventName,t.handler));else if(t.type==="model"&&t.element&&t.handler){let i=t.element.tagName==="SELECT"?"change":"input";setTimeout(()=>t.element.removeEventListener(i,t.handler))}else t.type==="attrSync"&&t.unwatch&&t.unwatch();t.dispose?.(),t.effect&&(this.#J(t.effect),this.#o.delete(t.effect),this.#se(t.effect))})}#J(e){this.#s.forEach((t,i)=>{t.delete(e),t.size===0&&this.#s.delete(i)})}#ie(e,t){for(let i=t;i;i=Object.getPrototypeOf(i)){let s=this.#b.get(i);s||this.#b.set(i,s=new Set),s.add(e)}}#se(e){for(let t=e.ctx;t;t=Object.getPrototypeOf(t))this.#b.get(t)?.delete(e)}get template(){return this.#d}get attrs(){return{get:e=>this.getAttribute(e),set:(e,t)=>this.setAttribute(e,t),remove:e=>this.removeAttribute(e),has:e=>this.hasAttribute(e),toggle:(e,t)=>this.toggleAttribute(e,t),keys:()=>Array.from(this.attributes).map(e=>e.name),entries:()=>Array.from(this.attributes).map(e=>[e.name,e.value])}}addEventListener(e,t,i){if((e==="setup"||e==="rendered")&&this.#R){queueMicrotask(()=>{let s=new CustomEvent(e);typeof t=="function"?t.call(this,s):t?.handleEvent?.(s)});return}super.addEventListener(e,t,i)}dispatchEvent(e,t=null,i={}){if(typeof e=="string"){let s=new CustomEvent(e,{cancelable:!0,...i,detail:t});return super.dispatchEvent(s)}return super.dispatchEvent(e)}applyTemplate(e=""){let t=e||this.#d;if(this.#H=!0,this.#B=t,this.#N(this.#e),this.#e=[],this.innerHTML="",t){let s=document.createElement("template");s.innerHTML=t.trim();let r=s.content.cloneNode(!0);this.#Y(r),this.#re(r)}let i=++this.#D;new Promise(s=>{let r=null,l,n=()=>{clearTimeout(r),r=setTimeout(()=>{l.disconnect(),this.#k(Array.from(this.children)).then(s)},0)};l=new MutationObserver(h=>{h.some(a=>a.type==="childList")&&n()}),l.observe(this,{childList:!0}),n()}).then(()=>{i===this.#D&&(this.#R=!0,this.dispatchEvent("rendered"))})}#re(e){HTMLElement.prototype.appendChild.call(this,e)}clone(e={}){let t=this.attrs.get("app");return f.extend(t,e)}watch(e,t,i={}){if(typeof t!="function")return()=>{};let{deep:s=!1,immediate:r=!1}=i;if(typeof e=="string"&&e.endsWith("()")){let l=e.slice(0,-2),n=this[l];if(typeof n!="function")return()=>{};let h=this.#a.get(l);if(!h){h={original:n,handlers:[]},this.#a.set(l,h);let o=(...u)=>{let c=n.apply(this,u),p=d=>{for(let y of[...h.handlers])y.callback(u,d,y.unwatch)};return c instanceof Promise?c.then(d=>(p(d),d)):(p(c),c)};this[l]=o}let a=()=>{let o=h.handlers.findIndex(u=>u.unwatch===a);o!==-1&&h.handlers.splice(o,1),h.handlers.length===0&&(this[l]=h.original,this.#a.delete(l))};return h.handlers.push({callback:t,unwatch:a}),a}if(typeof e=="string"){let l=e,n=()=>{let a=this.#t.findIndex(o=>o.unwatch===n);a!==-1&&this.#t.splice(a,1)},h={type:"key",key:l,callback:t,deep:s,immediate:r,lastValue:void 0,unwatch:n};if(this.#t.push(h),r){let a=this.#z(l);h.lastValue=s&&a!==null&&typeof a=="object"?JSON.parse(JSON.stringify(a)):a,t(a,void 0,n)}return n}if(typeof e=="function"){let l=e,n,h={type:"getter",getter:l,callback:t,deep:s,lastValue:n,effect:null,unwatch:null};this.#t.push(h);let a=()=>{let c=this.#t.indexOf(h);c!==-1&&this.#t.splice(c,1),h.effect&&(this.#s.forEach((p,d)=>{p.delete(h.effect),p.size===0&&this.#s.delete(d)}),this.#o.delete(h.effect))};h.unwatch=a;let o=()=>{let c=l.call(this);if(s?!this.#P(c,n):c!==n){let d=n;n=s&&c!==null&&typeof c=="object"?JSON.parse(JSON.stringify(c)):c,t(c,d,h.unwatch)}},u=this.#n(o);return h.effect=u,a}return()=>{}}unwatch(){[...this.#t].forEach(e=>e.unwatch()),this.#a.forEach(e=>{[...e.handlers].forEach(t=>t.unwatch())})}hasWatchers(){let e=0;return this.#a.forEach(t=>{e+=t.handlers.length}),this.#t.length+e}watched(e,t,i={}){if(typeof e=="string"&&e.endsWith("()")){let s=e.slice(0,-2),r=this.#a.get(s);r&&[...r.handlers].forEach(l=>l.unwatch())}else typeof e=="string"?this.#t.filter(s=>s.type==="key"&&s.key===e).forEach(s=>s.unwatch()):typeof e=="function"&&this.#t.filter(s=>s.type==="getter"&&s.getter===e).forEach(s=>s.unwatch());return this.watch(e,t,i)}#x(e){this.#u&&(this.#s.has(e)||this.#s.set(e,new Set),this.#s.get(e).add(this.#u))}#f(e){this.#E.add(e);let t=this.#s.get(e);if(t&&t.forEach(s=>this.#o.add(s)),this.#y){this.#S=!0;return}this.#y=!0;let i=()=>{this.#o.forEach(l=>{try{l()}catch(n){console.error("Effect execution error:",n)}}),this.#o.clear();let s=Array.from(this.#E),r=new Set;for(let l of s)for(let n of this.#t){if(n.type!=="key")continue;(n.key===l||n.deep&&(l===n.key||l.startsWith(n.key+".")))&&r.add(n)}for(let l of r){if(l.type!=="key")continue;let n=this.#z(l.key);if(!(l.deep?!this.#P(n,l.lastValue):n!==l.lastValue))continue;let a=l.lastValue;l.lastValue=l.deep&&n!==null&&typeof n=="object"?JSON.parse(JSON.stringify(n)):n;try{l.callback(n,a,l.unwatch)}catch(o){console.error("Watcher callback error:",o)}}this.#E.clear(),this.#y=!1,this.#S?(this.#S=!1,this.#y=!0,Promise.resolve().then(i)):this.#V.splice(0).forEach(l=>l())};Promise.resolve().then(i)}nextTick(){return this.#y?new Promise(e=>this.#V.push(e)):Promise.resolve()}#z(e){return e.split(".").reduce((t,i)=>t?.[i],this)}#P(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let r of i)if(!s.includes(r)||!this.#P(e[r],t[r]))return!1;return!0}static#A(e){return e!==null&&typeof e=="object"?e.__raw??e:e}#F=new WeakMap;#m(e,t=[]){if(e===null||typeof e!="object"||e.__isReactive)return e;let i=t.join("."),s=this.#F.get(e);if(s||this.#F.set(e,s=new Map),s.has(i))return s.get(i);let r=this,l=new Proxy(e,{get(n,h,a){if(h==="__isReactive")return!0;if(h==="__raw")return n;let o=typeof h=="symbol"?"<symbol>":h,u=[...t,o].join(".");r.#x(u);let c=Reflect.get(n,h,a);return c!==null&&typeof c=="object"&&!c.__isReactive?r.#m(c,[...t,o]):c},set(n,h,a,o){if(n[h]===a)return!0;let c=Reflect.set(n,h,a,o),p=typeof h=="symbol"?"<symbol>":h,d=[...t,p].join(".");if(r.#f(d),Array.isArray(n)&&(h==="length"||!isNaN(h))){let y=t.join(".");y&&r.#f(y)}return c},deleteProperty(n,h){let a=Reflect.deleteProperty(n,h),o=typeof h=="symbol"?"<symbol>":h,u=[...t,o].join(".");return r.#f(u),a}});return s.set(i,l),l}#q(e,t){let i=this;return new Proxy(e,{apply(s,r,l){let n=Reflect.apply(s,i,l);return i.#u?n:n instanceof Promise?n.then(h=>(i.#f(t),h)):(i.#f(t),n)}})}#n(e){let t=this.#r,i=()=>{let s=this.#u;this.#u=i;try{t?this.#g(t,e):e()}finally{this.#u=s}};return t&&(i.ctx=t,this.#ie(i,t)),i(),i}static#K=new Map;static#M(e){let t=f.#K.get(e);return t||(t=new Function("$s","$event","$__v",`with($s) { ${e} }`),f.#K.set(e,t)),t}#le=null;get#L(){return this.#le??=new Proxy(this,{has:(e,t)=>typeof t=="string"&&(t in e||t in this.#w||t in f.#p),get:(e,t)=>{if(t===Symbol.unscopables)return;if(typeof t=="string"&&!(t in e)){if(t in this.#w)return this.#w[t];if(t in f.#p)return f.#p[t]}let i=Reflect.get(e,t);return this.#ne(t,i),typeof i=="function"&&!Object.hasOwn(e,t)?i.bind(e):i},set:(e,t,i)=>Reflect.set(e,t,i)})}#U=new Set;#ne(e,t){if(typeof e!="string"||typeof t=="function"||this.#U.has(e)||this.#r&&e in this.#r)return;let i=Object.getOwnPropertyDescriptor(this,e);!i||!("value"in i)||(this.#U.add(e),console.warn(`<st-app app="${this.getAttribute("app")??""}">: \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E "${e}" \u043D\u0435 \u043E\u0431\u044A\u044F\u0432\u043B\u0435\u043D\u043E \u0432 \u043A\u043E\u043D\u0444\u0438\u0433\u0435 \u0438 \u043D\u0435 \u0440\u0435\u0430\u043A\u0442\u0438\u0432\u043D\u043E`))}#h(e){try{return f.#M(`return (${e});`).call(this,this.#L)}catch(t){console.warn("Expression evaluation error:",e,t);return}}#X(e,t=null){try{return f.#M(e).call(this,this.#L,t)}catch(i){console.error("Statement execution error:",e,i)}}#G(e,t){try{f.#M(`${e} = $__v;`).call(this,this.#L,null,t)}catch(i){console.error("Model binding error:",e,i)}}#he(e){let t=e.nodeValue,i=[],s=[],r=0,l=/\{\{(.+?)\}\}/g,n;for(;(n=l.exec(t))!==null;){n.index>r&&i.push(t.substring(r,n.index));let a=n[1].trim();i.push(null),s.push({index:i.length-1,expr:a}),r=l.lastIndex}r<t.length&&i.push(t.substring(r));let h=this.#n(()=>{s.forEach(({index:a,expr:o})=>{let u=this.#h(o);i[a]=u==null?"":String(u)}),e.nodeValue=i.join("")});this.#e.push({type:"text",node:e,effect:h})}#ae(e,t){let[i,...s]=t.name.slice(1).split("."),r=s.includes("self"),l=t.value,n=this.#r,h=a=>{r&&a.target!==e||(n?this.#g(n,()=>this.#X(l,a)):this.#X(l,a))};e.addEventListener(i,h),this.#e.push({type:"event",element:e,eventName:i,handler:h})}#oe(e,t){let i=t.value,s=this.#n(()=>{let r=this.#h(i);e.innerHTML=r==null?"":String(r)});this.#e.push({type:"html",element:e,effect:s})}#fe(e,t){let i=t.value,s=this.#n(()=>{this.#h(i)?e.style.display="":e.style.display="none"});this.#e.push({type:"show",element:e,effect:s})}#ue(e,t){let i=t.value,s=new Set;f.#W.set(e,s);let r=this.#n(()=>{let l=this.#h(i),n=new Set,h=a=>String(a).split(/\s+/).filter(Boolean).forEach(o=>n.add(o));Array.isArray(l)?l.forEach(a=>a&&h(a)):l&&typeof l=="object"?Object.entries(l).forEach(([a,o])=>o&&h(a)):l&&h(l),s.forEach(a=>n.has(a)||e.classList.remove(a)),n.forEach(a=>e.classList.add(a)),s.clear(),n.forEach(a=>s.add(a))});this.#e.push({type:"class",element:e,effect:r})}#ce(e,t){let i=t.value,s=this.#n(()=>{let h=this.#h(i);if(e.tagName==="INPUT"&&e.type==="checkbox")e.checked=!!h;else if(e.tagName==="INPUT"&&e.type==="radio")e.checked=e.value===h;else if(e.tagName==="SELECT"){let a=()=>{e.value=h};f.#$.set(e,a),a(),queueMicrotask(a)}else e.value=h??""}),r=this.#r,l=e.tagName==="SELECT"?"change":"input",n=h=>{let a;e.type==="checkbox"?a=e.checked:e.type==="number"||e.type==="range"?a=e.value===""?null:e.valueAsNumber:a=e.value,r?this.#g(r,()=>this.#G(i,a)):this.#G(i,a)};e.addEventListener(l,n),this.#e.push({type:"model",element:e,effect:s,handler:n})}#pe(e,t){let i=t.value,s=document.createComment(`if: ${i}`);e.parentNode.insertBefore(s,e),e.removeAttribute(t.name);let r=[{expr:i,template:e.cloneNode(!0)}],l=e.nextElementSibling;for(;l;)if(l.hasAttribute("#else-if")){let o=l.getAttribute("#else-if");l.removeAttribute("#else-if"),r.push({expr:o,template:l.cloneNode(!0)});let u=l.nextElementSibling;l.remove(),l=u}else if(l.hasAttribute("#else")){l.removeAttribute("#else"),r.push({expr:"true",template:l.cloneNode(!0)}),l.remove();break}else break;e.remove();let n={branch:null,node:null,bindings:[]},h=()=>{n.node?.remove(),this.#N(n.bindings),n.node=null,n.bindings=[]},a=this.#n(()=>{let o=r.find(c=>this.#h(c.expr))??null;if(n.branch===o||(h(),n.branch=o,!o))return;let u=o.template.cloneNode(!0);s.parentNode.insertBefore(u,s.nextSibling),n.bindings=this.#Q(()=>this.#C(u)),n.node=u});this.#e.push({type:"conditional",placeholder:s,effect:a,dispose:h})}#Q(e){let t=this.#e.length;return e(),this.#e.splice(t)}#de(e){return Object.assign(Object.create(this.#r??null),e)}#g(e,t){let i={};for(let r in e)i[r]=this[r],this[r]=e[r];let s=this.#r;this.#r=e;try{return t()}finally{this.#r=s;for(let r of Object.keys(i))i[r]!==void 0?this[r]=i[r]:delete this[r]}}#ye(e,t){Object.assign(e.ctx,t);let i=[...this.#b.get(e.ctx)??[]];i.forEach(s=>this.#J(s)),i.forEach(s=>{this.#b.get(e.ctx)?.has(s)&&s()})}#be(e,t){let i=t.value,s=i.match(/^\s*(\w+)\s+in\s+(.+)$/);if(!s){console.error("Invalid for syntax:",i);return}let r=s[1],l=s[2],n=e.getAttribute("#key");e.removeAttribute(t.name),e.removeAttribute("#key");let h=document.createComment(`for: ${i}`);e.parentNode.insertBefore(h,e);let a=e.cloneNode(!0);e.remove();let o=new Map,u=p=>{p.node.remove(),this.#N(p.bindings)},c=this.#n(()=>{let p=this.#h(l),d=[];Array.isArray(p)?d=p.map((b,m)=>({value:b,key:void 0,index:m})):p!==null&&typeof p=="object"&&(d=Object.entries(p).map(([b,m],v)=>({value:m,key:b,index:v})));let y=new Map,w=[];d.forEach(({value:b,key:m,index:v})=>{let A={[r]:b,$index:v};m!==void 0&&(A.$key=m);let O=this.#de(A),E=n?this.#g(O,()=>this.#h(n)):Symbol();n&&y.has(E)&&console.warn("Duplicate #key in #for:",i,E);let g=o.get(E);if(g&&f.#A(g.value)===f.#A(b)){o.delete(E),(g.value!==b||g.index!==v||g.key!==m)&&(Object.assign(g,{value:b,index:v,key:m}),this.#ye(g,A)),y.set(E,g),w.push(g);return}let T=a.cloneNode(!0),M=this.#g(O,()=>this.#Q(()=>this.#C(T))),P={node:T,bindings:M,value:b,index:v,key:m,ctx:O};y.set(E,P),w.push(P)}),o.forEach(u),o=y;let x=h;for(let b=w.length-1;b>=0;b--){let m=w[b].node;m.nextSibling!==x&&h.parentNode.insertBefore(m,x),x=m}let S=h.parentNode?.closest?.("select");S&&f.#$.get(S)?.()});this.#e.push({type:"loop",anchor:h,template:a,effect:c,dispose:()=>{o.forEach(u),o.clear()}})}#me(e,t){let i=t.name,s=t.value,r=[],l=[],n=0,h=/\{\{(.+?)\}\}/g,a;for(;(a=h.exec(s))!==null;){a.index>n&&r.push(s.substring(n,a.index));let u=a[1].trim();r.push(null),l.push({index:r.length-1,expr:u}),n=h.lastIndex}n<s.length&&r.push(s.substring(n));let o=this.#n(()=>{l.forEach(({index:p,expr:d})=>{let y=this.#h(d);r[p]=y==null?"":String(y)});let u=r.join(""),c=f.#ee.has(i)&&i in e&&(i!=="value"||e.tagName==="INPUT");if(f.#_.has(i)){let p=u===""||u==="false"||u==="0"||u==="null"||u==="undefined"||!u;p?e.removeAttribute(i):e.setAttribute(i,""),c&&(e[i]=!p)}else e.setAttribute(i,u),i==="class"&&f.#W.get(e)?.forEach(p=>e.classList.add(p)),c&&e.value!==u&&(e.value=u)});this.#e.push({type:"attribute",element:e,attrName:i,effect:o})}#ge(e){let t=Array.from(e.attributes),i=t.find(r=>r.name==="#pre"||r.name==="#if"||r.name==="#for");if(i?.name==="#pre")return e.removeAttribute("#pre"),!0;if(i?.name==="#if")return this.#pe(e,i),!0;if(i?.name==="#for")return this.#be(e,i),!0;let s=!1;for(let r of t)r.name==="#html"?(this.#oe(e,r),e.removeAttribute(r.name),s=!0):r.name==="#class"?(this.#ue(e,r),e.removeAttribute(r.name)):r.name==="#show"?(this.#fe(e,r),e.removeAttribute(r.name)):r.name==="#model"?(this.#ce(e,r),e.removeAttribute(r.name)):r.name==="#once"?e.removeAttribute(r.name):r.name.startsWith("@")?(this.#ae(e,r),e.removeAttribute(r.name)):/\{\{.+?\}\}/.test(r.value)&&this.#me(e,r);return s}#C(e){if(e.nodeType===Node.ELEMENT_NODE){let t=this.#ge(e);if(e.localName==="st-app")return;!t&&(e.parentNode||e.childNodes.length>0)&&this.#Y(e)}else e.nodeType===Node.TEXT_NODE&&/\{\{.+?\}\}/.test(e.nodeValue)&&this.#he(e)}#Y(e){for(let t of Array.from(e.childNodes))t.parentNode===e&&this.#C(t)}#Z(){let e=this.attrs.get("app"),t=f.#v.get(e);if(t){this.addEventListener("setup",t.setup),Object.entries(t.events).forEach(([l,n])=>this.addEventListener(l,n)),this.#d=t.template;let i=t.config;this.#w=i.helpers??{};let s=Object.getOwnPropertyDescriptors(i),r=new Set(["app","setup","template","events","helpers"]);Object.entries(s).forEach(([l,n])=>{if(!r.has(l)){if(n.get){let h=n.get;this.#te.set(l,h),Object.defineProperty(this,l,{get(){return this.#x(l),h.call(this)},enumerable:n.enumerable,configurable:!0})}else if(n.value!==void 0){let h=n.value;h!==null&&this.#I.set(l,typeof h=="object"?"json":typeof h);let a=h;typeof h=="object"&&h!==null?a=this.#m(h,[l]):typeof h=="function"&&(a=this.#q(h,l)),Object.defineProperty(this,l,{get(){return this.#x(l),a},set(o){a!==o&&(typeof o=="object"&&o!==null?a=this.#m(o,[l]):a=o,this.#f(l))},enumerable:!0,configurable:!0})}}}),typeof this.#i=="function"&&this.#i(),this.#i=!0}else this.attrs.get("app")||(typeof this.#i=="function"&&this.#i(),this.#i=!0)}async#k(e){await Promise.all(e.map(t=>new Promise(i=>{let s=null,r=()=>{clearTimeout(s),s=setTimeout(()=>{l.disconnect(),this.#k(Array.from(t.children)).then(i)},0)},l=new MutationObserver(n=>{n.some(h=>h.type==="childList")&&r()});l.observe(t,{childList:!0}),r()})))}#O(e){return e==null?"":e===!0?"true":e===!1?"false":typeof e=="number"?String(e):typeof e=="object"?JSON.stringify(e):String(e)}#ve(e,t){if(e==="")return t&&t!=="string"?null:"";switch(t){case"string":return e;case"number":{let i=Number(e);return Number.isNaN(i)?e:i}case"boolean":return!["false","0","null","undefined"].includes(e);case"json":try{return JSON.parse(e)}catch{return e}}if(e==="true")return!0;if(e==="false")return!1;if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);try{return JSON.parse(e)}catch{return e}}#j(e,t=!1){if(!e.startsWith(":"))return;let[i,s]=e.replace(/^:+/,"").split(".");i=i.replace(/-([a-z])/g,(h,a)=>a.toUpperCase());let r=this.getAttribute(e);if(r===null)return;let l=Object.getOwnPropertyDescriptor(this,i),n;if(r===""&&t&&l&&(l.get||l.value!==void 0)){n=this[i];let h=this.#O(n);r!==h&&this.setAttribute(e,h),l=null}else{if(l&&l.set===void 0&&l.writable===!1||l&&l.get!==void 0&&l.set===void 0||l&&this.#O(this[i])===r)return;n=this.#ve(r,s??this.#I.get(i))}if(!l||!l.set){let h=n;typeof n=="object"&&n!==null?h=this.#m(n,[i]):typeof n=="function"&&(h=this.#q(n,i));let a=e;if(Object.defineProperty(this,i,{get(){return this.#x(i),h},set(o){if(h!==o){typeof o=="object"&&o!==null?h=this.#m(o,[i]):h=o,this.#f(i);let u=this.#O(o);this.getAttribute(a)!==u&&this.setAttribute(a,u)}},enumerable:!0,configurable:!0}),typeof n=="object"&&n!==null){let o=this.watch(i,()=>{let u=this[i],c=this.#O(u);this.getAttribute(e)!==c&&this.setAttribute(e,c)},{deep:!0});this.#e.push({type:"attrSync",unwatch:o})}}else this[i]=n}attributeChangedCallback(e,t,i){e.startsWith(":")&&e!=="app"&&t!==i&&this.#i===!0&&this.#j(e)}connectedCallback(){if(f.#c.add(this),this.#i===!0){this.#T&&(this.#T=!1,this.applyTemplate(this.#B)),this.#l||(this.#l=new MutationObserver(t=>{for(let i of t)i.type==="attributes"&&i.attributeName&&i.attributeName.startsWith(":")&&i.attributeName!=="app"&&this.#j(i.attributeName)}),this.#l.observe(this,{attributes:!0}));return}let e=this.parentElement?.closest("st-app");if(e&&!e.#H){f.#c.delete(this);return}this.#Z(),Promise.all([new Promise(t=>{if(this.#i===!0)return t();this.#i=t}),new Promise(t=>{let i=null,s=()=>{clearTimeout(i),i=setTimeout(()=>{r.disconnect(),this.#k(Array.from(this.children)).then(t)},0)},r=new MutationObserver(l=>{l.some(n=>n.type==="childList")&&s()});r.observe(this,{childList:!0}),s()})]).then(()=>{this.dispatchEvent("setup");for(let i of this.attrs.keys())i.startsWith(":")&&this.#j(i,!0);let t=!1;this.childNodes.length>0&&Array.from(this.childNodes).some(s=>s.nodeType===Node.ELEMENT_NODE||s.nodeType===Node.TEXT_NODE&&s.textContent.trim()!=="")&&(this.#d?(this.applyTemplate(this.innerHTML),t=!0):this.#d=this.innerHTML),t||this.applyTemplate(),this.#i===!0&&!this.#l&&(this.#l=new MutationObserver(i=>{for(let s of i)s.type==="attributes"&&s.attributeName&&s.attributeName.startsWith(":")&&s.attributeName!=="app"&&this.#j(s.attributeName)}),this.#l.observe(this,{attributes:!0}))})}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||this.#Ee()})}#Ee(){this.#T=!0,this.#l&&(this.#l.disconnect(),this.#l=null),this.#N(this.#e),this.#e=[];for(let e of this.#t)e.type==="getter"&&e.effect&&(this.#s.forEach((t,i)=>{t.delete(e.effect),t.size===0&&this.#s.delete(i)}),this.#o.delete(e.effect));this.#t=[],this.#a.forEach((e,t)=>{this[t]=e.original}),this.#a.clear(),this.#E.clear(),this.#s.clear(),this.#o.clear(),f.#c.delete(this)}toggleAttribute(e,...t){return t.length<=1&&(t[0]===void 0||typeof t[0]=="boolean")?super.toggleAttribute(e,...t):this.cycleAttribute(e,...t)}cycleAttribute(e,t="",i=""){let s=this.getAttribute(e);this[t==""&&i==""&&(s||this.hasAttribute(e))?"removeAttribute":"setAttribute"](e,s!=t?t:i)}static{customElements.define("st-app",this)}};return R(V);})();
|
|
2
2
|
if(typeof App!=="undefined"&&App&&App.default)globalThis.App=App.default;
|