solely 0.5.0 → 0.5.1
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,e,s,i,a,r,n,o,h,l,c,u,d,p,f,b,m,y,v,w,g,S,M,O,$,k,j,W,C,N,A,E=Object.defineProperty,P=t=>{throw TypeError(t)},L=(t,e,s)=>e.has(t)||P("Cannot "+s),D=(t,e,s)=>(L(t,e,"read from private field"),s?s.call(t):e.get(t)),q=(t,e,s)=>e.has(t)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),U=(t,e,s,i)=>(L(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),_=(t,e,s)=>(L(t,e,"access private method"),s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("../../shared/is-object.cjs"),T=require("../../shared/env.cjs"),x=require("../../shared/case-convert.cjs"),I=require("../reactivity/observe.cjs"),V=require("../renderer/renderIR.cjs"),H=Symbol.for("solely.manifest"),J=class extends HTMLElement{constructor(m={}){var y,w;super(),q(this,v),((t,e,s)=>{e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(w="$refs")?w+"":w,{}),q(this,t),q(this,e),q(this,s),q(this,i),q(this,a),q(this,r),q(this,n,!1),q(this,o,!1),q(this,h,!1),q(this,l,!1),q(this,c,!1),q(this,u,!1),q(this,d,!1),q(this,p,new Set),q(this,f,!1),q(this,b,!1);const S=this.constructor;U(this,t,S[H]||{tagName:"base-element"});const O=D(this,t);U(this,a,(null==(y=O.shadowDOM)?void 0:y.use)?this.attachShadow({mode:O.shadowDOM.mode||"open"}):this),_(this,v,g).call(this,m),_(this,v,M).call(this,O),queueMicrotask(()=>_(this,v,A).call(this))}static get observedAttributes(){const t=this[H];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return D(this,i)}set $data(t){var e;R.isObject(t)||(t={}),t!==D(this,i)&&(null==(e=D(this,r))||e.call(this),_(this,v,g).call(this,t),_(this,v,$).call(this),_(this,v,j).call(this))}refresh(){_(this,v,j).call(this)}connectedCallback(){if(D(this,f))throw new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);U(this,c,!0);const i=D(this,t);if(_(this,v,A).call(this),(i.className||i.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),_(this,v,C).call(this),i.attributeMap&&R.isObject(this.$data)){_(this,v,$).call(this);for(const[t,e]of i.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=_(this,v,k).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}_(this,v,w).call(this),D(this,s)&&!D(this,e)&&U(this,e,V.createRender(D(this,s),D(this,a),this)),D(this,u)&&(U(this,u,!1),_(this,v,j).call(this)),this.mounted()}disconnectedCallback(){U(this,c,!1),D(this,f)||_(this,v,N).call(this),this.unmounted()}attributeChangedCallback(e,s,i){var a;if(D(this,f)||s===i||!R.isObject(this.$data))return;if(D(this,p).has(e))return;const r=null==(a=D(this,t).attributeMap)?void 0:a.get(e);if(!r)return;const n=r.name,o=this.$data[n],l=_(this,v,k).call(this,i,r.default??o,r.type);o!==l&&(U(this,h,!0),this.$data[n]=l,this.attributeChanged(e,o,l))}emit(t,e,s){D(this,f)||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){D(this,f)||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(T.IS_DEV&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(T.IS_DEV&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){var t,s;D(this,f)||(U(this,f,!0),U(this,c,!1),_(this,v,N).call(this),null==(t=D(this,e))||t.destroy(),U(this,e,void 0),null==(s=D(this,r))||s.call(this),U(this,r,void 0))}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,r=new WeakMap,n=new WeakMap,o=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,v=new WeakSet,w=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=D(J,y),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const r of t){if(s.has(r))continue;if(e.some(t=>r.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,r);if(!t||!("value"in t))continue;const a=t.value,n=i.get(r);(null==n?void 0:n.set)&&(delete this[r],this[r]=a)}},g=function(e){const{proxy:s,dispose:a}=I.observe(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,r=D(this,t),n=String(i),o=null==(s=r.propMap)?void 0:s.get(n);(null==o?void 0:o.reflect)&&_(this,v,S).call(this,o,a)}this.emit("dataChange",{...e}),_(this,v,j).call(this)});U(this,i,s),U(this,r,a)},S=function(t,e){const s=x.camelToKebab(t.name);D(this,p).add(s);try{if(null==e)return void this.removeAttribute(s);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)}}finally{D(this,p).delete(s)}},M=function(t){t.ir&&U(this,s,t.ir)},O=function(){const e=D(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;let e,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(e=Object.getOwnPropertyDescriptor(s,t.name),!e);)s=Object.getPrototypeOf(s);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},$=function(){D(this,d)||(U(this,d,!0),_(this,v,O).call(this))},k=function(t,e,s){if(null===t)return"boolean"!==s&&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(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=JSON.parse(t);return Array.isArray(s)?s:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},j=function(){D(this,f)||(D(this,c)?!D(this,o)&&D(this,e)&&(U(this,o,!0),queueMicrotask(()=>{D(this,f)||(U(this,o,!1),_(this,v,W).call(this))})):U(this,u,!0))},W=function(){var t;if(!D(this,f)&&!D(this,n)&&D(this,c)){U(this,n,!0);try{D(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),null==(t=D(this,e))||t.update(),this.updated(),D(this,h)&&(this.afterAttributesUpdate(),U(this,h,!1))}finally{U(this,n,!1)}}},C=function(){var e;const s=D(this,t);if(!s.styles)return;const i=D(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return void U(this,b,!0)}const r=i instanceof ShadowRoot?i:document.head,n=`solely-style-${T.SOLELY_VERSION}-${s.tagName}`,o=!(null==(e=s.shadowDOM)?void 0:e.use),h="undefined"!=typeof CSS&&CSS.escape?CSS.escape(n):n.replace(/([.#:[\]()!])/g,"\\$1");if(!r.querySelector(`#${h}`)){const t=document.createElement("style");t.id=n,t.textContent=s.styles,r.appendChild(t)}if(o){const t=D(J,m).get(n)||0;D(J,m).set(n,t+1),U(this,b,!0)}},N=function(){var e,s;if(!D(this,b))return;U(this,b,!1);const i=D(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${T.SOLELY_VERSION}-${i.tagName}`,e=D(J,m).get(t)||0;if(e<=1){const e=CSS.escape(t);null==(s=document.head.querySelector(`#${e}`))||s.remove(),D(J,m).delete(t)}else D(J,m).set(t,e-1)}},A=function(){D(this,l)||(U(this,l,!0),this.created())},q(J,m,new Map),q(J,y,new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]));let F=J;exports.default=F;
|
|
1
|
+
"use strict";var t,e,s,i,a,r,n,o,h,l,c,u,d,p,f,b,m,y,v,w,g,S,M,O,$,k,j,W,C,N,A,E=Object.defineProperty,P=t=>{throw TypeError(t)},L=(t,e,s)=>e.has(t)||P("Cannot "+s),D=(t,e,s)=>(L(t,e,"read from private field"),s?s.call(t):e.get(t)),q=(t,e,s)=>e.has(t)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),U=(t,e,s,i)=>(L(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),_=(t,e,s)=>(L(t,e,"access private method"),s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R=require("../../shared/is-object.cjs"),T=require("../../shared/env.cjs"),x=require("../../shared/case-convert.cjs"),I=require("../reactivity/observe.cjs"),V=require("../renderer/renderIR.cjs"),H=Symbol.for("solely.manifest"),J=class extends HTMLElement{constructor(m={}){var y,w;super(),q(this,v),((t,e,s)=>{e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(w="$refs")?w+"":w,{}),q(this,t),q(this,e),q(this,s),q(this,i),q(this,a),q(this,r),q(this,n,!1),q(this,o,!1),q(this,h,!1),q(this,l,!1),q(this,c,!1),q(this,u,!1),q(this,d,!1),q(this,p,new Set),q(this,f,!1),q(this,b,!1);const S=this.constructor;U(this,t,S[H]||{tagName:"base-element"});const O=D(this,t);U(this,a,(null==(y=O.shadowDOM)?void 0:y.use)?this.attachShadow({mode:O.shadowDOM.mode||"open"}):this),_(this,v,g).call(this,m),_(this,v,M).call(this,O),queueMicrotask(()=>_(this,v,A).call(this))}static get observedAttributes(){const t=this[H];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return D(this,i)}set $data(t){var e;R.isObject(t)||(t={}),t!==D(this,i)&&(null==(e=D(this,r))||e.call(this),_(this,v,g).call(this,t),_(this,v,$).call(this),_(this,v,j).call(this))}refresh(){_(this,v,j).call(this)}connectedCallback(){if(D(this,f))throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);U(this,c,!0);const i=D(this,t);if(_(this,v,A).call(this),(i.className||i.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),_(this,v,C).call(this),i.attributeMap&&R.isObject(this.$data)){_(this,v,$).call(this);for(const[t,e]of i.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=_(this,v,k).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}_(this,v,w).call(this),D(this,s)&&!D(this,e)&&U(this,e,V.createRender(D(this,s),D(this,a),this)),D(this,u)&&(U(this,u,!1),_(this,v,j).call(this)),this.mounted()}disconnectedCallback(){U(this,c,!1),D(this,f)||_(this,v,N).call(this),this.unmounted()}attributeChangedCallback(e,s,i){var a;if(D(this,f)||s===i||!R.isObject(this.$data))return;if(D(this,p).has(e))return;const r=null==(a=D(this,t).attributeMap)?void 0:a.get(e);if(!r)return;const n=r.name,o=this.$data[n],l=_(this,v,k).call(this,i,r.default??o,r.type);o!==l&&(U(this,h,!0),this.$data[n]=l,this.attributeChanged(e,o,l))}emit(t,e,s){D(this,f)||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){D(this,f)||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(T.IS_DEV&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(T.IS_DEV&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){var t,s;D(this,f)||(U(this,f,!0),U(this,c,!1),_(this,v,N).call(this),null==(t=D(this,e))||t.destroy(),U(this,e,void 0),null==(s=D(this,r))||s.call(this),U(this,r,void 0),this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,r=new WeakMap,n=new WeakMap,o=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,v=new WeakSet,w=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=D(J,y),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const r of t){if(s.has(r))continue;if(e.some(t=>r.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,r);if(!t||!("value"in t))continue;const a=t.value,n=i.get(r);(null==n?void 0:n.set)&&(delete this[r],this[r]=a)}},g=function(e){const{proxy:s,dispose:a}=I.observe(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,r=D(this,t),n=String(i),o=null==(s=r.propMap)?void 0:s.get(n);(null==o?void 0:o.reflect)&&_(this,v,S).call(this,o,a)}this.emit("dataChange",{...e}),_(this,v,j).call(this)});U(this,i,s),U(this,r,a)},S=function(t,e){const s=x.camelToKebab(t.name);D(this,p).add(s);try{if(null==e)return void this.removeAttribute(s);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)}}finally{D(this,p).delete(s)}},M=function(t){t.ir&&U(this,s,t.ir)},O=function(){const e=D(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;let e,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(e=Object.getOwnPropertyDescriptor(s,t.name),!e);)s=Object.getPrototypeOf(s);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},$=function(){D(this,d)||(U(this,d,!0),_(this,v,O).call(this))},k=function(t,e,s){if(null===t)return"boolean"!==s&&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(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=JSON.parse(t);return Array.isArray(s)?s:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},j=function(){D(this,f)||(D(this,c)?!D(this,o)&&D(this,e)&&(U(this,o,!0),queueMicrotask(()=>{D(this,f)||(U(this,o,!1),_(this,v,W).call(this))})):U(this,u,!0))},W=function(){var t;if(!D(this,f)&&!D(this,n)&&D(this,c)){U(this,n,!0);try{D(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),null==(t=D(this,e))||t.update(),this.updated(),D(this,h)&&(this.afterAttributesUpdate(),U(this,h,!1))}finally{U(this,n,!1)}}},C=function(){var e;const s=D(this,t);if(!s.styles)return;const i=D(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return void U(this,b,!0)}const r=i instanceof ShadowRoot?i:document.head,n=`solely-style-${T.SOLELY_VERSION}-${s.tagName}`,o=!(null==(e=s.shadowDOM)?void 0:e.use),h="undefined"!=typeof CSS&&CSS.escape?CSS.escape(n):n.replace(/([.#:[\]()!])/g,"\\$1");if(!r.querySelector(`#${h}`)){const t=document.createElement("style");t.id=n,t.textContent=s.styles,r.appendChild(t)}if(o){const t=D(J,m).get(n)||0;D(J,m).set(n,t+1),U(this,b,!0)}},N=function(){var e,s;if(!D(this,b))return;U(this,b,!1);const i=D(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${T.SOLELY_VERSION}-${i.tagName}`,e=D(J,m).get(t)||0;if(e<=1){const e=CSS.escape(t);null==(s=document.head.querySelector(`#${e}`))||s.remove(),D(J,m).delete(t)}else D(J,m).set(t,e-1)}},A=function(){D(this,l)||(U(this,l,!0),this.created())},q(J,m,new Map),q(J,y,new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]));let F=J;exports.default=F;
|
|
@@ -32,7 +32,7 @@ declare class BaseElement<TData extends object = Record<string, unknown>, TRefs
|
|
|
32
32
|
*/
|
|
33
33
|
protected error(condition: boolean, message: string): void;
|
|
34
34
|
/**
|
|
35
|
-
* 显式销毁组件,清理 renderer
|
|
35
|
+
* 显式销毁组件,清理 renderer 等资源,并从 DOM 中移除。
|
|
36
36
|
* 适用于确认组件不再 reconnect 的场景。
|
|
37
37
|
* 调用后如需重新使用组件,需重新创建实例。
|
|
38
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e,s,i,a,r,o,n,h,l,c,d,u,p,f,b,m,y,v,w,g,M,S,$,O,k,j,W,C,A,N,E=Object.defineProperty,P=t=>{throw TypeError(t)},U=(t,e,s)=>e.has(t)||P("Cannot "+s),D=(t,e,s)=>(U(t,e,"read from private field"),s?s.call(t):e.get(t)),L=(t,e,s)=>e.has(t)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),q=(t,e,s,i)=>(U(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),x=(t,e,s)=>(U(t,e,"access private method"),s);import{isObject as T}from"../../shared/is-object.js";import{SOLELY_VERSION as H,IS_DEV as J}from"../../shared/env.js";import{camelToKebab as R}from"../../shared/case-convert.js";import{observe as F}from"../reactivity/observe.js";import{createRender as I}from"../renderer/renderIR.js";const V=Symbol.for("solely.manifest"),_=class extends HTMLElement{constructor(m={}){var y,w;super(),L(this,v),((t,e,s)=>{e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(w="$refs")?w+"":w,{}),L(this,t),L(this,e),L(this,s),L(this,i),L(this,a),L(this,r),L(this,o,!1),L(this,n,!1),L(this,h,!1),L(this,l,!1),L(this,c,!1),L(this,d,!1),L(this,u,!1),L(this,p,new Set),L(this,f,!1),L(this,b,!1);const M=this.constructor;q(this,t,M[V]||{tagName:"base-element"});const $=D(this,t);q(this,a,(null==(y=$.shadowDOM)?void 0:y.use)?this.attachShadow({mode:$.shadowDOM.mode||"open"}):this),x(this,v,g).call(this,m),x(this,v,S).call(this,$),queueMicrotask(()=>x(this,v,N).call(this))}static get observedAttributes(){const t=this[V];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return D(this,i)}set $data(t){var e;T(t)||(t={}),t!==D(this,i)&&(null==(e=D(this,r))||e.call(this),x(this,v,g).call(this,t),x(this,v,O).call(this),x(this,v,j).call(this))}refresh(){x(this,v,j).call(this)}connectedCallback(){if(D(this,f))throw new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);q(this,c,!0);const i=D(this,t);if(x(this,v,N).call(this),(i.className||i.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),x(this,v,C).call(this),i.attributeMap&&T(this.$data)){x(this,v,O).call(this);for(const[t,e]of i.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=x(this,v,k).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}x(this,v,w).call(this),D(this,s)&&!D(this,e)&&q(this,e,I(D(this,s),D(this,a),this)),D(this,d)&&(q(this,d,!1),x(this,v,j).call(this)),this.mounted()}disconnectedCallback(){q(this,c,!1),D(this,f)||x(this,v,A).call(this),this.unmounted()}attributeChangedCallback(e,s,i){var a;if(D(this,f)||s===i||!T(this.$data))return;if(D(this,p).has(e))return;const r=null==(a=D(this,t).attributeMap)?void 0:a.get(e);if(!r)return;const o=r.name,n=this.$data[o],l=x(this,v,k).call(this,i,r.default??n,r.type);n!==l&&(q(this,h,!0),this.$data[o]=l,this.attributeChanged(e,n,l))}emit(t,e,s){D(this,f)||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){D(this,f)||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(J&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(J&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){var t,s;D(this,f)||(q(this,f,!0),q(this,c,!1),x(this,v,A).call(this),null==(t=D(this,e))||t.destroy(),q(this,e,void 0),null==(s=D(this,r))||s.call(this),q(this,r,void 0))}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,r=new WeakMap,o=new WeakMap,n=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,p=new WeakMap,f=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,v=new WeakSet,w=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=D(_,y),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const r of t){if(s.has(r))continue;if(e.some(t=>r.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,r);if(!t||!("value"in t))continue;const a=t.value,o=i.get(r);(null==o?void 0:o.set)&&(delete this[r],this[r]=a)}},g=function(e){const{proxy:s,dispose:a}=F(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,r=D(this,t),o=String(i),n=null==(s=r.propMap)?void 0:s.get(o);(null==n?void 0:n.reflect)&&x(this,v,M).call(this,n,a)}this.emit("dataChange",{...e}),x(this,v,j).call(this)});q(this,i,s),q(this,r,a)},M=function(t,e){const s=R(t.name);D(this,p).add(s);try{if(null==e)return void this.removeAttribute(s);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)}}finally{D(this,p).delete(s)}},S=function(t){t.ir&&q(this,s,t.ir)},$=function(){const e=D(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;let e,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(e=Object.getOwnPropertyDescriptor(s,t.name),!e);)s=Object.getPrototypeOf(s);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},O=function(){D(this,u)||(q(this,u,!0),x(this,v,$).call(this))},k=function(t,e,s){if(null===t)return"boolean"!==s&&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(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=JSON.parse(t);return Array.isArray(s)?s:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},j=function(){D(this,f)||(D(this,c)?!D(this,n)&&D(this,e)&&(q(this,n,!0),queueMicrotask(()=>{D(this,f)||(q(this,n,!1),x(this,v,W).call(this))})):q(this,d,!0))},W=function(){var t;if(!D(this,f)&&!D(this,o)&&D(this,c)){q(this,o,!0);try{D(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),null==(t=D(this,e))||t.update(),this.updated(),D(this,h)&&(this.afterAttributesUpdate(),q(this,h,!1))}finally{q(this,o,!1)}}},C=function(){var e;const s=D(this,t);if(!s.styles)return;const i=D(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return void q(this,b,!0)}const r=i instanceof ShadowRoot?i:document.head,o=`solely-style-${H}-${s.tagName}`,n=!(null==(e=s.shadowDOM)?void 0:e.use),h="undefined"!=typeof CSS&&CSS.escape?CSS.escape(o):o.replace(/([.#:[\]()!])/g,"\\$1");if(!r.querySelector(`#${h}`)){const t=document.createElement("style");t.id=o,t.textContent=s.styles,r.appendChild(t)}if(n){const t=D(_,m).get(o)||0;D(_,m).set(o,t+1),q(this,b,!0)}},A=function(){var e,s;if(!D(this,b))return;q(this,b,!1);const i=D(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${H}-${i.tagName}`,e=D(_,m).get(t)||0;if(e<=1){const e=CSS.escape(t);null==(s=document.head.querySelector(`#${e}`))||s.remove(),D(_,m).delete(t)}else D(_,m).set(t,e-1)}},N=function(){D(this,l)||(q(this,l,!0),this.created())},L(_,m,new Map),L(_,y,new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]));let z=_;export{z as default};
|
|
1
|
+
var t,e,s,i,a,r,o,n,h,l,c,d,u,p,f,b,m,y,v,w,g,M,S,$,O,k,j,W,C,A,N,E=Object.defineProperty,P=t=>{throw TypeError(t)},U=(t,e,s)=>e.has(t)||P("Cannot "+s),D=(t,e,s)=>(U(t,e,"read from private field"),s?s.call(t):e.get(t)),L=(t,e,s)=>e.has(t)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),q=(t,e,s,i)=>(U(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),x=(t,e,s)=>(U(t,e,"access private method"),s);import{isObject as T}from"../../shared/is-object.js";import{SOLELY_VERSION as H,IS_DEV as J}from"../../shared/env.js";import{camelToKebab as R}from"../../shared/case-convert.js";import{observe as F}from"../reactivity/observe.js";import{createRender as I}from"../renderer/renderIR.js";const V=Symbol.for("solely.manifest"),_=class extends HTMLElement{constructor(m={}){var y,w;super(),L(this,v),((t,e,s)=>{e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(this,"symbol"!=typeof(w="$refs")?w+"":w,{}),L(this,t),L(this,e),L(this,s),L(this,i),L(this,a),L(this,r),L(this,o,!1),L(this,n,!1),L(this,h,!1),L(this,l,!1),L(this,c,!1),L(this,d,!1),L(this,u,!1),L(this,p,new Set),L(this,f,!1),L(this,b,!1);const M=this.constructor;q(this,t,M[V]||{tagName:"base-element"});const $=D(this,t);q(this,a,(null==(y=$.shadowDOM)?void 0:y.use)?this.attachShadow({mode:$.shadowDOM.mode||"open"}):this),x(this,v,g).call(this,m),x(this,v,S).call(this,$),queueMicrotask(()=>x(this,v,N).call(this))}static get observedAttributes(){const t=this[V];return(null==t?void 0:t.attributeMap)?Array.from(t.attributeMap.keys()):[]}get $data(){return D(this,i)}set $data(t){var e;T(t)||(t={}),t!==D(this,i)&&(null==(e=D(this,r))||e.call(this),x(this,v,g).call(this,t),x(this,v,O).call(this),x(this,v,j).call(this))}refresh(){x(this,v,j).call(this)}connectedCallback(){if(D(this,f))throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);q(this,c,!0);const i=D(this,t);if(x(this,v,N).call(this),(i.className||i.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),x(this,v,C).call(this),i.attributeMap&&T(this.$data)){x(this,v,O).call(this);for(const[t,e]of i.attributeMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),a=x(this,v,k).call(this,i,e.default,e.type);this.$data[s]=a}else"default"in e&&void 0===this.$data[s]&&(this.$data[s]=e.default,"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}x(this,v,w).call(this),D(this,s)&&!D(this,e)&&q(this,e,I(D(this,s),D(this,a),this)),D(this,d)&&(q(this,d,!1),x(this,v,j).call(this)),this.mounted()}disconnectedCallback(){q(this,c,!1),D(this,f)||x(this,v,A).call(this),this.unmounted()}attributeChangedCallback(e,s,i){var a;if(D(this,f)||s===i||!T(this.$data))return;if(D(this,p).has(e))return;const r=null==(a=D(this,t).attributeMap)?void 0:a.get(e);if(!r)return;const o=r.name,n=this.$data[o],l=x(this,v,k).call(this,i,r.default??n,r.type);n!==l&&(q(this,h,!0),this.$data[o]=l,this.attributeChanged(e,n,l))}emit(t,e,s){D(this,f)||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){D(this,f)||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(J&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(J&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){var t,s;D(this,f)||(q(this,f,!0),q(this,c,!1),x(this,v,A).call(this),null==(t=D(this,e))||t.destroy(),q(this,e,void 0),null==(s=D(this,r))||s.call(this),q(this,r,void 0),this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,r=new WeakMap,o=new WeakMap,n=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,p=new WeakMap,f=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,v=new WeakSet,w=function(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=D(_,y),i=new Map;let a=Object.getPrototypeOf(this);for(;a&&a!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(a);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);a=Object.getPrototypeOf(a)}for(const r of t){if(s.has(r))continue;if(e.some(t=>r.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,r);if(!t||!("value"in t))continue;const a=t.value,o=i.get(r);(null==o?void 0:o.set)&&(delete this[r],this[r]=a)}},g=function(e){const{proxy:s,dispose:a}=F(e,e=>{var s;if("set"===e.type){const{key:i,newValue:a}=e,r=D(this,t),o=String(i),n=null==(s=r.propMap)?void 0:s.get(o);(null==n?void 0:n.reflect)&&x(this,v,M).call(this,n,a)}this.emit("dataChange",{...e}),x(this,v,j).call(this)});q(this,i,s),q(this,r,a)},M=function(t,e){const s=R(t.name);D(this,p).add(s);try{if(null==e)return void this.removeAttribute(s);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)}}finally{D(this,p).delete(s)}},S=function(t){t.ir&&q(this,s,t.ir)},$=function(){const e=D(this,t);if(e.attributeMap)for(const[,t]of e.attributeMap){if(!1===t.reactive)continue;let e,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(e=Object.getOwnPropertyDescriptor(s,t.name),!e);)s=Object.getPrototypeOf(s);if(!(null==e?void 0:e.get)&&!(null==e?void 0:e.set)){const e=Object.getOwnPropertyDescriptor(this,t.name);e&&"value"in e&&(this.$data[t.name]=e.value,delete this[t.name]),Object.defineProperty(this,t.name,{get:()=>this.$data[t.name],set:e=>{this.$data[t.name]=e},configurable:!0,enumerable:!0})}}},O=function(){D(this,u)||(q(this,u,!0),x(this,v,$).call(this))},k=function(t,e,s){if(null===t)return"boolean"!==s&&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(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=JSON.parse(t);return Array.isArray(s)?s:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},j=function(){D(this,f)||(D(this,c)?!D(this,n)&&D(this,e)&&(q(this,n,!0),queueMicrotask(()=>{D(this,f)||(q(this,n,!1),x(this,v,W).call(this))})):q(this,d,!0))},W=function(){var t;if(!D(this,f)&&!D(this,o)&&D(this,c)){q(this,o,!0);try{D(this,h)&&this.beforeAttributesUpdate(),this.beforeUpdate(),null==(t=D(this,e))||t.update(),this.updated(),D(this,h)&&(this.afterAttributesUpdate(),q(this,h,!1))}finally{q(this,o,!1)}}},C=function(){var e;const s=D(this,t);if(!s.styles)return;const i=D(this,a);if(s.sheet&&i instanceof ShadowRoot&&"adoptedStyleSheets"in i){if(!i.adoptedStyleSheets.includes(s.sheet)){const t=Array.from(i.adoptedStyleSheets);t.push(s.sheet),i.adoptedStyleSheets=t}return void q(this,b,!0)}const r=i instanceof ShadowRoot?i:document.head,o=`solely-style-${H}-${s.tagName}`,n=!(null==(e=s.shadowDOM)?void 0:e.use),h="undefined"!=typeof CSS&&CSS.escape?CSS.escape(o):o.replace(/([.#:[\]()!])/g,"\\$1");if(!r.querySelector(`#${h}`)){const t=document.createElement("style");t.id=o,t.textContent=s.styles,r.appendChild(t)}if(n){const t=D(_,m).get(o)||0;D(_,m).set(o,t+1),q(this,b,!0)}},A=function(){var e,s;if(!D(this,b))return;q(this,b,!1);const i=D(this,t);if(!(null==(e=i.shadowDOM)?void 0:e.use)&&i.styles){const t=`solely-style-${H}-${i.tagName}`,e=D(_,m).get(t)||0;if(e<=1){const e=CSS.escape(t);null==(s=document.head.querySelector(`#${e}`))||s.remove(),D(_,m).delete(t)}else D(_,m).set(t,e-1)}},N=function(){D(this,l)||(q(this,l,!0),this.created())},L(_,m,new Map),L(_,y,new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]));let z=_;export{z as default};
|
package/dist/shared/env.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(()=>{var o,e;if("undefined"!=typeof window){if(null==(o=window.location)?void 0:o.search.includes("debug"))return!0;const e=globalThis;if(!0===e.__DEBUG__||!0===e.__IS_DEV__)return!0}return!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes((null==(e=window.location)?void 0:e.hostname)||""))})(),e=!o;exports.IS_DEV=o,exports.IS_PROD=e,exports.SOLELY_VERSION="0.5.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=(()=>{var o,e;if("undefined"!=typeof window){if(null==(o=window.location)?void 0:o.search.includes("debug"))return!0;const e=globalThis;if(!0===e.__DEBUG__||!0===e.__IS_DEV__)return!0}return!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes((null==(e=window.location)?void 0:e.hostname)||""))})(),e=!o;exports.IS_DEV=o,exports.IS_PROD=e,exports.SOLELY_VERSION="0.5.1";
|
package/dist/shared/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=(()=>{var n,o;if("undefined"!=typeof window){if(null==(n=window.location)?void 0:n.search.includes("debug"))return!0;const o=globalThis;if(!0===o.__DEBUG__||!0===o.__IS_DEV__)return!0}return!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes((null==(o=window.location)?void 0:o.hostname)||""))})(),o=!n,i="0.5.
|
|
1
|
+
const n=(()=>{var n,o;if("undefined"!=typeof window){if(null==(n=window.location)?void 0:n.search.includes("debug"))return!0;const o=globalThis;if(!0===o.__DEBUG__||!0===o.__IS_DEV__)return!0}return!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes((null==(o=window.location)?void 0:o.hostname)||""))})(),o=!n,i="0.5.1";export{n as IS_DEV,o as IS_PROD,i as SOLELY_VERSION};
|
package/package.json
CHANGED