solely 0.6.0 → 0.7.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 +76 -26
- 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/message/index.cjs +1 -1
- package/dist/components/commands/message/index.js +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/badge/index.html.cjs +1 -1
- package/dist/components/elements/badge/index.html.js +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/button/index.html.cjs +1 -1
- package/dist/components/elements/button/index.html.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.html.cjs +1 -1
- package/dist/components/elements/checkbox/index.html.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/fab/index.html.cjs +1 -1
- package/dist/components/elements/fab/index.html.js +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/not-found/index.html.cjs +1 -1
- package/dist/components/elements/not-found/index.html.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/progress/index.html.cjs +1 -1
- package/dist/components/elements/progress/index.html.js +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/select/index.html.cjs +1 -1
- package/dist/components/elements/select/index.html.js +1 -1
- package/dist/components/elements/skeleton/index.html.cjs +1 -1
- package/dist/components/elements/skeleton/index.html.js +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/steps/index.html.cjs +1 -1
- package/dist/components/elements/steps/index.html.js +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/table/index.html.cjs +1 -1
- package/dist/components/elements/table/index.html.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/timeline/index.html.cjs +1 -1
- package/dist/components/elements/timeline/index.html.js +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/tree/index.html.cjs +1 -1
- package/dist/components/elements/tree/index.html.js +1 -1
- package/dist/components/elements/upload/index.html.cjs +1 -1
- package/dist/components/elements/upload/index.html.js +1 -1
- package/dist/plugins/solely-vite-plugin.cjs +1 -1
- package/dist/plugins/solely-vite-plugin.d.ts +10 -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/runtime/component/base-element.cjs +1 -1
- package/dist/runtime/component/base-element.d.ts +8 -1
- package/dist/runtime/component/base-element.js +1 -1
- package/dist/runtime/component/decorators.d.ts +7 -0
- package/dist/runtime/reactivity/observe.cjs +1 -1
- package/dist/runtime/reactivity/observe.d.ts +1 -0
- package/dist/runtime/reactivity/observe.js +1 -1
- package/dist/runtime/renderer/html-decode.cjs +1 -1
- package/dist/runtime/renderer/html-decode.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/svg-sanitize.cjs +1 -1
- package/dist/shared/svg-sanitize.js +1 -1
- package/dist/types/ir.d.ts +2 -2
- package/package.json +6 -3
package/dist/router/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_DEV as e}from"../shared/env.js";let t=null,s=null,i=null;function a(){return t?Promise.resolve(t):(i||(i=new Promise(e=>{s=e})),i)}const r=(()=>{const e=()=>a();return Object.defineProperties(e,{then:{value:(e,t)=>a().then(e,t),writable:!1,enumerable:!1,configurable:!0},catch:{value:e=>a().catch(e),writable:!1,enumerable:!1,configurable:!0},finally:{value:e=>a().finally(e),writable:!1,enumerable:!1,configurable:!0},[Symbol.toStringTag]:{value:"Promise",writable:!1,enumerable:!1,configurable:!0}}),e})();function n(e){return t||(t=new o(e),s&&s(t),s=null,i=null,t)}function h(){return t}class o{routes;base;mode;beforeEachGuard;afterEachGuard;currentRoute=null;listeners=new Set;componentCache=new Map;keepAliveCache=new Map;keepAliveKeys=[];navigationId=0;maxKeepAlive;constructor(e){this.routes=e.routes,this.base=this.normalizeBase(e.base),this.mode=e.mode||"history",this.beforeEachGuard=e.beforeEach,this.afterEachGuard=e.afterEach,this.maxKeepAlive=e.maxKeepAlive}normalizeBase(e){let t=e||"/";return t.startsWith("/")||(t="/"+t),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}static MAX_REDIRECTS=20;matchRoute(e="/"){return this.matchRouteInternal(e,new Set,0)}matchRouteInternal(t,s,i){if(i>=o.MAX_REDIRECTS)return e&&console.error(`[Router] Too many redirects (max ${o.MAX_REDIRECTS}), last path: ${t}`),null;const a=this.normalizePath(t);if(s.has(a))return e&&console.error(`[Router] Circular redirect detected: ${a}`),null;s.add(a);const[r,n]=a.split("?"),h=r.split("/").filter(Boolean),c=this.parseQuery(n),l=this.recursiveMatch(this.routes,h);if(l){const e=l.matched[l.matched.length-1];return e.config.redirect?this.matchRouteInternal(e.config.redirect,s,i+1):{matched:l.matched,params:l.params,query:c,fullPath:a,meta:l.matched.reduce((e,t)=>({...e,...t.config.meta||{}}),{})}}return null}recursiveMatch(e,t){const s=[...e].sort((e,t)=>this.calculateScore(t.path)-this.calculateScore(e.path));for(const i of s){const e=i.path.split("/").filter(Boolean),s={};let a=!0;if(0===e.length&&0===t.length)return{matched:[{config:i,params:{}}],params:{}};for(let i=0;i<e.length;i++){const r=e[i],n=t[i];if(r.startsWith(":")){if(!n){a=!1;break}Object.defineProperty(s,r.slice(1),{value:n,writable:!0,enumerable:!0,configurable:!0})}else{if("*"===r){a=!0;break}if(r!==n){a=!1;break}}}if(a){const a=e.length,r=t.slice(a),n={config:i,params:s};if(r.length>0&&i.children){const e=this.recursiveMatch(i.children,r);if(e)return{matched:[n,...e.matched],params:{...s,...e.params}}}else if(0===r.length||e.includes("*"))return{matched:[n],params:s}}}return null}calculateScore(e="/"){const t=e.split("/").filter(Boolean);return 0===t.length?1:t.reduce((e,t)=>t.startsWith(":")?e+5:"*"===t?e+0:e+10,0)}parseQuery(e){const t={};return e?(new URLSearchParams(e).forEach((e,s)=>{Object.defineProperty(t,s,{value:e,writable:!0,enumerable:!0,configurable:!0})}),t):t}normalizePath(e="/"){const t=e&&"string"==typeof e?e:"/",s=t.indexOf("?"),i=-1===s?t:t.slice(0,s),a=-1===s?"":t.slice(s+1);let r=i;return r.startsWith("/")||(r="/"+r),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),a?`${r}?${a}`:r}getPath(){let e;try{e="hash"===this.mode?window.location.hash.slice(1)||"/":`${window.location.pathname}${window.location.search}`}catch{e="/"}const t=this.base||"/";return"/"===t||e!==t&&!e.startsWith(t+"/")||(e=e.slice(t.length)||"/"),this.normalizePath(e)}updateBrowserHistory(e="/",t){const s=this.normalizePath(e),i=this.base||"/";if("hash"===this.mode)t?window.location.replace(`#${s}`):window.location.hash=s;else{const e=i.endsWith("/")?i.slice(0,-1):i,a="/"===e?s:e+s;t?window.history.replaceState({path:a},"",a):window.history.pushState({path:a},"",a)}}async navigate(e="/",t=!1,s=!1){const i=++this.navigationId,a=this.normalizePath(e),r=this.currentRoute,n=this.matchRoute(a);if(!n)return{success:!1,error:`No route matched: ${a}`};if(r&&r.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const e=await this.beforeEachGuard(n,r);if(i!==this.navigationId)return{success:!1,cancelled:!0};if(!1===e)return{success:!1,cancelled:!0};if("string"==typeof e)return this.navigate(e,t)}catch(h){return i!==this.navigationId?{success:!1,cancelled:!0}:{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return i!==this.navigationId?{success:!1,cancelled:!0}:(this.currentRoute=n,s||this.updateBrowserHistory(a,t),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,r),{success:!0})}resolve(e="/"){const t=this.normalizePath(e);if("hash"===this.mode)return`#${t}`;const s=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===s?t:s+t}get modeType(){return this.mode}pushWithQuery(e="/",t){const s=new URLSearchParams(t).toString(),i=e.includes("?")?"&":"?";return this.push(e+(s?i+s:""))}push(e="/"){return this.navigate(e,!1)}replace(e="/"){return this.navigate(e,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}isStarted=!1;handleRouteChange=null;setupListeners(){this.isStarted||(this.isStarted=!0,this.handleRouteChange=()=>{this.navigate(this.getPath(),!0,!0)},"hash"===this.mode?window.addEventListener("hashchange",this.handleRouteChange):window.addEventListener("popstate",this.handleRouteChange),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}destroy(){this.handleRouteChange&&("hash"===this.mode?window.removeEventListener("hashchange",this.handleRouteChange):window.removeEventListener("popstate",this.handleRouteChange),this.handleRouteChange=null),this.isStarted=!1,this.listeners.clear(),this.componentCache.clear()
|
|
1
|
+
import{IS_DEV as e}from"../shared/env.js";let t=null,s=null,i=null;function a(){return t?Promise.resolve(t):(i||(i=new Promise(e=>{s=e})),i)}const r=(()=>{const e=()=>a();return Object.defineProperties(e,{then:{value:(e,t)=>a().then(e,t),writable:!1,enumerable:!1,configurable:!0},catch:{value:e=>a().catch(e),writable:!1,enumerable:!1,configurable:!0},finally:{value:e=>a().finally(e),writable:!1,enumerable:!1,configurable:!0},[Symbol.toStringTag]:{value:"Promise",writable:!1,enumerable:!1,configurable:!0}}),e})();function n(e){return t||(t=new o(e),s&&s(t),s=null,i=null,t)}function h(){return t}class o{routes;base;mode;beforeEachGuard;afterEachGuard;currentRoute=null;listeners=new Set;componentCache=new Map;keepAliveCache=new Map;keepAliveKeys=[];navigationId=0;maxKeepAlive;constructor(e){this.routes=e.routes,this.base=this.normalizeBase(e.base),this.mode=e.mode||"history",this.beforeEachGuard=e.beforeEach,this.afterEachGuard=e.afterEach,this.maxKeepAlive=e.maxKeepAlive}normalizeBase(e){let t=e||"/";return t.startsWith("/")||(t="/"+t),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}static MAX_REDIRECTS=20;matchRoute(e="/"){return this.matchRouteInternal(e,new Set,0)}matchRouteInternal(t,s,i){if(i>=o.MAX_REDIRECTS)return e&&console.error(`[Router] Too many redirects (max ${o.MAX_REDIRECTS}), last path: ${t}`),null;const a=this.normalizePath(t);if(s.has(a))return e&&console.error(`[Router] Circular redirect detected: ${a}`),null;s.add(a);const[r,n]=a.split("?"),h=r.split("/").filter(Boolean),c=this.parseQuery(n),l=this.recursiveMatch(this.routes,h);if(l){const e=l.matched[l.matched.length-1];return e.config.redirect?this.matchRouteInternal(e.config.redirect,s,i+1):{matched:l.matched,params:l.params,query:c,fullPath:a,meta:l.matched.reduce((e,t)=>({...e,...t.config.meta||{}}),{})}}return null}recursiveMatch(e,t){const s=[...e].sort((e,t)=>this.calculateScore(t.path)-this.calculateScore(e.path));for(const i of s){const e=i.path.split("/").filter(Boolean),s={};let a=!0;if(0===e.length&&0===t.length)return{matched:[{config:i,params:{}}],params:{}};for(let i=0;i<e.length;i++){const r=e[i],n=t[i];if(r.startsWith(":")){if(!n){a=!1;break}Object.defineProperty(s,r.slice(1),{value:n,writable:!0,enumerable:!0,configurable:!0})}else{if("*"===r){a=!0;break}if(r!==n){a=!1;break}}}if(a){const a=e.length,r=t.slice(a),n={config:i,params:s};if(r.length>0&&i.children){const e=this.recursiveMatch(i.children,r);if(e)return{matched:[n,...e.matched],params:{...s,...e.params}}}else if(0===r.length||e.includes("*"))return{matched:[n],params:s}}}return null}calculateScore(e="/"){const t=e.split("/").filter(Boolean);return 0===t.length?1:t.reduce((e,t)=>t.startsWith(":")?e+5:"*"===t?e+0:e+10,0)}parseQuery(e){const t={};return e?(new URLSearchParams(e).forEach((e,s)=>{Object.defineProperty(t,s,{value:e,writable:!0,enumerable:!0,configurable:!0})}),t):t}normalizePath(e="/"){const t=e&&"string"==typeof e?e:"/",s=t.indexOf("?"),i=-1===s?t:t.slice(0,s),a=-1===s?"":t.slice(s+1);let r=i;return r.startsWith("/")||(r="/"+r),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),a?`${r}?${a}`:r}getPath(){let e;try{e="hash"===this.mode?window.location.hash.slice(1)||"/":`${window.location.pathname}${window.location.search}`}catch{e="/"}const t=this.base||"/";return"/"===t||e!==t&&!e.startsWith(t+"/")||(e=e.slice(t.length)||"/"),this.normalizePath(e)}updateBrowserHistory(e="/",t){const s=this.normalizePath(e),i=this.base||"/";if("hash"===this.mode)t?window.location.replace(`#${s}`):window.location.hash=s;else{const e=i.endsWith("/")?i.slice(0,-1):i,a="/"===e?s:e+s;t?window.history.replaceState({path:a},"",a):window.history.pushState({path:a},"",a)}}async navigate(e="/",t=!1,s=!1){const i=++this.navigationId,a=this.normalizePath(e),r=this.currentRoute,n=this.matchRoute(a);if(!n)return{success:!1,error:`No route matched: ${a}`};if(r&&r.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const e=await this.beforeEachGuard(n,r);if(i!==this.navigationId)return{success:!1,cancelled:!0};if(!1===e)return{success:!1,cancelled:!0};if("string"==typeof e)return this.navigate(e,t)}catch(h){return i!==this.navigationId?{success:!1,cancelled:!0}:{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return i!==this.navigationId?{success:!1,cancelled:!0}:(this.currentRoute=n,s||this.updateBrowserHistory(a,t),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,r),{success:!0})}resolve(e="/"){const t=this.normalizePath(e);if("hash"===this.mode)return`#${t}`;const s=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===s?t:s+t}get modeType(){return this.mode}pushWithQuery(e="/",t){const s=new URLSearchParams(t).toString(),i=e.includes("?")?"&":"?";return this.push(e+(s?i+s:""))}push(e="/"){return this.navigate(e,!1)}replace(e="/"){return this.navigate(e,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}isStarted=!1;handleRouteChange=null;setupListeners(){this.isStarted||(this.isStarted=!0,this.handleRouteChange=()=>{this.navigate(this.getPath(),!0,!0)},"hash"===this.mode?window.addEventListener("hashchange",this.handleRouteChange):window.addEventListener("popstate",this.handleRouteChange),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}destroy(){this.handleRouteChange&&("hash"===this.mode?window.removeEventListener("hashchange",this.handleRouteChange):window.removeEventListener("popstate",this.handleRouteChange),this.handleRouteChange=null),this.isStarted=!1,this.listeners.clear(),this.componentCache.clear();for(const e of this.keepAliveCache.values())e.dispose?.();this.keepAliveCache.clear(),this.keepAliveKeys=[],this.currentRoute=null,t=null}getCurrentRoute(){return this.currentRoute}getKeepAlive(e){const t=this.keepAliveCache.get(e);if(t){const t=this.keepAliveKeys.indexOf(e);-1!==t&&(this.keepAliveKeys.splice(t,1),this.keepAliveKeys.push(e))}return t}setKeepAlive(e,t){if(this.keepAliveCache.has(e)){const s=this.keepAliveCache.get(e);s&&s!==t&&s.dispose?.(),this.keepAliveCache.set(e,t);const i=this.keepAliveKeys.indexOf(e);-1!==i&&(this.keepAliveKeys.splice(i,1),this.keepAliveKeys.push(e))}else this.keepAliveCache.set(e,t),this.keepAliveKeys.push(e),this.evictKeepAlive()}hasKeepAlive(e){return this.keepAliveCache.has(e)}evictKeepAlive(){if(this.maxKeepAlive)for(;this.keepAliveKeys.length>this.maxKeepAlive;){const e=this.keepAliveKeys.shift();if(e){const t=this.keepAliveCache.get(e);t?.dispose?.(),this.keepAliveCache.delete(e)}}}cacheKey(e){return this.normalizePath(e)}prefetch(e){const t=this.matchRoute(e);if(!t)return;const s=this.cacheKey(t.fullPath),i=t.matched[t.matched.length-1];if(!i?.config.component)return;const a=i.config.component;if("function"!=typeof a)return;if(this.componentCache.has(s))return;const r=a();this.componentCache.set(s,r),r.catch(()=>{this.componentCache.delete(s)})}getComponentFromCache(e){return this.componentCache.get(this.cacheKey(e))}}export{o as Router,n as createRouter,h as getRouter,r as routerReady};
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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"),o="undefined"!=typeof HTMLElement?HTMLElement:class{};function n(e){if(null===e||"object"!=typeof e)return e;const t=globalThis.structuredClone;if("function"==typeof t)try{return t(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return e}}class c extends o{$refs={};#e;#t;#s;#i;#r;#a;#o=!1;#n=!1;#c=!1;#d=!1;#h=!1;#l=!1;#u=!1;#p=new Set;#f=!1;#b=!1;static#y=new Map;static#m=new WeakSet;#g=new Map;static#S=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.#v(e),this.#A(s),queueMicrotask(()=>this.#O())}#C(){const e=Object.getOwnPropertyNames(this),t=["#","_"],s=c.#S,i=new Map;let r=Object.getPrototypeOf(this);for(;r&&r!==o.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)}}#v(e){t.IS_DEV&&e&&"object"==typeof e&&(c.#m.has(e)&&console.warn(`[Solely] <${this.#e.tagName}>: 该初始数据对象已被其他实例使用,$data 会共享同一响应式代理(改一个实例会同时触发另一个实例刷新)。如需实例隔离,请为每个实例传入新对象。`),c.#m.add(e));const{proxy:s,dispose:r}=i.observe(e,e=>{if("set"===e.type||"array-replace"===e.type){const{key:t,newValue:s}=e,i=this.#e,r=String(t),a=i.propMap?.get(r);a?.reflect&&this.#R(a,s)}!1!==this.#e.dataChangeEvent&&this.emit("dataChange",{...e}),this.#w()});this.#i=s,this.#a=r}#R(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)}}#A(e){e.ir&&(this.#s=e.ir)}#j(e){const t=this.#g.get(e);if(void 0!==t)return t;let s=null,i=Object.getPrototypeOf(this);for(;i&&i!==o.prototype;){const t=Object.getOwnPropertyDescriptor(i,e);if(t){s=t.get||t.set?t:null;break}i=Object.getPrototypeOf(i)}return this.#g.set(e,s),s}#$(e,t){const s=this.#j(e.name);s?.set?this[e.name]=t:this.$data[e.name]=t}#N(){const e=this.#e;if(e.attributeMap)for(const[,t]of e.attributeMap)if(!1!==t.reactive&&!this.#j(t.name)){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})}}#P(){this.#u||(this.#u=!0,this.#N())}get $data(){return this.#i}set $data(t){e.isObject(t)||(t={}),t!==this.#i&&(this.#a?.(),this.#v(t),this.#P(),this.#w())}#M(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}}#w(){this.#f||(this.#h?!this.#n&&this.#t&&(this.#n=!0,queueMicrotask(()=>{this.#f||(this.#n=!1,this.#D())})):this.#l=!0)}#D(){if(!this.#f&&!this.#o&&this.#h){this.#o=!0;try{this.#c&&this.beforeAttributesUpdate(),this.beforeUpdate(),this.#t?.update(),this.updated(),this.#c&&(this.afterAttributesUpdate(),this.#c=!1)}finally{this.#o=!1}}}refresh(){this.#w()}#E(){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,o="undefined"!=typeof CSS&&CSS.escape?CSS.escape(r):r.replace(/([.#:[\]()!])/g,"\\$1");if(!i.querySelector(`#${o}`)){const t=document.createElement("style");t.id=r,t.textContent=e.styles,i.appendChild(t)}if(a){const e=c.#y.get(r)||0;c.#y.set(r,e+1),this.#b=!0}}#U(){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=c.#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(),c.#y.delete(s)}else c.#y.set(s,i-1)}}connectedCallback(){if(this.#f)return t.IS_DEV&&console.error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`),void this.remove();this.#h=!0;const s=this.#e;if(this.#O(),(s.className||s.tagName||"").split(" ").forEach(e=>e&&this.classList.add(e)),this.#E(),s.attributeMap&&e.isObject(this.$data)){this.#P();for(const[e,t]of s.attributeMap){const s=t.name;if(this.hasAttribute(e)){const s=this.getAttribute(e),i=this.#M(s,n(t.default),t.type);this.#$(t,i)}else"default"in t&&void 0===this.$data[s]&&(this.#$(t,n(t.default)),"boolean"===t.type&&!0===t.default&&this.setAttribute(e,""))}}this.#C(),this.#s&&!this.#t&&(this.#t=r.createRender(this.#s,this.#r,this)),this.#l&&(this.#l=!1,this.#w()),this.mounted()}disconnectedCallback(){this.#h=!1,this.#f||this.#U(),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,c=this.$data[o],d=void 0!==a.default?n(a.default):c,h=this.#M(i,d,a.type);c!==h&&(this.#c=!0,this.#$(a,h),this.$data[o]===c&&(this.#c=!1),this.attributeChanged(t,c,h))}#O(){this.#d||(this.#d=!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.#h=!1,this.#U(),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=c;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node/SSR 环境没有 HTMLElement。若模块顶层直接 `extends HTMLElement`,
|
|
3
|
+
* `import 'solely'` 会在求值阶段抛 `ReferenceError: HTMLElement is not defined`。
|
|
4
|
+
* 这里退化为空基类:浏览器环境仍是原生 HTMLElement(行为不变),
|
|
5
|
+
* Node 环境仅保证「可导入」,实例化与渲染仍需 DOM。
|
|
6
|
+
*/
|
|
7
|
+
declare const HTMLElementBase: typeof HTMLElement;
|
|
1
8
|
declare interface BaseElement<TData extends object = Record<string, unknown>, TRefs extends Record<string, Element> = Record<string, Element>> {
|
|
2
9
|
/**
|
|
3
10
|
* 通过 ref 属性获取的 DOM 元素引用集合
|
|
@@ -6,7 +13,7 @@ declare interface BaseElement<TData extends object = Record<string, unknown>, TR
|
|
|
6
13
|
*/
|
|
7
14
|
$refs: TRefs;
|
|
8
15
|
}
|
|
9
|
-
declare class BaseElement<TData extends object = Record<string, unknown>, TRefs extends Record<string, Element> = Record<string, Element>> extends
|
|
16
|
+
declare class BaseElement<TData extends object = Record<string, unknown>, TRefs extends Record<string, Element> = Record<string, Element>> extends HTMLElementBase implements BaseElement<TData, TRefs> {
|
|
10
17
|
#private;
|
|
11
18
|
$refs: TRefs;
|
|
12
19
|
static get observedAttributes(): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as t}from"../../shared/is-object.js";import{
|
|
1
|
+
import{isObject as t}from"../../shared/is-object.js";import{IS_DEV as e,SOLELY_VERSION 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"),n="undefined"!=typeof HTMLElement?HTMLElement:class{};function d(t){if(null===t||"object"!=typeof t)return t;const e=globalThis.structuredClone;if("function"==typeof e)try{return e(t)}catch{}try{return JSON.parse(JSON.stringify(t))}catch{return t}}class h extends n{$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 WeakSet;#g=new Map;static#v=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.#A(t),this.#S(s),queueMicrotask(()=>this.#O())}#C(){const t=Object.getOwnPropertyNames(this),e=["#","_"],s=h.#v,i=new Map;let r=Object.getPrototypeOf(this);for(;r&&r!==n.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)}}#A(t){e&&t&&"object"==typeof t&&(h.#y.has(t)&&console.warn(`[Solely] <${this.#t.tagName}>: 该初始数据对象已被其他实例使用,$data 会共享同一响应式代理(改一个实例会同时触发另一个实例刷新)。如需实例隔离,请为每个实例传入新对象。`),h.#y.add(t));const{proxy:s,dispose:i}=r(t,t=>{if("set"===t.type||"array-replace"===t.type){const{key:e,newValue:s}=t,i=this.#t,r=String(e),a=i.propMap?.get(r);a?.reflect&&this.#w(a,s)}!1!==this.#t.dataChangeEvent&&this.emit("dataChange",{...t}),this.#R()});this.#i=s,this.#a=i}#w(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)}}#S(t){t.ir&&(this.#s=t.ir)}#$(t){const e=this.#g.get(t);if(void 0!==e)return e;let s=null,i=Object.getPrototypeOf(this);for(;i&&i!==n.prototype;){const e=Object.getOwnPropertyDescriptor(i,t);if(e){s=e.get||e.set?e:null;break}i=Object.getPrototypeOf(i)}return this.#g.set(t,s),s}#j(t,e){const s=this.#$(t.name);s?.set?this[t.name]=e:this.$data[t.name]=e}#P(){const t=this.#t;if(t.attributeMap)for(const[,e]of t.attributeMap)if(!1!==e.reactive&&!this.#$(e.name)){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})}}#N(){this.#u||(this.#u=!0,this.#P())}get $data(){return this.#i}set $data(e){t(e)||(e={}),e!==this.#i&&(this.#a?.(),this.#A(e),this.#N(),this.#R())}#M(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}}#R(){this.#f||(this.#c?!this.#n&&this.#e&&(this.#n=!0,queueMicrotask(()=>{this.#f||(this.#n=!1,this.#U())})):this.#l=!0)}#U(){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.#R()}#D(){const t=this.#t;if(!t.styles)return;const e=this.#r;if(t.sheet&&e instanceof ShadowRoot&&"adoptedStyleSheets"in e){if(!e.adoptedStyleSheets.includes(t.sheet)){const s=Array.from(e.adoptedStyleSheets);s.push(t.sheet),e.adoptedStyleSheets=s}return void(this.#m=!0)}const i=e instanceof ShadowRoot?e:document.head,r=`solely-style-${s}-${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=h.#b.get(r)||0;h.#b.set(r,t+1),this.#m=!0}}#k(){if(!this.#m)return;this.#m=!1;const t=this.#t;if(!t.shadowDOM?.use&&t.styles){const e=`solely-style-${s}-${t.tagName}`,i=h.#b.get(e)||0;if(i<=1){const t="undefined"!=typeof CSS&&CSS.escape?CSS.escape(e):e.replace(/([.#:[\]()!])/g,"\\$1");document.head.querySelector(`#${t}`)?.remove(),h.#b.delete(e)}else h.#b.set(e,i-1)}}connectedCallback(){if(this.#f)return e&&console.error(`[Solely] <${this.tagName.toLowerCase()}> has been disposed and cannot be reconnected.`),void this.remove();this.#c=!0;const s=this.#t;if(this.#O(),(s.className||s.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),this.#D(),s.attributeMap&&t(this.$data)){this.#N();for(const[t,e]of s.attributeMap){const s=e.name;if(this.hasAttribute(t)){const s=this.getAttribute(t),i=this.#M(s,d(e.default),e.type);this.#j(e,i)}else"default"in e&&void 0===this.$data[s]&&(this.#j(e,d(e.default)),"boolean"===e.type&&!0===e.default&&this.setAttribute(t,""))}}this.#C(),this.#s&&!this.#e&&(this.#e=a(this.#s,this.#r,this)),this.#l&&(this.#l=!1,this.#R()),this.mounted()}disconnectedCallback(){this.#c=!1,this.#f||this.#k(),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],h=void 0!==a.default?d(a.default):n,c=this.#M(i,h,a.type);n!==c&&(this.#d=!0,this.#j(a,c),this.$data[o]===n&&(this.#d=!1),this.attributeChanged(e,n,c))}#O(){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,s){if(e&&t){const t=this.tagName.toLowerCase();console.warn(`[${t}] ${s}`)}}error(t,s){if(e&&t){const t=this.tagName.toLowerCase();console.error(`[${t}] ${s}`)}}dispose(){this.#f||(this.#f=!0,this.#c=!1,this.#k(),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{h as default};
|
|
@@ -51,6 +51,13 @@ export interface Manifest {
|
|
|
51
51
|
tagName: string;
|
|
52
52
|
/** s-model 双向绑定配置 */
|
|
53
53
|
model?: ModelConfig;
|
|
54
|
+
/**
|
|
55
|
+
* 是否在每次数据变更时派发 `dataChange` 事件(冒泡 + composed)
|
|
56
|
+
* - 默认 true,便于外部监听
|
|
57
|
+
* - 高频更新场景(输入框、拖拽)可设为 false 以省去事件构造与派发开销
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
dataChangeEvent?: boolean;
|
|
54
61
|
}
|
|
55
62
|
/** 框架内部使用的运行时版本 */
|
|
56
63
|
export interface InternalManifest extends Manifest {
|
|
@@ -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
|
|
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 a(e,t,n){c(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 c(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 l(t,n){const r=i.get(n);if(r)for(const e of r.keys())c(n,e);for(let o=0;o<t.length;o++){const r=t[o];e.isObject(r)&&!p(r)&&a(n,String(o),m(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,n=new WeakMap)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;let r=n.get(e);if(r?.has(t))return!0;if(r||(r=new WeakSet,n.set(e,r)),r.add(t),Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!g(e[r],t[r],n))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const o=Reflect.ownKeys(e),i=Reflect.ownKeys(t);if(o.length!==i.length)return!1;for(const s of o){if(!Reflect.has(t,s))return!1;const r=e[s],o=t[s];if(!g(r,o,n))return!1}return!0},b=(e,t)=>{e.active&&(e.deepCompare&&("set"===t.type||"array-replace"===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:a}=n[o++],c=r.get(e);c&&c.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type||"array-replace"===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 l=s.get(e);if(l)for(let t=l.length-1;t>=0;t--){const e=l[t],r=e.parentRef.deref();if(!r){l.splice(t,1);continue}if(a.has(r))continue;const o=new Set(a);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.isObject(n)&&!p(n)&&a(r,String(t+o),m(n))}R(r,{type:"array-push",index:t,values:n})}else if("pop"===t)c(r,String(o-1)),R(r,{type:"array-splice",index:o-1,deleteCount:1,insert:[]});else if(l(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=w(r,e).apply(r,t);return l(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=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 j={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=m(s),t=i.get(o)?.get(r);return t!==e&&a(o,r,e),e}return s},set(t,n,r,i){const s=Reflect.get(t,n,i),l=f(r);if(Object.is(s,l))return!0;const u=Reflect.set(t,n,l,i);return!!u&&(e.isObject(l)&&!p(l)?a(i,n,m(l)):c(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(l)?R(i,{type:"array-replace",key:n,oldValue:s,newValue:l}):R(i,{type:"set",key:n,newValue:l,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&&(c(i,t),0===(o.get(i)||0)&&R(i,{type:"delete",key:t,oldValue:r}))}return i}};function m(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,j);return n.set(e,o),o}exports.isProxy=y,exports.observe=function(t,n,o={}){const{throttle:i=0,onBatch:s,immediate:a=!1,deepCompare:c}=o,l={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 a=0;a<e.length;a++){const t=e[a];"*"===t&&"*"===e[a+1]?(n+="**",a++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let a=0;a<r.length;a++){const e=r[a];"**"===e?1===r.length?o.push(".*"):0===a?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let a=0;a<o.length;a++)if(i+=o[a],a<o.length-1){const e=o[a],t=o[a+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:c},u=m(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(l),a){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e.isObject(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(a=>{const c=Reflect.get(t,a);if(e.isObject(c)&&s.has(c))return;const l=Reflect.get(o,a),f=[...i,a];n.forEach(e=>{d(f,e.filterRegexes)&&b(e,{type:"set",key:a,newValue:c,oldValue:void 0,path:f})}),e.isObject(c)&&!p(c)&&r(c,l,f,s)}))};r(f(t),u)}const g=()=>{const e=r.get(u);e&&(e.delete(l),0===e.size&&r.delete(u)),l.pending=[],l.timer&&(clearTimeout(l.timer),l.timer=null)};return{proxy:u,unobserve:()=>{l.active&&(l.active=!1,g())},resume:()=>{l.active||(l.active=!0,(()=>{let e=r.get(u);e||(e=new Set,r.set(u,e)),e.add(l)})())},dispose:()=>{if(!l.active)return l.callback=()=>{},void(l.onBatch=void 0);l.active=!1,g(),l.callback=()=>{},l.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
|
|
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 a(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 c(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(r)&&!p(r)&&a(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,n=new WeakMap)=>{if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;let r=n.get(e);if(r?.has(t))return!0;if(r||(r=new WeakSet,n.set(e,r)),r.add(t),Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!R(e[r],t[r],n))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const o=Reflect.ownKeys(e),i=Reflect.ownKeys(t);if(o.length!==i.length)return!1;for(const s of o){if(!Reflect.has(t,s))return!1;const r=e[s],o=t[s];if(!R(r,o,n))return!1}return!0},b=(e,t)=>{e.active&&(e.deepCompare&&("set"===t.type||"array-replace"===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:a}=n[o++],l=r.get(e);l&&l.forEach(e=>{if(!e.active)return;let n=i;if("set"===t.type||"delete"===t.type||"array-replace"===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(a.has(r))continue;const o=new Set(a);o.add(r),n.push({node:r,relativePath:[e.key,...i],visited:o})}}},w={},v=(e,t)=>e[t];["push","pop","shift","unshift","splice"].forEach(t=>{w[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=v(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)&&a(r,String(t+o),A(n))}m(r,{type:"array-push",index:t,values:n})}else if("pop"===t)l(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=>{w[e]=function(...t){const n=this,r=f(n),i=o.get(n)||0;o.set(n,i+1);try{const o=v(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=>{w[e]=function(t,...n){const r=f(this),o=v(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(w,r))return Reflect.get(w,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&&a(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)?a(i,n,A(c)):l(i,n),0===(o.get(i)||0)&&(!Array.isArray(t)&&Array.isArray(s)&&Array.isArray(c)?m(i,{type:"array-replace",key:n,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&&(l(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:a=!1,deepCompare:l}=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 a=0;a<e.length;a++){const t=e[a];"*"===t&&"*"===e[a+1]?(n+="**",a++):"*"===t?n+="*":"."===t?n+=".":/[.*+?^${}()|[\]\\]/.test(t)?n+="\\"+t:n+=t}const r=n.split("."),o=[];for(let a=0;a<r.length;a++){const e=r[a];"**"===e?1===r.length?o.push(".*"):0===a?o.push("(?:[^.]+\\.)*"):o.push("(?:\\.[^.]+)*"):"*"===e?o.push("[^.]+"):o.push(e)}let i="^";for(let a=0;a<o.length;a++)if(i+=o[a],a<o.length-1){const e=o[a],t=o[a+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:l},u=A(t);let y=r.get(u);if(y||(y=new Set,r.set(u,y)),y.add(c),a){const n=[...y],r=(t,o,i=[],s=new WeakSet)=>{e(t)&&!s.has(t)&&(s.add(t),Reflect.ownKeys(t).forEach(a=>{const l=Reflect.get(t,a);if(e(l)&&s.has(l))return;const c=Reflect.get(o,a),f=[...i,a];n.forEach(e=>{g(f,e.filterRegexes)&&b(e,{type:"set",key:a,newValue:l,oldValue:void 0,path:f})}),e(l)&&!p(l)&&r(l,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";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",shy:"",zwj:"",zwnj:"",hellip:"…",middot:"·",bull:"•",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",laquo:"«",raquo:"»",lsaquo:"‹",rsaquo:"›",dagger:"†",Dagger:"‡",prime:"′",Prime:"″",permil:"‰",cent:"¢",pound:"£",yen:"¥",euro:"€",curren:"¤",copy:"©",reg:"®",trade:"™",deg:"°",plusmn:"±",times:"×",divide:"÷",frac12:"½",frac14:"¼",frac34:"¾",sup1:"¹",sup2:"²",sup3:"³",micro:"µ",para:"¶",sect:"§",iexcl:"¡",iquest:"¿",minus:"−",le:"≤",ge:"≥",ne:"≠",asymp:"≈",equiv:"≡",infin:"∞",sum:"∑",radic:"√",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔"},r={128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376},t=/&(?:#([xX][0-9a-fA-F]+|\d+)|([a-zA-Z0-9]+));/g;exports.default=function(s){return s&&"string"==typeof s&&s.includes("&")?s.replace(t,(t,s,o)=>{if(o){if(Object.prototype.hasOwnProperty.call(e,o))return e[o];const r=o.toLowerCase();return Object.prototype.hasOwnProperty.call(e,r)?e[r]:t}if(s){const e="x"===s[0]||"X"===s[0];let o=parseInt(e?s.slice(1):s,e?16:10);return isNaN(o)?t:(o>=128&&o<=159&&(o=r[o]||o),0===o||o>=55296&&o<=57343||o>1114111?"�":String.fromCodePoint(o))}return t}):s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const r={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",shy:"",zwj:"",zwnj:"",hellip:"…",middot:"·",bull:"•",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",laquo:"«",raquo:"»",lsaquo:"‹",rsaquo:"›",dagger:"†",Dagger:"‡",prime:"′",Prime:"″",permil:"‰",cent:"¢",pound:"£",yen:"¥",euro:"€",curren:"¤",copy:"©",reg:"®",trade:"™",deg:"°",plusmn:"±",times:"×",divide:"÷",frac12:"½",frac14:"¼",frac34:"¾",sup1:"¹",sup2:"²",sup3:"³",micro:"µ",para:"¶",sect:"§",iexcl:"¡",iquest:"¿",minus:"−",le:"≤",ge:"≥",ne:"≠",asymp:"≈",equiv:"≡",infin:"∞",sum:"∑",radic:"√",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔"},e={128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376},t=/&(?:#([xX][0-9a-fA-F]+|\d+)|([a-zA-Z0-9]+));/g;function a(a){return a&&"string"==typeof a&&a.includes("&")?a.replace(t,(t,a,s)=>{if(s){if(Object.prototype.hasOwnProperty.call(r,s))return r[s];const e=s.toLowerCase();return Object.prototype.hasOwnProperty.call(r,e)?r[e]:t}if(a){const r="x"===a[0]||"X"===a[0];let s=parseInt(r?a.slice(1):a,r?16:10);return isNaN(s)?t:(s>=128&&s<=159&&(s=e[s]||s),0===s||s>=55296&&s<=57343||s>1114111?"�":String.fromCodePoint(s))}return t}):a}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
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
|
+
"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"]),c=new Set(["value","selectedIndex"]),h=new Set(["href","src","srcset","action","formaction","xlink:href","poster"]),l=new Set(["srcdoc"]),p=/^\s*(?:javascript|vbscript)\s*:|^\s*data:text\/html(?:[;,]|$)/i,d=new WeakMap;function f(e,t,n){if(!s.IS_DEV)return;let i=d.get(e);i||(i=new Set,d.set(e,i)),i.has(t)||(i.add(t),console.warn(n))}const u=new WeakMap;function m(e){let t=u.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},u.set(e,t)),t}function v(e,t){const s=t.a?.find(e=>"class"===e.k&&!e.d);s?.v&&e.setAttribute("class",s.v)}function y(e,t){if(!e.style)return;const s=t.a?.find(e=>"style"===e.k&&!e.d),n=s?S(s.v):{};for(const i in n){const t=n[i];i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t}}const g=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 S(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 k(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 N(e,t,s,n){const i=r[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||a.has(t))return void k(e,t,s);if(l.has(t)&&null!=s)return void function(e,t){f(e,`srcdoc:${String(t)}`,'[Solely] Blocked "srcdoc" binding (HTML injection risk). Use a sandboxed iframe with "src" instead.')}(e,s);if((h.has(t)||h.has(i))&&function(e){return"string"==typeof e&&p.test(e.replace(/\s+/g,""))}(s))return void function(e,t,s){f(e,`${t}:${String(s)}`,`[Solely] Blocked unsafe URL for "${t}": ${String(s).slice(0,80)}. Use a http(s)/relative URL instead.`)}(e,t,s);const o=e,c=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"!==c&&"TEXTAREA"!==c||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!r[t]?k(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 K{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=u.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=m(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let h;r.loops=s;let l,p=!1,d=!1;for(const f of t){const{k:t,f:u,d:m,v:v}=f;if(":class"===t){h=this.evalIR(u??-1,[s],f.__m),p=!0;continue}if(":style"===t){l=this.evalIR(u??-1,[s],f.__m),d=!0;continue}if("class"===t||"style"===t)continue;const y=t[0];if("@"===y){const s=t.slice(1),i=f.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],f.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("ref"===t&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=e;continue}const g=m?this.evalIR(u??-1,[s],f.__m):v??"";if(":"===y){const s=t.slice(1);"SELECT"===e.tagName&&c.has(s)?o.push(()=>N(e,s,g,a)):N(e,s,g,a)}else n||k(e,t,String(g))}return p&&((e,t)=>{const s=m(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 c in i)g(c)&&(o[c]=i[c]);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 c in n)o[c]||a.push(c);for(const c in o)n[c]||r.push(c);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,h),d&&((e,t)=>{const s=m(e),n=S(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);v(e,t),y(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),v(a,t),y(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 c=this.isKaRestoring;this.isKaRestoring=!0;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."),e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=h,this.isKaRestoring=c}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);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.");const h=t+".0";if(this.prevNodeMap.get(h))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=c}}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=K,exports.createRender=(e,t,s={})=>{const n=new K(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};
|
|
@@ -1 +1 @@
|
|
|
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};
|
|
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"]),c=new Set(["value","selectedIndex"]),h=new Set(["href","src","srcset","action","formaction","xlink:href","poster"]),l=new Set(["srcdoc"]),p=/^\s*(?:javascript|vbscript)\s*:|^\s*data:text\/html(?:[;,]|$)/i,d=new WeakMap;function f(e,t,n){if(!s)return;let i=d.get(e);i||(i=new Set,d.set(e,i)),i.has(t)||(i.add(t),console.warn(n))}const u=new WeakMap;function m(e){let t=u.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},u.set(e,t)),t}function v(e,t){const s=t.a?.find(e=>"class"===e.k&&!e.d);s?.v&&e.setAttribute("class",s.v)}function y(e,t){if(!e.style)return;const s=t.a?.find(e=>"style"===e.k&&!e.d),n=s?k(s.v):{};for(const i in n){const t=n[i];i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t}}const g=e=>!(!e||0===e.length||/\s/.test(e)&&(s&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function k(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 N(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 K(e,t,s,n){const i=r[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||a.has(t))return void N(e,t,s);if(l.has(t)&&null!=s)return void function(e,t){f(e,`srcdoc:${String(t)}`,'[Solely] Blocked "srcdoc" binding (HTML injection risk). Use a sandboxed iframe with "src" instead.')}(e,s);if((h.has(t)||h.has(i))&&function(e){return"string"==typeof e&&p.test(e.replace(/\s+/g,""))}(s))return void function(e,t,s){f(e,`${t}:${String(s)}`,`[Solely] Blocked unsafe URL for "${t}": ${String(s).slice(0,80)}. Use a http(s)/relative URL instead.`)}(e,t,s);const o=e,c=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"!==c&&"TEXTAREA"!==c||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!r[t]?N(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 S{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=u.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=m(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let h;r.loops=s;let l,p=!1,d=!1;for(const f of t){const{k:t,f:u,d:m,v:v}=f;if(":class"===t){h=this.evalIR(u??-1,[s],f.__m),p=!0;continue}if(":style"===t){l=this.evalIR(u??-1,[s],f.__m),d=!0;continue}if("class"===t||"style"===t)continue;const y=t[0];if("@"===y){const s=t.slice(1),i=f.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],f.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("ref"===t&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=e;continue}const g=m?this.evalIR(u??-1,[s],f.__m):v??"";if(":"===y){const s=t.slice(1);"SELECT"===e.tagName&&c.has(s)?o.push(()=>K(e,s,g,a)):K(e,s,g,a)}else n||N(e,t,String(g))}return p&&((e,t)=>{const s=m(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 c in i)g(c)&&(o[c]=i[c]);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 c in n)o[c]||a.push(c);for(const c in o)n[c]||r.push(c);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,h),d&&((e,t)=>{const s=m(e),n=k(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.Element:{const e=this.createElement(t,s);v(e,t),y(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),v(a,t),y(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 c=this.isKaRestoring;this.isKaRestoring=!0;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."),e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=h,this.isKaRestoring=c}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);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.");const h=t+".0";if(this.prevNodeMap.get(h))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=c}}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 b=(e,t,s={})=>{const n=new S(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};export{S as IRRenderer,b as createRender};
|
package/dist/shared/env.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(()=>{if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(()=>{const e=globalThis;if(!0===e.__IS_PROD__)return!1;if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;if(!0===e.__DEBUG__||!0===e.__IS_DEV__)return!0}const o=e.process?.env?.NODE_ENV;return"production"!==o&&("development"===o||!("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.7.0";
|
package/dist/shared/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=(()=>{if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;
|
|
1
|
+
const n=(()=>{const n=globalThis;if(!0===n.__IS_PROD__)return!1;if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;if(!0===n.__DEBUG__||!0===n.__IS_DEV__)return!0}const o=n.process?.env?.NODE_ENV;return"production"!==o&&("development"===o||!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes(window.location?.hostname||"")))})(),o=!n,e="0.7.0";export{n as IS_DEV,o as IS_PROD,e as SOLELY_VERSION};
|
|
@@ -1 +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"]),
|
|
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"]),i=["to","values","from","by"],a=/@import|expression\s*\(|(?:^|[;{\s])behavior\s*:|-moz-binding/i,f=/\/\*[\s\S]*?\*\//g;function l(e){return a.test(e.replace(f,""))}const c=new Map;function m(e){const t=e.replace(/[\s-]+/g,"");return n.test(t)||o.test(t)}function u(e){const t=(e.getAttribute("attributeName")||"").toLowerCase();return!!t&&(!!t.startsWith("on")||!!s.has(t)&&i.some(t=>{const r=e.getAttribute(t);return null!==r&&m(r)}))}function g(e){for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();t.has(e)?r.has(e)&&u(n)||"style"===e&&l(n.textContent||"")?n.remove():g(n):n.remove()}for(const t of Array.from(e.attributes)){const r=t.name.toLowerCase();(r.startsWith("on")||s.has(r)&&m(t.value))&&e.removeAttribute(t.name)}}exports.sanitizeSvg=function(t){if(!t)return"";if("undefined"==typeof DOMParser)return"";const r=c.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 g(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?(g(s),s.innerHTML):""}(t);if(c.size>=500){const e=c.size-500+1,t=c.keys();for(let r=0;r<e;r++){const e=t.next().value;if(void 0===e)break;c.delete(e)}}return c.set(t,n),n};
|
|
@@ -1 +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,
|
|
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,s=new Set(["href","xlink:href","src","action","formaction"]),i=["to","values","from","by"],a=/@import|expression\s*\(|(?:^|[;{\s])behavior\s*:|-moz-binding/i,f=/\/\*[\s\S]*?\*\//g;function l(e){return a.test(e.replace(f,""))}const m=new Map;function c(e){const t=e.replace(/[\s-]+/g,"");return n.test(t)||o.test(t)}function u(e){const t=(e.getAttribute("attributeName")||"").toLowerCase();return!!t&&(!!t.startsWith("on")||!!s.has(t)&&i.some(t=>{const r=e.getAttribute(t);return null!==r&&c(r)}))}function g(t){if(!t)return"";if("undefined"==typeof DOMParser)return"";const r=m.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 p(n.documentElement),n.documentElement.innerHTML;e&&console.warn("[Solely Icon] SVG XML 解析失败,回退 HTML 容错解析");const o=(new DOMParser).parseFromString(r,"text/html"),s=o.body?.firstElementChild;return s?(p(s),s.innerHTML):""}(t);if(m.size>=500){const e=m.size-500+1,t=m.keys();for(let r=0;r<e;r++){const e=t.next().value;if(void 0===e)break;m.delete(e)}}return m.set(t,n),n}function p(e){for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();t.has(e)?r.has(e)&&u(n)||"style"===e&&l(n.textContent||"")?n.remove():p(n):n.remove()}for(const t of Array.from(e.attributes)){const r=t.name.toLowerCase();(r.startsWith("on")||s.has(r)&&c(t.value))&&e.removeAttribute(t.name)}}export{g as sanitizeSvg};
|
package/dist/types/ir.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solely",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": [
|
|
@@ -212,6 +212,7 @@
|
|
|
212
212
|
"link": "npm link && echo '✅ 全局链接成功,可在其他项目中使用 npm link solely'",
|
|
213
213
|
"unlink": "npm unlink -g solely && echo '✅ 已取消全局链接'",
|
|
214
214
|
"test": "vitest",
|
|
215
|
+
"test:run": "vitest run",
|
|
215
216
|
"test:ui": "vitest --ui",
|
|
216
217
|
"test:coverage": "vitest --coverage",
|
|
217
218
|
"typecheck": "tsc --noEmit",
|
|
@@ -221,8 +222,10 @@
|
|
|
221
222
|
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,json,md}\"",
|
|
222
223
|
"clean": "rimraf dist",
|
|
223
224
|
"prebuild": "npm run clean",
|
|
224
|
-
"
|
|
225
|
-
"
|
|
225
|
+
"check:exports": "node scripts/check-exports.mjs",
|
|
226
|
+
"verify": "npm run typecheck && npm run lint && npm run format:check && npm run test:run && npm run build && npm run check:exports",
|
|
227
|
+
"prepublishOnly": "npm run build && npm run test:run && npm run check:exports",
|
|
228
|
+
"pack:local": "npm run build && npm run check:exports && npm pack && echo '✅ 打包完成,可在其他项目中使用 file: 引用'",
|
|
226
229
|
"dev:debug": "node --inspect-brk ./node_modules/vite/bin/vite.js",
|
|
227
230
|
"prepare": "husky"
|
|
228
231
|
},
|