solely 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -27
- 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.d.ts +30 -0
- package/dist/router/core.js +1 -1
- package/dist/router/router-view.cjs +1 -1
- package/dist/router/router-view.d.ts +10 -0
- package/dist/router/router-view.js +1 -1
- package/dist/router/types.d.ts +3 -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
|
@@ -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.1";
|
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.1";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.1",
|
|
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
|
},
|