solely 0.5.7 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/compiler/ir/buildIR.cjs +1 -1
- package/dist/compiler/ir/buildIR.js +1 -1
- package/dist/compiler/parser/parser.cjs +1 -1
- package/dist/compiler/parser/parser.js +1 -1
- package/dist/components/commands/drawer/index.cjs +1 -1
- package/dist/components/commands/drawer/index.js +1 -1
- package/dist/components/commands/drawer/style.css.cjs +1 -1
- package/dist/components/commands/drawer/style.css.js +1 -1
- package/dist/components/commands/message/index.cjs +1 -1
- package/dist/components/commands/message/index.js +1 -1
- package/dist/components/commands/modal/index.cjs +1 -1
- package/dist/components/commands/modal/index.js +1 -1
- package/dist/components/commands/modal/style.css.cjs +1 -1
- package/dist/components/commands/modal/style.css.js +1 -1
- package/dist/components/commands/popconfirm/index.cjs +1 -1
- package/dist/components/commands/popconfirm/index.js +1 -1
- package/dist/components/commands/tooltip/index.cjs +1 -1
- package/dist/components/commands/tooltip/index.js +1 -1
- package/dist/components/commands/utils.cjs +1 -1
- package/dist/components/commands/utils.js +1 -1
- package/dist/components/elements/alert/index.cjs +1 -1
- package/dist/components/elements/alert/index.html.cjs +1 -1
- package/dist/components/elements/alert/index.html.js +1 -1
- package/dist/components/elements/alert/index.js +1 -1
- package/dist/components/elements/backtop/index.cjs +1 -1
- package/dist/components/elements/backtop/index.html.cjs +1 -1
- package/dist/components/elements/backtop/index.html.js +1 -1
- package/dist/components/elements/backtop/index.js +1 -1
- package/dist/components/elements/breadcrumb/index.cjs +1 -1
- package/dist/components/elements/breadcrumb/index.html.cjs +1 -1
- package/dist/components/elements/breadcrumb/index.html.js +1 -1
- package/dist/components/elements/breadcrumb/index.js +1 -1
- package/dist/components/elements/button/index.cjs +1 -1
- package/dist/components/elements/button/index.html.cjs +1 -1
- package/dist/components/elements/button/index.html.js +1 -1
- package/dist/components/elements/button/index.js +1 -1
- package/dist/components/elements/button/style.css.cjs +1 -1
- package/dist/components/elements/button/style.css.js +1 -1
- package/dist/components/elements/card/index.html.cjs +1 -1
- package/dist/components/elements/card/index.html.js +1 -1
- package/dist/components/elements/checkbox/index.cjs +1 -1
- package/dist/components/elements/checkbox/index.html.cjs +1 -1
- package/dist/components/elements/checkbox/index.html.js +1 -1
- package/dist/components/elements/checkbox/index.js +1 -1
- package/dist/components/elements/coordinate-input/index.html.cjs +1 -1
- package/dist/components/elements/coordinate-input/index.html.js +1 -1
- package/dist/components/elements/coordinate-input/style.css.cjs +1 -1
- package/dist/components/elements/coordinate-input/style.css.js +1 -1
- package/dist/components/elements/fab/index.cjs +1 -1
- package/dist/components/elements/fab/index.html.cjs +1 -1
- package/dist/components/elements/fab/index.html.js +1 -1
- package/dist/components/elements/fab/index.js +1 -1
- package/dist/components/elements/icon/index.cjs +1 -1
- package/dist/components/elements/icon/index.d.ts +8 -0
- package/dist/components/elements/icon/index.html.cjs +1 -1
- package/dist/components/elements/icon/index.html.js +1 -1
- package/dist/components/elements/icon/index.js +1 -1
- package/dist/components/elements/input/index.cjs +1 -1
- package/dist/components/elements/input/index.html.cjs +1 -1
- package/dist/components/elements/input/index.html.js +1 -1
- package/dist/components/elements/input/index.js +1 -1
- package/dist/components/elements/input/style.css.cjs +1 -1
- package/dist/components/elements/input/style.css.js +1 -1
- package/dist/components/elements/not-found/index.html.cjs +1 -1
- package/dist/components/elements/not-found/index.html.js +1 -1
- package/dist/components/elements/not-found/style.css.cjs +1 -1
- package/dist/components/elements/not-found/style.css.js +1 -1
- package/dist/components/elements/pagination/index.html.cjs +1 -1
- package/dist/components/elements/pagination/index.html.js +1 -1
- package/dist/components/elements/pagination/style.css.cjs +1 -1
- package/dist/components/elements/pagination/style.css.js +1 -1
- package/dist/components/elements/radio/index.cjs +1 -1
- package/dist/components/elements/radio/index.html.cjs +1 -1
- package/dist/components/elements/radio/index.html.js +1 -1
- package/dist/components/elements/radio/index.js +1 -1
- package/dist/components/elements/rate/index.cjs +1 -1
- package/dist/components/elements/rate/index.html.cjs +1 -1
- package/dist/components/elements/rate/index.html.js +1 -1
- package/dist/components/elements/rate/index.js +1 -1
- package/dist/components/elements/select/index.cjs +1 -1
- package/dist/components/elements/select/index.html.cjs +1 -1
- package/dist/components/elements/select/index.html.js +1 -1
- package/dist/components/elements/select/index.js +1 -1
- package/dist/components/elements/slider/index.cjs +1 -1
- package/dist/components/elements/slider/index.html.cjs +1 -1
- package/dist/components/elements/slider/index.html.js +1 -1
- package/dist/components/elements/slider/index.js +1 -1
- package/dist/components/elements/steps/index.cjs +1 -1
- package/dist/components/elements/steps/index.html.cjs +1 -1
- package/dist/components/elements/steps/index.html.js +1 -1
- package/dist/components/elements/steps/index.js +1 -1
- package/dist/components/elements/switch/index.cjs +1 -1
- package/dist/components/elements/switch/index.html.cjs +1 -1
- package/dist/components/elements/switch/index.html.js +1 -1
- package/dist/components/elements/switch/index.js +1 -1
- package/dist/components/elements/table/index.html.cjs +1 -1
- package/dist/components/elements/table/index.html.js +1 -1
- package/dist/components/elements/table/style.css.cjs +1 -1
- package/dist/components/elements/table/style.css.js +1 -1
- package/dist/components/elements/tabs/index.html.cjs +1 -1
- package/dist/components/elements/tabs/index.html.js +1 -1
- package/dist/components/elements/tag/index.html.cjs +1 -1
- package/dist/components/elements/tag/index.html.js +1 -1
- package/dist/components/elements/tag/style.css.cjs +1 -1
- package/dist/components/elements/tag/style.css.js +1 -1
- package/dist/components/elements/timeline/index.cjs +1 -1
- package/dist/components/elements/timeline/index.js +1 -1
- package/dist/components/elements/tooltip/index.cjs +1 -1
- package/dist/components/elements/tooltip/index.html.cjs +1 -1
- package/dist/components/elements/tooltip/index.html.js +1 -1
- package/dist/components/elements/tooltip/index.js +1 -1
- package/dist/components/elements/tree/index.cjs +1 -1
- package/dist/components/elements/tree/index.d.ts +5 -0
- package/dist/components/elements/tree/index.html.cjs +1 -1
- package/dist/components/elements/tree/index.html.js +1 -1
- package/dist/components/elements/tree/index.js +1 -1
- package/dist/components/elements/upload/index.cjs +1 -1
- package/dist/components/elements/upload/index.html.cjs +1 -1
- package/dist/components/elements/upload/index.html.js +1 -1
- package/dist/components/elements/upload/index.js +1 -1
- package/dist/components/theme/variables.css +50 -9
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/solely-vite-plugin.cjs +1 -1
- package/dist/plugins/solely-vite-plugin.js +1 -1
- package/dist/router/core.cjs +1 -1
- package/dist/router/core.js +1 -1
- package/dist/router/router-link.cjs +1 -1
- package/dist/router/router-link.js +1 -1
- package/dist/router/router-view.cjs +1 -1
- package/dist/router/router-view.js +1 -1
- package/dist/runtime/component/base-element.cjs +1 -1
- package/dist/runtime/component/base-element.js +1 -1
- package/dist/runtime/component/decorators.cjs +1 -1
- package/dist/runtime/component/decorators.js +1 -1
- package/dist/runtime/reactivity/observe.cjs +1 -1
- package/dist/runtime/reactivity/observe.js +1 -1
- package/dist/runtime/renderer/renderIR.cjs +1 -1
- package/dist/runtime/renderer/renderIR.js +1 -1
- package/dist/shared/env.cjs +1 -1
- package/dist/shared/env.js +1 -1
- package/dist/shared/functions.d.ts +2 -2
- package/dist/shared/gen-function.cjs +1 -1
- package/dist/shared/gen-function.js +1 -1
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -1
- package/dist/shared/svg-sanitize.cjs +1 -0
- package/dist/shared/svg-sanitize.d.ts +27 -0
- package/dist/shared/svg-sanitize.js +1 -0
- package/dist/shared/templateError.cjs +1 -1
- package/dist/shared/templateError.js +1 -1
- package/package.json +14 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../shared/is-object.cjs"),t=require("../../shared/env.cjs"),s=require("../../shared/case-convert.cjs"),i=require("../reactivity/observe.cjs"),r=require("../renderer/renderIR.cjs"),a=Symbol.for("solely.manifest");class o extends HTMLElement{$refs={};#e;#t;#s;#i;#r;#a;#o=!1;#n=!1;#d=!1;#h=!1;#c=!1;#l=!1;#u=!1;#p=new Set;#f=!1;#b=!1;static#y=new Map;static#m=new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]);static get observedAttributes(){const e=this[a];return e?.attributeMap?Array.from(e.attributeMap.keys()):[]}constructor(e={}){super();const t=this.constructor;this.#e=t[a]||{tagName:"base-element"};const s=this.#e;this.#r=s.shadowDOM?.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this,this.#S(e),this.#g(s),queueMicrotask(()=>this.#v())}#A(){const e=Object.getOwnPropertyNames(this),t=["#","_"],s=o.#m,i=new Map;let r=Object.getPrototypeOf(this);for(;r&&r!==HTMLElement.prototype;){const e=Object.getOwnPropertyDescriptors(r);for(const[t,s]of Object.entries(e))s.set&&!i.has(t)&&i.set(t,s);r=Object.getPrototypeOf(r)}for(const a of e){if(s.has(a))continue;if(t.some(e=>a.startsWith(e)))continue;const e=Object.getOwnPropertyDescriptor(this,a);if(!e||!("value"in e))continue;const r=e.value,o=i.get(a);o?.set&&(delete this[a],this[a]=r)}}#S(e){const{proxy:t,dispose:s}=i.observe(e,e=>{if("set"===e.type){const{key:t,newValue:s}=e,i=this.#e,r=String(t),a=i.propMap?.get(r);a?.reflect&&this.#O(a,s)}this.emit("dataChange",{...e}),this.#R()});this.#i=t,this.#a=s}#O(e,t){const i=s.camelToKebab(e.name);this.#p.add(i);try{if(null==t)return void this.removeAttribute(i);if("boolean"===e.type)t?this.setAttribute(i,""):this.removeAttribute(i);else{const e="object"==typeof t?JSON.stringify(t):String(t);this.setAttribute(i,e)}}finally{this.#p.delete(i)}}#g(e){e.ir&&(this.#s=e.ir)}#C(){const e=this.#e;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(!e?.get&&!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})}}}#$(){this.#u||(this.#u=!0,this.#C())}get $data(){return this.#i}set $data(t){e.isObject(t)||(t={}),t!==this.#i&&(this.#a?.(),this.#S(t),this.#$(),this.#R())}#w(e,t,s){if(null===e)return"boolean"!==s&&t;switch(s){case"boolean":return!0;case"number":{const s=Number(e);return isNaN(s)?t:s}case"object":try{return JSON.parse(e)}catch(i){return console.error(`[Solely] Failed to parse object value: "${e}", using default value.`,i),t}case"array":try{const s=JSON.parse(e);return Array.isArray(s)?s:t}catch(i){return console.error(`[Solely] Failed to parse array value: "${e}", using default value.`,i),t}default:return e}}#R(){this.#f||(this.#c?!this.#n&&this.#t&&(this.#n=!0,queueMicrotask(()=>{this.#f||(this.#n=!1,this.#j())})):this.#l=!0)}#j(){if(!this.#f&&!this.#o&&this.#c){this.#o=!0;try{this.#d&&this.beforeAttributesUpdate(),this.beforeUpdate(),this.#t?.update(),this.updated(),this.#d&&(this.afterAttributesUpdate(),this.#d=!1)}finally{this.#o=!1}}}refresh(){this.#R()}#M(){const e=this.#e;if(!e.styles)return;const s=this.#r;if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s){if(!s.adoptedStyleSheets.includes(e.sheet)){const t=Array.from(s.adoptedStyleSheets);t.push(e.sheet),s.adoptedStyleSheets=t}return void(this.#b=!0)}const i=s instanceof ShadowRoot?s:document.head,r=`solely-style-${t.SOLELY_VERSION}-${e.tagName}`,a=!e.shadowDOM?.use,n="undefined"!=typeof CSS&&CSS.escape?CSS.escape(r):r.replace(/([.#:[\]()!])/g,"\\$1");if(!i.querySelector(`#${n}`)){const t=document.createElement("style");t.id=r,t.textContent=e.styles,i.appendChild(t)}if(a){const e=o.#y.get(r)||0;o.#y.set(r,e+1),this.#b=!0}}#N(){if(!this.#b)return;this.#b=!1;const e=this.#e;if(!e.shadowDOM?.use&&e.styles){const s=`solely-style-${t.SOLELY_VERSION}-${e.tagName}`,i=o.#y.get(s)||0;if(i<=1){const e="undefined"!=typeof CSS&&CSS.escape?CSS.escape(s):s.replace(/([.#:[\]()!])/g,"\\$1");document.head.querySelector(`#${e}`)?.remove(),o.#y.delete(s)}else o.#y.set(s,i-1)}}connectedCallback(){if(this.#f)throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);this.#c=!0;const t=this.#e;if(this.#v(),(t.className||t.tagName||"").split(" ").forEach(e=>e&&this.classList.add(e)),this.#M(),t.attributeMap&&e.isObject(this.$data)){this.#$();for(const[e,s]of t.attributeMap){const t=s.name;if(this.hasAttribute(e)){const i=this.getAttribute(e),r=this.#w(i,s.default,s.type);this.$data[t]=r}else"default"in s&&void 0===this.$data[t]&&(this.$data[t]=s.default,"boolean"===s.type&&!0===s.default&&this.setAttribute(e,""))}}this.#A(),this.#s&&!this.#t&&(this.#t=r.createRender(this.#s,this.#r,this)),this.#l&&(this.#l=!1,this.#R()),this.mounted()}disconnectedCallback(){this.#c=!1,this.#f||this.#N(),this.unmounted()}attributeChangedCallback(t,s,i){if(this.#f||s===i||!e.isObject(this.$data))return;if(this.#p.has(t))return;const r=this.#e,a=r.attributeMap?.get(t);if(!a)return;const o=a.name,n=this.$data[o],d=this.#w(i,a.default??n,a.type);n!==d&&(this.#d=!0,this.$data[o]=d,this.attributeChanged(t,n,d))}#v(){this.#h||(this.#h=!0,this.created())}emit(e,t,s){this.#f||this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t,...s}))}emitNative(e,t){this.#f||this.dispatchEvent(new Event(e,{bubbles:!0,composed:!0,...t}))}warn(e,s){if(t.IS_DEV&&e){const e=this.tagName.toLowerCase();console.warn(`[${e}] ${s}`)}}error(e,s){if(t.IS_DEV&&e){const e=this.tagName.toLowerCase();console.error(`[${e}] ${s}`)}}dispose(){this.#f||(this.#f=!0,this.#c=!1,this.#N(),this.#t?.destroy(),this.#t=void 0,this.#a?.(),this.#a=void 0,this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(e,t,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}}exports.default=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{isObject as t}from"../../shared/is-object.js";import{SOLELY_VERSION as e,IS_DEV as s}from"../../shared/env.js";import{camelToKebab as i}from"../../shared/case-convert.js";import{observe as r}from"../reactivity/observe.js";import{createRender as a}from"../renderer/renderIR.js";const o=Symbol.for("solely.manifest");class n extends HTMLElement{$refs={};#t;#e;#s;#i;#r;#a;#o=!1;#n=!1;#d=!1;#h=!1;#c=!1;#l=!1;#u=!1;#p=new Set;#f=!1;#m=!1;static#b=new Map;static#y=new Set(["$data","$refs","constructor","created","mounted","beforeUpdate","updated","unmounted","attributeChanged","beforeAttributesUpdate","afterAttributesUpdate","emit","emitNative","refresh","dispose","warn","error"]);static get observedAttributes(){const t=this[o];return t?.attributeMap?Array.from(t.attributeMap.keys()):[]}constructor(t={}){super();const e=this.constructor;this.#t=e[o]||{tagName:"base-element"};const s=this.#t;this.#r=s.shadowDOM?.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this,this.#g(t),this.#v(s),queueMicrotask(()=>this.#S())}#A(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=n.#y,i=new Map;let r=Object.getPrototypeOf(this);for(;r&&r!==HTMLElement.prototype;){const t=Object.getOwnPropertyDescriptors(r);for(const[e,s]of Object.entries(t))s.set&&!i.has(e)&&i.set(e,s);r=Object.getPrototypeOf(r)}for(const a of t){if(s.has(a))continue;if(e.some(t=>a.startsWith(t)))continue;const t=Object.getOwnPropertyDescriptor(this,a);if(!t||!("value"in t))continue;const r=t.value,o=i.get(a);o?.set&&(delete this[a],this[a]=r)}}#g(t){const{proxy:e,dispose:s}=r(t,t=>{if("set"===t.type){const{key:e,newValue:s}=t,i=this.#t,r=String(e),a=i.propMap?.get(r);a?.reflect&&this.#O(a,s)}this.emit("dataChange",{...t}),this.#C()});this.#i=e,this.#a=s}#O(t,e){const s=i(t.name);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{this.#p.delete(s)}}#v(t){t.ir&&(this.#s=t.ir)}#R(){const t=this.#t;if(t.attributeMap)for(const[,e]of t.attributeMap){if(!1===e.reactive)continue;let t,s=Object.getPrototypeOf(this);for(;s&&s!==HTMLElement.prototype&&(t=Object.getOwnPropertyDescriptor(s,e.name),!t);)s=Object.getPrototypeOf(s);if(!t?.get&&!t?.set){const t=Object.getOwnPropertyDescriptor(this,e.name);t&&"value"in t&&(this.$data[e.name]=t.value,delete this[e.name]),Object.defineProperty(this,e.name,{get:()=>this.$data[e.name],set:t=>{this.$data[e.name]=t},configurable:!0,enumerable:!0})}}}#$(){this.#u||(this.#u=!0,this.#R())}get $data(){return this.#i}set $data(e){t(e)||(e={}),e!==this.#i&&(this.#a?.(),this.#g(e),this.#$(),this.#C())}#w(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}}#C(){this.#f||(this.#c?!this.#n&&this.#e&&(this.#n=!0,queueMicrotask(()=>{this.#f||(this.#n=!1,this.#j())})):this.#l=!0)}#j(){if(!this.#f&&!this.#o&&this.#c){this.#o=!0;try{this.#d&&this.beforeAttributesUpdate(),this.beforeUpdate(),this.#e?.update(),this.updated(),this.#d&&(this.afterAttributesUpdate(),this.#d=!1)}finally{this.#o=!1}}}refresh(){this.#C()}#M(){const t=this.#t;if(!t.styles)return;const s=this.#r;if(t.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s){if(!s.adoptedStyleSheets.includes(t.sheet)){const e=Array.from(s.adoptedStyleSheets);e.push(t.sheet),s.adoptedStyleSheets=e}return void(this.#m=!0)}const i=s instanceof ShadowRoot?s:document.head,r=`solely-style-${e}-${t.tagName}`,a=!t.shadowDOM?.use,o="undefined"!=typeof CSS&&CSS.escape?CSS.escape(r):r.replace(/([.#:[\]()!])/g,"\\$1");if(!i.querySelector(`#${o}`)){const e=document.createElement("style");e.id=r,e.textContent=t.styles,i.appendChild(e)}if(a){const t=n.#b.get(r)||0;n.#b.set(r,t+1),this.#m=!0}}#N(){if(!this.#m)return;this.#m=!1;const t=this.#t;if(!t.shadowDOM?.use&&t.styles){const s=`solely-style-${e}-${t.tagName}`,i=n.#b.get(s)||0;if(i<=1){const t="undefined"!=typeof CSS&&CSS.escape?CSS.escape(s):s.replace(/([.#:[\]()!])/g,"\\$1");document.head.querySelector(`#${t}`)?.remove(),n.#b.delete(s)}else n.#b.set(s,i-1)}}connectedCallback(){if(this.#f)throw this.remove(),new Error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`);this.#c=!0;const e=this.#t;if(this.#S(),(e.className||e.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),this.#M(),e.attributeMap&&t(this.$data)){this.#$();for(const[t,s]of e.attributeMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),r=this.#w(i,s.default,s.type);this.$data[e]=r}else"default"in s&&void 0===this.$data[e]&&(this.$data[e]=s.default,"boolean"===s.type&&!0===s.default&&this.setAttribute(t,""))}}this.#A(),this.#s&&!this.#e&&(this.#e=a(this.#s,this.#r,this)),this.#l&&(this.#l=!1,this.#C()),this.mounted()}disconnectedCallback(){this.#c=!1,this.#f||this.#N(),this.unmounted()}attributeChangedCallback(e,s,i){if(this.#f||s===i||!t(this.$data))return;if(this.#p.has(e))return;const r=this.#t,a=r.attributeMap?.get(e);if(!a)return;const o=a.name,n=this.$data[o],d=this.#w(i,a.default??n,a.type);n!==d&&(this.#d=!0,this.$data[o]=d,this.attributeChanged(e,n,d))}#S(){this.#h||(this.#h=!0,this.created())}emit(t,e,s){this.#f||this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}emitNative(t,e){this.#f||this.dispatchEvent(new Event(t,{bubbles:!0,composed:!0,...e}))}warn(t,e){if(s&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${e}`)}}error(t,e){if(s&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${e}`)}}dispose(){this.#f||(this.#f=!0,this.#c=!1,this.#N(),this.#e?.destroy(),this.#e=void 0,this.#a?.(),this.#a=void 0,this.remove())}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../shared/case-convert.cjs"),o=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const{tagName:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/env.cjs"),t=require("../../shared/case-convert.cjs"),o=require("../../compiler/parser/parser.cjs"),r=require("../../compiler/ir/buildIR.cjs"),n=Symbol.for("solely.manifest");exports.CustomElement=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const c=s,{tagName:i}=l,p="undefined"!=typeof HTMLElement&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement;if(a&&p)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(i))return e.IS_DEV&&console.warn(`[Solely] 标签名称 "${i}" 已经被注册,跳过重复定义。`),s[n]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e.IS_DEV&&console.info(`[Solely] Using precompiled IR for <${i}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${i}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${i}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=o.parseHtml(l.template);l.ir=r.buildIR(e,{source:l.template,filename:i})}catch(f){const t=f instanceof Error?f:new Error(String(f));console.error(`[Compiler Error] <${i}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e.IS_DEV?t.stack:"")}else e.IS_DEV&&console.warn(`[Solely] <${i}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e.IS_DEV&&console.warn(`[Solely] <${i}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,o=new Map;l.props.forEach(r=>{const n="string"==typeof r?{name:r}:r,s=t.camelToKebab(n.name),l=n.name,a={...n,name:l};e.set(s,a),o.set(l,a)}),l.attributeMap=e,l.propMap=o}class m extends c{}if(m[n]=l,a){if(e.IS_DEV){const e=s.prototype,t=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&console.error(`[${i}] 禁止重写 ${o}(),请使用框架钩子`)}customElements.define(i,m)}return m}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_DEV as e}from"../../shared/env.js";import{camelToKebab as t}from"../../shared/case-convert.js";import{parseHtml as o}from"../../compiler/parser/parser.js";import{buildIR as
|
|
1
|
+
import{IS_DEV as e}from"../../shared/env.js";import{camelToKebab as t}from"../../shared/case-convert.js";import{parseHtml as o}from"../../compiler/parser/parser.js";import{buildIR as n}from"../../compiler/ir/buildIR.js";const r=Symbol.for("solely.manifest"),s=s=>{const l=s,a="undefined"!=typeof window&&"undefined"!=typeof customElements;return s=>{const c=s,{tagName:i}=l,p="undefined"!=typeof HTMLElement&&!(s.prototype instanceof HTMLElement)&&s!==HTMLElement;if(a&&p)throw new TypeError(`[Solely] CustomElement decorator can only be applied to classes extending HTMLElement.\nReceived: ${s.name||"anonymous class"}`);if(a&&customElements.get(i))return e&&console.warn(`[Solely] 标签名称 "${i}" 已经被注册,跳过重复定义。`),s[r]=l,s;if("string"!=typeof l.template||l.ir){if(l.template&&!l.ir)if("object"==typeof l.template&&null!==l.template){const t=l.template;"root"===t.t&&Array.isArray(t.fns)&&Array.isArray(t.n)?(l.ir=t,e&&console.info(`[Solely] Using precompiled IR for <${i}> | Nodes: ${t.n.length} | Fns: ${t.fns.length}`)):console.error(`[Manifest Error] <${i}>: 提供的 template 不是有效的 IRRoot 对象。\n期望: { t: "root", fns: [], n: [] }\n实际: ${JSON.stringify(Object.keys(t))}`)}else console.error(`[Manifest Error] <${i}>: template 类型无效。\n期望: string 或 IRRoot 对象\n实际: ${typeof l.template}`)}else if(l.template.trim())try{const e=o(l.template);l.ir=n(e,{source:l.template,filename:i})}catch(f){const t=f instanceof Error?f:new Error(String(f));console.error(`[Compiler Error] <${i}>: 模板编译失败\n错误: ${t.message}\n模板长度: ${l.template.length} 字符`,e?t.stack:"")}else e&&console.warn(`[Solely] <${i}>: 模板为空字符串`);if(a&&l.styles&&!l.sheet&&"CSSStyleSheet"in window)try{const e=new CSSStyleSheet;"function"==typeof e.replaceSync&&(e.replaceSync(l.styles),l.sheet=e)}catch{e&&console.warn(`[Solely] <${i}>: CSSStyleSheet 不可用,将使用 style 标签回退方案`)}if(l.props&&!l.attributeMap){const e=new Map,o=new Map;l.props.forEach(n=>{const r="string"==typeof n?{name:n}:n,s=t(r.name),l=r.name,a={...r,name:l};e.set(s,a),o.set(l,a)}),l.attributeMap=e,l.propMap=o}class m extends c{}if(m[r]=l,a){if(e){const e=s.prototype,t=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const o of t)Object.prototype.hasOwnProperty.call(e,o)&&console.error(`[${i}] 禁止重写 ${o}(),请使用框架钩子`)}customElements.define(i,m)}return m}};export{s as CustomElement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/is-object.cjs"),t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function c(e,t,n){l(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function l(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function a(t,n){const r=i.get(n);if(r)for(const e of r.keys())l(n,e);for(let o=0;o<t.length;o++){const r=t[o];e.isObject(r)&&!p(r)&&c(n,String(o),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../shared/is-object.cjs"),t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function c(e,t,n){l(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function l(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function a(t,n){const r=i.get(n);if(r)for(const e of r.keys())l(n,e);for(let o=0;o<t.length;o++){const r=t[o];e.isObject(r)&&!p(r)&&c(n,String(o),w(r))}}function f(e){if(e&&"object"==typeof e){const n=e[t];if(n)return n}return e}const u=Object.prototype.toString,p=e=>{if(!e||"object"!=typeof e)return!1;const t=u.call(e);return"[object Date]"===t||"[object RegExp]"===t||"[object Map]"===t||"[object Set]"===t||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Response&&e instanceof Response||"undefined"!=typeof Request&&e instanceof Request};function y(e){return!(!e||!e[t])}const h=new Map,d=(e,t)=>{if(0===t.length)return!0;const n=e.map(String);for(let r=n.length;r>0;r--){const e=n.slice(0,r).join(".");if(t.some(t=>t.test(e)))return!0}return!1},g=(e,t)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!g(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Reflect.ownKeys(e),r=Reflect.ownKeys(t);if(n.length!==r.length)return!1;for(const o of n){if(!Reflect.has(t,o))return!1;const n=e[o],r=t[o];if(!g(n,r))return!1}return!0},b=(e,t)=>{e.active&&(e.deepCompare&&"set"===t.type&&g(t.oldValue,t.newValue)||(e.throttle>0?(e.pending.push(t),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([t]):e.callback(t)))},R=(e,t)=>{const n=[{node:e,relativePath:[],visited:new Set([e])}];let o=0;for(;o<n.length;){const{node:e,relativePath:i,visited:c}=n[o++],l=r.get(e);l&&l.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type?n=[...i,t.key]:"array-push"!==t.type&&"array-splice"!==t.type||(n=[...i,String(t.index)]),!d(n,e.filterRegexes))return;const r={...t,path:n};b(e,r)});const a=s.get(e);if(a)for(let t=a.length-1;t>=0;t--){const e=a[t],r=e.parentRef.deref();if(!r){a.splice(t,1);continue}if(c.has(r))continue;const o=new Set(c);o.add(r),n.push({node:r,relativePath:[e.key,...i],visited:o})}}},v={},j=(e,t)=>e[t];["push","pop","shift","unshift","splice"].forEach(t=>{v[t]=function(...n){const r=this,i=f(r),s=o.get(r)||0;o.set(r,s+1);try{const o=i.length,s=j(i,t).apply(i,n);if("push"===t){const t=i.length-n.length;for(let o=0;o<n.length;o++){const n=i[t+o];e.isObject(n)&&!p(n)&&c(r,String(t+o),w(n))}R(r,{type:"array-push",index:t,values:n})}else if("pop"===t)l(r,String(o-1)),R(r,{type:"array-splice",index:o-1,deleteCount:1,insert:[]});else if(a(i,r),"unshift"===t)R(r,{type:"array-push",index:0,values:n});else if("shift"===t)R(r,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===t){const[e,t,...o]=n;R(r,{type:"array-splice",index:e,deleteCount:t,insert:o})}return s}finally{o.set(r,s)}}}),["sort","reverse","fill","copyWithin"].forEach(e=>{v[e]=function(...t){const n=this,r=f(n),i=o.get(n)||0;o.set(n,i+1);try{const o=j(r,e).apply(r,t);return a(r,n),R(n,{type:"array-reset",method:e}),o}finally{o.set(n,i)}}}),["indexOf","lastIndexOf","includes"].forEach(e=>{v[e]=function(t,...n){const r=f(this),o=j(r,e);let i=o.apply(r,[t,...n]);return-1!==i&&!1!==i||!y(t)||(i=o.apply(r,[f(t),...n])),i}});const m={get(n,r,o){if(r===t)return n;if(Array.isArray(n)&&Object.prototype.hasOwnProperty.call(v,r))return Reflect.get(v,r,o);const s=Reflect.get(n,r,o);if("symbol"==typeof r)return s;if(e.isObject(s)&&!p(s)){const e=w(s),t=i.get(o)?.get(r);return t!==e&&c(o,r,e),e}return s},set(t,n,r,i){const s=Reflect.get(t,n,i),a=f(r);if(Object.is(s,a))return!0;const u=Reflect.set(t,n,a,i);return!!u&&(e.isObject(a)&&!p(a)?c(i,n,w(a)):l(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(a)?R(i,{type:"array-replace",oldValue:s,newValue:a}):R(i,{type:"set",key:n,newValue:a,oldValue:s})),u)},deleteProperty(e,t){if(!Reflect.has(e,t))return!1;const r=Reflect.get(e,t),i=Reflect.deleteProperty(e,t);if(i){const i=n.get(e);i&&(l(i,t),0===(o.get(i)||0)&&R(i,{type:"delete",key:t,oldValue:r}))}return i}};function w(e){if(!Object.isExtensible(e))return e;if(p(e))return e;if(e[t])return e;const r=n.get(e);if(r)return r;const o=new Proxy(e,m);return n.set(e,o),o}exports.isProxy=y,exports.observe=function(t,n,o={}){const{throttle:i=0,onBatch:s,immediate:c=!1,deepCompare:l}=o,a={callback:n,onBatch:s,throttle:i,filterRegexes:(Array.isArray(o.filter)?o.filter:o.filter?[o.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=h.get(e);if(t)return t;let n="";for(let c=0;c<e.length;c++){const t=e[c];"*"===t&&"*"===e[c+1]?(n+="**",c++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let c=0;c<r.length;c++){const e=r[c];"**"===e?1===r.length?o.push(".*"):0===c?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let c=0;c<o.length;c++)if(i+=o[c],c<o.length-1){const e=o[c],t=o[c+1];if(e.endsWith("\\.)*"))continue;if(t.startsWith("(?:\\."))continue;i+="\\."}i+="$";const s=new RegExp(i);return h.set(e,s),s}),pending:[],timer:null,active:!0,deepCompare:l},u=w(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(a),c){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e.isObject(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(c=>{const l=Reflect.get(t,c);if(e.isObject(l)&&s.has(l))return;const a=Reflect.get(o,c),f=[...i,c];n.forEach(e=>{d(f,e.filterRegexes)&&b(e,{type:"set",key:c,newValue:l,oldValue:void 0,path:f})}),e.isObject(l)&&!p(l)&&r(l,a,f,s)}))};r(f(t),u)}const g=()=>{const e=r.get(u);e&&(e.delete(a),0===e.size&&r.delete(u)),a.pending=[],a.timer&&(clearTimeout(a.timer),a.timer=null)};return{proxy:u,unobserve:()=>{a.active&&(a.active=!1,g())},resume:()=>{a.active||(a.active=!0,(()=>{let e=r.get(u);e||(e=new Set,r.set(u,e)),e.add(a)})())},dispose:()=>{if(!a.active)return a.callback=()=>{},void(a.onBatch=void 0);a.active=!1,g(),a.callback=()=>{},a.onBatch=void 0}}},exports.toProxy=function(e){return e&&"object"==typeof e&&"proxy"in e?e.proxy:e},exports.toRaw=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../../shared/is-object.js";const t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function l(e,t,n){a(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function a(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function c(t,n){const r=i.get(n);if(r)for(const e of r.keys())a(n,e);for(let o=0;o<t.length;o++){const r=t[o];e(r)&&!p(r)&&l(n,String(o),
|
|
1
|
+
import{isObject as e}from"../../shared/is-object.js";const t=Symbol("solely.raw"),n=new WeakMap,r=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap;function l(e,t,n){a(e,t);let r=i.get(e);r||(r=new Map,i.set(e,r)),r.set(t,n);let o=s.get(n);o||(o=[],s.set(n,o)),o.some(n=>n.parentRef.deref()===e&&n.key===t)||o.push({parentRef:new WeakRef(e),key:t})}function a(e,t){const n=i.get(e);if(!n)return;const r=n.get(t);if(!r)return;n.delete(t);const o=s.get(r);if(o){const n=o.filter(n=>{const r=n.parentRef.deref();return void 0!==r&&!(r===e&&n.key===t)});0===n.length?s.delete(r):s.set(r,n)}}function c(t,n){const r=i.get(n);if(r)for(const e of r.keys())a(n,e);for(let o=0;o<t.length;o++){const r=t[o];e(r)&&!p(r)&&l(n,String(o),A(r))}}function f(e){if(e&&"object"==typeof e){const n=e[t];if(n)return n}return e}const u=Object.prototype.toString,p=e=>{if(!e||"object"!=typeof e)return!1;const t=u.call(e);return"[object Date]"===t||"[object RegExp]"===t||"[object Map]"===t||"[object Set]"===t||"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Response&&e instanceof Response||"undefined"!=typeof Request&&e instanceof Request};function y(e){return!(!e||!e[t])}function h(e){return e&&"object"==typeof e&&"proxy"in e?e.proxy:e}const d=new Map,g=(e,t)=>{if(0===t.length)return!0;const n=e.map(String);for(let r=n.length;r>0;r--){const e=n.slice(0,r).join(".");if(t.some(t=>t.test(e)))return!0}return!1},R=(e,t)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!R(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Reflect.ownKeys(e),r=Reflect.ownKeys(t);if(n.length!==r.length)return!1;for(const o of n){if(!Reflect.has(t,o))return!1;const n=e[o],r=t[o];if(!R(n,r))return!1}return!0},b=(e,t)=>{e.active&&(e.deepCompare&&"set"===t.type&&R(t.oldValue,t.newValue)||(e.throttle>0?(e.pending.push(t),e.timer||(e.timer=setTimeout(()=>{if(!e.active)return;const t=[...e.pending];e.pending=[],e.timer=null,t.length>0&&(e.onBatch?e.onBatch(t):e.callback(t[t.length-1]))},e.throttle))):e.onBatch?e.onBatch([t]):e.callback(t)))},m=(e,t)=>{const n=[{node:e,relativePath:[],visited:new Set([e])}];let o=0;for(;o<n.length;){const{node:e,relativePath:i,visited:l}=n[o++],a=r.get(e);a&&a.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type?n=[...i,t.key]:"array-push"!==t.type&&"array-splice"!==t.type||(n=[...i,String(t.index)]),!g(n,e.filterRegexes))return;const r={...t,path:n};b(e,r)});const c=s.get(e);if(c)for(let t=c.length-1;t>=0;t--){const e=c[t],r=e.parentRef.deref();if(!r){c.splice(t,1);continue}if(l.has(r))continue;const o=new Set(l);o.add(r),n.push({node:r,relativePath:[e.key,...i],visited:o})}}},v={},w=(e,t)=>e[t];["push","pop","shift","unshift","splice"].forEach(t=>{v[t]=function(...n){const r=this,i=f(r),s=o.get(r)||0;o.set(r,s+1);try{const o=i.length,s=w(i,t).apply(i,n);if("push"===t){const t=i.length-n.length;for(let o=0;o<n.length;o++){const n=i[t+o];e(n)&&!p(n)&&l(r,String(t+o),A(n))}m(r,{type:"array-push",index:t,values:n})}else if("pop"===t)a(r,String(o-1)),m(r,{type:"array-splice",index:o-1,deleteCount:1,insert:[]});else if(c(i,r),"unshift"===t)m(r,{type:"array-push",index:0,values:n});else if("shift"===t)m(r,{type:"array-splice",index:0,deleteCount:1,insert:[]});else if("splice"===t){const[e,t,...o]=n;m(r,{type:"array-splice",index:e,deleteCount:t,insert:o})}return s}finally{o.set(r,s)}}}),["sort","reverse","fill","copyWithin"].forEach(e=>{v[e]=function(...t){const n=this,r=f(n),i=o.get(n)||0;o.set(n,i+1);try{const o=w(r,e).apply(r,t);return c(r,n),m(n,{type:"array-reset",method:e}),o}finally{o.set(n,i)}}}),["indexOf","lastIndexOf","includes"].forEach(e=>{v[e]=function(t,...n){const r=f(this),o=w(r,e);let i=o.apply(r,[t,...n]);return-1!==i&&!1!==i||!y(t)||(i=o.apply(r,[f(t),...n])),i}});const k={get(n,r,o){if(r===t)return n;if(Array.isArray(n)&&Object.prototype.hasOwnProperty.call(v,r))return Reflect.get(v,r,o);const s=Reflect.get(n,r,o);if("symbol"==typeof r)return s;if(e(s)&&!p(s)){const e=A(s),t=i.get(o)?.get(r);return t!==e&&l(o,r,e),e}return s},set(t,n,r,i){const s=Reflect.get(t,n,i),c=f(r);if(Object.is(s,c))return!0;const u=Reflect.set(t,n,c,i);return!!u&&(e(c)&&!p(c)?l(i,n,A(c)):a(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(c)?m(i,{type:"array-replace",oldValue:s,newValue:c}):m(i,{type:"set",key:n,newValue:c,oldValue:s})),u)},deleteProperty(e,t){if(!Reflect.has(e,t))return!1;const r=Reflect.get(e,t),i=Reflect.deleteProperty(e,t);if(i){const i=n.get(e);i&&(a(i,t),0===(o.get(i)||0)&&m(i,{type:"delete",key:t,oldValue:r}))}return i}};function A(e){if(!Object.isExtensible(e))return e;if(p(e))return e;if(e[t])return e;const r=n.get(e);if(r)return r;const o=new Proxy(e,k);return n.set(e,o),o}function x(t,n,o={}){const{throttle:i=0,onBatch:s,immediate:l=!1,deepCompare:a}=o,c={callback:n,onBatch:s,throttle:i,filterRegexes:(Array.isArray(o.filter)?o.filter:o.filter?[o.filter]:[]).map(e=>{if(""===e)return/^.*$/;const t=d.get(e);if(t)return t;let n="";for(let l=0;l<e.length;l++){const t=e[l];"*"===t&&"*"===e[l+1]?(n+="**",l++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let l=0;l<r.length;l++){const e=r[l];"**"===e?1===r.length?o.push(".*"):0===l?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let l=0;l<o.length;l++)if(i+=o[l],l<o.length-1){const e=o[l],t=o[l+1];if(e.endsWith("\\.)*"))continue;if(t.startsWith("(?:\\."))continue;i+="\\."}i+="$";const s=new RegExp(i);return d.set(e,s),s}),pending:[],timer:null,active:!0,deepCompare:a},u=A(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(c),l){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(l=>{const a=Reflect.get(t,l);if(e(a)&&s.has(a))return;const c=Reflect.get(o,l),f=[...i,l];n.forEach(e=>{g(f,e.filterRegexes)&&b(e,{type:"set",key:l,newValue:a,oldValue:void 0,path:f})}),e(a)&&!p(a)&&r(a,c,f,s)}))};r(f(t),u)}const h=()=>{const e=r.get(u);e&&(e.delete(c),0===e.size&&r.delete(u)),c.pending=[],c.timer&&(clearTimeout(c.timer),c.timer=null)};return{proxy:u,unobserve:()=>{c.active&&(c.active=!1,h())},resume:()=>{c.active||(c.active=!0,(()=>{let e=r.get(u);e||(e=new Set,r.set(u,e)),e.add(c)})())},dispose:()=>{if(!c.active)return c.callback=()=>{},void(c.onBatch=void 0);c.active=!1,h(),c.callback=()=>{},c.onBatch=void 0}}}export{y as isProxy,x as observe,h as toProxy,f as toRaw};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,t=(t,s,n)=>((t,s,n)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n)(t,"symbol"!=typeof s?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),n=require("../../shared/templateError.cjs"),i=require("../../shared/env.cjs"),o=require("./html-decode.cjs"),r=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g,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"},c=new Set(["data-","aria-","role","form"]),l=new Set(["value","selectedIndex"]),p=new WeakMap;function d(e){let t=p.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},p.set(e,t)),t}function u(e,t){var s;const n=null==(s=t.a)?void 0:s.find(e=>"class"===e.k&&!e.d);(null==n?void 0:n.v)&&e.setAttribute("class",n.v)}function f(e,t){var s;if(!e.style)return;const n=null==(s=t.a)?void 0:s.find(e=>"style"===e.k&&!e.d),i=n?m(n.v):{};for(const o in i){const t=i[o];o.startsWith("--")?e.style.setProperty(o,t):e.style[o]=t}}const v=e=>!(!e||0===e.length||/\s/.test(e)&&(i.IS_DEV&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function m(e){const t={},s=[[e]];for(;s.length;){const[e,n]=s.pop()||[];if(e){if("string"==typeof e){let s;for(r.lastIndex=0;null!==(s=r.exec(e));){const e=s[1].trim(),n=s[2].trim();e&&n&&(t[e]=n)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push([e[t]]);else if("object"==typeof e){const i=e;for(const e in i){const o=i[e];if(null==o)continue;const r=n?`${n}-${e}`:e;"object"!=typeof o||Array.isArray(o)?t[r]=String(o):s.push([o,r])}}}}return t}function y(e,t,s){const n=null==s?"":String(s),i=t.indexOf(":");if(i>0){const s=t.slice(0,i),o=a[s];if(o)return void(e.getAttributeNS(o,t)!==n&&e.setAttributeNS(o,t,n))}e.getAttribute(t)!==n&&e.setAttribute(t,n)}function g(e,t,s,n){const i=h[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||c.has(t))return void y(e,t,s);const o=e,r=o.tagName;if(null!=s){if("src"===i||"href"===i){const t=String(s);if(o[i]===t||e.getAttribute(i)===t)return}if("value"!==i||"INPUT"!==r&&"TEXTAREA"!==r||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!h[t]?y(e,t,s):o[i]!==s&&(o[i]=s);else{if(o[i]===s)return;o[i]=s}}else if("boolean"==typeof o[i])!1!==o[i]&&(o[i]=!1);else{const s=o[i];""!==s&&void 0!==s&&(o[i]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class N{constructor(e,s,n={}){t(this,"nodeMap",new Map),t(this,"prevNodeMap",new Map),t(this,"pathStack",[]),t(this,"pathKey",""),t(this,"staticSubtreeCache",new Map),t(this,"keepaliveCache",new Map),t(this,"currentKaKey",null),t(this,"kaDepth",0),t(this,"isKaRestoring",!1),t(this,"rafIds",new Set),t(this,"keepaliveAccessCounter",0),t(this,"maxKeepalive",20),t(this,"renderedKaKeys",new Set),this.ir=e,this.container=s,this.scope=n}scheduleRaf(e){const t=requestAnimationFrame(()=>{this.rafIds.delete(t),e()});return this.rafIds.add(t),t}pushPath(e){this.pathStack.push(e),this.pathKey=this.pathStack.join(".")}popPath(){this.pathStack.pop(),this.pathKey=this.pathStack.join(".")}evalIR(e,t,s){var o;const r=this.ir.fns[e-1];if(i.IS_DEV)try{return r?r.apply(this.scope,t):""}catch(a){return n.showTemplateError(a.message||a.toString(),(null==(o=this.ir.m)?void 0:o.src)||"",s,this.scope.tagName),""}return r?r.apply(this.scope,t):""}createElement(e,t){const s=e.g??"";return t instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):o.default(e.x||"");return document.createTextNode(s)}createComment(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(s)}removeEventListenersFromNode(e){const t=p.get(e);if(t)for(const[s,n]of Object.entries(t.events))n.listener&&e.removeEventListener(s,n.listener)}applyAttrs(e,t,s,n=!1,i=!1){const o=[],r=d(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let h;r.loops=s;let c,p=!1,u=!1;for(const d of t){const{k:t,f:f,d:v,v:m}=d;if(":class"===t){h=this.evalIR(f??-1,[s],d.__m),p=!0;continue}if(":style"===t){c=this.evalIR(f??-1,[s],d.__m),u=!0;continue}if("class"===t||"style"===t)continue;const N=t[0];if("@"===N){const s=t.slice(1),i=d.r??"user";let o=r.events[s];if(!o){o={model:[],user:[],listener:null};const t=e=>{for(const t of o.model)t(e);for(const t of o.user)t(e)};o.listener=t,e.addEventListener(s,t),r.events[s]=o}if(!n){const e=e=>this.evalIR(f??-1,[e,r.loops],d.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],d.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],d.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],d.__m));continue}if("ref"===t&&m){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[m]=e;continue}const S=v?this.evalIR(f??-1,[s],d.__m):m??"";if(":"===N){const s=t.slice(1);"SELECT"===e.tagName&&l.has(s)?o.push(()=>g(e,s,S,a)):g(e,s,S,a)}else n||y(e,t,String(S))}return p&&((e,t)=>{const s=d(e),n=s.prevClassObj,i=function(e){const t={},s=[e];for(;s.length;){const e=s.pop();if(e)if("string"==typeof e){const s=e.split(" ");for(let e=0;e<s.length;e++){const n=s[e].trim();n&&(t[n]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push(e[t]);else if("object"==typeof e){const s=e;for(const e in s)s[e]&&(t[e]=!0)}}return t}(t),o={};for(const h in i)v(h)&&(o[h]=i[h]);if(!n){const t=[];for(const e in o)t.push(e);return t.length&&e.classList.add(...t),void(s.prevClassObj=o)}const r=[],a=[];for(const h in n)o[h]||a.push(h);for(const h in o)n[h]||r.push(h);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,h),u&&((e,t)=>{const s=d(e),n=m(t),i=s.prevStyleObj;if(!i){for(const t in n){const s=n[t];t.startsWith("--")?e.style.setProperty(t,s):e.style[t]=s}return void(s.prevStyleObj=n)}let o=!1;for(const r in i)r in n||(r.startsWith("--")?e.style.removeProperty(r):e.style[r]="",o=!0);for(const r in n){const t=n[r];t!==i[r]&&(r.startsWith("--")?e.style.setProperty(r,t):e.style[r]=t,o=!0)}o&&(s.prevStyleObj=n)})(e,c),o}updateNode(e,t,s){const n=t.d?this.evalIR(t.f??-1,[s],t.__m):t.x||"";t.d&&e.textContent!==n&&(e.textContent=n)}createStaticSubtree(e,t,n){var i;switch(e.t){case s.ASTType.Element:{const s=this.createElement(e,t);u(s,e),f(s,e);const o=this.applyAttrs(s,e.a??[],n);return null==(i=e.c)||i.forEach(e=>{const t=this.createStaticSubtree(e,s,n);s.appendChild(t)}),o.forEach(e=>e()),s}case s.ASTType.Text:return this.createText(e,n);case s.ASTType.Comment:return this.createComment(e,n);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,s,n){const i=this.staticSubtreeCache.get(t);if(i){const e=i.cloneNode(!0);return s.appendChild(e),e}const o=this.createStaticSubtree(e,s,n);return s.appendChild(o),this.staticSubtreeCache.set(t,o.cloneNode(!0)),o}currentKey(){return this.pathKey}findEntry(e){let t=this.nodeMap.get(e);return t||(t=this.prevNodeMap.get(e),t&&(this.prevNodeMap.delete(e),this.nodeMap.set(e,t))),t}registerNode(e,t,s,n){const i=this.currentKaKey?{irNode:t,node:s,loops:n,kaKey:this.currentKaKey}:{irNode:t,node:s,loops:n};this.nodeMap.set(e,i)}processNode(e,t,n){var o,r,a,h,c,l,p,d,v;const m=this.currentKey(),y=this.findEntry(m);let g;if(1!==e.s)if(y){g=y.node;let t=[];e.d&&(e.t===s.ASTType.Element?t=this.applyAttrs(g,e.a??[],n,!0,this.isKaRestoring):this.updateNode(g,e,n)),null==(o=e.c)||o.forEach((e,t)=>{this.pushPath(t),this.processNode(e,g,n),this.popPath()}),t.forEach(e=>e())}else switch(e.t){case s.ASTType.Element:g=this.createElement(e,t),u(g,e),f(g,e);const o=this.applyAttrs(g,e.a??[],n);t.appendChild(g),this.registerNode(m,e,g,n),null==(r=e.c)||r.forEach((e,t)=>{this.pushPath(t),this.processNode(e,g,n),this.popPath()}),o.forEach(e=>e());break;case s.ASTType.Text:g=this.createText(e,n),t.appendChild(g),this.registerNode(m,e,g,n);break;case s.ASTType.Comment:g=this.createComment(e,n),t.appendChild(g),this.registerNode(m,e,g,n);break;case s.ASTType.For:{this.pushPath(-1);const i=this.currentKey();this.popPath();let o=null==(a=this.findEntry(i))?void 0:a.node;o||(o=document.createComment("for"),t.appendChild(o),this.registerNode(i,{t:s.ASTType.Comment},o,n));const r=this.evalIR(e.f??-1,[n],e.__m)||[],c=document.createDocumentFragment();r.forEach((t,s)=>{var i;const o=[...n,{itmVal:t,idxVal:s}];null==(i=e.c)||i.forEach((e,t)=>{this.pushPath(s),this.pushPath(t),this.processNode(e,c,o),this.popPath(),this.popPath()})}),null==(h=o.parentNode)||h.insertBefore(c,o);break}case s.ASTType.Conditional:{this.pushPath(-1);const s=this.currentKey();this.popPath();let o=null==(c=this.findEntry(s))?void 0:c.node;o||(o=document.createComment("if"),t.appendChild(o),this.registerNode(s,{},o,n));for(let r=0;r<(e.b||[]).length;r++){const s=null==(l=e.b)?void 0:l[r];if(null===s.f||this.evalIR(s.f,[n],s.__m)){this.pushPath(r);const e=this.currentKey();if(this.popPath(),1===s.ka){this.renderedKaKeys.add(e);const a=this.keepaliveCache.get(e);if(a&&!a.active){null==(p=o.parentNode)||p.insertBefore(a.fragment,o);for(const[e,t]of a.entries)this.prevNodeMap.set(e,t);a.active=!0,a.lastUsed=++this.keepaliveAccessCounter;const h=this.isKaRestoring;this.isKaRestoring=!0;const c=this.currentKaKey;this.currentKaKey=e,this.kaDepth++,i.IS_DEV&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly."),s.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,n),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=c,this.isKaRestoring=h}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);const h=this.currentKaKey;this.currentKaKey=e,this.kaDepth++,i.IS_DEV&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly.");const c=e+".0";if(this.prevNodeMap.get(c))s.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,n),this.popPath(),this.popPath()});else{const e=document.createDocumentFragment();s.c.forEach((t,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(t,e,n),this.popPath(),this.popPath()}),null==(d=o.parentNode)||d.insertBefore(e,o)}this.kaDepth--,this.currentKaKey=h}}else{const e=document.createDocumentFragment();s.c.forEach((t,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(t,e,n),this.popPath(),this.popPath()}),null==(v=o.parentNode)||v.insertBefore(e,o)}break}}break}}else y?g=y.node:(g=this.handleStaticSubtree(e,m,t,n),this.registerNode(m,e,g,n))}evictKeepaliveIfNeeded(){var e;let t=0;for(const[,i]of this.keepaliveCache.entries())i.active||t++;if(t<=this.maxKeepalive)return;let s=null,n=1/0;for(const[i,o]of this.keepaliveCache.entries())o.active||o.lastUsed<n&&(n=o.lastUsed,s=i);if(s){const t=this.keepaliveCache.get(s);for(const[,s]of t.entries){if(this.removeEventListenersFromNode(s.node),s.irNode.a){const e=s.irNode.a.find(e=>"unmounted"===e.k);e&&this.scheduleRaf(()=>{this.evalIR(e.f??-1,[s.node,s.loops],e.__m)})}null==(e=s.node)||e.remove()}this.keepaliveCache.delete(s)}}cleanupOldNodes(){const e=this.prevNodeMap,t=new Map;for(const[s,n]of e.entries()){const{irNode:e,node:i,loops:o}=n,r=n.kaKey&&this.renderedKaKeys.has(n.kaKey);if(e.a){if(n.kaKey&&!r){const t=e.a.find(e=>"deactivated"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}else{const t=e.a.find(e=>"unmounted"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}const t=e.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}if(n.kaKey&&!r&&i.parentNode){let e=t.get(n.kaKey);e||(e={fragment:document.createDocumentFragment(),entries:[]},t.set(n.kaKey,e));const o=n.kaKey.split(".").length;s.split(".").length===o+1&&e.fragment.appendChild(i),e.entries.push([s,n])}else this.removeEventListenersFromNode(i),null==i||i.remove()}for(const[s,n]of t.entries()){const e=this.keepaliveCache.get(s);e&&e.active?(e.fragment=n.fragment,e.entries=n.entries,e.active=!1,e.lastUsed=++this.keepaliveAccessCounter):e||this.keepaliveCache.set(s,{fragment:n.fragment,entries:n.entries,lastUsed:++this.keepaliveAccessCounter,active:!1})}this.evictKeepaliveIfNeeded(),e.clear()}mount(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}update(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}destroy(){var e;this.rafIds.forEach(e=>cancelAnimationFrame(e)),this.rafIds.clear();const t=e=>{for(const[,t]of e.entries())this.removeEventListenersFromNode(t.node)};t(this.nodeMap),t(this.prevNodeMap);for(const[,s]of this.keepaliveCache.entries())for(const[,t]of s.entries){if(this.removeEventListenersFromNode(t.node),t.irNode.a){const e=t.irNode.a.find(e=>"unmounted"===e.k);e&&this.evalIR(e.f??-1,[t.node,t.loops],e.__m)}null==(e=t.node)||e.remove()}this.container.innerHTML="",this.scope.$refs={},this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear(),this.keepaliveCache.clear(),this.renderedKaKeys.clear()}irToNode(e,t,s,n){this.pushPath(t),this.processNode(e,s,n),this.popPath()}}exports.IRRenderer=N,exports.createRender=(e,t,s={})=>{const n=new N(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../types/ast.cjs"),t=require("../../shared/templateError.cjs"),s=require("../../shared/env.cjs"),n=require("./html-decode.cjs"),i=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g,o={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},r={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},a=new Set(["data-","aria-","role","form"]),h=new Set(["value","selectedIndex"]),c=new WeakMap;function p(e){let t=c.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},c.set(e,t)),t}function l(e,t){const s=t.a?.find(e=>"class"===e.k&&!e.d);s?.v&&e.setAttribute("class",s.v)}function d(e,t){if(!e.style)return;const s=t.a?.find(e=>"style"===e.k&&!e.d),n=s?u(s.v):{};for(const i in n){const t=n[i];i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t}}const f=e=>!(!e||0===e.length||/\s/.test(e)&&(s.IS_DEV&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function u(e){const t={},s=[[e]];for(;s.length;){const[e,n]=s.pop()||[];if(e){if("string"==typeof e){let s;for(i.lastIndex=0;null!==(s=i.exec(e));){const e=s[1].trim(),n=s[2].trim();e&&n&&(t[e]=n)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push([e[t]]);else if("object"==typeof e){const i=e;for(const e in i){const o=i[e];if(null==o)continue;const r=n?`${n}-${e}`:e;"object"!=typeof o||Array.isArray(o)?t[r]=String(o):s.push([o,r])}}}}return t}function m(e,t,s){const n=null==s?"":String(s),i=t.indexOf(":");if(i>0){const s=t.slice(0,i),r=o[s];if(r)return void(e.getAttributeNS(r,t)!==n&&e.setAttributeNS(r,t,n))}e.getAttribute(t)!==n&&e.setAttribute(t,n)}function v(e,t,s,n){const i=r[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||a.has(t))return void m(e,t,s);const o=e,h=o.tagName;if(null!=s){if("src"===i||"href"===i){const t=String(s);if(o[i]===t||e.getAttribute(i)===t)return}if("value"!==i||"INPUT"!==h&&"TEXTAREA"!==h||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!r[t]?m(e,t,s):o[i]!==s&&(o[i]=s);else{if(o[i]===s)return;o[i]=s}}else if("boolean"==typeof o[i])!1!==o[i]&&(o[i]=!1);else{const s=o[i];""!==s&&void 0!==s&&(o[i]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class y{constructor(e,t,s={}){this.ir=e,this.container=t,this.scope=s}ir;container;scope;nodeMap=new Map;prevNodeMap=new Map;pathStack=[];pathKey="";staticSubtreeCache=new Map;keepaliveCache=new Map;currentKaKey=null;kaDepth=0;isKaRestoring=!1;rafIds=new Set;keepaliveAccessCounter=0;maxKeepalive=20;renderedKaKeys=new Set;scheduleRaf(e){const t=requestAnimationFrame(()=>{this.rafIds.delete(t),e()});return this.rafIds.add(t),t}pushPath(e){this.pathStack.push(e),this.pathKey=this.pathStack.join(".")}popPath(){this.pathStack.pop(),this.pathKey=this.pathStack.join(".")}evalIR(e,n,i){const o=this.ir.fns[e-1];if(s.IS_DEV)try{return o?o.apply(this.scope,n):""}catch(r){return t.showTemplateError(r.message||r.toString(),this.ir.m?.src||"",i,this.scope.tagName),""}return o?o.apply(this.scope,n):""}createElement(e,t){const s=e.g??"";return t instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):n.default(e.x||"");return document.createTextNode(s)}createComment(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(s)}removeEventListenersFromNode(e){const t=c.get(e);if(t)for(const[s,n]of Object.entries(t.events))n.listener&&e.removeEventListener(s,n.listener)}applyAttrs(e,t,s,n=!1,i=!1){const o=[],r=p(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let c;r.loops=s;let l,d=!1,y=!1;for(const p of t){const{k:t,f:f,d:u,v:g}=p;if(":class"===t){c=this.evalIR(f??-1,[s],p.__m),d=!0;continue}if(":style"===t){l=this.evalIR(f??-1,[s],p.__m),y=!0;continue}if("class"===t||"style"===t)continue;const N=t[0];if("@"===N){const s=t.slice(1),i=p.r??"user";let o=r.events[s];if(!o){o={model:[],user:[],listener:null};const t=e=>{for(const t of o.model)t(e);for(const t of o.user)t(e)};o.listener=t,e.addEventListener(s,t),r.events[s]=o}if(!n){const e=e=>this.evalIR(f??-1,[e,r.loops],p.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],p.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],p.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],p.__m));continue}if("ref"===t&&g){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[g]=e;continue}const S=u?this.evalIR(f??-1,[s],p.__m):g??"";if(":"===N){const s=t.slice(1);"SELECT"===e.tagName&&h.has(s)?o.push(()=>v(e,s,S,a)):v(e,s,S,a)}else n||m(e,t,String(S))}return d&&((e,t)=>{const s=p(e),n=s.prevClassObj,i=function(e){const t={},s=[e];for(;s.length;){const e=s.pop();if(e)if("string"==typeof e){const s=e.split(" ");for(let e=0;e<s.length;e++){const n=s[e].trim();n&&(t[n]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push(e[t]);else if("object"==typeof e){const s=e;for(const e in s)s[e]&&(t[e]=!0)}}return t}(t),o={};for(const h in i)f(h)&&(o[h]=i[h]);if(!n){const t=[];for(const e in o)t.push(e);return t.length&&e.classList.add(...t),void(s.prevClassObj=o)}const r=[],a=[];for(const h in n)o[h]||a.push(h);for(const h in o)n[h]||r.push(h);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,c),y&&((e,t)=>{const s=p(e),n=u(t),i=s.prevStyleObj;if(!i){for(const t in n){const s=n[t];t.startsWith("--")?e.style.setProperty(t,s):e.style[t]=s}return void(s.prevStyleObj=n)}let o=!1;for(const r in i)r in n||(r.startsWith("--")?e.style.removeProperty(r):e.style[r]="",o=!0);for(const r in n){const t=n[r];t!==i[r]&&(r.startsWith("--")?e.style.setProperty(r,t):e.style[r]=t,o=!0)}o&&(s.prevStyleObj=n)})(e,l),o}updateNode(e,t,s){const n=t.d?this.evalIR(t.f??-1,[s],t.__m):t.x||"";t.d&&e.textContent!==n&&(e.textContent=n)}createStaticSubtree(t,s,n){switch(t.t){case e.ASTType.Element:{const e=this.createElement(t,s);l(e,t),d(e,t);const i=this.applyAttrs(e,t.a??[],n);return t.c?.forEach(t=>{const s=this.createStaticSubtree(t,e,n);e.appendChild(s)}),i.forEach(e=>e()),e}case e.ASTType.Text:return this.createText(t,n);case e.ASTType.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,s,n){const i=this.staticSubtreeCache.get(t);if(i){const e=i.cloneNode(!0);return s.appendChild(e),e}const o=this.createStaticSubtree(e,s,n);return s.appendChild(o),this.staticSubtreeCache.set(t,o.cloneNode(!0)),o}currentKey(){return this.pathKey}findEntry(e){let t=this.nodeMap.get(e);return t||(t=this.prevNodeMap.get(e),t&&(this.prevNodeMap.delete(e),this.nodeMap.set(e,t))),t}registerNode(e,t,s,n){const i=this.currentKaKey?{irNode:t,node:s,loops:n,kaKey:this.currentKaKey}:{irNode:t,node:s,loops:n};this.nodeMap.set(e,i)}processNode(t,n,i){const o=this.currentKey(),r=this.findEntry(o);let a;if(1!==t.s)if(r){a=r.node;let s=[];t.d&&(t.t===e.ASTType.Element?s=this.applyAttrs(a,t.a??[],i,!0,this.isKaRestoring):this.updateNode(a,t,i)),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),s.forEach(e=>e())}else switch(t.t){case e.ASTType.Element:a=this.createElement(t,n),l(a,t),d(a,t);const r=this.applyAttrs(a,t.a??[],i);n.appendChild(a),this.registerNode(o,t,a,i),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),r.forEach(e=>e());break;case e.ASTType.Text:a=this.createText(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.ASTType.Comment:a=this.createComment(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.ASTType.For:{this.pushPath(-1);const s=this.currentKey();this.popPath();let o=this.findEntry(s)?.node;o||(o=document.createComment("for"),n.appendChild(o),this.registerNode(s,{t:e.ASTType.Comment},o,i));const r=this.evalIR(t.f??-1,[i],t.__m)||[],a=document.createDocumentFragment();r.forEach((e,s)=>{const n=[...i,{itmVal:e,idxVal:s}];t.c?.forEach((e,t)=>{this.pushPath(s),this.pushPath(t),this.processNode(e,a,n),this.popPath(),this.popPath()})}),o.parentNode?.insertBefore(a,o);break}case e.ASTType.Conditional:{this.pushPath(-1);const e=this.currentKey();this.popPath();let o=this.findEntry(e)?.node;o||(o=document.createComment("if"),n.appendChild(o),this.registerNode(e,{},o,i));for(let r=0;r<(t.b||[]).length;r++){const e=t.b?.[r];if(null===e.f||this.evalIR(e.f,[i],e.__m)){this.pushPath(r);const t=this.currentKey();if(this.popPath(),1===e.ka){this.renderedKaKeys.add(t);const a=this.keepaliveCache.get(t);if(a&&!a.active){o.parentNode?.insertBefore(a.fragment,o);for(const[e,t]of a.entries)this.prevNodeMap.set(e,t);a.active=!0,a.lastUsed=++this.keepaliveAccessCounter;const h=this.isKaRestoring;this.isKaRestoring=!0;const c=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s.IS_DEV&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly."),e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=c,this.isKaRestoring=h}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);const h=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s.IS_DEV&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly.");const c=t+".0";if(this.prevNodeMap.get(c))e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()});else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}this.kaDepth--,this.currentKaKey=h}}else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}break}}break}}else r?a=r.node:(a=this.handleStaticSubtree(t,o,n,i),this.registerNode(o,t,a,i))}evictKeepaliveIfNeeded(){let e=0;for(const[,n]of this.keepaliveCache.entries())n.active||e++;if(e<=this.maxKeepalive)return;let t=null,s=1/0;for(const[n,i]of this.keepaliveCache.entries())i.active||i.lastUsed<s&&(s=i.lastUsed,t=n);if(t){const e=this.keepaliveCache.get(t);for(const[,t]of e.entries){if(this.removeEventListenersFromNode(t.node),t.irNode.a){const e=t.irNode.a.find(e=>"unmounted"===e.k);e&&this.scheduleRaf(()=>{this.evalIR(e.f??-1,[t.node,t.loops],e.__m)})}t.node?.remove()}this.keepaliveCache.delete(t)}}cleanupOldNodes(){const e=this.prevNodeMap,t=new Map;for(const[s,n]of e.entries()){const{irNode:e,node:i,loops:o}=n,r=n.kaKey&&this.renderedKaKeys.has(n.kaKey);if(e.a){if(n.kaKey&&!r){const t=e.a.find(e=>"deactivated"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}else{const t=e.a.find(e=>"unmounted"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}const t=e.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}if(n.kaKey&&!r&&i.parentNode){let e=t.get(n.kaKey);e||(e={fragment:document.createDocumentFragment(),entries:[]},t.set(n.kaKey,e));const o=n.kaKey.split(".").length;s.split(".").length===o+1&&e.fragment.appendChild(i),e.entries.push([s,n])}else this.removeEventListenersFromNode(i),i?.remove()}for(const[s,n]of t.entries()){const e=this.keepaliveCache.get(s);e&&e.active?(e.fragment=n.fragment,e.entries=n.entries,e.active=!1,e.lastUsed=++this.keepaliveAccessCounter):e||this.keepaliveCache.set(s,{fragment:n.fragment,entries:n.entries,lastUsed:++this.keepaliveAccessCounter,active:!1})}this.evictKeepaliveIfNeeded(),e.clear()}mount(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}update(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}destroy(){this.rafIds.forEach(e=>cancelAnimationFrame(e)),this.rafIds.clear();const e=e=>{for(const[,t]of e.entries())this.removeEventListenersFromNode(t.node)};e(this.nodeMap),e(this.prevNodeMap);for(const[,t]of this.keepaliveCache.entries())for(const[,e]of t.entries){if(this.removeEventListenersFromNode(e.node),e.irNode.a){const t=e.irNode.a.find(e=>"unmounted"===e.k);t&&this.evalIR(t.f??-1,[e.node,e.loops],t.__m)}e.node?.remove()}this.container.innerHTML="",this.scope.$refs={},this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear(),this.keepaliveCache.clear(),this.renderedKaKeys.clear()}irToNode(e,t,s,n){this.pushPath(t),this.processNode(e,s,n),this.popPath()}}exports.IRRenderer=y,exports.createRender=(e,t,s={})=>{const n=new y(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,s,n)=>((t,s,n)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n)(t,"symbol"!=typeof s?s+"":s,n);import{ASTType as s}from"../../types/ast.js";import{showTemplateError as n}from"../../shared/templateError.js";import{IS_DEV as i}from"../../shared/env.js";import o from"./html-decode.js";const r=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g,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"},c=new Set(["data-","aria-","role","form"]),l=new Set(["value","selectedIndex"]),p=new WeakMap;function d(e){let t=p.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},p.set(e,t)),t}function f(e,t){var s;const n=null==(s=t.a)?void 0:s.find(e=>"class"===e.k&&!e.d);(null==n?void 0:n.v)&&e.setAttribute("class",n.v)}function u(e,t){var s;if(!e.style)return;const n=null==(s=t.a)?void 0:s.find(e=>"style"===e.k&&!e.d),i=n?v(n.v):{};for(const o in i){const t=i[o];o.startsWith("--")?e.style.setProperty(o,t):e.style[o]=t}}const m=e=>!(!e||0===e.length||/\s/.test(e)&&(i&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function v(e){const t={},s=[[e]];for(;s.length;){const[e,n]=s.pop()||[];if(e){if("string"==typeof e){let s;for(r.lastIndex=0;null!==(s=r.exec(e));){const e=s[1].trim(),n=s[2].trim();e&&n&&(t[e]=n)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push([e[t]]);else if("object"==typeof e){const i=e;for(const e in i){const o=i[e];if(null==o)continue;const r=n?`${n}-${e}`:e;"object"!=typeof o||Array.isArray(o)?t[r]=String(o):s.push([o,r])}}}}return t}function y(e,t,s){const n=null==s?"":String(s),i=t.indexOf(":");if(i>0){const s=t.slice(0,i),o=a[s];if(o)return void(e.getAttributeNS(o,t)!==n&&e.setAttributeNS(o,t,n))}e.getAttribute(t)!==n&&e.setAttribute(t,n)}function g(e,t,s,n){const i=h[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||c.has(t))return void y(e,t,s);const o=e,r=o.tagName;if(null!=s){if("src"===i||"href"===i){const t=String(s);if(o[i]===t||e.getAttribute(i)===t)return}if("value"!==i||"INPUT"!==r&&"TEXTAREA"!==r||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!h[t]?y(e,t,s):o[i]!==s&&(o[i]=s);else{if(o[i]===s)return;o[i]=s}}else if("boolean"==typeof o[i])!1!==o[i]&&(o[i]=!1);else{const s=o[i];""!==s&&void 0!==s&&(o[i]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class N{constructor(e,s,n={}){t(this,"nodeMap",new Map),t(this,"prevNodeMap",new Map),t(this,"pathStack",[]),t(this,"pathKey",""),t(this,"staticSubtreeCache",new Map),t(this,"keepaliveCache",new Map),t(this,"currentKaKey",null),t(this,"kaDepth",0),t(this,"isKaRestoring",!1),t(this,"rafIds",new Set),t(this,"keepaliveAccessCounter",0),t(this,"maxKeepalive",20),t(this,"renderedKaKeys",new Set),this.ir=e,this.container=s,this.scope=n}scheduleRaf(e){const t=requestAnimationFrame(()=>{this.rafIds.delete(t),e()});return this.rafIds.add(t),t}pushPath(e){this.pathStack.push(e),this.pathKey=this.pathStack.join(".")}popPath(){this.pathStack.pop(),this.pathKey=this.pathStack.join(".")}evalIR(e,t,s){var o;const r=this.ir.fns[e-1];if(i)try{return r?r.apply(this.scope,t):""}catch(a){return n(a.message||a.toString(),(null==(o=this.ir.m)?void 0:o.src)||"",s,this.scope.tagName),""}return r?r.apply(this.scope,t):""}createElement(e,t){const s=e.g??"";return t instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):o(e.x||"");return document.createTextNode(s)}createComment(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(s)}removeEventListenersFromNode(e){const t=p.get(e);if(t)for(const[s,n]of Object.entries(t.events))n.listener&&e.removeEventListener(s,n.listener)}applyAttrs(e,t,s,n=!1,i=!1){const o=[],r=d(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let h;r.loops=s;let c,p=!1,f=!1;for(const d of t){const{k:t,f:u,d:m,v:v}=d;if(":class"===t){h=this.evalIR(u??-1,[s],d.__m),p=!0;continue}if(":style"===t){c=this.evalIR(u??-1,[s],d.__m),f=!0;continue}if("class"===t||"style"===t)continue;const N=t[0];if("@"===N){const s=t.slice(1),i=d.r??"user";let o=r.events[s];if(!o){o={model:[],user:[],listener:null};const t=e=>{for(const t of o.model)t(e);for(const t of o.user)t(e)};o.listener=t,e.addEventListener(s,t),r.events[s]=o}if(!n){const e=e=>this.evalIR(u??-1,[e,r.loops],d.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],d.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],d.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],d.__m));continue}if("ref"===t&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=e;continue}const k=m?this.evalIR(u??-1,[s],d.__m):v??"";if(":"===N){const s=t.slice(1);"SELECT"===e.tagName&&l.has(s)?o.push(()=>g(e,s,k,a)):g(e,s,k,a)}else n||y(e,t,String(k))}return p&&((e,t)=>{const s=d(e),n=s.prevClassObj,i=function(e){const t={},s=[e];for(;s.length;){const e=s.pop();if(e)if("string"==typeof e){const s=e.split(" ");for(let e=0;e<s.length;e++){const n=s[e].trim();n&&(t[n]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push(e[t]);else if("object"==typeof e){const s=e;for(const e in s)s[e]&&(t[e]=!0)}}return t}(t),o={};for(const h in i)m(h)&&(o[h]=i[h]);if(!n){const t=[];for(const e in o)t.push(e);return t.length&&e.classList.add(...t),void(s.prevClassObj=o)}const r=[],a=[];for(const h in n)o[h]||a.push(h);for(const h in o)n[h]||r.push(h);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,h),f&&((e,t)=>{const s=d(e),n=v(t),i=s.prevStyleObj;if(!i){for(const t in n){const s=n[t];t.startsWith("--")?e.style.setProperty(t,s):e.style[t]=s}return void(s.prevStyleObj=n)}let o=!1;for(const r in i)r in n||(r.startsWith("--")?e.style.removeProperty(r):e.style[r]="",o=!0);for(const r in n){const t=n[r];t!==i[r]&&(r.startsWith("--")?e.style.setProperty(r,t):e.style[r]=t,o=!0)}o&&(s.prevStyleObj=n)})(e,c),o}updateNode(e,t,s){const n=t.d?this.evalIR(t.f??-1,[s],t.__m):t.x||"";t.d&&e.textContent!==n&&(e.textContent=n)}createStaticSubtree(e,t,n){var i;switch(e.t){case s.Element:{const s=this.createElement(e,t);f(s,e),u(s,e);const o=this.applyAttrs(s,e.a??[],n);return null==(i=e.c)||i.forEach(e=>{const t=this.createStaticSubtree(e,s,n);s.appendChild(t)}),o.forEach(e=>e()),s}case s.Text:return this.createText(e,n);case s.Comment:return this.createComment(e,n);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,s,n){const i=this.staticSubtreeCache.get(t);if(i){const e=i.cloneNode(!0);return s.appendChild(e),e}const o=this.createStaticSubtree(e,s,n);return s.appendChild(o),this.staticSubtreeCache.set(t,o.cloneNode(!0)),o}currentKey(){return this.pathKey}findEntry(e){let t=this.nodeMap.get(e);return t||(t=this.prevNodeMap.get(e),t&&(this.prevNodeMap.delete(e),this.nodeMap.set(e,t))),t}registerNode(e,t,s,n){const i=this.currentKaKey?{irNode:t,node:s,loops:n,kaKey:this.currentKaKey}:{irNode:t,node:s,loops:n};this.nodeMap.set(e,i)}processNode(e,t,n){var o,r,a,h,c,l,p,d,m;const v=this.currentKey(),y=this.findEntry(v);let g;if(1!==e.s)if(y){g=y.node;let t=[];e.d&&(e.t===s.Element?t=this.applyAttrs(g,e.a??[],n,!0,this.isKaRestoring):this.updateNode(g,e,n)),null==(o=e.c)||o.forEach((e,t)=>{this.pushPath(t),this.processNode(e,g,n),this.popPath()}),t.forEach(e=>e())}else switch(e.t){case s.Element:g=this.createElement(e,t),f(g,e),u(g,e);const o=this.applyAttrs(g,e.a??[],n);t.appendChild(g),this.registerNode(v,e,g,n),null==(r=e.c)||r.forEach((e,t)=>{this.pushPath(t),this.processNode(e,g,n),this.popPath()}),o.forEach(e=>e());break;case s.Text:g=this.createText(e,n),t.appendChild(g),this.registerNode(v,e,g,n);break;case s.Comment:g=this.createComment(e,n),t.appendChild(g),this.registerNode(v,e,g,n);break;case s.For:{this.pushPath(-1);const i=this.currentKey();this.popPath();let o=null==(a=this.findEntry(i))?void 0:a.node;o||(o=document.createComment("for"),t.appendChild(o),this.registerNode(i,{t:s.Comment},o,n));const r=this.evalIR(e.f??-1,[n],e.__m)||[],c=document.createDocumentFragment();r.forEach((t,s)=>{var i;const o=[...n,{itmVal:t,idxVal:s}];null==(i=e.c)||i.forEach((e,t)=>{this.pushPath(s),this.pushPath(t),this.processNode(e,c,o),this.popPath(),this.popPath()})}),null==(h=o.parentNode)||h.insertBefore(c,o);break}case s.Conditional:{this.pushPath(-1);const s=this.currentKey();this.popPath();let o=null==(c=this.findEntry(s))?void 0:c.node;o||(o=document.createComment("if"),t.appendChild(o),this.registerNode(s,{},o,n));for(let r=0;r<(e.b||[]).length;r++){const s=null==(l=e.b)?void 0:l[r];if(null===s.f||this.evalIR(s.f,[n],s.__m)){this.pushPath(r);const e=this.currentKey();if(this.popPath(),1===s.ka){this.renderedKaKeys.add(e);const a=this.keepaliveCache.get(e);if(a&&!a.active){null==(p=o.parentNode)||p.insertBefore(a.fragment,o);for(const[e,t]of a.entries)this.prevNodeMap.set(e,t);a.active=!0,a.lastUsed=++this.keepaliveAccessCounter;const h=this.isKaRestoring;this.isKaRestoring=!0;const c=this.currentKaKey;this.currentKaKey=e,this.kaDepth++,i&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly."),s.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,n),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=c,this.isKaRestoring=h}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);const h=this.currentKaKey;this.currentKaKey=e,this.kaDepth++,i&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly.");const c=e+".0";if(this.prevNodeMap.get(c))s.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,n),this.popPath(),this.popPath()});else{const e=document.createDocumentFragment();s.c.forEach((t,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(t,e,n),this.popPath(),this.popPath()}),null==(d=o.parentNode)||d.insertBefore(e,o)}this.kaDepth--,this.currentKaKey=h}}else{const e=document.createDocumentFragment();s.c.forEach((t,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(t,e,n),this.popPath(),this.popPath()}),null==(m=o.parentNode)||m.insertBefore(e,o)}break}}break}}else y?g=y.node:(g=this.handleStaticSubtree(e,v,t,n),this.registerNode(v,e,g,n))}evictKeepaliveIfNeeded(){var e;let t=0;for(const[,i]of this.keepaliveCache.entries())i.active||t++;if(t<=this.maxKeepalive)return;let s=null,n=1/0;for(const[i,o]of this.keepaliveCache.entries())o.active||o.lastUsed<n&&(n=o.lastUsed,s=i);if(s){const t=this.keepaliveCache.get(s);for(const[,s]of t.entries){if(this.removeEventListenersFromNode(s.node),s.irNode.a){const e=s.irNode.a.find(e=>"unmounted"===e.k);e&&this.scheduleRaf(()=>{this.evalIR(e.f??-1,[s.node,s.loops],e.__m)})}null==(e=s.node)||e.remove()}this.keepaliveCache.delete(s)}}cleanupOldNodes(){const e=this.prevNodeMap,t=new Map;for(const[s,n]of e.entries()){const{irNode:e,node:i,loops:o}=n,r=n.kaKey&&this.renderedKaKeys.has(n.kaKey);if(e.a){if(n.kaKey&&!r){const t=e.a.find(e=>"deactivated"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}else{const t=e.a.find(e=>"unmounted"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}const t=e.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}if(n.kaKey&&!r&&i.parentNode){let e=t.get(n.kaKey);e||(e={fragment:document.createDocumentFragment(),entries:[]},t.set(n.kaKey,e));const o=n.kaKey.split(".").length;s.split(".").length===o+1&&e.fragment.appendChild(i),e.entries.push([s,n])}else this.removeEventListenersFromNode(i),null==i||i.remove()}for(const[s,n]of t.entries()){const e=this.keepaliveCache.get(s);e&&e.active?(e.fragment=n.fragment,e.entries=n.entries,e.active=!1,e.lastUsed=++this.keepaliveAccessCounter):e||this.keepaliveCache.set(s,{fragment:n.fragment,entries:n.entries,lastUsed:++this.keepaliveAccessCounter,active:!1})}this.evictKeepaliveIfNeeded(),e.clear()}mount(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}update(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}destroy(){var e;this.rafIds.forEach(e=>cancelAnimationFrame(e)),this.rafIds.clear();const t=e=>{for(const[,t]of e.entries())this.removeEventListenersFromNode(t.node)};t(this.nodeMap),t(this.prevNodeMap);for(const[,s]of this.keepaliveCache.entries())for(const[,t]of s.entries){if(this.removeEventListenersFromNode(t.node),t.irNode.a){const e=t.irNode.a.find(e=>"unmounted"===e.k);e&&this.evalIR(e.f??-1,[t.node,t.loops],e.__m)}null==(e=t.node)||e.remove()}this.container.innerHTML="",this.scope.$refs={},this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear(),this.keepaliveCache.clear(),this.renderedKaKeys.clear()}irToNode(e,t,s,n){this.pushPath(t),this.processNode(e,s,n),this.popPath()}}const k=(e,t,s={})=>{const n=new N(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};export{N as IRRenderer,k as createRender};
|
|
1
|
+
import{ASTType as e}from"../../types/ast.js";import{showTemplateError as t}from"../../shared/templateError.js";import{IS_DEV as s}from"../../shared/env.js";import n from"./html-decode.js";const i=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g,o={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},r={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},a=new Set(["data-","aria-","role","form"]),h=new Set(["value","selectedIndex"]),c=new WeakMap;function l(e){let t=c.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},c.set(e,t)),t}function p(e,t){const s=t.a?.find(e=>"class"===e.k&&!e.d);s?.v&&e.setAttribute("class",s.v)}function d(e,t){if(!e.style)return;const s=t.a?.find(e=>"style"===e.k&&!e.d),n=s?u(s.v):{};for(const i in n){const t=n[i];i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t}}const f=e=>!(!e||0===e.length||/\s/.test(e)&&(s&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function u(e){const t={},s=[[e]];for(;s.length;){const[e,n]=s.pop()||[];if(e){if("string"==typeof e){let s;for(i.lastIndex=0;null!==(s=i.exec(e));){const e=s[1].trim(),n=s[2].trim();e&&n&&(t[e]=n)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push([e[t]]);else if("object"==typeof e){const i=e;for(const e in i){const o=i[e];if(null==o)continue;const r=n?`${n}-${e}`:e;"object"!=typeof o||Array.isArray(o)?t[r]=String(o):s.push([o,r])}}}}return t}function m(e,t,s){const n=null==s?"":String(s),i=t.indexOf(":");if(i>0){const s=t.slice(0,i),r=o[s];if(r)return void(e.getAttributeNS(r,t)!==n&&e.setAttributeNS(r,t,n))}e.getAttribute(t)!==n&&e.setAttribute(t,n)}function v(e,t,s,n){const i=r[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||a.has(t))return void m(e,t,s);const o=e,h=o.tagName;if(null!=s){if("src"===i||"href"===i){const t=String(s);if(o[i]===t||e.getAttribute(i)===t)return}if("value"!==i||"INPUT"!==h&&"TEXTAREA"!==h||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!r[t]?m(e,t,s):o[i]!==s&&(o[i]=s);else{if(o[i]===s)return;o[i]=s}}else if("boolean"==typeof o[i])!1!==o[i]&&(o[i]=!1);else{const s=o[i];""!==s&&void 0!==s&&(o[i]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class y{constructor(e,t,s={}){this.ir=e,this.container=t,this.scope=s}ir;container;scope;nodeMap=new Map;prevNodeMap=new Map;pathStack=[];pathKey="";staticSubtreeCache=new Map;keepaliveCache=new Map;currentKaKey=null;kaDepth=0;isKaRestoring=!1;rafIds=new Set;keepaliveAccessCounter=0;maxKeepalive=20;renderedKaKeys=new Set;scheduleRaf(e){const t=requestAnimationFrame(()=>{this.rafIds.delete(t),e()});return this.rafIds.add(t),t}pushPath(e){this.pathStack.push(e),this.pathKey=this.pathStack.join(".")}popPath(){this.pathStack.pop(),this.pathKey=this.pathStack.join(".")}evalIR(e,n,i){const o=this.ir.fns[e-1];if(s)try{return o?o.apply(this.scope,n):""}catch(r){return t(r.message||r.toString(),this.ir.m?.src||"",i,this.scope.tagName),""}return o?o.apply(this.scope,n):""}createElement(e,t){const s=e.g??"";return t instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):n(e.x||"");return document.createTextNode(s)}createComment(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(s)}removeEventListenersFromNode(e){const t=c.get(e);if(t)for(const[s,n]of Object.entries(t.events))n.listener&&e.removeEventListener(s,n.listener)}applyAttrs(e,t,s,n=!1,i=!1){const o=[],r=l(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let c;r.loops=s;let p,d=!1,y=!1;for(const l of t){const{k:t,f:f,d:u,v:g}=l;if(":class"===t){c=this.evalIR(f??-1,[s],l.__m),d=!0;continue}if(":style"===t){p=this.evalIR(f??-1,[s],l.__m),y=!0;continue}if("class"===t||"style"===t)continue;const N=t[0];if("@"===N){const s=t.slice(1),i=l.r??"user";let o=r.events[s];if(!o){o={model:[],user:[],listener:null};const t=e=>{for(const t of o.model)t(e);for(const t of o.user)t(e)};o.listener=t,e.addEventListener(s,t),r.events[s]=o}if(!n){const e=e=>this.evalIR(f??-1,[e,r.loops],l.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],l.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],l.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(f??-1,[e,s],l.__m));continue}if("ref"===t&&g){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[g]=e;continue}const k=u?this.evalIR(f??-1,[s],l.__m):g??"";if(":"===N){const s=t.slice(1);"SELECT"===e.tagName&&h.has(s)?o.push(()=>v(e,s,k,a)):v(e,s,k,a)}else n||m(e,t,String(k))}return d&&((e,t)=>{const s=l(e),n=s.prevClassObj,i=function(e){const t={},s=[e];for(;s.length;){const e=s.pop();if(e)if("string"==typeof e){const s=e.split(" ");for(let e=0;e<s.length;e++){const n=s[e].trim();n&&(t[n]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push(e[t]);else if("object"==typeof e){const s=e;for(const e in s)s[e]&&(t[e]=!0)}}return t}(t),o={};for(const h in i)f(h)&&(o[h]=i[h]);if(!n){const t=[];for(const e in o)t.push(e);return t.length&&e.classList.add(...t),void(s.prevClassObj=o)}const r=[],a=[];for(const h in n)o[h]||a.push(h);for(const h in o)n[h]||r.push(h);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,c),y&&((e,t)=>{const s=l(e),n=u(t),i=s.prevStyleObj;if(!i){for(const t in n){const s=n[t];t.startsWith("--")?e.style.setProperty(t,s):e.style[t]=s}return void(s.prevStyleObj=n)}let o=!1;for(const r in i)r in n||(r.startsWith("--")?e.style.removeProperty(r):e.style[r]="",o=!0);for(const r in n){const t=n[r];t!==i[r]&&(r.startsWith("--")?e.style.setProperty(r,t):e.style[r]=t,o=!0)}o&&(s.prevStyleObj=n)})(e,p),o}updateNode(e,t,s){const n=t.d?this.evalIR(t.f??-1,[s],t.__m):t.x||"";t.d&&e.textContent!==n&&(e.textContent=n)}createStaticSubtree(t,s,n){switch(t.t){case e.Element:{const e=this.createElement(t,s);p(e,t),d(e,t);const i=this.applyAttrs(e,t.a??[],n);return t.c?.forEach(t=>{const s=this.createStaticSubtree(t,e,n);e.appendChild(s)}),i.forEach(e=>e()),e}case e.Text:return this.createText(t,n);case e.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,s,n){const i=this.staticSubtreeCache.get(t);if(i){const e=i.cloneNode(!0);return s.appendChild(e),e}const o=this.createStaticSubtree(e,s,n);return s.appendChild(o),this.staticSubtreeCache.set(t,o.cloneNode(!0)),o}currentKey(){return this.pathKey}findEntry(e){let t=this.nodeMap.get(e);return t||(t=this.prevNodeMap.get(e),t&&(this.prevNodeMap.delete(e),this.nodeMap.set(e,t))),t}registerNode(e,t,s,n){const i=this.currentKaKey?{irNode:t,node:s,loops:n,kaKey:this.currentKaKey}:{irNode:t,node:s,loops:n};this.nodeMap.set(e,i)}processNode(t,n,i){const o=this.currentKey(),r=this.findEntry(o);let a;if(1!==t.s)if(r){a=r.node;let s=[];t.d&&(t.t===e.Element?s=this.applyAttrs(a,t.a??[],i,!0,this.isKaRestoring):this.updateNode(a,t,i)),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),s.forEach(e=>e())}else switch(t.t){case e.Element:a=this.createElement(t,n),p(a,t),d(a,t);const r=this.applyAttrs(a,t.a??[],i);n.appendChild(a),this.registerNode(o,t,a,i),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),r.forEach(e=>e());break;case e.Text:a=this.createText(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.Comment:a=this.createComment(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.For:{this.pushPath(-1);const s=this.currentKey();this.popPath();let o=this.findEntry(s)?.node;o||(o=document.createComment("for"),n.appendChild(o),this.registerNode(s,{t:e.Comment},o,i));const r=this.evalIR(t.f??-1,[i],t.__m)||[],a=document.createDocumentFragment();r.forEach((e,s)=>{const n=[...i,{itmVal:e,idxVal:s}];t.c?.forEach((e,t)=>{this.pushPath(s),this.pushPath(t),this.processNode(e,a,n),this.popPath(),this.popPath()})}),o.parentNode?.insertBefore(a,o);break}case e.Conditional:{this.pushPath(-1);const e=this.currentKey();this.popPath();let o=this.findEntry(e)?.node;o||(o=document.createComment("if"),n.appendChild(o),this.registerNode(e,{},o,i));for(let r=0;r<(t.b||[]).length;r++){const e=t.b?.[r];if(null===e.f||this.evalIR(e.f,[i],e.__m)){this.pushPath(r);const t=this.currentKey();if(this.popPath(),1===e.ka){this.renderedKaKeys.add(t);const a=this.keepaliveCache.get(t);if(a&&!a.active){o.parentNode?.insertBefore(a.fragment,o);for(const[e,t]of a.entries)this.prevNodeMap.set(e,t);a.active=!0,a.lastUsed=++this.keepaliveAccessCounter;const h=this.isKaRestoring;this.isKaRestoring=!0;const c=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly."),e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=c,this.isKaRestoring=h}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);const h=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly.");const c=t+".0";if(this.prevNodeMap.get(c))e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()});else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}this.kaDepth--,this.currentKaKey=h}}else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}break}}break}}else r?a=r.node:(a=this.handleStaticSubtree(t,o,n,i),this.registerNode(o,t,a,i))}evictKeepaliveIfNeeded(){let e=0;for(const[,n]of this.keepaliveCache.entries())n.active||e++;if(e<=this.maxKeepalive)return;let t=null,s=1/0;for(const[n,i]of this.keepaliveCache.entries())i.active||i.lastUsed<s&&(s=i.lastUsed,t=n);if(t){const e=this.keepaliveCache.get(t);for(const[,t]of e.entries){if(this.removeEventListenersFromNode(t.node),t.irNode.a){const e=t.irNode.a.find(e=>"unmounted"===e.k);e&&this.scheduleRaf(()=>{this.evalIR(e.f??-1,[t.node,t.loops],e.__m)})}t.node?.remove()}this.keepaliveCache.delete(t)}}cleanupOldNodes(){const e=this.prevNodeMap,t=new Map;for(const[s,n]of e.entries()){const{irNode:e,node:i,loops:o}=n,r=n.kaKey&&this.renderedKaKeys.has(n.kaKey);if(e.a){if(n.kaKey&&!r){const t=e.a.find(e=>"deactivated"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}else{const t=e.a.find(e=>"unmounted"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}const t=e.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}if(n.kaKey&&!r&&i.parentNode){let e=t.get(n.kaKey);e||(e={fragment:document.createDocumentFragment(),entries:[]},t.set(n.kaKey,e));const o=n.kaKey.split(".").length;s.split(".").length===o+1&&e.fragment.appendChild(i),e.entries.push([s,n])}else this.removeEventListenersFromNode(i),i?.remove()}for(const[s,n]of t.entries()){const e=this.keepaliveCache.get(s);e&&e.active?(e.fragment=n.fragment,e.entries=n.entries,e.active=!1,e.lastUsed=++this.keepaliveAccessCounter):e||this.keepaliveCache.set(s,{fragment:n.fragment,entries:n.entries,lastUsed:++this.keepaliveAccessCounter,active:!1})}this.evictKeepaliveIfNeeded(),e.clear()}mount(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}update(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}destroy(){this.rafIds.forEach(e=>cancelAnimationFrame(e)),this.rafIds.clear();const e=e=>{for(const[,t]of e.entries())this.removeEventListenersFromNode(t.node)};e(this.nodeMap),e(this.prevNodeMap);for(const[,t]of this.keepaliveCache.entries())for(const[,e]of t.entries){if(this.removeEventListenersFromNode(e.node),e.irNode.a){const t=e.irNode.a.find(e=>"unmounted"===e.k);t&&this.evalIR(t.f??-1,[e.node,e.loops],t.__m)}e.node?.remove()}this.container.innerHTML="",this.scope.$refs={},this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear(),this.keepaliveCache.clear(),this.renderedKaKeys.clear()}irToNode(e,t,s,n){this.pushPath(t),this.processNode(e,s,n),this.popPath()}}const g=(e,t,s={})=>{const n=new y(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};export{y as IRRenderer,g as createRender};
|
package/dist/shared/env.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(()=>{if("undefined"!=typeof window){if(window.location?.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(window.location?.hostname||""))})(),o=!e;exports.IS_DEV=e,exports.IS_PROD=o,exports.SOLELY_VERSION="0.6.0";
|
package/dist/shared/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=(()=>{
|
|
1
|
+
const n=(()=>{if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;const n=globalThis;if(!0===n.__DEBUG__||!0===n.__IS_DEV__)return!0}return!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes(window.location?.hostname||""))})(),o=!n,e="0.6.0";export{n as IS_DEV,o as IS_PROD,e as SOLELY_VERSION};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** 函数创建器类型 */
|
|
2
|
-
export type FunctionCreator<TArgs extends
|
|
2
|
+
export type FunctionCreator<TArgs extends unknown[], TReturn> = (...args: TArgs) => TReturn;
|
|
3
3
|
export declare function isCSPBlocked(): boolean;
|
|
4
4
|
/**
|
|
5
5
|
* 创建函数
|
|
@@ -7,4 +7,4 @@ export declare function isCSPBlocked(): boolean;
|
|
|
7
7
|
* @param args 参数列表,最后一个元素是函数体
|
|
8
8
|
* @returns 创建的函数
|
|
9
9
|
*/
|
|
10
|
-
export declare function createFunction<TArgs extends
|
|
10
|
+
export declare function createFunction<TArgs extends unknown[]>(args: string[]): FunctionCreator<TArgs, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./functions.cjs"),r=/\{\{\{\s*[\s\S]*?\s*\}\}\}/,n=/\{\{\s*([\s\S]*?)\s*\}\}/g;exports.genFunction=function(t,o,s){if(!
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./functions.cjs"),r=/\{\{\{\s*[\s\S]*?\s*\}\}\}/,n=/\{\{\s*([\s\S]*?)\s*\}\}/g;exports.genFunction=function(t,o,s){if(!t?.trim())return()=>"";const{processed:c,error:i}=function(e,t){if(!e?.trim())return{processed:""};if(r.test(e))return{processed:e,error:"Illegal interpolation syntax: use {{ }} instead of {{{ }}}"};if("template"===t)try{return{processed:e.replace(n,(e,r)=>`\${${r.trim()}}`)}}catch(o){return{processed:e,error:`Template parse error: ${o instanceof Error?o.message:String(o)}`}}return{processed:e}}(t,o);if(i)return function(){throw new Error(`[Compile Error] ${i} Original: ${t}`)};try{const r=function(e,r){switch(r){case"template":return`return \`${e}\`;`;case"expression":return`return (${e});`;case"handler":case"lifecycle":return(n=e).endsWith(";")?n:n+";";default:return"return undefined;"}var n}(c,o),{loopValues:n,loopIndices:t}=function(e){return e.length?{loopValues:`var [${e.map(e=>e.i).join(", ")}] = loops.map(l => l.itmVal);`,loopIndices:`var [${e.map(e=>e.x).join(", ")}] = loops.map(l => l.idxVal);`}:{loopValues:"",loopIndices:""}}(s),i=function(e,r,n,t){const o="lifecycle"===e?["el","loops"]:"handler"===e?["event","loops"]:["loops"],s=`\n const { $data } = this;\n ${"handler"===e?"const { value, checked } = event?.target || {};":""}\n ${n}\n ${t}\n ${r}\n `.replace(/^\s+|\s+$/gm,"");return o.push(s),o}(o,r,n,t);return e.createFunction(i)}catch(a){const e=a instanceof Error?a.message:String(a);return function(){throw new Error(`[Parse Error] ${e} Original: ${t}`)}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createFunction as r}from"./functions.js";const e=/\{\{\{\s*[\s\S]*?\s*\}\}\}/,n=/\{\{\s*([\s\S]*?)\s*\}\}/g;function t(t,o,s){if(!
|
|
1
|
+
import{createFunction as r}from"./functions.js";const e=/\{\{\{\s*[\s\S]*?\s*\}\}\}/,n=/\{\{\s*([\s\S]*?)\s*\}\}/g;function t(t,o,s){if(!t?.trim())return()=>"";const{processed:i,error:a}=function(r,t){if(!r?.trim())return{processed:""};if(e.test(r))return{processed:r,error:"Illegal interpolation syntax: use {{ }} instead of {{{ }}}"};if("template"===t)try{return{processed:r.replace(n,(r,e)=>`\${${e.trim()}}`)}}catch(o){return{processed:r,error:`Template parse error: ${o instanceof Error?o.message:String(o)}`}}return{processed:r}}(t,o);if(a)return function(){throw new Error(`[Compile Error] ${a} Original: ${t}`)};try{const e=function(r,e){switch(e){case"template":return`return \`${r}\`;`;case"expression":return`return (${r});`;case"handler":case"lifecycle":return(n=r).endsWith(";")?n:n+";";default:return"return undefined;"}var n}(i,o),{loopValues:n,loopIndices:t}=function(r){return r.length?{loopValues:`var [${r.map(r=>r.i).join(", ")}] = loops.map(l => l.itmVal);`,loopIndices:`var [${r.map(r=>r.x).join(", ")}] = loops.map(l => l.idxVal);`}:{loopValues:"",loopIndices:""}}(s),a=function(r,e,n,t){const o="lifecycle"===r?["el","loops"]:"handler"===r?["event","loops"]:["loops"],s=`\n const { $data } = this;\n ${"handler"===r?"const { value, checked } = event?.target || {};":""}\n ${n}\n ${t}\n ${e}\n `.replace(/^\s+|\s+$/gm,"");return o.push(s),o}(o,e,n,t);return r(a)}catch(c){const r=c instanceof Error?c.message:String(c);return function(){throw new Error(`[Parse Error] ${r} Original: ${t}`)}}}export{t as genFunction};
|
package/dist/shared/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./templateError.cjs"),r=require("./gen-function.cjs"),s=require("./functions.cjs"),t=require("./event-listeners.cjs"),o=require("./is-object.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./templateError.cjs"),r=require("./gen-function.cjs"),s=require("./functions.cjs"),t=require("./event-listeners.cjs"),o=require("./is-object.cjs"),i=require("./url.cjs"),c=require("./env.cjs"),n=require("./case-convert.cjs"),a=require("./svg-sanitize.cjs");exports.showTemplateError=e.showTemplateError,exports.genFunction=r.genFunction,exports.createFunction=s.createFunction,exports.isCSPBlocked=s.isCSPBlocked,exports.listeners=t.default,exports.isObject=o.isObject,exports.parseHashUrl=i.parseHashUrl,exports.IS_DEV=c.IS_DEV,exports.IS_PROD=c.IS_PROD,exports.SOLELY_VERSION=c.SOLELY_VERSION,exports.camelToKebab=n.camelToKebab,exports.sanitizeSvg=a.sanitizeSvg;
|
package/dist/shared/index.d.ts
CHANGED
package/dist/shared/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{showTemplateError as r}from"./templateError.js";import{genFunction as o}from"./gen-function.js";import{createFunction as t,isCSPBlocked as
|
|
1
|
+
import{showTemplateError as r}from"./templateError.js";import{genFunction as o}from"./gen-function.js";import{createFunction as t,isCSPBlocked as s}from"./functions.js";import{default as m}from"./event-listeners.js";import{isObject as e}from"./is-object.js";import{parseHashUrl as i}from"./url.js";import{IS_DEV as f,IS_PROD as n,SOLELY_VERSION as p}from"./env.js";import{camelToKebab as j}from"./case-convert.js";import{sanitizeSvg as a}from"./svg-sanitize.js";export{f as IS_DEV,n as IS_PROD,p as SOLELY_VERSION,j as camelToKebab,t as createFunction,o as genFunction,s as isCSPBlocked,e as isObject,m as listeners,i as parseHashUrl,a as sanitizeSvg,r as showTemplateError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./env.cjs"),t=new Set(["svg","g","defs","symbol","use","switch","view","metadata","title","desc","style","a","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","image","lineargradient","radialgradient","stop","pattern","solidcolor","clippath","mask","marker","filter","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","animate","animatemotion","animatetransform","set","mpath","discard"]),r=new Set(["set","animate","animatetransform","animatemotion"]),n=/^\s*(?:javascript|vbscript)\s*:/i,o=/^\s*data:(?!image\/)/i,s=new Set(["href","xlink:href","src","action","formaction"]),a=["to","values","from","by"],i=new Map;function f(e){const t=e.replace(/[\s-]+/g,"");return n.test(t)||o.test(t)}function l(e){const t=(e.getAttribute("attributeName")||"").toLowerCase();return!!t&&(!!t.startsWith("on")||!!s.has(t)&&a.some(t=>{const r=e.getAttribute(t);return null!==r&&f(r)}))}function c(e){for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();t.has(e)?r.has(e)&&l(n)?n.remove():c(n):n.remove()}for(const t of Array.from(e.attributes)){const r=t.name.toLowerCase();(r.startsWith("on")||s.has(r)&&f(t.value))&&e.removeAttribute(t.name)}}exports.sanitizeSvg=function(t){if(!t)return"";if("undefined"==typeof DOMParser)return"";const r=i.get(t);if(void 0!==r)return r;const n=function(t){const r=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,n=(new DOMParser).parseFromString(r,"image/svg+xml");if(!n.querySelector("parsererror"))return c(n.documentElement),n.documentElement.innerHTML;e.IS_DEV&&console.warn("[Solely Icon] SVG XML 解析失败,回退 HTML 容错解析");const o=(new DOMParser).parseFromString(r,"text/html"),s=o.body?.firstElementChild;return s?(c(s),s.innerHTML):""}(t);if(i.size>=500){const e=i.size-500+1,t=i.keys();for(let r=0;r<e;r++){const e=t.next().value;if(void 0===e)break;i.delete(e)}}return i.set(t,n),n};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG 内容消毒工具
|
|
3
|
+
*
|
|
4
|
+
* 背景:icon 组件通过 `innerHTML` 注入 SVG 内容,内容来源包括
|
|
5
|
+
* 开发者注册的图标(registerIcon)和远程加载的 SVG Sprite(loadIconSprite)。
|
|
6
|
+
* 后者可能来自第三方源,恶意 SVG 可携带 SMIL 事件属性(onbegin/onend)、
|
|
7
|
+
* <script>、<foreignObject>、javascript: 链接等 XSS 载荷。
|
|
8
|
+
*
|
|
9
|
+
* 注意:通过 innerHTML 注入的 <script> 不会执行,但 SVG 的 SMIL 动画
|
|
10
|
+
* 事件属性(如 <animate onbegin="...">)在现代浏览器中仍会触发,
|
|
11
|
+
* 因此必须在注入前消毒。
|
|
12
|
+
*
|
|
13
|
+
* 设计取舍:不引入 DOMPurify 等运行时依赖(本项目零运行时依赖是核心卖点),
|
|
14
|
+
* 采用 DOMParser + 手写规则,覆盖:
|
|
15
|
+
* - 元素白名单:仅保留合法 SVG 元素,其余(script / foreignObject / HTML /
|
|
16
|
+
* MathML / 未知命名空间)一律移除
|
|
17
|
+
* - on* 事件属性(含 SMIL 的 onbegin/onend/onrepeat)
|
|
18
|
+
* - 危险协议 URL:javascript: / vbscript: / data:text/html
|
|
19
|
+
* - SMIL 动画写属性载荷:<set>/<animate> 等通过 attributeName 在运行时
|
|
20
|
+
* 写入 on*(无条件拦截)或 URL 属性(值携带危险协议时拦截)
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* 消毒 SVG 字符串,移除可执行载荷
|
|
24
|
+
* @param svg 原始 SVG 内容
|
|
25
|
+
* @returns 消毒后的 SVG 字符串;解析失败或环境无 DOMParser 时返回空串(安全兜底)
|
|
26
|
+
*/
|
|
27
|
+
export declare function sanitizeSvg(svg: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IS_DEV as e}from"./env.js";const t=new Set(["svg","g","defs","symbol","use","switch","view","metadata","title","desc","style","a","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","textpath","image","lineargradient","radialgradient","stop","pattern","solidcolor","clippath","mask","marker","filter","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","animate","animatemotion","animatetransform","set","mpath","discard"]),r=new Set(["set","animate","animatetransform","animatemotion"]),n=/^\s*(?:javascript|vbscript)\s*:/i,o=/^\s*data:(?!image\/)/i,a=new Set(["href","xlink:href","src","action","formaction"]),s=["to","values","from","by"],i=new Map;function f(e){const t=e.replace(/[\s-]+/g,"");return n.test(t)||o.test(t)}function l(e){const t=(e.getAttribute("attributeName")||"").toLowerCase();return!!t&&(!!t.startsWith("on")||!!a.has(t)&&s.some(t=>{const r=e.getAttribute(t);return null!==r&&f(r)}))}function m(t){if(!t)return"";if("undefined"==typeof DOMParser)return"";const r=i.get(t);if(void 0!==r)return r;const n=function(t){const r=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,n=(new DOMParser).parseFromString(r,"image/svg+xml");if(!n.querySelector("parsererror"))return c(n.documentElement),n.documentElement.innerHTML;e&&console.warn("[Solely Icon] SVG XML 解析失败,回退 HTML 容错解析");const o=(new DOMParser).parseFromString(r,"text/html"),a=o.body?.firstElementChild;return a?(c(a),a.innerHTML):""}(t);if(i.size>=500){const e=i.size-500+1,t=i.keys();for(let r=0;r<e;r++){const e=t.next().value;if(void 0===e)break;i.delete(e)}}return i.set(t,n),n}function c(e){for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();t.has(e)?r.has(e)&&l(n)?n.remove():c(n):n.remove()}for(const t of Array.from(e.attributes)){const r=t.name.toLowerCase();(r.startsWith("on")||a.has(r)&&f(t.value))&&e.removeAttribute(t.name)}}export{m as sanitizeSvg};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",c="#ff6b6b",l="#ffffff",r="#a0a0a0",i="#5ddcff";function s(o){let n=0;for(let e=0;e<o.length;){const t=o.codePointAt(e)??0;"\t"!==o[e]?(n+=t>=9472&&t<=9599||t>255?2:1,e+=t>65535?2:1):(n+=4,e++)}return n}function f(o,n={}){const{lineIndex:e=0,totalLines:t=1}=n,c=Math.max(1,Math.floor(o));return(t<=1||0===e?"^":"~").repeat(c)}exports.showTemplateError=function(a,p="",$,d="component"){const g=`%c[Solely]%c Template Error in <${d}> → ${a?.message??String(a)}`,h=[`color:${l};background:${c};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!p||!$?.loc||$.loc.length<2)return console.error(g,...h),void($?.expr&&console.info(`Expression: ${$.expr.trim()}`));const x=$.loc;let m=x[0]||0,u=x[1]||0;m|=0,u|=0,m<1&&(m=1),u<1&&(u=1);const b=p.split("\n");if(m>b.length)return void console.error(`[Solely] 行号 ${m} 超出范围`);const S=m-1,M=Math.max(0,S-3),w=Math.min(b.length-1,S+3),E=String(w+1).length,y=$.expr?.trim()??"",v=y?y.split("\n"):[],L=y?Math.max(...v.map(s)):0,T=v.length>1,k=`color:${o};`,C=`color:${t};font-weight:bold;`,I=`color:${o};`,P=`color:${e};background:${n};padding:0 4px;`,j=`color:${o};`,A=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${g} %c(Line:${m}, Col:${u})`,...h,`color:${o};font-weight:normal;`);for(let o=M;o<=w;o++){const n=b[o],e=String(o+1).padStart(E," ");if(o!==S){console.info(`%c${e} │%c ${n}`,k,I);continue}const t=s(n.slice(0,Math.max(0,u-1))),c=" ".repeat(E+3),l=e.padEnd(E," ");if(console.info(`%c${l} │%c ${n}`,C,P),T)for(let o=0;o<v.length;o++){const n=v[o],e=S+o;let l=0;if(0===o)l=t;else if(e<b.length){const o=b[e],n=o.search(/\S/);l=s(-1===n?o:o.slice(0,n))}const r=f(Math.max(1,s(n.trim())),{lineIndex:o,totalLines:v.length}),i=c+" ".repeat(l);if(0===o)console.info(`%c${i}%c${r}`,j,A);else if(e<b.length){const o=String(e+1).padEnd(E," "),n=b[e];console.info(`%c${o} │%c ${n}`,C,P),console.info(`%c${i}%c${r}`,j,A)}}else{const o=c+" ".repeat(t),n=f(L||1);console.info(`%c${o}%c${n}`,j,A)}}y&&console.info(`%cExpression:%c ${y}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",
|
|
1
|
+
const o="#858585",n="#3c1e1e",e="#f8f8f2",t="#ff6b6b",c="#ff6b6b",l="#ffffff",r="#a0a0a0",i="#5ddcff";function f(o){let n=0;for(let e=0;e<o.length;){const t=o.codePointAt(e)??0;"\t"!==o[e]?(n+=t>=9472&&t<=9599||t>255?2:1,e+=t>65535?2:1):(n+=4,e++)}return n}function s(o,n={}){const{lineIndex:e=0,totalLines:t=1}=n,c=Math.max(1,Math.floor(o));return(t<=1||0===e?"^":"~").repeat(c)}function a(a,$="",p,d="component"){const g=`%c[Solely]%c Template Error in <${d}> → ${a?.message??String(a)}`,h=[`color:${l};background:${c};padding:4px 10px;border-radius:6px;font-weight:bold;`,`color:${t};font-weight:bold;`];if(!$||!p?.loc||p.loc.length<2)return console.error(g,...h),void(p?.expr&&console.info(`Expression: ${p.expr.trim()}`));const x=p.loc;let m=x[0]||0,u=x[1]||0;m|=0,u|=0,m<1&&(m=1),u<1&&(u=1);const b=$.split("\n");if(m>b.length)return void console.error(`[Solely] 行号 ${m} 超出范围`);const S=m-1,M=Math.max(0,S-3),w=Math.min(b.length-1,S+3),E=String(w+1).length,y=p.expr?.trim()??"",L=y?y.split("\n"):[],k=y?Math.max(...L.map(f)):0,v=L.length>1,C=`color:${o};`,I=`color:${t};font-weight:bold;`,A=`color:${o};`,P=`color:${e};background:${n};padding:0 4px;`,T=`color:${o};`,j=`color:${t};font-weight:bold;padding:0 4px;`;console.groupCollapsed(`${g} %c(Line:${m}, Col:${u})`,...h,`color:${o};font-weight:normal;`);for(let o=M;o<=w;o++){const n=b[o],e=String(o+1).padStart(E," ");if(o!==S){console.info(`%c${e} │%c ${n}`,C,A);continue}const t=f(n.slice(0,Math.max(0,u-1))),c=" ".repeat(E+3),l=e.padEnd(E," ");if(console.info(`%c${l} │%c ${n}`,I,P),v)for(let o=0;o<L.length;o++){const n=L[o],e=S+o;let l=0;if(0===o)l=t;else if(e<b.length){const o=b[e],n=o.search(/\S/);l=f(-1===n?o:o.slice(0,n))}const r=s(Math.max(1,f(n.trim())),{lineIndex:o,totalLines:L.length}),i=c+" ".repeat(l);if(0===o)console.info(`%c${i}%c${r}`,T,j);else if(e<b.length){const o=String(e+1).padEnd(E," "),n=b[e];console.info(`%c${o} │%c ${n}`,I,P),console.info(`%c${i}%c${r}`,T,j)}}else{const o=c+" ".repeat(t),n=s(k||1);console.info(`%c${o}%c${n}`,T,j)}}y&&console.info(`%cExpression:%c ${y}`,`color:${r};font-weight:bold;`,`color:${i};font-family:monospace;`),console.groupEnd()}export{a as showTemplateError};
|