solely 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/event-listeners.cjs"),e=require("../../types/ast.cjs"),n=require("../../types/lifecycle.cjs"),c=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function s(o,s){var i;const l=(null==(i=(o.match(c)||[])[1])?void 0:i.toLowerCase())??"",f=function(e,c){const o=[];let s;const i=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.default.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=n.mapAttrKeyToLifecycleKind(f)||f;const u=s[0],a=u.indexOf("=");let d;if(-1===a)d=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let e=t+1;for(;e<u.length&&/\s/.test(u[e]);)e++;d=e}else{let e=t;for(;e<u.length&&/\s/.test(u[e]);)e++;d=e}}const p=s.index+d+l,y=e.slice(0,p).split("\n"),m=c[0]+y.length-1,g=y.length>1?y[y.length-1].length+1:c[1]+p;o.push({key:f,value:i,loc:[m,g]})}return o}(o,s);return{type:{for:e.ASTType.For,if:e.ASTType.If,elseif:e.ASTType.ElseIf,else:e.ASTType.Else}[l]??e.ASTType.Element,tag:l,loc:s,children:[],attrs:f}}function i(t,e){const n=t.length;if(t.startsWith("!--",e)){const n=t.indexOf("--\x3e",e+3);return-1===n?-1:n+2}if(t.startsWith("![CDATA[",e)){const n=t.indexOf("]]>",e+8);return-1===n?-1:n+2}if("!"===t[e])return t.indexOf(">",e+1);if("?"===t[e]){const n=t.indexOf("?>",e+1);return-1===n?-1:n+1}let c=!1,o=!1,r=e;for(;r<n;){const e=t[r];if("'"!==e||o)if('"'!==e||c){if(">"===e&&!c&&!o)return r}else o=!o;else c=!c;r++}return-1}exports.parseHtml=function(t){const n=[];if(!t)return[];const c=[],r=[],l=()=>{var t;return 0===c.length?n:(t=c[c.length-1]).children||(t.children=[])};let f=0;const u=t.length,a=[0];for(let e=0;e<u;e++)"\n"===t[e]&&a.push(e+1);function d(t){let e=0;for(let n=1;n<a.length&&!(a[n]>t);n++)e=n;return[e+1,t-a[e]+1]}for(;f<u;){const n=t.indexOf("<",f);if(-1===n||n>f){const c=t.substring(f,-1===n?void 0:n),o=c.trim();if(o){const t=d(f+c.indexOf(o));l().push({type:e.ASTType.Text,tag:"text",content:o,loc:t,children:[]})}if(-1===n)break;f=n}const a=i(t,f+1);if(-1===a){const n=t.substring(f);n.trim()&&l().push({type:e.ASTType.Text,tag:"text",content:n.trim(),children:[],loc:d(f)});break}const p=t.substring(f,a+1),y=l(),m=d(f);if(p.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:p.slice(4,-3),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("<![CDATA[")){y.push({type:e.ASTType.Text,tag:"text",content:p.slice(9,-3),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("<!")&&!p.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:p.slice(2,-1),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("<?")){y.push({type:e.ASTType.Comment,tag:"comment",content:p.slice(2,-2),loc:m,children:[]}),f=a+1;continue}if(p.startsWith("</")){const t=r.pop();for(;c.length>0;){if((c[c.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){c.pop();break}c.pop()}f=a+1;continue}const g=s(p,m);y.push(g);const h=g.tag||"",x=h.toLowerCase().startsWith("script"),b=h.toLowerCase().startsWith("style"),v=p.endsWith("/>")||o.has(h.toLowerCase());if((x||b)&&!v){const n=`</${h}>`,c=t.toLowerCase().indexOf(n,a+1);if(-1!==c){const o=t.substring(a+1,c);o.length&&g.children.push({type:e.ASTType.Text,tag:"text",content:o,loc:d(a+1),children:[]}),f=c+n.length;continue}{const n=t.substring(a+1);n.length&&g.children.push({type:e.ASTType.Text,tag:"text",content:n,loc:d(a+1),children:[]}),f=u;continue}}v||g.type===e.ASTType.Text||g.type===e.ASTType.Comment||(c.push(g),r.push(h)),f=a+1}return n};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../shared/event-listeners.cjs"),e=require("../../types/ast.cjs"),n=require("../../types/lifecycle.cjs"),c=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,o=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function s(o,s){var i;const l=(null==(i=(o.match(c)||[])[1])?void 0:i.toLowerCase())??"",f=function(e,c){const o=[];let s;const i=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.default.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=n.mapAttrKeyToLifecycleKind(f)||f;const u=s[0],a=u.indexOf("=");let p;if(-1===a)p=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let e=t+1;for(;e<u.length&&/\s/.test(u[e]);)e++;p=e}else{let e=t;for(;e<u.length&&/\s/.test(u[e]);)e++;p=e}}const d=s.index+p+l,y=e.slice(0,d).split("\n"),m=c[0]+y.length-1,g=y.length>1?y[y.length-1].length+1:c[1]+d;o.push({key:f,value:i,loc:[m,g]})}return o}(o,s);return{type:{for:e.ASTType.For,if:e.ASTType.If,elseif:e.ASTType.ElseIf,else:e.ASTType.Else}[l]??e.ASTType.Element,tag:l,loc:s,children:[],attrs:f}}function i(t,e){const n=t.length;if(t.startsWith("!--",e)){const n=t.indexOf("--\x3e",e+3);return-1===n?-1:n+2}if(t.startsWith("![CDATA[",e)){const n=t.indexOf("]]>",e+8);return-1===n?-1:n+2}if("!"===t[e])return t.indexOf(">",e+1);if("?"===t[e]){const n=t.indexOf("?>",e+1);return-1===n?-1:n+1}let c=!1,o=!1,r=e;for(;r<n;){const e=t[r];if("'"!==e||o)if('"'!==e||c){if(">"===e&&!c&&!o)return r}else o=!o;else c=!c;r++}return-1}exports.parseHtml=function(t){const n=[];if(!t)return[];const c=[],r=[],l=()=>{var t;return 0===c.length?n:(t=c[c.length-1]).children||(t.children=[])};let f=0;const u=t.length,a=[0];for(let e=0;e<u;e++)"\n"===t[e]&&a.push(e+1);function p(t){let e=0;for(let n=1;n<a.length&&!(a[n]>t);n++)e=n;return[e+1,t-a[e]+1]}for(;f<u;){const n=t.indexOf("<",f);if(-1===n||n>f){const o=t.substring(f,-1===n?void 0:n),r=c.length>0?c[c.length-1]:null;let s,i;if(!r||"pre"!==r.tag&&"code"!==r.tag&&"textarea"!==r.tag&&"script"!==r.tag&&"style"!==r.tag){if(s=o.trim(),""===s){if(f=n,-1===n)break;continue}i=f+(o.length-o.trimStart().length)}else s=o,i=f;const u=l(),a=u[u.length-1];if(a&&a.type===e.ASTType.Text)a.content+=s;else{const t=p(i);u.push({type:e.ASTType.Text,tag:"text",content:s,loc:t,children:[]})}if(-1===n)break;f=n}const a=i(t,f+1);if(-1===a){const n=t.substring(f);n.trim()&&l().push({type:e.ASTType.Text,tag:"text",content:n.trim(),children:[],loc:p(f)});break}const d=t.substring(f,a+1),y=l(),m=p(f);if(d.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:d.slice(4,-3),loc:m,children:[]}),f=a+1;continue}if(d.startsWith("<![CDATA[")){y.push({type:e.ASTType.Text,tag:"text",content:d.slice(9,-3),loc:m,children:[]}),f=a+1;continue}if(d.startsWith("<!")&&!d.startsWith("\x3c!--")){y.push({type:e.ASTType.Comment,tag:"comment",content:d.slice(2,-1),loc:m,children:[]}),f=a+1;continue}if(d.startsWith("<?")){y.push({type:e.ASTType.Comment,tag:"comment",content:d.slice(2,-2),loc:m,children:[]}),f=a+1;continue}if(d.startsWith("</")){const t=r.pop();for(;c.length>0;){if((c[c.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){c.pop();break}c.pop()}f=a+1;continue}const g=s(d,m);y.push(g);const h=g.tag||"",x=h.toLowerCase().startsWith("script"),b=h.toLowerCase().startsWith("style"),v=d.endsWith("/>")||o.has(h.toLowerCase());if((x||b)&&!v){const n=`</${h}>`,c=t.toLowerCase().indexOf(n,a+1);if(-1!==c){const o=t.substring(a+1,c);o.length&&g.children.push({type:e.ASTType.Text,tag:"text",content:o,loc:p(a+1),children:[]}),f=c+n.length;continue}{const n=t.substring(a+1);n.length&&g.children.push({type:e.ASTType.Text,tag:"text",content:n,loc:p(a+1),children:[]}),f=u;continue}}v||g.type===e.ASTType.Text||g.type===e.ASTType.Comment||(c.push(g),r.push(h)),f=a+1}return n};
@@ -1 +1 @@
1
- import t from"../../shared/event-listeners.js";import{ASTType as n}from"../../types/ast.js";import{mapAttrKeyToLifecycleKind as e}from"../../types/lifecycle.js";const o=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,c=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function s(c,s){var i;const l=(null==(i=(c.match(o)||[])[1])?void 0:i.toLowerCase())??"",f=function(n,o){const c=[];let s;const i=n.replace(/^\s*[^\s"'/>]+/,""),l=n.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=e(f)||f;const u=s[0],a=u.indexOf("=");let p;if(-1===a)p=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let n=t+1;for(;n<u.length&&/\s/.test(u[n]);)n++;p=n}else{let n=t;for(;n<u.length&&/\s/.test(u[n]);)n++;p=n}}const m=s.index+p+l,d=n.slice(0,m).split("\n"),y=o[0]+d.length-1,g=d.length>1?d[d.length-1].length+1:o[1]+m;c.push({key:f,value:i,loc:[y,g]})}return c}(c,s);return{type:{for:n.For,if:n.If,elseif:n.ElseIf,else:n.Else}[l]??n.Element,tag:l,loc:s,children:[],attrs:f}}function i(t,n){const e=t.length;if(t.startsWith("!--",n)){const e=t.indexOf("--\x3e",n+3);return-1===e?-1:e+2}if(t.startsWith("![CDATA[",n)){const e=t.indexOf("]]>",n+8);return-1===e?-1:e+2}if("!"===t[n])return t.indexOf(">",n+1);if("?"===t[n]){const e=t.indexOf("?>",n+1);return-1===e?-1:e+1}let o=!1,c=!1,r=n;for(;r<e;){const n=t[r];if("'"!==n||c)if('"'!==n||o){if(">"===n&&!o&&!c)return r}else c=!c;else o=!o;r++}return-1}function l(t){const e=[];if(!t)return[];const o=[],r=[],l=()=>{var t;return 0===o.length?e:(t=o[o.length-1]).children||(t.children=[])};let f=0;const u=t.length,a=[0];for(let n=0;n<u;n++)"\n"===t[n]&&a.push(n+1);function p(t){let n=0;for(let e=1;e<a.length&&!(a[e]>t);e++)n=e;return[n+1,t-a[n]+1]}for(;f<u;){const e=t.indexOf("<",f);if(-1===e||e>f){const o=t.substring(f,-1===e?void 0:e),c=o.trim();if(c){const t=p(f+o.indexOf(c));l().push({type:n.Text,tag:"text",content:c,loc:t,children:[]})}if(-1===e)break;f=e}const a=i(t,f+1);if(-1===a){const e=t.substring(f);e.trim()&&l().push({type:n.Text,tag:"text",content:e.trim(),children:[],loc:p(f)});break}const m=t.substring(f,a+1),d=l(),y=p(f);if(m.startsWith("\x3c!--")){d.push({type:n.Comment,tag:"comment",content:m.slice(4,-3),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<![CDATA[")){d.push({type:n.Text,tag:"text",content:m.slice(9,-3),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<!")&&!m.startsWith("\x3c!--")){d.push({type:n.Comment,tag:"comment",content:m.slice(2,-1),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<?")){d.push({type:n.Comment,tag:"comment",content:m.slice(2,-2),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("</")){const t=r.pop();for(;o.length>0;){if((o[o.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){o.pop();break}o.pop()}f=a+1;continue}const g=s(m,y);d.push(g);const h=g.tag||"",x=h.toLowerCase().startsWith("script"),b=h.toLowerCase().startsWith("style"),v=m.endsWith("/>")||c.has(h.toLowerCase());if((x||b)&&!v){const e=`</${h}>`,o=t.toLowerCase().indexOf(e,a+1);if(-1!==o){const c=t.substring(a+1,o);c.length&&g.children.push({type:n.Text,tag:"text",content:c,loc:p(a+1),children:[]}),f=o+e.length;continue}{const e=t.substring(a+1);e.length&&g.children.push({type:n.Text,tag:"text",content:e,loc:p(a+1),children:[]}),f=u;continue}}v||g.type===n.Text||g.type===n.Comment||(o.push(g),r.push(h)),f=a+1}return e}export{l as parseHtml};
1
+ import t from"../../shared/event-listeners.js";import{ASTType as e}from"../../types/ast.js";import{mapAttrKeyToLifecycleKind as n}from"../../types/lifecycle.js";const o=/<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/,c=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),r=/\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;function s(c,s){var i;const l=(null==(i=(c.match(o)||[])[1])?void 0:i.toLowerCase())??"",f=function(e,o){const c=[];let s;const i=e.replace(/^\s*[^\s"'/>]+/,""),l=e.length-i.length;for(;null!==(s=r.exec(i));){const r=s[1];if(!r)continue;const i=s[2]??s[3]??s[4]??"";let f=r;t.has(r)&&(f=f.replace(/^on/,"@")),"s-model"!==f&&(f=f.replace(/^on-/,"@").replace(/^s-/,":")),f=n(f)||f;const u=s[0],a=u.indexOf("=");let p;if(-1===a)p=u.indexOf(r)+r.length;else{let t=a+1;for(;t<u.length&&/\s/.test(u[t]);)t++;if('"'===u[t]||"'"===u[t]){let e=t+1;for(;e<u.length&&/\s/.test(u[e]);)e++;p=e}else{let e=t;for(;e<u.length&&/\s/.test(u[e]);)e++;p=e}}const m=s.index+p+l,d=e.slice(0,m).split("\n"),y=o[0]+d.length-1,g=d.length>1?d[d.length-1].length+1:o[1]+m;c.push({key:f,value:i,loc:[y,g]})}return c}(c,s);return{type:{for:e.For,if:e.If,elseif:e.ElseIf,else:e.Else}[l]??e.Element,tag:l,loc:s,children:[],attrs:f}}function i(t,e){const n=t.length;if(t.startsWith("!--",e)){const n=t.indexOf("--\x3e",e+3);return-1===n?-1:n+2}if(t.startsWith("![CDATA[",e)){const n=t.indexOf("]]>",e+8);return-1===n?-1:n+2}if("!"===t[e])return t.indexOf(">",e+1);if("?"===t[e]){const n=t.indexOf("?>",e+1);return-1===n?-1:n+1}let o=!1,c=!1,r=e;for(;r<n;){const e=t[r];if("'"!==e||c)if('"'!==e||o){if(">"===e&&!o&&!c)return r}else c=!c;else o=!o;r++}return-1}function l(t){const n=[];if(!t)return[];const o=[],r=[],l=()=>{var t;return 0===o.length?n:(t=o[o.length-1]).children||(t.children=[])};let f=0;const u=t.length,a=[0];for(let e=0;e<u;e++)"\n"===t[e]&&a.push(e+1);function p(t){let e=0;for(let n=1;n<a.length&&!(a[n]>t);n++)e=n;return[e+1,t-a[e]+1]}for(;f<u;){const n=t.indexOf("<",f);if(-1===n||n>f){const c=t.substring(f,-1===n?void 0:n),r=o.length>0?o[o.length-1]:null;let s,i;if(!r||"pre"!==r.tag&&"code"!==r.tag&&"textarea"!==r.tag&&"script"!==r.tag&&"style"!==r.tag){if(s=c.trim(),""===s){if(f=n,-1===n)break;continue}i=f+(c.length-c.trimStart().length)}else s=c,i=f;const u=l(),a=u[u.length-1];if(a&&a.type===e.Text)a.content+=s;else{const t=p(i);u.push({type:e.Text,tag:"text",content:s,loc:t,children:[]})}if(-1===n)break;f=n}const a=i(t,f+1);if(-1===a){const n=t.substring(f);n.trim()&&l().push({type:e.Text,tag:"text",content:n.trim(),children:[],loc:p(f)});break}const m=t.substring(f,a+1),d=l(),y=p(f);if(m.startsWith("\x3c!--")){d.push({type:e.Comment,tag:"comment",content:m.slice(4,-3),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<![CDATA[")){d.push({type:e.Text,tag:"text",content:m.slice(9,-3),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<!")&&!m.startsWith("\x3c!--")){d.push({type:e.Comment,tag:"comment",content:m.slice(2,-1),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("<?")){d.push({type:e.Comment,tag:"comment",content:m.slice(2,-2),loc:y,children:[]}),f=a+1;continue}if(m.startsWith("</")){const t=r.pop();for(;o.length>0;){if((o[o.length-1].tag||"").toLowerCase()===(null==t?void 0:t.toLowerCase())){o.pop();break}o.pop()}f=a+1;continue}const g=s(m,y);d.push(g);const h=g.tag||"",x=h.toLowerCase().startsWith("script"),b=h.toLowerCase().startsWith("style"),k=m.endsWith("/>")||c.has(h.toLowerCase());if((x||b)&&!k){const n=`</${h}>`,o=t.toLowerCase().indexOf(n,a+1);if(-1!==o){const c=t.substring(a+1,o);c.length&&g.children.push({type:e.Text,tag:"text",content:c,loc:p(a+1),children:[]}),f=o+n.length;continue}{const n=t.substring(a+1);n.length&&g.children.push({type:e.Text,tag:"text",content:n,loc:p(a+1),children:[]}),f=u;continue}}k||g.type===e.Text||g.type===e.Comment||(o.push(g),r.push(h)),f=a+1}return n}export{l as parseHtml};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/index.cjs"),r=require("./shared/templateError.cjs"),s=require("./shared/gen-function.cjs"),t=require("./shared/functions.cjs"),o=require("./shared/event-listeners.cjs"),i=require("./shared/is-object.cjs"),u=require("./shared/url.cjs"),p=require("./shared/env.cjs"),c=require("./types/ast.cjs"),x=require("./types/lifecycle.cjs"),n=require("./router/router-view.cjs"),j=require("./router/router-link.cjs"),q=require("./runtime/component/base-element.cjs"),a=require("./compiler/ir/buildIR.cjs"),l=require("./compiler/parser/parser.cjs"),d=require("./router/core.cjs"),m=require("./runtime/reactivity/observe.cjs"),b=require("./runtime/component/decorators.cjs"),h=require("./runtime/renderer/renderIR.cjs");exports.createRouter=e.createRouter,exports.showTemplateError=r.showTemplateError,exports.genFunction=s.genFunction,exports.createFunction=t.createFunction,exports.listeners=o.default,exports.isObject=i.isObject,exports.parseHashUrl=u.parseHashUrl,exports.IS_DEV=p.IS_DEV,exports.IS_PROD=p.IS_PROD,exports.ASTType=c.ASTType,exports.LIFECYCLE_ATTRS_MAP=x.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=x.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=x.mapAttrKeyToLifecycleKind,Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>n.default}),Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>j.default}),exports.BaseElement=q.default,exports.buildIR=a.buildIR,exports.clearIRCache=a.clearIRCache,exports.transformModel=a.transformModel,exports.parseHtml=l.parseHtml,exports.Router=d.Router,exports.getRouter=d.getRouter,exports.routerReady=d.routerReady,exports.isProxy=m.isProxy,exports.observe=m.observe,exports.toRaw=m.toRaw,exports.CustomElement=b.CustomElement,exports.IRRenderer=h.IRRenderer,exports.createRender=h.createRender;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./router/index.cjs"),r=require("./shared/templateError.cjs"),s=require("./shared/gen-function.cjs"),t=require("./shared/functions.cjs"),o=require("./shared/event-listeners.cjs"),i=require("./shared/is-object.cjs"),u=require("./shared/url.cjs"),p=require("./shared/env.cjs"),c=require("./types/ast.cjs"),x=require("./types/lifecycle.cjs"),n=require("./router/router-view.cjs"),j=require("./router/router-link.cjs"),q=require("./runtime/component/base-element.cjs"),a=require("./runtime/renderer/html-decode.cjs"),d=require("./compiler/ir/buildIR.cjs"),l=require("./compiler/parser/parser.cjs"),m=require("./router/core.cjs"),b=require("./runtime/reactivity/observe.cjs"),h=require("./runtime/component/decorators.cjs"),v=require("./runtime/renderer/renderIR.cjs");exports.createRouter=e.createRouter,exports.showTemplateError=r.showTemplateError,exports.genFunction=s.genFunction,exports.createFunction=t.createFunction,exports.listeners=o.default,exports.isObject=i.isObject,exports.parseHashUrl=u.parseHashUrl,exports.IS_DEV=p.IS_DEV,exports.IS_PROD=p.IS_PROD,exports.ASTType=c.ASTType,exports.LIFECYCLE_ATTRS_MAP=x.LIFECYCLE_ATTRS_MAP,exports.isLifecycleKind=x.isLifecycleKind,exports.mapAttrKeyToLifecycleKind=x.mapAttrKeyToLifecycleKind,Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>n.default}),Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>j.default}),exports.BaseElement=q.default,exports.htmlDecode=a.default,exports.buildIR=d.buildIR,exports.clearIRCache=d.clearIRCache,exports.transformModel=d.transformModel,exports.parseHtml=l.parseHtml,exports.Router=m.Router,exports.getRouter=m.getRouter,exports.routerReady=m.routerReady,exports.isProxy=b.isProxy,exports.observe=b.observe,exports.toRaw=b.toRaw,exports.CustomElement=h.CustomElement,exports.IRRenderer=v.IRRenderer,exports.createRender=v.createRender;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{createRouter as r}from"./router/index.js";import{showTemplateError as e}from"./shared/templateError.js";import{genFunction as o}from"./shared/gen-function.js";import{createFunction as t}from"./shared/functions.js";import{default as m}from"./shared/event-listeners.js";import{isObject as s}from"./shared/is-object.js";import{parseHashUrl as i}from"./shared/url.js";import{IS_DEV as p,IS_PROD as a}from"./shared/env.js";import{ASTType as f}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as n,isLifecycleKind as j,mapAttrKeyToLifecycleKind as u}from"./types/lifecycle.js";import{default as d}from"./router/router-view.js";import{default as l}from"./router/router-link.js";import{default as c}from"./runtime/component/base-element.js";import{buildIR as h,clearIRCache as v,transformModel as b}from"./compiler/ir/buildIR.js";import{parseHtml as y}from"./compiler/parser/parser.js";import{Router as R,getRouter as k,routerReady as w}from"./router/core.js";import{isProxy as x,observe as E,toRaw as I}from"./runtime/reactivity/observe.js";import{CustomElement as g}from"./runtime/component/decorators.js";import{IRRenderer as B,createRender as L}from"./runtime/renderer/renderIR.js";export{f as ASTType,c as BaseElement,g as CustomElement,B as IRRenderer,p as IS_DEV,a as IS_PROD,n as LIFECYCLE_ATTRS_MAP,R as Router,l as RouterLink,d as RouterView,h as buildIR,v as clearIRCache,t as createFunction,L as createRender,r as createRouter,o as genFunction,k as getRouter,j as isLifecycleKind,s as isObject,x as isProxy,m as listeners,u as mapAttrKeyToLifecycleKind,E as observe,i as parseHashUrl,y as parseHtml,w as routerReady,e as showTemplateError,I as toRaw,b as transformModel};
1
+ import{createRouter as r}from"./router/index.js";import{showTemplateError as e}from"./shared/templateError.js";import{genFunction as o}from"./shared/gen-function.js";import{createFunction as t}from"./shared/functions.js";import{default as m}from"./shared/event-listeners.js";import{isObject as s}from"./shared/is-object.js";import{parseHashUrl as i}from"./shared/url.js";import{IS_DEV as a,IS_PROD as p}from"./shared/env.js";import{ASTType as f}from"./types/ast.js";import{LIFECYCLE_ATTRS_MAP as n,isLifecycleKind as u,mapAttrKeyToLifecycleKind as d}from"./types/lifecycle.js";import{default as j}from"./router/router-view.js";import{default as l}from"./router/router-link.js";import{default as c}from"./runtime/component/base-element.js";import{default as h}from"./runtime/renderer/html-decode.js";import{buildIR as v,clearIRCache as b,transformModel as y}from"./compiler/ir/buildIR.js";import{parseHtml as R}from"./compiler/parser/parser.js";import{Router as k,getRouter as w,routerReady as x}from"./router/core.js";import{isProxy as E,observe as I,toRaw as g}from"./runtime/reactivity/observe.js";import{CustomElement as B}from"./runtime/component/decorators.js";import{IRRenderer as D,createRender as L}from"./runtime/renderer/renderIR.js";export{f as ASTType,c as BaseElement,B as CustomElement,D as IRRenderer,a as IS_DEV,p as IS_PROD,n as LIFECYCLE_ATTRS_MAP,k as Router,l as RouterLink,j as RouterView,v as buildIR,b as clearIRCache,t as createFunction,L as createRender,r as createRouter,o as genFunction,w as getRouter,h as htmlDecode,u as isLifecycleKind,s as isObject,E as isProxy,m as listeners,d as mapAttrKeyToLifecycleKind,I as observe,i as parseHashUrl,R as parseHtml,x as routerReady,e as showTemplateError,g as toRaw,y as transformModel};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,s=(s,e,r)=>((s,e,r)=>e in s?t(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r)(s,"symbol"!=typeof e?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let e,r=null;const i=new Promise(t=>{e=t});class n{constructor(t){s(this,"routes"),s(this,"base"),s(this,"mode"),s(this,"beforeEachGuard"),s(this,"afterEachGuard"),s(this,"currentRoute",null),s(this,"listeners",new Set),s(this,"componentCache",new Map),s(this,"loadingComponents",new Set),s(this,"isStarted",!1),this.routes=t.routes,this.base=t.base??"/",this.mode=t.mode||"history",this.beforeEachGuard=t.beforeEach,this.afterEachGuard=t.afterEach}matchRoute(t="/"){const s=t.startsWith("/")?t:"/"+t,[e,r]=s.split("?"),i=e.split("/").filter(Boolean),n=this.parseQuery(r),h=this.recursiveMatch(this.routes,i);if(h){const t=h.matched[h.matched.length-1];return t.config.redirect?this.matchRoute(t.config.redirect):{matched:h.matched,params:h.params,query:n,fullPath:s,meta:h.matched.reduce((t,s)=>({...t,...s.config.meta||{}}),{})}}return null}recursiveMatch(t,s){const e=[...t].sort((t,s)=>this.calculateScore(s.path)-this.calculateScore(t.path));for(const r of e){const t=r.path.split("/").filter(Boolean),e={};let i=!0;if(0===t.length&&0===s.length)return{matched:[{config:r,params:{}}],params:{}};for(let r=0;r<t.length;r++){const n=t[r],h=s[r];if(n.startsWith(":")){if(!h){i=!1;break}e[n.slice(1)]=h}else{if("*"===n){i=!0;break}if(n!==h){i=!1;break}}}if(i){const i=t.length,n=s.slice(i),h={config:r,params:e};if(n.length>0&&r.children){const t=this.recursiveMatch(r.children,n);if(t)return{matched:[h,...t.matched],params:{...e,...t.params}}}else if(0===n.length||t.includes("*"))return{matched:[h],params:e}}}return null}calculateScore(t="/"){const s=t.split("/").filter(Boolean);return 0===s.length?1:s.reduce((t,s)=>s.startsWith(":")?t+5:"*"===s?t+0:t+10,0)}parseQuery(t){const s={};return t?(new URLSearchParams(t).forEach((t,e)=>{s[e]=t}),s):s}normalizePath(t="/"){let s=t&&"string"==typeof t?t:"/";return s.startsWith("/")||(s="/"+s),s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),s}getPath(){let t;try{t="hash"===this.mode?window.location.hash.slice(1)||"/":window.location.pathname||"/"}catch{t="/"}const s=this.base||"/";return"/"!==s&&t.startsWith(s)&&(t=t.slice(s.length)||"/"),this.normalizePath(t)}updateBrowserHistory(t="/",s){const e=this.normalizePath(t),r=this.base||"/";if("hash"===this.mode)s?window.location.replace(`#${e}`):window.location.hash=e;else{const t=r.endsWith("/")?r.slice(0,-1):r,i="/"===t?e:t+e;s?window.history.replaceState({path:i},"",i):window.history.pushState({path:i},"",i)}}async navigate(t="/",s=!1,e=!1){const r=this.normalizePath(t),i=this.currentRoute,n=this.matchRoute(r);if(!n)return{success:!1,error:`No route matched: ${r}`};if(i&&i.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const t=await this.beforeEachGuard(n,i);if(!1===t)return{success:!1,cancelled:!0};if("string"==typeof t)return this.navigate(t,s)}catch(h){return{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return this.currentRoute=n,e||this.updateBrowserHistory(r,s),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,i),{success:!0}}resolve(t="/"){const s=this.normalizePath(t);if("hash"===this.mode)return`#${s}`;const e=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===e?s:e+s}get modeType(){return this.mode}pushWithQuery(t="/",s){const e=new URLSearchParams(s).toString(),r=t.includes("?")?"&":"?";return this.push(t+(e?r+e:""))}push(t="/"){return this.navigate(t,!1)}replace(t="/"){return this.navigate(t,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}setupListeners(){this.isStarted||(window.addEventListener("popstate",()=>{this.navigate(this.getPath(),!0,!0)}),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}getCurrentRoute(){return this.currentRoute}prefetch(t){const s=this.matchRoute(t);if(!s)return;const e=s.matched[s.matched.length-1];if(!(null==e?void 0:e.config.component))return;const r=e.config.component;"function"==typeof r&&(this.loadingComponents.has(t)||this.componentCache.has(t)||(this.loadingComponents.add(t),r().then(s=>{this.componentCache.set(t,Promise.resolve(s))}).catch(()=>{}).finally(()=>{this.loadingComponents.delete(t)})))}getComponentFromCache(t){return this.componentCache.get(t)}}exports.Router=n,exports.createRouter=function(t){return r||(r=new n(t),e(r),r)},exports.getRouter=function(){return r},exports.routerReady=i;
1
+ "use strict";var t=Object.defineProperty,s=(s,e,r)=>((s,e,r)=>e in s?t(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r)(s,"symbol"!=typeof e?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let e,r=null;const i=new Promise(t=>{e=t});class n{constructor(t){s(this,"routes"),s(this,"base"),s(this,"mode"),s(this,"beforeEachGuard"),s(this,"afterEachGuard"),s(this,"currentRoute",null),s(this,"listeners",new Set),s(this,"componentCache",new Map),s(this,"loadingComponents",new Set),s(this,"isStarted",!1),this.routes=t.routes,this.base=t.base??"/",this.mode=t.mode||"history",this.beforeEachGuard=t.beforeEach,this.afterEachGuard=t.afterEach}matchRoute(t="/"){const s=t.startsWith("/")?t:"/"+t,[e,r]=s.split("?"),i=e.split("/").filter(Boolean),n=this.parseQuery(r),h=this.recursiveMatch(this.routes,i);if(h){const t=h.matched[h.matched.length-1];return t.config.redirect?this.matchRoute(t.config.redirect):{matched:h.matched,params:h.params,query:n,fullPath:s,meta:h.matched.reduce((t,s)=>({...t,...s.config.meta||{}}),{})}}return null}recursiveMatch(t,s){const e=[...t].sort((t,s)=>this.calculateScore(s.path)-this.calculateScore(t.path));for(const r of e){const t=r.path.split("/").filter(Boolean),e={};let i=!0;if(0===t.length&&0===s.length)return{matched:[{config:r,params:{}}],params:{}};for(let r=0;r<t.length;r++){const n=t[r],h=s[r];if(n.startsWith(":")){if(!h){i=!1;break}e[n.slice(1)]=h}else{if("*"===n){i=!0;break}if(n!==h){i=!1;break}}}if(i){const i=t.length,n=s.slice(i),h={config:r,params:e};if(n.length>0&&r.children){const t=this.recursiveMatch(r.children,n);if(t)return{matched:[h,...t.matched],params:{...e,...t.params}}}else if(0===n.length||t.includes("*"))return{matched:[h],params:e}}}return null}calculateScore(t="/"){const s=t.split("/").filter(Boolean);return 0===s.length?1:s.reduce((t,s)=>s.startsWith(":")?t+5:"*"===s?t+0:t+10,0)}parseQuery(t){const s={};return t?(new URLSearchParams(t).forEach((t,e)=>{s[e]=t}),s):s}normalizePath(t="/"){let s=t&&"string"==typeof t?t:"/";return s.startsWith("/")||(s="/"+s),s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),s}getPath(){let t;try{t="hash"===this.mode?window.location.hash.slice(1)||"/":window.location.pathname||"/"}catch{t="/"}const s=this.base||"/";return"/"!==s&&t.startsWith(s)&&(t=t.slice(s.length)||"/"),this.normalizePath(t)}updateBrowserHistory(t="/",s){const e=this.normalizePath(t),r=this.base||"/";if("hash"===this.mode)s?window.location.replace(`#${e}`):window.location.hash=e;else{const t=r.endsWith("/")?r.slice(0,-1):r,i="/"===t?e:t+e;s?window.history.replaceState({path:i},"",i):window.history.pushState({path:i},"",i)}}async navigate(t="/",s=!1,e=!1){const r=this.normalizePath(t),i=this.currentRoute,n=this.matchRoute(r);if(!n)return{success:!1,error:`No route matched: ${r}`};if(i&&i.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const t=await this.beforeEachGuard(n,i);if(!1===t)return{success:!1,cancelled:!0};if("string"==typeof t)return this.navigate(t,s)}catch(h){return{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return this.currentRoute=n,e||this.updateBrowserHistory(r,s),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,i),{success:!0}}resolve(t="/"){const s=this.normalizePath(t);if("hash"===this.mode)return`#${s}`;const e=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===e?s:e+s}get modeType(){return this.mode}pushWithQuery(t="/",s){const e=new URLSearchParams(s).toString(),r=t.includes("?")?"&":"?";return this.push(t+(e?r+e:""))}push(t="/"){return this.navigate(t,!1)}replace(t="/"){return this.navigate(t,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}setupListeners(){if(this.isStarted)return;this.isStarted=!0;const t=()=>{this.navigate(this.getPath(),!0,!0)};"hash"===this.mode?window.addEventListener("hashchange",t):window.addEventListener("popstate",t),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0)}getCurrentRoute(){return this.currentRoute}prefetch(t){const s=this.matchRoute(t);if(!s)return;const e=s.matched[s.matched.length-1];if(!(null==e?void 0:e.config.component))return;const r=e.config.component;"function"==typeof r&&(this.loadingComponents.has(t)||this.componentCache.has(t)||(this.loadingComponents.add(t),r().then(s=>{this.componentCache.set(t,Promise.resolve(s))}).catch(()=>{}).finally(()=>{this.loadingComponents.delete(t)})))}getComponentFromCache(t){return this.componentCache.get(t)}}exports.Router=n,exports.createRouter=function(t){return r||(r=new n(t),e(r),r)},exports.getRouter=function(){return r},exports.routerReady=i;
@@ -1 +1 @@
1
- var t=Object.defineProperty,s=(s,e,r)=>((s,e,r)=>e in s?t(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r)(s,"symbol"!=typeof e?e+"":e,r);let e,r=null;const i=new Promise(t=>{e=t});function n(t){return r||(r=new o(t),e(r),r)}function h(){return r}class o{constructor(t){s(this,"routes"),s(this,"base"),s(this,"mode"),s(this,"beforeEachGuard"),s(this,"afterEachGuard"),s(this,"currentRoute",null),s(this,"listeners",new Set),s(this,"componentCache",new Map),s(this,"loadingComponents",new Set),s(this,"isStarted",!1),this.routes=t.routes,this.base=t.base??"/",this.mode=t.mode||"history",this.beforeEachGuard=t.beforeEach,this.afterEachGuard=t.afterEach}matchRoute(t="/"){const s=t.startsWith("/")?t:"/"+t,[e,r]=s.split("?"),i=e.split("/").filter(Boolean),n=this.parseQuery(r),h=this.recursiveMatch(this.routes,i);if(h){const t=h.matched[h.matched.length-1];return t.config.redirect?this.matchRoute(t.config.redirect):{matched:h.matched,params:h.params,query:n,fullPath:s,meta:h.matched.reduce((t,s)=>({...t,...s.config.meta||{}}),{})}}return null}recursiveMatch(t,s){const e=[...t].sort((t,s)=>this.calculateScore(s.path)-this.calculateScore(t.path));for(const r of e){const t=r.path.split("/").filter(Boolean),e={};let i=!0;if(0===t.length&&0===s.length)return{matched:[{config:r,params:{}}],params:{}};for(let r=0;r<t.length;r++){const n=t[r],h=s[r];if(n.startsWith(":")){if(!h){i=!1;break}e[n.slice(1)]=h}else{if("*"===n){i=!0;break}if(n!==h){i=!1;break}}}if(i){const i=t.length,n=s.slice(i),h={config:r,params:e};if(n.length>0&&r.children){const t=this.recursiveMatch(r.children,n);if(t)return{matched:[h,...t.matched],params:{...e,...t.params}}}else if(0===n.length||t.includes("*"))return{matched:[h],params:e}}}return null}calculateScore(t="/"){const s=t.split("/").filter(Boolean);return 0===s.length?1:s.reduce((t,s)=>s.startsWith(":")?t+5:"*"===s?t+0:t+10,0)}parseQuery(t){const s={};return t?(new URLSearchParams(t).forEach((t,e)=>{s[e]=t}),s):s}normalizePath(t="/"){let s=t&&"string"==typeof t?t:"/";return s.startsWith("/")||(s="/"+s),s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),s}getPath(){let t;try{t="hash"===this.mode?window.location.hash.slice(1)||"/":window.location.pathname||"/"}catch{t="/"}const s=this.base||"/";return"/"!==s&&t.startsWith(s)&&(t=t.slice(s.length)||"/"),this.normalizePath(t)}updateBrowserHistory(t="/",s){const e=this.normalizePath(t),r=this.base||"/";if("hash"===this.mode)s?window.location.replace(`#${e}`):window.location.hash=e;else{const t=r.endsWith("/")?r.slice(0,-1):r,i="/"===t?e:t+e;s?window.history.replaceState({path:i},"",i):window.history.pushState({path:i},"",i)}}async navigate(t="/",s=!1,e=!1){const r=this.normalizePath(t),i=this.currentRoute,n=this.matchRoute(r);if(!n)return{success:!1,error:`No route matched: ${r}`};if(i&&i.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const t=await this.beforeEachGuard(n,i);if(!1===t)return{success:!1,cancelled:!0};if("string"==typeof t)return this.navigate(t,s)}catch(h){return{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return this.currentRoute=n,e||this.updateBrowserHistory(r,s),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,i),{success:!0}}resolve(t="/"){const s=this.normalizePath(t);if("hash"===this.mode)return`#${s}`;const e=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===e?s:e+s}get modeType(){return this.mode}pushWithQuery(t="/",s){const e=new URLSearchParams(s).toString(),r=t.includes("?")?"&":"?";return this.push(t+(e?r+e:""))}push(t="/"){return this.navigate(t,!1)}replace(t="/"){return this.navigate(t,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}setupListeners(){this.isStarted||(window.addEventListener("popstate",()=>{this.navigate(this.getPath(),!0,!0)}),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0))}getCurrentRoute(){return this.currentRoute}prefetch(t){const s=this.matchRoute(t);if(!s)return;const e=s.matched[s.matched.length-1];if(!(null==e?void 0:e.config.component))return;const r=e.config.component;"function"==typeof r&&(this.loadingComponents.has(t)||this.componentCache.has(t)||(this.loadingComponents.add(t),r().then(s=>{this.componentCache.set(t,Promise.resolve(s))}).catch(()=>{}).finally(()=>{this.loadingComponents.delete(t)})))}getComponentFromCache(t){return this.componentCache.get(t)}}export{o as Router,n as createRouter,h as getRouter,i as routerReady};
1
+ var t=Object.defineProperty,s=(s,e,r)=>((s,e,r)=>e in s?t(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r)(s,"symbol"!=typeof e?e+"":e,r);let e,r=null;const i=new Promise(t=>{e=t});function n(t){return r||(r=new o(t),e(r),r)}function h(){return r}class o{constructor(t){s(this,"routes"),s(this,"base"),s(this,"mode"),s(this,"beforeEachGuard"),s(this,"afterEachGuard"),s(this,"currentRoute",null),s(this,"listeners",new Set),s(this,"componentCache",new Map),s(this,"loadingComponents",new Set),s(this,"isStarted",!1),this.routes=t.routes,this.base=t.base??"/",this.mode=t.mode||"history",this.beforeEachGuard=t.beforeEach,this.afterEachGuard=t.afterEach}matchRoute(t="/"){const s=t.startsWith("/")?t:"/"+t,[e,r]=s.split("?"),i=e.split("/").filter(Boolean),n=this.parseQuery(r),h=this.recursiveMatch(this.routes,i);if(h){const t=h.matched[h.matched.length-1];return t.config.redirect?this.matchRoute(t.config.redirect):{matched:h.matched,params:h.params,query:n,fullPath:s,meta:h.matched.reduce((t,s)=>({...t,...s.config.meta||{}}),{})}}return null}recursiveMatch(t,s){const e=[...t].sort((t,s)=>this.calculateScore(s.path)-this.calculateScore(t.path));for(const r of e){const t=r.path.split("/").filter(Boolean),e={};let i=!0;if(0===t.length&&0===s.length)return{matched:[{config:r,params:{}}],params:{}};for(let r=0;r<t.length;r++){const n=t[r],h=s[r];if(n.startsWith(":")){if(!h){i=!1;break}e[n.slice(1)]=h}else{if("*"===n){i=!0;break}if(n!==h){i=!1;break}}}if(i){const i=t.length,n=s.slice(i),h={config:r,params:e};if(n.length>0&&r.children){const t=this.recursiveMatch(r.children,n);if(t)return{matched:[h,...t.matched],params:{...e,...t.params}}}else if(0===n.length||t.includes("*"))return{matched:[h],params:e}}}return null}calculateScore(t="/"){const s=t.split("/").filter(Boolean);return 0===s.length?1:s.reduce((t,s)=>s.startsWith(":")?t+5:"*"===s?t+0:t+10,0)}parseQuery(t){const s={};return t?(new URLSearchParams(t).forEach((t,e)=>{s[e]=t}),s):s}normalizePath(t="/"){let s=t&&"string"==typeof t?t:"/";return s.startsWith("/")||(s="/"+s),s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),s}getPath(){let t;try{t="hash"===this.mode?window.location.hash.slice(1)||"/":window.location.pathname||"/"}catch{t="/"}const s=this.base||"/";return"/"!==s&&t.startsWith(s)&&(t=t.slice(s.length)||"/"),this.normalizePath(t)}updateBrowserHistory(t="/",s){const e=this.normalizePath(t),r=this.base||"/";if("hash"===this.mode)s?window.location.replace(`#${e}`):window.location.hash=e;else{const t=r.endsWith("/")?r.slice(0,-1):r,i="/"===t?e:t+e;s?window.history.replaceState({path:i},"",i):window.history.pushState({path:i},"",i)}}async navigate(t="/",s=!1,e=!1){const r=this.normalizePath(t),i=this.currentRoute,n=this.matchRoute(r);if(!n)return{success:!1,error:`No route matched: ${r}`};if(i&&i.fullPath===n.fullPath)return{success:!0};if(this.beforeEachGuard)try{const t=await this.beforeEachGuard(n,i);if(!1===t)return{success:!1,cancelled:!0};if("string"==typeof t)return this.navigate(t,s)}catch(h){return{success:!1,error:h instanceof Error?h.message:"Guard Error"}}return this.currentRoute=n,e||this.updateBrowserHistory(r,s),this.notifyListeners(),this.afterEachGuard&&this.afterEachGuard(n,i),{success:!0}}resolve(t="/"){const s=this.normalizePath(t);if("hash"===this.mode)return`#${s}`;const e=this.base.endsWith("/")?this.base.slice(0,-1):this.base;return"/"===e?s:e+s}get modeType(){return this.mode}pushWithQuery(t="/",s){const e=new URLSearchParams(s).toString(),r=t.includes("?")?"&":"?";return this.push(t+(e?r+e:""))}push(t="/"){return this.navigate(t,!1)}replace(t="/"){return this.navigate(t,!0)}back(){window.history.back()}forward(){window.history.forward()}listen(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}setupListeners(){if(this.isStarted)return;this.isStarted=!0;const t=()=>{this.navigate(this.getPath(),!0,!0)};"hash"===this.mode?window.addEventListener("hashchange",t):window.addEventListener("popstate",t),"hash"!==this.mode||window.location.hash||(window.location.hash="/"),this.navigate(this.getPath(),!0)}getCurrentRoute(){return this.currentRoute}prefetch(t){const s=this.matchRoute(t);if(!s)return;const e=s.matched[s.matched.length-1];if(!(null==e?void 0:e.config.component))return;const r=e.config.component;"function"==typeof r&&(this.loadingComponents.has(t)||this.componentCache.has(t)||(this.loadingComponents.add(t),r().then(s=>{this.componentCache.set(t,Promise.resolve(s))}).catch(()=>{}).finally(()=>{this.loadingComponents.delete(t)})))}getComponentFromCache(t){return this.componentCache.get(t)}}export{o as Router,n as createRouter,h as getRouter,i as routerReady};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./core.cjs"),e=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const r=new Map;exports.default=class extends e.default{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s.routerReady,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){if(!this.router)return;const t=this.router;this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof exports.default&&t++,i=i.parentElement;this.level=t}async loadRoute(t){var i,s;this.abortController&&(this.abortController.abort(),this.abortController=null);const e=++this.latestLoadId,n=null==t?void 0:t.matched[this.level];if(!n)return void this.handleEmptyRoute();const{config:r}=n;let o=r.tagName;if(!o&&"function"==typeof r.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const n=this.abortController.signal;try{let h;const l=null==(s=null==(i=this.router)?void 0:i.getComponentFromCache)?void 0:s.call(i,null==t?void 0:t.fullPath);if(h=l?await l:await r.component(),n.aborted||e!==this.latestLoadId)return;o="string"==typeof h?h:h.tagName}catch(l){if(n.aborted||e!==this.latestLoadId)return;return this.renderError(`Load Error: ${l}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!n.aborted&&(this.abortController=null)}}if(e!==this.latestLoadId)return;if(!o)return void this.clear();if(!r.forceReload&&this.currentElement&&this.currentTagName===o.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},r.props);this.clear();const h=this.getOrCreateComponent(o,r);this.syncState(h,null==t?void 0:t.params,(null==t?void 0:t.query)||{},r.props),this.appendChild(h),this.currentElement=h,this.currentTagName=o.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s)){const t=r.get(s);if(t)return t}const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const o=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{o.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=o}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}},exports.default=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n.CustomElement({tagName:"router-view"})],exports.default);
1
+ "use strict";var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./core.cjs"),e=require("../runtime/component/base-element.cjs"),n=require("../runtime/component/decorators.cjs");Object.getOwnPropertyDescriptor;const o=new Map;exports.default=class extends e.default{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s.routerReady,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){if(!this.router)return;const t=this.router;this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;){const s=i.closest("router-view");if(s){if(t++,i=s.parentElement,!i){const t=s.getRootNode();i=t instanceof ShadowRoot?t.host:null}}else{const t=i.getRootNode();i=t instanceof ShadowRoot?t.host:null}}this.level=t}async loadRoute(t){var i,s;this.abortController&&(this.abortController.abort(),this.abortController=null);const e=++this.latestLoadId,n=null==t?void 0:t.matched[this.level];if(!n)return void this.handleEmptyRoute();const{config:o}=n;let r=o.tagName;if(!r&&"function"==typeof o.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const n=this.abortController.signal;try{let h;const l=null==(s=null==(i=this.router)?void 0:i.getComponentFromCache)?void 0:s.call(i,null==t?void 0:t.fullPath);if(h=l?await l:await o.component(),n.aborted||e!==this.latestLoadId)return;r="string"==typeof h?h:h.tagName}catch(l){if(n.aborted||e!==this.latestLoadId)return;return this.renderError(`Load Error: ${l}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!n.aborted&&(this.abortController=null)}}if(e!==this.latestLoadId)return;if(!r)return void this.clear();if(!o.forceReload&&this.currentElement&&this.currentTagName===r.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},o.props);this.clear();const h=this.getOrCreateComponent(r,o);this.syncState(h,null==t?void 0:t.params,(null==t?void 0:t.query)||{},o.props),this.appendChild(h),this.currentElement=h,this.currentTagName=r.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&o.has(s)){const t=o.get(s);if(t)return t}const e=document.createElement(t);return i.keepAlive&&o.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=new Map;Object.entries(i).forEach(([t,i])=>o.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>o.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{o.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),o.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const r=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{r.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=r}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}},exports.default=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n.CustomElement({tagName:"router-view"})],exports.default);
@@ -1 +1 @@
1
- var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);import{routerReady as s}from"./core.js";import e from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const r=new Map;let o=class extends e{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){if(!this.router)return;const t=this.router;this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;)i instanceof o&&t++,i=i.parentElement;this.level=t}async loadRoute(t){var i,s;this.abortController&&(this.abortController.abort(),this.abortController=null);const e=++this.latestLoadId,n=null==t?void 0:t.matched[this.level];if(!n)return void this.handleEmptyRoute();const{config:r}=n;let o=r.tagName;if(!o&&"function"==typeof r.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const n=this.abortController.signal;try{let h;const l=null==(s=null==(i=this.router)?void 0:i.getComponentFromCache)?void 0:s.call(i,null==t?void 0:t.fullPath);if(h=l?await l:await r.component(),n.aborted||e!==this.latestLoadId)return;o="string"==typeof h?h:h.tagName}catch(l){if(n.aborted||e!==this.latestLoadId)return;return this.renderError(`Load Error: ${l}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!n.aborted&&(this.abortController=null)}}if(e!==this.latestLoadId)return;if(!o)return void this.clear();if(!r.forceReload&&this.currentElement&&this.currentTagName===o.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},r.props);this.clear();const h=this.getOrCreateComponent(o,r);this.syncState(h,null==t?void 0:t.params,(null==t?void 0:t.query)||{},r.props),this.appendChild(h),this.currentElement=h,this.currentTagName=o.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&r.has(s)){const t=r.get(s);if(t)return t}const e=document.createElement(t);return i.keepAlive&&r.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=new Map;Object.entries(i).forEach(([t,i])=>r.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>r.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{r.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),r.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const o=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{o.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=o}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};o=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n({tagName:"router-view"})],o);export{o as default};
1
+ var t=Object.defineProperty,i=(i,s,e)=>((i,s,e)=>s in i?t(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e)(i,"symbol"!=typeof s?s+"":s,e);import{routerReady as s}from"./core.js";import e from"../runtime/component/base-element.js";import{CustomElement as n}from"../runtime/component/decorators.js";Object.getOwnPropertyDescriptor;const o=new Map;let r=class extends e{constructor(){super(...arguments),i(this,"unsubscribe"),i(this,"level",0),i(this,"currentElement",null),i(this,"currentTagName",null),i(this,"routerAttrs",new Set),i(this,"prevPropKeys",new Set),i(this,"scheduled",!1),i(this,"latestLoadId",0),i(this,"abortController",null),i(this,"router",null)}async mounted(){this.detectLevel(),this.router=await s,this.unsubscribe=this.router.listen(()=>{this.scheduleLoad()}),this.loadRoute(this.router.getCurrentRoute())}unmounted(){var t;null==(t=this.unsubscribe)||t.call(this)}scheduleLoad(){if(!this.router)return;const t=this.router;this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.loadRoute(t.getCurrentRoute())}))}detectLevel(){let t=0,i=this.parentElement;for(;i;){const s=i.closest("router-view");if(s){if(t++,i=s.parentElement,!i){const t=s.getRootNode();i=t instanceof ShadowRoot?t.host:null}}else{const t=i.getRootNode();i=t instanceof ShadowRoot?t.host:null}}this.level=t}async loadRoute(t){var i,s;this.abortController&&(this.abortController.abort(),this.abortController=null);const e=++this.latestLoadId,n=null==t?void 0:t.matched[this.level];if(!n)return void this.handleEmptyRoute();const{config:o}=n;let r=o.tagName;if(!r&&"function"==typeof o.component){this.clear(),this.renderLoading(),this.abortController=new AbortController;const n=this.abortController.signal;try{let h;const l=null==(s=null==(i=this.router)?void 0:i.getComponentFromCache)?void 0:s.call(i,null==t?void 0:t.fullPath);if(h=l?await l:await o.component(),n.aborted||e!==this.latestLoadId)return;r="string"==typeof h?h:h.tagName}catch(l){if(n.aborted||e!==this.latestLoadId)return;return this.renderError(`Load Error: ${l}`),this.currentElement=null,void(this.currentTagName=null)}finally{this.abortController&&!n.aborted&&(this.abortController=null)}}if(e!==this.latestLoadId)return;if(!r)return void this.clear();if(!o.forceReload&&this.currentElement&&this.currentTagName===r.toLowerCase())return void this.syncState(this.currentElement,null==t?void 0:t.params,(null==t?void 0:t.query)||{},o.props);this.clear();const h=this.getOrCreateComponent(r,o);this.syncState(h,null==t?void 0:t.params,(null==t?void 0:t.query)||{},o.props),this.appendChild(h),this.currentElement=h,this.currentTagName=r.toLowerCase()}getOrCreateComponent(t,i){const s=`${this.level}-${t.toLowerCase()}`;if(i.keepAlive&&o.has(s)){const t=o.get(s);if(t)return t}const e=document.createElement(t);return i.keepAlive&&o.set(s,e),e}syncState(t,i,s,e={}){const n=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=new Map;Object.entries(i).forEach(([t,i])=>o.set(n(t),String(i))),Object.entries(s).forEach(([t,i])=>o.set(`query-${n(t)}`,String(i))),this.routerAttrs.forEach(i=>{o.has(i)||(t.removeAttribute(i),this.routerAttrs.delete(i))}),o.forEach((i,s)=>{t.getAttribute(s)!==i&&t.setAttribute(s,i),this.routerAttrs.add(s)});const r=new Set(Object.keys(e));this.prevPropKeys.forEach(i=>{r.has(i)||(t[i]=void 0)}),Object.entries(e).forEach(([i,s])=>{t[i]!==s&&(t[i]=s)}),this.prevPropKeys=r}handleEmptyRoute(){this.clear(),0===this.level&&this.renderError("404 Not Found")}renderLoading(){this.textContent="";const t=document.createElement("div");t.style.cssText="padding:20px; color:#999;",t.textContent="Loading...",this.appendChild(t)}renderError(t){this.textContent="";const i=document.createElement("div");i.style.cssText="padding:20px; color:#ff4d4f;",i.textContent=String(t),this.appendChild(i)}clear(){this.currentElement&&this.contains(this.currentElement)&&this.removeChild(this.currentElement),this.innerHTML="",this.currentElement=null,this.currentTagName=null,this.routerAttrs.clear(),this.prevPropKeys.clear()}};r=((t,i)=>{for(var s,e=i,n=t.length-1;n>=0;n--)(s=t[n])&&(e=s(e)||e);return e})([n({tagName:"router-view"})],r);export{r as default};
@@ -1 +1 @@
1
- "use strict";var t,e,s,i,n,h,a,o,r,c,u,l,d,f,b,p,m,v,k,w,y,M,W=Object.defineProperty,$=t=>{throw TypeError(t)},g=(t,e,s)=>((t,e,s)=>e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),S=(t,e,s)=>e.has(t)||$("Cannot "+s),C=(t,e,s)=>(S(t,e,"read from private field"),s?s.call(t):e.get(t)),j=(t,e,s)=>e.has(t)?$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),A=(t,e,s,i)=>(S(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),q=(t,e,s)=>(S(t,e,"access private method"),s);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N=require("../../shared/is-object.cjs"),E=require("../../shared/env.cjs"),x=require("../reactivity/observe.cjs"),O=require("../renderer/renderIR.cjs"),R=Symbol.for("solely.manifest"),U=class extends HTMLElement{constructor(f={}){var p;super(),j(this,d),g(this,"$refs",{}),j(this,t),j(this,e),j(this,s),j(this,i),j(this,n),j(this,h),j(this,a,!1),j(this,o,!1),j(this,r,!1),j(this,c,!1),j(this,u,!1),j(this,l,!1);const v=this.constructor;A(this,t,v[R]||{tagName:"base-element"});const k=C(this,t);A(this,n,(null==(p=k.shadowDOM)?void 0:p.use)?this.attachShadow({mode:k.shadowDOM.mode||"open"}):this),q(this,d,b).call(this,f),q(this,d,m).call(this,k),queueMicrotask(()=>q(this,d,M).call(this))}static get observedAttributes(){const t=this[R];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var e;N.isObject(t)||(t={}),null==(e=C(this,h))||e.call(this),q(this,d,b).call(this,t),q(this,d,k).call(this)}refresh(){q(this,d,k).call(this)}connectedCallback(){var i;A(this,u,!0);const h=this.constructor.upgradeProps;let a;a=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],q(this,d,f).call(this,a),q(this,d,M).call(this);const o=C(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),q(this,d,y).call(this),o.propMap&&N.isObject(this.$data))for(const[t,e]of o.propMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=q(this,d,v).call(this,i,e.default,e.type);this.$data[s]=n}else"default"in e&&(this.$data[s]=e.default)}C(this,s)&&!C(this,e)&&A(this,e,O.createRender(C(this,s),C(this,n),this)),C(this,l)&&(A(this,l,!1),q(this,d,k).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){A(this,u,!1),this.unmounted()}attributeChangedCallback(e,s,i){var n;if(s===i||!N.isObject(this.$data))return;const h=null==(n=C(this,t).propMap)?void 0:n.get(e);if(!h)return;const a=h.name,o=this.$data[a],c=q(this,d,v).call(this,i,h.default??o,h.type);this.$data[a]=c,A(this,r,!0),this.attributeChanged(e,o,c)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,u=new WeakMap,l=new WeakMap,d=new WeakSet,f=function(t){for(const e of t)if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this[e]=t}},b=function(e){const{proxy:s,dispose:n}=x.observe(e,e=>{var s,i;if("set"===e.type){const{key:n,newValue:h}=e,a=C(this,t),o=String(n),r=(null==(s=a.propMap)?void 0:s.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=a.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&q(this,d,p).call(this,r,h)}this.emit("change",{source:"state",...e}),q(this,d,k).call(this)});A(this,i,s),A(this,h,n)},p=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},m=function(t){t.ir&&A(this,s,t.ir)},v=function(t,e,s){if(null===t)return"boolean"===s?e??!1:e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch{return e}default:return t}},k=function(){C(this,u)?!C(this,o)&&C(this,e)&&(A(this,o,!0),queueMicrotask(()=>{A(this,o,!1),q(this,d,w).call(this)})):A(this,l,!0)},w=function(){!C(this,a)&&C(this,u)&&(A(this,a,!0),C(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,e).update(),this.updated(),C(this,r)&&(this.afterAttributesUpdate(),A(this,r,!1)),A(this,a,!1))},y=function(){const e=C(this,t);if(!e.styles)return;const s=C(this,n);if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s)return void(s.adoptedStyleSheets.includes(e.sheet)||(s.adoptedStyleSheets=[...s.adoptedStyleSheets,e.sheet]));const i=s instanceof ShadowRoot?s:document.head,h=`solely-style-${e.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=e.styles,i.appendChild(t)}},M=function(){C(this,c)||(A(this,c,!0),this.created())},g(U,"upgradeProps"),(()=>{if(E.IS_DEV){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,n){if(U.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,n=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of n)t[e]!==U.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,n)}}})();let z=U;exports.default=z;
1
+ "use strict";var t,e,s,i,n,a,h,o,r,c,l,u,d,f,b,p,v,m,k,y,w,M,g=Object.defineProperty,S=t=>{throw TypeError(t)},$=(t,e,s)=>((t,e,s)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),W=(t,e,s)=>e.has(t)||S("Cannot "+s),C=(t,e,s)=>(W(t,e,"read from private field"),s?s.call(t):e.get(t)),j=(t,e,s)=>e.has(t)?S("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),A=(t,e,s,i)=>(W(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),N=(t,e,s)=>(W(t,e,"access private method"),s);Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("../../shared/is-object.cjs"),E=require("../../shared/env.cjs"),O=require("../reactivity/observe.cjs"),x=require("../renderer/renderIR.cjs"),J=Symbol.for("solely.manifest"),R=class extends HTMLElement{constructor(f={}){var p;super(),j(this,d),$(this,"$refs",{}),j(this,t),j(this,e),j(this,s),j(this,i),j(this,n),j(this,a),j(this,h,!1),j(this,o,!1),j(this,r,!1),j(this,c,!1),j(this,l,!1),j(this,u,!1);const m=this.constructor;A(this,t,m[J]||{tagName:"base-element"});const k=C(this,t);A(this,n,(null==(p=k.shadowDOM)?void 0:p.use)?this.attachShadow({mode:k.shadowDOM.mode||"open"}):this),N(this,d,b).call(this,f),N(this,d,v).call(this,k),queueMicrotask(()=>N(this,d,M).call(this))}static get observedAttributes(){const t=this[J];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var e;q.isObject(t)||(t={}),null==(e=C(this,a))||e.call(this),N(this,d,b).call(this,t),N(this,d,k).call(this)}refresh(){N(this,d,k).call(this)}connectedCallback(){var i;A(this,l,!0);const a=this.constructor.upgradeProps;let h;h=Array.isArray(a)?a.includes("$data")?a:[...a,"$data"]:["$data"],N(this,d,f).call(this,h),N(this,d,M).call(this);const o=C(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),N(this,d,w).call(this),o.propMap&&q.isObject(this.$data))for(const[t,e]of o.propMap){const s=e.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=N(this,d,m).call(this,i,e.default,e.type);this.$data[s]=n}else"default"in e&&(this.$data[s]=e.default)}C(this,s)&&!C(this,e)&&A(this,e,x.createRender(C(this,s),C(this,n),this)),C(this,u)&&(A(this,u,!1),N(this,d,k).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){A(this,l,!1),this.unmounted()}attributeChangedCallback(e,s,i){var n;if(s===i||!q.isObject(this.$data))return;const a=null==(n=C(this,t).propMap)?void 0:n.get(e);if(!a)return;const h=a.name,o=this.$data[h],c=N(this,d,m).call(this,i,a.default??o,a.type);this.$data[h]=c,A(this,r,!0),this.attributeChanged(e,o,c)}emit(t,e,s){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e,...s}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,e,s){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,e=new WeakMap,s=new WeakMap,i=new WeakMap,n=new WeakMap,a=new WeakMap,h=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakSet,f=function(t){for(const e of t)if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this[e]=t}},b=function(e){const{proxy:s,dispose:n}=O.observe(e,e=>{var s,i;if("set"===e.type){const{key:n,newValue:a}=e,h=C(this,t),o=String(n),r=(null==(s=h.propMap)?void 0:s.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=h.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&N(this,d,p).call(this,r,a)}this.emit("change",{source:"state",...e}),N(this,d,k).call(this)});A(this,i,s),A(this,a,n)},p=function(t,e){const s=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)e?this.setAttribute(s,""):this.removeAttribute(s);else{const t="object"==typeof e?JSON.stringify(e):String(e);this.setAttribute(s,t)}},v=function(t){t.ir&&A(this,s,t.ir)},m=function(t,e,s){if(null===t)return"boolean"===s?e??!1:e;switch(s){case"boolean":return!0;case"number":{const s=Number(t);return isNaN(s)?e:s}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),e}case"array":try{const s=t.replace(/'/g,'"'),i=JSON.parse(s);return Array.isArray(i)?i:e}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),e}default:return t}},k=function(){C(this,l)?!C(this,o)&&C(this,e)&&(A(this,o,!0),queueMicrotask(()=>{A(this,o,!1),N(this,d,y).call(this)})):A(this,u,!0)},y=function(){!C(this,h)&&C(this,l)&&(A(this,h,!0),C(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,e).update(),this.updated(),C(this,r)&&(this.afterAttributesUpdate(),A(this,r,!1)),A(this,h,!1))},w=function(){const e=C(this,t);if(!e.styles)return;const s=C(this,n);if(e.sheet&&s instanceof ShadowRoot&&"adoptedStyleSheets"in s)return void(s.adoptedStyleSheets.includes(e.sheet)||(s.adoptedStyleSheets=[...s.adoptedStyleSheets,e.sheet]));const i=s instanceof ShadowRoot?s:document.head,a=`solely-style-${e.tagName}`;if(!i.querySelector(`#${a}`)){const t=document.createElement("style");t.id=a,t.textContent=e.styles,i.appendChild(t)}},M=function(){C(this,c)||(A(this,c,!0),this.created())},$(R,"upgradeProps"),(()=>{if(E.IS_DEV){const t=customElements.define,e=new WeakSet;customElements.define=function(s,i,n){if(R.isPrototypeOf(i)&&!e.has(i)){e.add(i);const t=i.prototype,n=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const e of n)t[e]!==R.prototype[e]&&console.error(`[${s}] 禁止重写 ${e}(),请使用框架钩子`)}return t.call(this,s,i,n)}}})();let U=R;exports.default=U;
@@ -1 +1 @@
1
- var t,s,e,i,n,h,o,a,r,c,l,u,d,f,p,b,m,k,v,w,y,M,W=Object.defineProperty,$=t=>{throw TypeError(t)},g=(t,s,e)=>((t,s,e)=>s in t?W(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e)(t,"symbol"!=typeof s?s+"":s,e),C=(t,s,e)=>s.has(t)||$("Cannot "+e),S=(t,s,e)=>(C(t,s,"read from private field"),e?e.call(t):s.get(t)),j=(t,s,e)=>s.has(t)?$("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),A=(t,s,e,i)=>(C(t,s,"write to private field"),i?i.call(t,e):s.set(t,e),e),N=(t,s,e)=>(C(t,s,"access private method"),e);import{isObject as E}from"../../shared/is-object.js";import{IS_DEV as x}from"../../shared/env.js";import{observe as O}from"../reactivity/observe.js";import{createRender as R}from"../renderer/renderIR.js";const U=Symbol.for("solely.manifest"),q=class extends HTMLElement{constructor(f={}){var b;super(),j(this,d),g(this,"$refs",{}),j(this,t),j(this,s),j(this,e),j(this,i),j(this,n),j(this,h),j(this,o,!1),j(this,a,!1),j(this,r,!1),j(this,c,!1),j(this,l,!1),j(this,u,!1);const k=this.constructor;A(this,t,k[U]||{tagName:"base-element"});const v=S(this,t);A(this,n,(null==(b=v.shadowDOM)?void 0:b.use)?this.attachShadow({mode:v.shadowDOM.mode||"open"}):this),N(this,d,p).call(this,f),N(this,d,m).call(this,v),queueMicrotask(()=>N(this,d,M).call(this))}static get observedAttributes(){const t=this[U];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return S(this,i)}set $data(t){var s;E(t)||(t={}),null==(s=S(this,h))||s.call(this),N(this,d,p).call(this,t),N(this,d,v).call(this)}refresh(){N(this,d,v).call(this)}connectedCallback(){var i;A(this,l,!0);const h=this.constructor.upgradeProps;let o;o=Array.isArray(h)?h.includes("$data")?h:[...h,"$data"]:["$data"],N(this,d,f).call(this,o),N(this,d,M).call(this);const a=S(this,t);if((a.className||a.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),N(this,d,y).call(this),a.propMap&&E(this.$data))for(const[t,s]of a.propMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=N(this,d,k).call(this,i,s.default,s.type);this.$data[e]=n}else"default"in s&&(this.$data[e]=s.default)}S(this,e)&&!S(this,s)&&A(this,s,R(S(this,e),S(this,n),this)),S(this,u)&&(A(this,u,!1),N(this,d,v).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){A(this,l,!1),this.unmounted()}attributeChangedCallback(s,e,i){var n;if(e===i||!E(this.$data))return;const h=null==(n=S(this,t).propMap)?void 0:n.get(s);if(!h)return;const o=h.name,a=this.$data[o],c=N(this,d,k).call(this,i,h.default??a,h.type);this.$data[o]=c,A(this,r,!0),this.attributeChanged(s,a,c)}emit(t,s,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:s,...e}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,s,e){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,s=new WeakMap,e=new WeakMap,i=new WeakMap,n=new WeakMap,h=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakSet,f=function(t){for(const s of t)if(this.hasOwnProperty(s)){const t=this[s];delete this[s],this[s]=t}},p=function(s){const{proxy:e,dispose:n}=O(s,s=>{var e,i;if("set"===s.type){const{key:n,newValue:h}=s,o=S(this,t),a=String(n),r=(null==(e=o.propMap)?void 0:e.get(a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=o.propMap)?void 0:i.values())||[]).find(t=>t.name===a);(null==r?void 0:r.reflect)&&N(this,d,b).call(this,r,h)}this.emit("change",{source:"state",...s}),N(this,d,v).call(this)});A(this,i,e),A(this,h,n)},b=function(t,s){const e=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)s?this.setAttribute(e,""):this.removeAttribute(e);else{const t="object"==typeof s?JSON.stringify(s):String(s);this.setAttribute(e,t)}},m=function(t){t.ir&&A(this,e,t.ir)},k=function(t,s,e){if(null===t)return"boolean"===e?s??!1:s;switch(e){case"boolean":return!0;case"number":{const e=Number(t);return isNaN(e)?s:e}case"object":try{return JSON.parse(t)}catch{return s}default:return t}},v=function(){S(this,l)?!S(this,a)&&S(this,s)&&(A(this,a,!0),queueMicrotask(()=>{A(this,a,!1),N(this,d,w).call(this)})):A(this,u,!0)},w=function(){!S(this,o)&&S(this,l)&&(A(this,o,!0),S(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),S(this,s).update(),this.updated(),S(this,r)&&(this.afterAttributesUpdate(),A(this,r,!1)),A(this,o,!1))},y=function(){const s=S(this,t);if(!s.styles)return;const e=S(this,n);if(s.sheet&&e instanceof ShadowRoot&&"adoptedStyleSheets"in e)return void(e.adoptedStyleSheets.includes(s.sheet)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s.sheet]));const i=e instanceof ShadowRoot?e:document.head,h=`solely-style-${s.tagName}`;if(!i.querySelector(`#${h}`)){const t=document.createElement("style");t.id=h,t.textContent=s.styles,i.appendChild(t)}},M=function(){S(this,c)||(A(this,c,!0),this.created())},g(q,"upgradeProps"),(()=>{if(x){const t=customElements.define,s=new WeakSet;customElements.define=function(e,i,n){if(q.isPrototypeOf(i)&&!s.has(i)){s.add(i);const t=i.prototype,n=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const s of n)t[s]!==q.prototype[s]&&console.error(`[${e}] 禁止重写 ${s}(),请使用框架钩子`)}return t.call(this,e,i,n)}}})();let z=q;export{z as default};
1
+ var t,s,e,i,n,a,h,o,r,c,l,u,d,f,p,b,m,v,k,y,w,g,$=Object.defineProperty,M=t=>{throw TypeError(t)},S=(t,s,e)=>((t,s,e)=>s in t?$(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e)(t,"symbol"!=typeof s?s+"":s,e),W=(t,s,e)=>s.has(t)||M("Cannot "+e),C=(t,s,e)=>(W(t,s,"read from private field"),e?e.call(t):s.get(t)),j=(t,s,e)=>s.has(t)?M("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,e),A=(t,s,e,i)=>(W(t,s,"write to private field"),i?i.call(t,e):s.set(t,e),e),N=(t,s,e)=>(W(t,s,"access private method"),e);import{isObject as E}from"../../shared/is-object.js";import{IS_DEV as O}from"../../shared/env.js";import{observe as x}from"../reactivity/observe.js";import{createRender as J}from"../renderer/renderIR.js";const R=Symbol.for("solely.manifest"),U=class extends HTMLElement{constructor(f={}){var b;super(),j(this,d),S(this,"$refs",{}),j(this,t),j(this,s),j(this,e),j(this,i),j(this,n),j(this,a),j(this,h,!1),j(this,o,!1),j(this,r,!1),j(this,c,!1),j(this,l,!1),j(this,u,!1);const v=this.constructor;A(this,t,v[R]||{tagName:"base-element"});const k=C(this,t);A(this,n,(null==(b=k.shadowDOM)?void 0:b.use)?this.attachShadow({mode:k.shadowDOM.mode||"open"}):this),N(this,d,p).call(this,f),N(this,d,m).call(this,k),queueMicrotask(()=>N(this,d,g).call(this))}static get observedAttributes(){const t=this[R];return(null==t?void 0:t.propMap)?Array.from(t.propMap.keys()):[]}get $data(){return C(this,i)}set $data(t){var s;E(t)||(t={}),null==(s=C(this,a))||s.call(this),N(this,d,p).call(this,t),N(this,d,k).call(this)}refresh(){N(this,d,k).call(this)}connectedCallback(){var i;A(this,l,!0);const a=this.constructor.upgradeProps;let h;h=Array.isArray(a)?a.includes("$data")?a:[...a,"$data"]:["$data"],N(this,d,f).call(this,h),N(this,d,g).call(this);const o=C(this,t);if((o.className||o.tagName||"").split(" ").forEach(t=>t&&this.classList.add(t)),N(this,d,w).call(this),o.propMap&&E(this.$data))for(const[t,s]of o.propMap){const e=s.name;if(this.hasAttribute(t)){const i=this.getAttribute(t),n=N(this,d,v).call(this,i,s.default,s.type);this.$data[e]=n}else"default"in s&&(this.$data[e]=s.default)}C(this,e)&&!C(this,s)&&A(this,s,J(C(this,e),C(this,n),this)),C(this,u)&&(A(this,u,!1),N(this,d,k).call(this)),this.mounted(),null==(i=this.onInit)||i.call(this)}disconnectedCallback(){A(this,l,!1),this.unmounted()}attributeChangedCallback(s,e,i){var n;if(e===i||!E(this.$data))return;const a=null==(n=C(this,t).propMap)?void 0:n.get(s);if(!a)return;const h=a.name,o=this.$data[h],c=N(this,d,v).call(this,i,a.default??o,a.type);this.$data[h]=c,A(this,r,!0),this.attributeChanged(s,o,c)}emit(t,s,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:s,...e}))}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}attributeChanged(t,s,e){}beforeAttributesUpdate(){}afterAttributesUpdate(){}};t=new WeakMap,s=new WeakMap,e=new WeakMap,i=new WeakMap,n=new WeakMap,a=new WeakMap,h=new WeakMap,o=new WeakMap,r=new WeakMap,c=new WeakMap,l=new WeakMap,u=new WeakMap,d=new WeakSet,f=function(t){for(const s of t)if(this.hasOwnProperty(s)){const t=this[s];delete this[s],this[s]=t}},p=function(s){const{proxy:e,dispose:n}=x(s,s=>{var e,i;if("set"===s.type){const{key:n,newValue:a}=s,h=C(this,t),o=String(n),r=(null==(e=h.propMap)?void 0:e.get(o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()))||Array.from((null==(i=h.propMap)?void 0:i.values())||[]).find(t=>t.name===o);(null==r?void 0:r.reflect)&&N(this,d,b).call(this,r,a)}this.emit("change",{source:"state",...s}),N(this,d,k).call(this)});A(this,i,e),A(this,a,n)},b=function(t,s){const e=t.name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();if("boolean"===t.type)s?this.setAttribute(e,""):this.removeAttribute(e);else{const t="object"==typeof s?JSON.stringify(s):String(s);this.setAttribute(e,t)}},m=function(t){t.ir&&A(this,e,t.ir)},v=function(t,s,e){if(null===t)return"boolean"===e?s??!1:s;switch(e){case"boolean":return!0;case"number":{const e=Number(t);return isNaN(e)?s:e}case"object":try{return JSON.parse(t)}catch(i){return console.error(`[Solely] Failed to parse object value: "${t}", using default value.`,i),s}case"array":try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);return Array.isArray(i)?i:s}catch(i){return console.error(`[Solely] Failed to parse array value: "${t}", using default value.`,i),s}default:return t}},k=function(){C(this,l)?!C(this,o)&&C(this,s)&&(A(this,o,!0),queueMicrotask(()=>{A(this,o,!1),N(this,d,y).call(this)})):A(this,u,!0)},y=function(){!C(this,h)&&C(this,l)&&(A(this,h,!0),C(this,r)&&this.beforeAttributesUpdate(),this.beforeUpdate(),C(this,s).update(),this.updated(),C(this,r)&&(this.afterAttributesUpdate(),A(this,r,!1)),A(this,h,!1))},w=function(){const s=C(this,t);if(!s.styles)return;const e=C(this,n);if(s.sheet&&e instanceof ShadowRoot&&"adoptedStyleSheets"in e)return void(e.adoptedStyleSheets.includes(s.sheet)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s.sheet]));const i=e instanceof ShadowRoot?e:document.head,a=`solely-style-${s.tagName}`;if(!i.querySelector(`#${a}`)){const t=document.createElement("style");t.id=a,t.textContent=s.styles,i.appendChild(t)}},g=function(){C(this,c)||(A(this,c,!0),this.created())},S(U,"upgradeProps"),(()=>{if(O){const t=customElements.define,s=new WeakSet;customElements.define=function(e,i,n){if(U.isPrototypeOf(i)&&!s.has(i)){s.add(i);const t=i.prototype,n=["connectedCallback","disconnectedCallback","attributeChangedCallback"];for(const s of n)t[s]!==U.prototype[s]&&console.error(`[${e}] 禁止重写 ${s}(),请使用框架钩子`)}return t.call(this,e,i,n)}}})();let q=U;export{q as default};
@@ -1,6 +1,6 @@
1
1
  import { IRRoot } from '../../types';
2
2
  /** Prop 配置,支持类型声明 */
3
- export type PropType = 'string' | 'number' | 'boolean' | 'object';
3
+ export type PropType = 'string' | 'number' | 'boolean' | 'object' | 'array';
4
4
  /** 属性描述符 */
5
5
  export interface PropDescriptor {
6
6
  /** HTML attribute 名 */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./component/base-element.cjs"),r=require("./reactivity/observe.cjs"),o=require("./component/decorators.cjs"),s=require("./renderer/renderIR.cjs");exports.BaseElement=e.default,exports.isProxy=r.isProxy,exports.observe=r.observe,exports.toRaw=r.toRaw,exports.CustomElement=o.CustomElement,exports.IRRenderer=s.IRRenderer,exports.createRender=s.createRender;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./component/base-element.cjs"),r=require("./renderer/html-decode.cjs"),o=require("./reactivity/observe.cjs"),s=require("./component/decorators.cjs"),t=require("./renderer/renderIR.cjs");exports.BaseElement=e.default,exports.htmlDecode=r.default,exports.isProxy=o.isProxy,exports.observe=o.observe,exports.toRaw=o.toRaw,exports.CustomElement=s.CustomElement,exports.IRRenderer=t.IRRenderer,exports.createRender=t.createRender;
@@ -1 +1 @@
1
- import{default as e}from"./component/base-element.js";import{isProxy as r,observe as o,toRaw as t}from"./reactivity/observe.js";import{CustomElement as m}from"./component/decorators.js";import{IRRenderer as s,createRender as n}from"./renderer/renderIR.js";export{e as BaseElement,m as CustomElement,s as IRRenderer,n as createRender,r as isProxy,o as observe,t as toRaw};
1
+ import{default as e}from"./component/base-element.js";import{default as r}from"./renderer/html-decode.js";import{isProxy as o,observe as t,toRaw as m}from"./reactivity/observe.js";import{CustomElement as s}from"./component/decorators.js";import{IRRenderer as a,createRender as d}from"./renderer/renderIR.js";export{e as BaseElement,s as CustomElement,a as IRRenderer,d as createRender,r as htmlDecode,o as isProxy,t as observe,m as toRaw};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=(()=>{const t={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",copy:"©",reg:"®",trade:"™",hellip:"…",middot:"·",euro:"€"},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},r=/&(?:#([xX][0-9a-fA-F]+|\d+)|([a-zA-Z0-9]+));/g;return function(o){return o&&"string"==typeof o&&o.includes("&")?o.replace(r,(r,o,n)=>{if(n)return t[n.toLowerCase()]||r;if(o){const t="x"===o[0]||"X"===o[0];let n=parseInt(t?o.slice(1):o,t?16:10);return isNaN(n)?r:(n>=128&&n<=159&&(n=e[n]||n),0===n||n>=55296&&n<=57343||n>1114111?"�":String.fromCodePoint(n))}return r}):o}})();exports.default=t;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 终极 HTML 实体解码工具 (Template Engine 专用)
3
+ * 1. 跨平台:无 DOM 依赖,支持 Node.js / Browser / Worker / 小程序
4
+ * 2. 兼容性:支持命名实体、数字实体 (10/16进制)、Windows-1252 特殊映射
5
+ * 3. 安全性:严格校验 Unicode 码点范围,防止非法字符注入
6
+ * 4. 性能:针对模板引擎优化,包含快速路径判断
7
+ */
8
+ declare const htmlDecode: (str: string) => string;
9
+ export default htmlDecode;
@@ -0,0 +1 @@
1
+ const t=(()=>{const t={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",copy:"©",reg:"®",trade:"™",hellip:"…",middot:"·",euro:"€"},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},e=/&(?:#([xX][0-9a-fA-F]+|\d+)|([a-zA-Z0-9]+));/g;return function(n){return n&&"string"==typeof n&&n.includes("&")?n.replace(e,(e,n,o)=>{if(o)return t[o.toLowerCase()]||e;if(n){const t="x"===n[0]||"X"===n[0];let o=parseInt(t?n.slice(1):n,t?16:10);return isNaN(o)?e:(o>=128&&o<=159&&(o=r[o]||o),0===o||o>=55296&&o<=57343||o>1114111?"�":String.fromCodePoint(o))}return e}):n}})();export{t as default};
@@ -1 +1,2 @@
1
1
  export * from './renderIR';
2
+ export { default as htmlDecode } from './html-decode';
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,s,n)=>((e,s,n)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n)(e,"symbol"!=typeof s?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),n=require("../../shared/templateError.cjs"),o=require("../../shared/env.cjs"),i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),a={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},h={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},u=new Set(["data-","aria-","role","form"]),f=new Set(["value","selectedIndex"]);function d(t,e){var s;const n=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==n?void 0:n.v)&&t.setAttribute("class",n.v)}function m(t,e){var s;if(!t.style)return;const n=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),o=n?b(n.v):{};for(const i in o){const e=o[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t)&&(o.IS_DEV&&console.warn(`[Solely] Invalid class name "${t}" contains whitespace, will be ignored`),1));function b(t){const e={},s=[[t]];for(;s.length;){const[t,n]=s.pop()||[];if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let n;for(;null!==(n=s.exec(t));){const t=n[1].trim(),s=n[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const o in t){const i=t[o];if(null==i)continue;const r=n?`${n}-${o}`:o;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function v(t,e,s){const n=null==s?"":String(s),o=e.indexOf(":");if(o>0){const s=e.slice(0,o),i=a[s];if(i)return void(t.getAttributeNS(i,e)!==n&&t.setAttributeNS(i,e,n))}t.getAttribute(e)!==n&&t.setAttribute(e,n)}function y(t,e,s){const n=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||u.has(e))return void v(t,e,s);const o=t,i=o.tagName;if(null!=s){if("src"===n||"href"===n){const e=String(s);if(o[n]===e||t.getAttribute(n)===e)return}if("value"!==n||"INPUT"!==i&&"TEXTAREA"!==i||o.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==o.ownerSVGElement)&&!h[e]?v(t,e,s):o[n]!==s&&(o[n]=s);else{if(o[n]===s)return;o[n]=s}}else if("boolean"==typeof o[n])!1!==o[n]&&(o[n]=!1);else{const s=o[n];""!==s&&void 0!==s&&(o[n]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,n={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=n}evalIR(t,e,s){var o;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return n.showTemplateError(r.message||r.toString(),(null==(o=this.ir.m)?void 0:o.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g??"";return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,n=!1){const o=[],a=t;let h;a[i]||(a[i]={loops:null}),a[i].loops=s,a[r]||(a[r]=Object.create(null));let u,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:b}=c;if(":class"===e){h=this.evalIR(l??-1,[s],c.o),d=!0;continue}if(":style"===e){u=this.evalIR(l??-1,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),o=c.r??"user";let h=a[r][s];if(h||(h=a[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!n){const t=t=>this.evalIR(l??-1,[t,a[i].loops],c.o);h[o].push(t)}continue}if("mounted"===e){n||requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.o));continue}if("updated"===e){n&&requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.o));continue}if("ref"===e&&b){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[b]=t;continue}const S=p?this.evalIR(l??-1,[s],c.o):b??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&f.has(s)?o.push(()=>y(t,s,S)):y(t,s,S)}else n||v(t,e,String(S))}return d&&((t,e)=>{const s=t,n=s[c],o=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const n=s[t].trim();n&&(e[n]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in o)p(c)&&(i[c]=o[c]);if(!n){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in n)i[c]||(t.classList.remove(c),r=!0);for(const c in i)n[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,h),m&&((t,e)=>{const s=t,n=b(e),o=s[l];if(!o){for(const e in n){const s=n[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=n)}let i=!1;for(const r in o)r in n||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in n){const e=n[r];e!==o[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=n)})(t,u),o}updateNode(t,e,s){const n=e.d?this.evalIR(e.f??-1,[s],e.o):e.x||"";e.d&&t.textContent!==n&&(t.textContent=n)}createStaticSubtree(t,e,n){var o;switch(t.t){case s.ASTType.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],n);return null==(o=t.c)||o.forEach(t=>{const e=this.createStaticSubtree(t,s,n);s.appendChild(e)}),i.forEach(t=>t()),s}case s.ASTType.Text:return this.createText(t,n);case s.ASTType.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,n){const o=this.staticSubtreeCache.get(e);if(o){const t=o.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,n);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,n,o,i){var r,c,l,a,h,u,f;const p=n+"-"+e,b=this.nodeMap.get(p);let v;if(1!==t.s)if(b){v=b.node,b.marker=this.marker;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(v,t.a??[],i,!0):this.updateNode(v,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,p,v,i)}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:v=this.createElement(t,o),d(v,t),m(v,t);const e=this.applyAttrs(v,t.a??[],i);o.appendChild(v),this.nodeMap.set(p,{irNode:t,node:v,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,p,v,i)}),e.forEach(t=>t());break;case s.ASTType.Text:v=this.createText(t,i),o.appendChild(v),this.nodeMap.set(p,{irNode:t,node:v,loops:i,marker:this.marker});break;case s.ASTType.Comment:v=this.createComment(t,i),o.appendChild(v),this.nodeMap.set(p,{irNode:t,node:v,loops:i,marker:this.marker});break;case s.ASTType.For:{const e=`${p}-end`;let n=null==(l=this.nodeMap.get(e))?void 0:l.node;n?this.nodeMap.get(e).marker=this.marker:(n=document.createComment(`for:${p}`),o.appendChild(n),this.nodeMap.set(e,{irNode:{t:s.ASTType.Comment},node:n,loops:i,marker:this.marker}));const r=this.evalIR(t.f??-1,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var n;const o=[...i,{itmVal:e,idxVal:s}];null==(n=t.c)||n.forEach((t,e)=>{this.irToNode(t,e,`${p}-for-${s}`,c,o)})}),null==(a=n.parentNode)||a.insertBefore(c,n);break}case s.ASTType.Conditional:{const e=`${p}-end`;let s=null==(h=this.nodeMap.get(e))?void 0:h.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${p}`),o.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let n=0;n<(t.b||[]).length;n++){const e=null==(u=t.b)?void 0:u[n];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${p}-if-${n}`,t,i)}),null==(f=s.parentNode)||f.insertBefore(t,s);break}}break}}else b?(b.marker=this.marker,v=b.node):(v=this.handleStaticSubtree(t,p,o,i),this.nodeMap.set(p,{irNode:t,node:v,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:n,loops:o}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f??-1,[n,o],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==n||n.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=w,exports.createRender=(t,e,s={})=>{const n=new w(t,e,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};
1
+ "use strict";var t=Object.defineProperty,e=(e,s,n)=>((e,s,n)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n)(e,"symbol"!=typeof s?s+"":s,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../types/ast.cjs"),n=require("../../shared/templateError.cjs"),o=require("../../shared/env.cjs"),i=require("./html-decode.cjs"),r=Symbol("solely.irCtx"),c=Symbol("solely.irEvents"),l=Symbol("solely.prevClassObj"),a=Symbol("solely.prevStyleObj"),h={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},u={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},f=new Set(["data-","aria-","role","form"]),d=new Set(["value","selectedIndex"]);function m(t,e){var s;const n=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==n?void 0:n.v)&&t.setAttribute("class",n.v)}function p(t,e){var s;if(!t.style)return;const n=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),o=n?v(n.v):{};for(const i in o){const e=o[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const b=t=>!(!t||0===t.length||/\s/.test(t)&&(o.IS_DEV&&console.warn(`[Solely] Invalid class name "${t}" contains whitespace, will be ignored`),1));function v(t){const e={},s=[[t]];for(;s.length;){const[t,n]=s.pop()||[];if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let n;for(;null!==(n=s.exec(t));){const t=n[1].trim(),s=n[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const o in t){const i=t[o];if(null==i)continue;const r=n?`${n}-${o}`:o;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function y(t,e,s){const n=null==s?"":String(s),o=e.indexOf(":");if(o>0){const s=e.slice(0,o),i=h[s];if(i)return void(t.getAttributeNS(i,e)!==n&&t.setAttributeNS(i,e,n))}t.getAttribute(e)!==n&&t.setAttribute(e,n)}function w(t,e,s){const n=u[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||f.has(e))return void y(t,e,s);const o=t,i=o.tagName;if(null!=s){if("src"===n||"href"===n){const e=String(s);if(o[n]===e||t.getAttribute(n)===e)return}if("value"!==n||"INPUT"!==i&&"TEXTAREA"!==i||o.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==o.ownerSVGElement)&&!u[e]?y(t,e,s):o[n]!==s&&(o[n]=s);else{if(o[n]===s)return;o[n]=s}}else if("boolean"==typeof o[n])!1!==o[n]&&(o[n]=!1);else{const s=o[n];""!==s&&void 0!==s&&(o[n]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class S{constructor(t,s,n={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=n}evalIR(t,e,s){var o;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return n.showTemplateError(r.message||r.toString(),(null==(o=this.ir.m)?void 0:o.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g??"";return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.o):i.default(t.x||"");return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,n=!1){const o=[],i=t;let h;i[r]||(i[r]={loops:null}),i[r].loops=s,i[c]||(i[c]=Object.create(null));let u,f=!1,m=!1;for(const l of e){const{k:e,f:a,d:p,v:b}=l;if(":class"===e){h=this.evalIR(a??-1,[s],l.o),f=!0;continue}if(":style"===e){u=this.evalIR(a??-1,[s],l.o),m=!0;continue}if("class"===e||"style"===e)continue;const v=e[0];if("@"===v){const s=e.slice(1),o=l.r??"user";let h=i[c][s];if(h||(h=i[c][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!n){const t=t=>this.evalIR(a??-1,[t,i[r].loops],l.o);h[o].push(t)}continue}if("mounted"===e){n||requestAnimationFrame(()=>this.evalIR(a??-1,[t,s],l.o));continue}if("updated"===e){n&&requestAnimationFrame(()=>this.evalIR(a??-1,[t,s],l.o));continue}if("ref"===e&&b){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[b]=t;continue}const S=p?this.evalIR(a??-1,[s],l.o):b??"";if(":"===v){const s=e.slice(1);"SELECT"===t.tagName&&d.has(s)?o.push(()=>w(t,s,S)):w(t,s,S)}else n||y(t,e,String(S))}return f&&((t,e)=>{const s=t,n=s[l],o=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const n=s[t].trim();n&&(e[n]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in o)b(c)&&(i[c]=o[c]);if(!n){for(const e in i)t.classList.add(e);return void(s[l]=i)}let r=!1;for(const c in n)i[c]||(t.classList.remove(c),r=!0);for(const c in i)n[c]||(t.classList.add(c),r=!0);r&&(s[l]=i)})(t,h),m&&((t,e)=>{const s=t,n=v(e),o=s[a];if(!o){for(const e in n){const s=n[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[a]=n)}let i=!1;for(const r in o)r in n||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in n){const e=n[r];e!==o[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[a]=n)})(t,u),o}updateNode(t,e,s){const n=e.d?this.evalIR(e.f??-1,[s],e.o):e.x||"";e.d&&t.textContent!==n&&(t.textContent=n)}createStaticSubtree(t,e,n){var o;switch(t.t){case s.ASTType.Element:{const s=this.createElement(t,e);m(s,t),p(s,t);const i=this.applyAttrs(s,t.a??[],n);return null==(o=t.c)||o.forEach(t=>{const e=this.createStaticSubtree(t,s,n);s.appendChild(e)}),i.forEach(t=>t()),s}case s.ASTType.Text:return this.createText(t,n);case s.ASTType.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,n){const o=this.staticSubtreeCache.get(e);if(o){const t=o.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,n);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,n,o,i){var r,c,l,a,h,u,f;const d=n+"-"+e,b=this.nodeMap.get(d);let v;if(1!==t.s)if(b){v=b.node,b.marker=this.marker;let e=[];t.d&&(t.t===s.ASTType.Element?e=this.applyAttrs(v,t.a??[],i,!0):this.updateNode(v,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,d,v,i)}),e.forEach(t=>t())}else switch(t.t){case s.ASTType.Element:v=this.createElement(t,o),m(v,t),p(v,t);const e=this.applyAttrs(v,t.a??[],i);o.appendChild(v),this.nodeMap.set(d,{irNode:t,node:v,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,d,v,i)}),e.forEach(t=>t());break;case s.ASTType.Text:v=this.createText(t,i),o.appendChild(v),this.nodeMap.set(d,{irNode:t,node:v,loops:i,marker:this.marker});break;case s.ASTType.Comment:v=this.createComment(t,i),o.appendChild(v),this.nodeMap.set(d,{irNode:t,node:v,loops:i,marker:this.marker});break;case s.ASTType.For:{const e=`${d}-end`;let n=null==(l=this.nodeMap.get(e))?void 0:l.node;n?this.nodeMap.get(e).marker=this.marker:(n=document.createComment(`for:${d}`),o.appendChild(n),this.nodeMap.set(e,{irNode:{t:s.ASTType.Comment},node:n,loops:i,marker:this.marker}));const r=this.evalIR(t.f??-1,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var n;const o=[...i,{itmVal:e,idxVal:s}];null==(n=t.c)||n.forEach((t,e)=>{this.irToNode(t,e,`${d}-for-${s}`,c,o)})}),null==(a=n.parentNode)||a.insertBefore(c,n);break}case s.ASTType.Conditional:{const e=`${d}-end`;let s=null==(h=this.nodeMap.get(e))?void 0:h.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${d}`),o.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let n=0;n<(t.b||[]).length;n++){const e=null==(u=t.b)?void 0:u[n];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${d}-if-${n}`,t,i)}),null==(f=s.parentNode)||f.insertBefore(t,s);break}}break}}else b?(b.marker=this.marker,v=b.node):(v=this.handleStaticSubtree(t,d,o,i),this.nodeMap.set(d,{irNode:t,node:v,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:n,loops:o}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f??-1,[n,o],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==n||n.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}exports.IRRenderer=S,exports.createRender=(t,e,s={})=>{const n=new S(t,e,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};
@@ -1 +1 @@
1
- var t=Object.defineProperty,e=(e,s,n)=>((e,s,n)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n)(e,"symbol"!=typeof s?s+"":s,n);import{ASTType as s}from"../../types/ast.js";import{showTemplateError as n}from"../../shared/templateError.js";import{IS_DEV as o}from"../../shared/env.js";const i=Symbol("solely.irCtx"),r=Symbol("solely.irEvents"),c=Symbol("solely.prevClassObj"),l=Symbol("solely.prevStyleObj"),a={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},h={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},f=new Set(["data-","aria-","role","form"]),u=new Set(["value","selectedIndex"]);function d(t,e){var s;const n=null==(s=e.a)?void 0:s.find(t=>"class"===t.k&&!t.d);(null==n?void 0:n.v)&&t.setAttribute("class",n.v)}function m(t,e){var s;if(!t.style)return;const n=null==(s=e.a)?void 0:s.find(t=>"style"===t.k&&!t.d),o=n?v(n.v):{};for(const i in o){const e=o[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const p=t=>!(!t||0===t.length||/\s/.test(t)&&(o&&console.warn(`[Solely] Invalid class name "${t}" contains whitespace, will be ignored`),1));function v(t){const e={},s=[[t]];for(;s.length;){const[t,n]=s.pop()||[];if(t){if("string"==typeof t){const s=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let n;for(;null!==(n=s.exec(t));){const t=n[1].trim(),s=n[2].trim();t&&s&&(e[t]=s)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push([t[e]]);else if("object"==typeof t)for(const o in t){const i=t[o];if(null==i)continue;const r=n?`${n}-${o}`:o;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):s.push([i,r])}}}return e}function y(t,e,s){const n=null==s?"":String(s),o=e.indexOf(":");if(o>0){const s=e.slice(0,o),i=a[s];if(i)return void(t.getAttributeNS(i,e)!==n&&t.setAttributeNS(i,e,n))}t.getAttribute(e)!==n&&t.setAttribute(e,n)}function b(t,e,s){const n=h[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||f.has(e))return void y(t,e,s);const o=t,i=o.tagName;if(null!=s){if("src"===n||"href"===n){const e=String(s);if(o[n]===e||t.getAttribute(n)===e)return}if("value"!==n||"INPUT"!==i&&"TEXTAREA"!==i||o.value!==s)if("boolean"!=typeof s)(t instanceof SVGElement||void 0!==o.ownerSVGElement)&&!h[e]?y(t,e,s):o[n]!==s&&(o[n]=s);else{if(o[n]===s)return;o[n]=s}}else if("boolean"==typeof o[n])!1!==o[n]&&(o[n]=!1);else{const s=o[n];""!==s&&void 0!==s&&(o[n]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class w{constructor(t,s,n={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=s,this.scope=n}evalIR(t,e,s){var o;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return n(r.message||r.toString(),(null==(o=this.ir.m)?void 0:o.src)||"",s,this.scope.tagName),""}}createElement(t,e){const s=t.g??"";return e instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.o):t.x||"";return document.createTextNode(s)}createComment(t,e){const s=t.d?this.evalIR(t.f??-1,[e],t.o):t.x||"";return document.createComment(s)}applyAttrs(t,e,s,n=!1){const o=[],a=t;let h;a[i]||(a[i]={loops:null}),a[i].loops=s,a[r]||(a[r]=Object.create(null));let f,d=!1,m=!1;for(const c of e){const{k:e,f:l,d:p,v:v}=c;if(":class"===e){h=this.evalIR(l??-1,[s],c.o),d=!0;continue}if(":style"===e){f=this.evalIR(l??-1,[s],c.o),m=!0;continue}if("class"===e||"style"===e)continue;const w=e[0];if("@"===w){const s=e.slice(1),o=c.r??"user";let h=a[r][s];if(h||(h=a[r][s]={model:[],user:[]},t.addEventListener(s,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!n){const t=t=>this.evalIR(l??-1,[t,a[i].loops],c.o);h[o].push(t)}continue}if("mounted"===e){n||requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.o));continue}if("updated"===e){n&&requestAnimationFrame(()=>this.evalIR(l??-1,[t,s],c.o));continue}if("ref"===e&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=t;continue}const S=p?this.evalIR(l??-1,[s],c.o):v??"";if(":"===w){const s=e.slice(1);"SELECT"===t.tagName&&u.has(s)?o.push(()=>b(t,s,S)):b(t,s,S)}else n||y(t,e,String(S))}return d&&((t,e)=>{const s=t,n=s[c],o=function(t){const e={},s=[t];for(;s.length;){const t=s.pop();if(t)if("string"==typeof t){const s=t.split(" ");for(let t=0;t<s.length;t++){const n=s[t].trim();n&&(e[n]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)s.push(t[e]);else if("object"==typeof t)for(const s in t)t[s]&&(e[s]=!0)}return e}(e),i={};for(const c in o)p(c)&&(i[c]=o[c]);if(!n){for(const e in i)t.classList.add(e);return void(s[c]=i)}let r=!1;for(const c in n)i[c]||(t.classList.remove(c),r=!0);for(const c in i)n[c]||(t.classList.add(c),r=!0);r&&(s[c]=i)})(t,h),m&&((t,e)=>{const s=t,n=v(e),o=s[l];if(!o){for(const e in n){const s=n[e];e.startsWith("--")?t.style.setProperty(e,s):t.style[e]=s}return void(s[l]=n)}let i=!1;for(const r in o)r in n||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in n){const e=n[r];e!==o[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(s[l]=n)})(t,f),o}updateNode(t,e,s){const n=e.d?this.evalIR(e.f??-1,[s],e.o):e.x||"";e.d&&t.textContent!==n&&(t.textContent=n)}createStaticSubtree(t,e,n){var o;switch(t.t){case s.Element:{const s=this.createElement(t,e);d(s,t),m(s,t);const i=this.applyAttrs(s,t.a??[],n);return null==(o=t.c)||o.forEach(t=>{const e=this.createStaticSubtree(t,s,n);s.appendChild(e)}),i.forEach(t=>t()),s}case s.Text:return this.createText(t,n);case s.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,s,n){const o=this.staticSubtreeCache.get(e);if(o){const t=o.cloneNode(!0);return s.appendChild(t),t}const i=this.createStaticSubtree(t,s,n);return s.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,n,o,i){var r,c,l,a,h,f,u;const p=n+"-"+e,v=this.nodeMap.get(p);let y;if(1!==t.s)if(v){y=v.node,v.marker=this.marker;let e=[];t.d&&(t.t===s.Element?e=this.applyAttrs(y,t.a??[],i,!0):this.updateNode(y,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,p,y,i)}),e.forEach(t=>t())}else switch(t.t){case s.Element:y=this.createElement(t,o),d(y,t),m(y,t);const e=this.applyAttrs(y,t.a??[],i);o.appendChild(y),this.nodeMap.set(p,{irNode:t,node:y,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,p,y,i)}),e.forEach(t=>t());break;case s.Text:y=this.createText(t,i),o.appendChild(y),this.nodeMap.set(p,{irNode:t,node:y,loops:i,marker:this.marker});break;case s.Comment:y=this.createComment(t,i),o.appendChild(y),this.nodeMap.set(p,{irNode:t,node:y,loops:i,marker:this.marker});break;case s.For:{const e=`${p}-end`;let n=null==(l=this.nodeMap.get(e))?void 0:l.node;n?this.nodeMap.get(e).marker=this.marker:(n=document.createComment(`for:${p}`),o.appendChild(n),this.nodeMap.set(e,{irNode:{t:s.Comment},node:n,loops:i,marker:this.marker}));const r=this.evalIR(t.f??-1,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,s)=>{var n;const o=[...i,{itmVal:e,idxVal:s}];null==(n=t.c)||n.forEach((t,e)=>{this.irToNode(t,e,`${p}-for-${s}`,c,o)})}),null==(a=n.parentNode)||a.insertBefore(c,n);break}case s.Conditional:{const e=`${p}-end`;let s=null==(h=this.nodeMap.get(e))?void 0:h.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`if:${p}`),o.appendChild(s),this.nodeMap.set(e,{irNode:{},node:s,loops:i,marker:this.marker}));for(let n=0;n<(t.b||[]).length;n++){const e=null==(f=t.b)?void 0:f[n];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.irToNode(e,s,`${p}-if-${n}`,t,i)}),null==(u=s.parentNode)||u.insertBefore(t,s);break}}break}}else v?(v.marker=this.marker,y=v.node):(y=this.handleStaticSubtree(t,p,o,i),this.nodeMap.set(p,{irNode:t,node:y,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:s,node:n,loops:o}=e;if(s.a){const t=s.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f??-1,[n,o],t.o)});const e=s.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==n||n.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const S=(t,e,s={})=>{const n=new w(t,e,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};export{w as IRRenderer,S as createRender};
1
+ var t=Object.defineProperty,e=(e,o,s)=>((e,o,s)=>o in e?t(e,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[o]=s)(e,"symbol"!=typeof o?o+"":o,s);import{ASTType as o}from"../../types/ast.js";import{showTemplateError as s}from"../../shared/templateError.js";import{IS_DEV as n}from"../../shared/env.js";import i from"./html-decode.js";const r=Symbol("solely.irCtx"),c=Symbol("solely.irEvents"),l=Symbol("solely.prevClassObj"),a=Symbol("solely.prevStyleObj"),h={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},f={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},u=new Set(["data-","aria-","role","form"]),d=new Set(["value","selectedIndex"]);function m(t,e){var o;const s=null==(o=e.a)?void 0:o.find(t=>"class"===t.k&&!t.d);(null==s?void 0:s.v)&&t.setAttribute("class",s.v)}function p(t,e){var o;if(!t.style)return;const s=null==(o=e.a)?void 0:o.find(t=>"style"===t.k&&!t.d),n=s?y(s.v):{};for(const i in n){const e=n[i];i.startsWith("--")?t.style.setProperty(i,e):t.style[i]=e}}const v=t=>!(!t||0===t.length||/\s/.test(t)&&(n&&console.warn(`[Solely] Invalid class name "${t}" contains whitespace, will be ignored`),1));function y(t){const e={},o=[[t]];for(;o.length;){const[t,s]=o.pop()||[];if(t){if("string"==typeof t){const o=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;let s;for(;null!==(s=o.exec(t));){const t=s[1].trim(),o=s[2].trim();t&&o&&(e[t]=o)}continue}if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)o.push([t[e]]);else if("object"==typeof t)for(const n in t){const i=t[n];if(null==i)continue;const r=s?`${s}-${n}`:n;"object"!=typeof i||Array.isArray(i)?e[r]=String(i):o.push([i,r])}}}return e}function b(t,e,o){const s=null==o?"":String(o),n=e.indexOf(":");if(n>0){const o=e.slice(0,n),i=h[o];if(i)return void(t.getAttributeNS(i,e)!==s&&t.setAttributeNS(i,e,s))}t.getAttribute(e)!==s&&t.setAttribute(e,s)}function w(t,e,o){const s=f[e]||e;if(e.startsWith("data-")||e.startsWith("aria-")||u.has(e))return void b(t,e,o);const n=t,i=n.tagName;if(null!=o){if("src"===s||"href"===s){const e=String(o);if(n[s]===e||t.getAttribute(s)===e)return}if("value"!==s||"INPUT"!==i&&"TEXTAREA"!==i||n.value!==o)if("boolean"!=typeof o)(t instanceof SVGElement||void 0!==n.ownerSVGElement)&&!f[e]?b(t,e,o):n[s]!==o&&(n[s]=o);else{if(n[s]===o)return;n[s]=o}}else if("boolean"==typeof n[s])!1!==n[s]&&(n[s]=!1);else{const o=n[s];""!==o&&void 0!==o&&(n[s]=""),t.hasAttribute(e)&&t.removeAttribute(e)}}class S{constructor(t,o,s={}){e(this,"nodeMap",new Map),e(this,"marker",!1),e(this,"staticSubtreeCache",new Map),this.ir=t,this.container=o,this.scope=s}evalIR(t,e,o){var n;const i=this.ir.fns[t-1];try{return i?i.apply(this.scope,e):""}catch(r){return s(r.message||r.toString(),(null==(n=this.ir.m)?void 0:n.src)||"",o,this.scope.tagName),""}}createElement(t,e){const o=t.g??"";return e instanceof SVGElement||"svg"===o?document.createElementNS("http://www.w3.org/2000/svg",o):document.createElement(o)}createText(t,e){const o=t.d?this.evalIR(t.f??-1,[e],t.o):i(t.x||"");return document.createTextNode(o)}createComment(t,e){const o=t.d?this.evalIR(t.f??-1,[e],t.o):t.x||"";return document.createComment(o)}applyAttrs(t,e,o,s=!1){const n=[],i=t;let h;i[r]||(i[r]={loops:null}),i[r].loops=o,i[c]||(i[c]=Object.create(null));let f,u=!1,m=!1;for(const l of e){const{k:e,f:a,d:p,v:v}=l;if(":class"===e){h=this.evalIR(a??-1,[o],l.o),u=!0;continue}if(":style"===e){f=this.evalIR(a??-1,[o],l.o),m=!0;continue}if("class"===e||"style"===e)continue;const y=e[0];if("@"===y){const o=e.slice(1),n=l.r??"user";let h=i[c][o];if(h||(h=i[c][o]={model:[],user:[]},t.addEventListener(o,t=>{for(const e of h.model)e(t);for(const e of h.user)e(t)})),!s){const t=t=>this.evalIR(a??-1,[t,i[r].loops],l.o);h[n].push(t)}continue}if("mounted"===e){s||requestAnimationFrame(()=>this.evalIR(a??-1,[t,o],l.o));continue}if("updated"===e){s&&requestAnimationFrame(()=>this.evalIR(a??-1,[t,o],l.o));continue}if("ref"===e&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=t;continue}const S=p?this.evalIR(a??-1,[o],l.o):v??"";if(":"===y){const o=e.slice(1);"SELECT"===t.tagName&&d.has(o)?n.push(()=>w(t,o,S)):w(t,o,S)}else s||b(t,e,String(S))}return u&&((t,e)=>{const o=t,s=o[l],n=function(t){const e={},o=[t];for(;o.length;){const t=o.pop();if(t)if("string"==typeof t){const o=t.split(" ");for(let t=0;t<o.length;t++){const s=o[t].trim();s&&(e[s]=!0)}}else if(Array.isArray(t))for(let e=t.length-1;e>=0;e--)o.push(t[e]);else if("object"==typeof t)for(const o in t)t[o]&&(e[o]=!0)}return e}(e),i={};for(const c in n)v(c)&&(i[c]=n[c]);if(!s){for(const e in i)t.classList.add(e);return void(o[l]=i)}let r=!1;for(const c in s)i[c]||(t.classList.remove(c),r=!0);for(const c in i)s[c]||(t.classList.add(c),r=!0);r&&(o[l]=i)})(t,h),m&&((t,e)=>{const o=t,s=y(e),n=o[a];if(!n){for(const e in s){const o=s[e];e.startsWith("--")?t.style.setProperty(e,o):t.style[e]=o}return void(o[a]=s)}let i=!1;for(const r in n)r in s||(r.startsWith("--")?t.style.removeProperty(r):t.style[r]="",i=!0);for(const r in s){const e=s[r];e!==n[r]&&(r.startsWith("--")?t.style.setProperty(r,e):t.style[r]=e,i=!0)}i&&(o[a]=s)})(t,f),n}updateNode(t,e,o){const s=e.d?this.evalIR(e.f??-1,[o],e.o):e.x||"";e.d&&t.textContent!==s&&(t.textContent=s)}createStaticSubtree(t,e,s){var n;switch(t.t){case o.Element:{const o=this.createElement(t,e);m(o,t),p(o,t);const i=this.applyAttrs(o,t.a??[],s);return null==(n=t.c)||n.forEach(t=>{const e=this.createStaticSubtree(t,o,s);o.appendChild(e)}),i.forEach(t=>t()),o}case o.Text:return this.createText(t,s);case o.Comment:return this.createComment(t,s);default:return document.createComment("unknown")}}handleStaticSubtree(t,e,o,s){const n=this.staticSubtreeCache.get(e);if(n){const t=n.cloneNode(!0);return o.appendChild(t),t}const i=this.createStaticSubtree(t,o,s);return o.appendChild(i),this.staticSubtreeCache.set(e,i.cloneNode(!0)),i}irToNode(t,e,s,n,i){var r,c,l,a,h,f,u;const d=s+"-"+e,v=this.nodeMap.get(d);let y;if(1!==t.s)if(v){y=v.node,v.marker=this.marker;let e=[];t.d&&(t.t===o.Element?e=this.applyAttrs(y,t.a??[],i,!0):this.updateNode(y,t,i)),null==(r=t.c)||r.forEach((t,e)=>{this.irToNode(t,e,d,y,i)}),e.forEach(t=>t())}else switch(t.t){case o.Element:y=this.createElement(t,n),m(y,t),p(y,t);const e=this.applyAttrs(y,t.a??[],i);n.appendChild(y),this.nodeMap.set(d,{irNode:t,node:y,loops:i,marker:this.marker}),null==(c=t.c)||c.forEach((t,e)=>{this.irToNode(t,e,d,y,i)}),e.forEach(t=>t());break;case o.Text:y=this.createText(t,i),n.appendChild(y),this.nodeMap.set(d,{irNode:t,node:y,loops:i,marker:this.marker});break;case o.Comment:y=this.createComment(t,i),n.appendChild(y),this.nodeMap.set(d,{irNode:t,node:y,loops:i,marker:this.marker});break;case o.For:{const e=`${d}-end`;let s=null==(l=this.nodeMap.get(e))?void 0:l.node;s?this.nodeMap.get(e).marker=this.marker:(s=document.createComment(`for:${d}`),n.appendChild(s),this.nodeMap.set(e,{irNode:{t:o.Comment},node:s,loops:i,marker:this.marker}));const r=this.evalIR(t.f??-1,[i],t.o)||[],c=document.createDocumentFragment();r.forEach((e,o)=>{var s;const n=[...i,{itmVal:e,idxVal:o}];null==(s=t.c)||s.forEach((t,e)=>{this.irToNode(t,e,`${d}-for-${o}`,c,n)})}),null==(a=s.parentNode)||a.insertBefore(c,s);break}case o.Conditional:{const e=`${d}-end`;let o=null==(h=this.nodeMap.get(e))?void 0:h.node;o?this.nodeMap.get(e).marker=this.marker:(o=document.createComment(`if:${d}`),n.appendChild(o),this.nodeMap.set(e,{irNode:{},node:o,loops:i,marker:this.marker}));for(let s=0;s<(t.b||[]).length;s++){const e=null==(f=t.b)?void 0:f[s];if(null===e.f||this.evalIR(e.f,[i],e.o)){const t=document.createDocumentFragment();e.c.forEach((e,o)=>{this.irToNode(e,o,`${d}-if-${s}`,t,i)}),null==(u=o.parentNode)||u.insertBefore(t,o);break}}break}}else v?(v.marker=this.marker,y=v.node):(y=this.handleStaticSubtree(t,d,n,i),this.nodeMap.set(d,{irNode:t,node:y,loops:i,marker:this.marker}))}cleanupOldNodes(){for(const[t,e]of this.nodeMap.entries())if(e.marker!==this.marker){const{irNode:o,node:s,loops:n}=e;if(o.a){const t=o.a.find(t=>"unmounted"===t.k);t&&requestAnimationFrame(()=>{this.evalIR(t.f??-1,[s,n],t.o)});const e=o.a.find(t=>"ref"===t.k);e&&e.v&&delete this.scope.$refs[e.v]}null==s||s.remove(),this.nodeMap.delete(t)}}mount(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}update(){this.marker=!this.marker,this.ir.n.forEach((t,e)=>{this.irToNode(t,e,"root",this.container,[])}),this.cleanupOldNodes()}destroy(){this.container.innerHTML="",this.nodeMap.clear(),this.staticSubtreeCache.clear()}}const g=(t,e,o={})=>{const s=new S(t,e,o);return s.mount(),{update:()=>s.update(),destroy:()=>s.destroy()}};export{S as IRRenderer,g as createRender};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.2.8",
4
+ "version": "0.2.9",
5
5
  "description": "A lightweight TypeScript framework for building web components with compile-time optimizations",
6
6
  "type": "module",
7
7
  "sideEffects": false,