solely 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -315,6 +315,55 @@ class StyledCard extends BaseElement<{ txt: string }> {
315
315
 
316
316
  ---
317
317
 
318
+ ### 插槽(Slots)支持
319
+
320
+ 当 shadowDOM 功能处于开启状态时,该组件支持使用标准的 Web Components 插槽功能,并允许对插槽名称进行动态修改。
321
+
322
+ ```ts
323
+ // 带插槽的组件
324
+ @CustomElement({
325
+ tagName: 'my-layout',
326
+ template: `
327
+ <header><slot name="header"></slot></header>
328
+ <main><slot></slot></main>
329
+ <footer><slot s-name="$data.footerSlotName"></slot></footer>
330
+ `,
331
+ shadowDOM: { use: true },
332
+ styles: `
333
+ header, footer { background: #f0f0f0; padding: 10px; }
334
+ main { padding: 20px; }
335
+ `
336
+ })
337
+ class MyLayout extends BaseElement<{ footerSlotName: string }> {
338
+ constructor() {
339
+ super({ footerSlotName: 'default-footer' })
340
+ }
341
+
342
+ // 动态修改插槽名称
343
+ changeFooterSlot() {
344
+ this.$data.footerSlotName = 'custom-footer'
345
+ }
346
+ }
347
+ ```
348
+
349
+ ```html
350
+ <my-layout>
351
+ <!-- 命名插槽 -->
352
+ <h1 slot="header">页面标题</h1>
353
+
354
+ <!-- 默认插槽 -->
355
+ <p>这是页面内容...</p>
356
+
357
+ <!-- 动态插槽 -->
358
+ <div slot="default-footer">默认页脚</div>
359
+ <div slot="custom-footer">自定义页脚</div>
360
+ </my-layout>
361
+ ```
362
+
363
+ 使用动态插槽时,通过 `s-name="$data.slotName"` 语法绑定动态插槽名称,当数据变化时,插槽内容会自动重新分配。
364
+
365
+ ---
366
+
318
367
  ## 组件通信
319
368
 
320
369
  | 方式 | 示例 |
@@ -427,6 +476,7 @@ npm run pack:local # 生成 solely-<ver>.tgz,file: 引用
427
476
  |---|---|
428
477
  | 必须先写 `this.` 吗? | 模板中可省略,直接写 `$data.xxx` |
429
478
  | 什么时候用 Shadow DOM? | 需要样式/结构隔离时,在 `@CustomElement({shadowDOM: { use: true }})` 开启 |
479
+ | 组件支持插槽(Slots)吗? | 是的,当 shadowDOM 功能处于开启状态时,支持标准 Web Components 插槽功能,并允许使用 `s-name="$data.slotName"` 语法动态修改插槽名称 |
430
480
  | 能给子组件传对象吗? | 可以,用 `s-对象='json-string'` 或在父组件里直接 `querySelector('child').$data = {...}` |
431
481
  | 路由能否用 history 模式? | 当前仅实现 hash 模式,history 模式可自行扩展 |
432
482
  | 如何调试响应式数据? | 浏览器 DevTools 控制台直接 `document.querySelector('my-el').$data` 即可读写 |
@@ -446,7 +496,7 @@ npm run pack:local # 生成 solely-<ver>.tgz,file: 引用
446
496
 
447
497
  ## 版本与发布
448
498
 
449
- - 当前版本:**0.0.28**
499
+ - 当前版本:**0.0.29**
450
500
  - 遵循语义化版本(SemVer)
451
501
  - 构建产物位于 `dist/`,`package.json` 的 `"module"` 指向 `dist/solely.js`,类型声明 `dist/solely.d.ts`
452
502
 
package/dist/solely.js CHANGED
@@ -375,8 +375,6 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
375
375
  case "text":
376
376
  Gt(e);
377
377
  break;
378
- case "slot":
379
- break;
380
378
  default:
381
379
  Kt(t, e);
382
380
  break;
@@ -1,3 +1,3 @@
1
- (function(p,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(p=typeof globalThis<"u"?globalThis:p||self,v(p.solely={}))})(this,function(p){"use strict";var It=p=>{throw TypeError(p)};var yt=(p,v,C)=>v.has(p)||It("Cannot "+C);var P=(p,v,C)=>(yt(p,v,"read from private field"),C?C.call(p):v.get(p)),O=(p,v,C)=>v.has(p)?It("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(p):v.set(p,C),w=(p,v,C,X)=>(yt(p,v,"write to private field"),X?X.call(p,C):v.set(p,C),C),D=(p,v,C)=>(yt(p,v,"access private method"),C);var z,Q,J,U,N,V,W,S,G,Et;const v=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,C=/<\/?([^\s]+?)[/\s>]/,X=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Ot=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=/\{\{(.+?)\}\}/g;function jt(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function Tt(n,t){const e=(t.match(C)||[])[1]||"",s={rootId:"0",tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(X);for(;;){const o=r.exec(t);if(o===null)break;if(!o[0].trim())continue;const[a,i]=o[1]?o[1].trim().split("="):[o[2],o[3].trim().slice(1,-1)];if(a==="onMounted"||a==="onUpdated")s[a]=Ht(n,i);else if(ct.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=F(n,i);else if(a.startsWith("s-")){const l=a.slice(2);switch(l){case"model":s.model=i;break;case"style":s.styles=m=>j(n,i,m);break;case"class":s.classes=m=>j(n,i,m);break;case"readonly":s.props.readOnly=m=>j(n,i,m);break;default:s.props[l]=m=>j(n,i,m);break}}else s.attrs[a]=i;r.lastIndex--}if(e==="For"?s.fn=o=>j(n,s.attrs.each,o):(e==="If"||e==="ElseIf")&&(s.fn=o=>j(n,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=l=>j(n,`$data.${o}`,l),i=(l,m)=>{if(s.on[l]){const u=s.on[l];s.on[l]=(c,h)=>{m(c,h),u(c,h)}}else s.on[l]=m};if(e==="input"){const l=s.attrs.type||"text";if(l==="checkbox")s.props.checked=a,i("change",F(n,`$data.${o}=checked`));else if(l==="radio"){const m=s.attrs.value;s.props.checked=u=>a(u)==m,i("change",F(n,`if(checked){$data.${o}='${m}'}`))}else s.props.value=a,i("input",F(n,`$data.${o}=value`))}else if(e==="textarea")s.props.value=a,i("input",F(n,`$data.${o}=value`));else if(e==="select"){const l="multiple"in s.attrs;l?i("change",F(n,`
1
+ (function(p,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(p=typeof globalThis<"u"?globalThis:p||self,b(p.solely={}))})(this,function(p){"use strict";var It=p=>{throw TypeError(p)};var yt=(p,b,C)=>b.has(p)||It("Cannot "+C);var P=(p,b,C)=>(yt(p,b,"read from private field"),C?C.call(p):b.get(p)),O=(p,b,C)=>b.has(p)?It("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(p):b.set(p,C),w=(p,b,C,X)=>(yt(p,b,"write to private field"),X?X.call(p,C):b.set(p,C),C),D=(p,b,C)=>(yt(p,b,"access private method"),C);var z,Q,J,U,N,V,W,S,G,Et;const b=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,C=/<\/?([^\s]+?)[/\s>]/,X=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Ot=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=/\{\{(.+?)\}\}/g;function jt(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function Tt(n,t){const e=(t.match(C)||[])[1]||"",s={rootId:"0",tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(X);for(;;){const o=r.exec(t);if(o===null)break;if(!o[0].trim())continue;const[a,i]=o[1]?o[1].trim().split("="):[o[2],o[3].trim().slice(1,-1)];if(a==="onMounted"||a==="onUpdated")s[a]=Ht(n,i);else if(ct.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=F(n,i);else if(a.startsWith("s-")){const l=a.slice(2);switch(l){case"model":s.model=i;break;case"style":s.styles=m=>j(n,i,m);break;case"class":s.classes=m=>j(n,i,m);break;case"readonly":s.props.readOnly=m=>j(n,i,m);break;default:s.props[l]=m=>j(n,i,m);break}}else s.attrs[a]=i;r.lastIndex--}if(e==="For"?s.fn=o=>j(n,s.attrs.each,o):(e==="If"||e==="ElseIf")&&(s.fn=o=>j(n,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=l=>j(n,`$data.${o}`,l),i=(l,m)=>{if(s.on[l]){const u=s.on[l];s.on[l]=(c,h)=>{m(c,h),u(c,h)}}else s.on[l]=m};if(e==="input"){const l=s.attrs.type||"text";if(l==="checkbox")s.props.checked=a,i("change",F(n,`$data.${o}=checked`));else if(l==="radio"){const m=s.attrs.value;s.props.checked=u=>a(u)==m,i("change",F(n,`if(checked){$data.${o}='${m}'}`))}else s.props.value=a,i("input",F(n,`$data.${o}=value`))}else if(e==="textarea")s.props.value=a,i("input",F(n,`$data.${o}=value`));else if(e==="select"){const l="multiple"in s.attrs;l?i("change",F(n,`
2
2
  $data.${o} = Array.from(event.target.selectedOptions).map(o => o.value);
3
- `)):(i("change",F(n,`$data.${o}=value`)),s.props.value=a);const m=(h,d=[])=>{const k=a(d);if(l){const R=Array.isArray(k)?k:k!=null?[k]:[];for(const I of h.options)I.selected=R.includes(I.value)}else{const R=k??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,d)=>{u==null||u(h,d),m(h,d||[])},s.onUpdated=(h,d)=>{c==null||c(h,d),m(h,d||[])}}}return s}function bt(n,t){const e=[];if(!t)return e;t=jt(t);const s=[],r=[],o=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let a=0;return t.replace(v,(i,l)=>{const m=o();if(l>a){const u=t.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:d=>u.replace(it,(k,R)=>j(n,R,d));m.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))m.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=Tt(n,i),c=i.endsWith("/>")||Ot.includes(u.tagName);m.push(u),c||(s.push(u),r.push(u.tagName))}return""}),t.length>a&&e.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:t.substring(a).trim(),children:[]}),e}const j=(n,t,e)=>{try{return Z(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){return console.error(`[BaseElement][${n.tagName}] Error evaluating expression: {{ ${t} }}`,n,s),""}},F=(n,t)=>(e,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),t]).bind(n)(n.$data,e,(r=e==null?void 0:e.target)==null?void 0:r.value,(o=e==null?void 0:e.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${n.tagName}] Error executing event handler "${t}"`,n,a)}},Ht=(n,t)=>(e,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${t} }).call(this)`]).bind(n)(n.$data,e,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${n.tagName}] Error executing lifecycle handler "${t}"`,n,r)}},ct=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],Lt=typeof requestAnimationFrame=="function"?n=>requestAnimationFrame(n):typeof Promise<"u"?n=>Promise.resolve().then(n):n=>setTimeout(n,0),vt=(n,...t)=>{if(typeof n!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>n(...t))},lt={};function Z(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!lt[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(Ft(e))throw new Error("Input contains potentially dangerous code: "+e);lt[t]=new Function(...n)}return lt[t]}const Dt=["eval","Function","process","require"];function Ft(n){return Dt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const Ut="http://www.w3.org/1999/xlink",Vt="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",zt=n=>{const t=$t(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},kt=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},At=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{n.style[a]=i})},Ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?n.classList.add(a):n.classList.remove(a)})},ut=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=ut(s);Object.entries(r).forEach(([o,a])=>{t[`${e}-${o}`]=a})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(o=>o.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=ut(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},wt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=wt(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},Rt=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},Gt=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),Rt(e,s,t)}),kt(e,t.props,t.loops),Ct(e,t),At(e,t),typeof t.onUpdated=="function"&&requestAnimationFrame(()=>{t.onUpdated(e,t.loops||[])}),Mt(e,n.children,t.children)},Kt=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":zt(t);break;case"slot":break;default:Gt(n,t);break}},ht=(n,t,e)=>{e&&e.parentNode===n?n.insertBefore(t,e):n.appendChild(t)},Qt=(n,t,e)=>{const s=$t(t),r=document.createTextNode(s);t.elm=r,ht(n,r,e)},Jt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,ht(n,r,e)},Nt=(n,t,e,s)=>{t.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(o=>{const a=t.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Ut,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Vt,o,a):r.setAttribute(o,a)}),Object.keys(t.on).forEach(o=>{Rt(r,o,t)}),kt(r,t.props,t.loops),Ct(r,t),At(r,t),t.elm=r,ht(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(o=>{Y(r,o,void 0,s)}),typeof t.onMounted=="function"&&requestAnimationFrame(()=>{t.onMounted(r,t.loops||[])})},Y=(n,t,e,s)=>{switch(t.tagName){case"comment":Jt(n,t,e);break;case"text":Qt(n,t,e);break;default:Nt(n,t,e,s);break}},Xt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Zt=n=>n&&n.tagName==="Else",q=(n,t,e=[],s="0",r)=>{var i,l,m;let o=0,a=0;for(let u=0;u<t.length;u++){const c=t[u];if(c.tagName==="If"){let h=!1;o++;let d=1;for(((i=c.fn)==null?void 0:i.call(c,e))&&(q(n,c.children,e,`${s}-if-${o}-${d}`,d),h=!0),d++;u+1<t.length&&Xt(t[u+1]);)((m=(l=t[u+1]).fn)==null?void 0:m.call(l,e))&&!h&&(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++,d++;u+1<t.length&&Zt(t[u+1])&&(h||(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:d="index"}=c.attrs;(c.fn(e)||[]).forEach((R,I)=>{const ot={item:h,value:R,index:d,valueIndex:I};q(n,c.children,[...e,ot],`${s}-for-${a}-${I}`,1)})}else{const h={...c,loops:e,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,e,`${s}-${u}`),n.push(h)}}},Mt=(n,t,e)=>{var a,i,l,m,u;const s=new Map;t.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<e.length;){const c=e[r],h=s.get(c.key);if(h){const d=h.node;if(d.tagName!==c.tagName){(a=d.elm)==null||a.remove();const k=(i=t[o+1])==null?void 0:i.elm;Y(n,c,k),s.delete(c.key),o++}else{if(c.ifId&&d.ifId!==c.ifId){(l=d.elm)==null||l.remove();const k=(m=t[o+1])==null?void 0:m.elm;Y(n,c,k)}else Kt(d,c);s.delete(c.key),o++}}else{const d=(u=t[o])==null?void 0:u.elm;Y(n,c,d)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return q(s,t||[],[],"0"),Mt(n,e,s),s},_=n=>{if(n===null||typeof n!="object")return!1;const t=Object.prototype.toString.call(n);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(t)};function Pt(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],o={};return r&&r.split("&").forEach(a=>{const[i,l]=a.split("=");i&&l&&(o[decodeURIComponent(i)]=decodeURIComponent(l))}),{path:s.split("/"),query:o}}function pt(n,t,e={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:m=!1}=e,u=Array.isArray(e.filter)?e.filter:e.filter?[e.filter]:[];let c=[],h=null,d=!0;const k=(f,g,$=new WeakMap)=>{if(f===g)return!0;if(f==null||g==null||typeof f!="object"||typeof g!="object")return f===g;if($.has(f))return $.get(f)===g;if($.set(f,g),Array.isArray(f)&&Array.isArray(g)){if(f.length!==g.length)return!1;for(let y=0;y<f.length;y++)if(!k(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const A=Object.keys(f),E=Object.keys(g);if(A.length!==E.length)return!1;for(const y of A)if(!Object.prototype.hasOwnProperty.call(g,y)||!k(f[y],g[y],$))return!1;return!0},R=f=>{if(u.length===0)return!0;const g=f.map(String).join(".");return u.some($=>{if(!$)return!0;try{return new RegExp("^"+$.replace(/\./g,"\\.").replace(/\[\*\]/g,"(\\.\\d+)?").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+")+"$").test(g)}catch{return!0}})},I=(f,g,$)=>{d&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!d){h=null;return}const A=c;c=[],h=null,l&&l(A);for(const E of A)t(E.path,E.newValue,E.oldValue)},a))):(t(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!_(f)||!(Array.isArray(f)||Object.prototype.toString.call(f)==="[object Object]"))return f;const $={};if(["push","pop","shift","unshift","splice","sort","reverse"].forEach(E=>{const y=Array.prototype[E];$[E]=function(...b){if(!d)return Reflect.apply(y,f,b);const M=[...f],L=y.apply(f,b);return k(f,M)||I(g,f,M),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const A=new Proxy(f,{get(E,y,b){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,b);const M=Reflect.get(E,y,b);if(_(M)){const at=[...o.get(A)||[],y],gt=ot(M,at);return o.set(gt,at),gt}return M},set(E,y,b,M){const L=Reflect.get(E,y,M),at=_(b)&&!(b instanceof Date||b instanceof RegExp||b instanceof Map||b instanceof Set);if(i&&at?k(L,b):L===b)return!0;const oe=Reflect.set(E,y,b,M),ae=o.get(A)||g;return I([...ae,y],b,L),oe},deleteProperty(E,y){if(Reflect.has(E,y)){const b=E[y],M=Reflect.deleteProperty(E,y),L=o.get(A)||[];return M&&r.has(E)&&I([...L,y],void 0,b),M}return!1}});return s.set(f,A),o.set(A,g),A},re=ot(n,[]);if(m){const f=(g,$,A=new WeakSet)=>{if(!(!_(g)||!d||A.has(g))){A.add(g);for(const E of Object.keys(g)){const y=[...$,E],b=g[E];R(y)&&t(y,b,void 0),_(b)&&f(b,y,A)}}};f(n,[])}return{proxy:re,unobserve:()=>{d&&(d=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{d=!0}}}class Yt extends HTMLElement{constructor(e={}){var a;super();O(this,S);O(this,z);O(this,Q,[]);O(this,J,[]);O(this,U,!1);O(this,N,!1);O(this,V);O(this,W);const s=this._manifest||{};w(this,V,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(e,()=>D(this,S,G).call(this));w(this,z,r),w(this,W,o),s.template&&typeof s.template=="string"&&w(this,Q,bt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const e=this._manifest||this.prototype._manifest;return e!=null&&e.props?e.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return P(this,z)}set $data(e){_(e)||(e={}),P(this,W)&&P(this,W).call(this);const{proxy:s,unobserve:r}=pt(e,()=>D(this,S,G).call(this));w(this,z,s),w(this,W,r),D(this,S,G).call(this)}refresh(){D(this,S,G).call(this)}connectedCallback(){const e=this._manifest||{};if((e.className||e.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),e.styles&&!P(this,V).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=e.styles,P(this,V).appendChild(r)}if(e.props&&_(this.$data))for(const r of e.props){const o=typeof r=="string"?r:r.name,a=typeof r=="object"&&"type"in r?r.type:void 0,i=o.replace(/-([a-z])/g,(m,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const m=this.getAttribute(o);this.$data[i]=D(this,S,Et).call(this,m,l,a)}}D(this,S,G).call(this)}disconnectedCallback(){var e;this.isConnected&&(this.unmounted(),(e=P(this,W))==null||e.call(this),w(this,W,void 0))}attributeChangedCallback(e,s,r){if(s===r||!_(this.$data))return;const o=e.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,S,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,U=new WeakMap,N=new WeakMap,V=new WeakMap,W=new WeakMap,S=new WeakSet,G=function(){P(this,U)||(w(this,U,!0),vt(()=>{var e;if(!this.isConnected){w(this,U,!1);return}this.beforeUpdate(),w(this,J,ft(P(this,V),P(this,Q),P(this,J))),w(this,U,!1),P(this,N)?this.updated():(w(this,N,!0),this.mounted(),(e=this.onInit)==null||e.call(this))}))},Et=function(e,s,r){if(e===null)return s;switch(r||typeof s){case"number":const a=Number(e);return isNaN(a)?s:a;case"boolean":return e==="true";case"object":try{return JSON.parse(e)}catch{return s}default:return e}};const St=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=te(n),customElements.define(n.tagName,t),t},te=n=>(n=Object.assign({hasConfig:!1},n),n);var ee=Object.getOwnPropertyDescriptor,_t=n=>{throw TypeError(n)},ne=(n,t,e,s)=>{for(var r=s>1?void 0:s?ee(t,e):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=a(r)||r);return r},dt=(n,t,e)=>t.has(n)||_t("Cannot "+e),x=(n,t,e)=>(dt(n,t,"read from private field"),e?e.call(n):t.get(n)),T=(n,t,e)=>t.has(n)?_t("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),H=(n,t,e,s)=>(dt(n,t,"write to private field"),t.set(n,e),e),se=(n,t,e)=>(dt(n,t,"access private method"),e),tt,et,nt,K,B,st,rt,mt,xt;function Wt(n){return n instanceof HTMLElement&&n.isRouterView===!0}p.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),T(this,mt),T(this,tt,[]),T(this,et,[]),T(this,nt,null),T(this,K),T(this,B,[]),T(this,st,{}),T(this,rt,this.onHashChange.bind(this))}get isRouterView(){return!0}get $routes(){return x(this,B)}set $routes(t){H(this,B,t),this.onHashChange()}get $remainingPath(){return x(this,et)}get $matchedRoute(){return x(this,nt)}set $pipe(t){H(this,st,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",x(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",x(this,rt))}onHashChange(){var e;if(!this.isConnected)return;const t=this.findAncestorRouterView();if(t)H(this,K,t.$remainingPath),H(this,B,((e=t.$matchedRoute)==null?void 0:e.children)||[]);else{const{path:s}=Pt(window.location);H(this,K,s)}se(this,mt,xt).call(this)}prepareComponentData(t){const e={},s={};for(const[r,o]of Object.entries(t))e[r]=()=>o;for(const[r,o]of Object.entries(x(this,st))){const a=r.toLowerCase();let i=null;a.startsWith("on-")?i=a.slice(3):a.startsWith("on")&&ct.includes(a.slice(2))&&(i=a.slice(2)),i?s[i]=o:e[r]=()=>o}return{props:e,on:s}}matchRoute(t,e){for(const s of t){const r=s.path.split("/").filter(i=>i),o={};if(r.length>e.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],m=e[i];if(l.startsWith(":"))o[l.substring(1)]=m;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==m){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateToChildRouterViews(t=this){for(const e of t.childNodes)Wt(e)?e.onHashChange():this.propagateToChildRouterViews(e)}findAncestorRouterView(){let t=this.parentElement;for(;t;){if(Wt(t))return t;t=t.parentElement}return null}},tt=new WeakMap,et=new WeakMap,nt=new WeakMap,K=new WeakMap,B=new WeakMap,st=new WeakMap,rt=new WeakMap,mt=new WeakSet,xt=function(){const n=x(this,K)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(x(this,B),n);H(this,et,s),H(this,nt,t);const r=(t==null?void 0:t.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(e);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],x(this,tt))),this.propagateToChildRouterViews()},p.RouterViewElement=ne([St({tagName:"router-view"})],p.RouterViewElement),p.BaseElement=Yt,p.CustomElement=St,p.createFunction=Z,p.isObject=_,p.listeners=ct,p.observe=pt,p.parseHashUrl=Pt,p.parseHtml=bt,p.patch=ft,p.runInAsyncQueue=vt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
3
+ `)):(i("change",F(n,`$data.${o}=value`)),s.props.value=a);const m=(h,d=[])=>{const k=a(d);if(l){const R=Array.isArray(k)?k:k!=null?[k]:[];for(const I of h.options)I.selected=R.includes(I.value)}else{const R=k??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,d)=>{u==null||u(h,d),m(h,d||[])},s.onUpdated=(h,d)=>{c==null||c(h,d),m(h,d||[])}}}return s}function vt(n,t){const e=[];if(!t)return e;t=jt(t);const s=[],r=[],o=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let a=0;return t.replace(b,(i,l)=>{const m=o();if(l>a){const u=t.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:d=>u.replace(it,(k,R)=>j(n,R,d));m.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))m.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=Tt(n,i),c=i.endsWith("/>")||Ot.includes(u.tagName);m.push(u),c||(s.push(u),r.push(u.tagName))}return""}),t.length>a&&e.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:t.substring(a).trim(),children:[]}),e}const j=(n,t,e)=>{try{return Z(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){return console.error(`[BaseElement][${n.tagName}] Error evaluating expression: {{ ${t} }}`,n,s),""}},F=(n,t)=>(e,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),t]).bind(n)(n.$data,e,(r=e==null?void 0:e.target)==null?void 0:r.value,(o=e==null?void 0:e.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${n.tagName}] Error executing event handler "${t}"`,n,a)}},Ht=(n,t)=>(e,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${t} }).call(this)`]).bind(n)(n.$data,e,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${n.tagName}] Error executing lifecycle handler "${t}"`,n,r)}},ct=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],Lt=typeof requestAnimationFrame=="function"?n=>requestAnimationFrame(n):typeof Promise<"u"?n=>Promise.resolve().then(n):n=>setTimeout(n,0),bt=(n,...t)=>{if(typeof n!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>n(...t))},lt={};function Z(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!lt[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(Ft(e))throw new Error("Input contains potentially dangerous code: "+e);lt[t]=new Function(...n)}return lt[t]}const Dt=["eval","Function","process","require"];function Ft(n){return Dt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const Ut="http://www.w3.org/1999/xlink",Vt="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",zt=n=>{const t=$t(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},kt=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},At=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{n.style[a]=i})},Ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?n.classList.add(a):n.classList.remove(a)})},ut=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=ut(s);Object.entries(r).forEach(([o,a])=>{t[`${e}-${o}`]=a})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(o=>o.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=ut(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},wt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=wt(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},Rt=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},Gt=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),Rt(e,s,t)}),kt(e,t.props,t.loops),Ct(e,t),At(e,t),typeof t.onUpdated=="function"&&requestAnimationFrame(()=>{t.onUpdated(e,t.loops||[])}),Mt(e,n.children,t.children)},Kt=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":zt(t);break;default:Gt(n,t);break}},ht=(n,t,e)=>{e&&e.parentNode===n?n.insertBefore(t,e):n.appendChild(t)},Qt=(n,t,e)=>{const s=$t(t),r=document.createTextNode(s);t.elm=r,ht(n,r,e)},Jt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,ht(n,r,e)},Nt=(n,t,e,s)=>{t.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(o=>{const a=t.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Ut,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Vt,o,a):r.setAttribute(o,a)}),Object.keys(t.on).forEach(o=>{Rt(r,o,t)}),kt(r,t.props,t.loops),Ct(r,t),At(r,t),t.elm=r,ht(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(o=>{Y(r,o,void 0,s)}),typeof t.onMounted=="function"&&requestAnimationFrame(()=>{t.onMounted(r,t.loops||[])})},Y=(n,t,e,s)=>{switch(t.tagName){case"comment":Jt(n,t,e);break;case"text":Qt(n,t,e);break;default:Nt(n,t,e,s);break}},Xt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Zt=n=>n&&n.tagName==="Else",q=(n,t,e=[],s="0",r)=>{var i,l,m;let o=0,a=0;for(let u=0;u<t.length;u++){const c=t[u];if(c.tagName==="If"){let h=!1;o++;let d=1;for(((i=c.fn)==null?void 0:i.call(c,e))&&(q(n,c.children,e,`${s}-if-${o}-${d}`,d),h=!0),d++;u+1<t.length&&Xt(t[u+1]);)((m=(l=t[u+1]).fn)==null?void 0:m.call(l,e))&&!h&&(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++,d++;u+1<t.length&&Zt(t[u+1])&&(h||(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:d="index"}=c.attrs;(c.fn(e)||[]).forEach((R,I)=>{const ot={item:h,value:R,index:d,valueIndex:I};q(n,c.children,[...e,ot],`${s}-for-${a}-${I}`,1)})}else{const h={...c,loops:e,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,e,`${s}-${u}`),n.push(h)}}},Mt=(n,t,e)=>{var a,i,l,m,u;const s=new Map;t.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<e.length;){const c=e[r],h=s.get(c.key);if(h){const d=h.node;if(d.tagName!==c.tagName){(a=d.elm)==null||a.remove();const k=(i=t[o+1])==null?void 0:i.elm;Y(n,c,k),s.delete(c.key),o++}else{if(c.ifId&&d.ifId!==c.ifId){(l=d.elm)==null||l.remove();const k=(m=t[o+1])==null?void 0:m.elm;Y(n,c,k)}else Kt(d,c);s.delete(c.key),o++}}else{const d=(u=t[o])==null?void 0:u.elm;Y(n,c,d)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return q(s,t||[],[],"0"),Mt(n,e,s),s},_=n=>{if(n===null||typeof n!="object")return!1;const t=Object.prototype.toString.call(n);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(t)};function Pt(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],o={};return r&&r.split("&").forEach(a=>{const[i,l]=a.split("=");i&&l&&(o[decodeURIComponent(i)]=decodeURIComponent(l))}),{path:s.split("/"),query:o}}function pt(n,t,e={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:m=!1}=e,u=Array.isArray(e.filter)?e.filter:e.filter?[e.filter]:[];let c=[],h=null,d=!0;const k=(f,g,$=new WeakMap)=>{if(f===g)return!0;if(f==null||g==null||typeof f!="object"||typeof g!="object")return f===g;if($.has(f))return $.get(f)===g;if($.set(f,g),Array.isArray(f)&&Array.isArray(g)){if(f.length!==g.length)return!1;for(let y=0;y<f.length;y++)if(!k(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const A=Object.keys(f),E=Object.keys(g);if(A.length!==E.length)return!1;for(const y of A)if(!Object.prototype.hasOwnProperty.call(g,y)||!k(f[y],g[y],$))return!1;return!0},R=f=>{if(u.length===0)return!0;const g=f.map(String).join(".");return u.some($=>{if(!$)return!0;try{return new RegExp("^"+$.replace(/\./g,"\\.").replace(/\[\*\]/g,"(\\.\\d+)?").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+")+"$").test(g)}catch{return!0}})},I=(f,g,$)=>{d&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!d){h=null;return}const A=c;c=[],h=null,l&&l(A);for(const E of A)t(E.path,E.newValue,E.oldValue)},a))):(t(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!_(f)||!(Array.isArray(f)||Object.prototype.toString.call(f)==="[object Object]"))return f;const $={};if(["push","pop","shift","unshift","splice","sort","reverse"].forEach(E=>{const y=Array.prototype[E];$[E]=function(...v){if(!d)return Reflect.apply(y,f,v);const M=[...f],L=y.apply(f,v);return k(f,M)||I(g,f,M),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const A=new Proxy(f,{get(E,y,v){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,v);const M=Reflect.get(E,y,v);if(_(M)){const at=[...o.get(A)||[],y],gt=ot(M,at);return o.set(gt,at),gt}return M},set(E,y,v,M){const L=Reflect.get(E,y,M),at=_(v)&&!(v instanceof Date||v instanceof RegExp||v instanceof Map||v instanceof Set);if(i&&at?k(L,v):L===v)return!0;const oe=Reflect.set(E,y,v,M),ae=o.get(A)||g;return I([...ae,y],v,L),oe},deleteProperty(E,y){if(Reflect.has(E,y)){const v=E[y],M=Reflect.deleteProperty(E,y),L=o.get(A)||[];return M&&r.has(E)&&I([...L,y],void 0,v),M}return!1}});return s.set(f,A),o.set(A,g),A},re=ot(n,[]);if(m){const f=(g,$,A=new WeakSet)=>{if(!(!_(g)||!d||A.has(g))){A.add(g);for(const E of Object.keys(g)){const y=[...$,E],v=g[E];R(y)&&t(y,v,void 0),_(v)&&f(v,y,A)}}};f(n,[])}return{proxy:re,unobserve:()=>{d&&(d=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{d=!0}}}class Yt extends HTMLElement{constructor(e={}){var a;super();O(this,S);O(this,z);O(this,Q,[]);O(this,J,[]);O(this,U,!1);O(this,N,!1);O(this,V);O(this,W);const s=this._manifest||{};w(this,V,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(e,()=>D(this,S,G).call(this));w(this,z,r),w(this,W,o),s.template&&typeof s.template=="string"&&w(this,Q,vt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const e=this._manifest||this.prototype._manifest;return e!=null&&e.props?e.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return P(this,z)}set $data(e){_(e)||(e={}),P(this,W)&&P(this,W).call(this);const{proxy:s,unobserve:r}=pt(e,()=>D(this,S,G).call(this));w(this,z,s),w(this,W,r),D(this,S,G).call(this)}refresh(){D(this,S,G).call(this)}connectedCallback(){const e=this._manifest||{};if((e.className||e.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),e.styles&&!P(this,V).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=e.styles,P(this,V).appendChild(r)}if(e.props&&_(this.$data))for(const r of e.props){const o=typeof r=="string"?r:r.name,a=typeof r=="object"&&"type"in r?r.type:void 0,i=o.replace(/-([a-z])/g,(m,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const m=this.getAttribute(o);this.$data[i]=D(this,S,Et).call(this,m,l,a)}}D(this,S,G).call(this)}disconnectedCallback(){var e;this.isConnected&&(this.unmounted(),(e=P(this,W))==null||e.call(this),w(this,W,void 0))}attributeChangedCallback(e,s,r){if(s===r||!_(this.$data))return;const o=e.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,S,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,U=new WeakMap,N=new WeakMap,V=new WeakMap,W=new WeakMap,S=new WeakSet,G=function(){P(this,U)||(w(this,U,!0),bt(()=>{var e;if(!this.isConnected){w(this,U,!1);return}this.beforeUpdate(),w(this,J,ft(P(this,V),P(this,Q),P(this,J))),w(this,U,!1),P(this,N)?this.updated():(w(this,N,!0),this.mounted(),(e=this.onInit)==null||e.call(this))}))},Et=function(e,s,r){if(e===null)return s;switch(r||typeof s){case"number":const a=Number(e);return isNaN(a)?s:a;case"boolean":return e==="true";case"object":try{return JSON.parse(e)}catch{return s}default:return e}};const St=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=te(n),customElements.define(n.tagName,t),t},te=n=>(n=Object.assign({hasConfig:!1},n),n);var ee=Object.getOwnPropertyDescriptor,_t=n=>{throw TypeError(n)},ne=(n,t,e,s)=>{for(var r=s>1?void 0:s?ee(t,e):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=a(r)||r);return r},dt=(n,t,e)=>t.has(n)||_t("Cannot "+e),x=(n,t,e)=>(dt(n,t,"read from private field"),e?e.call(n):t.get(n)),T=(n,t,e)=>t.has(n)?_t("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),H=(n,t,e,s)=>(dt(n,t,"write to private field"),t.set(n,e),e),se=(n,t,e)=>(dt(n,t,"access private method"),e),tt,et,nt,K,B,st,rt,mt,xt;function Wt(n){return n instanceof HTMLElement&&n.isRouterView===!0}p.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),T(this,mt),T(this,tt,[]),T(this,et,[]),T(this,nt,null),T(this,K),T(this,B,[]),T(this,st,{}),T(this,rt,this.onHashChange.bind(this))}get isRouterView(){return!0}get $routes(){return x(this,B)}set $routes(t){H(this,B,t),this.onHashChange()}get $remainingPath(){return x(this,et)}get $matchedRoute(){return x(this,nt)}set $pipe(t){H(this,st,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",x(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",x(this,rt))}onHashChange(){var e;if(!this.isConnected)return;const t=this.findAncestorRouterView();if(t)H(this,K,t.$remainingPath),H(this,B,((e=t.$matchedRoute)==null?void 0:e.children)||[]);else{const{path:s}=Pt(window.location);H(this,K,s)}se(this,mt,xt).call(this)}prepareComponentData(t){const e={},s={};for(const[r,o]of Object.entries(t))e[r]=()=>o;for(const[r,o]of Object.entries(x(this,st))){const a=r.toLowerCase();let i=null;a.startsWith("on-")?i=a.slice(3):a.startsWith("on")&&ct.includes(a.slice(2))&&(i=a.slice(2)),i?s[i]=o:e[r]=()=>o}return{props:e,on:s}}matchRoute(t,e){for(const s of t){const r=s.path.split("/").filter(i=>i),o={};if(r.length>e.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],m=e[i];if(l.startsWith(":"))o[l.substring(1)]=m;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==m){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateToChildRouterViews(t=this){for(const e of t.childNodes)Wt(e)?e.onHashChange():this.propagateToChildRouterViews(e)}findAncestorRouterView(){let t=this.parentElement;for(;t;){if(Wt(t))return t;t=t.parentElement}return null}},tt=new WeakMap,et=new WeakMap,nt=new WeakMap,K=new WeakMap,B=new WeakMap,st=new WeakMap,rt=new WeakMap,mt=new WeakSet,xt=function(){const n=x(this,K)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(x(this,B),n);H(this,et,s),H(this,nt,t);const r=(t==null?void 0:t.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(e);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],x(this,tt))),this.propagateToChildRouterViews()},p.RouterViewElement=ne([St({tagName:"router-view"})],p.RouterViewElement),p.BaseElement=Yt,p.CustomElement=St,p.createFunction=Z,p.isObject=_,p.listeners=ct,p.observe=pt,p.parseHashUrl=Pt,p.parseHtml=vt,p.patch=ft,p.runInAsyncQueue=bt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solely",
3
3
  "private": false,
4
- "version": "0.0.28",
4
+ "version": "0.0.29",
5
5
  "type": "module",
6
6
  "module": "./dist/solely.js",
7
7
  "types": "./dist/solely.d.ts",