@bkm016/basalt 0.1.4 → 0.1.5
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 +53 -5
- package/{chunk-y648fzx0.js → chunk-0039s4jt.js} +3 -3
- package/{chunk-m40gxwq4.js → chunk-00gwse5r.js} +3 -3
- package/{chunk-t6zs4kw0.js → chunk-0fwdxd45.js} +2 -2
- package/{chunk-nmca5h6m.js → chunk-0j0qggej.js} +1 -1
- package/chunk-0n99m9m4.js +2 -0
- package/{chunk-pjyn2s97.js → chunk-0stvywr8.js} +1 -1
- package/{chunk-ztsjgssj.js → chunk-1xa7d5mh.js} +1 -1
- package/chunk-2nb3d92s.js +2 -0
- package/chunk-2nkfxhef.js +3868 -0
- package/chunk-2pa1z37c.js +2 -0
- package/{chunk-fw2bpqmw.js → chunk-2qcpq99g.js} +1 -1
- package/{chunk-981f9dw8.js → chunk-36cqq0ga.js} +6 -6
- package/{chunk-whvj83b7.js → chunk-3c330qna.js} +2 -2
- package/chunk-3k627vf2.js +3 -0
- package/{chunk-r7fpkb49.js → chunk-3k7ejpkc.js} +1 -1
- package/chunk-4g5f43ea.js +3 -0
- package/{chunk-fjtvjrkg.js → chunk-539ekagy.js} +4 -4
- package/{chunk-97rzj7f6.js → chunk-5v4g21rw.js} +1 -1
- package/{chunk-r0scgfwx.js → chunk-6dsq0fns.js} +2 -2
- package/{chunk-pbcy6zdt.js → chunk-7as47pcw.js} +1 -1
- package/{chunk-g2t6t8fk.js → chunk-7jezts2n.js} +2 -2
- package/{chunk-8wc8qdx8.js → chunk-7qq99360.js} +6 -6
- package/{chunk-9rmqgc3c.js → chunk-7tgqhveh.js} +15 -15
- package/{chunk-mvfsxdx6.js → chunk-7w0mefgk.js} +10 -10
- package/{chunk-y58ygzn9.js → chunk-818nd6s1.js} +3 -3
- package/{chunk-vv7fp27r.js → chunk-8mezk0cb.js} +2 -2
- package/{chunk-q7t30zz2.js → chunk-8xb636vr.js} +5 -5
- package/{chunk-ev6yvy5y.js → chunk-980drajf.js} +15 -15
- package/{chunk-3x94302m.js → chunk-9z7sdh5e.js} +3 -3
- package/{chunk-zggzfa7j.js → chunk-a4b75ekk.js} +2 -2
- package/{chunk-2zp1mv3q.js → chunk-ar3dbfp9.js} +1 -1
- package/{chunk-vk1gxk1t.js → chunk-aw65h276.js} +1 -1
- package/{chunk-f3xadvab.js → chunk-b9fqretv.js} +2 -2
- package/{chunk-7tbya5b5.js → chunk-bgkegf0k.js} +22 -22
- package/{chunk-0y7ne3d0.js → chunk-bwawt15q.js} +2 -2
- package/{chunk-pxsrqrd0.js → chunk-c4qr1f41.js} +2 -2
- package/chunk-dddsrff6.js +478 -0
- package/{chunk-xfvvh1s5.js → chunk-e63c1186.js} +1 -1
- package/{chunk-em187cy3.js → chunk-ebzkckyw.js} +2 -2
- package/chunk-eegztdzb.js +2 -0
- package/{chunk-rmj5b73e.js → chunk-gw05p4g3.js} +1 -1
- package/{chunk-k23t7vhs.js → chunk-h1rypb99.js} +5 -5
- package/{chunk-akr0a8nc.js → chunk-hq5ke1yp.js} +1 -1
- package/{chunk-jwdb0ccj.js → chunk-jvwg4rn1.js} +3 -3
- package/{chunk-7afmgncg.js → chunk-jyrwk08p.js} +1 -1
- package/chunk-kns4kv7b.js +3 -0
- package/{chunk-8d46jtbj.js → chunk-mat08ab1.js} +2 -2
- package/{chunk-jk25nt60.js → chunk-mkp28k1x.js} +2 -2
- package/{chunk-3ct2tkr8.js → chunk-npez1492.js} +2 -2
- package/{chunk-shadcb9z.js → chunk-nx3jnbv8.js} +2 -2
- package/{chunk-ykens1hy.js → chunk-nxkmd29x.js} +1 -1
- package/{chunk-y7nma9rk.js → chunk-pjr91g6k.js} +2 -2
- package/{chunk-m8vkwdgr.js → chunk-r0jc8e7t.js} +4 -4
- package/chunk-rxj6tct8.js +2 -0
- package/{chunk-362g64pd.js → chunk-sqaam5ak.js} +1 -1
- package/{chunk-4w17tzp5.js → chunk-srjgvdvs.js} +12 -12
- package/{chunk-r9aatvwm.js → chunk-stj493dn.js} +2 -2
- package/{chunk-k6w6y71k.js → chunk-t7sc0wwc.js} +2 -2
- package/{chunk-kp22kaez.js → chunk-v4k3qmdm.js} +2 -2
- package/{chunk-1vd0f74z.js → chunk-vt1anydc.js} +4 -4
- package/chunk-wd3z74av.js +2 -0
- package/{chunk-xh3vr5vz.js → chunk-wfyrfvfn.js} +1 -1
- package/{chunk-2hbfk5xd.js → chunk-wnzvnskb.js} +2 -2
- package/{chunk-cjc90f84.js → chunk-x89em726.js} +3 -3
- package/{chunk-vexrrw1b.js → chunk-xtq1xpq0.js} +2 -2
- package/chunk-yna8bwqc.js +2 -0
- package/{chunk-aky4tztg.js → chunk-zn0g0859.js} +2 -2
- package/{chunk-qe0teyn1.js → chunk-zrkh5dw7.js} +1 -1
- package/chunk-zzwjt7fp.js +2 -0
- package/compiled.js +12 -12
- package/package.json +1 -1
- package/ui-test-worker.js +20 -20
- package/web/chunk-01hcjafh.js +2 -0
- package/web/{chunk-n8sky2q6.js → chunk-07agqp8h.js} +1 -1
- package/web/{chunk-hvw3gn2a.js → chunk-0k9aec1s.js} +20 -20
- package/web/{chunk-74j07k8k.js → chunk-0p1nmj5n.js} +2 -2
- package/web/chunk-0qr891eq.js +70 -0
- package/web/{chunk-ts7zrf5b.js → chunk-0whceqes.js} +2 -2
- package/web/chunk-0ytga215.js +1 -0
- package/web/{chunk-0z0y25zf.js → chunk-12z7d0hp.js} +3 -3
- package/web/chunk-14bad871.js +2 -0
- package/web/chunk-1amzv4ha.js +1 -0
- package/web/chunk-1cfh0e2e.js +324 -0
- package/web/chunk-1pasbxwh.js +89 -0
- package/web/{chunk-4d3a7xs2.js → chunk-1s2hp6h1.js} +1 -1
- package/web/chunk-26bwh1sb.js +169 -0
- package/web/{chunk-wnskxerq.js → chunk-2nht58dc.js} +5 -5
- package/web/chunk-2y0rc1fe.js +1 -0
- package/web/chunk-3hkgdw6f.js +36 -0
- package/web/chunk-4a4j030b.js +1 -0
- package/web/{chunk-nvhmq4z5.js → chunk-4m3zdd41.js} +6 -6
- package/web/chunk-4w298aqs.js +1 -0
- package/web/{chunk-t4c8xavd.js → chunk-56krfj3b.js} +7 -7
- package/web/{chunk-ds7srg4p.js → chunk-5nda24gv.js} +1 -1
- package/web/{chunk-42e3b9hv.js → chunk-5shygfgb.js} +19 -19
- package/web/chunk-65nwc4cf.js +1 -0
- package/web/chunk-6bwgdvf6.js +1 -0
- package/web/chunk-6enn8p66.js +1 -0
- package/web/chunk-6stt9d18.js +1 -0
- package/web/{chunk-4gavbw65.js → chunk-7a3c137d.js} +1 -1
- package/web/chunk-7e47b1sn.js +1 -0
- package/web/chunk-7pypx5h8.js +2 -0
- package/web/chunk-7znyd1mj.js +39 -0
- package/web/{chunk-3re8y26v.js → chunk-892nf39p.js} +7 -7
- package/web/chunk-8r0s8tx7.js +1 -0
- package/web/chunk-9dy7z3ej.js +2 -0
- package/web/chunk-9mq2cdtq.js +1 -0
- package/web/chunk-9w5tf22s.js +1 -0
- package/web/{chunk-bhsaj6qq.js → chunk-9xgspn75.js} +2 -2
- package/web/{chunk-zx8zec24.js → chunk-abhad4zj.js} +56 -56
- package/web/chunk-advfpyb9.js +140 -0
- package/web/chunk-affear07.js +3 -0
- package/web/chunk-ahztazsg.js +1 -0
- package/web/chunk-aqt7kc3s.js +106 -0
- package/web/chunk-b5hah4mf.js +1 -0
- package/web/chunk-b8tfetd8.js +1 -0
- package/web/{chunk-9cx1be43.js → chunk-bnb9xhgw.js} +15 -15
- package/web/{chunk-n1dmrz44.js → chunk-c01176kn.js} +2 -2
- package/web/chunk-c3nn0vvc.js +1 -0
- package/web/chunk-c53xmf48.js +30 -0
- package/web/chunk-ckgpy4r4.js +1 -0
- package/web/chunk-crzseqbx.js +24 -0
- package/web/chunk-d22wq71s.js +1 -0
- package/web/{chunk-pws2seas.js → chunk-d60dpf69.js} +19 -19
- package/web/{chunk-6cnek1xh.js → chunk-d6ddkh6e.js} +1 -1
- package/web/{chunk-cg3jterp.js → chunk-d9wdsjkk.js} +2 -2
- package/web/{chunk-ttg6tbwx.js → chunk-da7m1kva.js} +2 -2
- package/web/chunk-dbnrfxt1.js +8 -0
- package/web/chunk-ddxf8e84.js +1 -0
- package/web/chunk-dzg1pv80.js +200 -0
- package/web/{chunk-yqbnps3a.js → chunk-e8h45nyr.js} +1 -1
- package/web/chunk-ej9vb61c.js +1 -0
- package/web/chunk-f9k3xrwb.js +2 -0
- package/web/{chunk-fh2vj0wv.js → chunk-fjag6yg8.js} +2 -2
- package/web/chunk-fnnrrzqa.js +78 -0
- package/web/{chunk-n90cqdvg.js → chunk-fv6vm14n.js} +2 -2
- package/web/{chunk-b1bgzz66.js → chunk-g5jxwkdh.js} +1 -1
- package/web/{chunk-sspfxp5e.js → chunk-g8kkc6vz.js} +1 -1
- package/web/chunk-g9sqbafw.js +2 -0
- package/web/{chunk-0h0vb6gt.js → chunk-gcv91974.js} +4 -4
- package/web/{chunk-sfg2wkhe.js → chunk-gxqaa4sv.js} +7 -7
- package/web/chunk-gxsb5tx3.js +1 -0
- package/web/{chunk-54thej0t.js → chunk-gyp6v7jd.js} +2 -2
- package/web/chunk-h0c42zy3.js +1 -0
- package/web/chunk-h2ag4kvz.js +2 -0
- package/web/{chunk-kmr7r9xj.js → chunk-h6gh63xj.js} +2 -2
- package/web/{chunk-6m69hczt.js → chunk-h6k1x096.js} +2 -2
- package/web/{chunk-24mfx6w1.js → chunk-j1bw5v1g.js} +2 -2
- package/web/chunk-j34q5jn6.js +1 -0
- package/web/{chunk-0pbjgdgp.js → chunk-ja7w629n.js} +2 -2
- package/web/{chunk-zbj1trar.js → chunk-jam45rqg.js} +2 -2
- package/web/{chunk-f4tacm06.js → chunk-jcdw85mv.js} +1 -1
- package/web/chunk-jfvxxp5c.js +1 -0
- package/web/chunk-jg6fmz2d.js +1 -0
- package/web/{chunk-92ssjk2y.js → chunk-k67v6dyg.js} +40 -40
- package/web/chunk-ka7c5rhx.js +99 -0
- package/web/{chunk-df5zx17h.js → chunk-kza0t0gj.js} +1 -1
- package/web/{chunk-0b47eyrf.js → chunk-m8knte9z.js} +1 -1
- package/web/{chunk-v5cnt7c8.js → chunk-mnzramhc.js} +1 -1
- package/web/{chunk-a408enpy.js → chunk-mpfgr049.js} +1 -1
- package/web/chunk-mz1dabxh.js +1 -0
- package/web/chunk-mz9b5bsa.js +1 -0
- package/web/chunk-p53n0hwr.js +1 -0
- package/web/chunk-paywgcf7.js +40 -0
- package/web/chunk-pfcnr9tw.js +1 -0
- package/web/chunk-pyg1mr80.js +303 -0
- package/web/chunk-q7xkscc5.js +1 -0
- package/web/{chunk-xzp7jf7e.js → chunk-qcge7d6s.js} +2 -2
- package/web/chunk-qmbgb79a.js +1139 -0
- package/web/{chunk-pjkdrgm0.js → chunk-qq5gh5zr.js} +1 -1
- package/web/chunk-qrdh9j62.js +1 -0
- package/web/{chunk-9t5dnjaz.js → chunk-s24qs1bn.js} +9 -9
- package/web/chunk-sd22cnjy.js +1 -0
- package/web/{chunk-ydtrc1ay.js → chunk-sd3cdqcm.js} +2 -2
- package/web/{chunk-rykfak98.js → chunk-sf101c23.js} +2 -2
- package/web/{chunk-1gbd61z0.js → chunk-sfq6cw45.js} +2 -2
- package/web/chunk-svqj4az8.js +1 -0
- package/web/chunk-t7jwyvvr.js +1 -0
- package/web/{chunk-rvrf0f3h.js → chunk-tcp77cp2.js} +2 -2
- package/web/chunk-tf18d2dk.css +1 -0
- package/web/chunk-thbqwq6b.js +1 -0
- package/web/chunk-v0g4cqc1.js +4 -0
- package/web/chunk-vhzys0rr.js +292 -0
- package/web/chunk-vnt34mkb.js +1 -0
- package/web/chunk-vqfz99ff.js +1 -0
- package/web/chunk-vttgyb5v.js +2 -0
- package/web/chunk-x7sb3bwf.js +370 -0
- package/web/chunk-xce8n339.js +1 -0
- package/web/{chunk-kwccs9f6.js → chunk-xk1t58c4.js} +12 -12
- package/web/chunk-xsrvw7dt.js +4 -0
- package/web/chunk-xtss82z2.js +1 -0
- package/web/{chunk-2j4m0bh1.js → chunk-y7jq61nv.js} +2 -2
- package/web/{chunk-1eg9sbbt.js → chunk-ybw6vgf6.js} +2 -2
- package/web/{chunk-ybrf9mhz.js → chunk-yvgs6bm3.js} +4 -4
- package/web/{chunk-b53bfkys.js → chunk-z4aj066q.js} +1 -1
- package/web/chunk-zazs8p6c.js +1 -0
- package/web/{chunk-aqfpnhmt.js → chunk-zc1mk10n.js} +19 -19
- package/web/{chunk-d11v5s7w.js → chunk-zqht0jzx.js} +6 -6
- package/web/{chunk-pz9ps2jm.js → chunk-zz397b0v.js} +12 -12
- package/web/index.html +1 -1
- package/worker.js +1 -1
- package/chunk-06hdzq5n.js +0 -2
- package/chunk-5dfbezv9.js +0 -2
- package/chunk-5x1sankd.js +0 -3753
- package/chunk-71h08f4g.js +0 -2
- package/chunk-7nzhdrv9.js +0 -2
- package/chunk-7q51n619.js +0 -2
- package/chunk-9mmz6wt3.js +0 -2
- package/chunk-bpw6q7g0.js +0 -3
- package/chunk-fvn32nzj.js +0 -478
- package/chunk-n6e43rvk.js +0 -3
- package/chunk-ry0z4ev6.js +0 -2
- package/chunk-vkpvcxjr.js +0 -2
- package/web/chunk-0rmkpsgp.js +0 -1
- package/web/chunk-0s80zw00.js +0 -1
- package/web/chunk-0xkyryrq.js +0 -1
- package/web/chunk-2s0bmrkv.js +0 -39
- package/web/chunk-2z1rwr28.js +0 -2
- package/web/chunk-344bq59c.js +0 -89
- package/web/chunk-3t0211rw.js +0 -1
- package/web/chunk-44rmrmcn.js +0 -1
- package/web/chunk-4bzqrwr0.js +0 -1139
- package/web/chunk-4jmazh6x.js +0 -370
- package/web/chunk-4re74xwm.js +0 -140
- package/web/chunk-4rm1vy7w.js +0 -1
- package/web/chunk-59kqahb3.js +0 -1
- package/web/chunk-5qtyq3ce.js +0 -292
- package/web/chunk-5z4jcqct.js +0 -200
- package/web/chunk-5z6x2n5h.js +0 -1
- package/web/chunk-6beqrmtq.js +0 -1
- package/web/chunk-6f5ke0x9.js +0 -1
- package/web/chunk-6xaqxcq8.js +0 -1
- package/web/chunk-7q6wvv2x.js +0 -1
- package/web/chunk-7qsa4p8h.js +0 -1
- package/web/chunk-8nja0ygy.js +0 -1
- package/web/chunk-8y64fkpz.js +0 -24
- package/web/chunk-9ad7v7bm.js +0 -8
- package/web/chunk-9dzxv335.js +0 -4
- package/web/chunk-a497tykb.js +0 -70
- package/web/chunk-b6k9w215.js +0 -2
- package/web/chunk-cjfssg3m.js +0 -2
- package/web/chunk-cqp1d4p0.js +0 -1
- package/web/chunk-dy2gm1fs.js +0 -1
- package/web/chunk-e0zre35a.js +0 -1
- package/web/chunk-e9twvs9n.js +0 -3
- package/web/chunk-f2kgtyfp.js +0 -1
- package/web/chunk-f8bn5tzf.js +0 -1
- package/web/chunk-f91wzwtk.js +0 -1
- package/web/chunk-fdp9bsj7.js +0 -1
- package/web/chunk-g1ev11wx.js +0 -1
- package/web/chunk-gmzqdm7v.js +0 -1
- package/web/chunk-hfaffkrh.js +0 -1
- package/web/chunk-j2vt8c8v.js +0 -1
- package/web/chunk-ka3q31t1.js +0 -1
- package/web/chunk-khxcn8tt.js +0 -106
- package/web/chunk-kqqmp1am.js +0 -1
- package/web/chunk-m2d1sp30.js +0 -1
- package/web/chunk-nbgqbxcy.js +0 -1
- package/web/chunk-ncpnpe9w.js +0 -99
- package/web/chunk-ne0v8mfb.js +0 -2
- package/web/chunk-ngx2cp8x.js +0 -2
- package/web/chunk-nxcgf7ec.js +0 -1
- package/web/chunk-p0kvmf28.js +0 -2
- package/web/chunk-p3k7m5nr.js +0 -1
- package/web/chunk-pggaffrh.js +0 -169
- package/web/chunk-pxe3vna4.js +0 -1
- package/web/chunk-qh15dxav.css +0 -1
- package/web/chunk-qpmbxhh6.js +0 -1
- package/web/chunk-r0rctnxz.js +0 -1
- package/web/chunk-rn3dnqm8.js +0 -1
- package/web/chunk-rtf2zzzv.js +0 -1
- package/web/chunk-srrfphes.js +0 -1
- package/web/chunk-tdr6x2xc.js +0 -1
- package/web/chunk-tncvg1nn.js +0 -1
- package/web/chunk-vyp0ns1f.js +0 -2
- package/web/chunk-wvdehm9y.js +0 -303
- package/web/chunk-x7ahcpj7.js +0 -1
- package/web/chunk-y38bf0wm.js +0 -1
- package/web/chunk-y56aaba5.js +0 -2
- package/web/chunk-ye58t45p.js +0 -4
- package/web/chunk-z1h20s8c.js +0 -78
- package/web/chunk-zj4q9jth.js +0 -36
- package/web/chunk-zj5k94dk.js +0 -40
- package/web/chunk-zqch0sc8.js +0 -30
- package/web/install.ps1 +0 -91
- package/web/install.sh +0 -177
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h,o,i,r,y,t,n,_,s,Z,yt,vt,Wt,be,me,ae,de,xt,st,te,an,Q}from"./chunk-qmbgb79a.js";var je=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],ge=s("key-round",je);function xe(e){let d=[],g="",b,N=!1;for(let u=0;u<e.length;u++){let c=e[u];if(b)if(c===b)b=void 0;else if(c==="\\"&&b==='"'&&u+1<e.length)g+=e[++u];else g+=c;else if(c==='"'||c==="'")b=c,N=!0;else if(c==="\\"&&u+1<e.length)g+=e[++u],N=!0;else if(/\s/.test(c)){if(N||g)d.push(g);g="",N=!1}else g+=c,N=!0}if(N||g)d.push(g);return d}function le(e){return e.map((d)=>d===""||/[\s"'\\]/.test(d)?`"${d.replace(/(["\\])/g,"\\$1")}"`:d).join(" ")}var ve="size-4 cursor-pointer rounded border-line text-accent accent-accent focus-visible:outline-2 focus-visible:outline-accent",Te={connected:{label:"已连接",dot:"bg-success"},idle:{label:"待连接",dot:"bg-faint"},disabled:{label:"已停用",dot:"bg-faint"},failed:{label:"连接失败",dot:"bg-danger"},needs_auth:{label:"需要认证",dot:"bg-warning"}};function Y(e){return e.type==="local"?le(e.command):e.url}function he({info:e,tools:d=!1}){let g=Te[e.status.status];return n("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs text-dim",children:[t("span",{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${g.dot}`}),t("span",{className:d?void 0:"hidden @md/panel:inline",children:g.label}),d&&e.status.status==="connected"&&n("span",{className:"text-faint",children:["· ",e.toolCount," 个工具"]})]})}function $e(e){if(typeof e!=="object"||e===null||!("type"in e))return"any";let d=e.type;if(typeof d==="string")return d;if(Array.isArray(d))return d.filter((g)=>typeof g==="string").join(" | ")||"any";return"any"}function ye(e){let{Button:d,CopyButton:g,Dialog:b,StatusChip:N,confirm:u,style:c,useTheme:k}=_();k();let{info:a,connection:I}=e,[m,q]=r(),[G,K]=r(),[S,j]=r(!1),W=a.status.status==="connected",z=a.status.status==="needs_auth",V=a.status.status==="failed",A=a.config.type==="remote"&&Boolean(a.config.oauth);o(()=>{function p(x){if(x&&x!==a.name)return;let J=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"";I.request(`/api/mcp/${encodeURIComponent(a.name)}/connect${J}`,{method:"POST"}).then((ne)=>e.onChanged(ne)).catch(()=>{})}function f(x){if(x.data?.type==="mcp-oauth-success")p(x.data.name)}function D(x){if(x.key==="basalt-mcp-oauth-event"&&x.newValue)try{let J=JSON.parse(x.newValue);p(J.name)}catch(J){}}window.addEventListener("message",f),window.addEventListener("storage",D);let R;if("BroadcastChannel"in window)R=new BroadcastChannel("basalt-mcp-oauth"),R.onmessage=(x)=>{if(x.data?.type==="mcp-oauth-success")p(x.data.name)};return()=>{window.removeEventListener("message",f),window.removeEventListener("storage",D),R?.close()}},[I,a.name,a.projectID,e]),o(()=>{if(a.status.status!=="connected")return;let p=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"";I.request(`/api/mcp/${encodeURIComponent(a.name)}/tools${p}`).then((f)=>{if(Array.isArray(f))q(f),K(void 0)}).catch((f)=>{K(f instanceof Error?f.message:"获取工具失败")})},[I,a.name,a.projectID,a.status.status]);async function O(p){j(!0);try{let f=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"",D=await I.request(`/api/mcp/${encodeURIComponent(a.name)}/${p}${f}`,{method:"POST"});e.onChanged(D)}catch{}finally{j(!1)}}async function U(){j(!0);try{let p=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"",f=a.status.status==="needs_auth"?a.status.authorizationUrl:void 0;if(!f)f=(await I.request(`/api/mcp/${encodeURIComponent(a.name)}/oauth/authorize${p}`,{method:"POST"})).authorizationUrl;if(f)window.open(f,"_blank","width=600,height=700")}catch(p){K(p instanceof Error?p.message:"获取授权链接失败")}finally{j(!1)}}async function ee(){j(!0);try{let p=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"",f=await I.request(`/api/mcp/${encodeURIComponent(a.name)}/oauth/clear${p}`,{method:"POST"});e.onChanged(f)}finally{j(!1)}}async function E(){if(!await u({title:`删除 ${a.name}?`,description:"删除后将断开连接并不再向会话提供其工具。",action:"删除",danger:!0}))return;j(!0);try{let f=a.projectID?`?projectID=${encodeURIComponent(a.projectID)}`:"";await I.request(`/api/mcp/${encodeURIComponent(a.name)}${f}`,{method:"DELETE"}),e.onChanged(),e.onClose()}finally{j(!1)}}let T=a.config,l=Y(T),C="error"in a.status?a.status.error:void 0,M=m?.length??a.toolCount??0;return t(b,{open:!0,className:"bg-panel shadow-float",onOpenChange:(p)=>{if(!p&&!S)e.onClose()},title:n("div",{className:"flex flex-wrap items-center gap-3",children:[t("div",{className:"flex size-8 items-center justify-center rounded-[10px] border border-accent/20 bg-accent-soft text-accent",children:T.type==="local"?t(st,{className:"size-4"}):t(be,{className:"size-4"})}),t("span",{className:"font-serif text-lg font-semibold tracking-tight text-ink",children:a.name}),W?t(N,{tone:"success",pulse:!0,children:"已连接"}):z?t(N,{tone:"warning",pulse:!0,children:"需要授权"}):V?t(N,{tone:"danger",children:"连接失败"}):a.status.status==="disabled"?t(N,{tone:"neutral",children:"已停用"}):t(N,{tone:"neutral",children:"未连接"})]}),description:n("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"flex min-w-0 max-w-full items-center gap-1 rounded-lg border border-line bg-raised/60 py-0.5 pr-1 pl-2.5 font-mono text-[11.5px] text-ink",children:[t("span",{className:"min-w-0 truncate",title:l,children:l}),t(g,{text:l,label:"复制地址",size:"icon-xs",className:"shrink-0 text-dim hover:text-ink"})]}),t("span",{className:"rounded-lg border border-line px-2 py-1 text-[11px] leading-none text-dim",children:T.type==="local"?"本地命令":"远程 HTTP"}),A&&n("span",{className:c("control.badgeAccent","gap-1 rounded-lg border border-accent/25 px-2 py-1"),children:[t(xt,{className:"size-3"}),"OAuth 2.0"]})]}),size:"lg",footer:n("div",{className:"flex w-full items-center justify-between gap-2 max-sm:flex-col",children:[n("div",{className:"flex items-center gap-1 max-sm:w-full",children:[A&&t(d,{type:"button",variant:"ghost",onClick:ee,disabled:S,title:"清除已保存的 OAuth 凭据",children:"清除凭据"}),t(d,{type:"button",variant:"danger-ghost",size:"icon-sm","aria-label":"删除服务器",onClick:E,disabled:S,title:"删除服务器",children:t(te,{className:"size-4"})})]}),n("div",{className:"flex items-center gap-2 max-sm:w-full max-sm:justify-end",children:[t(d,{type:"button",variant:"ghost",onClick:e.onEdit,disabled:S,children:"编辑配置"}),!z&&t(d,{type:"button",variant:"secondary",onClick:()=>O(W?"disconnect":"connect"),disabled:S,children:S?"处理中...":W?"断开连接":"立即连接"}),t(d,{type:"button",variant:"primary",onClick:e.onClose,children:"完成"})]})]}),children:n("div",{className:"space-y-6 pt-1",children:[z&&t("div",{className:"relative overflow-hidden rounded-2xl border border-warning/30 bg-[radial-gradient(120%_140%_at_0%_0%,color-mix(in_oklch,var(--color-warning)_16%,transparent),transparent_65%)] p-5",children:n("div",{className:"flex items-start gap-4 max-sm:flex-col",children:[t("div",{className:"relative flex size-11 shrink-0 items-center justify-center rounded-xl border border-warning/30 bg-panel text-warning shadow-[0_0_28px_-4px_color-mix(in_oklch,var(--color-warning)_55%,transparent)]",children:t(ge,{className:"size-5"})}),n("div",{className:"min-w-0 flex-1 space-y-1.5",children:[t("h4",{className:"text-sm font-semibold text-ink",children:"授权后即可使用此服务器"}),t("p",{className:"text-[13px] leading-relaxed text-dim",children:"该端点要求 OAuth 2.0 身份许可。在浏览器中完成授权后,令牌会自动保存并载入全部工具。"}),C&&t("p",{className:"line-clamp-2 break-words font-mono text-[11.5px] text-faint",title:C,children:C})]}),n(d,{type:"button",variant:"primary",onClick:U,disabled:S,className:"shrink-0",children:[t(Wt,{className:"mr-1.5 size-3.5"}),S?"正在拉起授权...":"前往授权"]})]})}),V&&n("div",{className:c("callout.base",c("callout.danger"),"gap-3 rounded-2xl p-4"),children:[t(yt,{className:"mt-0.5 size-4 shrink-0 text-danger"}),n("div",{className:"min-w-0 space-y-1",children:[t("h4",{className:"text-sm font-medium text-ink",children:"连接失败"}),t("p",{className:"font-mono text-[11.5px] leading-relaxed break-words text-dim",children:C})]})]}),n("section",{className:"space-y-3",children:[n("div",{className:"flex items-baseline justify-between gap-3 px-0.5",children:[n("h4",{className:"flex items-center gap-2 text-[13px] font-medium text-ink",children:["可用工具",t("span",{className:"rounded-full bg-raised px-1.5 py-0.5 font-mono text-[11px] leading-none text-dim",children:M})]}),t("span",{className:"text-[11.5px] text-faint",children:"对所有会话可用"})]}),G?t("div",{className:c("callout.base",c("callout.danger"),"text-xs leading-relaxed break-words"),children:G}):!W?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[t("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:t(an,{className:"size-4.5"})}),t("p",{className:"text-[13px] font-medium text-dim",children:z?"等待授权":"尚未连接"}),t("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:z?"授权完成后会自动连接并列出工具。":"连接服务器后,这里会列出它提供的全部工具。"})]}):!m?t("div",{role:"status","aria-label":"正在获取工具列表",className:"grid gap-2",children:[0,1,2].map((p)=>n("div",{className:"animate-pulse space-y-2.5 rounded-xl border border-line p-3.5",children:[t("div",{className:"h-3.5 w-32 rounded bg-raised"}),t("div",{className:"h-3 w-4/5 rounded bg-raised/70"})]},p))}):m.length===0?n("div",{className:c("surface.emptyDashed","gap-2 py-10"),children:[t("div",{className:"flex size-10 items-center justify-center rounded-full bg-raised text-faint",children:t(an,{className:"size-4.5"})}),t("p",{className:"text-[13px] font-medium text-dim",children:"没有可用工具"}),t("p",{className:"max-w-xs text-xs leading-relaxed text-faint",children:"已连接成功,但该服务器没有声明任何工具。"})]}):t("ul",{className:"grid gap-2",children:m.map((p)=>{let f=p.inputSchema?.properties??{},D=p.inputSchema?.required??[],R=Object.entries(f);return n("li",{className:c("surface.subtle","border-line bg-raised/30 p-3.5 transition-colors hover:border-line-strong hover:bg-raised/60"),children:[t("span",{className:"font-mono text-[13px] font-medium break-all text-accent",children:p.name}),p.description&&t("p",{className:"mt-1.5 text-[13px] leading-relaxed break-words text-dim",children:p.description}),R.length>0&&t("div",{className:"mt-3 flex flex-wrap gap-1.5",children:R.map(([x,J])=>n("span",{title:D.includes(x)?"必填参数":"可选参数",className:"inline-flex items-center gap-1 rounded-md border border-line bg-panel px-1.5 py-1 font-mono text-[11px] leading-none",children:[t("span",{className:"text-ink",children:x}),D.includes(x)&&t("span",{className:"text-warning",children:"*"}),t("span",{className:"text-faint",children:$e(J)})]},x))})]},p.name)})})]})]})})}var De=/^[A-Za-z0-9_-]{1,64}$/;function H(e){return t("span",{className:"truncate text-xs text-faint",children:e.children})}function Ne(e){let{pairs:d,onChange:g,InputComponent:b}=e,N=(u,c)=>g(d.map((k,a)=>a===u?{...k,...c}:k));return n("div",{className:"space-y-2",children:[n("div",{className:"flex min-h-7 items-center gap-2",children:[t("span",{className:"shrink-0 text-[13px] font-medium text-dim",children:e.label}),t(H,{children:e.tip}),n("button",{type:"button",className:"ml-auto inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-lg px-2 text-xs font-medium text-dim transition-colors hover:bg-raised hover:text-ink",onClick:()=>g([...d,{key:"",value:"",saved:!1}]),children:[t(me,{className:"size-3.5"}),"添加"]})]}),d.map((u,c)=>n("div",{className:"flex min-w-0 items-center gap-1.5",children:[t(b,{"aria-label":`${e.keyLabel} ${c+1}`,placeholder:e.keyLabel,value:u.key,readOnly:u.saved,onChange:(k)=>N(c,{key:k.target.value}),className:"min-w-0 flex-[2] font-mono text-xs"}),t(b,{"aria-label":`${e.keyLabel} ${u.key||c+1} 的值`,type:"password",autoComplete:"off",placeholder:u.saved?"已保存,留空保持不变":"值",value:u.value,onChange:(k)=>N(c,{value:k.target.value}),className:"min-w-0 flex-[3] font-mono text-xs"}),t("button",{type:"button","aria-label":`删除 ${u.key||"该项"}`,className:"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-faint transition-colors hover:bg-danger/10 hover:text-danger",onClick:()=>g(d.filter((k,a)=>a!==c)),children:t(Q,{className:"size-4"})})]},c))]})}function Ce(e){return Object.keys(e??{}).map((d)=>({key:d,value:"",saved:!0}))}function we(e){let{Button:d,Segmented:g,Dialog:b,Form:N,Field:u,Input:c,Switch:k,style:a,useTheme:I}=_();I();let{existing:m}=e,[q,G]=r(m?.config.type??"local"),[K,S]=r(m?.name??""),[j,W]=r(m?.config.type==="local"?le(m.config.command):""),[z,V]=r(m?.config.type==="remote"?m.config.url:""),[A,O]=r(Ce(m?.config.type==="local"?m.config.environment:void 0)),[U,ee]=r(Ce(m?.config.type==="remote"?m.config.headers:void 0)),E=m?.config.type==="remote"?m.config.oauth:void 0,[T,l]=r(Boolean(E)),[C,M]=r(typeof E==="object"&&E.clientId?E.clientId:""),[p,f]=r(""),[D,R]=r(typeof E==="object"&&E.scope?E.scope:""),[x,J]=r(m?.config.defer??"default"),[ne,ke]=r(m?.config.timeout!==void 0?String(m.config.timeout):""),[ie,Ie]=r(m?.config.defer!==void 0||m?.config.timeout!==void 0),[pe,X]=r(),[re,ue]=r(!1);async function Se(v){v.preventDefault(),X(void 0);let w=K.trim();if(!m&&!De.test(w)){X("名称只能包含英文字母、数字、下划线与中划线,长度 1-64");return}if(!m&&e.taken.includes(w)){X("同名服务器已存在");return}let se=ne.trim()?Number.parseInt(ne.trim(),10):void 0;if(se!==void 0&&(!Number.isFinite(se)||se<=0)){X("超时时间须为大于 0 的毫秒数");return}let ce;if(q==="local"){let L=xe(j.trim());if(!L.length){X("请输入启动命令");return}let F={};for(let B of A){let P=B.key.trim();if(!P)continue;if(!B.saved||B.value)F[P]=B.value}ce={type:"local",command:L,environment:Object.keys(F).length?F:void 0,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:se}}else{let L=z.trim();try{let P=new URL(L);if(P.protocol!=="http:"&&P.protocol!=="https:")throw Error("bad protocol")}catch{X("请输入合法的 HTTP 或 HTTPS 地址");return}let F={};for(let P of U){let oe=P.key.trim();if(!oe)continue;if(!P.saved||P.value)F[oe]=P.value}let B;if(T){let P=C.trim(),oe=p.trim(),fe=D.trim();if(P||oe||fe)B={clientId:P||void 0,clientSecret:oe||void 0,scope:fe||void 0};else B=!0}else B=!1;ce={type:"remote",url:L,headers:Object.keys(F).length?F:void 0,oauth:B,enabled:m?m.config.enabled:!0,defer:x==="default"?void 0:x,timeout:se}}ue(!0);try{let L=m?.name??w,F=m?m.projectID:e.projectID,B=F?`?projectID=${encodeURIComponent(F)}`:"";await e.connection.request(`/api/mcp/${encodeURIComponent(L)}${B}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(ce)}),e.onSaved()}catch(L){X(L instanceof Error?L.message:"保存失败")}finally{ue(!1)}}return t(b,{open:!0,onOpenChange:(v)=>{if(!v&&!re)e.onClose()},title:m?`编辑 ${m.name}`:"添加 MCP 服务器",size:"lg",footer:n("div",{className:"flex w-full justify-end gap-2.5",children:[t(d,{type:"button",variant:"ghost",onClick:e.onClose,disabled:re,className:"min-w-20",children:"取消"}),t(d,{type:"submit",form:"mcp-server-form",variant:"primary",disabled:re,className:"min-w-24",children:re?"保存中...":"保存"})]}),children:n(N,{id:"mcp-server-form",onSubmit:Se,children:[t(g,{value:q,onChange:(v)=>G(v),className:"w-full [&>button]:flex-1",options:[{value:"local",label:"本地(标准输入输出)"},{value:"remote",label:"远程(HTTP / SSE)"}]}),!m&&t(u,{label:"名称",aside:t(H,{children:"唯一标识,如 postgres"}),children:(v)=>t(c,{id:v,value:K,onChange:(w)=>S(w.target.value),placeholder:"postgres",className:"font-mono text-xs"})}),q==="local"?n(y,{children:[t(u,{label:"启动命令",aside:t(H,{children:"完整命令及参数"}),children:(v)=>t(c,{id:v,value:j,onChange:(w)=>W(w.target.value),placeholder:"npx -y @modelcontextprotocol/server-postgres ...",className:"font-mono text-xs"})}),t(Ne,{label:"环境变量",tip:"启动进程时注入",keyLabel:"变量名",pairs:A,onChange:O,InputComponent:c})]}):n(y,{children:[t(u,{label:"服务地址",aside:t(H,{children:"HTTP / HTTPS 端点"}),children:(v)=>t(c,{id:v,value:z,onChange:(w)=>V(w.target.value),placeholder:"https://example.com/mcp",className:"font-mono text-xs"})}),t(Ne,{label:"请求头",tip:"随每次请求发送",keyLabel:"头字段",pairs:U,onChange:ee,InputComponent:c}),n("div",{className:"flex items-center justify-between gap-4",children:[n("div",{className:"min-w-0",children:[t("span",{className:"block text-[13px] font-medium text-dim",children:"OAuth 2.0 认证"}),t("span",{className:"block truncate text-xs text-faint",children:"自动发现授权端点,使用 PKCE 并刷新令牌"})]}),t(k,{checked:T,onCheckedChange:l,label:"启用 OAuth 2.0"})]}),T&&n(y,{children:[t(u,{label:"Client ID",aside:t(H,{children:"留空自动动态注册(DCR)"}),children:(v)=>t(c,{id:v,value:C,onChange:(w)=>M(w.target.value),placeholder:"留空自动动态注册",className:"font-mono text-xs"})}),t(u,{label:"Client Secret",aside:t(H,{children:"留空保持不变"}),children:(v)=>t(c,{id:v,type:"password",autoComplete:"off",value:p,onChange:(w)=>f(w.target.value),placeholder:"••••••••",className:"font-mono text-xs"})}),t(u,{label:"Scope",aside:t(H,{children:"选填授权范围"}),children:(v)=>t(c,{id:v,value:D,onChange:(w)=>R(w.target.value),placeholder:"repo read:org",className:"font-mono text-xs"})})]})]}),n("div",{className:"space-y-3 border-t border-line/60 pt-3",children:[n("button",{type:"button","aria-expanded":ie,className:"flex w-full cursor-pointer items-center gap-1.5 text-[13px] font-medium text-dim transition-colors hover:text-ink",onClick:()=>Ie(!ie),children:[t(vt,{className:`size-3.5 transition-transform ${ie?"rotate-90":""}`}),"高级设置",t("span",{className:"truncate text-xs font-normal text-faint",children:"加载时机、超时"})]}),ie&&n("div",{className:"grid grid-cols-2 gap-3 max-sm:grid-cols-1",children:[t(u,{label:"加载时机",aside:t(H,{children:"延迟 = 按需加载"}),children:()=>t(g,{value:x,onChange:(v)=>J(v),className:"w-full [&>button]:flex-1",options:[{value:"default",label:"默认"},{value:"defer",label:"延迟"},{value:"always",label:"常驻"}]})}),t(u,{label:"超时(毫秒)",aside:t(H,{children:"留空用默认"}),children:(v)=>t(c,{id:v,value:ne,onChange:(w)=>ke(w.target.value),placeholder:"默认",className:"font-mono text-xs"})})]})]}),pe&&n("div",{role:"alert",className:a("callout.base",a("callout.danger"),"px-3 py-2.5 text-xs"),children:[t(Z,{className:"mt-0.5 size-3.5 shrink-0"}),t("span",{className:"min-w-0 break-words",children:pe})]})]})})}function tt({connection:e}){let{Button:d,Input:g,style:b,useTheme:N}=_();N();let[u,c]=r(""),[k,a]=r(),[I,m]=r(),[q,G]=r(!1),[K,S]=r(),[j,W]=r(!1),z=i(!1),[V,A]=r(),O=i(0),U=h(async()=>{let l=++O.current;G(!0);try{let C=await e.request("/api/mcp");if(l!==O.current)return;a(C),m(void 0)}catch(C){if(l===O.current)m(C instanceof Error?C.message:"读取失败")}finally{if(l===O.current)G(!1)}},[e]);o(()=>(U(),()=>{O.current++}),[U]);async function ee(l,C){if(z.current)return;z.current=!0,W(!0);let M=O.current;try{let p=l.projectID?`?projectID=${encodeURIComponent(l.projectID)}`:"",f=await e.request(`/api/mcp/${encodeURIComponent(l.name)}${p}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({...l.config,enabled:C})});if(M===O.current)a((D)=>D?.map((R)=>R.name===f.name&&R.projectID===f.projectID?f:R))}finally{z.current=!1,W(!1)}}let E=k?.filter((l)=>`${l.name} ${Y(l.config)}`.toLowerCase().includes(u.trim().toLowerCase())),T=k?.find((l)=>l.name===K);return n("div",{className:"min-w-0 space-y-6",children:[n("section",{className:"min-w-0",children:[n("div",{className:"mb-2.5 flex flex-wrap items-end justify-between gap-3 px-0.5",children:[n("div",{className:"min-w-0 flex-1 basis-48",children:[t("h2",{className:b("settings.groupTitle"),children:"MCP 服务器"}),t("p",{className:b("settings.groupDesc"),children:"外部工具与数据源管理"})]}),n("div",{className:"flex gap-2",children:[t(d,{variant:"ghost",disabled:q,onClick:U,className:"h-9 px-2.5 text-xs",children:t(ae,{className:`size-3.5 ${q?"animate-spin":""}`})}),n(d,{variant:"secondary",onClick:()=>A({}),className:"h-9 px-2.5 text-xs",children:[t(me,{className:"size-3.5 mr-1"}),"添加服务器"]})]})]}),I&&n("div",{role:"alert",className:b("callout.base",b("callout.danger"),"mb-3 flex-wrap items-center justify-between"),children:[n("p",{className:"min-w-0 flex-1 break-words text-sm text-danger",children:["无法读取 MCP 服务器:",I]}),t(d,{disabled:q,onClick:U,children:"重试"})]}),n("div",{className:"relative mb-3 min-w-0",children:[t(de,{"aria-hidden":!0,className:"pointer-events-none absolute top-3 left-3 size-4 text-faint"}),t(g,{type:"search","aria-label":"搜索 MCP 服务器",placeholder:"搜索服务器",value:u,onChange:(l)=>c(l.target.value),className:"h-10 min-w-0 pl-9"})]}),t("div",{className:b("settings.groupBox"),children:!k?t("div",{role:"status","aria-label":"正在加载",className:"divide-y divide-line",children:[0,1,2].map((l)=>n("div",{className:"h-16 space-y-2 px-4 py-3",children:[t("div",{className:"h-3 w-24 animate-pulse rounded bg-raised"}),t("div",{className:"h-3 w-2/3 animate-pulse rounded bg-raised"})]},l))}):E?.length===0?t("p",{className:"p-4 text-sm text-dim",children:"没有匹配的 MCP 服务器"}):t("ul",{className:"divide-y divide-line",children:E?.map((l)=>{let C=l.config.enabled===!1,M=l.scope==="file";return n("li",{className:`flex min-w-0 items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-raised/40 ${C?"opacity-55":""}`,children:[n("button",{type:"button",className:"group flex min-h-12 min-w-0 flex-1 cursor-pointer items-center gap-3 py-1 text-left focus-visible:outline-2 focus-visible:outline-accent","aria-label":`查看 ${l.name}`,disabled:M,title:M?"来自项目的 .mcp.json,只读":void 0,onClick:()=>S(l.name),children:[t("span",{"aria-hidden":!0,className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-raised text-dim",children:l.config.type==="local"?t(st,{className:"size-4"}):t(be,{className:"size-4"})}),n("span",{className:"min-w-0 flex-1",children:[t("span",{className:"block truncate text-sm font-medium text-ink",title:l.name,children:l.name}),t("span",{className:"mt-0.5 block truncate font-mono text-xs text-dim",title:Y(l.config),children:Y(l.config)})]}),t("span",{className:b("control.badge","shrink-0 text-[11px] text-dim"),children:l.scope==="project"?"项目":l.scope==="file"?".mcp.json":"全局"}),t(he,{info:l})]}),t("span",{className:"relative flex size-10 shrink-0 items-center justify-center",children:!M&&t("input",{type:"checkbox","aria-label":`启用服务器 ${l.name}`,className:ve,disabled:j||q,checked:!C,onChange:(p)=>ee(l,p.target.checked)})})]},l.name)})})})]}),T&&!V&&t(ye,{connection:e,info:T,onClose:()=>S(void 0),onEdit:()=>A({info:T}),onChanged:(l)=>l?a((C)=>C?.map((M)=>M.name===l.name?l:M)):U()},`${T.projectID}:${T.name}`),V&&t(we,{connection:e,existing:V.info,taken:(k??[]).map((l)=>l.name),onClose:()=>A(void 0),onSaved:()=>{A(void 0),U()}})]})}export{tt as McpSection};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e,a,b,l,M,P,Tt,Et,yo,gt,tn,vo,Yn,Pe,bo,Wi,At,Gi,nn,Xn}from"./chunk-pyg1mr80.js";import{J}from"./chunk-fjag6yg8.js";import{x}from"./chunk-qmbgb79a.js";function la(t,{edgePathsClass:r="edges edgePaths"}={}){let n=t.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),u=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:u,rootGroups:n}}e(la,"createLayoutElementGroups");async function D(t,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await P(t,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}e(D,"measureGroupLabel");async function ca(t,r,n){let i=await Et(t,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}e(ca,"insertMeasuredNode");function S(t,r,n){let i=t,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}e(S,"resolveNodeDir");async function k(t,r,n={}){let i=new J({multigraph:!0,compound:!0}),s=[...r.edges],o=l(),u=la(t),{edgeLabels:d,nodes:c}=u,g=new Map,h=new Map(r.nodes.map((f)=>[f.id,f])),C=r.direction,w=t.node()!=null;await Promise.all(r.nodes.map(async(f)=>{if(f.isGroup){if(w){let p=n.unwrapGroupLabels&&f.labelType!=="markdown";await D(c,f,p?Number.POSITIVE_INFINITY:void 0)}i.setNode(f.id,{...f})}else{if(w){let p=await ca(c,f,{config:o,dir:S(f,h,C)});g.set(f.id,p)}i.setNode(f.id,{...f})}}));for(let f of s){if(w&&Wi(f))await At(d,f);if(i.setEdge(f.start,f.end,{...f},f.id),!r.edges.some((E)=>E.id===f.id))r.edges.push(f)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:f}=await (x("qq5gh5zr"),import("./chunk-qq5gh5zr.js"));f(t,r)}return{graph:i,groups:u,nodeElements:g}}e(k,"createGraphWithElements");var W=new Map,m=new Map,R=new Map,Z=e(()=>{m.clear(),R.clear(),W.clear()},"clear"),v=e((t,r)=>{let n=m.get(r)||[];return a.trace("In isDescendant",r," ",t," = ",n.includes(t)),n.includes(t)},"isDescendant"),I=e((t,r)=>{let n=m.get(r)||[];if(a.info("Descendants of ",r," is ",n),a.info("Edge is ",t),t.v===r||t.w===r)return!1;if(!n)return a.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(t.v)||v(t.v,r)||v(t.w,r)||n.includes(t.w)},"edgeInCluster"),T=e((t,r,n,i)=>{a.debug("Copying children of ",t,"root",i,"data",r.node(t),i);let s=r.children(t)||[];if(t!==i)s.push(t);a.debug("Copying (nodes) clusterId",t,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)T(o,r,n,i);else{let u=r.node(o);if(a.info("cp ",o," to ",i," with parent ",t),n.setNode(o,u),i!==r.parent(o))a.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(t!==i&&o!==t)a.debug("Setting parent",o,t),n.setParent(o,t);else a.info("In copy ",t,"root",i,"data",r.node(t),i),a.debug("Not Setting parent for node=",o,"cluster!==rootId",t!==i,"node!==clusterId",o!==t);let d=r.edges(o);a.debug("Copying Edges",d),d.forEach((c)=>{a.info("Edge",c);let g=r.edge(c.v,c.w,c.name);a.info("Edge data",g,i);try{if(I(c,i))a.info("Copying as ",c.v,c.w,g,c.name),n.setEdge(c.v,c.w,g,c.name),a.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else a.info("Skipping copy of edge ",c.v,"-->",c.w," rootId: ",i," clusterId:",t)}catch(h){a.error(h)}})}a.debug("Removing node",o),r.removeNode(o)})},"copy"),B=e((t,r)=>{let n=r.children(t),i=[...n];for(let s of n)R.set(s,t),i=[...i,...B(s,r)];return i},"extractDescendants"),ee=e((t,r,n)=>{let i=t.edges().filter((c)=>c.v===r||c.w===r),s=t.edges().filter((c)=>c.v===n||c.w===n),o=i.map((c)=>({v:c.v===r?n:c.v,w:c.w===r?r:c.w})),u=s.map((c)=>({v:c.v,w:c.w}));return o.filter((c)=>u.some((g)=>c.v===g.v&&c.w===g.w))},"findCommonEdges"),Fn=e((t,r,n)=>{let i=r.children(t);if(a.trace("Searching children of id ",t,i),i.length<1)return t;let s;for(let o of i){let u=Fn(o,r,n),d=ee(r,n,u);if(u)if(d.length>0)s=u;else return u}return s},"findNonClusterChild"),L=e((t)=>{if(!W.has(t))return t;if(!W.get(t).externalConnections)return t;if(W.has(t))return W.get(t).id;return t},"getAnchorId"),to=e((t,r)=>{if(!t||r>10){a.debug("Opting out, no graph ");return}else a.debug("Opting in, graph ");t.nodes().forEach(function(n){if(t.children(n).length>0)a.debug("Cluster identified",n," Replacement id in edges: ",Fn(n,t,n)),m.set(n,B(n,t)),W.set(n,{id:Fn(n,t,n),clusterData:t.node(n)})}),t.nodes().forEach(function(n){let i=t.children(n),s=t.edges();if(i.length>0)a.debug("Cluster identified",n,m),s.forEach((o)=>{let u=v(o.v,n),d=v(o.w,n);if(u^d)a.debug("Edge: ",o," leaves cluster ",n),a.debug("Descendants of XXX ",n,": ",m.get(n)),W.get(n).externalConnections=!0});else a.debug("Not a cluster ",n,m)});for(let n of W.keys()){let i=W.get(n).id,s=t.parent(i);if(s!==n&&W.has(s)&&!W.get(s).externalConnections)W.get(n).id=s;let o=t.edges().some((u)=>u.v===n);if(i&&W.get(n)?.externalConnections&&o&&_(t,i,n)){let u=te(t,n,t.parent(i));if(u)W.get(n).id=u}}t.edges().forEach(function(n){let i=t.edge(n);a.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),a.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(t.edge(n)));let{v:s,w:o}=n;if(a.debug("Fix XXX",W,"ids:",n.v,n.w,"Translating: ",W.get(n.v)," --- ",W.get(n.w)),W.get(n.v)||W.get(n.w)){if(a.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=L(n.v),o=L(n.w),t.removeEdge(n.v,n.w,n.name),s!==n.v){let u=t.parent(s);W.get(u).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let u=t.parent(o);W.get(u).externalConnections=!0,i.toCluster=n.w}a.debug("Fix Replacing with XXX",s,o,n.name),t.setEdge(s,o,i,n.name)}}),A(t,0),a.trace(W)},"adjustClustersAndEdges"),A=e((t,r)=>{if(r>10){a.error("Bailing out");return}let n=t.nodes(),i=!1;for(let s of n){let o=t.children(s);i=i||o.length>0}if(!i){a.debug("Done, no node has children",t.nodes());return}a.debug("Nodes = ",n,r);for(let s of n)if(a.debug("Extracting node",s,W,W.has(s)&&!W.get(s).externalConnections,!t.parent(s),t.node(s),t.children("D")," Depth ",r),!W.has(s))a.debug("Not a cluster",s,r);else if(!W.get(s).externalConnections&&t.children(s)&&t.children(s).length>0){a.debug("Cluster without external connections, without a parent and with children",s,r);let u=t.graph().rankdir==="TB"?"LR":"TB";if(W.get(s)?.clusterData?.dir)u=W.get(s).clusterData.dir,a.debug("Fixing dir",W.get(s).clusterData.dir,u);let d=new J({multigraph:!0,compound:!0}).setGraph({rankdir:u,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});T(s,t,d,s),t.setNode(s,{clusterNode:!0,id:s,clusterData:W.get(s).clusterData,label:W.get(s).label,graph:d})}else a.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!W.get(s).externalConnections," no parent: ",!t.parent(s)," children ",t.children(s)&&t.children(s).length>0,t.children("D"),r),a.debug(W);n=t.nodes(),a.debug("New list of nodes",n);for(let s of n){let o=t.node(s);if(a.debug(" Now next level",s,o),o?.clusterNode)A(o.graph,r+1)}},"extractor"),X=e((t,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=t.children(i),o=X(t,s);n=[...n,...o]}),n},"sorter"),ua=e((t)=>X(t,t.children()),"sortNodesByHierarchy"),_=e((t,r,n)=>{let i=t.parent(r);while(i&&i!==n){let s=W.get(i);if(s&&!s.externalConnections)return!0;i=t.parent(i)}return!1},"isNodeInExtractableCluster"),te=e((t,r,n)=>{let i=t.children(r)??[];for(let s of i){if(s===n||v(s,n))continue;let o=Fn(s,t,r);if(!o)continue;if(!_(t,o,r))return o}return null},"findSafeAnchorNode");function cr({prepareLayout:t,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let u=r??O;return e(async function(c,g,h,C){let w=g.select("g");(h?.insertMarkers??Xn)(w,c.markers,c.type,c.diagramId),G();let f={element:w,helpers:h,options:C};f.preparedLayout=await t?.(c,f);let p=await u(c,f),E=await n(c,f),N={...f,measure:p};if(i)await i(c,N,E);else await F(c,N,o);await s?.(c,N,E)},"render")}e(cr,"createCommonLayoutRenderer");function G(){yo(),bo(),vo(),Z()}e(G,"clearLayoutRenderState");async function O(t,{element:r},n){return await k(r,t,n)}e(O,"defaultMeasureLayout");async function F(t,r,n={}){let{measure:i}=r,{groups:s}=i;for(let u of n.getNodes?.(t,r)??t.nodes){if(n.skipNode?.(u,r))continue;await j(s,u,r,n)}let o=z(t.nodes);for(let u of t.edges){if(V(u,n))continue;await Y(s,u,o,t,n,r)}}e(F,"paintLayoutData");async function j(t,r,n,i){if(r.clusterNode)gt(r);else if(H(r,n,i))await tn(t.clusters,r);else gt(r)}e(j,"paintLayoutNode");function H(t,r,n){return t.isGroup===!0&&(n.isCluster?.(t,r)??!0)}e(H,"shouldPaintAsCluster");function z(t){let r=new Map;for(let n of t)if(n?.id)r.set(n.id,n);return r}e(z,"buildNodeLookup");function V(t,r){return t.isLayoutOnly||Boolean(r.skipEdge?.(t))}e(V,"shouldSkipPaintEdge");async function Y(t,r,n,i,s,o){let u=nn(t.edgePaths,{...r},s.clusterDb??new Map,i.type,y(r.start,r,n,o,s),y(r.end,r,n,o,s),i.diagramId,q(r,s),i.layoutAlgorithm);if(Wi(r)){if(!Yn.has(r.id))await At(t.edgeLabels,r);K(r,u)}}e(Y,"paintLayoutEdge");function y(t,r,n,i,s){return s.getEdgeNode?.(t,r,i)??(t?n.get(t)??{}:{})}e(y,"getRenderedNode");function q(t,r){return typeof r.skipIntersect==="function"?r.skipIntersect(t):r.skipIntersect??!1}e(q,"shouldSkipIntersect");function K(t,r){let n=r?.updatedPath??r?.originalPath,i=b(),{subGraphTitleTotalMargin:s}=Tt({flowchart:i.flowchart??{}});if(t.label){let o=Yn.get(t.id),{x:u,y:d}=Gi(t,r);o.attr("transform",`translate(${u}, ${d+s/2})`)}for(let[o,u]of[["startLeft",t.startLabelLeft],["startRight",t.startLabelRight],["endLeft",t.endLabelLeft],["endRight",t.endLabelRight]])if(u){let{x:d,y:c}=Q(t,o,n);Pe.get(t.id)[o].attr("transform",`translate(${d}, ${c})`)}}e(K,"positionRenderedEdgeLabel");var ne={startLeft:"start_left",startRight:"start_right",endLeft:"end_left",endRight:"end_right"};function Q(t,r,n){let i=t.terminalLabelCenters?.[r];if(i)return{...i};if(!n)return{x:t.x,y:t.y};let s=r.startsWith("start")?t.arrowTypeStart:t.arrowTypeEnd;return M.calcTerminalLabelPosition(s?10:0,ne[r],n)}e(Q,"terminalLabelTranslate");
|
|
2
|
+
export{la,ca,W,Fn,to,ua,cr};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import{G}from"./chunk-14bad871.js";import{e,a,D,B,C,S,E,T,A,R,L,l,ee,qn,Gr,V,We,U}from"./chunk-pyg1mr80.js";import{X}from"./chunk-zc1mk10n.js";import{_t}from"./chunk-f9k3xrwb.js";import{Xe}from"./chunk-07agqp8h.js";function rt(t,o){return o<t?-1:o>t?1:o>=t?0:NaN}function at(t){return t}function nt(){var t=at,o=rt,k=null,H=ee(0),g=ee(qn),h=ee(0);function s(r){var i,u=(r=Gr(r)).length,m,z,W=0,v=Array(u),c=Array(u),F=+H.apply(this,arguments),_=Math.min(qn,Math.max(-qn,g.apply(this,arguments)-F)),N,Z=Math.min(Math.abs(_)/u,h.apply(this,arguments)),p=Z*(_<0?-1:1),M;for(i=0;i<u;++i)if((M=c[v[i]=i]=+t(r[i],i,r))>0)W+=M;if(o!=null)v.sort(function(I,x){return o(c[I],c[x])});else if(k!=null)v.sort(function(I,x){return k(r[I],r[x])});for(i=0,z=W?(_-u*p)/W:0;i<u;++i,F=N)m=v[i],M=c[m],N=F+(M>0?M*z:0)+p,c[m]={data:r[m],index:i,value:M,startAngle:F,endAngle:N,padAngle:Z};return c}return s.value=function(r){return arguments.length?(t=typeof r==="function"?r:ee(+r),s):t},s.sortValues=function(r){return arguments.length?(o=r,k=null,s):o},s.sort=function(r){return arguments.length?(k=r,o=null,s):k},s.startAngle=function(r){return arguments.length?(H=typeof r==="function"?r:ee(+r),s):H},s.endAngle=function(r){return arguments.length?(g=typeof r==="function"?r:ee(+r),s):g},s.padAngle=function(r){return arguments.length?(h=typeof r==="function"?r:ee(+r),s):h},s}var gt=D.pie,it={sections:new Map,showData:!1,config:gt},{sections:K,showData:ot}=it,xt=structuredClone(gt),St=e(()=>structuredClone(xt),"getConfig"),yt=e(()=>{K=new Map,ot=it.showData,C()},"clear"),wt=e(({label:t,value:o})=>{if(o<0)throw Error(`"${t}" has invalid value: ${o}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);if(!K.has(t))K.set(t,o),a.debug(`added new section: ${t}, with value: ${o}`)},"addSection"),At=e(()=>K,"getSections"),Ct=e((t)=>{ot=t},"setShowData"),$t=e(()=>ot,"getShowData"),dt={getConfig:St,clear:yt,setDiagramTitle:R,getDiagramTitle:L,setAccTitle:S,getAccTitle:E,setAccDescription:T,getAccDescription:A,addSection:wt,getSections:At,setShowData:Ct,getShowData:$t},Dt=e((t,o)=>{G(t,o),o.setShowData(t.showData),t.sections.map(o.addSection)},"populateDb"),Tt={parse:e(async(t)=>{let o=await X("pie",t);a.debug(o),Dt(o,dt)},"parse")},bt=e((t)=>`
|
|
2
|
+
.pieCircle{
|
|
3
|
+
stroke: ${t.pieStrokeColor};
|
|
4
|
+
stroke-width : ${t.pieStrokeWidth};
|
|
5
|
+
opacity : ${t.pieOpacity};
|
|
6
|
+
}
|
|
7
|
+
.pieCircle.highlighted{
|
|
8
|
+
scale: 1.05;
|
|
9
|
+
opacity: 1;
|
|
10
|
+
}
|
|
11
|
+
.pieCircle.highlightedOnHover:hover{
|
|
12
|
+
transition-duration: 250ms;
|
|
13
|
+
scale: 1.05;
|
|
14
|
+
opacity: 1;
|
|
15
|
+
}
|
|
16
|
+
.pieOuterCircle{
|
|
17
|
+
stroke: ${t.pieOuterStrokeColor};
|
|
18
|
+
stroke-width: ${t.pieOuterStrokeWidth};
|
|
19
|
+
fill: none;
|
|
20
|
+
}
|
|
21
|
+
.pieTitleText {
|
|
22
|
+
text-anchor: middle;
|
|
23
|
+
font-size: ${t.pieTitleTextSize};
|
|
24
|
+
fill: ${t.pieTitleTextColor};
|
|
25
|
+
font-family: ${t.fontFamily};
|
|
26
|
+
}
|
|
27
|
+
.slice {
|
|
28
|
+
font-family: ${t.fontFamily};
|
|
29
|
+
fill: ${t.pieSectionTextColor};
|
|
30
|
+
font-size:${t.pieSectionTextSize};
|
|
31
|
+
// fill: white;
|
|
32
|
+
}
|
|
33
|
+
.legend text {
|
|
34
|
+
fill: ${t.pieLegendTextColor};
|
|
35
|
+
font-family: ${t.fontFamily};
|
|
36
|
+
font-size: ${t.pieLegendTextSize};
|
|
37
|
+
}
|
|
38
|
+
`,"getStyles"),kt=bt,zt=e((t)=>{let o=[...t.values()].reduce((g,h)=>g+h,0),k=[...t.entries()].map(([g,h])=>({label:g,value:h})).filter((g)=>g.value/o*100>=1);return nt().value((g)=>g.value).sort(null)(k)},"createPieArcs"),Et=e((t,o,k,H)=>{a.debug(`rendering pie chart
|
|
39
|
+
`+t);let g=H.db,h=l(),s=U(g.getConfig(),h.pie),r=40,i=18,u=4,m=450,z=m,W=V(o),v=W.append("g");v.attr("transform","translate("+z/2+","+m/2+")");let{themeVariables:c}=h,[F]=We(c.pieOuterStrokeWidth);F??=2;let{legendPosition:_,textPosition:N}=s,Z=s.donutHole>0&&s.donutHole<=0.9?s.donutHole:0,p=Math.min(z,m)/2-r,M=_t().innerRadius(Z*p).outerRadius(p),I=_t().innerRadius(p*N).outerRadius(p*N),x=v.append("g");x.append("circle").attr("cx",0).attr("cy",0).attr("r",p+F/2).attr("class","pieOuterCircle");let q=g.getSections(),pt=zt(q),ft=[c.pie1,c.pie2,c.pie3,c.pie4,c.pie5,c.pie6,c.pie7,c.pie8,c.pie9,c.pie10,c.pie11,c.pie12],Q=0;q.forEach((n)=>{Q+=n});let lt=pt.filter((n)=>(n.data.value/Q*100).toFixed(0)!=="0"),Y=Xe(ft).domain([...q.keys()]);x.selectAll("mySlices").data(lt).enter().append("path").attr("d",M).attr("fill",(n)=>Y(n.data.label)).attr("class",(n)=>{let d="pieCircle";if(s.highlightSlice==="hover")d+=" highlightedOnHover";else if(s.highlightSlice===n.data.label)d+=" highlighted";return d}),x.selectAll("mySlices").data(lt).enter().append("text").text((n)=>(n.data.value/Q*100).toFixed(0)+"%").attr("transform",(n)=>"translate("+I.centroid(n)+")").style("text-anchor","middle").attr("class","slice");let ht=v.append("text").text(g.getDiagramTitle()).attr("x",0).attr("y",-(m-50)/2).attr("class","pieTitleText"),j=[...q.entries()].map(([n,d])=>({label:n,value:d})),O=v.selectAll(".legend").data(j).enter().append("g").attr("class","legend");O.append("rect").attr("width",i).attr("height",i).style("fill",(n)=>Y(n.label)).style("stroke",(n)=>Y(n.label)),O.append("text").attr("x",i+u).attr("y",i-u).text((n)=>{if(g.getShowData())return`${n.label} [${n.value}]`;return n.label});let P=Math.max(...O.selectAll("text").nodes().map((n)=>n?.getBoundingClientRect().width??0)),J=m,tt=z+r,f=i+u,et=j.length*f;switch(_){case"center":O.attr("transform",(n,d)=>{let y=f*j.length/2,w=-P/2-(i+u),b=d*f-y;return"translate("+w+","+b+")"});break;case"top":J+=et,O.attr("transform",(n,d)=>{let y=p,w=-P/2-(i+u),b=d*f-y;return`translate(${w}, ${b})`}),x.attr("transform",()=>`translate(0, ${et+f})`);break;case"bottom":J+=et,O.attr("transform",(n,d)=>{let y=-p-f,w=-P/2-(i+u),b=d*f-y;return"translate("+w+","+b+")"});break;case"left":tt+=i+u+P,O.attr("transform",(n,d)=>{let y=f*j.length/2,w=-p-(i+u),b=d*f-y;return"translate("+w+","+b+")"}),x.attr("transform",()=>`translate(${P+i+u}, 0)`);break;case"right":default:tt+=i+u+P,O.attr("transform",(n,d)=>{let y=f*j.length/2,w=12*i,b=d*f-y;return"translate("+w+","+b+")"});break}let st=ht.node()?.getBoundingClientRect().width??0,mt=z/2-st/2,vt=z/2+st/2,ct=Math.min(0,mt),ut=Math.max(tt,vt)-ct;W.attr("viewBox",`${ct} 0 ${ut} ${J}`),B(W,J,ut,s.useMaxWidth)},"draw"),Mt={draw:Et},Jt={parser:Tt,db:dt,renderer:Mt,styles:kt};export{Jt as diagram};
|