solely 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,i,s)=>((e,i,s)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s)(e,"symbol"!=typeof i?i+"":i,s);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./core.cjs"),s=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;let r=class extends s.default{constructor(){super(...arguments),e(this,"unsubscribe"),e(this,"level",0),e(this,"currentElement",null),e(this,"currentTagName",null),e(this,"routerAttrs",new Set),e(this,"prevPropKeys",new Set),e(this,"scheduled",!1),e(this,"cache",new Map),e(this,"latestLoadId",0)}async mounted(){this.detectLevel();const t=await i.routerReady;this.unsubscribe=t.listen(()=>{this.scheduleLoad(t.getCurrentRoute())}),this.loadRoute(t.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this),this.cache.forEach(t=>t.remove()),this.cache.clear()}scheduleLoad(t){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t)}))}detectLevel(){let t=0,e=this.parentElement;for(;e;)e instanceof r&&t++,e=e.parentElement;this.level=t}async loadRoute(t){const e=++this.latestLoadId,i=null==t?void 0:t.matched[this.level];if(!i)return void this.handleEmptyRoute();const{config:s}=i;let n=s.tagName;if(!n&&"function"==typeof s.component){this.renderLoading();try{const t=await s.component();n="string"==typeof t?t:t.tagName}catch(o){return void this.renderError(`Load Error: ${o}`)}}if(e!==this.latestLoadId)return;if(!n)return void this.clear();if(!s.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props);this.clear(s.keepAlive);const r=this.getOrCreateComponent(n,s);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},s.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,e){const i=t.toLowerCase();if(e.keepAlive&&this.cache.has(i))return this.cache.get(i);const s=document.createElement(t);return e.keepAlive&&this.cache.set(i,s),s}syncState(t,e,i,s={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(e).forEach(([t,e])=>r.set(n(t),String(e))),Object.entries(i).forEach(([t,e])=>r.set(`query-${n(t)}`,String(e))),this.routerAttrs.forEach(e=>{r.has(e)||(t.removeAttribute(e),this.routerAttrs.delete(e))}),r.forEach((e,i)=>{t.getAttribute(i)!==e&&t.setAttribute(i,e),this.routerAttrs.add(i)});const o=new Set(Object.keys(s));this.prevPropKeys.forEach(e=>{o.has(e)||(t[e]=void 0)}),Object.entries(s).forEach(([e,i])=>{t[e]!==i&&(t[e]=i)}),this.prevPropKeys=o}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.innerHTML='<div style="padding:20px; color:#999;">Loading...</div>'}renderError(t){this.innerHTML=`<div style="padding:20px; color:#ff4d4f;">${t}</div>`}clear(t=!1){this.currentElement?this.contains(this.currentElement)&&this.removeChild(this.currentElement):t||(this.innerHTML=""),this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};r=((t,e)=>{for(var i,s=e,n=t.length-1;n>=0;n--)(i=t[n])&&(s=i(s)||s);return s})([n.CustomElement({tagName:"router-view"})],r);const o=r;exports.default=o;
1
+ "use strict";var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./core.cjs"),e=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const r=new Map;let h=class extends e.default{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s.routerReady,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof h&&t++,i=i.parentElement;this.level=t}async loadRoute(t){this.abortController&&(this.abortController.abort(),this.abortController=null);const i=++this.latestLoadId,s=null==t?void 0:t.matched[this.level];if(!s)return void this.handleEmptyRoute();const{config:e}=s;let n=e.tagName;if(!n&&"function"==typeof e.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const t=this.abortController.signal;try{const s=await e.component();if(t.aborted||i!==this.latestLoadId)return;n="string"==typeof s?s:s.tagName}catch(h){if(t.aborted||i!==this.latestLoadId)return;return this.renderError(`Load Error: ${h}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!t.aborted&&(this.abortController=null)}}if(i!==this.latestLoadId)return;if(!n)return void this.clear();if(!e.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props);this.clear();const r=this.getOrCreateComponent(n,e);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s))return r.get(s);const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const h=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{h.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=h}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};h=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n.CustomElement({tagName:"router-view"})],h);const o=h;exports.default=o;
@@ -8,8 +8,9 @@ declare class RouterView extends BaseElement {
8
8
  private routerAttrs;
9
9
  private prevPropKeys;
10
10
  private scheduled;
11
- private cache;
12
11
  private latestLoadId;
12
+ private abortController;
13
+ private router;
13
14
  mounted(): Promise<void>;
14
15
  unmounted(): void;
15
16
  private scheduleLoad;
@@ -1 +1 @@
1
- var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);import{routerReady as s}from"./core.js";import e from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;let r=class extends e{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"cache",new Map),i(this,"latestLoadId",0)}async mounted(){this.detectLevel();const t=await s;this.unsubscribe=t.listen(()=>{this.scheduleLoad(t.getCurrentRoute())}),this.loadRoute(t.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this),this.cache.forEach(t=>t.remove()),this.cache.clear()}scheduleLoad(t){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t)}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof r&&t++,i=i.parentElement;this.level=t}async loadRoute(t){const i=++this.latestLoadId,s=null==t?void 0:t.matched[this.level];if(!s)return void this.handleEmptyRoute();const{config:e}=s;let n=e.tagName;if(!n&&"function"==typeof e.component){this.renderLoading();try{const t=await e.component();n="string"==typeof t?t:t.tagName}catch(o){return void this.renderError(`Load Error: ${o}`)}}if(i!==this.latestLoadId)return;if(!n)return void this.clear();if(!e.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props);this.clear(e.keepAlive);const r=this.getOrCreateComponent(n,e);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,i){const s=t.toLowerCase();if(i.keepAlive&&this.cache.has(s))return this.cache.get(s);const e=document.createElement(t);return i.keepAlive&&this.cache.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const o=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{o.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=o}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.innerHTML='<div style="padding:20px; color:#999;">Loading...</div>'}renderError(t){this.innerHTML=`<div style="padding:20px; color:#ff4d4f;">${t}</div>`}clear(t=!1){this.currentElement?this.contains(this.currentElement)&&this.removeChild(this.currentElement):t||(this.innerHTML=""),this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};r=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n({tagName:"router-view"})],r);const o=r;export{o as default};
1
+ var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);import{routerReady as s}from"./core.js";import e from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const r=new Map;let o=class extends e{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(this.router.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof o&&t++,i=i.parentElement;this.level=t}async loadRoute(t){this.abortController&&(this.abortController.abort(),this.abortController=null);const i=++this.latestLoadId,s=null==t?void 0:t.matched[this.level];if(!s)return void this.handleEmptyRoute();const{config:e}=s;let n=e.tagName;if(!n&&"function"==typeof e.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const t=this.abortController.signal;try{const s=await e.component();if(t.aborted||i!==this.latestLoadId)return;n="string"==typeof s?s:s.tagName}catch(o){if(t.aborted||i!==this.latestLoadId)return;return this.renderError(`Load Error: ${o}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!t.aborted&&(this.abortController=null)}}if(i!==this.latestLoadId)return;if(!n)return void this.clear();if(!e.forceReload&&this.currentElement&&this.currentTagName===n.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props);this.clear();const r=this.getOrCreateComponent(n,e);this.syncState(r,null==t?void 0:t.params,(null==t?void 0:t.query)||{},e.props),this.appendChild(r),this.currentElement=r,this.currentTagName=n.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s))return r.get(s);const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const o=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{o.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=o}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};o=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n({tagName:"router-view"})],o);const h=o;export{h as default};
@@ -1 +1 @@
1
- "use strict";var t,e,s,i,n,h,a,o,r,c,u,l,d,f,b,p,v,m,k,w,y=Object.defineProperty,M=t=>{throw TypeError(t)},g=(t,e,s)=>e.has(t)||M("Cannot "+s),S=(t,e,s)=>(g(t,e,"read from private field"),s?s.call(t):e.get(t)),W=(t,e,s)=>e.has(t)?M("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),C=(t,e,s,i)=>(g(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),$=(t,e,s)=>(g(t,e,"access private method"),s);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("../../shared/is-object.cjs"),A=require("../../shared/env.cjs"),q=require("../reactivity/observe.cjs"),N=require("../renderer/renderIR.cjs"),E=Symbol.for("solely.manifest"),x=class extends HTMLElement{constructor(l={}){var f;super(),W(this,u),W(this,t),W(this,e),W(this,s),W(this,i),W(this,n),W(this,h),W(this,a,!1),W(this,o,!1),W(this,r,!1),W(this,c,!1);const p=this.constructor;C(this,t,p[E]||{tagName:"base-element"});const v=S(this,t);C(this,n,(null==(f=v.shadowDOM)?void 0:f.use)?this.attachShadow({mode:v.shadowDOM.mode||"open"}):this),$(this,u,d).call(this,l),$(this,u,b).call(this,v),queueMicrotask(()=>$(this,u,w).call(this))}static get observedAttributes(){const t=this[E];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return S(this,i)}set $data(t){var e;j.isObject(t)||(t={}),null==(e=S(this,h))||e.call(this),$(this,u,d).call(this,t),$(this,u,v).call(this)}refresh(){$(this,u,v).call(this)}connectedCallback(){var i;const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],$(this,u,l).call(this,a),$(this,u,w).call(this);const o=S(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),$(this,u,k).call(this),o.propMap&&j.isObject(this.$data))for(const[t,e]of o.propMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=$(this,u,p).call(this,i,e.default,e.type);this.$data[s]=n}else"default"in e&&(this.$data[s]=e.default)}S(this,s)&&C(this,e,N.createRender(S(this,s),S(this,n),this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var t,s,i;this.unmounted(),null==(t=S(this,h))||t.call(this),C(this,h,void 0),null==(i=null==(s=S(this,e))?void 0:s.destroy)||i.call(s),C(this,e,null)}attributeChangedCallback(e,s,i){var n;if(s===i||!j.isObject(this.$data))return;const h=null==(n=S(this,t).propMap)?void 0:n.get(e);if(!h)return;const a=h.name,o=this.$data[a],c=$(this,u,p).call(this,i,h.default??o,h.type);this.$data[a]=c,C(this,r,!0),this.attributeChanged(e,o,c)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var O;t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakSet,l=function(t){for(const e of t)if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this[e]=t}},d=function(e){const{proxy:s,dispose:n}=q.observe(e,e=>{var s,i;if("set"===e.type){const{key:n,newValue:h}=e,a=S(this,t),o=String(n),r=(null==(s=a.propMap)?void 0:s.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&$(this,u,f).call(this,r,h)}this.emit("change",{source:"state",...e}),$(this,u,v).call(this)});C(this,i,s),C(this,h,n)},f=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},b=function(t){t.ir&&C(this,s,t.ir)},p=function(t,e,s){if(null===t)return"boolean"===s?e??!1:e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch{return e}default:return t}},v=function(){!S(this,o)&&S(this,e)&&(C(this,o,!0),queueMicrotask(()=>{C(this,o,!1),$(this,u,m).call(this)}))},m=function(){!S(this,a)&&this.isConnected&&(C(this,a,!0),S(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),S(this,e).update(),this.updated(),S(this,r)&&(this.afterAttributesUpdate(),C(this,r,!1)),C(this,a,!1))},k=function(){const e=S(this,t);if(!e.styles)return;const s=S(this,n);if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s)return void(s.adoptedStyleSheets.includes(e.sheet)||(s.adoptedStyleSheets=[...s.adoptedStyleSheets,e.sheet]));const i=s instanceof ShadowRoot?s:document.head,h=`solely-style-${e.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=e.styles,i.appendChild(t)}},w=function(){S(this,c)||(C(this,c,!0),this.created())},((t,e,s)=>{e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(x,"symbol"!=typeof(O="upgradeProps")?O+"":O,undefined),(()=>{if(A.IS_DEV){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,n){if(x.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,s=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of s)t[e],x.prototype[e]}return t.call(this,s,i,n)}}})();let R=x;exports.default=R;
1
+ "use strict";var t,e,s,i,n,h,a,o,r,c,u,l,d,f,b,p,m,v,k,w,y,M,W=Object.defineProperty,g=t=>{throw TypeError(t)},S=(t,e,s)=>e.has(t)||g("Cannot "+s),C=(t,e,s)=>(S(t,e,"read from private field"),s?s.call(t):e.get(t)),$=(t,e,s)=>e.has(t)?g("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),j=(t,e,s,i)=>(S(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),A=(t,e,s)=>(S(t,e,"access private method"),s);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("../../shared/is-object.cjs"),N=require("../../shared/env.cjs"),E=require("../reactivity/observe.cjs"),x=require("../renderer/renderIR.cjs"),O=Symbol.for("solely.manifest"),R=class extends HTMLElement{constructor(f={}){var p;super(),$(this,d),$(this,t),$(this,e),$(this,s),$(this,i),$(this,n),$(this,h),$(this,a,!1),$(this,o,!1),$(this,r,!1),$(this,c,!1),$(this,u,!1),$(this,l,!1);const v=this.constructor;j(this,t,v[O]||{tagName:"base-element"});const k=C(this,t);j(this,n,(null==(p=k.shadowDOM)?void 0:p.use)?this.attachShadow({mode:k.shadowDOM.mode||"open"}):this),A(this,d,b).call(this,f),A(this,d,m).call(this,k),queueMicrotask(()=>A(this,d,M).call(this))}static get observedAttributes(){const t=this[O];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var e;q.isObject(t)||(t={}),null==(e=C(this,h))||e.call(this),A(this,d,b).call(this,t),A(this,d,k).call(this)}refresh(){A(this,d,k).call(this)}connectedCallback(){var i;j(this,u,!0);const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],A(this,d,f).call(this,a),A(this,d,M).call(this);const o=C(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),A(this,d,y).call(this),o.propMap&&q.isObject(this.$data))for(const[t,e]of o.propMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=A(this,d,v).call(this,i,e.default,e.type);this.$data[s]=n}else"default"in e&&(this.$data[s]=e.default)}C(this,s)&&!C(this,e)&&j(this,e,x.createRender(C(this,s),C(this,n),this)),C(this,l)&&(j(this,l,!1),A(this,d,k).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){j(this,u,!1),this.unmounted()}attributeChangedCallback(e,s,i){var n;if(s===i||!q.isObject(this.$data))return;const h=null==(n=C(this,t).propMap)?void 0:n.get(e);if(!h)return;const a=h.name,o=this.$data[a],c=A(this,d,v).call(this,i,h.default??o,h.type);this.$data[a]=c,j(this,r,!0),this.attributeChanged(e,o,c)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var U;t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap,d=new WeakSet,f=function(t){for(const e of t)if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this[e]=t}},b=function(e){const{proxy:s,dispose:n}=E.observe(e,e=>{var s,i;if("set"===e.type){const{key:n,newValue:h}=e,a=C(this,t),o=String(n),r=(null==(s=a.propMap)?void 0:s.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&A(this,d,p).call(this,r,h)}this.emit("change",{source:"state",...e}),A(this,d,k).call(this)});j(this,i,s),j(this,h,n)},p=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},m=function(t){t.ir&&j(this,s,t.ir)},v=function(t,e,s){if(null===t)return"boolean"===s?e??!1:e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch{return e}default:return t}},k=function(){C(this,u)?!C(this,o)&&C(this,e)&&(j(this,o,!0),queueMicrotask(()=>{j(this,o,!1),A(this,d,w).call(this)})):j(this,l,!0)},w=function(){!C(this,a)&&C(this,u)&&(j(this,a,!0),C(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,e).update(),this.updated(),C(this,r)&&(this.afterAttributesUpdate(),j(this,r,!1)),j(this,a,!1))},y=function(){const e=C(this,t);if(!e.styles)return;const s=C(this,n);if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s)return void(s.adoptedStyleSheets.includes(e.sheet)||(s.adoptedStyleSheets=[...s.adoptedStyleSheets,e.sheet]));const i=s instanceof ShadowRoot?s:document.head,h=`solely-style-${e.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=e.styles,i.appendChild(t)}},M=function(){C(this,c)||(j(this,c,!0),this.created())},((t,e,s)=>{e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(R,"symbol"!=typeof(U="upgradeProps")?U+"":U,undefined),(()=>{if(N.IS_DEV){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,n){if(R.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,s=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of s)t[e],R.prototype[e]}return t.call(this,s,i,n)}}})();let z=R;exports.default=z;
@@ -1 +1 @@
1
- var t,s,e,i,n,h,o,a,r,c,l,u,d,f,b,m,p,v,k,w,y=Object.defineProperty,g=t=>{throw TypeError(t)},M=(t,s,e)=>s.has(t)||g("Cannot "+e),W=(t,s,e)=>(M(t,s,"read from private field"),e?e.call(t):s.get(t)),C=(t,s,e)=>s.has(t)?g("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),S=(t,s,e,i)=>(M(t,s,"write to private field"),i?i.call(t,e):s.set(t,e),e),$=(t,s,e)=>(M(t,s,"access private method"),e);import{isObject as j}from"../../shared/is-object.js";import{IS_DEV as A}from"../../shared/env.js";import{observe as N}from"../reactivity/observe.js";import{createRender as E}from"../renderer/renderIR.js";const x=Symbol.for("solely.manifest"),O=class extends HTMLElement{constructor(u={}){var f;super(),C(this,l),C(this,t),C(this,s),C(this,e),C(this,i),C(this,n),C(this,h),C(this,o,!1),C(this,a,!1),C(this,r,!1),C(this,c,!1);const m=this.constructor;S(this,t,m[x]||{tagName:"base-element"});const p=W(this,t);S(this,n,(null==(f=p.shadowDOM)?void 0:f.use)?this.attachShadow({mode:p.shadowDOM.mode||"open"}):this),$(this,l,d).call(this,u),$(this,l,b).call(this,p),queueMicrotask(()=>$(this,l,w).call(this))}static get observedAttributes(){const t=this[x];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return W(this,i)}set $data(t){var s;j(t)||(t={}),null==(s=W(this,h))||s.call(this),$(this,l,d).call(this,t),$(this,l,p).call(this)}refresh(){$(this,l,p).call(this)}connectedCallback(){var i;const h=this.constructor.upgradeProps;let o;o=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],$(this,l,u).call(this,o),$(this,l,w).call(this);const a=W(this,t);if((a.className||a.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),$(this,l,k).call(this),a.propMap&&j(this.$data))for(const[t,s]of a.propMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=$(this,l,m).call(this,i,s.default,s.type);this.$data[e]=n}else"default"in s&&(this.$data[e]=s.default)}W(this,e)&&S(this,s,E(W(this,e),W(this,n),this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){var t,e,i;this.unmounted(),null==(t=W(this,h))||t.call(this),S(this,h,void 0),null==(i=null==(e=W(this,s))?void 0:e.destroy)||i.call(e),S(this,s,null)}attributeChangedCallback(s,e,i){var n;if(e===i||!j(this.$data))return;const h=null==(n=W(this,t).propMap)?void 0:n.get(s);if(!h)return;const o=h.name,a=this.$data[o],c=$(this,l,m).call(this,i,h.default??a,h.type);this.$data[o]=c,S(this,r,!0),this.attributeChanged(s,a,c)}emit(t,s,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:s,...e}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,s,e){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var R;t=new WeakMap,s=new WeakMap,e=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakMap,c=new WeakMap,l=new WeakSet,u=function(t){for(const s of t)if(this.hasOwnProperty(s)){const t=this[s];delete this[s],this[s]=t}},d=function(s){const{proxy:e,dispose:n}=N(s,s=>{var e,i;if("set"===s.type){const{key:n,newValue:h}=s,o=W(this,t),a=String(n),r=(null==(e=o.propMap)?void 0:e.get(a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=o.propMap)?void 0:i.values())||[]).find(t=>t.name===a);(null==r?void 0:r.reflect)&&$(this,l,f).call(this,r,h)}this.emit("change",{source:"state",...s}),$(this,l,p).call(this)});S(this,i,e),S(this,h,n)},f=function(t,s){const e=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)s?this.setAttribute(e,""):this.removeAttribute(e);else{const t="object"==typeof s?JSON.stringify(s):String(s);this.setAttribute(e,t)}},b=function(t){t.ir&&S(this,e,t.ir)},m=function(t,s,e){if(null===t)return"boolean"===e?s??!1:s;switch(e){case"boolean":return!0;case"number":{const e=Number(t);return isNaN(e)?s:e}case"object":try{return JSON.parse(t)}catch{return s}default:return t}},p=function(){!W(this,a)&&W(this,s)&&(S(this,a,!0),queueMicrotask(()=>{S(this,a,!1),$(this,l,v).call(this)}))},v=function(){!W(this,o)&&this.isConnected&&(S(this,o,!0),W(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),W(this,s).update(),this.updated(),W(this,r)&&(this.afterAttributesUpdate(),S(this,r,!1)),S(this,o,!1))},k=function(){const s=W(this,t);if(!s.styles)return;const e=W(this,n);if(s.sheet&&e instanceof ShadowRoot&&"adoptedStyleSheets"in e)return void(e.adoptedStyleSheets.includes(s.sheet)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s.sheet]));const i=e instanceof ShadowRoot?e:document.head,h=`solely-style-${s.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=s.styles,i.appendChild(t)}},w=function(){W(this,c)||(S(this,c,!0),this.created())},((t,s,e)=>{s in t?y(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e})(O,"symbol"!=typeof(R="upgradeProps")?R+"":R,undefined),(()=>{if(A){const t=customElements.define,s=new WeakSet;customElements.define=function(e,i,n){if(O.isPrototypeOf(i)&&!s.has(i)){s.add(i);const t=i.prototype,e=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const s of e)t[s],O.prototype[s]}return t.call(this,e,i,n)}}})();let U=O;export{U as default};
1
+ var t,s,e,i,n,h,a,o,r,c,u,l,d,f,p,b,m,k,v,w,y,M,W=Object.defineProperty,g=t=>{throw TypeError(t)},C=(t,s,e)=>s.has(t)||g("Cannot "+e),S=(t,s,e)=>(C(t,s,"read from private field"),e?e.call(t):s.get(t)),$=(t,s,e)=>s.has(t)?g("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),j=(t,s,e,i)=>(C(t,s,"write to private field"),i?i.call(t,e):s.set(t,e),e),A=(t,s,e)=>(C(t,s,"access private method"),e);import{isObject as N}from"../../shared/is-object.js";import{IS_DEV as E}from"../../shared/env.js";import{observe as x}from"../reactivity/observe.js";import{createRender as O}from"../renderer/renderIR.js";const R=Symbol.for("solely.manifest"),U=class extends HTMLElement{constructor(f={}){var b;super(),$(this,d),$(this,t),$(this,s),$(this,e),$(this,i),$(this,n),$(this,h),$(this,a,!1),$(this,o,!1),$(this,r,!1),$(this,c,!1),$(this,u,!1),$(this,l,!1);const k=this.constructor;j(this,t,k[R]||{tagName:"base-element"});const v=S(this,t);j(this,n,(null==(b=v.shadowDOM)?void 0:b.use)?this.attachShadow({mode:v.shadowDOM.mode||"open"}):this),A(this,d,p).call(this,f),A(this,d,m).call(this,v),queueMicrotask(()=>A(this,d,M).call(this))}static get observedAttributes(){const t=this[R];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return S(this,i)}set $data(t){var s;N(t)||(t={}),null==(s=S(this,h))||s.call(this),A(this,d,p).call(this,t),A(this,d,v).call(this)}refresh(){A(this,d,v).call(this)}connectedCallback(){var i;j(this,u,!0);const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],A(this,d,f).call(this,a),A(this,d,M).call(this);const o=S(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),A(this,d,y).call(this),o.propMap&&N(this.$data))for(const[t,s]of o.propMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=A(this,d,k).call(this,i,s.default,s.type);this.$data[e]=n}else"default"in s&&(this.$data[e]=s.default)}S(this,e)&&!S(this,s)&&j(this,s,O(S(this,e),S(this,n),this)),S(this,l)&&(j(this,l,!1),A(this,d,v).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){j(this,u,!1),this.unmounted()}attributeChangedCallback(s,e,i){var n;if(e===i||!N(this.$data))return;const h=null==(n=S(this,t).propMap)?void 0:n.get(s);if(!h)return;const a=h.name,o=this.$data[a],c=A(this,d,k).call(this,i,h.default??o,h.type);this.$data[a]=c,j(this,r,!0),this.attributeChanged(s,o,c)}emit(t,s,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:s,...e}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,s,e){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};var q;t=new WeakMap,s=new WeakMap,e=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap,d=new WeakSet,f=function(t){for(const s of t)if(this.hasOwnProperty(s)){const t=this[s];delete this[s],this[s]=t}},p=function(s){const{proxy:e,dispose:n}=x(s,s=>{var e,i;if("set"===s.type){const{key:n,newValue:h}=s,a=S(this,t),o=String(n),r=(null==(e=a.propMap)?void 0:e.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&A(this,d,b).call(this,r,h)}this.emit("change",{source:"state",...s}),A(this,d,v).call(this)});j(this,i,e),j(this,h,n)},b=function(t,s){const e=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)s?this.setAttribute(e,""):this.removeAttribute(e);else{const t="object"==typeof s?JSON.stringify(s):String(s);this.setAttribute(e,t)}},m=function(t){t.ir&&j(this,e,t.ir)},k=function(t,s,e){if(null===t)return"boolean"===e?s??!1:s;switch(e){case"boolean":return!0;case"number":{const e=Number(t);return isNaN(e)?s:e}case"object":try{return JSON.parse(t)}catch{return s}default:return t}},v=function(){S(this,u)?!S(this,o)&&S(this,s)&&(j(this,o,!0),queueMicrotask(()=>{j(this,o,!1),A(this,d,w).call(this)})):j(this,l,!0)},w=function(){!S(this,a)&&S(this,u)&&(j(this,a,!0),S(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),S(this,s).update(),this.updated(),S(this,r)&&(this.afterAttributesUpdate(),j(this,r,!1)),j(this,a,!1))},y=function(){const s=S(this,t);if(!s.styles)return;const e=S(this,n);if(s.sheet&&e instanceof ShadowRoot&&"adoptedStyleSheets"in e)return void(e.adoptedStyleSheets.includes(s.sheet)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s.sheet]));const i=e instanceof ShadowRoot?e:document.head,h=`solely-style-${s.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=s.styles,i.appendChild(t)}},M=function(){S(this,c)||(j(this,c,!0),this.created())},((t,s,e)=>{s in t?W(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e})(U,"symbol"!=typeof(q="upgradeProps")?q+"":q,undefined),(()=>{if(E){const t=customElements.define,s=new WeakSet;customElements.define=function(e,i,n){if(U.isPrototypeOf(i)&&!s.has(i)){s.add(i);const t=i.prototype,e=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const s of e)t[s],U.prototype[s]}return t.call(this,e,i,n)}}})();let z=U;export{z as default};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),o=require("../../shared/templateError.cjs"),n=Symbol("solely.irCtx"),i=Symbol("solely.irEvents"),r=Symbol("solely.prevClassObj"),c=Symbol("solely.prevStyleObj"),l={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},a={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},h=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function f(t,e){var s;const o=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==o?void 0:o.v)&&t.setAttribute("class",o.v)}function d(t,e){var s;if(!t.style)return;const o=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),n=o?m(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}function m(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function p(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=l[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function b(t,e,s){const o=a[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||h.has(e))return void p(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!a[e]?p(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class y{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o.showTemplateError(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const l=[],a=t;let h;a[n]||(a[n]={loops:null}),a[n].loops=s,a[i]||(a[i]=Object.create(null));let f,d=!1,y=!1;for(const r of e){const{k:e,f:c,d:m,v:v}=r;if(":class"===e){h=this.evalIR(c,[s],r.o),d=!0;continue}if(":style"===e){f=this.evalIR(c,[s],r.o),y=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),l=r.r??"user";let h=a[i][s];if(h||(h=a[i][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!o){const t=t=>this.evalIR(c,[t,a[n].loops],r.o);h[l].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("ref"===e&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=t;continue}const S=m?this.evalIR(c,[s],r.o):v??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?l.push(()=>b(t,s,S)):b(t,s,S)}else o||p(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[r],n=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const o=s[t].trim();o&&(e[o]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e);if(!o){for(const e in n)t.classList.add(e);return void(s[r]=n)}let i=!1;for(const r in o)n[r]||(t.classList.remove(r),i=!0);for(const r in n)o[r]||(t.classList.add(r),i=!0);i&&(s[r]=n)})(t,h),y&&((t,e)=>{const s=t,o=m(e),n=s[c];if(!n){for(const e in o){const s=o[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[c]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[c]=o)})(t,f),l}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.ASTType.Element:{const s=this.createElement(t,e);f(s,t),d(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.ASTType.Text:return this.createText(t,o);case s.ASTType.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,a;const h=o+"-"+e,u=this.nodeMap.get(h);let m;if(1!==t.s)if(u){m=u.node,u.marker=this.marker;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(m,t.a??[],i,!0):this.updateNode(m,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,h,m,i)}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:m=this.createElement(t,n),f(m,t),d(m,t);const e=this.applyAttrs(m,t.a??[],i);n.appendChild(m),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,h,m,i)}),e.forEach(t=>t());break;case s.ASTType.Text:m=this.createText(t,i),n.appendChild(m),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.ASTType.Comment:m=this.createComment(t,i),n.appendChild(m),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.ASTType.For:{const e=`${h}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${h}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.ASTType.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${h}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.ASTType.Conditional:{const e=`${h}-end`;let s=null==(a=this.nodeMap.get(e))?void 0:a.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${h}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${h}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else u?(u.marker=this.marker,m=u.node):(m=this.handleStaticSubtree(t,h,n,i),this.nodeMap.set(h,{irNode:t,node:m,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=y,exports.createRender=(t,e,s={})=>{const o=new y(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};
1
+ "use strict";var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),o=require("../../shared/templateError.cjs"),n=require("../../shared/env.cjs"),i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),a={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},h={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},u=new Set(["data-","aria-","role","form"]),f=new Set(["value","selectedIndex"]);function d(t,e){var s;const o=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==o?void 0:o.v)&&t.setAttribute("class",o.v)}function m(t,e){var s;if(!t.style)return;const o=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),n=o?b(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t)&&(n.IS_DEV,1));function b(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function y(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=a[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function v(t,e,s){const o=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||u.has(e))return void y(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!h[e]?y(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o.showTemplateError(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const n=[],a=t;let h;a[i]||(a[i]={loops:null}),a[i].loops=s,a[r]||(a[r]=Object.create(null));let u,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:b}=c;if(":class"===e){h=this.evalIR(l,[s],c.o),d=!0;continue}if(":style"===e){u=this.evalIR(l,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),n=c.r??"user";let h=a[r][s];if(h||(h=a[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!o){const t=t=>this.evalIR(l,[t,a[i].loops],c.o);h[n].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("ref"===e&&b){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[b]=t;continue}const S=p?this.evalIR(l,[s],c.o):b??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&f.has(s)?n.push(()=>v(t,s,S)):v(t,s,S)}else o||y(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[c],n=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const o=s[t].trim();o&&(e[o]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in n)p(c)&&(i[c]=n[c]);if(!o){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in o)i[c]||(t.classList.remove(c),r=!0);for(const c in i)o[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,h),m&&((t,e)=>{const s=t,o=b(e),n=s[l];if(!n){for(const e in o){const s=o[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=o)})(t,u),n}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.ASTType.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.ASTType.Text:return this.createText(t,o);case s.ASTType.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,a;const h=o+"-"+e,u=this.nodeMap.get(h);let f;if(1!==t.s)if(u){f=u.node,u.marker=this.marker;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(f,t.a??[],i,!0):this.updateNode(f,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,h,f,i)}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:f=this.createElement(t,n),d(f,t),m(f,t);const e=this.applyAttrs(f,t.a??[],i);n.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,h,f,i)}),e.forEach(t=>t());break;case s.ASTType.Text:f=this.createText(t,i),n.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker});break;case s.ASTType.Comment:f=this.createComment(t,i),n.appendChild(f),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker});break;case s.ASTType.For:{const e=`${h}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${h}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.ASTType.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${h}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.ASTType.Conditional:{const e=`${h}-end`;let s=null==(a=this.nodeMap.get(e))?void 0:a.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${h}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${h}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else u?(u.marker=this.marker,f=u.node):(f=this.handleStaticSubtree(t,h,n,i),this.nodeMap.set(h,{irNode:t,node:f,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=w,exports.createRender=(t,e,s={})=>{const o=new w(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};
@@ -1 +1 @@
1
- var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);import{ASTType as s}from"../../types/ast.js";import{showTemplateError as o}from"../../shared/templateError.js";const n=Symbol("solely.irCtx"),i=Symbol("solely.irEvents"),r=Symbol("solely.prevClassObj"),c=Symbol("solely.prevStyleObj"),l={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},h={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},a=new Set(["data-","aria-","role","form"]),f=new Set(["value","selectedIndex"]);function u(t,e){var s;const o=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==o?void 0:o.v)&&t.setAttribute("class",o.v)}function d(t,e){var s;if(!t.style)return;const o=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),n=o?m(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}function m(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function p(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=l[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function y(t,e,s){const o=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||a.has(e))return void p(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!h[e]?p(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class b{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const l=[],h=t;let a;h[n]||(h[n]={loops:null}),h[n].loops=s,h[i]||(h[i]=Object.create(null));let u,d=!1,b=!1;for(const r of e){const{k:e,f:c,d:m,v:v}=r;if(":class"===e){a=this.evalIR(c,[s],r.o),d=!0;continue}if(":style"===e){u=this.evalIR(c,[s],r.o),b=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),l=r.r??"user";let a=h[i][s];if(a||(a=h[i][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of a.model)e(t);for(const e of a.user)e(t)})),!o){const t=t=>this.evalIR(c,[t,h[n].loops],r.o);a[l].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(c,[t,s],r.o));continue}if("ref"===e&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=t;continue}const S=m?this.evalIR(c,[s],r.o):v??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&f.has(s)?l.push(()=>y(t,s,S)):y(t,s,S)}else o||p(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[r],n=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const o=s[t].trim();o&&(e[o]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e);if(!o){for(const e in n)t.classList.add(e);return void(s[r]=n)}let i=!1;for(const r in o)n[r]||(t.classList.remove(r),i=!0);for(const r in n)o[r]||(t.classList.add(r),i=!0);i&&(s[r]=n)})(t,a),b&&((t,e)=>{const s=t,o=m(e),n=s[c];if(!n){for(const e in o){const s=o[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[c]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[c]=o)})(t,u),l}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.Element:{const s=this.createElement(t,e);u(s,t),d(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.Text:return this.createText(t,o);case s.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,h;const a=o+"-"+e,f=this.nodeMap.get(a);let m;if(1!==t.s)if(f){m=f.node,f.marker=this.marker;let e=[];t.d&&(t.t===s.Element?e=this.applyAttrs(m,t.a??[],i,!0):this.updateNode(m,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,a,m,i)}),e.forEach(t=>t())}else switch(t.t){case s.Element:m=this.createElement(t,n),u(m,t),d(m,t);const e=this.applyAttrs(m,t.a??[],i);n.appendChild(m),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,a,m,i)}),e.forEach(t=>t());break;case s.Text:m=this.createText(t,i),n.appendChild(m),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.Comment:m=this.createComment(t,i),n.appendChild(m),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker});break;case s.For:{const e=`${a}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${a}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${a}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.Conditional:{const e=`${a}-end`;let s=null==(h=this.nodeMap.get(e))?void 0:h.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${a}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${a}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else f?(f.marker=this.marker,m=f.node):(m=this.handleStaticSubtree(t,a,n,i),this.nodeMap.set(a,{irNode:t,node:m,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const v=(t,e,s={})=>{const o=new b(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};export{b as IRRenderer,v as createRender};
1
+ var t=Object.defineProperty,e=(e,s,o)=>((e,s,o)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o)(e,"symbol"!=typeof s?s+"":s,o);import{ASTType as s}from"../../types/ast.js";import{showTemplateError as o}from"../../shared/templateError.js";import{IS_DEV as n}from"../../shared/env.js";const i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),h={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},a={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},f=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function d(t,e){var s;const o=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==o?void 0:o.v)&&t.setAttribute("class",o.v)}function m(t,e){var s;if(!t.style)return;const o=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),n=o?y(o.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t));function y(t){const e={},s=[[t]];for(;s.length;){const[t,o]=s.pop();if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let o;for(;null!==(o=s.exec(t));){const t=o[1].trim(),s=o[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=o?`${o}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function b(t,e,s){const o=null==s?"":String(s),n=e.indexOf(":");if(n>0){const s=e.slice(0,n),i=h[s];if(i)return void(t.getAttributeNS(i,e)!==o&&t.setAttributeNS(i,e,o))}t.getAttribute(e)!==o&&t.setAttribute(e,o)}function v(t,e,s){const o=a[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||f.has(e))return void b(t,e,s);const n=t,i=n.tagName;if(null!=s){if("src"===o||"href"===o){const e=String(s);if(n[o]===e||t.getAttribute(o)===e)return}if("value"!==o||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!a[e]?b(t,e,s):n[o]!==s&&(n[o]=s);else{if(n[o]===s)return;n[o]=s}}else if("boolean"==typeof n[o])!1!==n[o]&&(n[o]=!1);else{const s=n[o];""!==s&&void 0!==s&&(n[o]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,o={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=o}evalIR(t,e,s){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return o(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g;return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,o=!1){const n=[],h=t;let a;h[i]||(h[i]={loops:null}),h[i].loops=s,h[r]||(h[r]=Object.create(null));let f,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:y}=c;if(":class"===e){a=this.evalIR(l,[s],c.o),d=!0;continue}if(":style"===e){f=this.evalIR(l,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),n=c.r??"user";let a=h[r][s];if(a||(a=h[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of a.model)e(t);for(const e of a.user)e(t)})),!o){const t=t=>this.evalIR(l,[t,h[i].loops],c.o);a[n].push(t)}continue}if("mounted"===e){o||requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("updated"===e){o&&requestAnimationFrame(()=>this.evalIR(l,[t,s],c.o));continue}if("ref"===e&&y){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[y]=t;continue}const S=p?this.evalIR(l,[s],c.o):y??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?n.push(()=>v(t,s,S)):v(t,s,S)}else o||b(t,e,String(S))}return d&&((t,e)=>{const s=t,o=s[c],n=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const o=s[t].trim();o&&(e[o]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in n)p(c)&&(i[c]=n[c]);if(!o){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in o)i[c]||(t.classList.remove(c),r=!0);for(const c in i)o[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,a),m&&((t,e)=>{const s=t,o=y(e),n=s[l];if(!n){for(const e in o){const s=o[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=o)}let i=!1;for(const r in n)r in o||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in o){const e=o[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=o)})(t,f),n}updateNode(t,e,s){const o=e.d?this.evalIR(e.f,[s],e.o):e.x||"";e.d&&t.textContent!==o&&(t.textContent=o)}createStaticSubtree(t,e,o){var n;switch(t.t){case s.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],o);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,s,o);s.appendChild(e)}),i.forEach(t=>t()),s}case s.Text:return this.createText(t,o);case s.Comment:return this.createComment(t,o);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,o){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,o);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,o,n,i){var r,c,l,h;const a=o+"-"+e,f=this.nodeMap.get(a);let u;if(1!==t.s)if(f){u=f.node,f.marker=this.marker;let e=[];t.d&&(t.t===s.Element?e=this.applyAttrs(u,t.a??[],i,!0):this.updateNode(u,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,a,u,i)}),e.forEach(t=>t())}else switch(t.t){case s.Element:u=this.createElement(t,n),d(u,t),m(u,t);const e=this.applyAttrs(u,t.a??[],i);n.appendChild(u),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,a,u,i)}),e.forEach(t=>t());break;case s.Text:u=this.createText(t,i),n.appendChild(u),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker});break;case s.Comment:u=this.createComment(t,i),n.appendChild(u),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker});break;case s.For:{const e=`${a}-end`;let o=null==(l=this.nodeMap.get(e))?void 0:l.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`for:${a}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{t:s.Comment},node:o,loops:i,marker:this.marker}));const r=this.evalIR(t.f,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var o;const n=[...i,{itmVal:e,idxVal:s}];null==(o=t.c)||o.forEach((t,e)=>{this.irToNode(t,e,`${a}-for-${s}`,c,n)})}),o.parentNode.insertBefore(c,o);break}case s.Conditional:{const e=`${a}-end`;let s=null==(h=this.nodeMap.get(e))?void 0:h.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${a}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let o=0;o<(t.b||[]).length;o++){const e=t.b[o];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${a}-if-${o}`,t,i)}),s.parentNode.insertBefore(t,s);break}}break}}else f?(f.marker=this.marker,u=f.node):(u=this.handleStaticSubtree(t,a,n,i),this.nodeMap.set(a,{irNode:t,node:u,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:o,loops:n}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f,[o,n],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==o||o.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const S=(t,e,s={})=>{const o=new w(t,e,s);return o.mount(),{update:()=>o.update(),destroy:()=>o.destroy()}};export{w as IRRenderer,S as createRender};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.2.3",
4
+ "version": "0.2.5",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -171,7 +171,7 @@
171
171
  "license": "MIT",
172
172
  "repository": {
173
173
  "type": "git",
174
- "url": "git+https://github.com/solelyjs/solely.git"
174
+ "url": "https://github.com/solelyjs/solely.git"
175
175
  },
176
176
  "bugs": {
177
177
  "url": "https://github.com/solelyjs/solely/issues"
@@ -204,6 +204,9 @@
204
204
  "dev:debug": "node --inspect-brk ./node_modules/vite/bin/vite.js",
205
205
  "prepare": "husky"
206
206
  },
207
+ "dependencies": {
208
+ "magic-string": "^0.30.21"
209
+ },
207
210
  "devDependencies": {
208
211
  "@rollup/plugin-strip": "^3.0.4",
209
212
  "@testing-library/dom": "^10.4.1",
@@ -219,7 +222,6 @@
219
222
  "husky": "^9.0.0",
220
223
  "jsdom": "27.0.0",
221
224
  "lint-staged": "^15.0.0",
222
- "magic-string": "^0.30.21",
223
225
  "prettier": "^3.0.0",
224
226
  "rimraf": "^5.0.10",
225
227
  "sass": "^1.83.0",
@@ -1,6 +0,0 @@
1
- import { RouteConfig } from './types';
2
- /**
3
- * 最终完整路由配置表
4
- */
5
- export declare const routes: RouteConfig[];
6
- export default routes;
@@ -1,6 +0,0 @@
1
- import { IRLocal } from '../types';
2
- export type GenType = "template" | "handler" | "expression" | "lifecycle";
3
- /**
4
- * 主入口:生成可执行的函数(支持上层捕获异常)
5
- */
6
- export declare function genFunction(code: string, type: GenType, locals: IRLocal[]): Function;