github-actions[bot]
commited on
Commit
·
9592df2
1
Parent(s):
eddf854
Update from GitHub Actions
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .output/nitro.json +1 -1
- .output/public/assets/@agoose77-mGnNv_bd.js +1 -0
- .output/public/assets/@wdns-P0uM2sk1.js +0 -0
- .output/public/assets/CodeBlocks.vue_vue_type_style_index_0_lang-DWS4lyNS.js +1 -0
- .output/public/assets/chat-BW5Qhkmv.js +1 -0
- .output/public/assets/content-CMwtYO4S.js +3 -0
- .output/public/assets/highlight.js-Ds8M-WS2.js +0 -0
- .output/public/assets/index-BJf2iObo.js +1 -0
- .output/public/assets/index-BSlpP4WW.js +3 -0
- .output/public/assets/index-DJgKQCUj.css +1 -0
- .output/public/assets/index-DUia5xTm.js +1 -0
- .output/public/assets/index-LPxgpECk.js +1 -0
- .output/public/assets/main-zbluuG_-.js +6 -0
- .output/public/assets/markdown-DPs5ApTw.js +1 -0
- .output/public/assets/markdown-it-highlightjs-Ikc7oQsB.js +1 -0
- .output/public/assets/mermaid-B98QzgAP.js +0 -0
- .output/public/assets/popup-fiphPf2R.js +1 -0
- .output/public/assets/prismjs-BGP89_QJ.js +453 -0
- .output/public/index.html +2 -2
- .output/public/popup.html +7 -7
- .output/public/sw.js +1 -1
- .output/server/chunks/nitro/nitro.mjs +0 -0
- .output/server/node_modules/@grpc/grpc-js/build/src/backoff-timeout.js +18 -1
- .output/server/node_modules/@grpc/grpc-js/build/src/certificate-provider.js +14 -7
- .output/server/node_modules/@grpc/grpc-js/build/src/channel-credentials.js +238 -71
- .output/server/node_modules/@grpc/grpc-js/build/src/channel-options.js +1 -0
- .output/server/node_modules/@grpc/grpc-js/build/src/channelz.js +15 -1
- .output/server/node_modules/@grpc/grpc-js/build/src/experimental.js +3 -1
- .output/server/node_modules/@grpc/grpc-js/build/src/http_proxy.js +56 -47
- .output/server/node_modules/@grpc/grpc-js/build/src/internal-channel.js +18 -15
- .output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-child-handler.js +8 -10
- .output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-outlier-detection.js +10 -9
- .output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-pick-first.js +40 -23
- .output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-round-robin.js +15 -13
- .output/server/node_modules/@grpc/grpc-js/build/src/load-balancer.js +2 -2
- .output/server/node_modules/@grpc/grpc-js/build/src/load-balancing-call.js +4 -4
- .output/server/node_modules/@grpc/grpc-js/build/src/resolving-call.js +10 -4
- .output/server/node_modules/@grpc/grpc-js/build/src/resolving-load-balancer.js +46 -39
- .output/server/node_modules/@grpc/grpc-js/build/src/retrying-call.js +22 -4
- .output/server/node_modules/@grpc/grpc-js/build/src/server-credentials.js +34 -25
- .output/server/node_modules/@grpc/grpc-js/build/src/server-interceptors.js +5 -0
- .output/server/node_modules/@grpc/grpc-js/build/src/server.js +50 -14
- .output/server/node_modules/@grpc/grpc-js/build/src/subchannel-interface.js +3 -0
- .output/server/node_modules/@grpc/grpc-js/build/src/subchannel.js +6 -4
- .output/server/node_modules/@grpc/grpc-js/build/src/transport.js +88 -148
- .output/server/node_modules/@grpc/grpc-js/package.json +1 -1
- .output/server/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +7 -7
- .output/server/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +44 -44
- .output/server/node_modules/jose/dist/webapi/jwe/general/encrypt.js +40 -40
- .output/server/node_modules/jose/dist/webapi/jwks/local.js +11 -14
.output/nitro.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"date": "2025-03-
|
3 |
"preset": "node-server",
|
4 |
"framework": {
|
5 |
"name": "nitro",
|
|
|
1 |
{
|
2 |
+
"date": "2025-03-12T06:02:50.534Z",
|
3 |
"preset": "node-server",
|
4 |
"framework": {
|
5 |
"name": "nitro",
|
.output/public/assets/@agoose77-mGnNv_bd.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{m as e}from"./mermaid-B98QzgAP.js";import"./dayjs-DOPU4UI6.js";import"./@braintree-DgpeZQRe.js";import"./d3-transition-swcnLnsT.js";import"./d3-zoom-D4Vc87xO.js";import"./dompurify-B5jhUdWW.js";import"./dagre-d3-es-FtH4B9px.js";function t(t,r){e.initialize(Object.assign({securityLevel:"loose"},r));let i=t.renderer.rules.fence;t.renderer.rules.fence=function(t,r,n,m,s){let d=t[r],o=d.info.trim(),a=o?function(e){return e.split(/\s+/g)[0]}(o):"";if(-1===["mermaid","{mermaid}"].indexOf(a))return void 0!==i?i(t,r,n,m,s):"";let l="",c=[];const u=document.createElement("div");document.body.appendChild(u);try{const t="mermaid-container";e.mermaidAPI.render(t,d.content,(e=>{let r=document.getElementById(t);null!==r&&c.push(["style",`max-width:${r.style.maxWidth};max-height:${r.style.maxHeight}`]),l=e}),u)}catch(p){return`<div class="alert alert-danger">${p}</div>`}finally{u.remove()}return c.push(["src",`data:image/svg+xml,${encodeURIComponent(l)}`]),`<img ${s.renderAttrs({attrs:c})}>`}}export{t as m};
|
.output/public/assets/@wdns-P0uM2sk1.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
.output/public/assets/CodeBlocks.vue_vue_type_style_index_0_lang-DWS4lyNS.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{l as e,a as t,f as a,a0 as l,v as n,y as s,ad as o,B as i,A as c,z as r,R as u,F as d,ab as p,aa as m,G as v,H as f,u as g,J as h,a1 as x,n as y,K as w,w as b,ah as _,o as k}from"./@vue-DsZlmJIP.js";import{b as C,t as j,_ as B}from"./global-BveI--BU.js";import{m as $}from"./markdown-DPs5ApTw.js";import{f as S,b as R}from"./fetch-2coGNStX.js";import{c as z,E,s as T,d as V,j as A,K as M,m as q,f as O,Y as D,Z as U,_ as I}from"./tdesign-vue-next-DsCOKp3d.js";import{Z as L,a5 as P,c as H,af as K,ad as Y,v as F,k as J}from"./tdesign-icons-vue-next-Dn30dVUK.js";import{v as Z}from"./uuid-_R2nDvl_.js";import{a as G}from"./main-zbluuG_-.js";import{a as N}from"./ChatInput.vue_vue_type_style_index_0_lang-CF8t52ZG.js";import{U as W}from"./@wdns-P0uM2sk1.js";const Q={class:"flex flex-row items-center p-2"},X={key:0,class:"flex flex-col gap-2 p-2"},ee={class:"max-h-32 bg-color-page overflow-auto whitespace-pre-line no-scrollbar p-2"},te=["innerHTML"],ae={class:"flex flex-row justify-end gap-2"},le={key:1,class:"flex flex-col gap-2 p-2"},ne={key:0,class:"max-h-32 bg-color-page overflow-auto whitespace-pre-line no-scrollbar p-2"},se={class:"flex flex-grow items-center gap-2 relative"},oe={key:2,class:"flex flex-col gap-2 p-2"},ie={key:0,class:"max-h-32 bg-color-page overflow-auto whitespace-pre-line no-scrollbar p-2"},ce={class:"max-h-72 no-scrollbar overflow-auto bordered p-2 shadow-sm"},re=e({__name:"ToolBar",props:{parent:Object},setup(e,{expose:w}){const b=C(),_=G(),k=e,B=t({top:"0px",left:"0px"}),D=t(!1),U=t(null),I=t(!1),Y=t(!1),F=t(""),J=t(""),N=()=>{D.value=!1,I.value=!1},W=()=>{const e=window.getSelection();navigator.clipboard.writeText(e.toString()),N(),O.success(j("components.toolBar.copySuccessMsg"))},re=()=>{navigator.clipboard.writeText(F.value),N(),O.success(j("components.toolBar.copySuccessMsg"))},ue=a((()=>b.toolBarButtons.filter((e=>e.name&&e.show)))),de=(e,t)=>{const{e:a}=t;if("Enter"===a.key){if(a.shiftKey)return;a.preventDefault(),ge()}};let pe="",me=null,ve="";const fe=()=>{je(),Y.value=!0,me=window.getSelection(),ve=me.toString()},ge=async()=>{const e=ve,t=J.value;pe=t.includes("{{text}}")?t.replace("{{text}}",e):e?e+"\r\n"+t:t,Y.value=!1,await he()};async function he(){const e=k.parent,t=U.value.getBoundingClientRect().left-e.getBoundingClientRect().left;je(),I.value=!0,y((()=>{const a=me.getRangeAt(0).getBoundingClientRect(),l=e.getBoundingClientRect(),n=U.value.getBoundingClientRect();let s=t;const o=l.width-n.width;s>o&&(s=o),s<0&&(s=0),B.value={top:a.top+e.scrollTop-l.top-52+"px",left:`${s}px`}})),await xe()}const xe=async()=>{b.assistModel?(F.value=j("components.toolBar.handing"),await S(pe,(e=>{F.value=e}))):O.error(j("components.toolBar.noAssistModel"))},ye=t(!1),we=async()=>{je(),ye.value=!0,ve=window.getSelection().toString()},be=t(""),_e=_.list,ke=async()=>{ye.value=!1;const e=ve,t={id:Z(),title:e,time:(new Date).getTime(),conversationId:"",conversationName:"",conversationAvatar:"",chats:[],notes:[ve]};if(_.add(t),O.success(j("pages.conversation.favorite_success")),b.assistModel){const a=j("pages.conversation.extract_core_conversation",{question:e,answer:""});await R(a,(e=>{t.title=e,t.title=t.title.replaceAll("###",""),t.title=t.title.trim(),_.update(t)}))}},Ce=async()=>{if(ye.value=!1,!be)return;const e=_e.find((e=>e.id==be.value));e.notes.push(ve),_.update(e),O.success(j("pages.conversation.favorite_success"))},je=()=>{I.value=!1,Y.value=!1,J.value="",ye.value=!1,be.value=""};return w({showToolbox:()=>{const e=window.getSelection();e.toString().trim()&&(D.value=!0,je(),y((()=>{const t=e.getRangeAt(0).getBoundingClientRect(),a=k.parent,l=a.getBoundingClientRect(),n=U.value.getBoundingClientRect();let s=t.left+t.width/2-n.width/2+a.scrollLeft-l.left;const o=l.width-n.width;s>o&&(s=o),s<0&&(s=0);let i=t.top+a.scrollTop-l.top-52;const c=a.scrollTop;i<c&&(i=c),B.value={top:`${i}px`,left:`${s}px`}})))},hideToolbox:N}),(e,t)=>{const a=z,y=E,w=T,b=M,_=q,k=A,C=V;return l((s(),n("div",{ref_key:"selectToolbox",ref:U,style:i(B.value),class:"z-50 absolute bg-color-container bordered rounded-xl shadow-md flex flex-col max-w-80",onMouseup:t[2]||(t[2]=o((()=>{}),["stop"])),onMousedown:t[3]||(t[3]=o((()=>{}),["stop"]))},[c("div",Q,[(s(!0),n(d,null,p(ue.value,(e=>(s(),n(d,null,[u(a,{onClick:t=>(async e=>{me=window.getSelection(),ve=me.toString(),pe=e.prompt.replace("{{text}}",ve),await he()})(e),size:"small",variant:"text"},{default:m((()=>[v(f(e.name),1)])),_:2},1032,["onClick"]),u(y,{layout:"vertical"})],64)))),256)),u(a,{size:"small",variant:"text",onClick:fe},{default:m((()=>[v(f(e.$t("components.toolBar.dialog")),1)])),_:1}),u(y,{layout:"vertical"}),u(a,{size:"small",variant:"text",onClick:we},{default:m((()=>[v(f(e.$t("components.toolBar.faviorite")),1)])),_:1}),u(y,{layout:"vertical"}),u(a,{size:"small",variant:"text",onClick:W},{default:m((()=>[v(f(e.$t("components.toolBar.copy")),1)])),_:1})]),I.value?(s(),n("div",X,[c("pre",ee," "+f(g(pe)),1),c("div",{class:"markdown-body",innerHTML:g($).render(F.value)},null,8,te),c("div",ae,[u(a,{size:"small",variant:"outline",onClick:xe},{default:m((()=>[u(g(L),{slot:"icon"})])),_:1}),u(a,{size:"small",variant:"outline",onClick:re},{default:m((()=>[u(g(P),{slot:"icon"})])),_:1}),u(a,{size:"small",variant:"outline",onClick:N},{default:m((()=>[u(g(H),{slot:"icon"})])),_:1})])])):r("",!0),Y.value?(s(),n("div",le,[g(ve).trim()?(s(),n("pre",ne," "+f(g(ve).trim()),1)):r("",!0),c("div",se,[u(w,{modelValue:J.value,"onUpdate:modelValue":t[0]||(t[0]=e=>J.value=e),onKeypress:de},null,8,["modelValue"]),u(a,{size:"small",shape:"circle",variant:"outline",onClick:ge,class:"absolute bottom-1 right-1"},{default:m((()=>[u(g(K),{slot:"icon"})])),_:1})])])):r("",!0),ye.value?(s(),n("div",oe,[g(ve).trim()?(s(),n("pre",ie," "+f(g(ve).trim()),1)):r("",!0),c("div",ce,[u(C,{modelValue:be.value,"onUpdate:modelValue":t[1]||(t[1]=e=>be.value=e)},{default:m((()=>[u(k,{gutter:[16,16]},{default:m((()=>[(s(!0),n(d,null,p(g(_e),(e=>(s(),h(_,{span:12},{default:m((()=>[u(b,{value:e.id,class:"grid grid-flow-col auto-cols-max align-middle fav-radio fav-radio-toolbar"},{default:m((()=>[v(f(e.title),1)])),_:2},1032,["value"])])),_:2},1024)))),256))])),_:1})])),_:1},8,["modelValue"])]),u(a,{onClick:Ce,theme:"default",variant:"outline"},{default:m((()=>t[4]||(t[4]=[v("添加到笔记")]))),_:1}),u(a,{onClick:ke,theme:"default",variant:"outline"},{default:m((()=>t[5]||(t[5]=[v("创建新的笔记")]))),_:1})])):r("",!0)],36)),[[x,D.value]])}}}),ue={class:"markdown-body"},de={class:"think-process"},pe={class:"flex justify-start mt-2 gap-5"},me={key:0,class:"tdesign-image-viewer-wrapper flex-wrap gap-6"},ve={key:0,class:"tdesign-image-viewer__error tdesign-image-viewer__ui-image tdesign-image-viewer__base"},fe={class:"tdesign-image-viewer__error--content"},ge={class:"tdesign-image-viewer__ui-image tdesign-image-viewer__base"},he=["src","onError"],xe=["onClick"],ye={class:"absolute left-1 top-1 max-w-[75%]"},we=["title"],be=B(e({__name:"AssistantContent",props:{content:{type:Object},isEditing:{type:Boolean,default:!1}},emits:["save","cancel"],setup(e,{emit:o}){const i=w([!1,!1,!1,!1]),k=w([!1,!1,!1,!1]),C=e,j=a((()=>$.render(C.content.text))),B=a((()=>C.content.images.map((e=>e.content||e.url)))),S=o,R=t(C.content.text),E=()=>{S("save",R.value)},V=()=>{R.value=C.content.text,S("cancel")},A=(e,t)=>{},M=t(null);return b((()=>C.isEditing),(e=>{e&&(R.value=C.content.text,y((()=>{M.value.$el.querySelector("textarea").focus()})))})),(t,a)=>{const o=T,y=z,w=D;return s(),n(d,null,[l(c("div",ue,[l(c("details",null,[c("summary",null,f(e.content.text?"查看 AI 思考过程":"思考中..."),1),c("div",de,f(e.content.think),1)],512),[[x,e.content.think]]),_([e.content.text],(()=>l((s(),n("div",{innerHTML:j.value},null,8,["innerHTML"])),[[x,e.content.text]])),a,0)],512),[[x,(e.content.text||e.content.think)&&!e.isEditing]]),l(c("div",null,[u(o,{ref_key:"textareaRef",ref:M,modelValue:R.value,"onUpdate:modelValue":a[1]||(a[1]=e=>R.value=e),autosize:{minRows:5,maxRows:20},onBlur:A},null,8,["modelValue"]),c("div",pe,[u(y,{size:"large",shape:"circle",variant:"text",onClick:V},{default:m((()=>[u(g(H),{slot:"icon"})])),_:1}),u(y,{size:"large",shape:"circle",variant:"text",onClick:E},{default:m((()=>[u(g(Y),{slot:"icon"})])),_:1})])],512),[[x,e.content.text&&e.isEditing]]),B.value.length>0?(s(),n("div",me,[(s(!0),n(d,null,p(C.content.images,((e,t)=>(s(),n("div",{key:t,class:"min-w-44 min-h-44"},[k[t]?(s(),n("div",ve,[c("div",fe,[u(g(F),{name:"image-error",size:"2em"}),a[2]||(a[2]=c("div",null,"图片无法显示",-1))])])):(s(),h(w,{key:1,visible:i[t],images:B.value,"default-index":t,"close-on-overlay":"",onClose:e=>(e=>{i[e]=!1})(t)},{trigger:m((()=>[c("div",ge,[c("img",{alt:"test",src:e.content||e.url,class:"tdesign-image-viewer__ui-image--img",onError:e=>(e=>{k[e]=!0})(t)},null,40,he),c("div",{class:"tdesign-image-viewer__ui-image--hover",onClick:e=>(e=>{i[e]=!0})(t)},[c("span",null,[u(g(J),{size:"1.4em"}),a[3]||(a[3]=v(" 预览 "))])],8,xe),c("div",ye,[c("div",{class:"text-black bg-white bg-opacity-75 p-1 rounded-2xl text-xs truncate",title:e.model},f(e.model),9,we)])])])),_:2},1032,["visible","images","default-index","onClose"]))])))),128))])):r("",!0)],64)}}}),[["__scopeId","data-v-f89b45ec"]]),_e={key:0,class:"whitespace-pre-wrap break-words"},ke={key:1},Ce={class:"flex justify-end mt-2 gap-5"},je=e({__name:"UserContent",props:{content:{type:Object},isEditing:{type:Boolean,default:!1}},emits:["save","cancel"],setup(e,{emit:l}){const o=e,i=a((()=>[...o.content.files,...o.content.images])),p=l,v=t(o.content.text),h=()=>{p("save",v.value)},x=()=>{v.value=o.content.text,p("cancel")},w=(e,t)=>{},_=t(null);return b((()=>o.isEditing),(e=>{e&&(v.value=o.content.text,y((()=>{_.value.$el.querySelector("textarea").focus()})))})),(t,a)=>{const l=T,o=z;return s(),n(d,null,[u(N,{files:i.value,showCloseButton:!1,class:"mb-2"},null,8,["files"]),e.isEditing?r("",!0):(s(),n("div",_e,f(e.content.text),1)),e.isEditing?(s(),n("div",ke,[u(l,{ref_key:"textareaRef",ref:_,modelValue:v.value,"onUpdate:modelValue":a[0]||(a[0]=e=>v.value=e),autosize:{minRows:2,maxRows:20},onBlur:w},null,8,["modelValue"]),c("div",Ce,[u(o,{size:"large",shape:"circle",variant:"text",onClick:x},{default:m((()=>[u(g(H),{slot:"icon"})])),_:1}),u(o,{size:"large",shape:"circle",variant:"text",onClick:h},{default:m((()=>[u(g(Y),{slot:"icon"})])),_:1})])])):r("",!0)],64)}}}),Be=e({__name:"CodeRenderer",props:{blocks:{type:Array,required:!0}},setup(e){const l=e,o=t(),i=a((()=>l.blocks.every((e=>e.complete))));const c=a((()=>{var e,t,a,n,s,o;if(!i.value)return"";const c=(null==(e=l.blocks.find((e=>"html"===e.language)))?void 0:e.code)||"",{head:r,body:u}=function(e){const t=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i),a=e.match(/<body\b[^>]*>([\s\S]*?)<\/body>/i);return{head:t?t[1].trim():"",body:a?a[1].trim():""}}(c),d=(null==(t=l.blocks.find((e=>"css"===e.language)))?void 0:t.code)||"",p=(null==(a=l.blocks.find((e=>"js"===e.language||"javascript"===e.language||"typescript"===e.language)))?void 0:a.code)||"";null==(n=l.blocks.find((e=>"typescript"===e.language)))||n.code;const m=(null==(s=l.blocks.find((e=>"jsx"===e.language)))?void 0:s.code)||"",v=(null==(o=l.blocks.find((e=>"vue"===e.language)))?void 0:o.code)||"";if(m){const e=m.match(/export default (\w+);/),t=e?e[1]:null;return`\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset="utf-8" />\n <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudflare.com; style-src 'unsafe-inline';">\n <style>${d}</style>\n <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.24.6/babel.min.js"><\/script>\n <script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js"><\/script>\n <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.production.min.js"><\/script>\n ${r}\n </head>\n\n <body>\n <div id="app"></div>\n ${u}\n <script type="text/babel">\n ${function(e){const t=/import\s+(?:(\w+)\s*,?\s*)?(?:{([^}]+)})?\s+from\s+['"]react['"];?/g,a=/import\s+['"]([^'"]+\.css)['"];?/g,l=/import\s+\w+\s+from\s+['"]react-dom['"];?/g,n=/ReactDOM\.render\([^)]*\);?/g;let s,o=e,i="";const c=new Set;for(;null!==(s=t.exec(e));)s[1]&&(i=s[1].trim()),s[2]&&s[2].split(",").forEach((e=>c.add(e.trim())));o=o.replace(t,""),o=o.replace(a,""),o=o.replace(l,""),o=o.replace(n,"");let r="";r+=i?`const ${i} = window.React;\n`:"const React = window.React;\n";c.size>0&&(r+=`const { ${Array.from(c).join(", ")} } = React;\n`);return(r+o).replace(/export default \w+;\s*$/,"")}(m)}\n ReactDOM.render(<${t} />, document.getElementById('app'))\n <\/script>\n </body>\n </html>\n `}if(v){const e=v.match(/<template>([\s\S]*)<\/template>/),t=v.match(/<script\s*(setup)?[^>]*>([\s\S]*)<\/script>/),a=v.match(/<style[^>]*>([\s\S]*)<\/style>/),l=e?e[1].trim():"",n=t?t[2].trim():"",s=t&&"setup"===t[1],o=a?a[1].trim():"";let i=n;if(s)i=i.replace(/import\s+.*from\s+['"].*['"]/g,""),i=`return {\n ${i}\n }`;else{const e=i.match(/export\s+default\s*{([\s\S]*)}/);e&&(i=e[1].trim())}return`\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset="utf-8" />\n <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'unsafe-inline' 'unsafe-eval' https://unpkg.com; style-src 'unsafe-inline';">\n <script src="https://unpkg.com/vue@3/dist/vue.global.js"><\/script>\n <style>${o}</style>\n ${r}\n </head>\n <body>\n <div id="app">\n ${l}\n </div>\n ${u}\n <script>\n const { createApp, ref, reactive, computed, onMounted } = Vue;\n \n const app = createApp({\n ${s?"setup() {":""}\n ${i}\n ${s?"}":""}\n });\n \n app.mount('#app');\n <\/script>\n </body>\n </html>\n `}return`\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset="utf-8" />\n <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline';">\n <style>${d}</style>\n ${r}\n </head>\n <body>\n ${u}\n <script>\n ${p}\n <\/script>\n </body>\n </html>\n `}));return b(c,(e=>{o.value&&(o.value.srcdoc=e)})),k((()=>{o.value&&(o.value.srcdoc=c.value)})),(e,t)=>(s(),n("iframe",{ref_key:"iframeRef",ref:o,sandbox:"allow-scripts",style:{width:"100%",height:"100%",border:"none"}},null,512))}}),$e={class:"h-full w-full relative"},Se=e({__name:"CodeBlocks",props:{content:{type:String,required:!0},closeBtn:{type:[Function,null],default:null}},setup(e){const a=e,l=t(0),o=t([]);b((()=>a.content),(e=>{o.value=function(e){const t=/(?:^|\n)```(?:(html|css|js|javascript|typescript|jsx|vue)?.*)\n([\s\S]*?)(?:```|$)/g;return[...e.matchAll(t)].map((e=>({language:e[1]||"javascript",code:e[2].trim(),complete:e[0].endsWith("```")})))}(a.content);const t=o.value.every((e=>e.complete));l.value=t?-1:0}),{immediate:!0});const i=()=>{a.closeBtn()};return(t,a)=>{const c=I,v=U,f=z;return s(),n("div",$e,[u(v,{modelValue:l.value,"onUpdate:modelValue":a[0]||(a[0]=e=>l.value=e),class:"h-full overflow-auto flex flex-col artifact"},{default:m((()=>[u(c,{value:-1,label:"preview"},{default:m((()=>[u(Be,{blocks:o.value,class:"rounded-lg"},null,8,["blocks"])])),_:1}),(s(!0),n(d,null,p(o.value,((e,t)=>(s(),h(c,{value:t,label:e.language},{default:m((()=>[u(g(W),{highlightjs:"",code:e.code,lang:e.language,theme:!1,class:"code-block h-full"},null,8,["code","lang"])])),_:2},1032,["value","label"])))),256))])),_:1},8,["modelValue"]),e.closeBtn?(s(),h(f,{key:0,size:"small",variant:"outline",onClick:i,class:"absolute right-0 top-3 z-50"},{default:m((()=>[u(g(H),{slot:"icon"})])),_:1})):r("",!0)])}}});export{be as A,je as _,re as a,Se as b};
|
.output/public/assets/chat-BW5Qhkmv.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{l as e,f as t,a,w as l,o,v as n,y as s,F as i,J as c,z as r,R as u,aa as d,A as v,H as p,u as m,ab as h,G as f,ac as g,ad as _,j as x,a0 as b,I as w,a1 as y,V as k,B as j,n as C}from"./@vue-DsZlmJIP.js";import{c as z,d as M,m as I,t as V,b as A,u as S,f as E,e as T}from"./global-BveI--BU.js";import{u as R,a as P}from"./vue-router-Be5-2oBH.js";import{c as U,_ as O}from"./ChatInput.vue_vue_type_style_index_0_lang-CF8t52ZG.js";import{_ as N}from"./avatar.vue_vue_type_script_setup_true_lang-jav6E5Ln.js";import{u as B}from"./app-_ksMLlTy.js";import{p as q,q as H,r as W,T as D,c as $,s as L,t as K,u as J,O as F,A as G,v as X,w as Y,n as Z,D as Q,x as ee,f as te,P as ae,l as le,y as oe,E as ne,G as se,m as ie,J as ce,d as re,j as ue,K as de}from"./tdesign-vue-next-DsCOKp3d.js";import{V as ve,W as pe,X as me,Y as he,Z as fe,$ as ge,a0 as _e,a1 as xe,a2 as be,a3 as we,_ as ye,a4 as ke,a5 as je,a6 as Ce,a7 as ze,a8 as Me,E as Ie,n as Ve}from"./tdesign-icons-vue-next-Dn30dVUK.js";import{v as Ae}from"./uuid-_R2nDvl_.js";import{u as Se,a as Ee}from"./main-zbluuG_-.js";import{g as Te,r as Re,s as Pe,c as Ue,a as Oe,b as Ne}from"./fetch-2coGNStX.js";import{_ as Be,A as qe,a as He,b as We}from"./CodeBlocks.vue_vue_type_style_index_0_lang-DWS4lyNS.js";import{d as De}from"./vuedraggable-K5Gqz8r2.js";import{g as $e}from"./lyihub-zLFv36Ly.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./lodash-Cky9m9r7.js";import"./@vueuse-Cn3Nsuq9.js";import"./vue-i18n-Dmk40Gks.js";import"./@intlify-eboPrqDD.js";import"./pinia-jKJ-xldK.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./mammoth-5Ncu60I4.js";import"./elkjs-CmFeGg_o.js";import"./xlsx-DB6BMndo.js";import"./pdfjs-dist-8WFUNQXM.js";import"./@dicebear-JcnEMRoc.js";import"./lodash-es-BkU_-LF8.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";import"./@wdns-P0uM2sk1.js";import"./ua-parser-js-9pz7LJLQ.js";import"./vue-DVRmszIO.js";import"./eventsource-parser-BEY8Dpg-.js";import"./@mozilla-BD532_dh.js";import"./markdown-DPs5ApTw.js";import"./markdown-it-link-attributes-UnOqz_aA.js";import"./markdown-it-C8SkdHr7.js";import"./mdurl-CDXpswLz.js";import"./uc.micro-CLkLCS2f.js";import"./entities-D7HTx9ov.js";import"./linkify-it-LcVOBuC5.js";import"./punycode.js-Bmr3cAX8.js";import"./@traptitech-BPk2gen6.js";import"./katex-BY7yyeOs.js";import"./markdown-it-highlightjs-Ikc7oQsB.js";import"./highlight.js-Ds8M-WS2.js";import"./@agoose77-mGnNv_bd.js";import"./mermaid-B98QzgAP.js";import"./dayjs-DOPU4UI6.js";import"./@braintree-DgpeZQRe.js";import"./d3-transition-swcnLnsT.js";import"./d3-timer-keMr1twq.js";import"./d3-dispatch-Chq_f_hl.js";import"./d3-interpolate-Ct9kki6l.js";import"./d3-color-D5ULnJIe.js";import"./d3-selection-G65jBFUY.js";import"./d3-ease-Cx6bG2vu.js";import"./d3-zoom-D4Vc87xO.js";import"./dompurify-B5jhUdWW.js";import"./dagre-d3-es-FtH4B9px.js";import"./d3-shape-C1TbtrGg.js";import"./d3-path-QSrLXsQ3.js";import"./d3-fetch-XwboCDHR.js";import"./khroma-Ca6ZlOUT.js";import"./ts-dedent-CttZBlkd.js";import"./stylis-Cl7w7uv3.js";import"./d3-scale-CjTvl_Qo.js";import"./internmap-B8oPgqVZ.js";import"./d3-array-B0evfIyH.js";import"./d3-format-C0lSXcPg.js";import"./d3-time-format-D74OpZq4.js";import"./d3-time-CebKitJR.js";import"./d3-axis-pCwzqJ1S.js";import"./cytoscape-D84qPEQv.js";import"./cytoscape-cose-bilkent-CoOmxuE9.js";import"./cose-base-kQthUiMK.js";import"./layout-base-DqRk0Tgc.js";const Le={class:"flex flex-col items-center justify-center mb-[var(--td-comp-margin-xxl)] gap-3"},Ke={class:"text-lg font-bold"},Je={class:"flex"},Fe={class:"flex flex-row justify-between gap-3 w-full"},Ge=e({__name:"ConversationDrawer",setup(e){const x=z(),b=t({get:()=>x.showEditorDrawer,set(e){x.showEditorDrawer=e}}),w=()=>{x.showEditorDrawer=!1},y=a(null),k=R(),j=()=>{const e=x.find(k.query.id);C.value=e.models.reduce(((e,t)=>(e[t.modelId]=t.showing,e)),{}),y.value={id:e.id,name:e.name,content:e.content,avatar:e.avatar,models:e.models.map((e=>e.modelId)),agentId:e.agentId,saveToAgent:!1,maxContextSize:e.maxContextSize,aspectRatio:e.aspectRatio}},C=a({});l((()=>{var e;return null==(e=y.value)?void 0:e.models}),(e=>{const t=Object.keys(C.value);t.forEach((t=>{e.includes(t)||delete C.value[t]})),e.forEach((e=>{t.includes(e)||(C.value[e]=!1)}))}));const A=t((()=>{if(!y.value)return!1;return Object.values(C.value).filter((e=>e)).length>=B}));l((()=>x.showEditorDrawer),(e=>{e&&j()})),M();const S=t((()=>I.availableModels.value.map((e=>({value:e.id,label:I.getModelItemTitle(e),...e}))))),E=Se(),T=t((()=>{let e=E.find(y.value.agentId);return e=e||E.defaultAgent,e})),P=e=>{y.value.avatar=e},U=()=>{const e=x.find(y.value.id);e.name=y.value.name,e.content=y.value.content,e.avatar=y.value.avatar,e.agentId=y.value.agentId,e.maxContextSize=y.value.maxContextSize,e.aspectRatio=y.value.aspectRatio;const t=[];e.models.forEach((e=>{y.value.models.includes(e.modelId)&&(e.showing=C.value[e.modelId],t.push(e))})),y.value.models.forEach((a=>{e.models.some((e=>e.modelId===a))||t.push({modelId:a,chats:[],startContext:0,apiAgentId:"",apiConversationId:"",apiNote:"",showing:C.value[a],status:{responseWating:!1,chating:!1,stop:!1}})})),e.models=t,y.value.saveToAgent&&(T.value.content=y.value.content),j(),te.success(V("pages.conversation.save_conversation_success"))},O=a(!1),ae=a(""),le=()=>{if(""===ae.value.trim())return void te.warning(V("pages.conversation.enter_agent_name"));const e=Ae();E.add({id:e,name:ae.value,status:!0,content:y.value.content,avatar:y.value.avatar,onboarding:"",isDefault:!1});const t=x.find(y.value.id);y.value.agentId=e,t.agentId=e,O.value=!1,te.success(V("pages.conversation.create_agent_success"))},oe=()=>{y.value.content=T.value.content},ne=()=>{y.value.saveToAgent=!y.value.saveToAgent};return o((()=>{x.showEditorDrawer=!1})),(e,t)=>{const a=W,l=H,o=$,x=D,k=L,j=K,z=F,M=J,E=Y,R=X,B=G,te=Z,se=q,ie=Q,ce=ee;return s(),n(i,null,[y.value?(s(),c(ie,{key:0,visible:b.value,"onUpdate:visible":t[7]||(t[7]=e=>b.value=e),size:"408px",footer:!1,header:m(V)("pages.conversation.current_conversation"),"close-btn":!0,class:"",onCloseBtnClick:w},{default:d((()=>[u(se,{ref:"form",data:y.value,"label-width":100,"label-align":"top"},{default:d((()=>[v("div",Le,[u(N,{ref:"avatarRef",url:y.value.avatar,onUpdate:P},null,8,["url"]),v("h1",Ke,p(m(V)("pages.conversation.agent"))+": "+p(T.value.name),1)]),u(l,{label:m(V)("pages.conversation.conversation_name"),name:"name"},{default:d((()=>[u(a,{modelValue:y.value.name,"onUpdate:modelValue":t[0]||(t[0]=e=>y.value.name=e)},null,8,["modelValue"])])),_:1},8,["label"]),u(l,{label:m(V)("pages.conversation.conversation_description"),name:"content",class:"relative"},{default:d((()=>[u(x,{content:m(V)("pages.conversation.rollback_from_agent")},{default:d((()=>[u(o,{shape:"circle",variant:"text",class:"absolute z-50 right-0 top-[-32px]",onClick:oe},{default:d((()=>[u(m(ve),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(k,{modelValue:y.value.content,"onUpdate:modelValue":t[1]||(t[1]=e=>y.value.content=e),autosize:{minRows:5,maxRows:10},name:"content"},null,8,["modelValue"])])),_:1},8,["label"]),u(l,{label:m(V)("pages.conversation.context_rounds"),name:"maxContextSize"},{default:d((()=>[u(j,{modelValue:y.value.maxContextSize,"onUpdate:modelValue":t[2]||(t[2]=e=>y.value.maxContextSize=e),inputNumberProps:"",showStep:"",min:0,max:30},null,8,["modelValue"])])),_:1},8,["label"]),u(l,{label:"图片宽高比",name:"aspectRatio"},{default:d((()=>[u(M,{modelValue:y.value.aspectRatio,"onUpdate:modelValue":t[3]||(t[3]=e=>y.value.aspectRatio=e)},{default:d((()=>[u(z,{value:"IMAGE_ASPECT_RATIO_SQUARE",label:"方形 (1:1)"}),u(z,{value:"IMAGE_ASPECT_RATIO_PORTRAIT",label:"竖屏 (9:16)"}),u(z,{value:"IMAGE_ASPECT_RATIO_LANDSCAPE",label:"横屏 (16:9)"}),u(z,{value:"IMAGE_ASPECT_RATIO_PORTRAIT_THREE_FOUR",label:"竖屏 (3:4)"}),u(z,{value:"IMAGE_ASPECT_RATIO_LANDSCAPE_FOUR_THREE",label:"横屏 (4:3)"})])),_:1},8,["modelValue"])])),_:1}),u(l,{label:m(V)("pages.conversation.model"),name:"models"},{default:d((()=>[u(M,{modelValue:y.value.models,"onUpdate:modelValue":t[5]||(t[5]=e=>y.value.models=e),multiple:""},{valueDisplay:d((({value:e,onClose:a})=>[(s(!0),n(i,null,h(e,((e,l)=>(s(),c(R,{key:l,closable:!0,"on-close":({e:e})=>{e.stopPropagation(),a(l)}},{default:d((()=>[u(E,{disabled:A.value&&!C.value[e.value],onClick:t[4]||(t[4]=_((()=>{}),["stop"])),class:"mr-1",size:"small",modelValue:C.value[e.value],"onUpdate:modelValue":t=>C.value[e.value]=t},null,8,["disabled","modelValue","onUpdate:modelValue"]),f(" "+p(e.label),1)])),_:2},1032,["on-close"])))),128))])),default:d((()=>[(s(!0),n(i,null,h(S.value,(e=>(s(),c(z,{key:e.value,value:e.value,label:e.label},{default:d((()=>[v("div",Je,[u(B,{size:"20px",class:"mr-1"},{icon:d((()=>[(s(),c(g(m(I).icons[e.type])))])),_:2},1024),f(" "+p(e.label),1)])])),_:2},1032,["value","label"])))),128))])),_:1},8,["modelValue"])])),_:1},8,["label"]),u(l,null,{default:d((()=>[v("div",Fe,[T.value.isDefault?r("",!0):(s(),c(te,{key:0,onChange:ne},{default:d((()=>[f(p(m(V)("pages.conversation.save_to_agent")),1)])),_:1})),u(o,{theme:"primary",type:"submit",onClick:U,class:"flex-1"},{default:d((()=>[f(p(m(V)("pages.conversation.save_conversation")),1)])),_:1})])])),_:1}),u(l,null,{default:d((()=>[u(o,{theme:"primary",type:"submit",onClick:t[6]||(t[6]=e=>O.value=!0),class:"w-full"},{default:d((()=>[f(p(m(V)("pages.conversation.save_as_new_agent")),1)])),_:1})])),_:1})])),_:1},8,["data"])])),_:1},8,["visible","header"])):r("",!0),u(ce,{visible:O.value,"onUpdate:visible":t[9]||(t[9]=e=>O.value=e),header:m(V)("pages.conversation.create_new_agent"),"on-confirm":le},{default:d((()=>[u(se,{ref:"form","label-width":100},{default:d((()=>[u(l,{label:m(V)("pages.conversation.agent_name"),name:"name"},{default:d((()=>[u(a,{modelValue:ae.value,"onUpdate:modelValue":t[8]||(t[8]=e=>ae.value=e)},null,8,["modelValue"])])),_:1},8,["label"])])),_:1},512)])),_:1},8,["visible","header"])],64)}}}),Xe={class:"h-full flex flex-col chat-model-container relative"},Ye={class:"cursor-pointer handle p-2 bg-color-container rounded-t-lg shadow-2xl chat-model-header z-50"},Ze={class:"flex flex-wrap justify-between w-full overflow-x-hidden"},Qe={class:"flex gap-1"},et={class:"max-w-[120px]"},tt={class:"model-info flex flex-col gap-2"},at={class:"max-h-44 overflow-auto no-scrollbar"},lt={class:"flex gap-1 flex-wrap"},ot={key:0,class:"flex w-full justify-end items-start flex-row-reverse gap-2 chat-item"},nt=["data-index"],st={class:"flex justify-between overflow-hidden h-[24px]"},it={class:"flex chat-item-tools gap-2"},ct={class:"user-chat-content p-2 rounded-lg"},rt={class:"w-[24px] h-[24px]"},ut={key:1,class:"flex w-full flex-col gap-2 chat-item"},dt={class:"flex justify-start align-middle items-center gap-2 h-[24px]"},vt={class:"flex flex-row justify-between gap-5"},pt={class:"flex flex-col w-full"},mt=["data-index"],ht={key:0,class:"loader"},ft={key:2,class:"flex gap-5 overflow-x-auto scrollbar p-1"},gt=["onClick"],_t={class:"flex flex-row w-full"},xt={class:"w-12 h-2"},bt=["src"],wt={class:"w-44"},yt={class:"w-full text-ellipsis overflow-hidden text-nowrap"},kt={class:"text-ellipsis overflow-hidden whitespace-nowrap"},jt={class:"max-h-10 overflow-hidden mt-2"},Ct={class:"h-[24px] mt-1 chat-item-tools"},zt={class:"flex justify-end gap-2"},Mt={key:3,class:"flex justify-center w-full"},It={class:"fixed-scroll-buttons"},Vt=e({__name:"ChatColumn",props:{chatModel:{type:Object},conversation:{type:Object},fullScreenModelId:{type:String,default:""}},emits:["stop-chat","extend-model-visible","re-chat","change-size","api-setting-visible","fav-note-visible","clear-chat-context","clear-chat-history"],setup(e,{emit:l}){const k=A();R();const j=e,C=a(null),z=a(null);Ee(),M();const S=t((()=>j.chatModel.chat.chats));const E=l,T=e=>{E("re-chat",e.model.id)},P=a(-1),U=e=>{P.value=e},O=e=>{S.value[P.value].content.text=e,P.value=-1},N=()=>{P.value=-1},B=t((()=>I.getModelItemTitle(j.chatModel.model))),q=e=>{navigator.clipboard.writeText(e.content.text),te.success(V("pages.note.noteCopySuccess"))},W=t((()=>{let e="",t="";if(j.chatModel.model.apiBase.startsWith("http"))e=j.chatModel.model.apiBase,t=j.chatModel.model.apiKey;else{let l=Te(j.chatModel.model.apiBase||I.dict[j.chatModel.model.type].apiBase);l=l.replace("/app/","/api/"),l.includes("?")?l+="&":l+="?",l+=`model=${j.chatModel.model.id}`,l+="&",l+=`conversation=${j.conversation.id}`;const o=l.indexOf("?");e=l.substring(0,o)+"/v1/chat/completions",t="oa_"+(a=l.substring(o+1),btoa(a).split("").map((e=>{const t=e.charCodeAt(0);return String.fromCharCode(t+1)})).join(""))}var a;return{apiBase:e,apiKey:t}})),L=t((()=>j.chatModel.model.apiBase.startsWith("http")?"ApiBase":"LocalApi")),J=t((()=>j.chatModel.model.apiBase.startsWith("http")?"ApiKey":"LocalKey")),F=a(!1),Y=a("");x((()=>{if(!S.value||0===S.value.length)return;const e=S.value[S.value.length-1];"assistant"===e.role&&(Y.value=e.content.text)}));const Z=()=>{F.value=!1};async function Q(){await window.ipcRenderer.invoke("refresh-vercel-view")?te.success("Refresh succeed"):te.error("Refresh failed")}async function ee(){await window.ipcRenderer.invoke("refresh-coze-com-view")?te.success("Refresh succeed"):te.error("Refresh failed")}async function ie(){await window.ipcRenderer.invoke("refresh-coze-cn-view")?te.success("Refresh succeed"):te.error("Refresh failed")}async function ce(){const e=I.dict["chatgpt.com"],t=await window.ipcRenderer.invoke("login-get-token",{url:e.tokenUrl,userAgent:"",script:"",show:!1,autoClose:!0});e.playground.apiKey=t.token,te.success("Refresh succeed")}async function re(){const e=I.dict.magai,t=await window.ipcRenderer.invoke("login-get-token",{url:e.tokenUrl,userAgent:"",script:"",show:!1,autoClose:!0});e.playground.apiKey=t.token,te.success("Refresh succeed")}const ue=a(!1),de=a(!1),ve=a(!1),Me=a(!1),Ie=()=>{if(!C.value)return;const e=C.value.querySelector(".chat-container-content"),t=e.scrollTop,a=e.scrollHeight,l=e.clientHeight;ue.value=t>200,de.value=a-t-l>200,ve.value=ue.value||de.value},Ve=()=>{C.value.querySelector(".chat-container-content").scrollTo({top:0,behavior:"smooth"})},Ae=()=>{const e=C.value.querySelector(".chat-container-content");e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},Se=e=>{Me.value=e};return o((()=>{C.value.querySelector(".chat-container-content").addEventListener("scroll",Ie)})),(t,a)=>{var l,o;const x=G,j=K,M=H,A=$,R=le,te=ae,Ie=D,Ee=X,Te=ne,Re=se,Pe=oe;return s(),n("div",Xe,[v("div",Ye,[v("div",Ze,[v("div",Qe,[u(x,{size:"20px"},{icon:d((()=>[(s(),c(g(m(I).icons[e.chatModel.model.type])))])),_:1}),v("div",et,[u(te,{placement:"bottom","cancel-btn":null,"confirm-btn":null},{content:d((()=>[v("div",tt,[a[21]||(a[21]=v("p",null,"Model Info",-1)),v("p",null,[v("span",null,p(t.$t("pages.setting.model.model_name")),1),f(p(e.chatModel.model.name),1)]),v("p",null,[v("span",null,p(t.$t("pages.setting.model.model_interface")),1),f(p(e.chatModel.model.type),1)]),v("p",null,[v("span",null,p(t.$t("pages.setting.model.model_address")),1),f(p(e.chatModel.model.apiBase),1)]),u(M,{label:m(V)("pages.conversation.temperature"),name:"temperature",labelAlign:"left",labelWidth:"64px"},{default:d((()=>[u(j,{modelValue:e.chatModel.model.temperature,"onUpdate:modelValue":a[0]||(a[0]=t=>e.chatModel.model.temperature=t),inputNumberProps:"",showStep:"",min:0,max:1,step:.1},null,8,["modelValue"])])),_:1},8,["label"]),u(M,{label:m(V)("pages.conversation.maxTokens"),name:"maxTokens",labelAlign:"left",labelWidth:"64px"},{default:d((()=>[u(j,{modelValue:e.chatModel.model.maxTokens,"onUpdate:modelValue":a[1]||(a[1]=t=>e.chatModel.model.maxTokens=t),inputNumberProps:"",showStep:"",min:1024,max:8192,step:128},null,8,["modelValue"])])),_:1},8,["label"]),u(M,{label:m(V)("pages.conversation.topP"),name:"topP",labelAlign:"left",labelWidth:"64px"},{default:d((()=>[u(j,{modelValue:e.chatModel.model.topP,"onUpdate:modelValue":a[2]||(a[2]=t=>e.chatModel.model.topP=t),inputNumberProps:"",showStep:"",min:0,max:1,step:.1},null,8,["modelValue"])])),_:1},8,["label"]),v("p",null,[v("span",null,p(L.value),1),f(p(W.value.apiBase),1)]),v("p",at,[v("span",null,p(J.value),1),f(p(W.value.apiKey),1)]),v("p",null,[a[15]||(a[15]=v("span",null,"Model ",-1)),f(p(e.chatModel.model.apiModel),1)]),"vercel"===e.chatModel.model.type?(s(),c(A,{key:0,theme:"primary",onClick:Q},{default:d((()=>a[16]||(a[16]=[f("refresh vercel.ai ")]))),_:1})):r("",!0),"coze.com"===e.chatModel.model.type?(s(),c(A,{key:1,theme:"primary",onClick:ee},{default:d((()=>a[17]||(a[17]=[f("refresh coze.com ")]))),_:1})):r("",!0),"coze.cn"===e.chatModel.model.type?(s(),c(A,{key:2,theme:"primary",onClick:ie},{default:d((()=>a[18]||(a[18]=[f("refresh coze.cn ")]))),_:1})):r("",!0),"chatgpt.com"===e.chatModel.model.type?(s(),c(A,{key:3,theme:"primary",onClick:ce},{default:d((()=>a[19]||(a[19]=[f("refresh chatgpt.com ")]))),_:1})):r("",!0),"magai"===e.chatModel.model.type?(s(),c(A,{key:4,theme:"primary",onClick:re},{default:d((()=>a[20]||(a[20]=[f("refresh magai.co ")]))),_:1})):r("",!0)])])),default:d((()=>[u(R,{theme:"primary",title:B.value,class:"block w-full whitespace-nowrap text-ellipsis overflow-hidden"},{default:d((()=>[f(p(B.value),1)])),_:1},8,["title"])])),_:1})])]),v("div",lt,[u(Ie,{content:m(V)("pages.conversation.maximize_minimize")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a[3]||(a[3]=_((t=>{return a=e.chatModel,void E("change-size",a.model.id);var a}),["stop"]))},{default:d((()=>[e.chatModel.chat.modelId==e.fullScreenModelId?(s(),c(m(pe),{key:0,slot:"icon"})):(s(),c(m(me),{key:1,slot:"icon"}))])),_:1})])),_:1},8,["content"]),u(Ie,{content:m(V)("pages.conversation.stop_answering")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a[4]||(a[4]=_((t=>{return a=e.chatModel,void E("stop-chat",a.model.id);var a}),["stop"]))},{default:d((()=>[u(m(he),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(Ie,{content:m(V)("pages.conversation.regenerate_last_conversation")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a[5]||(a[5]=_((t=>T(e.chatModel)),["stop"]))},{default:d((()=>[u(m(fe),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(te,{theme:"danger",content:m(V)("pages.conversation.confirm_delete_chat_history"),placement:"top",onConfirm:a[6]||(a[6]=t=>{return a=e.chatModel,void E("clear-chat-history",a.model.id);var a})},{default:d((()=>[u(Ie,{content:m(V)("pages.conversation.delete_chat_history")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline"},{default:d((()=>[u(m(ge),{slot:"icon"})])),_:1})])),_:1},8,["content"])])),_:1},8,["content"]),u(te,{theme:"warning",content:m(V)("pages.conversation.confirm_clear_context"),placement:"top",onConfirm:a[7]||(a[7]=t=>{return a=e.chatModel,void E("clear-chat-context",a.model.id);var a})},{default:d((()=>[u(Ie,{content:m(V)("pages.conversation.clear_context")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline"},{default:d((()=>[u(m(_e),{slot:"icon"})])),_:1})])),_:1},8,["content"])])),_:1},8,["content"]),u(Ie,{content:m(V)("pages.conversation.inherit_other_model_conversation")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a[8]||(a[8]=_((t=>{return a=e.chatModel,void E("extend-model-visible",a.model.id);var a}),["stop"]))},{default:d((()=>[u(m(xe),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(Ie,{content:m(V)("pages.conversation.api_conversation_settings")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a[9]||(a[9]=_((t=>{return a=e.chatModel,void E("api-setting-visible",a.model.id);var a}),["stop"]))},{default:d((()=>[u(m(be),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(Ie,{content:m(V)("pages.conversation.toggle_artifacts")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a[10]||(a[10]=_((e=>{F.value=!F.value}),["stop"]))},{default:d((()=>[u(m(we),{slot:"icon"})])),_:1})])),_:1},8,["content"])])])]),v("div",{class:"flex flex-1 overflow-hidden bg-color-container rounded-b-lg shadow-md w-full",onMouseenter:a[13]||(a[13]=e=>Se(!0)),onMouseleave:a[14]||(a[14]=e=>Se(!1))},[v("div",{class:"flex-1 relative h-full overflow-hidden",ref_key:"scrollable_chat",ref:C},[u(Pe,{"data-chat-id":e.chatModel.model.id,class:w(["flex flex-col h-full overflow-y-auto chat-container-content scrollable-chat relative",{chating:e.chatModel.chat.status.chating}]),scroll:{type:"virtual"},onMouseupPassive:null==(l=z.value)?void 0:l.showToolbox,onMousedownPassive:null==(o=z.value)?void 0:o.hideToolbox},{default:d((()=>[(s(!0),n(i,null,h(S.value,((t,l)=>(s(),c(Re,{key:l,class:"w-full"},{default:d((()=>["user"===t.role?(s(),n("div",ot,[v("div",{class:"flex flex-col gap-2 w-[calc(100%-24px-1rem)]","data-index":`${l}`},[v("div",st,[f(p(m(k).name)+" ",1),v("div",it,[u(te,{theme:"danger",content:m(V)("pages.conversation.dialog_confirm_delete_record"),placement:"bottom",onConfirm:e=>(e=>{const t=S.value.findIndex((t=>t===e));-1!==t&&(S.value.splice(t,1),t<S.value.length&&"assistant"===S.value[t].role&&S.value.splice(t,1))})(t)},{default:d((()=>[u(Ie,{content:m(V)("pages.conversation.button_tooltip_delete"),placement:"bottom"},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline"},{default:d((()=>[u(m(ye),{slot:"icon"})])),_:1})])),_:1},8,["content"])])),_:2},1032,["content","onConfirm"]),u(Ie,{content:m(V)("pages.conversation.button_tooltip_editor"),placement:"bottom"},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:e=>U(l)},{default:d((()=>[u(m(ke),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),u(Ie,{content:m(V)("pages.conversation.button_tooltip_copy")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:e=>q(t)},{default:d((()=>[u(m(je),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),u(Ie,{content:m(V)("pages.conversation.button_tooltip_favourite"),placement:"bottom"},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a=>{return l=e.chatModel,void E("fav-note-visible",l,t);var l}},{default:d((()=>[u(m(Ce),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),l===e.chatModel.chat.chats.length-2?(s(),c(Ie,{key:0,content:m(V)("pages.conversation.button_tooltip_refresh")},{default:d((()=>[u(A,{size:"small",shape:"circle",variant:"outline",onClick:a[11]||(a[11]=t=>T(e.chatModel))},{default:d((()=>[u(m(fe),{slot:"icon"})])),_:1})])),_:1},8,["content"])):r("",!0)])]),v("div",ct,[u(Be,{content:t.content,isEditing:P.value===l,onSave:O,onCancel:N},null,8,["content","isEditing"])])],8,nt),v("div",rt,[u(x,{size:"24px",image:m(k).avatar},null,8,["image"])])])):"assistant"===t.role?(s(),n("div",ut,[v("div",dt,[u(x,{size:"24px",image:e.conversation.avatar},null,8,["image"]),v("div",vt,p(e.conversation.name),1)]),v("div",pt,[v("div",{"data-index":`${l}`},[e.chatModel.chat.status.responseWating&&l===e.chatModel.chat.chats.length-1?(s(),n("span",ht)):(s(),c(qe,{key:1,content:t.content,isEditing:P.value===l,onSave:O,onCancel:N},null,8,["content","isEditing"])),t.content.webs&&t.content.webs.length>0?(s(),n("div",ft,[(s(!0),n(i,null,h(t.content.webs,(e=>(s(),n("div",{class:"bg-color-page p-2 w-60 cursor-pointer",onClick:t=>{return a=e.url,void(window.ipcRenderer?window.ipcRenderer.send("open-url",a):window.open(a));var a}},[v("div",_t,[v("div",xt,[v("img",{src:e.icon,alt:""},null,8,bt)]),v("div",wt,[v("div",yt,p(e.title),1),v("div",kt,p(e.url),1)])]),v("div",jt,p(e.excerpt),1)],8,gt)))),256))])):r("",!0)],8,mt),v("div",Ct,[v("div",zt,[t.model?(s(),c(Ee,{key:0,class:"max-w-60 model-tag"},{default:d((()=>[f(p(t.model),1)])),_:2},1024)):r("",!0),u(Ie,{content:m(V)("pages.conversation.button_tooltip_editor"),placement:"bottom"},{default:d((()=>[u(A,{size:"small",variant:"outline",onClick:e=>U(l)},{default:d((()=>[u(m(ke),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),u(Ie,{content:m(V)("pages.conversation.button_tooltip_copy")},{default:d((()=>[u(A,{size:"small",variant:"outline",onClick:e=>q(t)},{default:d((()=>[u(m(je),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),u(Ie,{content:m(V)("pages.conversation.toggle_artifacts")},{default:d((()=>[u(A,{size:"small",variant:"outline",onClick:e=>{var a;"assistant"===(a=t).role&&(Y.value=a.content.text,F.value=!0)}},{default:d((()=>[u(m(we),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),l===e.chatModel.chat.chats.length-1?(s(),c(Ie,{key:1,content:m(V)("pages.conversation.button_tooltip_refresh")},{default:d((()=>[u(A,{size:"small",variant:"outline",onClick:a[12]||(a[12]=t=>T(e.chatModel))},{default:d((()=>[u(m(fe),{slot:"icon"})])),_:1})])),_:1},8,["content"])):r("",!0)])])])])):"verbose"===t.role?(s(),c(Te,{key:2},{default:d((()=>[f(p(t.content.text),1)])),_:2},1024)):(s(),n("div",Mt,p(t.role)+" - "+p(t.content.text),1))])),_:2},1024)))),128))])),_:1},8,["data-chat-id","class","onMouseupPassive","onMousedownPassive"]),u(He,{ref_key:"toolbar",ref:z,parent:C.value},null,8,["parent"]),a[22]||(a[22]=v("div",{class:"absolute z-50 bottom-0 w-full h-20 rounded-b-lg chat-model-footer pointer-events-none"},null,-1))],512),F.value?(s(),n("div",{key:0,class:w([e.chatModel.chat.modelId===e.fullScreenModelId?"w-1/2":"w-full","pr-4"])},[u(We,{content:Y.value,closeBtn:Z},null,8,["content"])],2)):r("",!0),b(v("div",It,[b(u(A,{class:"scroll-top-btn",shape:"circle",onClick:Ve},{icon:d((()=>[u(m(ze))])),_:1},512),[[y,ue.value]]),b(u(A,{class:"scroll-bottom-btn",shape:"circle",onClick:Ae},{icon:d((()=>[u(m(ze),{style:{transform:"rotateX(180deg)"}})])),_:1},512),[[y,de.value]])],512),[[y,ve.value&&Me.value]])],32)])}}}),At={class:"flex flex-col items-center h-full relative"},St={class:"w-full flex gap-2 absolute bottom-0 z-50"},Et={class:"rounded-lg px-1 bg-color-container bordered flex items-center align-middle"},Tt={class:"flex flex-col justify-center items-center w-full"},Rt={class:"flex flex-col gap-5 w-full overflow-hidden"},Pt={class:"max-h-96 no-scrollbar overflow-auto bordered p-2 shadow-sm"},Ut=e({name:"ListConversation",setup(e){const o=A(),r=S(),N=Ee(),B=z(),L=R();P();const K=a(null),J=a(null);let F=!1;const X=a([]),Y=M(),Z=U(),Q=a(!1),le=async e=>{if(e.content)try{X.value.forEach((t=>{if(""!==Xe.value&&Xe.value!==t.model.id)return;const a=Oe(e.content);e.files.forEach((e=>{e.type.startsWith("image")?a.images.push({...e,model:""}):a.files.push(e)})),t.chat.chats.push({role:"user",content:a,id:"",liked:!1,model:""}),t.chat.chats.push({role:"assistant",content:Oe(""),id:"",liked:!1,model:""})})),E.setPause(!0);const t=X.value.map(((e,t)=>{if((""===Xe.value||Xe.value===e.model.id)&&!0!==e.chat.status.chating)return e.chat.status.chating=!0,e.chat.status.stop=!1,e.chat.status.responseWating=!0,e})).filter((e=>e));if(0===t.length)return;await pt(0),vt();let a="";if(J.value.internet){const l=await Pe(e.content);t.map((e=>{e.chat.chats[e.chat.chats.length-1].content.webs=l.map((e=>({title:e.title,icon:e.icon,excerpt:e.excerpt,url:e.url})))})),l.length>0&&(a=JSON.stringify(l.map((e=>({content:e.content,url:e.url})))))}const l=t.map(((e,t)=>new Promise(((l,o)=>{setTimeout((()=>{const t=Ue(J.value,e,a);l(t)}),100*t)}))));await Promise.all(l)}finally{F=!1,E.setPause(!1),B.$persist()}else te.error(V("pages.conversation.question_cannot_be_empty"))},oe=async()=>{try{if(""!==Xe.value)return void ne(Xe.value);E.setPause(!0);const e=X.value.map(((e,t)=>{if(0===e.chat.chats.length)return;if(!0===e.chat.status.chating)return;const a=e.chat.chats[e.chat.chats.length-1];if("assistant"==a.role)return Re(a.content),a.model="",e.chat.status.chating=!0,e.chat.status.stop=!1,e.chat.status.responseWating=!0,e;te.error(V("pages.conversation.please_start_question_again"))})).filter((e=>e));if(0===e.length)return;await pt(0),vt();let t="";if(J.value.internet){const a=e.find((e=>e.chat.chats.length>0));if(a){const l=a.chat.chats,o=l[l.length-2];if(o){const a=await Pe(o.content.text);e.map((e=>{e.chat.chats[e.chat.chats.length-1].content.webs=a.map((e=>({title:e.title,icon:e.icon,excerpt:e.excerpt,url:e.url})))})),a.length>0&&(t=JSON.stringify(a.map((e=>({content:e.content,url:e.url})))))}}}const a=e.map(((e,a)=>new Promise(((l,o)=>{setTimeout((()=>{const a=Ue(J.value,e,t);l(a)}),100*a)}))));await Promise.all(a)}finally{F=!1,E.setPause(!1),B.$persist()}},ne=async e=>{try{const t=X.value.find((t=>t.model.id===e));if(0===t.chat.chats.length)return;E.setPause(!0);const a=t.chat.chats[t.chat.chats.length-1];if("assistant"!=a.role)return void te.error(V("pages.conversation.please_start_question_again"));if(!0===t.chat.status.chating)return;Re(a.content),a.model="",t.chat.status.chating=!0,t.chat.status.stop=!1,t.chat.status.responseWating=!0;let l="";if(vt(),J.value.internet){const e=await Pe(t.chat.chats[t.chat.chats.length-2].content.text);a.content.webs=e.map((e=>({title:e.title,icon:e.icon,excerpt:e.excerpt,url:e.url}))),e.length>0&&(l=JSON.stringify(e.map((e=>({content:e.content,url:e.url})))))}await Ue(J.value,t,l)}finally{F=!1,E.setPause(!1),B.$persist()}},se=async()=>{""===Xe.value?(X.value.forEach((e=>{e.chat.chats.push({role:"verbose",content:Oe(V("pages.conversation.context_cleared")),id:"",liked:!1,model:""}),e.chat.startContext=e.chat.chats.length})),te.success(V("pages.conversation.context_cleared_success")),await pt(0)):ye(Xe.value)},ve=()=>{B.showEditorDrawer=!0},pe=e=>{const t=X.value.find((t=>t.chat.modelId===e));t.chat.status.stop=!0,t.chat.status.responseWating=!1,t.chat.status.chating=!1},me=()=>{""===Xe.value?X.value.forEach((e=>{e.chat.status.stop=!0,e.chat.status.responseWating=!1,e.chat.status.chating=!1})):pe(Xe.value)},be=()=>{J.value.internet=!J.value.internet},we=()=>{""===Xe.value?X.value.forEach((e=>{e.chat.chats=[],e.chat.startContext=0})):ke(Xe.value)},ye=e=>{const t=X.value.find((t=>t.chat.modelId===e)).chat;t.chats.push({role:"verbose",content:Oe(V("pages.conversation.context_cleared")),id:"",liked:!1,model:""}),t.startContext=t.chats.length,te.success(V("pages.conversation.context_cleared_success")),C((()=>{const t=document.querySelector(`[data-chat-id="${e}"]`);t&&t.scrollTo({top:t.scrollHeight,behavior:"smooth"})}))},ke=e=>{const t=X.value.find((t=>t.chat.modelId===e)).chat;t.chats=[],t.startContext=0},je=a(!1),Ce=a(""),ze=a(""),Se=e=>{je.value=!0,ze.value="",Ce.value=e},Te=async()=>{if(!ze.value)return void(je.value=!1);const e=J.value.models.find((e=>e.modelId===ze.value));if(Ce.value){const t=J.value.models.find((e=>e.modelId===Ce.value));t.chats=JSON.parse(JSON.stringify(e.chats)),t.startContext=0}else J.value.models.forEach((t=>{t.modelId!=ze.value&&(t.chats=JSON.parse(JSON.stringify(e.chats)),t.startContext=0)}));je.value=!1,await pt(0)},Be=a(!1),qe=a(""),He=a(""),We=a("");let Le="";const Ke=e=>{Be.value=!0,Le=e;const t=J.value.models.find((e=>e.modelId===Le));He.value=t.apiConversationId,qe.value=t.apiAgentId,We.value=t.apiNote},Je=()=>{var e,t,a;const l=J.value.models.find((e=>e.modelId===Le));l.apiConversationId=null==(e=He.value)?void 0:e.trim(),l.apiAgentId=null==(t=qe.value)?void 0:t.trim(),l.apiNote=null==(a=We.value)?void 0:a.trim(),Be.value=!1};async function Fe(){const e=X.value.find((e=>e.chat.modelId===Le));if("lyihub"===e.model.type){const t=await $e(e.model.apiKey);He.value=t.id}else He.value=Ae()}const Xe=a(""),Ye=e=>{1!==X.value.length&&(""===Xe.value?Xe.value=e:Xe.value="")},Ze=a(!1),Qe=a(""),et=N.list;let tt=null,at=null;const lt=async(e,t)=>{Ze.value=!0,Qe.value="",tt=e,at=t},ot=async()=>{const e=tt.chat.chats,t=e.findIndex((e=>e===at)),a=e[t].content.text;let l="";const n=t+1;n<e.length&&"assistant"===e[n].role&&(l=e[n].content.text);const s={id:Ae(),title:a,time:(new Date).getTime(),conversationId:J.value.id,conversationName:J.value.name,conversationAvatar:J.value.avatar,chats:[{...e[t],content:{...e[t].content}},{...e[n],content:{...e[n].content}}],notes:[]};if(N.add(s),te.success(V("pages.conversation.favorite_success")),o.assistModel){const e=V("pages.conversation.extract_core_conversation",{question:a,answer:l});await Ne(e,(e=>{s.title=e,s.title=s.title.replaceAll("###",""),s.title=s.title.trim(),N.update(s)}))}Ze.value=!1},nt=async()=>{if(!Qe)return void(Ze.value=!1);const e=et.find((e=>e.id==Qe.value)),t=tt.chat.chats,a=t.findIndex((e=>e===at)),l=a+1;e.chats.push({...t[a],content:{...t[a].content}}),e.chats.push({...t[l],content:{...t[l].content}}),N.update(e),te.success(V("pages.conversation.favorite_success")),Ze.value=!1},st=t((()=>S().isSidebarCompact)),it=t((()=>""!==Xe.value||1===X.value.length||st.value?12:2===X.value.length?6:3===X.value.length?4:4===X.value.length?3:5===X.value.length||6===X.value.length?4:7===X.value.length||8===X.value.length?3:12)),ct=t((()=>""!==Xe.value||1===X.value.length||st.value||2===X.value.length||3===X.value.length||4===X.value.length?"h-[calc(100%-10px)]":5===X.value.length||6===X.value.length||7===X.value.length||8===X.value.length?"h-[calc(50%-10px)]":"h-[calc(100%-10px)]")),rt=t((()=>{let e="h-[calc(100vh-56px-2*var(--td-comp-paddingTB-m))]";return r.showLayoutHeader&&r.showFooter&&(e="h-[calc(100vh-56px-var(--td-comp-size-xxl)-var(--td-comp-size-xxxl)-2*var(--td-comp-paddingTB-m))]"),r.showLayoutHeader&&!r.showFooter&&(e="h-[calc(100vh-56px-var(--td-comp-size-xxxl)-2*var(--td-comp-paddingTB-m))]"),!r.showLayoutHeader&&r.showFooter&&(e="h-[calc(100vh-56px-var(--td-comp-size-xxl)-2*var(--td-comp-paddingTB-m))]"),[e,{"chat-container-collapsed":st.value&&X.value.length>1&&!Xe.value}]})),ut=()=>{const e=X.value.map((e=>e.chat)),t=new Set(e),a=J.value.models.filter((e=>!t.has(e)));J.value.models=[...e,...a]},dt=new Map,vt=async()=>{if(!K.value)return;F=!0,await C();const e=K.value.querySelectorAll(".chating");for(;F;)await new Promise((e=>setTimeout(e,200))),e.forEach((e=>{const t=e.getAttribute("data-chat-id");if(t){if(!dt.has(t)){dt.set(t,!0);const a=()=>{const a=e.scrollHeight-e.scrollTop-e.clientHeight;a>80?dt.set(t,!1):a<50&&dt.set(t,!0)};e.onscroll=a,e.addEventListener("scroll",a)}dt.get(t)&&(null==e||e.scrollTo({top:e.scrollHeight,behavior:"instant"}))}}))};async function pt(e){if(await new Promise((t=>setTimeout(t,e))),!K.value)return;K.value.querySelectorAll(".scrollable-chat").forEach((e=>{null==e||e.scrollTo({top:e.scrollHeight,behavior:"instant"})}))}k((()=>{mt()}));const mt=()=>{(()=>{if(!K.value)return;K.value.querySelectorAll("[data-chat-id]").forEach((e=>{const t=e.getAttribute("data-chat-id");if(t){const a=e.onscroll;a&&e.removeEventListener("scroll",a),dt.delete(t)}}))})(),dt.clear()};x((()=>{J.value&&(mt(),ht())}));const ht=()=>{X.value=J.value.models.map((e=>{const t=Y.find(e.modelId);if(t&&e.showing)return{model:t,chat:e,id:e.modelId}})).filter(Boolean)};l((()=>L.query.id),(async e=>{var t;if("/conversation/chat"!==L.path)return J.value=null,void mt();let a=e,l=J.value;J.value=B.find(a),Xe.value="",ht();!L.query.isNew||!(null==(t=T.data)?void 0:t.content)||0===J.value.models.length||J.value.models[0].chats.length>0?await pt(l?0:500):le(T.data)}),{immediate:!0});const ft=t((()=>J.value.internet?{color:"green"}:{}));return(e,t)=>{const a=ie,l=$,o=D,r=ae,x=ce,k=G,C=de,z=ue,M=re,A=ee,S=W,E=H,T=q;return b((s(),n("div",At,[v("div",{class:w(["w-full",rt.value]),ref_key:"chatContainer",ref:K},[u(m(De),{tag:"t-row",modelValue:X.value,"onUpdate:modelValue":t[0]||(t[0]=e=>X.value=e),handle:".handle","component-data":{align:"top",gutter:10},onEnd:ut,"item-key":"id",class:"h-full"},{item:d((({element:e})=>[(s(),c(a,{span:it.value,key:e.model.id,class:w([ct.value,{hidden:""!==Xe.value&&Xe.value!==e.model.id}])},{default:d((()=>[u(Vt,{"chat-model":e,conversation:J.value,"data-index":`${e.model.id}`,"full-screen-model-id":Xe.value,onStopChat:pe,onExtendModelVisible:Se,onReChat:ne,onChangeSize:Ye,onApiSettingVisible:Ke,onFavNoteVisible:lt,onClearChatContext:ye,onClearChatHistory:ke},null,8,["chat-model","conversation","data-index","full-screen-model-id"])])),_:2},1032,["span","class"]))])),_:1},8,["modelValue"])],2),v("div",St,[u(O,{class:"flex-1",onInput:le}),v("div",Et,[m(Z)?(s(),c(x,{key:1,delay:0,modelValue:Q.value,"onUpdate:modelValue":t[7]||(t[7]=e=>Q.value=e),onOverlayClick:t[8]||(t[8]=e=>Q.value=!1)},{content:d((()=>[v("div",Tt,[u(l,{size:"large",shape:"circle",variant:"text",onClick:be},{default:d((()=>[u(m(Me),{slot:"icon",style:j(ft.value)},null,8,["style"])])),_:1}),u(l,{size:"large",shape:"circle",variant:"text",onClick:me},{default:d((()=>[u(m(he),{slot:"icon"})])),_:1}),u(l,{size:"large",shape:"circle",variant:"text",onClick:oe},{default:d((()=>[u(m(fe),{slot:"icon"})])),_:1}),u(l,{size:"large",shape:"circle",variant:"text",onClick:t[2]||(t[2]=e=>Se(""))},{default:d((()=>[u(m(xe),{slot:"icon"})])),_:1}),u(r,{theme:"danger",content:m(V)("pages.conversation.confirm_delete_all_chat_records"),placement:"left",onConfirm:t[4]||(t[4]=()=>{we(),Q.value=!1})},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text",onClick:t[3]||(t[3]=_((()=>{}),["stop"]))},{default:d((()=>[u(m(ge),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(r,{theme:"warning",content:m(V)("pages.conversation.confirm_clear_all_context"),placement:"left",onConfirm:t[6]||(t[6]=()=>{se(),Q.value=!1})},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text",onClick:t[5]||(t[5]=_((()=>{}),["stop"]))},{default:d((()=>[u(m(_e),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(l,{size:"large",shape:"circle",variant:"text",onClick:ve},{default:d((()=>[u(m(Ie),{slot:"icon"})])),_:1})])])),default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text"},{default:d((()=>[u(m(Ve),{slot:"icon"})])),_:1})])),_:1},8,["modelValue"])):(s(),n(i,{key:0},[u(o,{content:m(V)("pages.conversation.internet_search")},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text",onClick:_(be,["stop"])},{default:d((()=>[u(m(Me),{slot:"icon",style:j(ft.value)},null,8,["style"])])),_:1})])),_:1},8,["content"]),u(o,{content:m(V)("pages.conversation.stop_answering")},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text",onClick:_(me,["stop"])},{default:d((()=>[u(m(he),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(o,{content:m(V)("pages.conversation.regenerate_last_conversation")},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text",onClick:_(oe,["stop"])},{default:d((()=>[u(m(fe),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(o,{content:m(V)("pages.conversation.inherit_other_model_conversation"),placement:"top"},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text",onClick:t[1]||(t[1]=_((e=>Se("")),["stop"]))},{default:d((()=>[u(m(xe),{slot:"icon"})])),_:1})])),_:1},8,["content"]),u(r,{theme:"danger",content:m(V)("pages.conversation.confirm_delete_all_chat_records"),placement:"top",onConfirm:we},{default:d((()=>[u(o,{content:m(V)("pages.conversation.delete_all_chat_records"),placement:"top"},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text"},{default:d((()=>[u(m(ge),{slot:"icon"})])),_:1})])),_:1},8,["content"])])),_:1},8,["content"]),u(r,{theme:"warning",content:m(V)("pages.conversation.confirm_clear_all_context"),placement:"top",onConfirm:se},{default:d((()=>[u(o,{content:m(V)("pages.conversation.clear_all_context"),placement:"top"},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text"},{default:d((()=>[u(m(_e),{slot:"icon"})])),_:1})])),_:1},8,["content"])])),_:1},8,["content"]),u(o,{content:m(V)("pages.conversation.edit_current_conversation"),placement:"top"},{default:d((()=>[u(l,{size:"large",shape:"circle",variant:"text",onClick:ve},{default:d((()=>[u(m(Ie),{slot:"icon"})])),_:1})])),_:1},8,["content"])],64))])]),u(Ge),u(A,{header:m(V)("pages.conversation.inherit_model_dialog"),visible:je.value,"onUpdate:visible":t[10]||(t[10]=e=>je.value=e),"on-confirm":Te,class:"extend-model"},{default:d((()=>[u(M,{class:"w-full",modelValue:ze.value,"onUpdate:modelValue":t[9]||(t[9]=e=>ze.value=e)},{default:d((()=>[u(z,{gutter:[16,16],class:"w-full"},{default:d((()=>[(s(!0),n(i,null,h(X.value,(e=>(s(),c(a,{span:12},{default:d((()=>[u(C,{value:e.model.id,disabled:Ce.value===e.model.id},{default:d((()=>[u(k,{size:"20px",class:"mr-1"},{icon:d((()=>[(s(),c(g(m(I).icons[e.model.type])))])),_:2},1024),f(" "+p(m(I).getModelItemTitle(e.model)),1)])),_:2},1032,["value","disabled"])])),_:2},1024)))),256))])),_:1})])),_:1},8,["modelValue"])])),_:1},8,["header","visible"]),u(A,{header:m(V)("pages.conversation.api_conversation_settings"),visible:Be.value,"onUpdate:visible":t[14]||(t[14]=e=>Be.value=e),"on-confirm":Je},{default:d((()=>[u(T,{"label-align":"top"},{default:d((()=>[u(E,{label:m(V)("pages.conversation.api_agent"),name:"apiSettingAgent"},{default:d((()=>[u(S,{modelValue:qe.value,"onUpdate:modelValue":t[11]||(t[11]=e=>qe.value=e)},null,8,["modelValue"])])),_:1},8,["label"]),u(E,{label:m(V)("pages.conversation.api_conversation_id"),name:"apiSettingConversation"},{default:d((()=>[u(S,{modelValue:He.value,"onUpdate:modelValue":t[12]||(t[12]=e=>He.value=e)},null,8,["modelValue"]),u(l,{class:"ml-2",onClick:Fe},{default:d((()=>[f(p(m(V)("pages.conversation.api_conversation_id_random")),1)])),_:1})])),_:1},8,["label"]),u(E,{label:m(V)("pages.conversation.remarks"),name:"apiSettingNode"},{default:d((()=>[u(S,{modelValue:We.value,"onUpdate:modelValue":t[13]||(t[13]=e=>We.value=e)},null,8,["modelValue"])])),_:1},8,["label"])])),_:1})])),_:1},8,["header","visible"]),u(A,{header:m(V)("pages.conversation.button_tooltip_favourite"),visible:Ze.value,"onUpdate:visible":t[16]||(t[16]=e=>Ze.value=e),confirmBtn:null},{default:d((()=>[v("div",Rt,[v("div",Pt,[u(M,{modelValue:Qe.value,"onUpdate:modelValue":t[15]||(t[15]=e=>Qe.value=e)},{default:d((()=>[u(z,{gutter:[16,16]},{default:d((()=>[(s(!0),n(i,null,h(m(et),(e=>(s(),c(a,{span:12},{default:d((()=>[u(C,{value:e.id,class:"grid grid-flow-col auto-cols-max fav-radio fav-radio-dialog"},{default:d((()=>[f(p(e.title),1)])),_:2},1032,["value"])])),_:2},1024)))),256))])),_:1})])),_:1},8,["modelValue"])]),u(l,{onClick:nt,theme:"default",variant:"outline"},{default:d((()=>t[17]||(t[17]=[f("添加到笔记")]))),_:1}),u(l,{onClick:ot,theme:"default",variant:"outline"},{default:d((()=>t[18]||(t[18]=[f("创建新的笔记")]))),_:1})])])),_:1},8,["header","visible"])],512)),[[y,J.value]])}}});export{Ut as default};
|
.output/public/assets/content-CMwtYO4S.js
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import{_ as e,A as t,b as o,a as l}from"./CodeBlocks.vue_vue_type_style_index_0_lang-DWS4lyNS.js";import{_ as a}from"./ChatInput.vue_vue_type_style_index_0_lang-CF8t52ZG.js";import{b as s,u as n,d as i,t as r,m as u}from"./global-BveI--BU.js";import{a as c,u as d}from"./vue-router-Be5-2oBH.js";import{m as p}from"./markdown-DPs5ApTw.js";import{s as m,c as v,P as f,T as j,A as g,r as x,g as h,f as y}from"./tdesign-vue-next-DsCOKp3d.js";import{c as _,ad as b,_ as k,a4 as w,a5 as C,a3 as T,ae as z}from"./tdesign-icons-vue-next-Dn30dVUK.js";import{l as E,f as B,a as S,w as $,v as H,y as I,z as O,A as M,R as V,aa as L,u as R,F as q,n as P,J as A,ab as D,I as F,H as N}from"./@vue-DsZlmJIP.js";import{e as J}from"./fetch-2coGNStX.js";import{a as U}from"./main-zbluuG_-.js";import"./uuid-_R2nDvl_.js";import"./@wdns-P0uM2sk1.js";import"./ua-parser-js-9pz7LJLQ.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./mammoth-5Ncu60I4.js";import"./elkjs-CmFeGg_o.js";import"./xlsx-DB6BMndo.js";import"./pdfjs-dist-8WFUNQXM.js";import"./lodash-Cky9m9r7.js";import"./@vueuse-Cn3Nsuq9.js";import"./vue-i18n-Dmk40Gks.js";import"./@intlify-eboPrqDD.js";import"./pinia-jKJ-xldK.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./markdown-it-link-attributes-UnOqz_aA.js";import"./markdown-it-C8SkdHr7.js";import"./mdurl-CDXpswLz.js";import"./uc.micro-CLkLCS2f.js";import"./entities-D7HTx9ov.js";import"./linkify-it-LcVOBuC5.js";import"./punycode.js-Bmr3cAX8.js";import"./@traptitech-BPk2gen6.js";import"./katex-BY7yyeOs.js";import"./markdown-it-highlightjs-Ikc7oQsB.js";import"./highlight.js-Ds8M-WS2.js";import"./@agoose77-mGnNv_bd.js";import"./mermaid-B98QzgAP.js";import"./dayjs-DOPU4UI6.js";import"./@braintree-DgpeZQRe.js";import"./d3-transition-swcnLnsT.js";import"./d3-timer-keMr1twq.js";import"./d3-dispatch-Chq_f_hl.js";import"./d3-interpolate-Ct9kki6l.js";import"./d3-color-D5ULnJIe.js";import"./d3-selection-G65jBFUY.js";import"./d3-ease-Cx6bG2vu.js";import"./d3-zoom-D4Vc87xO.js";import"./dompurify-B5jhUdWW.js";import"./dagre-d3-es-FtH4B9px.js";import"./lodash-es-BkU_-LF8.js";import"./d3-shape-C1TbtrGg.js";import"./d3-path-QSrLXsQ3.js";import"./d3-fetch-XwboCDHR.js";import"./khroma-Ca6ZlOUT.js";import"./ts-dedent-CttZBlkd.js";import"./stylis-Cl7w7uv3.js";import"./d3-scale-CjTvl_Qo.js";import"./internmap-B8oPgqVZ.js";import"./d3-array-B0evfIyH.js";import"./d3-format-C0lSXcPg.js";import"./d3-time-format-D74OpZq4.js";import"./d3-time-CebKitJR.js";import"./d3-axis-pCwzqJ1S.js";import"./cytoscape-D84qPEQv.js";import"./cytoscape-cose-bilkent-CoOmxuE9.js";import"./cose-base-kQthUiMK.js";import"./layout-base-DqRk0Tgc.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";import"./eventsource-parser-BEY8Dpg-.js";import"./@mozilla-BD532_dh.js";import"./vuedraggable-K5Gqz8r2.js";import"./vue-DVRmszIO.js";const K={key:0,class:"markdown-body"},W=["innerHTML"],X={key:1},Y={class:"flex justify-end mt-2 gap-5"},Z=E({__name:"NoteContent",props:{content:{type:String},isEditing:{type:Boolean,default:!1}},emits:["save","cancel"],setup(e,{emit:t}){const o=e,l=B((()=>p.render(o.content))),a=t,s=S(o.content),n=()=>{a("save",s.value)},i=()=>{s.value=o.content,a("cancel")},r=(e,t)=>{t.e.relatedTarget||i()},u=S(null);return $((()=>o.isEditing),(e=>{e&&(s.value=o.content,P((()=>{u.value.$el.querySelector("textarea").focus()})))})),(t,o)=>{const a=m,c=v;return I(),H(q,null,[e.isEditing?O("",!0):(I(),H("div",K,[M("div",{innerHTML:l.value},null,8,W)])),e.isEditing?(I(),H("div",X,[V(a,{ref_key:"textareaRef",ref:u,modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=e=>s.value=e),autosize:{minRows:2,maxRows:20},onBlur:r},null,8,["modelValue"]),M("div",Y,[V(c,{size:"large",shape:"circle",variant:"text",onClick:i},{default:L((()=>[V(R(_),{slot:"icon"})])),_:1}),V(c,{size:"large",shape:"circle",variant:"text",onClick:n},{default:L((()=>[V(R(b),{slot:"icon"})])),_:1})])])):O("",!0)],64)}}}),G={class:"flex justify-between w-full"},Q={class:"flex-1"},ee={key:0,class:"text-xl font-bold"},te={class:"flex align-middle items-center gap-2"},oe={class:"flex flex-1 overflow-hidden"},le={class:"flex-1 relative h-full overflow-y-auto no-scrollbar flex flex-col gap-5"},ae={key:0,class:"flex w-full justify-end items-start gap-2 note-item"},se={class:"flex justify-end overflow-hidden h-[24px]"},ne={class:"bg-color-page bordered p-4 rounded-lg"},ie={class:"flex justify-end gap-2 note-item-tools"},re={class:"w-[24px] h-[24px]"},ue={key:1,class:"flex w-full justify-end items-start flex-row-reverse gap-2 note-item"},ce={class:"flex flex-col gap-2 w-[calc(100%-24px-1rem)]"},de={class:"flex justify-between overflow-hidden h-[24px]"},pe={class:"bg-color-page bordered p-4 rounded-lg"},me={class:"flex justify-end gap-2 note-item-tools"},ve={class:"w-[24px] h-[24px]"},fe={class:"flex w-full justify-end note-item items-start gap-2"},je={class:"flex justify-end overflow-hidden h-[24px]"},ge={class:"bg-color-page bordered p-4 rounded-lg"},xe={key:0,class:"loader"},he={class:"flex justify-end gap-2 note-item-tools"},ye={class:"w-[24px] h-[24px]"},_e={key:0,class:"w-1/2"},be=E({__name:"content",setup(p){var m;const _=S(null),E=S(null),K=s(),W=U();c();const X=d(),Y=S(),be=n(),ke=S(!1),we=i();$((()=>X.query.id),(e=>{if("/note/content"!==X.path)return void(Y.value=null);let t=e;Y.value=W.find(t)}),{immediate:!0});const Ce=B((()=>be.showLayoutHeader&&be.showFooter?"h-[calc(100vh-var(--td-comp-size-xxl)-var(--td-comp-size-xxxl)-2*var(--td-comp-paddingTB-m))]":be.showLayoutHeader&&!be.showFooter?"h-[calc(100vh-var(--td-comp-size-xxxl)-2*var(--td-comp-paddingTB-m))]":!be.showLayoutHeader&&be.showFooter?"h-[calc(100vh-var(--td-comp-size-xxl)-2*var(--td-comp-paddingTB-m))]":"h-[calc(100vh-2*var(--td-comp-paddingTB-m))]"));let Te=null;const ze=S(!1),Ee=async e=>{var t;if(e.content)if(e.content.startsWith("@")){const{name:t,content:o}=function(e){const t=e.indexOf("@");if(-1===t)return null;let o=e.indexOf(" ",t);const l=e.indexOf("(",t),a=e.indexOf(")",t);return-1!==l&&-1!==a&&a>l?o=e.indexOf(" ",a):-1===o&&(o=e.length),{name:e.substring(t+1,o).trim(),content:e.substring(o).trim()}}(e.content),l="ai"===t?we.find(K.assistModel):we.enableModels.find((e=>u.getModelItemTitle(e)===t));let a=o;Y.value.notes.push(`# ${a}`);try{let e="";for(let t=0;t<Y.value.chats.length;t++){const o=Y.value.chats[t];"user"===o.role&&(e+=`<|im_start|>user\n${o.content}<|im_end|>\n`),"assistant"===o.role&&(e+=`<|im_start|>assistant\n${o.content}<|im_end|>\n`)}for(let t=0;t<Y.value.notes.length;t++){e+=`<|im_start|>user\n${Y.value.notes[t]}<|im_end|>`}e+=`<|im_start|>user\n${o}<|im_end|>`,Te=setInterval(Be,0),ze.value=!0,await J(l,e,(e=>{ze.value&&(ze.value=!1),Y.value.notes[Y.value.notes.length-1]=`# ${a}\n`+e}))}finally{null!==Te&&(clearInterval(Te),Te=null)}}else Y.value.notes.push(e.content),t=0,P((()=>{setTimeout((()=>{var e;null==(e=_.value)||e.scrollTo({top:_.value.scrollHeight,behavior:"smooth"})}),t)}));else y.error(r("pages.note.noteEmptyError"))},Be=async()=>{for(var e;null!==Te;)await new Promise((e=>setTimeout(e,300))),null==(e=_.value)||e.scrollTo({top:_.value.scrollHeight,behavior:"instant"})},Se=S(!1);let $e=S("");const He=()=>{Se.value=!1},Ie=S(null),Oe=S(null==(m=Y.value)?void 0:m.title),Me=(e,t)=>{t.e.relatedTarget||(ke.value=!1)},Ve=()=>{Y.value.title=Oe.value,ke.value=!1},Le=()=>{var e;Oe.value=null==(e=Y.value)?void 0:e.title,ke.value=!0,P((()=>{Ie.value.$el.querySelector("input").focus()}))},Re=S(-1),qe=e=>{Re.value=e},Pe=e=>{Y.value.chats[Re.value].content.text=e,Re.value=-1},Ae=()=>{Re.value=-1},De=S(-1),Fe=e=>{Y.value.notes[De.value]=e,De.value=-1},Ne=()=>{De.value=-1},Je=()=>{navigator.clipboard.writeText(JSON.stringify(Y.value)),y.success(r("pages.note.noteCopySuccess"))};return(s,n)=>{const i=x,u=v,c=j,d=f,p=g;return Y.value?(I(),A(R(h),{key:0,class:F(["note-page overflow-hidden flex flex-col",[Ce.value]]),"header-bordered":"",title:Y.value.title,bordered:!1},{header:L((()=>[M("div",G,[M("div",Q,[ke.value?(I(),A(i,{key:1,ref_key:"inputTitleRef",ref:Ie,type:"text",modelValue:Oe.value,"onUpdate:modelValue":n[0]||(n[0]=e=>Oe.value=e),onEnter:Ve,onBlur:Me},null,8,["modelValue"])):(I(),H("h1",ee,N(Y.value.title),1))]),M("div",te,[V(c,{content:R(r)("pages.note.noteRenameTooltip"),placement:"top"},{default:L((()=>[ke.value?(I(),A(u,{key:1,size:"small",shape:"circle",variant:"text",onClick:Ve},{default:L((()=>[V(R(b),{slot:"icon"})])),_:1})):(I(),A(u,{key:0,size:"small",shape:"circle",variant:"text",onClick:Le},{default:L((()=>[V(R(z),{slot:"icon"})])),_:1}))])),_:1},8,["content"]),V(u,{size:"small",shape:"circle",variant:"text",onClick:Je},{default:L((()=>[V(R(C),{slot:"icon"})])),_:1})])])])),content:L((()=>[M("div",{ref_key:"scrollable_chat",ref:_,class:"h-full note-content flex flex-col gap-1 relative",onMouseupPassive:n[1]||(n[1]=//@ts-ignore
|
2 |
+
(...e)=>{var t,o;return(null==(t=E.value)?void 0:t.showToolbox)&&(null==(o=E.value)?void 0:o.showToolbox(...e))}),onMousedownPassive:n[2]||(n[2]=//@ts-ignore
|
3 |
+
(...e)=>{var t,o;return(null==(t=E.value)?void 0:t.hideToolbox)&&(null==(o=E.value)?void 0:o.hideToolbox(...e))})},[M("div",oe,[M("div",le,[(I(!0),H(q,null,D(Y.value.chats,((o,l)=>(I(),H(q,null,["user"===o.role?(I(),H("div",ae,[M("div",{class:F(["flex flex-col gap-2",Re.value===l?"w-full":""])},[M("div",se,N(R(K).name),1),M("div",ne,[V(e,{content:o.content,isEditing:Re.value===l,onSave:Pe,onCancel:Ae},null,8,["content","isEditing"])]),M("div",ie,[V(d,{theme:"danger",content:R(r)("pages.note.noteDeleteConfirm"),placement:"bottom",onConfirm:e=>(e=>{const t=Y.value.chats.findIndex((t=>t===e));-1!==t&&Y.value.chats.splice(t,2)})(o)},{default:L((()=>[V(c,{content:R(r)("pages.note.noteDeleteTooltip")},{default:L((()=>[V(u,{size:"small",variant:"outline"},{default:L((()=>[V(R(k),{slot:"icon"})])),_:1})])),_:1},8,["content"])])),_:2},1032,["content","onConfirm"]),V(c,{content:R(r)("pages.conversation.button_tooltip_editor"),placement:"bottom"},{default:L((()=>[V(u,{size:"small",variant:"outline",onClick:e=>qe(l)},{default:L((()=>[V(R(w),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"])])],2),M("div",re,[V(p,{size:"24px",image:R(K).avatar},null,8,["image"])])])):"assistant"===o.role?(I(),H("div",ue,[M("div",ce,[M("div",de,[M("div",null,N(Y.value.conversationName),1)]),M("div",pe,[V(t,{content:o.content,isEditing:Re.value===l,onSave:Pe,onCancel:Ae},null,8,["content","isEditing"])]),M("div",me,[V(c,{content:R(r)("pages.conversation.button_tooltip_editor"),placement:"bottom"},{default:L((()=>[V(u,{size:"small",variant:"outline",onClick:e=>qe(l)},{default:L((()=>[V(R(w),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),V(c,{content:R(r)("pages.note.noteCopyTooltip")},{default:L((()=>[V(u,{size:"small",variant:"outline",onClick:e=>{return t=o,navigator.clipboard.writeText(t.content.text),void y.success(r("pages.note.noteCopySuccess"));var t}},{default:L((()=>[V(R(C),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"]),V(c,{content:R(r)("pages.conversation.toggle_artifacts")},{default:L((()=>[V(u,{size:"small",variant:"outline",onClick:e=>{var t;"assistant"===(t=o).role&&(Se.value=!Se.value,Se.value&&($e.value=t.content.text))}},{default:L((()=>[V(R(T),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"])])]),M("div",ve,[V(p,{size:"24px",image:Y.value.conversationAvatar},null,8,["image"])])])):O("",!0)],64)))),256)),(I(!0),H(q,null,D(Y.value.notes,((e,t)=>(I(),H("div",fe,[M("div",{class:F(["flex flex-col gap-2 min-w-[300px]",De.value===t?"w-full":""])},[M("div",je,N(R(K).name),1),M("div",ge,[ze.value&&t===Y.value.notes.length-1?(I(),H("span",xe)):(I(),A(Z,{key:1,content:e,isEditing:De.value===t,onSave:Fe,onCancel:Ne},null,8,["content","isEditing"]))]),M("div",he,[V(d,{theme:"danger",content:R(r)("pages.note.noteDeleteConfirm"),placement:"bottom",onConfirm:e=>(e=>{Y.value.notes.splice(e,1)})(t)},{default:L((()=>[V(c,{content:R(r)("pages.note.noteDeleteTooltip")},{default:L((()=>[V(u,{size:"small",variant:"outline"},{default:L((()=>[V(R(k),{slot:"icon"})])),_:1})])),_:1},8,["content"])])),_:2},1032,["content","onConfirm"]),V(c,{content:R(r)("pages.conversation.button_tooltip_editor"),placement:"bottom"},{default:L((()=>[V(u,{size:"small",variant:"outline",onClick:e=>(e=>{De.value=e})(t)},{default:L((()=>[V(R(w),{slot:"icon"})])),_:2},1032,["onClick"])])),_:2},1032,["content"])])],2),M("div",ye,[V(p,{size:"24px",image:R(K).avatar},null,8,["image"])])])))),256))]),Se.value?(I(),H("div",_e,[V(o,{content:R($e),closeBtn:He},null,8,["content"])])):O("",!0)]),V(l,{ref_key:"toolbar",ref:E,parent:_.value},null,8,["parent"])],544)])),footer:L((()=>[V(a,{"show-upload":!1,"auto-complete-enabled":!0,placeholder:s.$t("pages.note.notePlaceholder"),onInput:Ee},null,8,["placeholder"])])),_:1},8,["class","title"])):O("",!0)}}});export{be as default};
|
.output/public/assets/highlight.js-Ds8M-WS2.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
.output/public/assets/index-BJf2iObo.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{a as e}from"./vue-router-Be5-2oBH.js";import{l as a,f as t,J as s,y as l,aa as i,R as n,z as r,ad as o,u,a as d,w as p,A as v,G as m,H as c,v as g,F as f,ab as b}from"./@vue-DsZlmJIP.js";import{c as _,A as j,g as h,p as x,q as y,r as z,s as k,x as C,f as w,m as S,j as V,Q as D}from"./tdesign-vue-next-DsCOKp3d.js";import{ac as U,ab as q,d as A}from"./tdesign-icons-vue-next-Dn30dVUK.js";import{t as R}from"./global-BveI--BU.js";import{_ as $}from"./avatar.vue_vue_type_script_setup_true_lang-jav6E5Ln.js";import{v as F}from"./uuid-_R2nDvl_.js";import{u as I}from"./main-zbluuG_-.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./lodash-es-BkU_-LF8.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";import"./lodash-Cky9m9r7.js";import"./@vueuse-Cn3Nsuq9.js";import"./vue-i18n-Dmk40Gks.js";import"./@intlify-eboPrqDD.js";import"./pinia-jKJ-xldK.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./@dicebear-JcnEMRoc.js";import"./@wdns-P0uM2sk1.js";import"./ua-parser-js-9pz7LJLQ.js";import"./vuedraggable-K5Gqz8r2.js";import"./vue-DVRmszIO.js";const N=a({__name:"AgentCard",props:{product:{type:Object}},emits:["start-chat","delete-item"],setup(e,{emit:a}){const d=e,p=t((()=>d.product.content.substring(0,20)+"...")),v=a;return(a,t)=>{const d=j,m=_,c=h;return l(),s(c,{title:e.product.name,description:p.value,"hover-shadow":"",bordered:!1},{avatar:i((()=>[n(d,{size:"56px",image:e.product.avatar},null,8,["image"])])),actions:i((()=>[n(m,{shape:"circle",onClick:t[0]||(t[0]=o((a=>{return t=e.product,void v("start-chat",t);var t}),["stop"])),variant:"text"},{default:i((()=>[n(u(U),{slot:"icon"})])),_:1}),e.product.isDefault?r("",!0):(l(),s(m,{key:0,shape:"circle",onClick:t[1]||(t[1]=o((a=>{return t=e.product,void v("delete-item",t);var t}),["stop"])),variant:"text"},{default:i((()=>[n(u(q),{slot:"icon"})])),_:1}))])),_:1},8,["title","description"])}}}),O={class:"flex flex-col items-center justify-center mb-[var(--td-comp-margin-xxl)]"},B={class:"w-full flex flex-row justify-end gap-3"},E={id:"",name:"",status:"1",content:"",avatar:"",onboarding:"",isDefault:!1},G=a({__name:"DialogForm",props:{visible:{type:Boolean,default:!1},data:Object},emits:["update:visible"],setup(e,{emit:a}){const t=I(),r=e,o=d(null),g=d(!1),f=d({...E}),b=e=>{f.value.avatar=e},j=({validateResult:e,firstError:a})=>{if(a)return void w.warning(a);const s=!f.value.id||""===f.value.id;s&&(f.value.id=F());const l={id:f.value.id,name:f.value.name,status:"1"===f.value.status,content:f.value.content,avatar:f.value.avatar,onboarding:f.value.onboarding,isDefault:f.value.isDefault};s?(t.add(l),w.success(R("pages.setting.agent.submit_success"))):(t.update(l),w.success(R("pages.setting.agent.update_success"))),g.value=!1},h=()=>{g.value=!1},S=a;p((()=>g.value),(e=>{S("update:visible",e)})),p((()=>r.visible),(e=>{g.value=e})),p((()=>r.data),(e=>{f.value=e}),{immediate:!0});const V={name:[{required:!0,message:R("pages.setting.agent.enter_agent_name"),type:"error"}],content:[{required:!0,message:R("pages.setting.agent.enter_agent_description"),type:"error"}]};return(e,a)=>{const t=z,r=y,d=k,p=_,w=x,S=C;return l(),s(S,{visible:g.value,"onUpdate:visible":a[2]||(a[2]=e=>g.value=e),header:f.value.id?u(R)("pages.setting.agent.editor_agent"):u(R)("pages.setting.agent.add_agent"),placement:"top",width:680,footer:!1},{body:i((()=>[n(w,{ref:"form",data:f.value,rules:V,"label-width":100,"label-align":"top",onSubmit:j},{default:i((()=>[v("div",O,[n($,{ref_key:"avatarRef",ref:o,url:f.value.avatar,onUpdate:b},null,8,["url"])]),n(r,{label:u(R)("pages.setting.agent.agent_name"),name:"name"},{default:i((()=>[n(t,{modelValue:f.value.name,"onUpdate:modelValue":a[0]||(a[0]=e=>f.value.name=e)},null,8,["modelValue"])])),_:1},8,["label"]),n(r,{label:u(R)("pages.setting.agent.agent_description"),name:"content"},{default:i((()=>[n(d,{modelValue:f.value.content,"onUpdate:modelValue":a[1]||(a[1]=e=>f.value.content=e),autosize:{minRows:5,maxRows:12},name:"content"},null,8,["modelValue"])])),_:1},8,["label"]),n(r,null,{default:i((()=>[v("div",B,[n(p,{variant:"outline",onClick:h},{default:i((()=>[m(c(u(R)("pages.setting.agent.cancel")),1)])),_:1}),n(p,{theme:"primary",type:"submit"},{default:i((()=>[m(c(u(R)("pages.setting.agent.confirm")),1)])),_:1})])])),_:1})])),_:1},8,["data"])])),_:1},8,["visible","header"])}}}),H={class:"list-card-items"},J={class:"list-card-pagination"},L=a({name:"ListAgent",setup(a){const r=e(),o=d(void 0),p=I(),m=d({current:1,pageSize:35,total:0}),c=t((()=>{const e=[p.defaultAgent,...p.agents];return m.value.total=e.length,e})),_=t((()=>o.value?R("pages.setting.agent.confirm_delete_agent",{agentName:o.value.name}):"")),x=d(!1),y=d(!1),z=d({...E}),k=e=>{m.value.pageSize=e,m.value.current=1},U=e=>{m.value.current=e},q=e=>{y.value=!0,o.value=e},$=()=>{p.remove(o.value.id),y.value=!1,w.success(R("pages.setting.agent.delete_success"))},F=()=>{o.value=void 0},O=e=>{r.push({path:"/conversation/index",query:{id:e.id}})},B=()=>{z.value={...E},x.value=!0};return(e,a)=>{const t=j,r=h,o=S,d=V,p=D,w=C;return l(),g("div",null,[v("div",H,[n(d,{gutter:[16,16]},{default:i((()=>[n(o,{xs:12,lg:4,xl:3},{default:i((()=>[n(r,{theme:"normal","hover-shadow":"",class:"list-card-item h-[108px] border-dashed",style:{"border-color":"var(--td-brand-color-active)"},title:e.$t("pages.setting.agent.add_agent"),onClick:B},{avatar:i((()=>[n(t,{size:"56px"},{icon:i((()=>[n(u(A))])),_:1})])),_:1},8,["title"])])),_:1}),(l(!0),g(f,null,b(c.value.slice(m.value.pageSize*(m.value.current-1),m.value.pageSize*m.value.current),(e=>(l(),s(o,{key:e.id,xs:12,lg:4,xl:3},{default:i((()=>[n(N,{class:"list-card-item h-[108px]",product:e,onDeleteItem:q,onStartChat:O,onClick:a=>(e=>{z.value={id:e.id,name:e.name,status:e.status?"1":"0",content:e.content,avatar:e.avatar,onboarding:e.onboarding,isDefault:e.isDefault},x.value=!0})(e)},null,8,["product","onClick"])])),_:2},1024)))),128))])),_:1})]),v("div",J,[n(p,{modelValue:m.value.current,"onUpdate:modelValue":a[0]||(a[0]=e=>m.value.current=e),"page-size":m.value.pageSize,"onUpdate:pageSize":a[1]||(a[1]=e=>m.value.pageSize=e),total:m.value.total,"page-size-options":[35],onPageSizeChange:k,onCurrentChange:U},null,8,["modelValue","page-size","total","page-size-options"])]),n(G,{visible:x.value,"onUpdate:visible":a[2]||(a[2]=e=>x.value=e),data:z.value},null,8,["visible","data"]),n(w,{visible:y.value,"onUpdate:visible":a[3]||(a[3]=e=>y.value=e),header:e.$t("pages.setting.agent.confirm_delete_selected_agent"),body:_.value,"on-cancel":F,onConfirm:$},null,8,["visible","header","body"])])}}});export{L as default};
|
.output/public/assets/index-BSlpP4WW.js
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import{r as e,q as a,d as l,R as t,J as o,N as s,w as n,p as u,c as r,f as d,j as i,m as c,u as m,O as p,A as v,n as g,U as f,P as h,x as _,g as y}from"./tdesign-vue-next-DsCOKp3d.js";import{l as b,f as V,v as w,y as x,R as j,aa as $,F as U,A as k,B as F,a as T,o as C,j as M,z,H as B,ab as A,J as S,ac as O,u as H,G as R}from"./@vue-DsZlmJIP.js";import{D,_ as I,b as N,u as L,t as P,S as E,d as q,c as J,m as K,g as G}from"./global-BveI--BU.js";import{u as X,a as Q,b as W}from"./main-zbluuG_-.js";import{_ as Y}from"./avatar.vue_vue_type_script_setup_true_lang-jav6E5Ln.js";import{b as Z}from"./@vueuse-Cn3Nsuq9.js";import{d as ee}from"./fetch-2coGNStX.js";import{d as ae}from"./vuedraggable-K5Gqz8r2.js";import{a9 as le,aa as te,c as oe}from"./tdesign-icons-vue-next-Dn30dVUK.js";import"./lodash-es-BkU_-LF8.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./lodash-Cky9m9r7.js";import"./vue-i18n-Dmk40Gks.js";import"./@intlify-eboPrqDD.js";import"./pinia-jKJ-xldK.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./@wdns-P0uM2sk1.js";import"./ua-parser-js-9pz7LJLQ.js";import"./vue-router-Be5-2oBH.js";import"./vue-DVRmszIO.js";import"./@dicebear-JcnEMRoc.js";import"./uuid-_R2nDvl_.js";import"./eventsource-parser-BEY8Dpg-.js";import"./@mozilla-BD532_dh.js";const se=b({__name:"CloudflareKVHTTPDriverForm",props:["modelValue"],emits:["update:modelValue"],setup(l,{emit:t}){const o=l,s=t,n=V({get:()=>o.modelValue,set:e=>s("update:modelValue",e)}),u=e=>{s("update:modelValue",{...n.value})};return(l,t)=>{const o=e,s=a;return x(),w(U,null,[j(s,{label:"API Base",name:"apiBase","initial-data":""},{default:$((()=>[j(o,{placeholder:"",modelValue:n.value.apiURL,"onUpdate:modelValue":t[0]||(t[0]=e=>n.value.apiURL=e),onChange:u},null,8,["modelValue"])])),_:1}),j(s,{label:"Account",name:"accountId","initial-data":""},{default:$((()=>[j(o,{placeholder:"",modelValue:n.value.accountId,"onUpdate:modelValue":t[1]||(t[1]=e=>n.value.accountId=e),onChange:u},null,8,["modelValue"])])),_:1}),j(s,{label:"Namespace",name:"namespaceId","initial-data":""},{default:$((()=>[j(o,{placeholder:"",modelValue:n.value.namespaceId,"onUpdate:modelValue":t[2]||(t[2]=e=>n.value.namespaceId=e),onChange:u},null,8,["modelValue"])])),_:1}),j(s,{label:"API Token",name:"apiToken","initial-data":""},{default:$((()=>[j(o,{type:"password",placeholder:"",modelValue:n.value.apiToken,"onUpdate:modelValue":t[3]||(t[3]=e=>n.value.apiToken=e),onChange:u},null,8,["modelValue"])])),_:1})],64)}}}),ne=Object.defineProperty({__proto__:null,default:se,driverConfig:{name:"cloudflareKVHTTP",component:"CloudflareKVHTTPDriverForm"}},Symbol.toStringTag,{value:"Module"}),ue={xmlns:"http://www.w3.org/2000/svg",width:"88",height:"48",fill:"none"};const re={render:function(e,a){return x(),w("svg",ue,a[0]||(a[0]=[k("path",{fill:"var(--td-component-border)",d:"M0 0h88v48H0z"},null,-1),k("path",{fill:"var(--td-text-color-primary)",d:"M42.863 14.052v2.708h1.625v-2.708z"},null,-1),k("path",{fill:"var(--td-text-color-primary)","fill-rule":"evenodd",d:"M38.349 23.982a5.326 5.326 0 1 1 10.653 0 5.326 5.326 0 0 1-10.653 0m5.326-3.701a3.701 3.701 0 1 0 0 7.403 3.701 3.701 0 0 0 0-7.403M52.208 26.781h-2.621l-2.06 6.699 1.552.478.511-1.661h2.614l.511 1.66 1.554-.477zm-.503 3.89-.697-2.265h-.221l-.697 2.266z","clip-rule":"evenodd"},null,-1),k("path",{fill:"var(--td-text-color-primary)",d:"m48.208 18.3 1.915-1.914 1.149 1.15-1.915 1.914zM53.606 23.17h-2.709v1.625h2.709zM44.488 31.205v2.708h-1.625v-2.708zM37.228 31.579l1.915-1.915-1.15-1.15-1.914 1.916zM36.453 24.795h-2.708V23.17h2.708zM36.079 17.535l1.915 1.915 1.149-1.15-1.915-1.914z"},null,-1)]))}},de={xmlns:"http://www.w3.org/2000/svg",width:"88",height:"48",fill:"none"};const ie={render:function(e,a){return x(),w("svg",de,a[0]||(a[0]=[k("path",{fill:"#13161B",d:"M0 0h88v48H0z"},null,-1),k("path",{fill:"#949EAA","fill-rule":"evenodd",d:"M52.533 26.87q-.748.129-1.533.13a9 9 0 0 1-8.533-11.87A9 9 0 0 0 44 33a9 9 0 0 0 8.533-6.13","clip-rule":"evenodd"},null,-1)]))}},ce={xmlns:"http://www.w3.org/2000/svg",width:"88",height:"48",fill:"none"};const me={render:function(e,a){return x(),w("svg",ce,a[0]||(a[0]=[k("path",{fill:"var(--td-component-border)",d:"M0 0h88v48H0z"},null,-1),k("path",{fill:"var(--td-text-color-primary)","fill-rule":"evenodd",d:"M44 20.583a3.417 3.417 0 1 0 0 6.833 3.417 3.417 0 0 0 0-6.833M39.083 24a4.917 4.917 0 1 1 9.834 0 4.917 4.917 0 0 1-9.834 0M43.25 17.333v-2.5h1.5v2.5zM48.184 18.755l1.767-1.767 1.06 1.06-1.767 1.768zM50.667 23.25h2.5v1.5h-2.5zM49.244 28.184l1.768 1.767-1.06 1.06-1.768-1.767zM44.75 30.666v2.5h-1.5v-2.5zM39.816 29.244l-1.767 1.768-1.061-1.061 1.767-1.768zM37.333 24.75h-2.5v-1.5h2.5zM38.756 19.816l-1.768-1.768 1.06-1.06 1.768 1.767z","clip-rule":"evenodd"},null,-1)]))}},pe=I(b({__name:"index",props:{value:{type:String}},setup(e){const a=e,l=V((()=>{const{value:e}=a;return{background:D.indexOf(e)>-1?e:"conic-gradient(from 90deg at 50% 50%, #FF0000 -19.41deg, #FF0000 18.76deg, #FF8A00 59.32deg, #FFE600 99.87deg, #14FF00 141.65deg, #00A3FF 177.72deg, #0500FF 220.23deg, #AD00FF 260.13deg, #FF00C7 300.69deg, #FF0000 340.59deg, #FF0000 378.76deg)"}}));return(e,a)=>(x(),w("div",{style:F(l.value),class:"color-container"},null,4))}}),[["__scopeId","data-v-f0f6ec52"]]),ve={class:"setting-container"},ge={class:"setting-group-title"},fe={style:{textAlign:"center",marginTop:"8px"}},he={class:"setting-group-title"},_e={class:"setting-layout-drawer"},ye={key:0,class:"setting-info mt-10"},be=b({__name:"appearance",setup(e){N();const i=L(),c=[
|
2 |
+
//@ts-ignore
|
3 |
+
{type:"light",text:P("pages.setting.theme.options.light")},{type:"dark",text:P("pages.setting.theme.options.dark")},{type:"auto",text:P("pages.setting.theme.options.auto")}],m=V((()=>-1===D.indexOf(p.value.brandTheme)?p.value.brandTheme:"")),p=T({...(()=>{const e=E;for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(e[a]=i[a]);return e})()}),v=T(!1),g=e=>{p.value.brandTheme=e};C((()=>{var e;null==(e=document.querySelector(".dynamic-color-btn"))||e.addEventListener("click",(()=>{v.value=!0}))}));const f=(e,a)=>{e||"document"!==a.trigger||(v.value=e)},h=()=>{const e=JSON.stringify(p.value,null,4),{copy:a}=Z({source:e});a().then((()=>{d.closeAll(),d.success(P("pages.setting.copy.success"))})).catch((()=>{d.closeAll(),d.error(P("pages.setting.copy.fail"))}))};return M((()=>{p.value.brandTheme&&i.updateConfig(p.value)})),(e,d)=>{const i=t,_=l,y=s,b=o,V=n,F=a,T=u,C=r;return x(),w("div",ve,[j(T,{ref:"form",data:p.value,"label-align":"left"},{default:$((()=>[k("div",ge,B(e.$t("pages.setting.theme.mode")),1),j(_,{modelValue:p.value.mode,"onUpdate:modelValue":d[0]||(d[0]=e=>p.value.mode=e)},{default:$((()=>[(x(),w(U,null,A(c,((e,a)=>k("div",{key:a,class:"setting-layout-drawer"},[k("div",null,[(x(),S(i,{key:a,value:e.type},{default:$((()=>{return[(x(),S(O((a=e.type,"light"===a?me:"dark"===a?ie:re))))];var a})),_:2},1032,["value"])),k("p",fe,B(e.text),1)])]))),64))])),_:1},8,["modelValue"]),k("div",he,B(e.$t("pages.setting.theme.color")),1),j(_,{modelValue:p.value.brandTheme,"onUpdate:modelValue":d[1]||(d[1]=e=>p.value.brandTheme=e)},{default:$((()=>[(x(!0),w(U,null,A(H(D),((e,a)=>(x(),w("div",{key:a,class:"setting-layout-drawer"},[(x(),S(i,{key:a,value:e,class:"setting-layout-color-group"},{default:$((()=>[j(pe,{value:e},null,8,["value"])])),_:2},1032,["value"]))])))),128)),k("div",_e,[j(b,{"destroy-on-close":"","expand-animation":"",placement:"bottom-right",trigger:"click",visible:v.value,"overlay-style":{padding:0},onVisibleChange:f},{content:$((()=>[j(y,{"on-change":g,"color-modes":["monochrome"],format:"HEX","swatch-colors":[]})])),default:$((()=>[j(i,{value:m.value,class:"setting-layout-color-group dynamic-color-btn"},{default:$((()=>[j(pe,{value:m.value},null,8,["value"])])),_:1},8,["value"])])),_:1},8,["visible"])])])),_:1},8,["modelValue"]),k("div",null,[j(F,{label:e.$t("pages.setting.element.showHeader"),name:"showHeader"},{default:$((()=>[j(V,{modelValue:p.value.showHeader,"onUpdate:modelValue":d[2]||(d[2]=e=>p.value.showHeader=e)},null,8,["modelValue"])])),_:1},8,["label"]),j(F,{label:e.$t("pages.setting.element.showNav"),name:"showNav"},{default:$((()=>[j(V,{modelValue:p.value.showNav,"onUpdate:modelValue":d[3]||(d[3]=e=>p.value.showNav=e)},null,8,["modelValue"])])),_:1},8,["label"]),j(F,{label:e.$t("pages.setting.element.showBreadcrumb"),name:"showBreadcrumb"},{default:$((()=>[j(V,{modelValue:p.value.showBreadcrumb,"onUpdate:modelValue":d[4]||(d[4]=e=>p.value.showBreadcrumb=e)},null,8,["modelValue"])])),_:1},8,["label"]),j(F,{label:e.$t("pages.setting.element.showFooter"),name:"showFooter"},{default:$((()=>[j(V,{modelValue:p.value.showFooter,"onUpdate:modelValue":d[5]||(d[5]=e=>p.value.showFooter=e)},null,8,["modelValue"])])),_:1},8,["label"])])])),_:1},8,["data"]),H(false)?(x(),w("div",ye,[k("p",null,B(e.$t("pages.setting.tips")),1),j(C,{theme:"primary",variant:"text",onClick:h},{default:$((()=>[R(B(e.$t("pages.setting.copy.title")),1)])),_:1})])):z("",!0),d[6]||(d[6]=k("div",{class:"text-center text-gray-400"},"3/12/2025, 6:00:25 AM",-1))])}}}),Ve={class:"flex justify-center"},we={class:"font-bold text-xl mb-5"},xe={class:"flex"},je={class:"font-bold text-xl mb-5"},$e={class:"flex flex-col gap-5"},Ue={class:"flex justify-between"},ke={class:"font-bold text-xl"},Fe={class:"flex flex-col gap-5 w-full overflow-hidden"},Te={class:"font-bold text-xl mb-5"},Ce=I(b({name:"User",setup(l){const t=q(),o=N(),s=X(),b=L(),F=J(),C=Q(),M=async e=>{try{const a=await async function(e){return new Promise(((a,l)=>{const t=new FileReader;t.onload=function(e){a(e.target.result)},t.onerror=function(e){l(e)},t.readAsText(e)}))}(e.raw);return D(JSON.parse(a)),d.success({content:P("pages.setting.user.import_success")}),{status:"success",error:"",response:{url:" "}}}catch{return d.error({content:P("pages.setting.user.import_failed")}),{status:"fail",error:"",response:{}}}};const D=e=>{var a;if(e.user&&o.$patch(e.user),e.model&&t.$patch(e.model),e.agent&&s.$patch(e.agent),e.setting&&b.$patch(e.setting),e.conversation){const a=function(e,a=640){return e.map((e=>({...e,models:e.models.map((e=>{try{const l=JSON.stringify(e.chats);return(new TextEncoder).encode(l).length/1024>a?{...e,chats:[]}:e}catch{return{...e,chats:[]}}}))})))}(e.conversation.list);F.$patch({...e.conversation,list:a})}e.note&&C.$patch(e.note),(null==(a=e.user)?void 0:a.lang)&&Z(e.user.lang)};function I(){const e=JSON.stringify({user:o.$state,model:t.$state,agent:s.$state,setting:b.$state,conversation:F.$state,note:C.$state},null,2),a=new Blob([e],{type:"application/json"}),l=document.createElement("a");l.href=URL.createObjectURL(a),l.download="config.json",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(l.href)}const E=window.isElectron,{changeLocale:Z,locale:se}=W(),ue=V({get:()=>se.value,set(e){Z(e)}}),re=e=>{o.avatar=e};function de(e,a){const l=a.e,t=l.key,s=[l.ctrlKey?"Ctrl":"",l.metaKey?"Cmd":"",l.altKey?"Alt":"",l.shiftKey?"Shift":""].filter(Boolean).join("+");o.shortcut=`${s}+${t.toUpperCase()}`,l.preventDefault()}const ie=V((()=>K.availableModels.value.map((e=>({value:e.id,label:K.getModelItemTitle(e),...e}))))),ce=()=>{o.toolBarButtons.push({name:"",icon:null,prompt:"",show:!0})},me=Object.assign({"./drivers/CloudflareKVHTTPDriverForm.vue":ne}),pe=Object.values(me).map((e=>e.driverConfig)),ve=V((()=>b.drivers.currentDriver)),ge=V((()=>b.drivers)),fe=V((()=>b.version)),he=V((()=>{const e=pe.find((e=>e.name===ve.value));return e?me[`./drivers/${e.component}.vue`].default:null})),_e=async e=>{b.updateDriverSettings(e,ge.value[e])};async function ye(e){b.updateDriverSettings(ve.value,e)}const Ce=T(!1),Me=T(!1),ze=T(!1),Be=T(null),Ae=V((()=>{var e;return null==(e=Be.value)?void 0:e.setting.version}));async function Se(){try{if(Ce.value=!0,Be.value=await De(),Be.value){new Date(Ae.value)>=new Date(fe.value)||!fe.value?ze.value=!0:(await Ie(),d.success("备份成功"))}else await Ie(),d.success("备份成功")}catch(e){d.error("备份失败: "+e.message)}finally{Ce.value=!1}}async function Oe(){try{Me.value=!0;const e=await De();if(!e)throw new Error("未找到远程数据");D(e),d.success("恢复成功")}catch(e){d.error("恢复失败: "+e.message)}finally{Me.value=!1}}async function He(){try{Ce.value=!0,await Ie(),d.success("备份成功")}catch(e){d.error("备份失败: "+e.message)}finally{ze.value=!1,Ce.value=!1}}async function Re(){if(Be.value)try{Me.value=!0,D(Be.value),d.success("数据已成功恢复")}catch(e){d.error("恢复失败: "+e.message)}finally{ze.value=!1,Me.value=!1}}const De=async()=>{try{const e=new URLSearchParams({driver:ve.value,config:JSON.stringify(ge.value[ve.value])}),a=await fetch(`${ee()}/config?${e.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok)throw new Error(await a.text());return(await a.json()).data}catch(e){throw e}};async function Ie(){try{b.version=(new Date).toISOString();const e={user:o.$state,model:t.$state,agent:s.$state,setting:b.$state,conversation:F.$state,note:C.$state},a=await fetch(ee()+"/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e,driver:ve.value,config:ge.value[ve.value]})});if(!a.ok)throw new Error(await a.text())}catch(e){throw e}}return(l,t)=>{const s=e,d=a,b=c,V=p,F=m,T=v,C=g,D=i,N=r,L=f,P=u,q=n,J=h,X=_,Q=y;return x(),S(Q,{shadow:"",class:"overflow-hidden",bordered:!1},{default:$((()=>[j(P,{ref:"form",class:"flex flex-col gap-8","label-align":"top"},{default:$((()=>[k("div",Ve,[j(Y,{ref:"avatarRef",url:H(o).avatar,onUpdate:re},null,8,["url"])]),k("div",null,[k("h1",we,B(l.$t("pages.setting.user.basic_settings")),1),j(D,{class:"row-gap",gutter:[32,24]},{default:$((()=>[j(b,{xs:12,lg:6},{default:$((()=>[j(d,{label:l.$t("pages.setting.user.username"),name:"name"},{default:$((()=>[j(s,{modelValue:H(o).name,"onUpdate:modelValue":t[0]||(t[0]=e=>H(o).name=e),placeholder:l.$t("pages.setting.user.enter_username")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1}),j(b,{xs:12,lg:6},{default:$((()=>[j(d,{label:l.$t("pages.setting.user.language"),name:"lang"},{default:$((()=>[j(F,{modelValue:ue.value,"onUpdate:modelValue":t[1]||(t[1]=e=>ue.value=e),class:"demo-select-base",clearable:""},{default:$((()=>[(x(!0),w(U,null,A(H(G),((e,a)=>(x(),S(V,{key:a,value:`${e.value}`,label:`${e.content}`},{default:$((()=>[R(B(e.content),1)])),_:2},1032,["value","label"])))),128))])),_:1},8,["modelValue"])])),_:1},8,["label"])])),_:1}),H(E)?(x(),S(b,{key:0,xs:12,lg:6},{default:$((()=>[j(d,{label:l.$t("pages.setting.user.shortcut"),name:"shortcut"},{default:$((()=>[j(s,{onKeydown:de,modelValue:H(o).shortcut,"onUpdate:modelValue":t[2]||(t[2]=e=>H(o).shortcut=e),placeholder:l.$t("pages.setting.user.enter_shortcut")},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1})):z("",!0),j(b,{xs:12,lg:6},{default:$((()=>[j(d,{label:l.$t("pages.setting.user.assist_model"),name:"assistModel"},{default:$((()=>[j(F,{modelValue:H(o).assistModel,"onUpdate:modelValue":t[3]||(t[3]=e=>H(o).assistModel=e),tips:l.$t("pages.setting.user.assist_model_tips")},{default:$((()=>[(x(!0),w(U,null,A(ie.value,(e=>(x(),S(V,{key:e.value,value:e.value,label:e.label},{default:$((()=>[k("div",xe,[j(T,{size:"20px",class:"mr-1"},{icon:$((()=>[(x(),S(O(H(K).icons[e.type])))])),_:2},1024),R(" "+B(e.label),1)])])),_:2},1032,["value","label"])))),128))])),_:1},8,["modelValue","tips"])])),_:1},8,["label"])])),_:1}),j(b,{xs:12,lg:6},{default:$((()=>[j(d,{label:l.$t("pages.setting.user.remoteHost"),name:"remoteHost"},{default:$((()=>[j(s,{modelValue:H(o).remoteHost,"onUpdate:modelValue":t[4]||(t[4]=e=>H(o).remoteHost=e)},null,8,["modelValue"])])),_:1},8,["label"])])),_:1}),H(E)?(x(),S(b,{key:1,span:6},{default:$((()=>[j(d,{label:l.$t("pages.setting.user.open_at_login"),name:"openAtLogin"},{default:$((()=>[j(C,{modelValue:H(o).openAtLogin,"onUpdate:modelValue":t[5]||(t[5]=e=>H(o).openAtLogin=e)},null,8,["modelValue"])])),_:1},8,["label"])])),_:1})):z("",!0),H(E)?(x(),S(b,{key:2,span:6},{default:$((()=>[j(d,{label:l.$t("pages.setting.user.minimize_to_bottom_right"),name:"minimizeToBottomRight"},{default:$((()=>[j(C,{modelValue:H(o).minimizeToBottomRight,"onUpdate:modelValue":t[6]||(t[6]=e=>H(o).minimizeToBottomRight=e)},null,8,["modelValue"])])),_:1},8,["label"])])),_:1})):z("",!0)])),_:1})]),k("div",null,[k("h1",je,B(l.$t("pages.setting.user.import_config")),1),j(P,null,{default:$((()=>[j(d,{label:"存储类型",name:"driverType","initial-data":""},{default:$((()=>[j(F,{modelValue:ve.value,"onUpdate:modelValue":t[7]||(t[7]=e=>ve.value=e),onChange:_e,placeholder:"Select Driver"},{default:$((()=>[(x(!0),w(U,null,A(H(pe),(e=>(x(),S(V,{key:e.name,value:e.name,label:e.name},null,8,["value","label"])))),128))])),_:1},8,["modelValue"])])),_:1}),(x(),S(O(he.value),{modelValue:ge.value[ve.value],"onUpdate:modelValue":[t[8]||(t[8]=e=>ge.value[ve.value]=e),ye]},null,8,["modelValue"])),j(D,{class:"row-gap",gutter:[24,24]},{default:$((()=>[j(b,{xs:6,lg:3,class:"flex justify-center"},{default:$((()=>[j(N,{onClick:Se,loading:Ce.value},{default:$((()=>t[11]||(t[11]=[R("备份到服务器")]))),_:1},8,["loading"])])),_:1}),j(b,{xs:6,lg:3,class:"flex justify-center"},{default:$((()=>[j(N,{onClick:Oe,loading:Me.value},{default:$((()=>t[12]||(t[12]=[R("从服务器恢复")]))),_:1},8,["loading"])])),_:1}),j(b,{xs:6,lg:3,class:"flex justify-center"},{default:$((()=>[j(L,{theme:"custom","request-method":M,multiple:!1},{default:$((()=>[j(N,{theme:"primary"},{default:$((()=>[R(B(l.$t("pages.setting.user.import_local_config")),1)])),_:1})])),_:1})])),_:1}),j(b,{xs:6,lg:3,class:"flex justify-center"},{default:$((()=>[j(N,{theme:"primary",onClick:I},{default:$((()=>[R(B(l.$t("pages.setting.user.export_local_config")),1)])),_:1})])),_:1})])),_:1})])),_:1})]),k("div",$e,[k("div",Ue,[k("h1",ke,B(l.$t("pages.setting.user.toolbar_settings")),1),j(N,{shape:"square",variant:"text",onClick:ce},{default:$((()=>[j(H(le),{slot:"icon"})])),_:1})]),k("div",Fe,[j(H(ae),{modelValue:H(o).toolBarButtons,"onUpdate:modelValue":t[9]||(t[9]=e=>H(o).toolBarButtons=e),"item-key":"id",animation:150,class:"flex flex-col gap-5",handle:".drag-handle"},{item:$((({element:e})=>[j(D,{gutter:{xs:8,sm:16,md:24,lg:32,xl:32,xxl:40},class:"items-center"},{default:$((()=>[j(b,{xs:2,sm:1},{default:$((()=>[j(N,{shape:"square",variant:"text",class:"drag-handle cursor-move"},{default:$((()=>[j(H(te))])),_:1})])),_:1}),j(b,{xs:2,sm:2},{default:$((()=>[j(s,{modelValue:e.name,"onUpdate:modelValue":a=>e.name=a,placeholder:"名称"},null,8,["modelValue","onUpdate:modelValue"])])),_:2},1024),j(b,{xs:3,sm:5},{default:$((()=>[j(s,{modelValue:e.prompt,"onUpdate:modelValue":a=>e.prompt=a,placeholder:"提示词"},null,8,["modelValue","onUpdate:modelValue"])])),_:2},1024),j(b,{xs:2,sm:2},{default:$((()=>[j(s,{modelValue:e.icon,"onUpdate:modelValue":a=>e.icon=a,placeholder:"图标"},null,8,["modelValue","onUpdate:modelValue"])])),_:2},1024),j(b,{xs:2,sm:1,class:"flex justify-end"},{default:$((()=>[j(q,{modelValue:e.show,"onUpdate:modelValue":a=>e.show=a},null,8,["modelValue","onUpdate:modelValue"])])),_:2},1024),j(b,{xs:1,sm:1,class:"flex justify-end"},{default:$((()=>[j(J,{content:l.$t("pages.setting.user.confirm_delete"),onConfirm:a=>(e=>{o.toolBarButtons=o.toolBarButtons.filter((a=>a!==e))})(e)},{default:$((()=>[j(N,{shape:"square",variant:"text"},{default:$((()=>[j(H(oe),{slot:"icon"})])),_:1})])),_:2},1032,["content","onConfirm"])])),_:2},1024)])),_:2},1024)])),_:1},8,["modelValue"])])]),k("div",null,[k("h1",Te,B(l.$t("pages.setting.user.theme_settings")),1),j(be)])])),_:1},512),j(X,{visible:ze.value,"onUpdate:visible":t[10]||(t[10]=e=>ze.value=e),attach:"body",header:"发现新的备份"},{body:$((()=>[t[13]||(t[13]=k("p",null,"检测到服务器上存在较新的备份数据。您希望如何处理?",-1)),k("p",null,"本地版本:"+B(fe.value),1),k("p",null,"服务器版本:"+B(Ae.value),1)])),footer:$((()=>[j(N,{onClick:He,loading:Ce.value},{default:$((()=>t[14]||(t[14]=[R("覆盖服务器数据")]))),_:1},8,["loading"]),j(N,{theme:"primary",onClick:Re,loading:Me.value},{default:$((()=>t[15]||(t[15]=[R("从服务器恢复")]))),_:1},8,["loading"])])),_:1},8,["visible"])])),_:1})}}}),[["__scopeId","data-v-fab0795e"]]);export{Ce as default};
|
.output/public/assets/index-DJgKQCUj.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.color-container[data-v-f0f6ec52]{width:24px;height:24px;border-radius:var(--td-radius-circle);display:inline-block}.setting-layout-color-group{display:inline-flex;justify-content:center;align-items:center;border-radius:50%!important;padding:6px!important;border:2px solid transparent!important}.setting-layout-color-group>.t-radio-button__label{display:inline-flex}.tdesign-setting-close{position:fixed;bottom:200px;right:300px}.setting-group-title{font-size:14px;line-height:22px;margin:16px 0;text-align:left;font-family:"PingFang SC",var(--td-font-family);font-style:normal;font-weight:500;color:var(--td-text-color-primary)}.setting-link{cursor:pointer;color:var(--td-brand-color);margin-bottom:8px}.setting-info{text-align:center;color:var(--td-text-color-placeholder);width:100%;background:var(--td-bg-color-container)}.setting-container .t-radio-group.t-size-m{min-height:32px;width:100%;justify-content:space-between;align-items:center}.setting-container .t-radio-group.t-size-m .t-radio-button{height:auto}.setting-container .setting-layout-drawer{display:flex;flex-direction:column;align-items:center;margin-bottom:16px}.setting-container .setting-layout-drawer .t-radio-button{display:inline-flex;max-height:78px;padding:8px;border-radius:var(--td-radius-default);border:2px solid var(--td-component-border)}.setting-container .setting-layout-drawer .t-radio-button>.t-radio-button__label{display:inline-flex}.setting-container .setting-layout-drawer .t-is-checked{border:2px solid var(--td-brand-color)!important}.setting-container .setting-layout-drawer .t-form__controls-content,.setting-container .t-form__controls-content{justify-content:end}.setting-route-theme .t-form__label{min-width:310px!important;color:var(--td-text-color-secondary)}.setting-color-theme .setting-layout-drawer .t-radio-button{height:32px}.setting-color-theme .setting-layout-drawer:last-child{margin-right:0}.drag-handle[data-v-fab0795e]{cursor:move}.drag-handle[data-v-fab0795e]:hover{opacity:.7}
|
.output/public/assets/index-DUia5xTm.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{v as e,y as t,ag as l,l as a,f as i,A as r,C as s,J as o,ac as n,H as d,a as f,w as p,a0 as h,a1 as u,R as c,aa as m,G as v,u as g,F as z,ab as _,I as x}from"./@vue-DsZlmJIP.js";import{u as w,a as k}from"./vue-router-Be5-2oBH.js";import{_ as B,d as M,m as y,c as j,u as E,t as H,e as F}from"./global-BveI--BU.js";import{_ as A}from"./ChatInput.vue_vue_type_style_index_0_lang-CF8t52ZG.js";import{u as S}from"./app-_ksMLlTy.js";import{A as U,l as G,j as I,m as L,g as b,n as V,o as C,c as O,f as q}from"./tdesign-vue-next-DsCOKp3d.js";import{v as R}from"./uuid-_R2nDvl_.js";import{u as T}from"./main-zbluuG_-.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./lodash-Cky9m9r7.js";import"./@vueuse-Cn3Nsuq9.js";import"./vue-i18n-Dmk40Gks.js";import"./@intlify-eboPrqDD.js";import"./pinia-jKJ-xldK.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./tdesign-icons-vue-next-Dn30dVUK.js";import"./mammoth-5Ncu60I4.js";import"./elkjs-CmFeGg_o.js";import"./xlsx-DB6BMndo.js";import"./pdfjs-dist-8WFUNQXM.js";import"./lodash-es-BkU_-LF8.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";import"./@wdns-P0uM2sk1.js";import"./ua-parser-js-9pz7LJLQ.js";import"./vuedraggable-K5Gqz8r2.js";import"./vue-DVRmszIO.js";const D={xmlns:"http://www.w3.org/2000/svg",width:"200",height:"140",fill:"none"};const $={render:function(a,i){return t(),e("svg",D,i[0]||(i[0]=[l('<g mask="url(#mask0_17_619)"><path fill="#97A3B7" d="M30 62h88v60H30z"></path><g filter="url(#filter0_f_17_619)"><path fill="#E3E6EB" d="M12 84h80v60H12z"></path></g><g filter="url(#filter1_f_17_619)"><path fill="#E3E6EB" d="M80 54h80v60H80z"></path></g><path fill="#fff" d="M46 105h32v2H46zM46 98h32v2H46zM46 88h16v2H46z"></path></g><path fill="currentcolor" d="M63 20h88v10H63z" opacity=".9"></path><mask id="a" width="88" height="50" x="63" y="30" maskUnits="userSpaceOnUse" style="mask-type:alpha;"><path fill="currentcolor" d="M63 30h88v50H63z"></path></mask><g mask="url(#a)"><path fill="currentcolor" d="M63 30h88v50H63z"></path><g filter="url(#filter2_f_17_619)" opacity=".3"><path fill="#97A3B7" d="M30 62h88v60H30z"></path></g></g><path fill="#fff" fill-rule="evenodd" d="m95.686 40.858 10.278 10.277A4 4 0 0 1 107 51c2.213 0 4 1.786 4 4q-.002.538-.134 1.033l10.276 10.28-2.828 2.829-4.598-4.597A17.1 17.1 0 0 1 107 65.909c-7.273 0-13.484-4.524-16-10.91a17.3 17.3 0 0 1 5.696-7.472l-3.838-3.84zM99 55a8.003 8.003 0 0 0 12.063 6.892l-3.029-3.026q-.496.132-1.034.134c-2.213 0-4-1.787-4-4q.002-.538.134-1.034l-3.027-3.027A7.96 7.96 0 0 0 99 54.999m8-10.91c7.273 0 13.484 4.524 16 10.91a17.3 17.3 0 0 1-4.166 6.177l-4.105-4.105a8.003 8.003 0 0 0-9.801-9.8l-2.55-2.551c1.47-.41 3.02-.63 4.622-.63" clip-rule="evenodd"></path><path fill="#fff" d="M68 24h2v2h-2zM74 24h2v2h-2zM80 24h66v2H80z"></path><path fill="#fff" stroke="#000" d="m157 54 24.249 42h-48.498z"></path><path stroke="#000" d="M157 89V71"></path>',8)]))}},N={xmlns:"http://www.w3.org/2000/svg",width:"200",height:"140",fill:"none"};const J={render:function(a,i){return t(),e("svg",N,i[0]||(i[0]=[l('<g mask="url(#mask0_16559_24301)"><path fill="#97A3B7" d="M30 62h88v60H30z"></path><g filter="url(#filter0_f_16559_24301)"><path fill="#E3E6EB" d="M12 84h80v60H12z"></path></g><g filter="url(#filter1_f_16559_24301)"><path fill="#E3E6EB" d="M80 54h80v60H80z"></path></g><path stroke="#fff" stroke-width="2" d="m49 93-7 7 7 7M69 107l7-7-7-7M62.365 87.443l-6.73 25.114"></path></g><path fill="currentcolor" d="M63 20h88v10H63z" opacity=".9"></path><mask id="a" width="88" height="50" x="63" y="30" maskUnits="userSpaceOnUse" style="mask-type:alpha;"><path fill="currentcolor" d="M63 30h88v50H63z"></path></mask><g mask="url(#a)"><path fill="currentcolor" d="M63 30h88v50H63z"></path><g filter="url(#filter2_f_16559_24301)" opacity=".3"><path fill="#97A3B7" d="M30 62h88v60H30z"></path></g></g><path fill="#fff" fill-rule="evenodd" d="M105.25 41c6.765 0 12.25 5.484 12.25 12.25 0 2.433-.709 4.7-1.932 6.606L121 65.288 117.288 69l-5.432-5.432a12.2 12.2 0 0 1-6.606 1.932C98.484 65.5 93 60.016 93 53.25S98.484 41 105.25 41m0 3.5a8.75 8.75 0 1 0 0 17.5 8.75 8.75 0 0 0 0-17.5" clip-rule="evenodd"></path><path fill="#fff" d="M68 24h2v2h-2zM74 24h2v2h-2zM80 24h66v2H80z"></path><path fill="#fff" fill-rule="evenodd" d="M153 56c-12.15 0-22 9.85-22 22 0 4.604 1.414 8.878 3.832 12.41L127 98.5l12.495-3.132A21.9 21.9 0 0 0 153 100c12.15 0 22-9.85 22-22s-9.85-22-22-22" clip-rule="evenodd"></path><path fill="#000" d="M131 78h.5zm3.832 12.41.359.348.284-.293-.23-.337zM127 98.5l-.359-.348-1.219 1.259 1.7-.426zm12.495-3.132.307-.394-.192-.15-.237.06zM153 100v.5zm22-22h-.5zm-43.5 0c0-11.874 9.626-21.5 21.5-21.5v-1c-12.426 0-22.5 10.074-22.5 22.5zm3.745 12.128A21.4 21.4 0 0 1 131.5 78h-1c0 4.708 1.446 9.08 3.919 12.693zm-.772-.066-7.832 8.09.718.696 7.832-8.09zm-7.351 8.923 12.494-3.132-.243-.97-12.495 3.132zM153 99.5c-4.976 0-9.555-1.69-13.198-4.526l-.615.789A22.4 22.4 0 0 0 153 100.5zM174.5 78c0 11.874-9.626 21.5-21.5 21.5v1c12.426 0 22.5-10.074 22.5-22.5zM153 56.5c11.874 0 21.5 9.626 21.5 21.5h1c0-12.426-10.074-22.5-22.5-22.5z"></path>',8)]))}},P={xmlns:"http://www.w3.org/2000/svg",width:"200",height:"140",fill:"none"};const Q={render:function(a,i){return t(),e("svg",P,i[0]||(i[0]=[l('<g mask="url(#mask0_16559_24251)"><path fill="#97A3B7" d="m68 48 38.105 22v44L68 136l-38.105-22V70z"></path><g filter="url(#a)"><path fill="#E3E6EB" d="M46.391 92h80v60h-80z"></path></g><g filter="url(#b)"><path fill="#E3E6EB" d="M0 23h80v60H0z"></path></g></g><mask id="c" width="78" height="88" x="80" y="9" maskUnits="userSpaceOnUse" style="mask-type:alpha;"><path fill="currentcolor" d="m119 9 38.105 22v44L119 97 80.895 75V31z"></path></mask><g mask="url(#c)"><path fill="currentcolor" fill-rule="evenodd" d="M80.895 31v44L119 97l38.105-22V31L119 53z" clip-rule="evenodd"></path><path fill="currentcolor" d="m119-35 38.105 22v44.5L119 53.5l-38.105-22V-13z" opacity=".9"></path><g filter="url(#d)" opacity=".3"><path fill="#97A3B7" d="m68 48 38.105 22v44L68 136l-38.105-22V70z"></path></g></g><path fill="#fff" stroke="#000" d="m143 68.822 4.867 17.053.133.466.469-.118 17.202-4.312-12.335 12.741-.337.348.337.348 12.335 12.741-17.202-4.312-.469-.118-.133.466L143 121.178l-4.867-17.053-.133-.466-.469.118-17.202 4.312 12.335-12.741.337-.348-.337-.348-12.335-12.741 17.202 4.312.469.118.133-.466z"></path><path fill="#fff" fill-rule="evenodd" d="m123.243 35.082 2.828-1.633-2.828-1.633-2.829 1.633zM119 32.632 121.828 31l-7.071-4.082-2.828 1.633zm8.485 3.267c-4.679 2.701-12.291 2.701-16.97 0-4.68-2.702-4.68-7.096 0-9.798s12.291-2.701 16.97 0c4.68 2.702 4.68 7.096 0 9.798m-19.799-11.43c-6.248 3.607-6.248 9.455 0 13.062s16.38 3.607 22.628 0 6.248-9.455 0-13.062-16.38-3.607-22.628 0M41.899 86.286l2.828 1.633v6.532L41.9 92.818zm12.02 6.94 2.829 1.634v6.532l-2.828-1.633zm-9.19 14.289-2.83-1.633.001 3.266 2.828 1.633zl9.192 5.307v3.266l2.828 1.633v-3.266l-2.828-1.633v-3.266l-9.192-5.307z" clip-rule="evenodd"></path><defs><filter id="a" width="180" height="160" x="-3.609" y="42" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_16559_24251" stdDeviation="25"></feGaussianBlur></filter><filter id="b" width="180" height="160" x="-50" y="-27" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_16559_24251" stdDeviation="25"></feGaussianBlur></filter><filter id="d" width="88.21" height="100" x="23.895" y="42" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_16559_24251" stdDeviation="3"></feGaussianBlur></filter></defs>',6)]))}},W={xmlns:"http://www.w3.org/2000/svg",width:"200",height:"140",fill:"none"};const K={render:function(a,i){return t(),e("svg",W,i[0]||(i[0]=[l('<g mask="url(#mask0_22_990)"><path fill="#97A3B7" fill-rule="evenodd" d="m144.569 105.61-48 27.712-48-27.712V83.712L96.57 56l48 27.713z" clip-rule="evenodd"></path><g filter="url(#filter0_f_22_990)"><path fill="#E3E6EB" d="M-3 33.999h80v60H-3z"></path></g><g filter="url(#filter1_f_22_990)"><path fill="#E3E6EB" d="M97 97.999h80v60H97z"></path></g></g><mask id="a" width="86" height="69" x="53" y="16" maskUnits="userSpaceOnUse" style="mask-type:alpha;"><path fill="currentcolor" fill-rule="evenodd" d="m113.357 42.715 16.472-9.51a36 36 0 0 0-3.186-2.043c-5.375-3.104-11.92-5.147-18.885-6.139-4.209-5.562-10.18-8.898-17.324-8.828-6.755.087-15.486 5.746-21.507 14.365q-1.247.622-2.432 1.306c-14.378 8.3-16.94 20.75-7.473 30.065-1.035-5.805-.31-10.865 3.101-16.215-.058.632-.21 4.427-.232 5.067-.67 18.914 15.02 34.058 26.139 33.928 8.45-.1 15.565-5.013 20.319-12.631 6.214-1.231 12.089-3.294 17.094-6.183 13.476-7.78 16.567-19.182 9.104-28.268l-16.599 9.582c1.762 3.654.049 7.823-5.078 10.783-5.126 2.96-12.347 3.948-18.677 2.931-2.843-.469-5.522-1.342-7.74-2.622l-.049-.028zM78.655 53.773c-6.127-3.977-5.683-10.226 1.195-14.197s17.703-4.226 24.591-.69zM93.556 18.17c4.61-.04 8.728 2.405 11.94 6.57-8.447-.918-17.384-.326-25.523 1.765 3.699-5.124 8.471-8.275 13.583-8.335m-2.232 63.447c-5.853.068-10.971-3.926-14.377-10.332 8.845 2.342 18.925 2.775 28.427 1.317-3.756 5.52-8.714 8.951-14.05 9.015" clip-rule="evenodd"></path></mask><g mask="url(#a)"><path fill="currentcolor" fill-rule="evenodd" d="m113.357 42.715 16.472-9.51a36 36 0 0 0-3.186-2.043c-5.375-3.104-11.92-5.147-18.885-6.139-4.209-5.562-10.18-8.898-17.324-8.828-6.755.087-15.486 5.746-21.507 14.365q-1.247.622-2.432 1.306c-14.378 8.3-16.94 20.75-7.473 30.065-1.035-5.805-.31-10.865 3.101-16.215-.058.632-.21 4.427-.232 5.067-.67 18.914 15.02 34.058 26.139 33.928 8.45-.1 15.565-5.013 20.319-12.631 6.214-1.231 12.089-3.294 17.094-6.183 13.476-7.78 16.567-19.182 9.104-28.268l-16.599 9.582c1.762 3.654.049 7.823-5.078 10.783-5.126 2.96-12.347 3.948-18.677 2.931-2.843-.469-5.522-1.342-7.74-2.622l-.049-.028zM78.655 53.773c-6.127-3.977-5.683-10.226 1.195-14.197s17.703-4.226 24.591-.69zM93.556 18.17c4.61-.04 8.728 2.405 11.94 6.57-8.447-.918-17.384-.326-25.523 1.765 3.699-5.124 8.471-8.275 13.583-8.335m-2.232 63.447c-5.853.068-10.971-3.926-14.377-10.332 8.845 2.342 18.925 2.775 28.427 1.317-3.756 5.52-8.714 8.951-14.05 9.015" clip-rule="evenodd"></path><g filter="url(#filter2_f_22_990)" opacity=".3"><path fill="#97A3B7" d="m96.569 56 48 27.712v55.426l-48 27.712-48-27.712V83.712z"></path></g></g><circle cx="155" cy="78" r="22" fill="#fff" stroke="#000" transform="rotate(180 155 78)"></circle><path stroke="#000" d="M155 83V65"></path><path fill="#C4C4C4" stroke="#000" stroke-linejoin="round" stroke-width="2" d="M155 87h.004v.004H155z"></path><path stroke="#fff" stroke-width="2" d="M96.57 112V88M86.57 98l10-10 9.999 10"></path>',7)]))}},X={xmlns:"http://www.w3.org/2000/svg",width:"200",height:"140",fill:"none"};const Y={render:function(a,i){return t(),e("svg",X,i[0]||(i[0]=[l('<mask id="a" width="78" height="88" x="80" y="9" maskUnits="userSpaceOnUse" style="mask-type:alpha;"><path fill="currentColor" d="m119 9 38.105 22v44L119 97 80.895 75V31z"></path></mask><g mask="url(#a)"><path fill="currentColor" d="m119 9 38.105 22v44L119 97 80.895 75V31z"></path><g filter="url(#b)" opacity=".3"><path fill="#97A3B7" d="m68 48 38.105 22v44L68 136l-38.105-22V70z"></path></g></g><mask id="c" width="78" height="88" x="29" y="48" maskUnits="userSpaceOnUse" style="mask-type:alpha;"><path fill="#97A3B7" d="m68 48 38.105 22v44L68 136l-38.105-22V70z"></path></mask><g mask="url(#c)"><path fill="#97A3B7" d="m68 48 38.105 22v44L68 136l-38.105-22V70z"></path><g filter="url(#d)"><path fill="#E3E6EB" d="M46.391 92h80v60h-80z"></path></g><g filter="url(#e)"><path fill="#E3E6EB" d="M0 23h80v60H0z"></path></g></g><path fill="#fff" d="m41.898 86.287 2.829 1.633v6.531l-2.828-1.632zM53.919 93.227l2.828 1.633v6.532l-2.828-1.633zM44.728 107.515l-2.829-1.633v3.266l2.829 1.633zl9.191 5.308v3.265l2.829 1.633v-3.266l-2.828-1.632v-3.266l-9.193-5.308z"></path><path fill="#fff" fill-rule="evenodd" d="M108.348 23.48c-2.16 2.51-1.813 5.903 1.047 8.08 3.265 2.486 8.568 2.447 11.845-.087 3.276-2.534 3.286-6.603.021-9.089-2.86-2.177-7.284-2.417-10.54-.74l5.202 3.96-2.373 1.836z" clip-rule="evenodd"></path><path fill="#fff" fill-rule="evenodd" d="m120.865 33.009 8.965 6.826 2.373-1.836-8.965-6.826q-.481.523-1.089.993-.608.468-1.284.843m-1.203-.916a8.5 8.5 0 0 0 1.305-.828 7.248 7.248 0 0 1 0 0 8.5 8.5 0 0 1-1.305.828" clip-rule="evenodd"></path><path fill="#fff" stroke="#181818" d="m144 70 24.249 42h-48.498z"></path><path stroke="#181818" d="M144 100V82"></path><path stroke="#181818" stroke-linejoin="round" stroke-width="2" d="M144 105h.004v.004H144z"></path><defs><filter id="b" width="88.21" height="100" x="23.895" y="42" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_216_313" stdDeviation="3"></feGaussianBlur></filter><filter id="d" width="180" height="160" x="-3.609" y="42" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_216_313" stdDeviation="25"></feGaussianBlur></filter><filter id="e" width="180" height="160" x="-50" y="-27" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"></feBlend><feGaussianBlur result="effect1_foregroundBlur_216_313" stdDeviation="25"></feGaussianBlur></filter></defs>',11)]))}},Z={xmlns:"http://www.w3.org/2000/svg",width:"200",height:"140",fill:"none"};const ee={render:function(a,i){return t(),e("svg",Z,i[0]||(i[0]=[l('<g mask="url(#mask0_21_716)"><path fill="#97A3B7" fill-rule="evenodd" d="M33 46.843 96.321 119l63.322-72.157C142.742 32 120.583 23 96.321 23 72.061 23 49.901 32 33 46.843" clip-rule="evenodd"></path><g filter="url(#filter0_f_21_716)"><path fill="#E3E6EB" d="M95 21h80v60H95z"></path></g><g filter="url(#filter1_f_21_716)"><path fill="#E3E6EB" d="M-7 43h80v60H-7z"></path></g></g><path fill="currentcolor" d="m72.812 63.688-3.157 3.157 6.246 6.247a50.3 50.3 0 0 0-12.713 8.151L96.321 119l11.913-13.575 6.413 6.412 3.157-3.157L80.45 71.326zM129.455 81.243l-15.318 17.455-28.74-28.74a50.4 50.4 0 0 1 10.924-1.19c12.695 0 24.29 4.709 33.134 12.475"></path><path fill="#fff" stroke="#000" d="m152 21.822 4.867 17.053.133.465.469-.117 17.202-4.312-12.335 12.741-.337.348.337.348 12.335 12.741-17.202-4.312-.469-.117-.133.465L152 74.178l-4.867-17.053-.133-.465-.469.117-17.202 4.312 12.335-12.741.337-.348-.337-.348-12.335-12.741 17.202 4.312.469.117.133-.465z"></path><path stroke="#fff" stroke-width="2" d="M101 31 90 42l11 11-8 8"></path>',4)]))}},te={class:"result-container"},le={class:"result-bg-img"},ae={class:"result-title"},ie={class:"result-tip"},re=B(a({__name:"index",props:{bgUrl:String,title:String,tip:String,type:String},setup(l){const a=l,f=i((()=>{switch(a.type){case"403":default:return $;case"404":return J;case"500":return Q;case"ie":return K;case"wifi":return ee;case"maintenance":return Y}}));return(a,i)=>(t(),e("div",te,[r("div",le,[(t(),o(n(f.value)))]),r("div",ae,d(l.title),1),r("div",ie,d(l.tip),1),s(a.$slots,"default",{},void 0,!0)]))}}),[["__scopeId","data-v-50bd89bc"]]),se={class:"flex-1 w-full overflow-hidden flex flex-col"},oe={class:"flex flex-col justify-center items-center gap-3 w-full"},ne={class:"text-center"},de={class:"text-2xl font-bold"},fe=["title"],pe={class:"text-center p-2"},he={key:0,class:"flex flex-col items-center align-middle gap-5 w-full p-2 overflow-y-auto no-scrollbar"},ue=["title"],ce={class:"flex gap-1"},me={class:"w-[200px] whitespace-nowrap text-ellipsis overflow-hidden"},ve={class:"w-full relative"},ge=a({name:"NewConversation",setup(l){const a=T(),s=w(),B=k(),D=f(null);p((()=>s.query.id),(e=>{if("/conversation/index"!==s.path)return void(D.value=null);const t=e;D.value=t?a.find(t):a.defaultAgent}),{immediate:!0}),M();const $=i((()=>y.availableModels.value.map((e=>({...e,title:y.getModelItemTitle(e)}))))),N=f([]),J=e=>{},P=j(),Q=e=>{if(0===N.value.length)return void q.error(H("pages.conversation.noSelectModelMsg"));const t={id:R(),name:D.value.name,avatar:D.value.avatar,agentId:D.value.id,content:D.value.content,models:[],time:(new Date).getTime(),pinned:!1,maxContextSize:10,aspectRatio:"IMAGE_ASPECT_RATIO_SQUARE",internet:!1};t.models=N.value.map((e=>({modelId:e,chats:[],startContext:0,apiAgentId:"",apiConversationId:"",apiNote:"",showing:!0,status:{responseWating:!1,chating:!1,stop:!1}}))),P.add(t),N.value=[],F.setData(e),B.push({path:"/conversation/chat",query:{id:t.id,isNew:1}})},W=E(),K=i((()=>{let e="h-[calc(100vh-2*var(--td-comp-paddingTB-m))]";return W.showLayoutHeader&&W.showFooter&&(e="h-[calc(100vh-var(--td-comp-size-xxl)-var(--td-comp-size-xxxl)-2*var(--td-comp-paddingTB-m))]"),W.showLayoutHeader&&!W.showFooter&&(e="h-[calc(100vh-var(--td-comp-size-xxxl)-2*var(--td-comp-paddingTB-m))]"),!W.showLayoutHeader&&W.showFooter&&(e="h-[calc(100vh-var(--td-comp-size-xxl)-2*var(--td-comp-paddingTB-m))]"),e})),X=e=>{B.push(e)};return(l,a)=>{const i=U,s=G,f=V,p=b,w=L,k=I,B=C,M=O;return h((t(),e("div",{class:x(["flex flex-col items-center w-full gap-5",K.value])},[r("div",se,[r("div",oe,[c(i,{size:"80px",image:D.value.avatar},null,8,["image"]),r("div",ne,[r("h1",de,d(D.value.name),1),c(s,{underline:"",theme:"primary",onClick:a[0]||(a[0]=e=>X("/setting/agent"))},{default:m((()=>[v(d(l.$t("pages.conversation.switchAgent")),1)])),_:1})]),r("div",{class:"text-center text-sm text-gray-500 w-full overflow-hidden whitespace-nowrap text-ellipsis",title:D.value.content},d(D.value.content),9,fe)]),r("div",pe,[r("span",null,d(l.$t("pages.conversation.modelTips",{max_model_num:g(S)})),1)]),$.value.length>0?(t(),e("div",he,[c(B,{modelValue:N.value,"onUpdate:modelValue":a[1]||(a[1]=e=>N.value=e),onChange:J,max:g(S),class:"w-full"},{default:m((()=>[c(k,{gutter:[{xs:0,sm:16,md:16,lg:16,xl:16,xxl:16},16],class:"w-full"},{default:m((()=>[(t(!0),e(z,null,_($.value,(e=>(t(),o(w,{key:e.id,xs:12,lg:4,xl:3},{default:m((()=>[c(p,{class:"shadow-md",bordered:!1},{default:m((()=>[r("div",{class:"flex justify-between overflow-hidden",title:e.title},[r("div",ce,[c(i,{size:"20px",class:"mr-1"},{icon:m((()=>[(t(),o(n(g(y).icons[e.type])))])),_:2},1024),r("div",me,d(e.title),1)]),(t(),o(f,{key:e.id,value:e.id},null,8,["value"]))],8,ue)])),_:2},1024)])),_:2},1024)))),128))])),_:1})])),_:1},8,["modelValue","max"])])):(t(),o(re,{key:1,type:"404",title:l.$t("pages.conversation.emptyModelTips")},{default:m((()=>[c(M,{size:"large",theme:"primary",variant:"base",onClick:a[2]||(a[2]=e=>X("/setting/model"))},{default:m((()=>[v(d(l.$t("pages.conversation.createModel")),1)])),_:1})])),_:1},8,["title"]))]),r("div",ve,[c(A,{onInput:Q})])],2)),[[u,D.value]])}}});export{ge as default};
|
.output/public/assets/index-LPxgpECk.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{t as e}from"./global-BveI--BU.js";import{a as t}from"./vue-router-Be5-2oBH.js";import{W as a,X as i,l as s,x as o,g as r,f as l}from"./tdesign-vue-next-DsCOKp3d.js";import{l as n,f as p,a as m,J as u,y as d,aa as j,R as v,G as c,H as g}from"./@vue-DsZlmJIP.js";import{a as f}from"./main-zbluuG_-.js";import"./lodash-Cky9m9r7.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./@vueuse-Cn3Nsuq9.js";import"./vue-i18n-Dmk40Gks.js";import"./@intlify-eboPrqDD.js";import"./pinia-jKJ-xldK.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./tdesign-icons-vue-next-Dn30dVUK.js";import"./lodash-es-BkU_-LF8.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";import"./@wdns-P0uM2sk1.js";import"./ua-parser-js-9pz7LJLQ.js";import"./vuedraggable-K5Gqz8r2.js";import"./vue-DVRmszIO.js";const h=n({name:"About Page",setup(n){const h=f(),b=p((()=>h.data)),k=t(),y=[{title:e("pages.note.tableTitleName"),align:"left",width:320,colKey:"title",fixed:"left"},{title:e("pages.note.tableOperation"),align:"left",fixed:"right",width:160,colKey:"op"}],w=m({defaultPageSize:20,total:b.value.length,defaultCurrent:1}),x=m(""),C=m(!1),_=()=>{h.remove(x.value),C.value=!1,l.success(e("pages.note.deleteMsgSuccess")),$()},$=()=>{x.value=""},z=()=>{$()};return(e,t)=>{const l=s,n=i,p=a,m=o,f=r;return d(),u(f,null,{default:j((()=>[v(p,{data:b.value,columns:y,"row-key":"id","vertical-align":"top",hover:!0,pagination:w.value},{op:j((t=>[v(n,null,{default:j((()=>[v(l,{theme:"primary",onClick:e=>{return a=t,void k.push(`/note/content?id=${a.row.id}`);var a}},{default:j((()=>[c(g(e.$t("pages.note.detail")),1)])),_:2},1032,["onClick"]),v(l,{theme:"danger",onClick:e=>{return a=t,x.value=a.row.id,void(C.value=!0);var a}},{default:j((()=>[c(g(e.$t("pages.note.delete")),1)])),_:2},1032,["onClick"])])),_:2},1024)])),_:1},8,["data","pagination"]),v(m,{visible:C.value,"onUpdate:visible":t[0]||(t[0]=e=>C.value=e),header:e.$t("layout.sideNav.confirmDelete"),"on-cancel":z,onConfirm:_},null,8,["visible","header"])])),_:1})}}});export{h as default};
|
.output/public/assets/main-zbluuG_-.js
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DUia5xTm.js","./@vue-DsZlmJIP.js","./@babel-D5ZMb8W9.js","./core-js-pure-ZQ_YVJtv.js","./vue-router-Be5-2oBH.js","./global-BveI--BU.js","./lodash-Cky9m9r7.js","./tdesign-vue-next-DsCOKp3d.js","./tdesign-icons-vue-next-Dn30dVUK.js","./tdesign-icons-vue-next-BGgy7GQY.css","./lodash-es-BkU_-LF8.js","./sortablejs-DGtSoqI-.js","./@popperjs-B4tvfKWZ.js","./tdesign-vue-next-C9LLy99s.css","./@vueuse-Cn3Nsuq9.js","./vue-i18n-Dmk40Gks.js","./@intlify-eboPrqDD.js","./pinia-jKJ-xldK.js","./pinia-plugin-persistedstate-DyrI1rJI.js","./destr-ClW9AvhW.js","./deep-pick-omit-DP_A4OSP.js","./tvision-color-Dyv1XgcL.js","./chroma-js-C-7CTB41.js","./@material-C_XhzpVg.js","./bezier-easing-7-TbLOHs.js","./ChatInput.vue_vue_type_style_index_0_lang-CF8t52ZG.js","./mammoth-5Ncu60I4.js","./elkjs-CmFeGg_o.js","./xlsx-DB6BMndo.js","./pdfjs-dist-8WFUNQXM.js","./ChatInput-BMuO6hgs.css","./app-_ksMLlTy.js","./uuid-_R2nDvl_.js","./@wdns-P0uM2sk1.js","./ua-parser-js-9pz7LJLQ.js","./vuedraggable-K5Gqz8r2.js","./vue-DVRmszIO.js","./index-DWphMrS1.css","./chat-BW5Qhkmv.js","./avatar.vue_vue_type_script_setup_true_lang-jav6E5Ln.js","./@dicebear-JcnEMRoc.js","./fetch-2coGNStX.js","./eventsource-parser-BEY8Dpg-.js","./@mozilla-BD532_dh.js","./CodeBlocks.vue_vue_type_style_index_0_lang-DWS4lyNS.js","./markdown-DPs5ApTw.js","./markdown-it-link-attributes-UnOqz_aA.js","./markdown-it-C8SkdHr7.js","./mdurl-CDXpswLz.js","./uc.micro-CLkLCS2f.js","./entities-D7HTx9ov.js","./linkify-it-LcVOBuC5.js","./punycode.js-Bmr3cAX8.js","./@traptitech-BPk2gen6.js","./katex-BY7yyeOs.js","./markdown-it-highlightjs-Ikc7oQsB.js","./highlight.js-Ds8M-WS2.js","./@agoose77-mGnNv_bd.js","./mermaid-B98QzgAP.js","./dayjs-DOPU4UI6.js","./@braintree-DgpeZQRe.js","./d3-transition-swcnLnsT.js","./d3-timer-keMr1twq.js","./d3-dispatch-Chq_f_hl.js","./d3-interpolate-Ct9kki6l.js","./d3-color-D5ULnJIe.js","./d3-selection-G65jBFUY.js","./d3-ease-Cx6bG2vu.js","./d3-zoom-D4Vc87xO.js","./dompurify-B5jhUdWW.js","./dagre-d3-es-FtH4B9px.js","./d3-shape-C1TbtrGg.js","./d3-path-QSrLXsQ3.js","./d3-fetch-XwboCDHR.js","./khroma-Ca6ZlOUT.js","./ts-dedent-CttZBlkd.js","./stylis-Cl7w7uv3.js","./d3-scale-CjTvl_Qo.js","./internmap-B8oPgqVZ.js","./d3-array-B0evfIyH.js","./d3-format-C0lSXcPg.js","./d3-time-format-D74OpZq4.js","./d3-time-CebKitJR.js","./d3-axis-pCwzqJ1S.js","./cytoscape-D84qPEQv.js","./cytoscape-cose-bilkent-CoOmxuE9.js","./cose-base-kQthUiMK.js","./layout-base-DqRk0Tgc.js","./CodeBlocks-Cek-iqBx.css","./lyihub-zLFv36Ly.js","./chat-Cg_gpPLS.css","./index-BSlpP4WW.js","./index-DJgKQCUj.css","./index-Dc0PR0S6.js","./index-BJf2iObo.js","./index-BPfFXn2Y.js","./FrameContent-BXoZjZi-.js","./FrameContent-CUoI637t.css","./about-D4hEieAK.js","./help-Dm0-B9za.js","./changelog-CmzmwycZ.js","./index-LPxgpECk.js","./content-CMwtYO4S.js","./content-CXerDfC_.css"])))=>i.map(i=>d[i]);
|
2 |
+
var e;import{i as t,l as a,a as n,u as s,_ as i,p as l,b as r,c as o,t as d,s as u,m as c}from"./global-BveI--BU.js";import{f as p,l as m,a9 as v,J as h,y as f,aa as g,I as A,u as D,v as y,ab as C,G as E,H as w,F as b,ac as F,R as k,z as x,A as j,o as _,a as S,w as I,ad as M,V as L,U as R}from"./@vue-DsZlmJIP.js";import{u as O}from"./@vueuse-Cn3Nsuq9.js";import{u as P}from"./vue-i18n-Dmk40Gks.js";import{C as z,B as V,a as U,H as N,M as T,L as W,b as X,F as Q,S as G,c as H,R as B,d as Z,e as J,P as Y,T as q,A as K,f as $,g as ee,h as te,i as ae,j as ne}from"./tdesign-vue-next-DsCOKp3d.js";import{_ as se}from"./@wdns-P0uM2sk1.js";import{u as ie,a as le,c as re,b as oe}from"./vue-router-Be5-2oBH.js";import{d as de}from"./pinia-jKJ-xldK.js";import{Q as ue,R as ce,d as pe,B as me,S as ve,T as he,K as fe,U as ge}from"./tdesign-icons-vue-next-Dn30dVUK.js";import{d as Ae}from"./vuedraggable-K5Gqz8r2.js";import"./lodash-Cky9m9r7.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./@intlify-eboPrqDD.js";import"./lodash-es-BkU_-LF8.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";import"./ua-parser-js-9pz7LJLQ.js";import"./vue-DVRmszIO.js";function De(){const{locale:e}=P({useScope:"global"});return{changeLocale:function(t){n.includes(t)||(t="zh_CN"),e.value=t,O(a,"zh_CN").value=t},getComponentsLocale:p((()=>t.global.getLocaleMessage(e.value).componentsLocale)),locale:e}}const ye=de("agent",{state:()=>({agents:[],defaultAgent:{id:"1",name:"小助手",content:"你是一个有用的人工智能助手。你可以通过回答我的问题来帮助我。",status:!0,avatar:"data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20180%20180%22%20fill%3D%22none%22%20shape-rendering%3D%22auto%22%3E%3Cmetadata%20xmlns%3Ardf%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3Adc%3D%22http%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%22%20xmlns%3Adcterms%3D%22http%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%22%3E%3Crdf%3ARDF%3E%3Crdf%3ADescription%3E%3Cdc%3Atitle%3EBottts%3C%2Fdc%3Atitle%3E%3Cdc%3Acreator%3EPablo%20Stanley%3C%2Fdc%3Acreator%3E%3Cdc%3Asource%20xsi%3Atype%3D%22dcterms%3AURI%22%3Ehttps%3A%2F%2Fbottts.com%2F%3C%2Fdc%3Asource%3E%3Cdcterms%3Alicense%20xsi%3Atype%3D%22dcterms%3AURI%22%3Ehttps%3A%2F%2Fbottts.com%2F%3C%2Fdcterms%3Alicense%3E%3Cdc%3Arights%3ERemix%20of%20%E2%80%9EBottts%E2%80%9D%20(https%3A%2F%2Fbottts.com%2F)%20by%20%E2%80%9EPablo%20Stanley%E2%80%9D%2C%20licensed%20under%20%E2%80%9EFree%20for%20personal%20and%20commercial%20use%E2%80%9D%20(https%3A%2F%2Fbottts.com%2F)%3C%2Fdc%3Arights%3E%3C%2Frdf%3ADescription%3E%3C%2Frdf%3ARDF%3E%3C%2Fmetadata%3E%3Cmask%20id%3D%22viewboxMask%22%3E%3Crect%20width%3D%22180%22%20height%3D%22180%22%20rx%3D%220%22%20ry%3D%220%22%20x%3D%220%22%20y%3D%220%22%20fill%3D%22%23fff%22%20%2F%3E%3C%2Fmask%3E%3Cg%20mask%3D%22url(%23viewboxMask)%22%3E%3Cg%20transform%3D%22translate(0%2066)%22%3E%3Cmask%20id%3D%22sidesAntenna01-a%22%20style%3D%22mask-type%3Aluminance%22%20maskUnits%3D%22userSpaceOnUse%22%20x%3D%226%22%20y%3D%2211%22%20width%3D%22156%22%20height%3D%2251%22%3E%3Cg%20fill%3D%22%23fff%22%3E%3Crect%20x%3D%226%22%20y%3D%2231%22%20width%3D%2236%22%20height%3D%2214%22%20rx%3D%224%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%2214%22%20width%3D%2236%22%20height%3D%2248%22%20rx%3D%224%22%2F%3E%3Crect%20x%3D%22126%22%20y%3D%2228%22%20width%3D%2236%22%20height%3D%2224%22%20rx%3D%224%22%2F%3E%3Cpath%20d%3D%22M11%2011h2v20h-2z%22%2F%3E%3C%2Fg%3E%3C%2Fmask%3E%3Cg%20mask%3D%22url(%23sidesAntenna01-a)%22%3E%3Cpath%20d%3D%22M0%200h180v76H0V0Z%22%20fill%3D%22%2300acc1%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-opacity%3D%22.3%22%20d%3D%22M0%200h180v76H0z%22%2F%3E%3Cpath%20fill%3D%22%23000%22%20fill-opacity%3D%22.1%22%20d%3D%22M0%2038h180v38H0z%22%2F%3E%3C%2Fg%3E%3Cpath%20fill%3D%22%23fff%22%20fill-opacity%3D%22.4%22%20d%3D%22M11%2011h2v20h-2z%22%2F%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%228%22%20r%3D%224%22%20fill%3D%22%23FFEA8F%22%2F%3E%3Ccircle%20cx%3D%2213%22%20cy%3D%227%22%20r%3D%222%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fg%3E%3Cg%20transform%3D%22translate(41)%22%3E%3Cmask%20id%3D%22topPyramid-a%22%20style%3D%22mask-type%3Aluminance%22%20maskUnits%3D%22userSpaceOnUse%22%20x%3D%2218%22%20y%3D%228%22%20width%3D%2264%22%20height%3D%2244%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22m50%208%2032%2044H18L50%208Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fmask%3E%3Cg%20mask%3D%22url(%23topPyramid-a)%22%3E%3Cpath%20d%3D%22M0%200h100v52H0V0Z%22%20fill%3D%22%2300acc1%22%2F%3E%3Cpath%20d%3D%22M0%200h100v52H0V0Z%22%20fill%3D%22%23fff%22%20fill-opacity%3D%22.3%22%2F%3E%3Cpath%20fill%3D%22%23fff%22%20fill-opacity%3D%22.8%22%20d%3D%22M50%204h30v48H50z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3Cg%20transform%3D%22translate(25%2044)%22%3E%3Cmask%20id%3D%22faceRound01-a%22%20style%3D%22mask-type%3Aluminance%22%20maskUnits%3D%22userSpaceOnUse%22%20x%3D%220%22%20y%3D%220%22%20width%3D%22130%22%20height%3D%22120%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M66%200c58.35%200%2064%2040.69%2064%2078%200%2033.31-25.47%2042-64%2042-37.46%200-66-8.69-66-42C0%2040.69%207.65%200%2066%200Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fmask%3E%3Cg%20mask%3D%22url(%23faceRound01-a)%22%3E%3Cpath%20d%3D%22M-4-2h138v124H-4V-2Z%22%20fill%3D%22%2300acc1%22%2F%3E%3Cg%20transform%3D%22translate(-1%20-1)%22%3E%3Cg%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20fill%3D%22%23000%22%3E%3Cpath%20d%3D%22M-9.12%20122.1c4.36-30.7%2013.06-4.57%2033.99-9.98%209.24-2.39%201.77-12.82%208.67-17.35%205.82-3.82%2013.76-.74%2020.43-3.21%209.63-3.57%209.5-10.82%2018.48-11.9%208.48-1.03%2017.37%202.34%2025.93%201.08%2016.15-2.4%209.53-34.03%2021.64-39.61%2012.1-5.6%2032.05%204.06%2034.66%2019.87%202.54%2015.42-14.46%2072.78-14.46%2072.78H-9.12%22%20fill-opacity%3D%22.2%22%2F%3E%3Cpath%20d%3D%22M35.93%20122c37.67%200%2041.6-14.75%2060.14-21.5%2018.53-6.76%2034.78%2010.71%2041-6.27%206.24-16.98%206.2%2035.95%206.2%2035.95H35.94V122Z%22%20fill-opacity%3D%22.1%22%2F%3E%3Cpath%20d%3D%22M-2%204.87C9.73%203.75%205.96%2016.8%2010.6%2016.8c1.85%200%204.03-8.46%207.38-8.46%202.46%200%202%205.5%207.32%204.91%205-.54%204.08-4%206.6-4%205.45%200%203.39%2020.2%207.74%2020.2%204.36%200%205.73-14.8%207.65-20.64%202.43-7.4%2016.97-11.56%206.6-14.5H-2.29%22%20fill-opacity%3D%22.4%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fg%3E%3Cg%20transform%3D%22translate(52%20124)%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M18%2010.22C18%2021.78%2024.47%2028%2038%2028c13.52%200%2020-6.34%2020-17.78C58%209.5%2057.17%208%2055%208H21c-2.05%200-3%201.38-3%202.22Z%22%20fill%3D%22%23000%22%20fill-opacity%3D%22.8%22%2F%3E%3Cmask%20id%3D%22mouthSmile02-a%22%20style%3D%22mask-type%3Aluminance%22%20maskUnits%3D%22userSpaceOnUse%22%20x%3D%2218%22%20y%3D%228%22%20width%3D%2240%22%20height%3D%2220%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M18%2010.22C18%2021.78%2024.47%2028%2038%2028c13.52%200%2020-6.34%2020-17.78C58%209.5%2057.17%208%2055%208H21c-2.05%200-3%201.38-3%202.22Z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fmask%3E%3Cg%20mask%3D%22url(%23mouthSmile02-a)%22%3E%3Crect%20x%3D%2230%22%20y%3D%222%22%20width%3D%2216%22%20height%3D%2214%22%20rx%3D%222%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3Cg%20transform%3D%22translate(38%2076)%22%3E%3Cg%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M53%200c34.75%200%2049%2017.47%2049%2031%200%2013.53-19.59%2017-49%2017-29.05%200-51-3.47-51-17S17.11%200%2053%200Z%22%20fill%3D%22%23000%22%20fill-opacity%3D%22.8%22%2F%3E%3Cpath%20d%3D%22M28.82%2034.65c-6.53-1.35-11.24-6.34-10.52-11.14.72-4.79%206.6-7.58%2013.12-6.23%206.53%201.36%2011.24%206.35%2010.52%2011.15-.72%204.8-6.6%207.59-13.12%206.23ZM75.42%2034.65c-6.52%201.36-12.4-1.43-13.12-6.23-.72-4.8%204-9.8%2010.52-11.15%206.52-1.35%2012.4%201.44%2013.12%206.24.72%204.81-4%209.8-10.52%2011.15Z%22%20fill%3D%22%2325A6F5%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E",onboarding:"你好,我是小助手",isDefault:!0}}),getters:{},actions:{add(e){e.id!==this.defaultAgent.id&&this.agents.push(e)},remove(e){this.defaultAgent.id!==e&&(this.agents=this.agents.filter((t=>t.id!==e)))},update(e){if(this.defaultAgent.id===e.id)return void(this.defaultAgent=e);const t=this.agents.findIndex((t=>t.id===e.id));-1!==t&&(this.agents[t]=e)},find(e){return this.defaultAgent.id===e?this.defaultAgent:this.agents.find((t=>t.id===e))}}});const Ce={getItem:e=>window.ipcRenderer.sendSync("GetConfig","note.json",e)||null,setItem:(e,t)=>{window.ipcRenderer.send("SaveConfig","note.json",e,t)}},Ee=de("note",{state:()=>({list:[]}),getters:{data(){return this.list}},actions:{add(e){this.list.push(e)},remove(e){this.list=this.list.filter((t=>t.id!==e))},update(e){const t=this.list.findIndex((t=>t.id===e.id));-1!==t&&(this.list[t]=e)},find(e){return this.list.find((t=>t.id===e))}},persist:{
|
3 |
+
// 在这里进行自定义配置
|
4 |
+
storage:window.ipcRenderer?Ce:localStorage}}),we=i(m({__name:"App",setup(e){const t=s(),a=p((()=>t.displayMode)),{getComponentsLocale:n,locale:i}=De();return(e,t)=>{const s=v("router-view"),l=z;return f(),h(l,{"global-config":D(n)},{default:g((()=>[(f(),h(s,{key:D(i),class:A([a.value])},null,8,["class"]))])),_:1},8,["global-config"])}}}),[["__scopeId","data-v-a54c09a9"]]),be=i(m({__name:"Breadcrumb",setup(e){const{locale:t}=De(),a=ie(),n=p((()=>{const e=a.path.split("/");e.shift();return e.reduce(((e,n,s)=>{var i;const l=null==(i=a.matched[s])?void 0:i.meta;if((null==l?void 0:l.hiddenBreadcrumb)||Object.values(a.params).includes(n))return e;let r=n;return(null==l?void 0:l.title)&&(r="string"==typeof l.title?l.title:l.title[t.value]),e.push({path:n,to:e[s-1]?`/${e[s-1].path}/${n}`:`/${n}`,title:r}),e}),[])}));return(e,t)=>{const a=U,s=V;return f(),h(s,{"max-item-width":"150",class:"tdesign-breadcrumb"},{default:g((()=>[(f(!0),y(b,null,C(n.value,(e=>(f(),h(a,{key:e.to,to:e.to},{default:g((()=>[E(w(e.title),1)])),_:2},1032,["to"])))),128))])),_:1})}}}),[["__scopeId","data-v-7ec7ffe3"]]),Fe=i(m({__name:"Content",setup:e=>(e,t)=>{const a=v("router-view");return f(),h(a,null,{default:g((({Component:e})=>[(f(),h(F(e)))])),_:1})}}),[["__scopeId","data-v-d7ed7a08"]]),ke=i(m({__name:"Footer",setup:e=>(e,t)=>(f(),y("div",{class:A([D(l)+"-footer","flex justify-center items-center"])},"Copyright © 2021-"+w((new Date).getFullYear())+" openseedsoft. All Rights Reserved",3))}),[["__scopeId","data-v-f64c9180"]]),xe=m({__name:"SettingMenu",props:{theme:{type:String,default:"light"},menu:{type:Array,default:()=>[]}},setup(e){const t=e;le(),s(),ye();const{locale:a}=De(),n=p((()=>nt())),i=p((()=>t.theme));return(t,s)=>{const l=T,r=N;return f(),h(r,{theme:i.value,value:n.value,class:"shadow-md"},{default:g((()=>[(f(!0),y(b,null,C(e.menu,(e=>(f(),h(l,{key:e.path,value:`/setting/${e.path}`,to:e.path},{default:g((()=>{return[E(w((t=e.meta.title,"string"==typeof t?t:t[a.value])),1)];var t})),_:2},1032,["value","to"])))),128))])),_:1},8,["theme","value"])}}}),je=m({__name:"LayoutContent",setup(e){const t=s(),a=r(),n=ie();let i=et;const o=p((()=>{var e;if(0==n.path.startsWith("/setting"))return null;return(null==(e=i.find((e=>"/setting"===e.path)))?void 0:e.children).filter((e=>{var t,n;return!(null==(t=e.meta)?void 0:t.isPro)||(null==(n=e.meta)?void 0:n.isPro)&&a.isPro})).filter((e=>(e.path.includes("api"),!0)))}));return(e,a)=>{const n=X,s=Q,i=W;return f(),h(i,{class:A([`${D(l)}-layout`,"flex flex-col h-full"])},{default:g((()=>[k(n,{class:A([`${D(l)}-content-layout`,"flex-1"])},{default:g((()=>[D(t).showBreadcrumb?(f(),h(be,{key:0})):x("",!0),o.value?(f(),h(xe,{key:1,theme:D(t).displayMode,menu:o.value,class:"mb-4 w-full overflow-x-auto"},null,8,["theme","menu"])):x("",!0),k(Fe)])),_:1},8,["class"]),D(t).showFooter?(f(),h(s,{key:0,class:A(`${D(l)}-footer-layout`)},{default:g((()=>[k(ke)])),_:1},8,["class"])):x("",!0)])),_:1},8,["class"])}}}),_e=m({__name:"MenuContent",props:{navData:{type:Array,default:()=>[]}},setup(e){const t=e,a=p((()=>nt())),{locale:n}=De(),s=p((()=>{const{navData:e}=t;return r(e)})),i=e=>{if("string"==typeof e.icon)return React.createElement("t-icon",{name:e.icon});return e.icon},l=e=>"string"==typeof e?e:e[n.value],r=(e,t)=>e&&0!==e.length?(e.sort(((e,t)=>{var a,n;return((null==(a=e.meta)?void 0:a.orderNo)||0)-((null==(n=t.meta)?void 0:n.orderNo)||0)})),e.map((e=>{var a,n;const s=t&&!e.path.includes(t)?`${t}/${e.path}`:e.path;return{path:s,title:null==(a=e.meta)?void 0:a.title,icon:null==(n=e.meta)?void 0:n.icon,children:r(e.children,s),meta:e.meta,redirect:e.redirect}})).filter((e=>e.meta&&!0!==e.meta.hidden))):[],o=e=>{const{frameSrc:t,frameBlank:a}=e.meta;return t&&a?t.match(/(http|https):\/\/([\w.]+\/?)\S*/):null},d=e=>{var t;return a.value.split("/").length>e.path.split("/").length&&a.value.startsWith(e.path)||a.value===e.path?a.value:(null==(t=e.meta)?void 0:t.single)?e.redirect:e.path};return(e,t)=>{const a=T,n=v("menu-content",!0),r=G;return f(),y("div",null,[(f(!0),y(b,null,C(s.value,(e=>{var t;return f(),y(b,{key:e.path},[e.children&&e.children.length&&!(null==(t=e.meta)?void 0:t.single)?(f(),h(r,{key:1,name:e.path,value:e.path,title:l(e.title)},{icon:g((()=>[(f(),h(F(i(e)),{class:"t-icon"}))])),default:g((()=>[e.children?(f(),h(n,{key:0,"nav-data":e.children},null,8,["nav-data"])):x("",!0)])),_:2},1032,["name","value","title"])):(f(),y(b,{key:0},[o(e)?(f(),h(a,{key:0,name:e.path,value:d(e),onClick:t=>{return a=o(e)[0],void window.open(a);var a}},{icon:g((()=>[(f(),h(F(i(e)),{class:"t-icon"}))])),default:g((()=>[E(" "+w(l(e.title)),1)])),_:2},1032,["name","value","onClick"])):(f(),h(a,{key:1,name:e.path,value:d(e),to:e.path},{icon:g((()=>[(f(),h(F(i(e)),{class:"t-icon"}))])),default:g((()=>[E(" "+w(l(e.title)),1)])),_:2},1032,["name","value","to"]))],64))],64)})),128))])}}}),Se={class:"header-operate-left"},Ie={key:1,class:"text-center font-bold w-full pr-16 overflow-hidden text-ellipsis whitespace-nowrap"},Me=i(m({__name:"Header",props:{theme:{type:String,default:"light"},menu:{type:Array,default:()=>[]},isCompact:{type:Boolean,default:!1},maxLevel:{type:Number,default:3}},setup(e){const t=e;le();const{locale:a}=De(),n=ie(),i=s(),r=o(),d=p((()=>nt())),u=p((()=>[`${l}-header-layout`])),c=p((()=>t.theme)),m=()=>{i.updateConfig({isSidebarCompact:!i.isSidebarCompact})};function v(e,t,a=""){for(const n of e){const e=a+n.path;if(e===t)return n;if(n.children){const a=v(n.children,t,e+"/");if(a)return a}}return null}const C=p((()=>{var e,t;if(n.path.startsWith("/setting")){return(null==(e=v(et,"/setting"))?void 0:e.meta).title[a.value]}if("/conversation/chat"===n.path){return r.find(n.query.id).name}const s=null==(t=v(et,n.path))?void 0:t.meta;return s?s.title[a.value]:n.path}));return(t,a)=>{const n=H,s=N;return f(),y("div",{class:A([u.value,"h-full"])},[k(s,{theme:c.value,"expand-type":"popup",value:d.value},{logo:g((()=>[j("div",Se,[k(n,{theme:"default",shape:"square",variant:"text",onClick:m},{default:g((()=>[k(D(ue),{name:"view-list"})])),_:1})])])),default:g((()=>[!0===D(i).showNav?(f(),h(_e,{key:0,class:"header-menu","nav-data":e.menu},null,8,["nav-data"])):(f(),y("div",Ie,w(C.value),1))])),operations:g((()=>a[0]||(a[0]=[j("div",{class:"operations-container"},null,-1)]))),_:1},8,["theme","value"])],2)}}}),[["__scopeId","data-v-066d80f0"]]),Le=m({__name:"LayoutHeader",setup(e){const t=s();let a=et;return(e,n)=>(f(),h(Me,{theme:D(t).displayMode,menu:D(a),"is-compact":D(t).isSidebarCompact},null,8,["theme","menu","is-compact"]))}}),Re=""+new URL("assets-t-logo-CxwPZnhN.png",import.meta.url).href,Oe={name:"seedchat",private:!0,description:"seedchat",author:{name:"zhepama",email:"[email protected]"},version:"1.0.6",type:"module",scripts:{debug:'concurrently "npm run server:dev" "npm run render:debug"',dev:'concurrently "npm run server:dev" "npm run render:dev"',build:"npm run clean && npm run server:build && npm run render:build && npm run electron:build ","build:local":"npm run build && npm run build:post","build:tencent":"node scripts/tencent.js && cross-env PWA=true vite build","electron:preview":"npm run server:build && vite --mode production","electron:build":"cross-env DEBUG=electron-builder* electron-builder --publish never --dir","render:dev":"vite --mode development --host","render:debug":"cross-env VSCODE_DEBUG=true vite --mode development","render:build":" vite build ","render:preview":"cross-env PWA=true vite build && vite preview","server:pages":"cross-env PWA=true npm run render:build && shx cp -r ./dist/* ./server/public/ && shx rm -rf ./dist && nitro build ","server:build":"nitro build && shx mkdir -p ./dist-server && shx cp -r ./.output/* ./dist-server/","server:cloudflare":" npm run server:cloudflare:script && npm run server:pages ","server:cloudflare:script":"node scripts/cloudflare.js ","server:cloudflare:local":"cross-env NITRO_PRESET=cloudflare_pages nitro build && wrangler pages dev dist/","server:dev":"cross-env CONFIG_PATH=.\\ nitro dev --host","server:prepare":"npm run proto:generate && nitro prepare","server:preview":"node dist-server/server/index.mjs",test:"vitest","build:post":"shx mkdir -p D:\\Applications\\seedchat && shx cp -r ./release/win-unpacked/* D:\\Applications\\seedchat",clean:"shx rm -rf ./dist/* && shx rm -rf ./dist-electron/* && shx rm -rf ./dist-server/* && shx rm -rf ./dist-docs/*","docs:dev":"vuepress dev docs","docs:build":"vuepress build docs","proto:generate":"pbjs -t static-module --es6 -w es6 -o server/proto/messages.js server/proto/messages.proto && pbts -o server/proto/messages.d.ts server/proto/messages.js"},dependencies:{"@agoose77/markdown-it-mermaid":"^1.1.0","@dicebear/collection":"^8.0.1","@dicebear/core":"^8.0.1","@grpc/grpc-js":"^1.12.6","@mozilla/readability":"^0.5.0","@traptitech/markdown-it-katex":"^3.6.0","@types/form-data":"^2.5.2","@types/ws":"^8.5.14","@vueuse/core":"^12.7.0","@wdns/vue-code-block":"^2.3.5","electron-context-menu":"^4.0.5","electron-findbar":"^0.6.4","eventsource-parser":"^3.0.0","form-data":"^4.0.2","highlight.js":"^11.11.1",jose:"^6.0.8",mammoth:"^1.9.0","markdown-it":"^14.1.0","markdown-it-highlightjs":"^4.2.0","markdown-it-link-attributes":"^4.0.1","pdfjs-dist":"^4.10.38",pinia:"^2.3.1","pinia-plugin-persistedstate":"^4.2.0",protobufjs:"^7.4.0","tdesign-icons-vue-next":"^0.3.4","tdesign-vue-next":"latest","tvision-color":"^1.6.0",undici:"^7.4.0",uuid:"^11.1.0",vue:"^3.5.13","vue-i18n":"^11.1.1","vue-router":"^4.5.0",vuedraggable:"^4.1.0",ws:"^8.18.1",xlsx:"^0.18.5"},devDependencies:{"@types/highlight.js":"^10.1.0","@types/markdown-it":"^14.1.2","@types/markdown-it-link-attributes":"^3.0.5","@types/uuid":"^10.0.0","@vitejs/plugin-vue":"^5.2.1","@vuepress/bundler-vite":"^2.0.0-rc.14","@vuepress/theme-default":"^2.0.0-rc.37",autoprefixer:"^10.4.20",concurrently:"^9.1.2","cross-env":"^7.0.3",electron:"^34.0.1","electron-builder":"^25.1.8",less:"^4.2.2",nitropack:"latest",postcss:"^8.5.1","postcss-less":"^6.0.0","protobufjs-cli":"^1.1.3","sass-embedded":"^1.85.1",shx:"^0.3.4","swagger-ui-dist":"^5.20.0",tailwindcss:"^3.4.4",terser:"^5.39.0",typescript:"^5.8.2","unplugin-auto-import":"^19.1.1","unplugin-vue-components":"^28.4.1",vite:"^6.2.0","vite-plugin-electron":"^0.29.0","vite-plugin-electron-renderer":"^0.14.6","vite-plugin-javascript-obfuscator":"^3.1.0","vite-svg-loader":"^5.1.0",vitest:"^3.0.7","vue-tsc":"^2.2.6",vuepress:"^2.0.0-rc.14",wrangler:"^3.106.0"},main:"dist-electron/main.js",overrides:{canvas:"npm:dry-uninstall"}},Pe={class:"flex justify-center w-full p-3"},ze=["src"],Ve={class:"flex align-middle justify-center items-center"},Ue={class:"p-2"},Ne={class:"flex w-full flex-col mb-2 gap-2 items-center align-middle justify-between"},Te={class:"text-center"},We={class:"version-container"},Xe=i(m({__name:"SideNav",props:{theme:{type:String,default:"light"}},setup(e){r();const t=e,a=p((()=>s().isSidebarCompact)),n=ie(),i=p((()=>nt()+`?id=${n.query.id}`)),u=p((()=>a.value?"":"Seed Chat PRO")),c=p((()=>[`${l}-sidebar-layout`,{hidden:a.value}])),m=p((()=>[`${l}-side-nav-logo-${a.value?"t":"tdesign"}-logo`])),v=le(),C=s(),b=()=>{const e=window.innerWidth<=991;C.updateConfig({isSidebarCompact:e,isCompact:e})};_((()=>{b(),window.onresize=()=>{b()}}));const F=()=>{v.push("/")},L=S("conversation"),R=o(),O=Ee(),P=S([]),z=S([]);I((()=>R.list.length),(()=>{P.value=R.data.map((e=>e))}),{immediate:!0}),I((()=>O.list.length),(()=>{z.value=O.data.map((e=>e))}),{immediate:!0});const V=()=>{R.list=[...P.value]},U=()=>{O.list=[...z.value]};I((()=>n.path),(e=>{e.startsWith("/note")?L.value="favorite":L.value="conversation"}),{immediate:!0});const N=e=>{v.push(e)};return(e,n)=>{const s=B,l=Z,r=K,o=H,p=q,C=Y,b=T,_=J;return f(),y("div",{class:A([c.value,"flex flex-col"])},[j("div",Pe,[j("img",{src:a.value?Re:"light"==t.theme?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALMAAAAcCAYAAAAqXo7IAAAACXBIWXMAAAsTAAALEwEAmpwYAAAJ6klEQVR4nO1cXYwbVxX+zszY3h/vrtNtEiUEYtTwpz6si0pSUFBMC0Xw0N3CS/MA3YAopUiw5SVqX+q8VFUkYIsqARISzkOL+uaIh0YRECdKf9JIiSO1UqUI4UUNpSTN2rvZ9c947uFhrndnx/eOx2MnefEnjXZ8f849d+a755577p2lS5eWIQTQaAgAgBCAEAzLIhgGwTAAwyAIAarVnB/ZtngkmbSOx+NUajQEiAixGMG2GfW6A9M0kEgYIGIIwThw4B4MMcSdgBGUSQQQERoN8fVq1T69tub8qdnkw8vL9lvVauslIbCb6E6pOsQQwdCSmQhotfjTKyutV6rV1lnb5m+65AYAjNZq4ujqautSrSaeYoY5JPUQdxsdZCYCmDFeq4nnVlZalxsN8XMikJ+sstzO9XXnj8vL9rlGQ3wLIAxJPcTdwgaZ2yRsNsXhWk2cr9fFiwCmu5GTCLBt/tqtW87pRkO85jj8ZY8FH2KIOwarTbxWC1+p152jts3f75WM7bKOw4fX1505IXB8bMx4mYiWw8ugOQBzANKK7CKAEjMXPOWzALLhtdyCPDOXpZxcRBllZs5H1KUMoMDMlV4aJKI03GeUgfo5laRei546OY24jWegaGNeUX6jv1101LWnbTNEvVCgixeXP7W62nq+XhdPMbvk7hfMgGnS1ZER4zeHDk3/IVABogyAPICZLmKXmDntqZcD8EJEFb/BzEUphyPKOMvM2T51OQkgx8yloEJysOQAHAojlJk33qKuf94yirbOKLI2+hug5zyAPwcUedY70Hx1o76HDRirq63fr6+LZwA9kYkA0yRY1uZlGHrWEwFC8OfW1pyXgxqXVqCI7kQGgL0hyoRFaYCy+sEsgKIc0EoQ0SJccoUisqyjlXebkeuSP38b275iAUgFWeNEwkC9LlBdacFuurFowwDGxkxMTFhwHIbjqAcVEW51USAHYCqK5v2g1+ldg0HIANz+F4ko7deLiPIAnowgM9W/Wh0oBWVKq9zN4MzIfpYHpJMXFQuAo8ohAmIxA+ffrODMmWVcv9H0kJaQTJr40hfHMPvYDkxNmrBbkWaJjCZ9Ca7rUYH7YubQ+SBSmron4Pqkvbapal+HFMJZ92Oe+zRcv1r1wqcALMBj2aTrEkTkJQAFbB1UWYTvX6+odMnPhZQzB2BRkX5W0V4K6hmp/Y5T2OxvydK1GI8b+MeZZbz62kewLAP79o1idMQAMwACPvywjr/9/SY++aSFnz29B7EYQYieCa1zLzI+K5UjopS/jKZuvu0P94EyM+f6lAG/DNmHItT9XoAkhHS/gnzwY33qV+6jbgeIaAGdg7QKd7D5B+QCFGRW+eNyQKvIrHzHSjKbJuHmTRtvnLqBZNLCT368G/ffn2y3CjII1WoLr/7lv3j7nSouXKji4Ye3oV7vmcxnNcrOw9fhHlyDctjGFQPktoKZK3KBVULny58ioqx8SXMBYo6EiSr0gUwvheUzzCmy8vLyk3kvEWW6LXq7oKJKVJLZsgjlch0ff9zEo49O44EHJrC25rhWGQDA2LbNwne/cy8uX17Fv5ZqYN4WRak81GT+LRGlIlqfPBEVPb9T2HxBeR8RMlAjI/3Vsq9sClBbkbCQhC4A+KUiOyX/zmmqHxsQkQ9FiB6UNOkLUK97Fpm5TERL6By487JeN6RUibqBoCQzAWjIxd7YqIFWiz1EdmHbjETcPWTUbIqO/DBg5ry0VCrf8AW5Kp/vccF2CPqVfzGkjCmNTjpkFWlXAspXNOkZuFOzTv98SH0AbLgrg0JFIT8FNSlPeNY2BXQO3HlNPT8yoTST0J7N6IWcUYi8WZfn4Tr0KrRDV+noLWxBZUBybldbgXUiRAHSEXToBTloolFElJM+b0qRPSU3yQYK7QLQNF2SOo7rQ/thGG6+EIClyO8FzDxPRGWoFz0zAArSn6x40tMRmipFqHM7kNGkl4IqSderMmhlokAaGJWrBISb1ebhWu2BQUlmx2Hs3pXAxISJ9967hevX78H27bGNaAURgZnx7sUVrK052LEjDiPwMGl3MHNOElq1gzQDd4qd86SpQlzdQmrlkOoEhfcqIWUoIafmbETZWQyGACegf06LCLeJletTh9mIg1PrvinJbLcYe/aM4KsPpXDq9A387pV/Y2ZmApbpktgwCNeuNfDOu1Xs2hXHQwem0IoWZ94C6UOXod5OnQ0RcO81pJbVpA8ivKfDAtRT85JnYRMU5SkMQIeyrn9EVOlWWVrlKJs5fsyhx3UAAga81s1wHMb3Ht8OIRhvvV3F1av/A8hdHDIzLMvA3s+M4IkndmLnzvjGlyphIX2mkp+czFwkoitQW4c0BhwjHRAy3Qp4Fku6+HHBd68i86yMsiyEtGjZEGXCouS5X9SU0c1oKahdkgUEkzn0Fj7gktlUZTgOI5Ew8MMf7MLBgyn851rD3QGU7vHkpIUvfH4MY2Nmz0SWmIf7ck7CfVAluJ3OQjPNeQ4HpTUy0wGnr1JwSecPzyl1k1EWZRvyWvBYUpWlbevSLp/RlAPcDYac53ce+sXVkwCyktTt9jPY7F+GmVOadiKjPXjkc5lVFKkiYJBJ4+V3DQe6vW0BqDGrj3y2z118Nj2CffeNbsljdsNzzaaeyMxIBrRdgvtQ2lc3eLc705oye9H99FrRc5/RlOk6hYYI+ofRpY0t4UcZi16A/gRakGz/tvCgkdOkL3aZLQrQW+eFfhRqwxgdNZ5JJCjPrA+xuR+rii1XoyG029dSzkfj4+bRQSgJOeoHJMuLVL8C+txFrMLd0Sv4M+TscUSW6QVFz31aU6YcUF87tUurrMqvQu96tJHXpM9p2sp0kdcBwzTpn8mkdSSZNA+aJp3rL2YMAHBGRoxfJ5PWg2NjxmJ0aRtYApD1WcJMH/LK/SijQCZivZNw+5XXFZB5GfRmbSue+7SmTLkHeV7kdendfHj5/lQHnPZqYs6pHvQCAFht8sZi9GYsZj3SaIif1uvOs0LgvrAH9dsy4nHjjfFx40XTpPO23blr6MMi3AefhpoQZbhfYxQUeSVsPZHWC4q++6KyVHiUEV6XCuT6IGxISvqTWc9XJlnoX3QRWxeSeaj7Vw5oUtkX2X5eU0eX7kcO6gFWUaSVNbqUdcLpwoWbG/8rg6j9fzJw79qa+FWt5vyCGeNBpJZflXwwPm7mxsfN15kZtu1e8Thh//5IZzaGGKJndGx1CMEwTboxOWk9Pz0dPxCPGwWVPy1/ryaT5nPT07H9IyP0uvxie4gh7gqU+3YueRnxOL0/OWk9nkyaj5kmXfCQWiQSRn56OvZgMmm+RITVIYmHuNvQbpoAm1Y2kTD+Go8bp2o15+lmk7+dSBjHR0eNc+6B/Duh5hBDdMf/AeWEF6kp7RGPAAAAAElFTkSuQmCC":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALMAAAAcCAYAAAAqXo7IAAAACXBIWXMAAAsTAAALEwEAmpwYAAAJiklEQVR4nO2cX4wkRR3HP9XdM7N/5vbmWOByiN4Y8F94uMEghwZzIyhGH7hFX+BBWTQiYqKLLwReGF4IIVEXQ6ImJg4PYHhb4gOEqDd34d9BAkOCiQkxzhoQkeN25vb25m93+VA9O70zVT3dvXN3PMw36WxP/X71q19Vfet/9Yo33tjA86Dd9gDwPPA8ieMILEtgWWBZAs9DNJvuD7pd7+Zs1nksnRbVdttDCEEqJeh2Ja2Wi21bZDIWQkg8T3L48CVMMcWFgBUmFAKEELTb3lcbje4LW1vuHzodecfGRvflRqP3qOdxhRAXytUppgiHkcxCQK8nP3nmTO+JRqN3vNuVX1fkBmC22fTu39zsvdFsendLiT0l9RQXGyNkFgKkZL7Z9B44c6b3Zrvt/VQIxDBZfb395865v9/Y6J5ot71vgGBK6ikuFrbJ3Cdhp+Pd0Wx6L7Za3iPA4jhyCgHdrvzK2bPuC+2297Tryi8GevApprhgcPrE6/X4Uqvl3t/tyu/GJWNf13XlHefOuUuex2Nzc9bjQoiNGL4s+U9eI6sAVWAtEFb0nyQoAzX/vZTQRs23k8SXGiov9Zhp5lFlVEBfTlXf9mogrGSwVWZQBsNpLGvCawzyGwZTemFpjosXCeL11zc+sbnZe7DV8u6WUpF7t5ASbFu8MzNj/erIkcXfjVEvoDJ5aIzeOjsrsAQ8lNDFr6EaCIBMaOM4AwIn9eVZP251jF7R1zsS0W6wFk35M9V0ETimCQ/m14Rl4I8h8vvY2dCCSFoP27A2N3u/PXfOuxfMRBYCbFvgOIPHssysFwI8T35ma8t9fEz6eRSpxhEZ4GAEnaioTtDWbnAUlf9CiM4qilxRicwYe+cTpTHy5fOY9lsOkAvrjTMZi1bLo3GmR7ej9qItC+bmbPbscXBdievqG5UQnB3jQAnYm8TzXaL+MbEBKv8VVMMetlkG7kxgM7cLf0yojpEvM77DOYTKZ23X3oyi7gCuTiIEpFIWL75U59ixDT481QmQVpDN2nzh83McvfVy9i7YdHuJRomCIXwdVZF1VMUsMVoQOUPcJwkvLFOauvRNyBGtd3848J5HDdO6Ct8LrLCzZysRTuR1RufdRaLnLy7qY+SliHaW0E81jmvSy6Efkfp1nGOQ36pjSjGdtvjbsQ2eevp9HMfi6qtnmZ2xkBIQ8O67Lf7y19N89FGPn9xzJamUwPNiE9o0vSiws/BKjJK3gB5lBvPhpKgxgQWJxkYO87RqJaCfJ3wO/rDGdhzUdhFXhxVGG2kD1diGG+QKejIXNWEl9GQuo6ljLZltW3D6dJfnnj9FNuvwox9ewTXXZJVQSoQlaDR6PPWn//LKqw1Onmxw0037aLVik/m4wdllRjNcj2izFiP9XAzdSaCOqrQqo5W/15dVUL2XCXcRbVchKQox9XPoG1YZ/TTpoJ9GNWY6QdR1gVoyO46gVmvxwQcdbrllkWuv3cPWlqt6ZQAk+/Y5fPtbl/Lmm5v8a72JlPuSOFVGT+ZfYy6kKDYrgd85BhVUZicRCuhRYHQbqcCA/MUEfvVRR/VYP9fI+vaXDHEfZjJEPkL83YOqIXwF/bpnFVV+64w23GU/3jjk4viiJbMA2v5ib27WoteTASIrdLuSTFpdMup0vBF5RJRRxNDNDR9CEWiZeIutI5hX/pWINvYafDKhqAl7K0S/bggvoIhu8r8c0Z8+8jH1w1DXhOXQkzK4blljtOEuG+INoxBBZxvGuxlxyJmQyH0sozKvQ3/rKr+rFAaoT8jO+UprXJxaTHv5BD7EQQnzblQJ/VoHP87SpJ0xLgBtW5HUddUcehiWpeSeB45GHhPLqIrSLXoOoVp3kZ2VnU+QTjVBnPOBgiG8OiZejgvbIMOQRz9Vgmij2jI7T3R3DS2ZXVdyxYEMe/bYvP32WT788BIuuyy1vVshhEBKyWuvn2Fry+Xyy9NYoZdJI6GEIrTuBOkQaohdCoTptrjGbanVIvoStr1Xj2jDhBzmOfc420UmQ4AnMZfTKtEOsUq79OEoyRqncfqmJXO3J7nyyhm+fEOO5184xW+e+DeHDu3BsRWJLUvw3nttXn2twYEDaW44vJdesn3mYZRRJNIdpx5l/IZ7jXiFXAzxoxLDThysoB+a1xn0zGG7PGsT8KGGOX/1CPHzJDvMGcYS8dcBdZPAOM1wXcl3brsMz5O8/EqDd975Hwi1OJRS4jgWBz81w+2372f//vT2lyoxsMTgYkwQFVTr0/UOeY3+xwGFCDo5FJFN+8drQ+86Mh9FVf4K0UhXjKATFdXA+6pBxzSi5dBPSVYIJ3OcI3wcwNYJXFeSyVh8/3sHuPHGHP95r61OAP3p8cKCw+c+O8fcnJ2EyKB6maOoyzZV/8mhKsA0zFX8v3mDPI+5Z84x2HIrR/CtGJJGHlURVT9M19P2fenrFwx6oA4YSoHfZcyLqzt938qB9AsM8td/nzTq/t8iqt6G0SC8kS0xOjWc6PG2AzSl1F/57N+7+HR+hquvmt0hk1Jtz3U6ZiJLSTYk7SqqUPrPOASPO/MGnYOMv71WCbwXDDpRhtDqGHkUX/pYZicJ6ihimG6ghdkePhaeNEqG8FXCR4s1zL3zSnJ3BrBmZ617MxlRltK8xaY+VvV2PO22Zzy+9u28Pz9v3z8JJxm0+kkjd5FtNFAnemsaWdmXNWLarATe8wadWkj8sKG9aJA3ME89+igbwpcM4YUx9kZg2bb4Zzbr3JXN2jfatjixmz1jP647M2P9Mpt1rpubs1aTW9vGOoMj4D4Ku7BX20VcHQoJ4z3LYLpgQtm3H6e3rQfe8wadWgx7QZRDwusGWR9V9BecDqIndC6SRwE4ffKmUuKlVMq5ud32ftxqufd5HldFvajft5FOW8/Nz1uP2LZ4sdsdPTUcwiqqAPLoCVFD9VhrGlmVnTfS4qAy9F7RakVHjei+1BmsD+ox7BcZfGVSxFzRFXaWVxl9/moh6ZnykieczFFQQt/A6pqwmsGXmsm4OHny9Pb/yhCi/38yuHRry/tFs+n+TErmw0jtf1Xyj/l5uzQ/bz8jpaTbVU86Lbj++kR3NqaYIjZGjjo8T2Lb4tTCgvPg4mL6cDptrenm0/7vzWzWfmBxMXX9zIx4xv9ie4opLgq053aKvJJ0Wvx9YcG5LZu1b7VtcTJAai+TscqLi6nrsln7USHYnJJ4iosN46EJDHrZTMb6czptPd9suvd0OvKbmYz12OysdUJdyL8Qbk4xxXj8H0eEKo5UwxgtAAAAAElFTkSuQmCC",class:A(["cursor-pointer",m.value]),onClick:F},null,10,ze)]),j("div",Ve,[k(l,{modelValue:L.value,"onUpdate:modelValue":n[0]||(n[0]=e=>L.value=e),variant:"primary-filled"},{default:g((()=>[k(s,{value:"conversation"},{default:g((()=>[E(w(e.$t("layout.sideNav.tabConversation")),1)])),_:1}),k(s,{value:"favorite"},{default:g((()=>[E(w(e.$t("layout.sideNav.tabFavorite")),1)])),_:1})])),_:1},8,["modelValue"])]),"conversation"===L.value?(f(),h(_,{key:0,class:"flex-1 bg-transparent",value:i.value,collapsed:a.value},{default:g((()=>[k(D(Ae),{onEnd:V,modelValue:P.value,"onUpdate:modelValue":n[2]||(n[2]=e=>P.value=e),"item-key":"id"},{item:g((({element:t})=>[(f(),h(b,{name:t.id,value:`/conversation/chat?id=${t.id}`,"data-index":t.id,key:t.id,to:`/conversation/chat?id=${t.id}`,class:"gap-2 relative menu-item"},{icon:g((()=>[k(r,{size:"24px",image:t.avatar},null,8,["image"])])),content:g((()=>[E(w(t.name)+" ",1),k(C,{theme:"danger",content:e.$t("layout.sideNav.confirmDelete"),placement:"right",onConfirm:e=>{return a=t,R.remove(a.id),R.data.length>0?v.push(`/conversation/chat?id=${R.data[0].id}`):v.push("/"),void $.success(d("layout.sideNav.deleteSuccessMsg"));var a},class:"absolute right-0 top-1.5"},{default:g((()=>[k(p,{content:e.$t("layout.sideNav.deleteAction"),placement:"right"},{default:g((()=>[k(o,{size:"small",shape:"circle",variant:"text",onClick:n[1]||(n[1]=M((()=>{}),["stop"]))},{default:g((()=>[k(D(ce),{slot:"icon",style:{width:"16px",height:"16px"}})])),_:1})])),_:1},8,["content"])])),_:2},1032,["content","onConfirm"])])),_:2},1032,["name","value","data-index","to"]))])),_:1},8,["modelValue"])])),_:1},8,["value","collapsed"])):x("",!0),"favorite"===L.value?(f(),h(_,{key:1,class:"flex-1 bg-transparent",value:i.value,collapsed:a.value},{default:g((()=>[k(D(Ae),{onEnd:U,modelValue:z.value,"onUpdate:modelValue":n[4]||(n[4]=e=>z.value=e),"item-key":"id"},{item:g((({element:t})=>[(f(),h(b,{name:t.id,value:`/note/content?id=${t.id}`,"data-index":t.id,key:t.id,to:`/note/content?id=${t.id}`,class:"gap-2 relative menu-item"},{default:g((()=>[E(w(t.title)+" ",1),k(C,{theme:"danger",content:e.$t("layout.sideNav.confirmDelete"),placement:"right",onConfirm:e=>{return a=t,O.remove(a.id),O.data.length>0?v.push(`/note/content?id=${O.data[0].id}`):v.push("/"),void $.success(d("layout.sideNav.deleteSuccessMsg"));var a},class:"absolute right-0 top-1.5"},{default:g((()=>[k(p,{content:e.$t("layout.sideNav.deleteAction"),placement:"right"},{default:g((()=>[k(o,{size:"small",shape:"circle",variant:"text",onClick:n[3]||(n[3]=M((()=>{}),["stop"]))},{default:g((()=>[k(D(ce),{slot:"icon",style:{width:"16px",height:"16px"}})])),_:1})])),_:1},8,["content"])])),_:2},1032,["content","onConfirm"])])),_:2},1032,["name","value","data-index","to"]))])),_:1},8,["modelValue"])])),_:1},8,["value","collapsed"])):x("",!0),j("div",Ue,[j("div",Ne,[k(o,{class:"w-full",theme:"primary",shape:"square",variant:"base",onClick:n[5]||(n[5]=e=>N("/conversation/index"))},{icon:g((()=>[k(D(pe))])),default:g((()=>[E(" "+w(e.$t("layout.header.start")),1)])),_:1}),k(o,{class:"w-full",theme:"primary",shape:"square",variant:"base",onClick:n[6]||(n[6]=e=>N("/setting"))},{icon:g((()=>[k(D(me))])),default:g((()=>[E(" "+w(e.$t("layout.header.setting")),1)])),_:1})]),j("div",Te,[j("span",We,w(u.value)+" "+w(D(Oe).version),1)])])],2)}}}),[["__scopeId","data-v-e0a68394"]]),Qe=m({__name:"LayoutSideNav",setup(e){const t=s();return(e,a)=>(f(),h(Xe,{theme:D(t).displayMode},null,8,["theme"]))}}),Ge={class:"flex gap-5 items-center align-middle justify-center"},He=i(m({__name:"ReloadPrompt",setup(e){const t=S(null),a=S(null),n=S(!1),s=()=>{n.value&&localStorage.setItem("pwaInstallDismissed","true"),n.value=!1},i=async()=>{if(a.value){a.value.prompt();const{outcome:e}=await a.value.userChoice;a.value=null,n.value=!1,localStorage.setItem("pwaInstallLastPrompt",(new Date).toISOString())}},l=e=>{e.preventDefault(),a.value=e;const t="true"===localStorage.getItem("pwaInstallDismissed"),s=localStorage.getItem("pwaInstallLastPrompt"),i=new Date;i.setDate(i.getDate()-30);!t&&(!s||new Date(s)<i)&&(n.value=!0)},r=()=>{n.value=!1,localStorage.removeItem("pwaInstallDismissed"),localStorage.removeItem("pwaInstallLastPrompt")},o=async()=>{if("visible"===document.visibilityState&&t.value)try{await t.value.update()}catch(e){}};return _((async()=>{await(async()=>{if("serviceWorker"in navigator)try{const e=await navigator.serviceWorker.register("/sw.js",{scope:"/"});t.value=e,e.addEventListener("updatefound",(()=>{const t=e.installing;t&&t.addEventListener("statechange",(()=>{"installed"===t.state&&navigator.serviceWorker.controller&&t.postMessage({type:"SKIP_WAITING"})}))})),navigator.serviceWorker.addEventListener("controllerchange",(()=>{window.location.reload()}))}catch(e){}})(),window.matchMedia("(display-mode: standalone)").matches||(window.addEventListener("beforeinstallprompt",l),window.addEventListener("appinstalled",r)),document.addEventListener("visibilitychange",o)})),L((()=>{window.removeEventListener("beforeinstallprompt",l),window.removeEventListener("appinstalled",r),document.removeEventListener("visibilitychange",o)})),(e,t)=>{const a=H,l=ee;return n.value?(f(),h(l,{key:0,class:"pwa-toast",role:"alert"},{default:g((()=>[t[2]||(t[2]=j("div",{class:"message"}," 将此应用添加到主屏幕,随时随地快速访问 ",-1)),j("div",Ge,[n.value?(f(),h(a,{key:0,onClick:i},{default:g((()=>t[0]||(t[0]=[E(" 安装 ")]))),_:1})):x("",!0),k(a,{onClick:s},{default:g((()=>t[1]||(t[1]=[E(" 稍后再说 ")]))),_:1})])])),_:1})):x("",!0)}}}),[["__scopeId","data-v-b1672b5d"]]),Be=m({__name:"index",setup(e){const t=ie(),a=s();return I((()=>t.path),(()=>{var e;null==(e=document.querySelector(`.${l}-layout`))||e.scrollTo({top:0,behavior:"smooth"})})),(e,t)=>{const n=te,s=ae,i=X,l=W;return f(),h(l,null,{default:g((()=>[k(n,null,{default:g((()=>[k(Qe)])),_:1}),k(l,{class:"h-screen overflow-hidden"},{default:g((()=>[D(a).showLayoutHeader?(f(),h(s,{key:0},{default:g((()=>[k(Le)])),_:1})):x("",!0),k(i,{class:"flex-1 overflow-y-auto main-layout-content"},{default:g((()=>[k(je)])),_:1}),(f(),h(He,{key:1}))])),_:1})])),_:1})}}}),Ze=[{path:"/conversation",component:Be,redirect:"/conversation/index",name:"conversation",meta:{title:{zh_CN:"会话",en_US:"Conversation"},icon:ve,orderNo:0},children:[{path:"index",name:"NewConversation",component:()=>se((()=>import("./index-DUia5xTm.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]),import.meta.url),meta:{title:{zh_CN:"新建会话",en_US:"New Conversation"}}},{path:"chat",name:"chat",component:()=>se((()=>import("./chat-BW5Qhkmv.js")),__vite__mapDeps([38,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,4,25,26,27,28,29,30,39,40,32,31,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,33,34,75,76,77,78,79,80,81,82,83,84,85,86,87,88,35,36,89,90]),import.meta.url),meta:{title:{zh_CN:"会话聊天",en_US:"Chat"},hidden:!0}}]},{path:"/setting",
|
5 |
+
// component: () => import('@/pages/setting/layout.vue'),
|
6 |
+
component:Be,redirect:"/setting/user",name:"setting",meta:{title:{zh_CN:"设置",en_US:"Setting"},icon:he,orderNo:0},children:[{path:"user",name:"User setting",component:()=>se((()=>import("./index-BSlpP4WW.js")),__vite__mapDeps([91,7,8,1,2,3,9,10,11,12,13,5,6,14,15,16,17,18,19,20,21,22,23,24,39,40,32,41,42,43,35,36,33,34,4,92]),import.meta.url),meta:{title:{zh_CN:"常规",en_US:"User"}}},{path:"model",name:"ModelSetting",component:()=>se((()=>import("./index-Dc0PR0S6.js")),__vite__mapDeps([93,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,41,42,43,89,32]),import.meta.url),meta:{title:{zh_CN:"模型",en_US:"Model"}}},{path:"agent",name:"AgentCenter",component:()=>se((()=>import("./index-BJf2iObo.js")),__vite__mapDeps([94,4,1,2,3,7,8,9,10,11,12,13,5,6,14,15,16,17,18,19,20,21,22,23,24,39,40,32,33,34,35,36]),import.meta.url),meta:{title:{zh_CN:"智能体",en_US:"Agent"}}},{path:"api",name:"api setting",component:()=>se((()=>import("./index-BPfFXn2Y.js")),__vite__mapDeps([95,96,14,1,2,3,6,5,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,97,41,42,43]),import.meta.url),meta:{title:{zh_CN:"OpenAPI",en_US:"OpenAPI"},isPro:!0}}]},{path:"/page",component:Be,redirect:"/page/about",name:"page",meta:{title:{zh_CN:"页面",en_US:"Page"},icon:fe,orderNo:0},children:[{path:"about",name:"AboutUs",component:()=>se((()=>import("./about-D4hEieAK.js")),__vite__mapDeps([98,96,14,1,2,3,6,5,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,97]),import.meta.url),meta:{title:{zh_CN:"关于我们",en_US:"About Us"}}},{path:"help",name:"help",component:()=>se((()=>import("./help-Dm0-B9za.js")),__vite__mapDeps([99,96,14,1,2,3,6,5,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,97,41,42,43]),import.meta.url),meta:{title:{zh_CN:"使用帮助",en_US:"Help"}}},{path:"changelog",name:"change log",component:()=>se((()=>import("./changelog-CmzmwycZ.js")),__vite__mapDeps([100,96,14,1,2,3,6,5,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,23,24,97]),import.meta.url),meta:{title:{zh_CN:"更新日志",en_US:"Change Log"}}}]},{path:"/note",component:Be,redirect:"/note/index",name:"note",meta:{title:{zh_CN:"笔记",en_US:"Notes"},icon:ge,orderNo:0},children:[{path:"index",name:"noteList",component:()=>se((()=>import("./index-LPxgpECk.js")),__vite__mapDeps([101,5,6,2,3,7,8,1,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,4,33,34,35,36]),import.meta.url),meta:{title:{zh_CN:"笔记列表",en_US:"Note List"}}},{path:"content",name:"content",component:()=>se((()=>import("./content-CMwtYO4S.js")),__vite__mapDeps([102,44,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,27,74,33,34,75,76,77,78,79,80,81,82,83,84,85,86,87,41,42,43,32,25,26,28,29,30,88,4,35,36,103]),import.meta.url),meta:{title:{zh_CN:"笔记内容",en_US:"Note Content"},hidden:!0}}]}],Je=Object.defineProperty({__proto__:null,default:Ze},Symbol.toStringTag,{value:"Module"}),Ye=Object.assign({"./modules/homepage.ts":Je}),qe=Object.assign({}),Ke=at(Ye),$e=at(qe),et=[...Ke,...$e].filter((e=>{var t;return!(null==(t=e.meta)?void 0:t.hidden)})),tt=[...Ke,...$e,{path:"/",redirect:"/conversation/index"}];function at(e){const t=[];return Object.keys(e).forEach((a=>{const n=e[a].default||{},s=Array.isArray(n)?[...n]:[n];t.push(...s)})),t}const nt=(e=3)=>{const t=st.currentRoute.value;return t.path?t.path.split("/").filter(((t,a)=>a<=e&&a>0)).map((e=>`/${e}`)).join(""):""},st=re({history:oe(),routes:tt,scrollBehavior:()=>({el:"#app",top:0,behavior:"smooth"})}),it=R(we);it.use(ne),it.use(st),it.use(u),it.use(t),c.initialize(),it.mount("#app").$nextTick((()=>{postMessage({payload:"removeLoading"},"*"),window.document.addEventListener("keydown",(e=>{e.ctrlKey&&"f"===e.key&&window.ipcRenderer&&(e.preventDefault(),window.ipcRenderer.send("electron-findbar/open"))}))})),null==(e=window.ipcRenderer)||e.on("main-process-message",((e,t)=>{}));export{Ee as a,De as b,ye as u};
|
.output/public/assets/markdown-DPs5ApTw.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{m as e}from"./markdown-it-link-attributes-UnOqz_aA.js";import{M as n}from"./markdown-it-C8SkdHr7.js";import{m as o}from"./@traptitech-BPk2gen6.js";import{m as s}from"./markdown-it-highlightjs-Ikc7oQsB.js";import{H as t}from"./highlight.js-Ds8M-WS2.js";import{m as i}from"./@agoose77-mGnNv_bd.js";import{f as c}from"./tdesign-vue-next-DsCOKp3d.js";const r={svg:"",buttonStyle:""},d=(e,n)=>(n={...r,...n},(...o)=>{const[s,t]=o,i=s[t];if(i.info&&i.info.includes(":")){const[e,n]=i.info.split(":",2);i.info=e}const c=s[t].content.replaceAll('"',""").replaceAll("'","'"),r=e(...o);return 0===c.length?r:`\n<div class="markdown-it-svg-code-copy">\n ${r}\n <button data-clipboard-text="${c}" class="code-copy-button ${n.buttonClass}" style="${n.buttonStyle}" title="Copy code" onclick="copyCodeToClipboard(this)">\n ${n.svg}\n </button>\n</div>\n`});t.registerLanguage("vue",(e=>({name:"vue",subLanguage:"xml",contains:[e.COMMENT("\x3c!--","--\x3e",{relevance:10}),{begin:/^(\s*)(<script>)/gm,end:/^(\s*)(<\/script>)/gm,subLanguage:"javascript",excludeBegin:!0,excludeEnd:!0},{begin:/^(\s*)(<script lang=["']ts["']>)/gm,end:/^(\s*)(<\/script>)/gm,subLanguage:"typescript",excludeBegin:!0,excludeEnd:!0},{begin:/^(\s*)(<style(\sscoped)?>)/gm,end:/^(\s*)(<\/style>)/gm,subLanguage:"css",excludeBegin:!0,excludeEnd:!0},{begin:/^(\s*)(<style lang=["'](scss|sass)["'](\sscoped)?>)/gm,end:/^(\s*)(<\/style>)/gm,subLanguage:"scss",excludeBegin:!0,excludeEnd:!0},{begin:/^(\s*)(<style lang=["']stylus["'](\sscoped)?>)/gm,end:/^(\s*)(<\/style>)/gm,subLanguage:"stylus",excludeBegin:!0,excludeEnd:!0}]})));const a=new n({linkify:!0,breaks:!0});a.use(i),a.use(o,{blockClass:"katexmath-block rounded-md p-[10px]",errorColor:" #cc0000"}),a.use(e,{attrs:{target:"_blank",rel:"noopener"}}),a.use(s,{hljs:t}),a.use(((e,n)=>{if(e.renderer.rules.code_block=d(e.renderer.rules.code_block,n),e.renderer.rules.fence=d(e.renderer.rules.fence,n),"undefined"!=typeof window&&!window.copyCodeToClipboard){window.copyCodeToClipboard=e=>{const o=e.dataset.clipboardText;navigator.clipboard.writeText(o).then((function(){n.onCopySuccess&&n.onCopySuccess(o,e)})).catch((function(o){n.onCopyError&&n.onCopyError(o,e)}))};const e="\n.markdown-it-svg-code-copy{\n position: relative;\n}\n.markdown-it-svg-code-copy:hover .code-copy-button {\n visibility: visible;\n opacity: 1;\n}\n.markdown-it-svg-code-copy .code-copy-button {\n position: absolute; \n top: 5px; \n right: 5px; \n cursor: pointer; \n outline: none; \n visibility: hidden; \n opacity: 0;\n}\n",o=document.createElement("style");o.appendChild(document.createTextNode(e)),document.head.appendChild(o)}}),{svg:'<svg fill="none" viewBox="0 0 24 24" width="1em" height="1em" class="t-icon t-icon-copy" slot="icon"><path fill="currentColor" d="M2 2h13v5.5h-2V4H4v9h3.5v2H2V2zm7 7h13v13H9V9zm2 2v9h9v-9h-9z"></path></svg>',onCopySuccess:(e,n)=>{c.success("复制成功!")}});export{a as m};
|
.output/public/assets/markdown-it-highlightjs-Ikc7oQsB.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{g as e}from"./@babel-D5ZMb8W9.js";import{r as t}from"./highlight.js-Ds8M-WS2.js";var r,n,l,o,i,u;function a(){if(n)return r;n=1;var e,t=Object.defineProperty,l=Object.defineProperties,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertyNames,a=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,f=(e,r,n)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,g=(e,t)=>{for(var r in t||(t={}))c.call(t,r)&&f(e,r,t[r]);if(a)for(var r of a(t))s.call(t,r)&&f(e,r,t[r]);return e},h={};function p(e,t,r,n,l){try{return t.highlight(n,{language:""!==l?l:"plaintext",ignoreIllegals:r}).value}catch(o){return e.utils.escapeHtml(n)}}function d(e,t,r,n,l){if(""!==l)return p(e,t,r,n,l);try{return t.highlightAuto(n).value}catch(o){return e.utils.escapeHtml(n)}}function b(e){return function(...t){return e(...t).replace(/<code class="/g,'<code class="hljs ').replace(/<code>/g,'<code class="hljs">')}}function j(e){var t,r,n;for(const o of e.tokens)if("inline"===o.type&&null!=o.children)for(const[u,a]of o.children.entries()){if("code_inline"!==a.type)continue;const c=o.children[u+1];if(null==c)continue;const s=/^{:?\.([^}]+)}/.exec(c.content);if(null==s)continue;const f=s[1];c.content=c.content.slice(s[0].length);let h=null!=(t=a.attrGet("class"))?t:"";h+=`${null!=(r=e.md.options.langPrefix)?r:"language-"}${f}`,a.attrSet("class",h),a.meta=(n=g({},a.meta),l(n,i({highlightLanguage:f})))}}function y(e,t,r,n,l){var o,i;const u=e[t];if(null==r.highlight)throw new Error("`options.highlight` was null, this is not supposed to happen");const a=r.highlight(u.content,null!=(i=null==(o=u.meta)?void 0:o.highlightLanguage)?i:"","");return`<code${l.renderAttrs(u)}>${a}</code>`}function O(e,t){const r=g(g({},O.defaults),t);if(null==r.hljs)throw new Error("Please pass a highlight.js instance for the required `hljs` option.");null!=r.register&&function(e,t){for(const[r,n]of Object.entries(t))e.registerLanguage(r,n)}(r.hljs,r.register),e.options.highlight=(r.auto?d:p).bind(null,e,r.hljs,r.ignoreIllegals),null!=e.renderer.rules.fence&&(e.renderer.rules.fence=b(e.renderer.rules.fence)),r.code&&null!=e.renderer.rules.code_block&&(e.renderer.rules.code_block=b(e.renderer.rules.code_block)),r.inline&&(e.core.ruler.before("linkify","inline_code_language",j),e.renderer.rules.code_inline=b(y))}return((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(h,{default:()=>O}),e=h,r=((e,r,n,l)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let i of u(r))c.call(e,i)||i===n||t(e,i,{get:()=>r[i],enumerable:!(l=o(r,i))||l.enumerable});return e})(t({},"__esModule",{value:!0}),e),O.defaults={auto:!1,code:!1,inline:!1,ignoreIllegals:!1},r}const c=e(u?i:(u=1,i=function(){if(o)return l;o=1;var e,r=Object.create,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,s=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=(e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,p=(e,t)=>{for(var r in t||(t={}))f.call(t,r)&&h(e,r,t[r]);if(c)for(var r of c(t))g.call(t,r)&&h(e,r,t[r]);return e},d=(e,t,r,l)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of u(t))f.call(e,o)||o===r||n(e,o,{get:()=>t[o],enumerable:!(l=i(t,o))||l.enumerable});return e},b=(e,t,l)=>(l=null!=e?r(s(e)):{},d(e&&e.__esModule?l:n(l,"default",{value:e,enumerable:!0}),e)),j={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(j,{default:()=>m}),e=j,l=d(n({},"__esModule",{value:!0}),e);var y=b(t()),O=b(a());function m(e,t){return null==(t=p(p({},m.defaults),t)).hljs&&(t.hljs=y.default),(0,O.default)(e,t)}return m.defaults={auto:!0,code:!0,inline:!1,ignoreIllegals:!0},l}().default));export{c as m};
|
.output/public/assets/mermaid-B98QzgAP.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
.output/public/assets/popup-fiphPf2R.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import{u as e,b as t,_ as o,s,i as r,m as i}from"./global-BveI--BU.js";import{l as a,a as l,f as n,o as p,n as u,V as m,v as d,y as c,A as v,J as j,a0 as w,ae as f,af as y,F as h,ab as k,I as g,z as b,H as x,u as E,ad as L,U as T}from"./@vue-DsZlmJIP.js";import{f as R}from"./fetch-2coGNStX.js";import{m as H}from"./markdown-DPs5ApTw.js";import{I as _}from"./tdesign-vue-next-DsCOKp3d.js";import"./lodash-Cky9m9r7.js";import"./@babel-D5ZMb8W9.js";import"./core-js-pure-ZQ_YVJtv.js";import"./@vueuse-Cn3Nsuq9.js";import"./vue-i18n-Dmk40Gks.js";import"./@intlify-eboPrqDD.js";import"./pinia-jKJ-xldK.js";import"./pinia-plugin-persistedstate-DyrI1rJI.js";import"./destr-ClW9AvhW.js";import"./deep-pick-omit-DP_A4OSP.js";import"./tvision-color-Dyv1XgcL.js";import"./chroma-js-C-7CTB41.js";import"./@material-C_XhzpVg.js";import"./bezier-easing-7-TbLOHs.js";import"./eventsource-parser-BEY8Dpg-.js";import"./@mozilla-BD532_dh.js";import"./markdown-it-link-attributes-UnOqz_aA.js";import"./markdown-it-C8SkdHr7.js";import"./mdurl-CDXpswLz.js";import"./uc.micro-CLkLCS2f.js";import"./entities-D7HTx9ov.js";import"./linkify-it-LcVOBuC5.js";import"./punycode.js-Bmr3cAX8.js";import"./@traptitech-BPk2gen6.js";import"./katex-BY7yyeOs.js";import"./markdown-it-highlightjs-Ikc7oQsB.js";import"./highlight.js-Ds8M-WS2.js";import"./@agoose77-mGnNv_bd.js";import"./mermaid-B98QzgAP.js";import"./dayjs-DOPU4UI6.js";import"./@braintree-DgpeZQRe.js";import"./d3-transition-swcnLnsT.js";import"./d3-timer-keMr1twq.js";import"./d3-dispatch-Chq_f_hl.js";import"./d3-interpolate-Ct9kki6l.js";import"./d3-color-D5ULnJIe.js";import"./d3-selection-G65jBFUY.js";import"./d3-ease-Cx6bG2vu.js";import"./d3-zoom-D4Vc87xO.js";import"./dompurify-B5jhUdWW.js";import"./dagre-d3-es-FtH4B9px.js";import"./lodash-es-BkU_-LF8.js";import"./d3-shape-C1TbtrGg.js";import"./d3-path-QSrLXsQ3.js";import"./d3-fetch-XwboCDHR.js";import"./elkjs-CmFeGg_o.js";import"./khroma-Ca6ZlOUT.js";import"./@wdns-P0uM2sk1.js";import"./ua-parser-js-9pz7LJLQ.js";import"./ts-dedent-CttZBlkd.js";import"./stylis-Cl7w7uv3.js";import"./d3-scale-CjTvl_Qo.js";import"./internmap-B8oPgqVZ.js";import"./d3-array-B0evfIyH.js";import"./d3-format-C0lSXcPg.js";import"./d3-time-format-D74OpZq4.js";import"./d3-time-CebKitJR.js";import"./d3-axis-pCwzqJ1S.js";import"./cytoscape-D84qPEQv.js";import"./cytoscape-cose-bilkent-CoOmxuE9.js";import"./cose-base-kQthUiMK.js";import"./layout-base-DqRk0Tgc.js";import"./tdesign-icons-vue-next-Dn30dVUK.js";import"./sortablejs-DGtSoqI-.js";import"./@popperjs-B4tvfKWZ.js";const z={class:"popup-container rounded-lg shadow-lg w-full flex flex-col pb-0 p-4",style:{"max-height":"500px"}},C={class:"relative flex items-center"},I={key:0,class:"space-y-2"},M=["onClick"],D={key:1},U=["innerHTML"],A={class:"footer-text py-1 border-t mt-4 text-sm text-center"},B=T(o(a({__name:"PopupWindow",setup(o){e();const s=t(),r=l(""),i=l(null),a=l(0),T=l(!1),B=l(""),K=l(!1),V=l(null),$=l(!0),J=e(),q=n((()=>J.displayMode)),F=[{name:"问问",icon:"chat",prompt:"{{text}}",show:!0}],N=n((()=>{const e=s.toolBarButtons.filter((e=>e.name&&e.show&&void 0!==e.prompt));return[...F,...e]})),O=async()=>{!T.value&&r.value.trim()&&await X()},P=()=>{if(!(null==window?void 0:window.ipcRenderer)||!V.value)return;const e=V.value.scrollHeight+118,t=Math.min(500,e);window.ipcRenderer.send("adjust-popup-height",t)},S=((e,t)=>{let o=null;return(...s)=>{o&&clearTimeout(o),o=setTimeout((()=>e(...s)),t)}})(P,50),W=()=>{if(!V.value)return;const{scrollTop:e,scrollHeight:t,clientHeight:o}=V.value;$.value=!(t-e-o>50)},X=async()=>{T.value=!0,K.value=!0,u((()=>{P()}));try{const e=r.value.trim();if(!e)return;const t=N.value[a.value],o=(t.prompt||"").replace(/{{text}}/g,e);B.value="",await R(o,(e=>{B.value=e,u((()=>{V.value&&$.value&&(V.value.scrollTop=V.value.scrollHeight),S()}))}))}finally{T.value=!1}},Y=()=>{K.value=!1,B.value="",u((()=>{var e,t;null==(e=i.value)||e.select(),null==(t=i.value)||t.focus(),P()}))},Z=()=>{K.value=!1,B.value="",r.value="",u((()=>{var e;null==(e=i.value)||e.focus(),P()}))},G=e=>{"Escape"!==e.key?K.value||("Tab"===e.key&&(e.preventDefault(),a.value=(a.value+1)%N.value.length),"ArrowUp"===e.key?(e.preventDefault(),a.value=a.value>0?a.value-1:N.value.length-1):"ArrowDown"===e.key&&(e.preventDefault(),a.value=(a.value+1)%N.value.length)):K.value?Y():Q()},Q=()=>{(null==window?void 0:window.ipcRenderer)&&window.ipcRenderer.send("hide-popup")};return p((()=>{var e,t;document.addEventListener("click",Q),document.addEventListener("keydown",G),null==(e=V.value)||e.addEventListener("scroll",W),null==(t=i.value)||t.focus(),u((()=>{P()})),(null==window?void 0:window.ipcRenderer)&&window.ipcRenderer.on("show-window",Z)})),m((()=>{var e;document.removeEventListener("click",Q),document.removeEventListener("keydown",G),null==(e=V.value)||e.removeEventListener("scroll",W),(null==window?void 0:window.ipcRenderer)&&window.ipcRenderer.removeListener("show-window",Z)})),(e,t)=>{const o=_;return c(),d("div",{class:g(["popup-window fixed inset-0 flex items-start justify-center",q.value]),onClick:t[1]||(t[1]=L((()=>{}),["stop"]))},[v("div",z,[v("div",C,[K.value?(c(),j(o,{key:1,name:"arrow-left",class:"absolute left-3 icon-color cursor-pointer",onClick:Y})):(c(),j(o,{key:0,name:"search",class:"absolute left-3 icon-color"})),w(v("input",{ref_key:"inputRef",ref:i,"onUpdate:modelValue":t[0]||(t[0]=e=>r.value=e),type:"text",class:"input-field w-full pl-10 pr-4 py-2 rounded-lg border focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入内容...",onKeydown:y(O,["enter"])},null,544),[[f,r.value]])]),v("div",{ref_key:"contentContainer",ref:V,class:"mt-4 overflow-auto no-scrollbar min-h-32"},[K.value?(c(),d("div",D,[v("div",{class:"markdown-body",innerHTML:E(H).render(B.value)},null,8,U)])):(c(),d("div",I,[(c(!0),d(h,null,k(N.value,((e,t)=>(c(),d("div",{key:e.name,class:g(["tool-button flex items-center p-2 rounded-lg cursor-pointer",a.value===t?"tool-button-selected":""]),onClick:e=>(async e=>{T.value||(a.value=e,await X())})(t)},[e.icon?(c(),j(o,{key:0,name:e.icon,class:"mr-2"},null,8,["name"])):b("",!0),v("span",null,x(e.name),1)],10,M)))),128))]))],512),v("div",A,x(K.value?`${N.value[a.value].name} - 使用 Esc 返回`:"使用 ↑↓ 或 Tab 切换,Enter 发送,Esc 关闭"),1)])],2)}}}),[["__scopeId","data-v-a20eede4"]]));B.use(s),B.use(r),i.initialize(),B.mount("#app").$nextTick((()=>{postMessage({payload:"removeLoading"},"*")}));
|
.output/public/assets/prismjs-BGP89_QJ.js
ADDED
@@ -0,0 +1,453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import{c as e,g as t}from"./@babel-D5ZMb8W9.js";function n(e,t){for(var n=0;n<t.length;n++){const a=t[n];if("string"!=typeof a&&!Array.isArray(a))for(const t in a)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(a,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}var a,r={exports:{}};var s,i,o=(a||(a=1,s=r,i=function(e){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,a={},r={
|
2 |
+
/**
|
3 |
+
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
4 |
+
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
5 |
+
* additional languages or plugins yourself.
|
6 |
+
*
|
7 |
+
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
8 |
+
*
|
9 |
+
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
10 |
+
* empty Prism object into the global scope before loading the Prism script like this:
|
11 |
+
*
|
12 |
+
* ```js
|
13 |
+
* window.Prism = window.Prism || {};
|
14 |
+
* Prism.manual = true;
|
15 |
+
* // add a new <script> to load Prism's script
|
16 |
+
* ```
|
17 |
+
*
|
18 |
+
* @default false
|
19 |
+
* @type {boolean}
|
20 |
+
* @memberof Prism
|
21 |
+
* @public
|
22 |
+
*/
|
23 |
+
manual:e.Prism&&e.Prism.manual,
|
24 |
+
/**
|
25 |
+
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
26 |
+
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
27 |
+
* own worker, you don't want it to do this.
|
28 |
+
*
|
29 |
+
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
30 |
+
*
|
31 |
+
* You obviously have to change this value before Prism executes. To do this, you can add an
|
32 |
+
* empty Prism object into the global scope before loading the Prism script like this:
|
33 |
+
*
|
34 |
+
* ```js
|
35 |
+
* window.Prism = window.Prism || {};
|
36 |
+
* Prism.disableWorkerMessageHandler = true;
|
37 |
+
* // Load Prism's script
|
38 |
+
* ```
|
39 |
+
*
|
40 |
+
* @default false
|
41 |
+
* @type {boolean}
|
42 |
+
* @memberof Prism
|
43 |
+
* @public
|
44 |
+
*/
|
45 |
+
disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,
|
46 |
+
/**
|
47 |
+
* A namespace for utility methods.
|
48 |
+
*
|
49 |
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
50 |
+
* change or disappear at any time.
|
51 |
+
*
|
52 |
+
* @namespace
|
53 |
+
* @memberof Prism
|
54 |
+
*/
|
55 |
+
util:{encode:function e(t){return t instanceof s?new s(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},
|
56 |
+
/**
|
57 |
+
* Returns the name of the type of the given value.
|
58 |
+
*
|
59 |
+
* @param {any} o
|
60 |
+
* @returns {string}
|
61 |
+
* @example
|
62 |
+
* type(null) === 'Null'
|
63 |
+
* type(undefined) === 'Undefined'
|
64 |
+
* type(123) === 'Number'
|
65 |
+
* type('foo') === 'String'
|
66 |
+
* type(true) === 'Boolean'
|
67 |
+
* type([1, 2]) === 'Array'
|
68 |
+
* type({}) === 'Object'
|
69 |
+
* type(String) === 'Function'
|
70 |
+
* type(/abc+/) === 'RegExp'
|
71 |
+
*/
|
72 |
+
type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},
|
73 |
+
/**
|
74 |
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
75 |
+
*
|
76 |
+
* @param {Object} obj
|
77 |
+
* @returns {number}
|
78 |
+
*/
|
79 |
+
objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++n}),e.__id},
|
80 |
+
/**
|
81 |
+
* Creates a deep clone of the given object.
|
82 |
+
*
|
83 |
+
* The main intended use of this function is to clone language definitions.
|
84 |
+
*
|
85 |
+
* @param {T} o
|
86 |
+
* @param {Record<number, any>} [visited]
|
87 |
+
* @returns {T}
|
88 |
+
* @template T
|
89 |
+
*/
|
90 |
+
clone:function e(t,n){var a,s;switch(n=n||{},r.util.type(t)){case"Object":if(s=r.util.objId(t),n[s])return n[s];for(var i in a=/** @type {Record<string, any>} */
|
91 |
+
{},n[s]=a,t)t.hasOwnProperty(i)&&(a[i]=e(t[i],n));
|
92 |
+
/** @type {any} */
|
93 |
+
return a;case"Array":return s=r.util.objId(t),n[s]?n[s]:(a=[],n[s]=a,
|
94 |
+
/** @type {Array} */
|
95 |
+
/** @type {any} */
|
96 |
+
t.forEach((function(t,r){a[r]=e(t,n)})),
|
97 |
+
/** @type {any} */a);default:return t}},
|
98 |
+
/**
|
99 |
+
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
100 |
+
*
|
101 |
+
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
102 |
+
*
|
103 |
+
* @param {Element} element
|
104 |
+
* @returns {string}
|
105 |
+
*/
|
106 |
+
getLanguage:function(e){for(;e;){var n=t.exec(e.className);if(n)return n[1].toLowerCase();e=e.parentElement}return"none"},
|
107 |
+
/**
|
108 |
+
* Sets the Prism `language-xxxx` class of the given element.
|
109 |
+
*
|
110 |
+
* @param {Element} element
|
111 |
+
* @param {string} language
|
112 |
+
* @returns {void}
|
113 |
+
*/
|
114 |
+
setLanguage:function(e,n){e.className=e.className.replace(RegExp(t,"gi"),""),e.classList.add("language-"+n)},
|
115 |
+
/**
|
116 |
+
* Returns the script element that is currently executing.
|
117 |
+
*
|
118 |
+
* This does __not__ work for line script element.
|
119 |
+
*
|
120 |
+
* @returns {HTMLScriptElement | null}
|
121 |
+
*/
|
122 |
+
currentScript:function(){if("undefined"==typeof document)return null;if(document.currentScript&&"SCRIPT"===document.currentScript.tagName)
|
123 |
+
/** @type {any} */
|
124 |
+
return document.currentScript;try{throw new Error}catch(a){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(a.stack)||[])[1];if(e){var t=document.getElementsByTagName("script");for(var n in t)if(t[n].src==e)return t[n]}return null}},
|
125 |
+
/**
|
126 |
+
* Returns whether a given class is active for `element`.
|
127 |
+
*
|
128 |
+
* The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
|
129 |
+
* if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
|
130 |
+
* given class is just the given class with a `no-` prefix.
|
131 |
+
*
|
132 |
+
* Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
|
133 |
+
* closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
|
134 |
+
* ancestors have the given class or the negated version of it, then the default activation will be returned.
|
135 |
+
*
|
136 |
+
* In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
|
137 |
+
* version of it, the class is considered active.
|
138 |
+
*
|
139 |
+
* @param {Element} element
|
140 |
+
* @param {string} className
|
141 |
+
* @param {boolean} [defaultActivation=false]
|
142 |
+
* @returns {boolean}
|
143 |
+
*/
|
144 |
+
isActive:function(e,t,n){for(var a="no-"+t;e;){var r=e.classList;if(r.contains(t))return!0;if(r.contains(a))return!1;e=e.parentElement}return!!n}},
|
145 |
+
/**
|
146 |
+
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
147 |
+
*
|
148 |
+
* @namespace
|
149 |
+
* @memberof Prism
|
150 |
+
* @public
|
151 |
+
*/
|
152 |
+
languages:{
|
153 |
+
/**
|
154 |
+
* The grammar for plain, unformatted text.
|
155 |
+
*/
|
156 |
+
plain:a,plaintext:a,text:a,txt:a,
|
157 |
+
/**
|
158 |
+
* Creates a deep copy of the language with the given id and appends the given tokens.
|
159 |
+
*
|
160 |
+
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
161 |
+
* will be overwritten at its original position.
|
162 |
+
*
|
163 |
+
* ## Best practices
|
164 |
+
*
|
165 |
+
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
166 |
+
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
167 |
+
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
168 |
+
*
|
169 |
+
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
170 |
+
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
171 |
+
*
|
172 |
+
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
173 |
+
* @param {Grammar} redef The new tokens to append.
|
174 |
+
* @returns {Grammar} The new language created.
|
175 |
+
* @public
|
176 |
+
* @example
|
177 |
+
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
178 |
+
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
179 |
+
* // at its original position
|
180 |
+
* 'comment': { ... },
|
181 |
+
* // CSS doesn't have a 'color' token, so this token will be appended
|
182 |
+
* 'color': /\b(?:red|green|blue)\b/
|
183 |
+
* });
|
184 |
+
*/
|
185 |
+
extend:function(e,t){var n=r.util.clone(r.languages[e]);for(var a in t)n[a]=t[a];return n},
|
186 |
+
/**
|
187 |
+
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
188 |
+
*
|
189 |
+
* ## Usage
|
190 |
+
*
|
191 |
+
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
192 |
+
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
193 |
+
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
194 |
+
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
195 |
+
* this:
|
196 |
+
*
|
197 |
+
* ```js
|
198 |
+
* Prism.languages.markup.style = {
|
199 |
+
* // token
|
200 |
+
* };
|
201 |
+
* ```
|
202 |
+
*
|
203 |
+
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
204 |
+
* before existing tokens. For the CSS example above, you would use it like this:
|
205 |
+
*
|
206 |
+
* ```js
|
207 |
+
* Prism.languages.insertBefore('markup', 'cdata', {
|
208 |
+
* 'style': {
|
209 |
+
* // token
|
210 |
+
* }
|
211 |
+
* });
|
212 |
+
* ```
|
213 |
+
*
|
214 |
+
* ## Special cases
|
215 |
+
*
|
216 |
+
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
217 |
+
* will be ignored.
|
218 |
+
*
|
219 |
+
* This behavior can be used to insert tokens after `before`:
|
220 |
+
*
|
221 |
+
* ```js
|
222 |
+
* Prism.languages.insertBefore('markup', 'comment', {
|
223 |
+
* 'comment': Prism.languages.markup.comment,
|
224 |
+
* // tokens after 'comment'
|
225 |
+
* });
|
226 |
+
* ```
|
227 |
+
*
|
228 |
+
* ## Limitations
|
229 |
+
*
|
230 |
+
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
231 |
+
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
232 |
+
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
233 |
+
* deleting properties which is necessary to insert at arbitrary positions.
|
234 |
+
*
|
235 |
+
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
236 |
+
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
237 |
+
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
238 |
+
*
|
239 |
+
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
240 |
+
* you hold the target object in a variable, then the value of the variable will not change.
|
241 |
+
*
|
242 |
+
* ```js
|
243 |
+
* var oldMarkup = Prism.languages.markup;
|
244 |
+
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
245 |
+
*
|
246 |
+
* assert(oldMarkup !== Prism.languages.markup);
|
247 |
+
* assert(newMarkup === Prism.languages.markup);
|
248 |
+
* ```
|
249 |
+
*
|
250 |
+
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
251 |
+
* object to be modified.
|
252 |
+
* @param {string} before The key to insert before.
|
253 |
+
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
254 |
+
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
255 |
+
* object to be modified.
|
256 |
+
*
|
257 |
+
* Defaults to `Prism.languages`.
|
258 |
+
* @returns {Grammar} The new grammar object.
|
259 |
+
* @public
|
260 |
+
*/
|
261 |
+
insertBefore:function(e,t,n,a){var s=(a=a||/** @type {any} */
|
262 |
+
r.languages)[e],i={};for(var o in s)if(s.hasOwnProperty(o)){if(o==t)for(var l in n)n.hasOwnProperty(l)&&(i[l]=n[l]);n.hasOwnProperty(o)||(i[o]=s[o])}var u=a[e];return a[e]=i,r.languages.DFS(r.languages,(function(t,n){n===u&&t!=e&&(this[t]=i)})),i},
|
263 |
+
// Traverse a language definition with Depth First Search
|
264 |
+
DFS:function e(t,n,a,s){s=s||{};var i=r.util.objId;for(var o in t)if(t.hasOwnProperty(o)){n.call(t,o,t[o],a||o);var l=t[o],u=r.util.type(l);"Object"!==u||s[i(l)]?"Array"!==u||s[i(l)]||(s[i(l)]=!0,e(l,n,o,s)):(s[i(l)]=!0,e(l,n,null,s))}}},plugins:{},
|
265 |
+
/**
|
266 |
+
* This is the most high-level function in Prism’s API.
|
267 |
+
* It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
|
268 |
+
* each one of them.
|
269 |
+
*
|
270 |
+
* This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
|
271 |
+
*
|
272 |
+
* @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
|
273 |
+
* @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
|
274 |
+
* @memberof Prism
|
275 |
+
* @public
|
276 |
+
*/
|
277 |
+
highlightAll:function(e,t){r.highlightAllUnder(document,e,t)},
|
278 |
+
/**
|
279 |
+
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
280 |
+
* {@link Prism.highlightElement} on each one of them.
|
281 |
+
*
|
282 |
+
* The following hooks will be run:
|
283 |
+
* 1. `before-highlightall`
|
284 |
+
* 2. `before-all-elements-highlight`
|
285 |
+
* 3. All hooks of {@link Prism.highlightElement} for each element.
|
286 |
+
*
|
287 |
+
* @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
|
288 |
+
* @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
|
289 |
+
* @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
|
290 |
+
* @memberof Prism
|
291 |
+
* @public
|
292 |
+
*/
|
293 |
+
highlightAllUnder:function(e,t,n){var a={callback:n,container:e,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};r.hooks.run("before-highlightall",a),a.elements=Array.prototype.slice.apply(a.container.querySelectorAll(a.selector)),r.hooks.run("before-all-elements-highlight",a);for(var s,i=0;s=a.elements[i++];)r.highlightElement(s,!0===t,a.callback)},
|
294 |
+
/**
|
295 |
+
* Highlights the code inside a single element.
|
296 |
+
*
|
297 |
+
* The following hooks will be run:
|
298 |
+
* 1. `before-sanity-check`
|
299 |
+
* 2. `before-highlight`
|
300 |
+
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
|
301 |
+
* 4. `before-insert`
|
302 |
+
* 5. `after-highlight`
|
303 |
+
* 6. `complete`
|
304 |
+
*
|
305 |
+
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
|
306 |
+
* the element's language.
|
307 |
+
*
|
308 |
+
* @param {Element} element The element containing the code.
|
309 |
+
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
|
310 |
+
* @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
|
311 |
+
* to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
|
312 |
+
* [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
|
313 |
+
*
|
314 |
+
* Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
|
315 |
+
* asynchronous highlighting to work. You can build your own bundle on the
|
316 |
+
* [Download page](https://prismjs.com/download.html).
|
317 |
+
* @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
|
318 |
+
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
|
319 |
+
* @memberof Prism
|
320 |
+
* @public
|
321 |
+
*/
|
322 |
+
highlightElement:function(t,n,a){var s=r.util.getLanguage(t),i=r.languages[s];r.util.setLanguage(t,s);var o=t.parentElement;o&&"pre"===o.nodeName.toLowerCase()&&r.util.setLanguage(o,s);var l={element:t,language:s,grammar:i,code:t.textContent};function u(e){l.highlightedCode=e,r.hooks.run("before-insert",l),l.element.innerHTML=l.highlightedCode,r.hooks.run("after-highlight",l),r.hooks.run("complete",l),a&&a.call(l.element)}if(r.hooks.run("before-sanity-check",l),(o=l.element.parentElement)&&"pre"===o.nodeName.toLowerCase()&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","0"),!l.code)return r.hooks.run("complete",l),void(a&&a.call(l.element));if(r.hooks.run("before-highlight",l),l.grammar)if(n&&e.Worker){var g=new Worker(r.filename);g.onmessage=function(e){u(e.data)},g.postMessage(JSON.stringify({language:l.language,code:l.code,immediateClose:!0}))}else u(r.highlight(l.code,l.grammar,l.language));else u(r.util.encode(l.code))},
|
323 |
+
/**
|
324 |
+
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
325 |
+
* and the language definitions to use, and returns a string with the HTML produced.
|
326 |
+
*
|
327 |
+
* The following hooks will be run:
|
328 |
+
* 1. `before-tokenize`
|
329 |
+
* 2. `after-tokenize`
|
330 |
+
* 3. `wrap`: On each {@link Token}.
|
331 |
+
*
|
332 |
+
* @param {string} text A string with the code to be highlighted.
|
333 |
+
* @param {Grammar} grammar An object containing the tokens to use.
|
334 |
+
*
|
335 |
+
* Usually a language definition like `Prism.languages.markup`.
|
336 |
+
* @param {string} language The name of the language definition passed to `grammar`.
|
337 |
+
* @returns {string} The highlighted HTML.
|
338 |
+
* @memberof Prism
|
339 |
+
* @public
|
340 |
+
* @example
|
341 |
+
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
342 |
+
*/
|
343 |
+
highlight:function(e,t,n){var a={code:e,grammar:t,language:n};if(r.hooks.run("before-tokenize",a),!a.grammar)throw new Error('The language "'+a.language+'" has no grammar.');return a.tokens=r.tokenize(a.code,a.grammar),r.hooks.run("after-tokenize",a),s.stringify(r.util.encode(a.tokens),a.language)},
|
344 |
+
/**
|
345 |
+
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
346 |
+
* and the language definitions to use, and returns an array with the tokenized code.
|
347 |
+
*
|
348 |
+
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
349 |
+
*
|
350 |
+
* This method could be useful in other contexts as well, as a very crude parser.
|
351 |
+
*
|
352 |
+
* @param {string} text A string with the code to be highlighted.
|
353 |
+
* @param {Grammar} grammar An object containing the tokens to use.
|
354 |
+
*
|
355 |
+
* Usually a language definition like `Prism.languages.markup`.
|
356 |
+
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
357 |
+
* @memberof Prism
|
358 |
+
* @public
|
359 |
+
* @example
|
360 |
+
* let code = `var foo = 0;`;
|
361 |
+
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
362 |
+
* tokens.forEach(token => {
|
363 |
+
* if (token instanceof Prism.Token && token.type === 'number') {
|
364 |
+
* console.log(`Found numeric literal: ${token.content}`);
|
365 |
+
* }
|
366 |
+
* });
|
367 |
+
*/
|
368 |
+
tokenize:function(e,t){var n=t.rest;if(n){for(var a in n)t[a]=n[a];delete t.rest}var r=new l;return u(r,r.head,e),o(e,r,t,r.head,0),function(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}(r)},
|
369 |
+
/**
|
370 |
+
* @namespace
|
371 |
+
* @memberof Prism
|
372 |
+
* @public
|
373 |
+
*/
|
374 |
+
hooks:{all:{},
|
375 |
+
/**
|
376 |
+
* Adds the given callback to the list of callbacks for the given hook.
|
377 |
+
*
|
378 |
+
* The callback will be invoked when the hook it is registered for is run.
|
379 |
+
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
380 |
+
*
|
381 |
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
382 |
+
*
|
383 |
+
* @param {string} name The name of the hook.
|
384 |
+
* @param {HookCallback} callback The callback function which is given environment variables.
|
385 |
+
* @public
|
386 |
+
*/
|
387 |
+
add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},
|
388 |
+
/**
|
389 |
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
390 |
+
*
|
391 |
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
392 |
+
*
|
393 |
+
* @param {string} name The name of the hook.
|
394 |
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
395 |
+
* @public
|
396 |
+
*/
|
397 |
+
run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var a,s=0;a=n[s++];)a(t)}},Token:s};function s(e,t,n,a){this.type=e,this.content=t,this.alias=n,this.length=0|(a||"").length}function i(e,t,n,a){e.lastIndex=t;var r=e.exec(n);if(r&&a&&r[1]){var s=r[1].length;r.index+=s,r[0]=r[0].slice(s)}return r}function o(e,t,n,a,l,c){for(var d in n)if(n.hasOwnProperty(d)&&n[d]){var p=n[d];p=Array.isArray(p)?p:[p];for(var h=0;h<p.length;++h){if(c&&c.cause==d+","+h)return;var f=p[h],m=f.inside,v=!!f.lookbehind,b=!!f.greedy,y=f.alias;if(b&&!f.pattern.global){var x=f.pattern.toString().match(/[imsuy]*$/)[0];f.pattern=RegExp(f.pattern.source,x+"g")}for(var F=f.pattern||f,k=a.next,w=l;k!==t.tail&&!(c&&w>=c.reach);w+=k.value.length,k=k.next){var A=k.value;if(t.length>e.length)return;if(!(A instanceof s)){var $,S=1;if(b){if(!($=i(F,w,e,v))||$.index>=e.length)break;var E=$.index,_=$.index+$[0].length,j=w;for(j+=k.value.length;E>=j;)j+=(k=k.next).value.length;if(w=j-=k.value.length,k.value instanceof s)continue;for(var C=k;C!==t.tail&&(j<_||"string"==typeof C.value);C=C.next)S++,j+=C.value.length;S--,A=e.slice(w,j),$.index-=w}else if(!($=i(F,0,A,v)))continue;E=$.index;var O=$[0],P=A.slice(0,E),L=A.slice(E+O.length),z=w+A.length;c&&z>c.reach&&(c.reach=z);var T=k.prev;if(P&&(T=u(t,T,P),w+=P.length),g(t,T,S),k=u(t,T,new s(d,m?r.tokenize(O,m):O,y,O)),L&&u(t,k,L),S>1){var M={cause:d+","+h,reach:z};o(e,t,n,k.prev,w,M),c&&M.reach>c.reach&&(c.reach=M.reach)}}}}}}function l(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function u(e,t,n){var a=t.next,r={value:n,prev:t,next:a};return t.next=r,a.prev=r,e.length++,r}function g(e,t,n){for(var a=t.next,r=0;r<n&&a!==e.tail;r++)a=a.next;t.next=a,a.prev=t,e.length-=r}if(e.Prism=r,s.stringify=function e(t,n){if("string"==typeof t)return t;if(Array.isArray(t)){var a="";return t.forEach((function(t){a+=e(t,n)})),a}var s={type:t.type,content:e(t.content,n),tag:"span",classes:["token",t.type],attributes:{},language:n},i=t.alias;i&&(Array.isArray(i)?Array.prototype.push.apply(s.classes,i):s.classes.push(i)),r.hooks.run("wrap",s);var o="";for(var l in s.attributes)o+=" "+l+'="'+(s.attributes[l]||"").replace(/"/g,""")+'"';return"<"+s.tag+' class="'+s.classes.join(" ")+'"'+o+">"+s.content+"</"+s.tag+">"},!e.document)return e.addEventListener?(r.disableWorkerMessageHandler||e.addEventListener("message",(function(t){var n=JSON.parse(t.data),a=n.language,s=n.code,i=n.immediateClose;e.postMessage(r.highlight(s,r.languages[a],a)),i&&e.close()}),!1),r):r;var c=r.util.currentScript();function d(){r.manual||r.highlightAll()}if(c&&(r.filename=c.src,c.hasAttribute("data-manual")&&(r.manual=!0)),!r.manual){var p=document.readyState;"loading"===p||"interactive"===p&&c&&c.defer?document.addEventListener("DOMContentLoaded",d):window.requestAnimationFrame?window.requestAnimationFrame(d):window.setTimeout(d,16)}return r}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{}),s.exports&&(s.exports=i),void 0!==e&&(e.Prism=i),i.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{
|
398 |
+
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
399 |
+
pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},i.languages.markup.tag.inside["attr-value"].inside.entity=i.languages.markup.entity,i.languages.markup.doctype.inside["internal-subset"].inside=i.languages.markup,i.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))})),Object.defineProperty(i.languages.markup.tag,"addInlined",{
|
400 |
+
/**
|
401 |
+
* Adds an inlined language to markup.
|
402 |
+
*
|
403 |
+
* An example of an inlined language is CSS with `<style>` tags.
|
404 |
+
*
|
405 |
+
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
406 |
+
* case insensitive.
|
407 |
+
* @param {string} lang The language key.
|
408 |
+
* @example
|
409 |
+
* addInlined('style', 'css');
|
410 |
+
*/
|
411 |
+
value:function(e,t){var n={};n["language-"+t]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:i.languages[t]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};a["language-"+t]={pattern:/[\s\S]+/,inside:i.languages[t]};var r={};r[e]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,(function(){return e})),"i"),lookbehind:!0,greedy:!0,inside:a},i.languages.insertBefore("markup","cdata",r)}}),Object.defineProperty(i.languages.markup.tag,"addAttribute",{
|
412 |
+
/**
|
413 |
+
* Adds an pattern to highlight languages embedded in HTML attributes.
|
414 |
+
*
|
415 |
+
* An example of an inlined language is CSS with `style` attributes.
|
416 |
+
*
|
417 |
+
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
418 |
+
* case insensitive.
|
419 |
+
* @param {string} lang The language key.
|
420 |
+
* @example
|
421 |
+
* addAttribute('style', 'css');
|
422 |
+
*/
|
423 |
+
value:function(e,t){i.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:i.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),i.languages.html=i.languages.markup,i.languages.mathml=i.languages.markup,i.languages.svg=i.languages.markup,i.languages.xml=i.languages.extend("markup",{}),i.languages.ssml=i.languages.xml,i.languages.atom=i.languages.xml,i.languages.rss=i.languages.xml,function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{
|
424 |
+
// https://drafts.csswg.org/css-values-3/#urls
|
425 |
+
pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|"+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(i),i.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},i.languages.javascript=i.languages.extend("clike",{"class-name":[i.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],
|
426 |
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
427 |
+
function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+// constant
|
428 |
+
/NaN|Infinity/.source+"|"+// binary integer
|
429 |
+
/0[bB][01]+(?:_[01]+)*n?/.source+"|"+// octal integer
|
430 |
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+// hexadecimal integer
|
431 |
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+// decimal bigint
|
432 |
+
/\d+(?:_\d+)*n/.source+"|"+// decimal number (integer or float) but no bigint
|
433 |
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),i.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,i.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(
|
434 |
+
// lookbehind
|
435 |
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
436 |
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+// Regex pattern:
|
437 |
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
438 |
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
439 |
+
// with the only syntax, so we have to define 2 different regex patterns.
|
440 |
+
/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+// `v` flag syntax. This supports 3 levels of nested character classes.
|
441 |
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+// lookahead
|
442 |
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:i.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},
|
443 |
+
// This must be declared before keyword because we use "function" inside the look-forward
|
444 |
+
"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:i.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:i.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:i.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:i.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),i.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:i.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),i.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),i.languages.markup&&(i.languages.markup.tag.addInlined("script","javascript"),i.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),i.languages.js=i.languages.javascript,function(){if(void 0!==i&&"undefined"!=typeof document){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},t="data-src-status",n="loading",a="loaded",r="pre[data-src]:not(["+t+'="'+a+'"]):not(['+t+'="'+n+'"])';i.hooks.add("before-highlightall",(function(e){e.selector+=", "+r})),i.hooks.add("before-sanity-check",(function(s){var o=
|
445 |
+
/** @type {HTMLPreElement} */s.element;if(o.matches(r)){s.code="",o.setAttribute(t,n);var l=o.appendChild(document.createElement("CODE"));l.textContent="Loading…";var u=o.getAttribute("data-src"),g=s.language;if("none"===g){var c=(/\.(\w+)$/.exec(u)||[,"none"])[1];g=e[c]||c}i.util.setLanguage(l,g),i.util.setLanguage(o,g);var d=i.plugins.autoloader;d&&d.loadLanguages(g),function(e,t,n){var a=new XMLHttpRequest;a.open("GET",e,!0),a.onreadystatechange=function(){4==a.readyState&&(a.status<400&&a.responseText?t(a.responseText):a.status>=400?n("✖ Error "+a.status+" while fetching file: "+a.statusText):n("✖ Error: File does not exist or is empty"))},a.send(null)}(u,(function(e){o.setAttribute(t,a);var n=function(e){var t=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(e||"");if(t){var n=Number(t[1]),a=t[2],r=t[3];return a?r?[n,Number(r)]:[n,void 0]:[n,n]}}(o.getAttribute("data-range"));if(n){var r=e.split(/\r\n?|\n/g),s=n[0],u=null==n[1]?r.length:n[1];s<0&&(s+=r.length),s=Math.max(0,Math.min(s-1,r.length)),u<0&&(u+=r.length),u=Math.max(0,Math.min(u,r.length)),e=r.slice(s,u).join("\n"),o.hasAttribute("data-start")||o.setAttribute("data-start",String(s+1))}l.textContent=e,i.highlightElement(l)}),(function(e){o.setAttribute(t,"failed"),l.textContent=e}))}})),i.plugins.fileHighlight={
|
446 |
+
/**
|
447 |
+
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
448 |
+
*
|
449 |
+
* Note: Elements which are already loaded or currently loading will not be touched by this method.
|
450 |
+
*
|
451 |
+
* @param {ParentNode} [container=document]
|
452 |
+
*/
|
453 |
+
highlight:function(e){for(var t,n=(e||document).querySelectorAll(r),a=0;t=n[a++];)i.highlightElement(t)}};var s=!1;i.fileHighlight=function(){s||(s=!0),i.plugins.fileHighlight.highlight.apply(this,arguments)}}}()),r.exports);const l=n({__proto__:null,default:t(o)},[o]);export{l as p};
|
.output/public/index.html
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
<link rel="mask-icon" href="/assets/logo.svg" color="#FFFFFF">
|
11 |
<meta name="theme-color" content="#ffffff">
|
12 |
<link rel="manifest" href="./manifest.webmanifest" />
|
13 |
-
<script type="module" crossorigin src="./assets/main-
|
14 |
<link rel="modulepreload" crossorigin href="./assets/core-js-pure-ZQ_YVJtv.js">
|
15 |
<link rel="modulepreload" crossorigin href="./assets/@babel-D5ZMb8W9.js">
|
16 |
<link rel="modulepreload" crossorigin href="./assets/lodash-Cky9m9r7.js">
|
@@ -33,7 +33,7 @@
|
|
33 |
<link rel="modulepreload" crossorigin href="./assets/tvision-color-Dyv1XgcL.js">
|
34 |
<link rel="modulepreload" crossorigin href="./assets/global-BveI--BU.js">
|
35 |
<link rel="modulepreload" crossorigin href="./assets/ua-parser-js-9pz7LJLQ.js">
|
36 |
-
<link rel="modulepreload" crossorigin href="./assets/@wdns-
|
37 |
<link rel="modulepreload" crossorigin href="./assets/vue-router-Be5-2oBH.js">
|
38 |
<link rel="modulepreload" crossorigin href="./assets/vue-DVRmszIO.js">
|
39 |
<link rel="modulepreload" crossorigin href="./assets/vuedraggable-K5Gqz8r2.js">
|
|
|
10 |
<link rel="mask-icon" href="/assets/logo.svg" color="#FFFFFF">
|
11 |
<meta name="theme-color" content="#ffffff">
|
12 |
<link rel="manifest" href="./manifest.webmanifest" />
|
13 |
+
<script type="module" crossorigin src="./assets/main-zbluuG_-.js"></script>
|
14 |
<link rel="modulepreload" crossorigin href="./assets/core-js-pure-ZQ_YVJtv.js">
|
15 |
<link rel="modulepreload" crossorigin href="./assets/@babel-D5ZMb8W9.js">
|
16 |
<link rel="modulepreload" crossorigin href="./assets/lodash-Cky9m9r7.js">
|
|
|
33 |
<link rel="modulepreload" crossorigin href="./assets/tvision-color-Dyv1XgcL.js">
|
34 |
<link rel="modulepreload" crossorigin href="./assets/global-BveI--BU.js">
|
35 |
<link rel="modulepreload" crossorigin href="./assets/ua-parser-js-9pz7LJLQ.js">
|
36 |
+
<link rel="modulepreload" crossorigin href="./assets/@wdns-P0uM2sk1.js">
|
37 |
<link rel="modulepreload" crossorigin href="./assets/vue-router-Be5-2oBH.js">
|
38 |
<link rel="modulepreload" crossorigin href="./assets/vue-DVRmszIO.js">
|
39 |
<link rel="modulepreload" crossorigin href="./assets/vuedraggable-K5Gqz8r2.js">
|
.output/public/popup.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8" />
|
5 |
<title>Popup</title>
|
6 |
-
<script type="module" crossorigin src="./assets/popup-
|
7 |
<link rel="modulepreload" crossorigin href="./assets/core-js-pure-ZQ_YVJtv.js">
|
8 |
<link rel="modulepreload" crossorigin href="./assets/@babel-D5ZMb8W9.js">
|
9 |
<link rel="modulepreload" crossorigin href="./assets/lodash-Cky9m9r7.js">
|
@@ -37,8 +37,8 @@
|
|
37 |
<link rel="modulepreload" crossorigin href="./assets/markdown-it-C8SkdHr7.js">
|
38 |
<link rel="modulepreload" crossorigin href="./assets/katex-BY7yyeOs.js">
|
39 |
<link rel="modulepreload" crossorigin href="./assets/@traptitech-BPk2gen6.js">
|
40 |
-
<link rel="modulepreload" crossorigin href="./assets/highlight.js-
|
41 |
-
<link rel="modulepreload" crossorigin href="./assets/markdown-it-highlightjs-
|
42 |
<link rel="modulepreload" crossorigin href="./assets/dayjs-DOPU4UI6.js">
|
43 |
<link rel="modulepreload" crossorigin href="./assets/@braintree-DgpeZQRe.js">
|
44 |
<link rel="modulepreload" crossorigin href="./assets/d3-timer-keMr1twq.js">
|
@@ -57,7 +57,7 @@
|
|
57 |
<link rel="modulepreload" crossorigin href="./assets/elkjs-CmFeGg_o.js">
|
58 |
<link rel="modulepreload" crossorigin href="./assets/khroma-Ca6ZlOUT.js">
|
59 |
<link rel="modulepreload" crossorigin href="./assets/ua-parser-js-9pz7LJLQ.js">
|
60 |
-
<link rel="modulepreload" crossorigin href="./assets/@wdns-
|
61 |
<link rel="modulepreload" crossorigin href="./assets/ts-dedent-CttZBlkd.js">
|
62 |
<link rel="modulepreload" crossorigin href="./assets/stylis-Cl7w7uv3.js">
|
63 |
<link rel="modulepreload" crossorigin href="./assets/internmap-B8oPgqVZ.js">
|
@@ -71,9 +71,9 @@
|
|
71 |
<link rel="modulepreload" crossorigin href="./assets/layout-base-DqRk0Tgc.js">
|
72 |
<link rel="modulepreload" crossorigin href="./assets/cose-base-kQthUiMK.js">
|
73 |
<link rel="modulepreload" crossorigin href="./assets/cytoscape-cose-bilkent-CoOmxuE9.js">
|
74 |
-
<link rel="modulepreload" crossorigin href="./assets/mermaid-
|
75 |
-
<link rel="modulepreload" crossorigin href="./assets/@agoose77-
|
76 |
-
<link rel="modulepreload" crossorigin href="./assets/markdown-
|
77 |
<link rel="stylesheet" crossorigin href="./assets/tdesign-icons-vue-next-BGgy7GQY.css">
|
78 |
<link rel="stylesheet" crossorigin href="./assets/tdesign-vue-next-C9LLy99s.css">
|
79 |
<link rel="stylesheet" crossorigin href="./assets/popup-CAYf2pdU.css">
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8" />
|
5 |
<title>Popup</title>
|
6 |
+
<script type="module" crossorigin src="./assets/popup-fiphPf2R.js"></script>
|
7 |
<link rel="modulepreload" crossorigin href="./assets/core-js-pure-ZQ_YVJtv.js">
|
8 |
<link rel="modulepreload" crossorigin href="./assets/@babel-D5ZMb8W9.js">
|
9 |
<link rel="modulepreload" crossorigin href="./assets/lodash-Cky9m9r7.js">
|
|
|
37 |
<link rel="modulepreload" crossorigin href="./assets/markdown-it-C8SkdHr7.js">
|
38 |
<link rel="modulepreload" crossorigin href="./assets/katex-BY7yyeOs.js">
|
39 |
<link rel="modulepreload" crossorigin href="./assets/@traptitech-BPk2gen6.js">
|
40 |
+
<link rel="modulepreload" crossorigin href="./assets/highlight.js-Ds8M-WS2.js">
|
41 |
+
<link rel="modulepreload" crossorigin href="./assets/markdown-it-highlightjs-Ikc7oQsB.js">
|
42 |
<link rel="modulepreload" crossorigin href="./assets/dayjs-DOPU4UI6.js">
|
43 |
<link rel="modulepreload" crossorigin href="./assets/@braintree-DgpeZQRe.js">
|
44 |
<link rel="modulepreload" crossorigin href="./assets/d3-timer-keMr1twq.js">
|
|
|
57 |
<link rel="modulepreload" crossorigin href="./assets/elkjs-CmFeGg_o.js">
|
58 |
<link rel="modulepreload" crossorigin href="./assets/khroma-Ca6ZlOUT.js">
|
59 |
<link rel="modulepreload" crossorigin href="./assets/ua-parser-js-9pz7LJLQ.js">
|
60 |
+
<link rel="modulepreload" crossorigin href="./assets/@wdns-P0uM2sk1.js">
|
61 |
<link rel="modulepreload" crossorigin href="./assets/ts-dedent-CttZBlkd.js">
|
62 |
<link rel="modulepreload" crossorigin href="./assets/stylis-Cl7w7uv3.js">
|
63 |
<link rel="modulepreload" crossorigin href="./assets/internmap-B8oPgqVZ.js">
|
|
|
71 |
<link rel="modulepreload" crossorigin href="./assets/layout-base-DqRk0Tgc.js">
|
72 |
<link rel="modulepreload" crossorigin href="./assets/cose-base-kQthUiMK.js">
|
73 |
<link rel="modulepreload" crossorigin href="./assets/cytoscape-cose-bilkent-CoOmxuE9.js">
|
74 |
+
<link rel="modulepreload" crossorigin href="./assets/mermaid-B98QzgAP.js">
|
75 |
+
<link rel="modulepreload" crossorigin href="./assets/@agoose77-mGnNv_bd.js">
|
76 |
+
<link rel="modulepreload" crossorigin href="./assets/markdown-DPs5ApTw.js">
|
77 |
<link rel="stylesheet" crossorigin href="./assets/tdesign-icons-vue-next-BGgy7GQY.css">
|
78 |
<link rel="stylesheet" crossorigin href="./assets/tdesign-vue-next-C9LLy99s.css">
|
79 |
<link rel="stylesheet" crossorigin href="./assets/popup-CAYf2pdU.css">
|
.output/public/sw.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
// 缓存名称 - 更改版本号可以强制更新缓存
|
2 |
-
const CACHE_NAME = 'app-cache-
|
3 |
const ASSETS_PATTERN = /\/assets\//;
|
4 |
// 需要缓存的资源列表
|
5 |
const urlsToCache = [
|
|
|
1 |
// 缓存名称 - 更改版本号可以强制更新缓存
|
2 |
+
const CACHE_NAME = 'app-cache-v1741759359524';
|
3 |
const ASSETS_PATTERN = /\/assets\//;
|
4 |
// 需要缓存的资源列表
|
5 |
const urlsToCache = [
|
.output/server/chunks/nitro/nitro.mjs
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
.output/server/node_modules/@grpc/grpc-js/build/src/backoff-timeout.js
CHANGED
@@ -17,6 +17,9 @@
|
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
exports.BackoffTimeout = void 0;
|
|
|
|
|
|
|
20 |
const INITIAL_BACKOFF_MS = 1000;
|
21 |
const BACKOFF_MULTIPLIER = 1.6;
|
22 |
const MAX_BACKOFF_MS = 120000;
|
@@ -68,6 +71,7 @@ class BackoffTimeout {
|
|
68 |
* if running is true.
|
69 |
*/
|
70 |
this.endTime = new Date();
|
|
|
71 |
if (options) {
|
72 |
if (options.initialDelay) {
|
73 |
this.initialDelay = options.initialDelay;
|
@@ -82,16 +86,25 @@ class BackoffTimeout {
|
|
82 |
this.maxDelay = options.maxDelay;
|
83 |
}
|
84 |
}
|
|
|
85 |
this.nextDelay = this.initialDelay;
|
86 |
this.timerId = setTimeout(() => { }, 0);
|
87 |
clearTimeout(this.timerId);
|
88 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
runTimer(delay) {
|
90 |
var _a, _b;
|
|
|
91 |
this.endTime = this.startTime;
|
92 |
-
this.endTime.setMilliseconds(this.endTime.getMilliseconds() +
|
93 |
clearTimeout(this.timerId);
|
94 |
this.timerId = setTimeout(() => {
|
|
|
95 |
this.callback();
|
96 |
this.running = false;
|
97 |
}, delay);
|
@@ -103,6 +116,7 @@ class BackoffTimeout {
|
|
103 |
* Call the callback after the current amount of delay time
|
104 |
*/
|
105 |
runOnce() {
|
|
|
106 |
this.running = true;
|
107 |
this.startTime = new Date();
|
108 |
this.runTimer(this.nextDelay);
|
@@ -116,6 +130,7 @@ class BackoffTimeout {
|
|
116 |
* again.
|
117 |
*/
|
118 |
stop() {
|
|
|
119 |
clearTimeout(this.timerId);
|
120 |
this.running = false;
|
121 |
}
|
@@ -124,6 +139,7 @@ class BackoffTimeout {
|
|
124 |
* retroactively apply that reset to the current timer.
|
125 |
*/
|
126 |
reset() {
|
|
|
127 |
this.nextDelay = this.initialDelay;
|
128 |
if (this.running) {
|
129 |
const now = new Date();
|
@@ -171,4 +187,5 @@ class BackoffTimeout {
|
|
171 |
}
|
172 |
}
|
173 |
exports.BackoffTimeout = BackoffTimeout;
|
|
|
174 |
//# sourceMappingURL=backoff-timeout.js.map
|
|
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
exports.BackoffTimeout = void 0;
|
20 |
+
const constants_1 = require("./constants");
|
21 |
+
const logging = require("./logging");
|
22 |
+
const TRACER_NAME = 'backoff';
|
23 |
const INITIAL_BACKOFF_MS = 1000;
|
24 |
const BACKOFF_MULTIPLIER = 1.6;
|
25 |
const MAX_BACKOFF_MS = 120000;
|
|
|
71 |
* if running is true.
|
72 |
*/
|
73 |
this.endTime = new Date();
|
74 |
+
this.id = BackoffTimeout.getNextId();
|
75 |
if (options) {
|
76 |
if (options.initialDelay) {
|
77 |
this.initialDelay = options.initialDelay;
|
|
|
86 |
this.maxDelay = options.maxDelay;
|
87 |
}
|
88 |
}
|
89 |
+
this.trace('constructed initialDelay=' + this.initialDelay + ' multiplier=' + this.multiplier + ' jitter=' + this.jitter + ' maxDelay=' + this.maxDelay);
|
90 |
this.nextDelay = this.initialDelay;
|
91 |
this.timerId = setTimeout(() => { }, 0);
|
92 |
clearTimeout(this.timerId);
|
93 |
}
|
94 |
+
static getNextId() {
|
95 |
+
return this.nextId++;
|
96 |
+
}
|
97 |
+
trace(text) {
|
98 |
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, '{' + this.id + '} ' + text);
|
99 |
+
}
|
100 |
runTimer(delay) {
|
101 |
var _a, _b;
|
102 |
+
this.trace('runTimer(delay=' + delay + ')');
|
103 |
this.endTime = this.startTime;
|
104 |
+
this.endTime.setMilliseconds(this.endTime.getMilliseconds() + delay);
|
105 |
clearTimeout(this.timerId);
|
106 |
this.timerId = setTimeout(() => {
|
107 |
+
this.trace('timer fired');
|
108 |
this.callback();
|
109 |
this.running = false;
|
110 |
}, delay);
|
|
|
116 |
* Call the callback after the current amount of delay time
|
117 |
*/
|
118 |
runOnce() {
|
119 |
+
this.trace('runOnce()');
|
120 |
this.running = true;
|
121 |
this.startTime = new Date();
|
122 |
this.runTimer(this.nextDelay);
|
|
|
130 |
* again.
|
131 |
*/
|
132 |
stop() {
|
133 |
+
this.trace('stop()');
|
134 |
clearTimeout(this.timerId);
|
135 |
this.running = false;
|
136 |
}
|
|
|
139 |
* retroactively apply that reset to the current timer.
|
140 |
*/
|
141 |
reset() {
|
142 |
+
this.trace('reset() running=' + this.running);
|
143 |
this.nextDelay = this.initialDelay;
|
144 |
if (this.running) {
|
145 |
const now = new Date();
|
|
|
187 |
}
|
188 |
}
|
189 |
exports.BackoffTimeout = BackoffTimeout;
|
190 |
+
BackoffTimeout.nextId = 0;
|
191 |
//# sourceMappingURL=backoff-timeout.js.map
|
.output/server/node_modules/@grpc/grpc-js/build/src/certificate-provider.js
CHANGED
@@ -31,9 +31,9 @@ class FileWatcherCertificateProvider {
|
|
31 |
this.config = config;
|
32 |
this.refreshTimer = null;
|
33 |
this.fileResultPromise = null;
|
34 |
-
this.latestCaUpdate =
|
35 |
this.caListeners = new Set();
|
36 |
-
this.latestIdentityUpdate =
|
37 |
this.identityListeners = new Set();
|
38 |
this.lastUpdateTime = null;
|
39 |
if ((config.certificateFile === undefined) !== (config.privateKeyFile === undefined)) {
|
@@ -57,7 +57,7 @@ class FileWatcherCertificateProvider {
|
|
57 |
if (!this.refreshTimer) {
|
58 |
return;
|
59 |
}
|
60 |
-
trace('File watcher read certificates certificate' +
|
61 |
this.lastUpdateTime = new Date();
|
62 |
this.fileResultPromise = null;
|
63 |
if (certificateResult.status === 'fulfilled' && privateKeyResult.status === 'fulfilled') {
|
@@ -74,6 +74,9 @@ class FileWatcherCertificateProvider {
|
|
74 |
caCertificate: caCertificateResult.value
|
75 |
};
|
76 |
}
|
|
|
|
|
|
|
77 |
for (const listener of this.identityListeners) {
|
78 |
listener(this.latestIdentityUpdate);
|
79 |
}
|
@@ -95,8 +98,8 @@ class FileWatcherCertificateProvider {
|
|
95 |
}
|
96 |
if (timeSinceLastUpdate > this.config.refreshIntervalMs * 2) {
|
97 |
// Clear out old updates if they are definitely stale
|
98 |
-
this.latestCaUpdate =
|
99 |
-
this.latestIdentityUpdate =
|
100 |
}
|
101 |
this.refreshTimer = setInterval(() => this.updateCertificates(), this.config.refreshIntervalMs);
|
102 |
trace('File watcher started watching');
|
@@ -114,7 +117,9 @@ class FileWatcherCertificateProvider {
|
|
114 |
addCaCertificateListener(listener) {
|
115 |
this.caListeners.add(listener);
|
116 |
this.maybeStartWatchingFiles();
|
117 |
-
|
|
|
|
|
118 |
}
|
119 |
removeCaCertificateListener(listener) {
|
120 |
this.caListeners.delete(listener);
|
@@ -123,7 +128,9 @@ class FileWatcherCertificateProvider {
|
|
123 |
addIdentityCertificateListener(listener) {
|
124 |
this.identityListeners.add(listener);
|
125 |
this.maybeStartWatchingFiles();
|
126 |
-
|
|
|
|
|
127 |
}
|
128 |
removeIdentityCertificateListener(listener) {
|
129 |
this.identityListeners.delete(listener);
|
|
|
31 |
this.config = config;
|
32 |
this.refreshTimer = null;
|
33 |
this.fileResultPromise = null;
|
34 |
+
this.latestCaUpdate = undefined;
|
35 |
this.caListeners = new Set();
|
36 |
+
this.latestIdentityUpdate = undefined;
|
37 |
this.identityListeners = new Set();
|
38 |
this.lastUpdateTime = null;
|
39 |
if ((config.certificateFile === undefined) !== (config.privateKeyFile === undefined)) {
|
|
|
57 |
if (!this.refreshTimer) {
|
58 |
return;
|
59 |
}
|
60 |
+
trace('File watcher read certificates certificate ' + certificateResult.status + ', privateKey ' + privateKeyResult.status + ', CA certificate ' + caCertificateResult.status);
|
61 |
this.lastUpdateTime = new Date();
|
62 |
this.fileResultPromise = null;
|
63 |
if (certificateResult.status === 'fulfilled' && privateKeyResult.status === 'fulfilled') {
|
|
|
74 |
caCertificate: caCertificateResult.value
|
75 |
};
|
76 |
}
|
77 |
+
else {
|
78 |
+
this.latestCaUpdate = null;
|
79 |
+
}
|
80 |
for (const listener of this.identityListeners) {
|
81 |
listener(this.latestIdentityUpdate);
|
82 |
}
|
|
|
98 |
}
|
99 |
if (timeSinceLastUpdate > this.config.refreshIntervalMs * 2) {
|
100 |
// Clear out old updates if they are definitely stale
|
101 |
+
this.latestCaUpdate = undefined;
|
102 |
+
this.latestIdentityUpdate = undefined;
|
103 |
}
|
104 |
this.refreshTimer = setInterval(() => this.updateCertificates(), this.config.refreshIntervalMs);
|
105 |
trace('File watcher started watching');
|
|
|
117 |
addCaCertificateListener(listener) {
|
118 |
this.caListeners.add(listener);
|
119 |
this.maybeStartWatchingFiles();
|
120 |
+
if (this.latestCaUpdate !== undefined) {
|
121 |
+
process.nextTick(listener, this.latestCaUpdate);
|
122 |
+
}
|
123 |
}
|
124 |
removeCaCertificateListener(listener) {
|
125 |
this.caListeners.delete(listener);
|
|
|
128 |
addIdentityCertificateListener(listener) {
|
129 |
this.identityListeners.add(listener);
|
130 |
this.maybeStartWatchingFiles();
|
131 |
+
if (this.latestIdentityUpdate !== undefined) {
|
132 |
+
process.nextTick(listener, this.latestIdentityUpdate);
|
133 |
+
}
|
134 |
}
|
135 |
removeIdentityCertificateListener(listener) {
|
136 |
this.identityListeners.delete(listener);
|
.output/server/node_modules/@grpc/grpc-js/build/src/channel-credentials.js
CHANGED
@@ -21,6 +21,10 @@ exports.createCertificateProviderChannelCredentials = createCertificateProviderC
|
|
21 |
const tls_1 = require("tls");
|
22 |
const call_credentials_1 = require("./call-credentials");
|
23 |
const tls_helpers_1 = require("./tls-helpers");
|
|
|
|
|
|
|
|
|
24 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
25 |
function verifyIsBufferOrNull(obj, friendlyName) {
|
26 |
if (obj && !(obj instanceof Buffer)) {
|
@@ -33,20 +37,14 @@ function verifyIsBufferOrNull(obj, friendlyName) {
|
|
33 |
* over a channel initialized with an instance of this class.
|
34 |
*/
|
35 |
class ChannelCredentials {
|
36 |
-
constructor(callCredentials) {
|
37 |
-
this.callCredentials = callCredentials || call_credentials_1.CallCredentials.createEmpty();
|
38 |
-
}
|
39 |
/**
|
40 |
-
*
|
|
|
|
|
|
|
41 |
*/
|
42 |
-
|
43 |
-
return this
|
44 |
-
}
|
45 |
-
_ref() {
|
46 |
-
// Do nothing by default
|
47 |
-
}
|
48 |
-
_unref() {
|
49 |
-
// Do nothing by default
|
50 |
}
|
51 |
/**
|
52 |
* Return a new ChannelCredentials instance with a given set of credentials.
|
@@ -104,41 +102,116 @@ class InsecureChannelCredentialsImpl extends ChannelCredentials {
|
|
104 |
compose(callCredentials) {
|
105 |
throw new Error('Cannot compose insecure credentials');
|
106 |
}
|
107 |
-
_getConnectionOptions() {
|
108 |
-
return {};
|
109 |
-
}
|
110 |
_isSecure() {
|
111 |
return false;
|
112 |
}
|
113 |
_equals(other) {
|
114 |
return other instanceof InsecureChannelCredentialsImpl;
|
115 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
};
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
}
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
_isSecure() {
|
144 |
return true;
|
@@ -156,6 +229,10 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
|
156 |
return false;
|
157 |
}
|
158 |
}
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
class CertificateProviderChannelCredentialsImpl extends ChannelCredentials {
|
161 |
constructor(caCertificateProvider, identityCertificateProvider, verifyOptions) {
|
@@ -164,36 +241,19 @@ class CertificateProviderChannelCredentialsImpl extends ChannelCredentials {
|
|
164 |
this.identityCertificateProvider = identityCertificateProvider;
|
165 |
this.verifyOptions = verifyOptions;
|
166 |
this.refcount = 0;
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
this.caCertificateUpdateListener = this.handleCaCertificateUpdate.bind(this);
|
170 |
this.identityCertificateUpdateListener = this.handleIdentityCertitificateUpdate.bind(this);
|
171 |
-
|
172 |
-
compose(callCredentials) {
|
173 |
-
const combinedCallCredentials = this.callCredentials.compose(callCredentials);
|
174 |
-
return new ComposedChannelCredentialsImpl(this, combinedCallCredentials);
|
175 |
-
}
|
176 |
-
_getConnectionOptions() {
|
177 |
-
var _a, _b, _c;
|
178 |
-
if (this.latestCaUpdate === null) {
|
179 |
-
return null;
|
180 |
-
}
|
181 |
-
if (this.identityCertificateProvider !== null && this.latestIdentityUpdate === null) {
|
182 |
-
return null;
|
183 |
-
}
|
184 |
-
const secureContext = (0, tls_1.createSecureContext)({
|
185 |
-
ca: this.latestCaUpdate.caCertificate,
|
186 |
-
key: (_a = this.latestIdentityUpdate) === null || _a === void 0 ? void 0 : _a.privateKey,
|
187 |
-
cert: (_b = this.latestIdentityUpdate) === null || _b === void 0 ? void 0 : _b.certificate,
|
188 |
-
ciphers: tls_helpers_1.CIPHER_SUITES
|
189 |
-
});
|
190 |
-
const options = {
|
191 |
-
secureContext: secureContext
|
192 |
-
};
|
193 |
-
if ((_c = this.verifyOptions) === null || _c === void 0 ? void 0 : _c.checkServerIdentity) {
|
194 |
-
options.checkServerIdentity = this.verifyOptions.checkServerIdentity;
|
195 |
-
}
|
196 |
-
return options;
|
197 |
}
|
198 |
_isSecure() {
|
199 |
return true;
|
@@ -212,7 +272,7 @@ class CertificateProviderChannelCredentialsImpl extends ChannelCredentials {
|
|
212 |
return false;
|
213 |
}
|
214 |
}
|
215 |
-
|
216 |
var _a;
|
217 |
if (this.refcount === 0) {
|
218 |
this.caCertificateProvider.addCaCertificateListener(this.caCertificateUpdateListener);
|
@@ -220,7 +280,7 @@ class CertificateProviderChannelCredentialsImpl extends ChannelCredentials {
|
|
220 |
}
|
221 |
this.refcount += 1;
|
222 |
}
|
223 |
-
|
224 |
var _a;
|
225 |
this.refcount -= 1;
|
226 |
if (this.refcount === 0) {
|
@@ -228,20 +288,126 @@ class CertificateProviderChannelCredentialsImpl extends ChannelCredentials {
|
|
228 |
(_a = this.identityCertificateProvider) === null || _a === void 0 ? void 0 : _a.removeIdentityCertificateListener(this.identityCertificateUpdateListener);
|
229 |
}
|
230 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
handleCaCertificateUpdate(update) {
|
232 |
this.latestCaUpdate = update;
|
|
|
233 |
}
|
234 |
handleIdentityCertitificateUpdate(update) {
|
235 |
this.latestIdentityUpdate = update;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
}
|
237 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
function createCertificateProviderChannelCredentials(caCertificateProvider, identityCertificateProvider, verifyOptions) {
|
239 |
-
return new CertificateProviderChannelCredentialsImpl(caCertificateProvider, identityCertificateProvider, verifyOptions !== null && verifyOptions !== void 0 ? verifyOptions :
|
240 |
}
|
241 |
class ComposedChannelCredentialsImpl extends ChannelCredentials {
|
242 |
-
constructor(channelCredentials,
|
243 |
-
super(
|
244 |
this.channelCredentials = channelCredentials;
|
|
|
245 |
if (!channelCredentials._isSecure()) {
|
246 |
throw new Error('Cannot compose insecure credentials');
|
247 |
}
|
@@ -250,9 +416,6 @@ class ComposedChannelCredentialsImpl extends ChannelCredentials {
|
|
250 |
const combinedCallCredentials = this.callCredentials.compose(callCredentials);
|
251 |
return new ComposedChannelCredentialsImpl(this.channelCredentials, combinedCallCredentials);
|
252 |
}
|
253 |
-
_getConnectionOptions() {
|
254 |
-
return this.channelCredentials._getConnectionOptions();
|
255 |
-
}
|
256 |
_isSecure() {
|
257 |
return true;
|
258 |
}
|
@@ -268,5 +431,9 @@ class ComposedChannelCredentialsImpl extends ChannelCredentials {
|
|
268 |
return false;
|
269 |
}
|
270 |
}
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
//# sourceMappingURL=channel-credentials.js.map
|
|
|
21 |
const tls_1 = require("tls");
|
22 |
const call_credentials_1 = require("./call-credentials");
|
23 |
const tls_helpers_1 = require("./tls-helpers");
|
24 |
+
const uri_parser_1 = require("./uri-parser");
|
25 |
+
const resolver_1 = require("./resolver");
|
26 |
+
const logging_1 = require("./logging");
|
27 |
+
const constants_1 = require("./constants");
|
28 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
29 |
function verifyIsBufferOrNull(obj, friendlyName) {
|
30 |
if (obj && !(obj instanceof Buffer)) {
|
|
|
37 |
* over a channel initialized with an instance of this class.
|
38 |
*/
|
39 |
class ChannelCredentials {
|
|
|
|
|
|
|
40 |
/**
|
41 |
+
* Returns a copy of this object with the included set of per-call credentials
|
42 |
+
* expanded to include callCredentials.
|
43 |
+
* @param callCredentials A CallCredentials object to associate with this
|
44 |
+
* instance.
|
45 |
*/
|
46 |
+
compose(callCredentials) {
|
47 |
+
return new ComposedChannelCredentialsImpl(this, callCredentials);
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
/**
|
50 |
* Return a new ChannelCredentials instance with a given set of credentials.
|
|
|
102 |
compose(callCredentials) {
|
103 |
throw new Error('Cannot compose insecure credentials');
|
104 |
}
|
|
|
|
|
|
|
105 |
_isSecure() {
|
106 |
return false;
|
107 |
}
|
108 |
_equals(other) {
|
109 |
return other instanceof InsecureChannelCredentialsImpl;
|
110 |
}
|
111 |
+
_createSecureConnector(channelTarget, options, callCredentials) {
|
112 |
+
return {
|
113 |
+
connect(socket) {
|
114 |
+
return Promise.resolve({
|
115 |
+
socket,
|
116 |
+
secure: false
|
117 |
+
});
|
118 |
+
},
|
119 |
+
waitForReady: () => {
|
120 |
+
return Promise.resolve();
|
121 |
+
},
|
122 |
+
getCallCredentials: () => {
|
123 |
+
return callCredentials !== null && callCredentials !== void 0 ? callCredentials : call_credentials_1.CallCredentials.createEmpty();
|
124 |
+
},
|
125 |
+
destroy() { }
|
126 |
+
};
|
127 |
+
}
|
128 |
}
|
129 |
+
function getConnectionOptions(secureContext, verifyOptions, channelTarget, options) {
|
130 |
+
var _a, _b, _c, _d;
|
131 |
+
const connectionOptions = {
|
132 |
+
secureContext: secureContext
|
133 |
+
};
|
134 |
+
if (verifyOptions.checkServerIdentity) {
|
135 |
+
connectionOptions.checkServerIdentity = verifyOptions.checkServerIdentity;
|
136 |
+
}
|
137 |
+
if (verifyOptions.rejectUnauthorized !== undefined) {
|
138 |
+
connectionOptions.rejectUnauthorized = verifyOptions.rejectUnauthorized;
|
139 |
+
}
|
140 |
+
connectionOptions.ALPNProtocols = ['h2'];
|
141 |
+
if (options['grpc.ssl_target_name_override']) {
|
142 |
+
const sslTargetNameOverride = options['grpc.ssl_target_name_override'];
|
143 |
+
const originalCheckServerIdentity = (_a = connectionOptions.checkServerIdentity) !== null && _a !== void 0 ? _a : tls_1.checkServerIdentity;
|
144 |
+
connectionOptions.checkServerIdentity = (host, cert) => {
|
145 |
+
return originalCheckServerIdentity(sslTargetNameOverride, cert);
|
146 |
};
|
147 |
+
connectionOptions.servername = sslTargetNameOverride;
|
148 |
+
}
|
149 |
+
else {
|
150 |
+
if ('grpc.http_connect_target' in options) {
|
151 |
+
/* This is more or less how servername will be set in createSession
|
152 |
+
* if a connection is successfully established through the proxy.
|
153 |
+
* If the proxy is not used, these connectionOptions are discarded
|
154 |
+
* anyway */
|
155 |
+
const targetPath = (0, resolver_1.getDefaultAuthority)((_b = (0, uri_parser_1.parseUri)(options['grpc.http_connect_target'])) !== null && _b !== void 0 ? _b : {
|
156 |
+
path: 'localhost',
|
157 |
+
});
|
158 |
+
const hostPort = (0, uri_parser_1.splitHostPort)(targetPath);
|
159 |
+
connectionOptions.servername = (_c = hostPort === null || hostPort === void 0 ? void 0 : hostPort.host) !== null && _c !== void 0 ? _c : targetPath;
|
160 |
}
|
161 |
+
}
|
162 |
+
if (options['grpc-node.tls_enable_trace']) {
|
163 |
+
connectionOptions.enableTrace = true;
|
164 |
+
}
|
165 |
+
let realTarget = channelTarget;
|
166 |
+
if ('grpc.http_connect_target' in options) {
|
167 |
+
const parsedTarget = (0, uri_parser_1.parseUri)(options['grpc.http_connect_target']);
|
168 |
+
if (parsedTarget) {
|
169 |
+
realTarget = parsedTarget;
|
170 |
}
|
171 |
}
|
172 |
+
const targetPath = (0, resolver_1.getDefaultAuthority)(realTarget);
|
173 |
+
const hostPort = (0, uri_parser_1.splitHostPort)(targetPath);
|
174 |
+
const remoteHost = (_d = hostPort === null || hostPort === void 0 ? void 0 : hostPort.host) !== null && _d !== void 0 ? _d : targetPath;
|
175 |
+
connectionOptions.host = remoteHost;
|
176 |
+
connectionOptions.servername = remoteHost;
|
177 |
+
return connectionOptions;
|
178 |
+
}
|
179 |
+
class SecureConnectorImpl {
|
180 |
+
constructor(connectionOptions, callCredentials) {
|
181 |
+
this.connectionOptions = connectionOptions;
|
182 |
+
this.callCredentials = callCredentials;
|
183 |
+
}
|
184 |
+
connect(socket) {
|
185 |
+
const tlsConnectOptions = Object.assign({ socket: socket }, this.connectionOptions);
|
186 |
+
return new Promise((resolve, reject) => {
|
187 |
+
const tlsSocket = (0, tls_1.connect)(tlsConnectOptions, () => {
|
188 |
+
if (!tlsSocket.authorized) {
|
189 |
+
reject(tlsSocket.authorizationError);
|
190 |
+
return;
|
191 |
+
}
|
192 |
+
resolve({
|
193 |
+
socket: tlsSocket,
|
194 |
+
secure: true
|
195 |
+
});
|
196 |
+
});
|
197 |
+
tlsSocket.on('error', (error) => {
|
198 |
+
reject(error);
|
199 |
+
});
|
200 |
+
});
|
201 |
+
}
|
202 |
+
waitForReady() {
|
203 |
+
return Promise.resolve();
|
204 |
}
|
205 |
+
getCallCredentials() {
|
206 |
+
return this.callCredentials;
|
207 |
+
}
|
208 |
+
destroy() { }
|
209 |
+
}
|
210 |
+
class SecureChannelCredentialsImpl extends ChannelCredentials {
|
211 |
+
constructor(secureContext, verifyOptions) {
|
212 |
+
super();
|
213 |
+
this.secureContext = secureContext;
|
214 |
+
this.verifyOptions = verifyOptions;
|
215 |
}
|
216 |
_isSecure() {
|
217 |
return true;
|
|
|
229 |
return false;
|
230 |
}
|
231 |
}
|
232 |
+
_createSecureConnector(channelTarget, options, callCredentials) {
|
233 |
+
const connectionOptions = getConnectionOptions(this.secureContext, this.verifyOptions, channelTarget, options);
|
234 |
+
return new SecureConnectorImpl(connectionOptions, callCredentials !== null && callCredentials !== void 0 ? callCredentials : call_credentials_1.CallCredentials.createEmpty());
|
235 |
+
}
|
236 |
}
|
237 |
class CertificateProviderChannelCredentialsImpl extends ChannelCredentials {
|
238 |
constructor(caCertificateProvider, identityCertificateProvider, verifyOptions) {
|
|
|
241 |
this.identityCertificateProvider = identityCertificateProvider;
|
242 |
this.verifyOptions = verifyOptions;
|
243 |
this.refcount = 0;
|
244 |
+
/**
|
245 |
+
* `undefined` means that the certificates have not yet been loaded. `null`
|
246 |
+
* means that an attempt to load them has completed, and has failed.
|
247 |
+
*/
|
248 |
+
this.latestCaUpdate = undefined;
|
249 |
+
/**
|
250 |
+
* `undefined` means that the certificates have not yet been loaded. `null`
|
251 |
+
* means that an attempt to load them has completed, and has failed.
|
252 |
+
*/
|
253 |
+
this.latestIdentityUpdate = undefined;
|
254 |
this.caCertificateUpdateListener = this.handleCaCertificateUpdate.bind(this);
|
255 |
this.identityCertificateUpdateListener = this.handleIdentityCertitificateUpdate.bind(this);
|
256 |
+
this.secureContextWatchers = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
_isSecure() {
|
259 |
return true;
|
|
|
272 |
return false;
|
273 |
}
|
274 |
}
|
275 |
+
ref() {
|
276 |
var _a;
|
277 |
if (this.refcount === 0) {
|
278 |
this.caCertificateProvider.addCaCertificateListener(this.caCertificateUpdateListener);
|
|
|
280 |
}
|
281 |
this.refcount += 1;
|
282 |
}
|
283 |
+
unref() {
|
284 |
var _a;
|
285 |
this.refcount -= 1;
|
286 |
if (this.refcount === 0) {
|
|
|
288 |
(_a = this.identityCertificateProvider) === null || _a === void 0 ? void 0 : _a.removeIdentityCertificateListener(this.identityCertificateUpdateListener);
|
289 |
}
|
290 |
}
|
291 |
+
_createSecureConnector(channelTarget, options, callCredentials) {
|
292 |
+
this.ref();
|
293 |
+
return new CertificateProviderChannelCredentialsImpl.SecureConnectorImpl(this, channelTarget, options, callCredentials !== null && callCredentials !== void 0 ? callCredentials : call_credentials_1.CallCredentials.createEmpty());
|
294 |
+
}
|
295 |
+
maybeUpdateWatchers() {
|
296 |
+
if (this.hasReceivedUpdates()) {
|
297 |
+
for (const watcher of this.secureContextWatchers) {
|
298 |
+
watcher(this.getLatestSecureContext());
|
299 |
+
}
|
300 |
+
this.secureContextWatchers = [];
|
301 |
+
}
|
302 |
+
}
|
303 |
handleCaCertificateUpdate(update) {
|
304 |
this.latestCaUpdate = update;
|
305 |
+
this.maybeUpdateWatchers();
|
306 |
}
|
307 |
handleIdentityCertitificateUpdate(update) {
|
308 |
this.latestIdentityUpdate = update;
|
309 |
+
this.maybeUpdateWatchers();
|
310 |
+
}
|
311 |
+
hasReceivedUpdates() {
|
312 |
+
if (this.latestCaUpdate === undefined) {
|
313 |
+
return false;
|
314 |
+
}
|
315 |
+
if (this.identityCertificateProvider && this.latestIdentityUpdate === undefined) {
|
316 |
+
return false;
|
317 |
+
}
|
318 |
+
return true;
|
319 |
+
}
|
320 |
+
getSecureContext() {
|
321 |
+
if (this.hasReceivedUpdates()) {
|
322 |
+
return Promise.resolve(this.getLatestSecureContext());
|
323 |
+
}
|
324 |
+
else {
|
325 |
+
return new Promise(resolve => {
|
326 |
+
this.secureContextWatchers.push(resolve);
|
327 |
+
});
|
328 |
+
}
|
329 |
+
}
|
330 |
+
getLatestSecureContext() {
|
331 |
+
var _a, _b;
|
332 |
+
if (!this.latestCaUpdate) {
|
333 |
+
return null;
|
334 |
+
}
|
335 |
+
if (this.identityCertificateProvider !== null && !this.latestIdentityUpdate) {
|
336 |
+
return null;
|
337 |
+
}
|
338 |
+
try {
|
339 |
+
return (0, tls_1.createSecureContext)({
|
340 |
+
ca: this.latestCaUpdate.caCertificate,
|
341 |
+
key: (_a = this.latestIdentityUpdate) === null || _a === void 0 ? void 0 : _a.privateKey,
|
342 |
+
cert: (_b = this.latestIdentityUpdate) === null || _b === void 0 ? void 0 : _b.certificate,
|
343 |
+
ciphers: tls_helpers_1.CIPHER_SUITES
|
344 |
+
});
|
345 |
+
}
|
346 |
+
catch (e) {
|
347 |
+
(0, logging_1.log)(constants_1.LogVerbosity.ERROR, 'Failed to createSecureContext with error ' + e.message);
|
348 |
+
return null;
|
349 |
+
}
|
350 |
}
|
351 |
}
|
352 |
+
CertificateProviderChannelCredentialsImpl.SecureConnectorImpl = class {
|
353 |
+
constructor(parent, channelTarget, options, callCredentials) {
|
354 |
+
this.parent = parent;
|
355 |
+
this.channelTarget = channelTarget;
|
356 |
+
this.options = options;
|
357 |
+
this.callCredentials = callCredentials;
|
358 |
+
}
|
359 |
+
connect(socket) {
|
360 |
+
return new Promise((resolve, reject) => {
|
361 |
+
const secureContext = this.parent.getLatestSecureContext();
|
362 |
+
if (!secureContext) {
|
363 |
+
reject(new Error('Failed to load credentials'));
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
if (socket.closed) {
|
367 |
+
reject(new Error('Socket closed while loading credentials'));
|
368 |
+
}
|
369 |
+
const connnectionOptions = getConnectionOptions(secureContext, this.parent.verifyOptions, this.channelTarget, this.options);
|
370 |
+
const tlsConnectOptions = Object.assign({ socket: socket }, connnectionOptions);
|
371 |
+
const closeCallback = () => {
|
372 |
+
reject(new Error('Socket closed'));
|
373 |
+
};
|
374 |
+
const errorCallback = (error) => {
|
375 |
+
reject(error);
|
376 |
+
};
|
377 |
+
const tlsSocket = (0, tls_1.connect)(tlsConnectOptions, () => {
|
378 |
+
tlsSocket.removeListener('close', closeCallback);
|
379 |
+
tlsSocket.removeListener('error', errorCallback);
|
380 |
+
if (!tlsSocket.authorized) {
|
381 |
+
reject(tlsSocket.authorizationError);
|
382 |
+
return;
|
383 |
+
}
|
384 |
+
resolve({
|
385 |
+
socket: tlsSocket,
|
386 |
+
secure: true
|
387 |
+
});
|
388 |
+
});
|
389 |
+
tlsSocket.once('close', closeCallback);
|
390 |
+
tlsSocket.once('error', errorCallback);
|
391 |
+
});
|
392 |
+
}
|
393 |
+
async waitForReady() {
|
394 |
+
await this.parent.getSecureContext();
|
395 |
+
}
|
396 |
+
getCallCredentials() {
|
397 |
+
return this.callCredentials;
|
398 |
+
}
|
399 |
+
destroy() {
|
400 |
+
this.parent.unref();
|
401 |
+
}
|
402 |
+
};
|
403 |
function createCertificateProviderChannelCredentials(caCertificateProvider, identityCertificateProvider, verifyOptions) {
|
404 |
+
return new CertificateProviderChannelCredentialsImpl(caCertificateProvider, identityCertificateProvider, verifyOptions !== null && verifyOptions !== void 0 ? verifyOptions : {});
|
405 |
}
|
406 |
class ComposedChannelCredentialsImpl extends ChannelCredentials {
|
407 |
+
constructor(channelCredentials, callCredentials) {
|
408 |
+
super();
|
409 |
this.channelCredentials = channelCredentials;
|
410 |
+
this.callCredentials = callCredentials;
|
411 |
if (!channelCredentials._isSecure()) {
|
412 |
throw new Error('Cannot compose insecure credentials');
|
413 |
}
|
|
|
416 |
const combinedCallCredentials = this.callCredentials.compose(callCredentials);
|
417 |
return new ComposedChannelCredentialsImpl(this.channelCredentials, combinedCallCredentials);
|
418 |
}
|
|
|
|
|
|
|
419 |
_isSecure() {
|
420 |
return true;
|
421 |
}
|
|
|
431 |
return false;
|
432 |
}
|
433 |
}
|
434 |
+
_createSecureConnector(channelTarget, options, callCredentials) {
|
435 |
+
const combinedCallCredentials = this.callCredentials.compose(callCredentials !== null && callCredentials !== void 0 ? callCredentials : call_credentials_1.CallCredentials.createEmpty());
|
436 |
+
return this.channelCredentials._createSecureConnector(channelTarget, options, combinedCallCredentials);
|
437 |
+
}
|
438 |
}
|
439 |
//# sourceMappingURL=channel-credentials.js.map
|
.output/server/node_modules/@grpc/grpc-js/build/src/channel-options.js
CHANGED
@@ -51,6 +51,7 @@ exports.recognizedOptions = {
|
|
51 |
'grpc-node.tls_enable_trace': true,
|
52 |
'grpc.lb.ring_hash.ring_size_cap': true,
|
53 |
'grpc-node.retry_max_attempts_limit': true,
|
|
|
54 |
};
|
55 |
function channelOptionsEqual(options1, options2) {
|
56 |
const keys1 = Object.keys(options1).sort();
|
|
|
51 |
'grpc-node.tls_enable_trace': true,
|
52 |
'grpc.lb.ring_hash.ring_size_cap': true,
|
53 |
'grpc-node.retry_max_attempts_limit': true,
|
54 |
+
'grpc-node.flow_control_window': true,
|
55 |
};
|
56 |
function channelOptionsEqual(options1, options2) {
|
57 |
const keys1 = Object.keys(options1).sort();
|
.output/server/node_modules/@grpc/grpc-js/build/src/channelz.js
CHANGED
@@ -246,6 +246,17 @@ function parseIPv6Chunk(addressChunk) {
|
|
246 |
const result = [];
|
247 |
return result.concat(...bytePairs);
|
248 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
/**
|
250 |
* Converts an IPv4 or IPv6 address from string representation to binary
|
251 |
* representation
|
@@ -254,7 +265,10 @@ function parseIPv6Chunk(addressChunk) {
|
|
254 |
*/
|
255 |
function ipAddressStringToBuffer(ipAddress) {
|
256 |
if ((0, net_1.isIPv4)(ipAddress)) {
|
257 |
-
return
|
|
|
|
|
|
|
258 |
}
|
259 |
else if ((0, net_1.isIPv6)(ipAddress)) {
|
260 |
let leftSection;
|
|
|
246 |
const result = [];
|
247 |
return result.concat(...bytePairs);
|
248 |
}
|
249 |
+
function isIPv6MappedIPv4(ipAddress) {
|
250 |
+
return (0, net_1.isIPv6)(ipAddress) && ipAddress.toLowerCase().startsWith('::ffff:') && (0, net_1.isIPv4)(ipAddress.substring(7));
|
251 |
+
}
|
252 |
+
/**
|
253 |
+
* Prerequisite: isIPv4(ipAddress)
|
254 |
+
* @param ipAddress
|
255 |
+
* @returns
|
256 |
+
*/
|
257 |
+
function ipv4AddressStringToBuffer(ipAddress) {
|
258 |
+
return Buffer.from(Uint8Array.from(ipAddress.split('.').map(segment => Number.parseInt(segment))));
|
259 |
+
}
|
260 |
/**
|
261 |
* Converts an IPv4 or IPv6 address from string representation to binary
|
262 |
* representation
|
|
|
265 |
*/
|
266 |
function ipAddressStringToBuffer(ipAddress) {
|
267 |
if ((0, net_1.isIPv4)(ipAddress)) {
|
268 |
+
return ipv4AddressStringToBuffer(ipAddress);
|
269 |
+
}
|
270 |
+
else if (isIPv6MappedIPv4(ipAddress)) {
|
271 |
+
return ipv4AddressStringToBuffer(ipAddress.substring(7));
|
272 |
}
|
273 |
else if ((0, net_1.isIPv6)(ipAddress)) {
|
274 |
let leftSection;
|
.output/server/node_modules/@grpc/grpc-js/build/src/experimental.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
"use strict";
|
2 |
Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
-
exports.createCertificateProviderChannelCredentials = exports.FileWatcherCertificateProvider = exports.createCertificateProviderServerCredentials = exports.createServerCredentialsWithInterceptors = exports.BaseSubchannelWrapper = exports.registerAdminService = exports.FilterStackFactory = exports.BaseFilter = exports.PickResultType = exports.QueuePicker = exports.UnavailablePicker = exports.ChildLoadBalancerHandler = exports.EndpointMap = exports.endpointHasAddress = exports.endpointToString = exports.subchannelAddressToString = exports.LeafLoadBalancer = exports.isLoadBalancerNameRegistered = exports.parseLoadBalancingConfig = exports.selectLbConfigFromList = exports.registerLoadBalancerType = exports.createChildChannelControlHelper = exports.BackoffTimeout = exports.parseDuration = exports.durationToMs = exports.splitHostPort = exports.uriToString = exports.createResolver = exports.registerResolver = exports.log = exports.trace = void 0;
|
4 |
var logging_1 = require("./logging");
|
5 |
Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return logging_1.trace; } });
|
6 |
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logging_1.log; } });
|
@@ -49,4 +49,6 @@ var certificate_provider_1 = require("./certificate-provider");
|
|
49 |
Object.defineProperty(exports, "FileWatcherCertificateProvider", { enumerable: true, get: function () { return certificate_provider_1.FileWatcherCertificateProvider; } });
|
50 |
var channel_credentials_1 = require("./channel-credentials");
|
51 |
Object.defineProperty(exports, "createCertificateProviderChannelCredentials", { enumerable: true, get: function () { return channel_credentials_1.createCertificateProviderChannelCredentials; } });
|
|
|
|
|
52 |
//# sourceMappingURL=experimental.js.map
|
|
|
1 |
"use strict";
|
2 |
Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
+
exports.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX = exports.createCertificateProviderChannelCredentials = exports.FileWatcherCertificateProvider = exports.createCertificateProviderServerCredentials = exports.createServerCredentialsWithInterceptors = exports.BaseSubchannelWrapper = exports.registerAdminService = exports.FilterStackFactory = exports.BaseFilter = exports.PickResultType = exports.QueuePicker = exports.UnavailablePicker = exports.ChildLoadBalancerHandler = exports.EndpointMap = exports.endpointHasAddress = exports.endpointToString = exports.subchannelAddressToString = exports.LeafLoadBalancer = exports.isLoadBalancerNameRegistered = exports.parseLoadBalancingConfig = exports.selectLbConfigFromList = exports.registerLoadBalancerType = exports.createChildChannelControlHelper = exports.BackoffTimeout = exports.parseDuration = exports.durationToMs = exports.splitHostPort = exports.uriToString = exports.createResolver = exports.registerResolver = exports.log = exports.trace = void 0;
|
4 |
var logging_1 = require("./logging");
|
5 |
Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return logging_1.trace; } });
|
6 |
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logging_1.log; } });
|
|
|
49 |
Object.defineProperty(exports, "FileWatcherCertificateProvider", { enumerable: true, get: function () { return certificate_provider_1.FileWatcherCertificateProvider; } });
|
50 |
var channel_credentials_1 = require("./channel-credentials");
|
51 |
Object.defineProperty(exports, "createCertificateProviderChannelCredentials", { enumerable: true, get: function () { return channel_credentials_1.createCertificateProviderChannelCredentials; } });
|
52 |
+
var internal_channel_1 = require("./internal-channel");
|
53 |
+
Object.defineProperty(exports, "SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX", { enumerable: true, get: function () { return internal_channel_1.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX; } });
|
54 |
//# sourceMappingURL=experimental.js.map
|
.output/server/node_modules/@grpc/grpc-js/build/src/http_proxy.js
CHANGED
@@ -16,13 +16,13 @@
|
|
16 |
*
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19 |
exports.mapProxyName = mapProxyName;
|
20 |
exports.getProxiedConnection = getProxiedConnection;
|
21 |
const logging_1 = require("./logging");
|
22 |
const constants_1 = require("./constants");
|
23 |
-
const
|
24 |
const http = require("http");
|
25 |
-
const tls = require("tls");
|
26 |
const logging = require("./logging");
|
27 |
const subchannel_address_1 = require("./subchannel-address");
|
28 |
const uri_parser_1 = require("./uri-parser");
|
@@ -109,6 +109,48 @@ function getNoProxyHostList() {
|
|
109 |
return [];
|
110 |
}
|
111 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
function mapProxyName(target, options) {
|
113 |
var _a;
|
114 |
const noProxyResult = {
|
@@ -130,11 +172,9 @@ function mapProxyName(target, options) {
|
|
130 |
return noProxyResult;
|
131 |
}
|
132 |
const serverHost = hostPort.host;
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
return noProxyResult;
|
137 |
-
}
|
138 |
}
|
139 |
const extraOptions = {
|
140 |
'grpc.http_connect_target': (0, uri_parser_1.uriToString)(target),
|
@@ -150,19 +190,19 @@ function mapProxyName(target, options) {
|
|
150 |
extraOptions: extraOptions,
|
151 |
};
|
152 |
}
|
153 |
-
function getProxiedConnection(address, channelOptions
|
154 |
var _a;
|
155 |
if (!('grpc.http_connect_target' in channelOptions)) {
|
156 |
-
return Promise.resolve(
|
157 |
}
|
158 |
const realTarget = channelOptions['grpc.http_connect_target'];
|
159 |
const parsedTarget = (0, uri_parser_1.parseUri)(realTarget);
|
160 |
if (parsedTarget === null) {
|
161 |
-
return Promise.resolve(
|
162 |
}
|
163 |
const splitHostPost = (0, uri_parser_1.splitHostPort)(parsedTarget.path);
|
164 |
if (splitHostPost === null) {
|
165 |
-
return Promise.resolve(
|
166 |
}
|
167 |
const hostPort = `${splitHostPost.host}:${(_a = splitHostPost.port) !== null && _a !== void 0 ? _a : resolver_dns_1.DEFAULT_PORT}`;
|
168 |
const options = {
|
@@ -191,7 +231,6 @@ function getProxiedConnection(address, channelOptions, connectionOptions) {
|
|
191 |
return new Promise((resolve, reject) => {
|
192 |
const request = http.request(options);
|
193 |
request.once('connect', (res, socket, head) => {
|
194 |
-
var _a;
|
195 |
request.removeAllListeners();
|
196 |
socket.removeAllListeners();
|
197 |
if (res.statusCode === 200) {
|
@@ -205,41 +244,11 @@ function getProxiedConnection(address, channelOptions, connectionOptions) {
|
|
205 |
if (head.length > 0) {
|
206 |
socket.unshift(head);
|
207 |
}
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
const targetPath = (0, resolver_1.getDefaultAuthority)(parsedTarget);
|
214 |
-
const hostPort = (0, uri_parser_1.splitHostPort)(targetPath);
|
215 |
-
const remoteHost = (_a = hostPort === null || hostPort === void 0 ? void 0 : hostPort.host) !== null && _a !== void 0 ? _a : targetPath;
|
216 |
-
const cts = tls.connect(Object.assign({ host: remoteHost, servername: remoteHost, socket: socket }, connectionOptions), () => {
|
217 |
-
trace('Successfully established a TLS connection to ' +
|
218 |
-
options.path +
|
219 |
-
' through proxy ' +
|
220 |
-
proxyAddressString);
|
221 |
-
resolve({ socket: cts, realTarget: parsedTarget });
|
222 |
-
});
|
223 |
-
cts.on('error', (error) => {
|
224 |
-
trace('Failed to establish a TLS connection to ' +
|
225 |
-
options.path +
|
226 |
-
' through proxy ' +
|
227 |
-
proxyAddressString +
|
228 |
-
' with error ' +
|
229 |
-
error.message);
|
230 |
-
reject();
|
231 |
-
});
|
232 |
-
}
|
233 |
-
else {
|
234 |
-
trace('Successfully established a plaintext connection to ' +
|
235 |
-
options.path +
|
236 |
-
' through proxy ' +
|
237 |
-
proxyAddressString);
|
238 |
-
resolve({
|
239 |
-
socket,
|
240 |
-
realTarget: parsedTarget,
|
241 |
-
});
|
242 |
-
}
|
243 |
}
|
244 |
else {
|
245 |
(0, logging_1.log)(constants_1.LogVerbosity.ERROR, 'Failed to connect to ' +
|
|
|
16 |
*
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
+
exports.parseCIDR = parseCIDR;
|
20 |
exports.mapProxyName = mapProxyName;
|
21 |
exports.getProxiedConnection = getProxiedConnection;
|
22 |
const logging_1 = require("./logging");
|
23 |
const constants_1 = require("./constants");
|
24 |
+
const net_1 = require("net");
|
25 |
const http = require("http");
|
|
|
26 |
const logging = require("./logging");
|
27 |
const subchannel_address_1 = require("./subchannel-address");
|
28 |
const uri_parser_1 = require("./uri-parser");
|
|
|
109 |
return [];
|
110 |
}
|
111 |
}
|
112 |
+
/*
|
113 |
+
* The groups correspond to CIDR parts as follows:
|
114 |
+
* 1. ip
|
115 |
+
* 2. prefixLength
|
116 |
+
*/
|
117 |
+
function parseCIDR(cidrString) {
|
118 |
+
const splitRange = cidrString.split('/');
|
119 |
+
if (splitRange.length !== 2) {
|
120 |
+
return null;
|
121 |
+
}
|
122 |
+
const prefixLength = parseInt(splitRange[1], 10);
|
123 |
+
if (!(0, net_1.isIPv4)(splitRange[0]) || Number.isNaN(prefixLength) || prefixLength < 0 || prefixLength > 32) {
|
124 |
+
return null;
|
125 |
+
}
|
126 |
+
return {
|
127 |
+
ip: ipToInt(splitRange[0]),
|
128 |
+
prefixLength: prefixLength
|
129 |
+
};
|
130 |
+
}
|
131 |
+
function ipToInt(ip) {
|
132 |
+
return ip.split(".").reduce((acc, octet) => (acc << 8) + parseInt(octet, 10), 0);
|
133 |
+
}
|
134 |
+
function isIpInCIDR(cidr, serverHost) {
|
135 |
+
const ip = cidr.ip;
|
136 |
+
const mask = -1 << (32 - cidr.prefixLength);
|
137 |
+
const hostIP = ipToInt(serverHost);
|
138 |
+
return (hostIP & mask) === (ip & mask);
|
139 |
+
}
|
140 |
+
function hostMatchesNoProxyList(serverHost) {
|
141 |
+
for (const host of getNoProxyHostList()) {
|
142 |
+
const parsedCIDR = parseCIDR(host);
|
143 |
+
// host is a CIDR and serverHost is an IP address
|
144 |
+
if ((0, net_1.isIPv4)(serverHost) && parsedCIDR && isIpInCIDR(parsedCIDR, serverHost)) {
|
145 |
+
return true;
|
146 |
+
}
|
147 |
+
else if (serverHost.endsWith(host)) {
|
148 |
+
// host is a single IP or a domain name suffix
|
149 |
+
return true;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
return false;
|
153 |
+
}
|
154 |
function mapProxyName(target, options) {
|
155 |
var _a;
|
156 |
const noProxyResult = {
|
|
|
172 |
return noProxyResult;
|
173 |
}
|
174 |
const serverHost = hostPort.host;
|
175 |
+
if (hostMatchesNoProxyList(serverHost)) {
|
176 |
+
trace('Not using proxy for target in no_proxy list: ' + (0, uri_parser_1.uriToString)(target));
|
177 |
+
return noProxyResult;
|
|
|
|
|
178 |
}
|
179 |
const extraOptions = {
|
180 |
'grpc.http_connect_target': (0, uri_parser_1.uriToString)(target),
|
|
|
190 |
extraOptions: extraOptions,
|
191 |
};
|
192 |
}
|
193 |
+
function getProxiedConnection(address, channelOptions) {
|
194 |
var _a;
|
195 |
if (!('grpc.http_connect_target' in channelOptions)) {
|
196 |
+
return Promise.resolve(null);
|
197 |
}
|
198 |
const realTarget = channelOptions['grpc.http_connect_target'];
|
199 |
const parsedTarget = (0, uri_parser_1.parseUri)(realTarget);
|
200 |
if (parsedTarget === null) {
|
201 |
+
return Promise.resolve(null);
|
202 |
}
|
203 |
const splitHostPost = (0, uri_parser_1.splitHostPort)(parsedTarget.path);
|
204 |
if (splitHostPost === null) {
|
205 |
+
return Promise.resolve(null);
|
206 |
}
|
207 |
const hostPort = `${splitHostPost.host}:${(_a = splitHostPost.port) !== null && _a !== void 0 ? _a : resolver_dns_1.DEFAULT_PORT}`;
|
208 |
const options = {
|
|
|
231 |
return new Promise((resolve, reject) => {
|
232 |
const request = http.request(options);
|
233 |
request.once('connect', (res, socket, head) => {
|
|
|
234 |
request.removeAllListeners();
|
235 |
socket.removeAllListeners();
|
236 |
if (res.statusCode === 200) {
|
|
|
244 |
if (head.length > 0) {
|
245 |
socket.unshift(head);
|
246 |
}
|
247 |
+
trace('Successfully established a plaintext connection to ' +
|
248 |
+
options.path +
|
249 |
+
' through proxy ' +
|
250 |
+
proxyAddressString);
|
251 |
+
resolve(socket);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
else {
|
254 |
(0, logging_1.log)(constants_1.LogVerbosity.ERROR, 'Failed to connect to ' +
|
.output/server/node_modules/@grpc/grpc-js/build/src/internal-channel.js
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
-
exports.InternalChannel = void 0;
|
20 |
const channel_credentials_1 = require("./channel-credentials");
|
21 |
const resolving_load_balancer_1 = require("./resolving-load-balancer");
|
22 |
const subchannel_pool_1 = require("./subchannel-pool");
|
@@ -89,6 +89,7 @@ class ShutdownPicker {
|
|
89 |
};
|
90 |
}
|
91 |
}
|
|
|
92 |
class ChannelzInfoTracker {
|
93 |
constructor(target) {
|
94 |
this.target = target;
|
@@ -197,8 +198,14 @@ class InternalChannel {
|
|
197 |
this.keepaliveTime = (_d = options['grpc.keepalive_time_ms']) !== null && _d !== void 0 ? _d : -1;
|
198 |
this.idleTimeoutMs = Math.max((_e = options['grpc.client_idle_timeout_ms']) !== null && _e !== void 0 ? _e : DEFAULT_IDLE_TIMEOUT_MS, MIN_IDLE_TIMEOUT_MS);
|
199 |
const channelControlHelper = {
|
200 |
-
createSubchannel: (subchannelAddress, subchannelArgs
|
201 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
subchannel.throttleKeepalive(this.keepaliveTime);
|
203 |
if (this.channelzEnabled) {
|
204 |
this.channelzInfoTracker.trace.addTrace('CT_INFO', 'Created subchannel or used existing subchannel', subchannel.getChannelzRef());
|
@@ -233,7 +240,8 @@ class InternalChannel {
|
|
233 |
}
|
234 |
},
|
235 |
};
|
236 |
-
this.resolvingLoadBalancer = new resolving_load_balancer_1.ResolvingLoadBalancer(this.target, channelControlHelper,
|
|
|
237 |
if (serviceConfig.retryThrottling) {
|
238 |
RETRY_THROTTLER_MAP.set(this.getTarget(), new retrying_call_1.RetryThrottler(serviceConfig.retryThrottling.maxTokens, serviceConfig.retryThrottling.tokenRatio, RETRY_THROTTLER_MAP.get(this.getTarget())));
|
239 |
}
|
@@ -243,6 +251,7 @@ class InternalChannel {
|
|
243 |
if (this.channelzEnabled) {
|
244 |
this.channelzInfoTracker.trace.addTrace('CT_INFO', 'Address resolution succeeded');
|
245 |
}
|
|
|
246 |
this.configSelector = configSelector;
|
247 |
this.currentResolutionError = null;
|
248 |
/* We process the queue asynchronously to ensure that the corresponding
|
@@ -388,7 +397,7 @@ class InternalChannel {
|
|
388 |
if (this.configSelector) {
|
389 |
return {
|
390 |
type: 'SUCCESS',
|
391 |
-
config: this.configSelector(method, metadata, this.randomChannelId),
|
392 |
};
|
393 |
}
|
394 |
else {
|
@@ -485,15 +494,6 @@ class InternalChannel {
|
|
485 |
this.trace('createRetryingCall [' + callNumber + '] method="' + method + '"');
|
486 |
return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, callNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget()));
|
487 |
}
|
488 |
-
createInnerCall(callConfig, method, host, credentials, deadline) {
|
489 |
-
// Create a RetryingCall if retries are enabled
|
490 |
-
if (this.options['grpc.enable_retries'] === 0) {
|
491 |
-
return this.createLoadBalancingCall(callConfig, method, host, credentials, deadline);
|
492 |
-
}
|
493 |
-
else {
|
494 |
-
return this.createRetryingCall(callConfig, method, host, credentials, deadline);
|
495 |
-
}
|
496 |
-
}
|
497 |
createResolvingCall(method, deadline, host, parentCall, propagateFlags) {
|
498 |
const callNumber = (0, call_number_1.getNextCallNumber)();
|
499 |
this.trace('createResolvingCall [' +
|
@@ -508,7 +508,7 @@ class InternalChannel {
|
|
508 |
host: host !== null && host !== void 0 ? host : this.defaultAuthority,
|
509 |
parentCall: parentCall,
|
510 |
};
|
511 |
-
const call = new resolving_call_1.ResolvingCall(this, method, finalOptions, this.filterStackFactory.clone(),
|
512 |
this.onCallStart();
|
513 |
call.addStatusWatcher(status => {
|
514 |
this.onCallEnd(status);
|
@@ -516,6 +516,7 @@ class InternalChannel {
|
|
516 |
return call;
|
517 |
}
|
518 |
close() {
|
|
|
519 |
this.resolvingLoadBalancer.destroy();
|
520 |
this.updateState(connectivity_state_1.ConnectivityState.SHUTDOWN);
|
521 |
this.currentPicker = new ShutdownPicker();
|
@@ -537,6 +538,8 @@ class InternalChannel {
|
|
537 |
(0, channelz_1.unregisterChannelzRef)(this.channelzRef);
|
538 |
}
|
539 |
this.subchannelPool.unrefUnusedSubchannels();
|
|
|
|
|
540 |
}
|
541 |
getTarget() {
|
542 |
return (0, uri_parser_1.uriToString)(this.target);
|
|
|
16 |
*
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
+
exports.InternalChannel = exports.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX = void 0;
|
20 |
const channel_credentials_1 = require("./channel-credentials");
|
21 |
const resolving_load_balancer_1 = require("./resolving-load-balancer");
|
22 |
const subchannel_pool_1 = require("./subchannel-pool");
|
|
|
89 |
};
|
90 |
}
|
91 |
}
|
92 |
+
exports.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX = 'grpc.internal.no_subchannel';
|
93 |
class ChannelzInfoTracker {
|
94 |
constructor(target) {
|
95 |
this.target = target;
|
|
|
198 |
this.keepaliveTime = (_d = options['grpc.keepalive_time_ms']) !== null && _d !== void 0 ? _d : -1;
|
199 |
this.idleTimeoutMs = Math.max((_e = options['grpc.client_idle_timeout_ms']) !== null && _e !== void 0 ? _e : DEFAULT_IDLE_TIMEOUT_MS, MIN_IDLE_TIMEOUT_MS);
|
200 |
const channelControlHelper = {
|
201 |
+
createSubchannel: (subchannelAddress, subchannelArgs) => {
|
202 |
+
const finalSubchannelArgs = {};
|
203 |
+
for (const [key, value] of Object.entries(subchannelArgs)) {
|
204 |
+
if (!key.startsWith(exports.SUBCHANNEL_ARGS_EXCLUDE_KEY_PREFIX)) {
|
205 |
+
finalSubchannelArgs[key] = value;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
const subchannel = this.subchannelPool.getOrCreateSubchannel(this.target, subchannelAddress, finalSubchannelArgs, this.credentials);
|
209 |
subchannel.throttleKeepalive(this.keepaliveTime);
|
210 |
if (this.channelzEnabled) {
|
211 |
this.channelzInfoTracker.trace.addTrace('CT_INFO', 'Created subchannel or used existing subchannel', subchannel.getChannelzRef());
|
|
|
240 |
}
|
241 |
},
|
242 |
};
|
243 |
+
this.resolvingLoadBalancer = new resolving_load_balancer_1.ResolvingLoadBalancer(this.target, channelControlHelper, options, (serviceConfig, configSelector) => {
|
244 |
+
var _a;
|
245 |
if (serviceConfig.retryThrottling) {
|
246 |
RETRY_THROTTLER_MAP.set(this.getTarget(), new retrying_call_1.RetryThrottler(serviceConfig.retryThrottling.maxTokens, serviceConfig.retryThrottling.tokenRatio, RETRY_THROTTLER_MAP.get(this.getTarget())));
|
247 |
}
|
|
|
251 |
if (this.channelzEnabled) {
|
252 |
this.channelzInfoTracker.trace.addTrace('CT_INFO', 'Address resolution succeeded');
|
253 |
}
|
254 |
+
(_a = this.configSelector) === null || _a === void 0 ? void 0 : _a.unref();
|
255 |
this.configSelector = configSelector;
|
256 |
this.currentResolutionError = null;
|
257 |
/* We process the queue asynchronously to ensure that the corresponding
|
|
|
397 |
if (this.configSelector) {
|
398 |
return {
|
399 |
type: 'SUCCESS',
|
400 |
+
config: this.configSelector.invoke(method, metadata, this.randomChannelId),
|
401 |
};
|
402 |
}
|
403 |
else {
|
|
|
494 |
this.trace('createRetryingCall [' + callNumber + '] method="' + method + '"');
|
495 |
return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, callNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget()));
|
496 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
createResolvingCall(method, deadline, host, parentCall, propagateFlags) {
|
498 |
const callNumber = (0, call_number_1.getNextCallNumber)();
|
499 |
this.trace('createResolvingCall [' +
|
|
|
508 |
host: host !== null && host !== void 0 ? host : this.defaultAuthority,
|
509 |
parentCall: parentCall,
|
510 |
};
|
511 |
+
const call = new resolving_call_1.ResolvingCall(this, method, finalOptions, this.filterStackFactory.clone(), callNumber);
|
512 |
this.onCallStart();
|
513 |
call.addStatusWatcher(status => {
|
514 |
this.onCallEnd(status);
|
|
|
516 |
return call;
|
517 |
}
|
518 |
close() {
|
519 |
+
var _a;
|
520 |
this.resolvingLoadBalancer.destroy();
|
521 |
this.updateState(connectivity_state_1.ConnectivityState.SHUTDOWN);
|
522 |
this.currentPicker = new ShutdownPicker();
|
|
|
538 |
(0, channelz_1.unregisterChannelzRef)(this.channelzRef);
|
539 |
}
|
540 |
this.subchannelPool.unrefUnusedSubchannels();
|
541 |
+
(_a = this.configSelector) === null || _a === void 0 ? void 0 : _a.unref();
|
542 |
+
this.configSelector = null;
|
543 |
}
|
544 |
getTarget() {
|
545 |
return (0, uri_parser_1.uriToString)(this.target);
|
.output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-child-handler.js
CHANGED
@@ -21,10 +21,8 @@ const load_balancer_1 = require("./load-balancer");
|
|
21 |
const connectivity_state_1 = require("./connectivity-state");
|
22 |
const TYPE_NAME = 'child_load_balancer_helper';
|
23 |
class ChildLoadBalancerHandler {
|
24 |
-
constructor(channelControlHelper
|
25 |
this.channelControlHelper = channelControlHelper;
|
26 |
-
this.credentials = credentials;
|
27 |
-
this.options = options;
|
28 |
this.currentChild = null;
|
29 |
this.pendingChild = null;
|
30 |
this.latestConfig = null;
|
@@ -33,10 +31,10 @@ class ChildLoadBalancerHandler {
|
|
33 |
this.parent = parent;
|
34 |
this.child = null;
|
35 |
}
|
36 |
-
createSubchannel(subchannelAddress, subchannelArgs
|
37 |
-
return this.parent.channelControlHelper.createSubchannel(subchannelAddress, subchannelArgs
|
38 |
}
|
39 |
-
updateState(connectivityState, picker) {
|
40 |
var _a;
|
41 |
if (this.calledByPendingChild()) {
|
42 |
if (connectivityState === connectivity_state_1.ConnectivityState.CONNECTING) {
|
@@ -49,7 +47,7 @@ class ChildLoadBalancerHandler {
|
|
49 |
else if (!this.calledByCurrentChild()) {
|
50 |
return;
|
51 |
}
|
52 |
-
this.parent.channelControlHelper.updateState(connectivityState, picker);
|
53 |
}
|
54 |
requestReresolution() {
|
55 |
var _a;
|
@@ -84,13 +82,13 @@ class ChildLoadBalancerHandler {
|
|
84 |
* @param lbConfig
|
85 |
* @param attributes
|
86 |
*/
|
87 |
-
updateAddressList(endpointList, lbConfig,
|
88 |
let childToUpdate;
|
89 |
if (this.currentChild === null ||
|
90 |
this.latestConfig === null ||
|
91 |
this.configUpdateRequiresNewPolicyInstance(this.latestConfig, lbConfig)) {
|
92 |
const newHelper = new this.ChildPolicyHelper(this);
|
93 |
-
const newChild = (0, load_balancer_1.createLoadBalancer)(lbConfig, newHelper
|
94 |
newHelper.setChild(newChild);
|
95 |
if (this.currentChild === null) {
|
96 |
this.currentChild = newChild;
|
@@ -113,7 +111,7 @@ class ChildLoadBalancerHandler {
|
|
113 |
}
|
114 |
}
|
115 |
this.latestConfig = lbConfig;
|
116 |
-
childToUpdate.updateAddressList(endpointList, lbConfig,
|
117 |
}
|
118 |
exitIdle() {
|
119 |
if (this.currentChild) {
|
|
|
21 |
const connectivity_state_1 = require("./connectivity-state");
|
22 |
const TYPE_NAME = 'child_load_balancer_helper';
|
23 |
class ChildLoadBalancerHandler {
|
24 |
+
constructor(channelControlHelper) {
|
25 |
this.channelControlHelper = channelControlHelper;
|
|
|
|
|
26 |
this.currentChild = null;
|
27 |
this.pendingChild = null;
|
28 |
this.latestConfig = null;
|
|
|
31 |
this.parent = parent;
|
32 |
this.child = null;
|
33 |
}
|
34 |
+
createSubchannel(subchannelAddress, subchannelArgs) {
|
35 |
+
return this.parent.channelControlHelper.createSubchannel(subchannelAddress, subchannelArgs);
|
36 |
}
|
37 |
+
updateState(connectivityState, picker, errorMessage) {
|
38 |
var _a;
|
39 |
if (this.calledByPendingChild()) {
|
40 |
if (connectivityState === connectivity_state_1.ConnectivityState.CONNECTING) {
|
|
|
47 |
else if (!this.calledByCurrentChild()) {
|
48 |
return;
|
49 |
}
|
50 |
+
this.parent.channelControlHelper.updateState(connectivityState, picker, errorMessage);
|
51 |
}
|
52 |
requestReresolution() {
|
53 |
var _a;
|
|
|
82 |
* @param lbConfig
|
83 |
* @param attributes
|
84 |
*/
|
85 |
+
updateAddressList(endpointList, lbConfig, options) {
|
86 |
let childToUpdate;
|
87 |
if (this.currentChild === null ||
|
88 |
this.latestConfig === null ||
|
89 |
this.configUpdateRequiresNewPolicyInstance(this.latestConfig, lbConfig)) {
|
90 |
const newHelper = new this.ChildPolicyHelper(this);
|
91 |
+
const newChild = (0, load_balancer_1.createLoadBalancer)(lbConfig, newHelper);
|
92 |
newHelper.setChild(newChild);
|
93 |
if (this.currentChild === null) {
|
94 |
this.currentChild = newChild;
|
|
|
111 |
}
|
112 |
}
|
113 |
this.latestConfig = lbConfig;
|
114 |
+
childToUpdate.updateAddressList(endpointList, lbConfig, options);
|
115 |
}
|
116 |
exitIdle() {
|
117 |
if (this.currentChild) {
|
.output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-outlier-detection.js
CHANGED
@@ -267,13 +267,13 @@ class OutlierDetectionPicker {
|
|
267 |
}
|
268 |
}
|
269 |
class OutlierDetectionLoadBalancer {
|
270 |
-
constructor(channelControlHelper
|
271 |
this.entryMap = new subchannel_address_1.EndpointMap();
|
272 |
this.latestConfig = null;
|
273 |
this.timerStartTime = null;
|
274 |
this.childBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler((0, experimental_1.createChildChannelControlHelper)(channelControlHelper, {
|
275 |
-
createSubchannel: (subchannelAddress, subchannelArgs
|
276 |
-
const originalSubchannel = channelControlHelper.createSubchannel(subchannelAddress, subchannelArgs
|
277 |
const mapEntry = this.entryMap.getForSubchannelAddress(subchannelAddress);
|
278 |
const subchannelWrapper = new OutlierDetectionSubchannelWrapper(originalSubchannel, mapEntry);
|
279 |
if ((mapEntry === null || mapEntry === void 0 ? void 0 : mapEntry.currentEjectionTimestamp) !== null) {
|
@@ -283,15 +283,15 @@ class OutlierDetectionLoadBalancer {
|
|
283 |
mapEntry === null || mapEntry === void 0 ? void 0 : mapEntry.subchannelWrappers.push(subchannelWrapper);
|
284 |
return subchannelWrapper;
|
285 |
},
|
286 |
-
updateState: (connectivityState, picker) => {
|
287 |
if (connectivityState === connectivity_state_1.ConnectivityState.READY) {
|
288 |
-
channelControlHelper.updateState(connectivityState, new OutlierDetectionPicker(picker, this.isCountingEnabled()));
|
289 |
}
|
290 |
else {
|
291 |
-
channelControlHelper.updateState(connectivityState, picker);
|
292 |
}
|
293 |
},
|
294 |
-
})
|
295 |
this.ejectionTimer = setInterval(() => { }, 0);
|
296 |
clearInterval(this.ejectionTimer);
|
297 |
}
|
@@ -499,10 +499,11 @@ class OutlierDetectionLoadBalancer {
|
|
499 |
}
|
500 |
}
|
501 |
}
|
502 |
-
updateAddressList(endpointList, lbConfig,
|
503 |
if (!(lbConfig instanceof OutlierDetectionLoadBalancingConfig)) {
|
504 |
return;
|
505 |
}
|
|
|
506 |
for (const endpoint of endpointList) {
|
507 |
if (!this.entryMap.has(endpoint)) {
|
508 |
trace('Adding map entry for ' + (0, subchannel_address_1.endpointToString)(endpoint));
|
@@ -516,7 +517,7 @@ class OutlierDetectionLoadBalancer {
|
|
516 |
}
|
517 |
this.entryMap.deleteMissing(endpointList);
|
518 |
const childPolicy = lbConfig.getChildPolicy();
|
519 |
-
this.childBalancer.updateAddressList(endpointList, childPolicy,
|
520 |
if (lbConfig.getSuccessRateEjectionConfig() ||
|
521 |
lbConfig.getFailurePercentageEjectionConfig()) {
|
522 |
if (this.timerStartTime) {
|
|
|
267 |
}
|
268 |
}
|
269 |
class OutlierDetectionLoadBalancer {
|
270 |
+
constructor(channelControlHelper) {
|
271 |
this.entryMap = new subchannel_address_1.EndpointMap();
|
272 |
this.latestConfig = null;
|
273 |
this.timerStartTime = null;
|
274 |
this.childBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler((0, experimental_1.createChildChannelControlHelper)(channelControlHelper, {
|
275 |
+
createSubchannel: (subchannelAddress, subchannelArgs) => {
|
276 |
+
const originalSubchannel = channelControlHelper.createSubchannel(subchannelAddress, subchannelArgs);
|
277 |
const mapEntry = this.entryMap.getForSubchannelAddress(subchannelAddress);
|
278 |
const subchannelWrapper = new OutlierDetectionSubchannelWrapper(originalSubchannel, mapEntry);
|
279 |
if ((mapEntry === null || mapEntry === void 0 ? void 0 : mapEntry.currentEjectionTimestamp) !== null) {
|
|
|
283 |
mapEntry === null || mapEntry === void 0 ? void 0 : mapEntry.subchannelWrappers.push(subchannelWrapper);
|
284 |
return subchannelWrapper;
|
285 |
},
|
286 |
+
updateState: (connectivityState, picker, errorMessage) => {
|
287 |
if (connectivityState === connectivity_state_1.ConnectivityState.READY) {
|
288 |
+
channelControlHelper.updateState(connectivityState, new OutlierDetectionPicker(picker, this.isCountingEnabled()), errorMessage);
|
289 |
}
|
290 |
else {
|
291 |
+
channelControlHelper.updateState(connectivityState, picker, errorMessage);
|
292 |
}
|
293 |
},
|
294 |
+
}));
|
295 |
this.ejectionTimer = setInterval(() => { }, 0);
|
296 |
clearInterval(this.ejectionTimer);
|
297 |
}
|
|
|
499 |
}
|
500 |
}
|
501 |
}
|
502 |
+
updateAddressList(endpointList, lbConfig, options) {
|
503 |
if (!(lbConfig instanceof OutlierDetectionLoadBalancingConfig)) {
|
504 |
return;
|
505 |
}
|
506 |
+
trace('Received update with config: ' + JSON.stringify(lbConfig.toJsonObject(), undefined, 2));
|
507 |
for (const endpoint of endpointList) {
|
508 |
if (!this.entryMap.has(endpoint)) {
|
509 |
trace('Adding map entry for ' + (0, subchannel_address_1.endpointToString)(endpoint));
|
|
|
517 |
}
|
518 |
this.entryMap.deleteMissing(endpointList);
|
519 |
const childPolicy = lbConfig.getChildPolicy();
|
520 |
+
this.childBalancer.updateAddressList(endpointList, childPolicy, options);
|
521 |
if (lbConfig.getSuccessRateEjectionConfig() ||
|
522 |
lbConfig.getFailurePercentageEjectionConfig()) {
|
523 |
if (this.timerStartTime) {
|
.output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-pick-first.js
CHANGED
@@ -103,6 +103,9 @@ function shuffled(list) {
|
|
103 |
* @returns
|
104 |
*/
|
105 |
function interleaveAddressFamilies(addressList) {
|
|
|
|
|
|
|
106 |
const result = [];
|
107 |
const ipv6Addresses = [];
|
108 |
const ipv4Addresses = [];
|
@@ -136,7 +139,7 @@ class PickFirstLoadBalancer {
|
|
136 |
* @param channelControlHelper `ChannelControlHelper` instance provided by
|
137 |
* this load balancer's owner.
|
138 |
*/
|
139 |
-
constructor(channelControlHelper
|
140 |
this.channelControlHelper = channelControlHelper;
|
141 |
/**
|
142 |
* The list of subchannels this load balancer is currently attempting to
|
@@ -173,15 +176,16 @@ class PickFirstLoadBalancer {
|
|
173 |
* the LB policy continuously attempts to connect to all of its subchannels.
|
174 |
*/
|
175 |
this.stickyTransientFailureMode = false;
|
|
|
176 |
/**
|
177 |
* The most recent error reported by any subchannel as it transitioned to
|
178 |
* TRANSIENT_FAILURE.
|
179 |
*/
|
180 |
this.lastError = null;
|
181 |
this.latestAddressList = null;
|
|
|
182 |
this.connectionDelayTimeout = setTimeout(() => { }, 0);
|
183 |
clearTimeout(this.connectionDelayTimeout);
|
184 |
-
this.reportHealthStatus = options[REPORT_HEALTH_STATUS_OPTION_NAME];
|
185 |
}
|
186 |
allChildrenHaveReportedTF() {
|
187 |
return this.children.every(child => child.hasReportedTransientFailure);
|
@@ -190,27 +194,36 @@ class PickFirstLoadBalancer {
|
|
190 |
this.children.every(child => child.hasReportedTransientFailure = false);
|
191 |
}
|
192 |
calculateAndReportNewState() {
|
|
|
193 |
if (this.currentPick) {
|
194 |
if (this.reportHealthStatus && !this.currentPick.isHealthy()) {
|
|
|
195 |
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
196 |
-
details:
|
197 |
-
}));
|
198 |
}
|
199 |
else {
|
200 |
-
this.updateState(connectivity_state_1.ConnectivityState.READY, new PickFirstPicker(this.currentPick));
|
201 |
}
|
202 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
else if (this.children.length === 0) {
|
204 |
-
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this));
|
205 |
}
|
206 |
else {
|
207 |
if (this.stickyTransientFailureMode) {
|
|
|
208 |
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
209 |
-
details:
|
210 |
-
}));
|
211 |
}
|
212 |
else {
|
213 |
-
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this));
|
214 |
}
|
215 |
}
|
216 |
}
|
@@ -330,12 +343,12 @@ class PickFirstLoadBalancer {
|
|
330 |
clearTimeout(this.connectionDelayTimeout);
|
331 |
this.calculateAndReportNewState();
|
332 |
}
|
333 |
-
updateState(newState, picker) {
|
334 |
trace(connectivity_state_1.ConnectivityState[this.currentState] +
|
335 |
' -> ' +
|
336 |
connectivity_state_1.ConnectivityState[newState]);
|
337 |
this.currentState = newState;
|
338 |
-
this.channelControlHelper.updateState(newState, picker);
|
339 |
}
|
340 |
resetSubchannelList() {
|
341 |
for (const child of this.children) {
|
@@ -352,10 +365,10 @@ class PickFirstLoadBalancer {
|
|
352 |
this.currentSubchannelIndex = 0;
|
353 |
this.children = [];
|
354 |
}
|
355 |
-
connectToAddressList(addressList) {
|
356 |
trace('connectToAddressList([' + addressList.map(address => (0, subchannel_address_1.subchannelAddressToString)(address)) + '])');
|
357 |
const newChildrenList = addressList.map(address => ({
|
358 |
-
subchannel: this.channelControlHelper.createSubchannel(address,
|
359 |
hasReportedTransientFailure: false,
|
360 |
}));
|
361 |
for (const { subchannel } of newChildrenList) {
|
@@ -385,10 +398,11 @@ class PickFirstLoadBalancer {
|
|
385 |
this.startNextSubchannelConnecting(0);
|
386 |
this.calculateAndReportNewState();
|
387 |
}
|
388 |
-
updateAddressList(endpointList, lbConfig) {
|
389 |
if (!(lbConfig instanceof PickFirstLoadBalancingConfig)) {
|
390 |
return;
|
391 |
}
|
|
|
392 |
/* Previously, an update would be discarded if it was identical to the
|
393 |
* previous update, to minimize churn. Now the DNS resolver is
|
394 |
* rate-limited, so that is less of a concern. */
|
@@ -398,16 +412,17 @@ class PickFirstLoadBalancer {
|
|
398 |
const rawAddressList = [].concat(...endpointList.map(endpoint => endpoint.addresses));
|
399 |
trace('updateAddressList([' + rawAddressList.map(address => (0, subchannel_address_1.subchannelAddressToString)(address)) + '])');
|
400 |
if (rawAddressList.length === 0) {
|
401 |
-
|
402 |
}
|
403 |
const addressList = interleaveAddressFamilies(rawAddressList);
|
404 |
this.latestAddressList = addressList;
|
405 |
-
this.
|
|
|
406 |
}
|
407 |
exitIdle() {
|
408 |
if (this.currentState === connectivity_state_1.ConnectivityState.IDLE &&
|
409 |
this.latestAddressList) {
|
410 |
-
this.connectToAddressList(this.latestAddressList);
|
411 |
}
|
412 |
}
|
413 |
resetBackoff() {
|
@@ -430,21 +445,22 @@ const LEAF_CONFIG = new PickFirstLoadBalancingConfig(false);
|
|
430 |
* that more closely reflects how it will be used as a leaf balancer.
|
431 |
*/
|
432 |
class LeafLoadBalancer {
|
433 |
-
constructor(endpoint, channelControlHelper,
|
434 |
this.endpoint = endpoint;
|
|
|
435 |
this.latestState = connectivity_state_1.ConnectivityState.IDLE;
|
436 |
const childChannelControlHelper = (0, load_balancer_1.createChildChannelControlHelper)(channelControlHelper, {
|
437 |
-
updateState: (connectivityState, picker) => {
|
438 |
this.latestState = connectivityState;
|
439 |
this.latestPicker = picker;
|
440 |
-
channelControlHelper.updateState(connectivityState, picker);
|
441 |
},
|
442 |
});
|
443 |
-
this.pickFirstBalancer = new PickFirstLoadBalancer(childChannelControlHelper
|
444 |
this.latestPicker = new picker_1.QueuePicker(this.pickFirstBalancer);
|
445 |
}
|
446 |
startConnecting() {
|
447 |
-
this.pickFirstBalancer.updateAddressList([this.endpoint], LEAF_CONFIG);
|
448 |
}
|
449 |
/**
|
450 |
* Update the endpoint associated with this LeafLoadBalancer to a new
|
@@ -452,7 +468,8 @@ class LeafLoadBalancer {
|
|
452 |
* attempt is not already in progress.
|
453 |
* @param newEndpoint
|
454 |
*/
|
455 |
-
updateEndpoint(newEndpoint) {
|
|
|
456 |
this.endpoint = newEndpoint;
|
457 |
if (this.latestState !== connectivity_state_1.ConnectivityState.IDLE) {
|
458 |
this.startConnecting();
|
|
|
103 |
* @returns
|
104 |
*/
|
105 |
function interleaveAddressFamilies(addressList) {
|
106 |
+
if (addressList.length === 0) {
|
107 |
+
return [];
|
108 |
+
}
|
109 |
const result = [];
|
110 |
const ipv6Addresses = [];
|
111 |
const ipv4Addresses = [];
|
|
|
139 |
* @param channelControlHelper `ChannelControlHelper` instance provided by
|
140 |
* this load balancer's owner.
|
141 |
*/
|
142 |
+
constructor(channelControlHelper) {
|
143 |
this.channelControlHelper = channelControlHelper;
|
144 |
/**
|
145 |
* The list of subchannels this load balancer is currently attempting to
|
|
|
176 |
* the LB policy continuously attempts to connect to all of its subchannels.
|
177 |
*/
|
178 |
this.stickyTransientFailureMode = false;
|
179 |
+
this.reportHealthStatus = false;
|
180 |
/**
|
181 |
* The most recent error reported by any subchannel as it transitioned to
|
182 |
* TRANSIENT_FAILURE.
|
183 |
*/
|
184 |
this.lastError = null;
|
185 |
this.latestAddressList = null;
|
186 |
+
this.latestOptions = {};
|
187 |
this.connectionDelayTimeout = setTimeout(() => { }, 0);
|
188 |
clearTimeout(this.connectionDelayTimeout);
|
|
|
189 |
}
|
190 |
allChildrenHaveReportedTF() {
|
191 |
return this.children.every(child => child.hasReportedTransientFailure);
|
|
|
194 |
this.children.every(child => child.hasReportedTransientFailure = false);
|
195 |
}
|
196 |
calculateAndReportNewState() {
|
197 |
+
var _a;
|
198 |
if (this.currentPick) {
|
199 |
if (this.reportHealthStatus && !this.currentPick.isHealthy()) {
|
200 |
+
const errorMessage = `Picked subchannel ${this.currentPick.getAddress()} is unhealthy`;
|
201 |
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
202 |
+
details: errorMessage,
|
203 |
+
}), errorMessage);
|
204 |
}
|
205 |
else {
|
206 |
+
this.updateState(connectivity_state_1.ConnectivityState.READY, new PickFirstPicker(this.currentPick), null);
|
207 |
}
|
208 |
}
|
209 |
+
else if (((_a = this.latestAddressList) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
210 |
+
const errorMessage = `No connection established. Last error: ${this.lastError}`;
|
211 |
+
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
212 |
+
details: errorMessage,
|
213 |
+
}), errorMessage);
|
214 |
+
}
|
215 |
else if (this.children.length === 0) {
|
216 |
+
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this), null);
|
217 |
}
|
218 |
else {
|
219 |
if (this.stickyTransientFailureMode) {
|
220 |
+
const errorMessage = `No connection established. Last error: ${this.lastError}`;
|
221 |
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
222 |
+
details: errorMessage,
|
223 |
+
}), errorMessage);
|
224 |
}
|
225 |
else {
|
226 |
+
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this), null);
|
227 |
}
|
228 |
}
|
229 |
}
|
|
|
343 |
clearTimeout(this.connectionDelayTimeout);
|
344 |
this.calculateAndReportNewState();
|
345 |
}
|
346 |
+
updateState(newState, picker, errorMessage) {
|
347 |
trace(connectivity_state_1.ConnectivityState[this.currentState] +
|
348 |
' -> ' +
|
349 |
connectivity_state_1.ConnectivityState[newState]);
|
350 |
this.currentState = newState;
|
351 |
+
this.channelControlHelper.updateState(newState, picker, errorMessage);
|
352 |
}
|
353 |
resetSubchannelList() {
|
354 |
for (const child of this.children) {
|
|
|
365 |
this.currentSubchannelIndex = 0;
|
366 |
this.children = [];
|
367 |
}
|
368 |
+
connectToAddressList(addressList, options) {
|
369 |
trace('connectToAddressList([' + addressList.map(address => (0, subchannel_address_1.subchannelAddressToString)(address)) + '])');
|
370 |
const newChildrenList = addressList.map(address => ({
|
371 |
+
subchannel: this.channelControlHelper.createSubchannel(address, options),
|
372 |
hasReportedTransientFailure: false,
|
373 |
}));
|
374 |
for (const { subchannel } of newChildrenList) {
|
|
|
398 |
this.startNextSubchannelConnecting(0);
|
399 |
this.calculateAndReportNewState();
|
400 |
}
|
401 |
+
updateAddressList(endpointList, lbConfig, options) {
|
402 |
if (!(lbConfig instanceof PickFirstLoadBalancingConfig)) {
|
403 |
return;
|
404 |
}
|
405 |
+
this.reportHealthStatus = options[REPORT_HEALTH_STATUS_OPTION_NAME];
|
406 |
/* Previously, an update would be discarded if it was identical to the
|
407 |
* previous update, to minimize churn. Now the DNS resolver is
|
408 |
* rate-limited, so that is less of a concern. */
|
|
|
412 |
const rawAddressList = [].concat(...endpointList.map(endpoint => endpoint.addresses));
|
413 |
trace('updateAddressList([' + rawAddressList.map(address => (0, subchannel_address_1.subchannelAddressToString)(address)) + '])');
|
414 |
if (rawAddressList.length === 0) {
|
415 |
+
this.lastError = 'No addresses resolved';
|
416 |
}
|
417 |
const addressList = interleaveAddressFamilies(rawAddressList);
|
418 |
this.latestAddressList = addressList;
|
419 |
+
this.latestOptions = options;
|
420 |
+
this.connectToAddressList(addressList, options);
|
421 |
}
|
422 |
exitIdle() {
|
423 |
if (this.currentState === connectivity_state_1.ConnectivityState.IDLE &&
|
424 |
this.latestAddressList) {
|
425 |
+
this.connectToAddressList(this.latestAddressList, this.latestOptions);
|
426 |
}
|
427 |
}
|
428 |
resetBackoff() {
|
|
|
445 |
* that more closely reflects how it will be used as a leaf balancer.
|
446 |
*/
|
447 |
class LeafLoadBalancer {
|
448 |
+
constructor(endpoint, channelControlHelper, options) {
|
449 |
this.endpoint = endpoint;
|
450 |
+
this.options = options;
|
451 |
this.latestState = connectivity_state_1.ConnectivityState.IDLE;
|
452 |
const childChannelControlHelper = (0, load_balancer_1.createChildChannelControlHelper)(channelControlHelper, {
|
453 |
+
updateState: (connectivityState, picker, errorMessage) => {
|
454 |
this.latestState = connectivityState;
|
455 |
this.latestPicker = picker;
|
456 |
+
channelControlHelper.updateState(connectivityState, picker, errorMessage);
|
457 |
},
|
458 |
});
|
459 |
+
this.pickFirstBalancer = new PickFirstLoadBalancer(childChannelControlHelper);
|
460 |
this.latestPicker = new picker_1.QueuePicker(this.pickFirstBalancer);
|
461 |
}
|
462 |
startConnecting() {
|
463 |
+
this.pickFirstBalancer.updateAddressList([this.endpoint], LEAF_CONFIG, Object.assign(Object.assign({}, this.options), { [REPORT_HEALTH_STATUS_OPTION_NAME]: true }));
|
464 |
}
|
465 |
/**
|
466 |
* Update the endpoint associated with this LeafLoadBalancer to a new
|
|
|
468 |
* attempt is not already in progress.
|
469 |
* @param newEndpoint
|
470 |
*/
|
471 |
+
updateEndpoint(newEndpoint, newOptions) {
|
472 |
+
this.options = newOptions;
|
473 |
this.endpoint = newEndpoint;
|
474 |
if (this.latestState !== connectivity_state_1.ConnectivityState.IDLE) {
|
475 |
this.startConnecting();
|
.output/server/node_modules/@grpc/grpc-js/build/src/load-balancer-round-robin.js
CHANGED
@@ -65,17 +65,15 @@ class RoundRobinPicker {
|
|
65 |
}
|
66 |
}
|
67 |
class RoundRobinLoadBalancer {
|
68 |
-
constructor(channelControlHelper
|
69 |
this.channelControlHelper = channelControlHelper;
|
70 |
-
this.credentials = credentials;
|
71 |
-
this.options = options;
|
72 |
this.children = [];
|
73 |
this.currentState = connectivity_state_1.ConnectivityState.IDLE;
|
74 |
this.currentReadyPicker = null;
|
75 |
this.updatesPaused = false;
|
76 |
this.lastError = null;
|
77 |
this.childChannelControlHelper = (0, load_balancer_1.createChildChannelControlHelper)(channelControlHelper, {
|
78 |
-
updateState: (connectivityState, picker) => {
|
79 |
/* Ensure that name resolution is requested again after active
|
80 |
* connections are dropped. This is more aggressive than necessary to
|
81 |
* accomplish that, so we are counting on resolvers to have
|
@@ -83,6 +81,9 @@ class RoundRobinLoadBalancer {
|
|
83 |
if (this.currentState === connectivity_state_1.ConnectivityState.READY && connectivityState !== connectivity_state_1.ConnectivityState.READY) {
|
84 |
this.channelControlHelper.requestReresolution();
|
85 |
}
|
|
|
|
|
|
|
86 |
this.calculateAndUpdateState();
|
87 |
},
|
88 |
});
|
@@ -108,18 +109,19 @@ class RoundRobinLoadBalancer {
|
|
108 |
this.updateState(connectivity_state_1.ConnectivityState.READY, new RoundRobinPicker(readyChildren.map(child => ({
|
109 |
endpoint: child.getEndpoint(),
|
110 |
picker: child.getPicker(),
|
111 |
-
})), index));
|
112 |
}
|
113 |
else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.CONNECTING) > 0) {
|
114 |
-
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this));
|
115 |
}
|
116 |
else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE) > 0) {
|
|
|
117 |
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
118 |
-
details:
|
119 |
-
}));
|
120 |
}
|
121 |
else {
|
122 |
-
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this));
|
123 |
}
|
124 |
/* round_robin should keep all children connected, this is how we do that.
|
125 |
* We can't do this more efficiently in the individual child's updateState
|
@@ -131,7 +133,7 @@ class RoundRobinLoadBalancer {
|
|
131 |
}
|
132 |
}
|
133 |
}
|
134 |
-
updateState(newState, picker) {
|
135 |
trace(connectivity_state_1.ConnectivityState[this.currentState] +
|
136 |
' -> ' +
|
137 |
connectivity_state_1.ConnectivityState[newState]);
|
@@ -142,18 +144,18 @@ class RoundRobinLoadBalancer {
|
|
142 |
this.currentReadyPicker = null;
|
143 |
}
|
144 |
this.currentState = newState;
|
145 |
-
this.channelControlHelper.updateState(newState, picker);
|
146 |
}
|
147 |
resetSubchannelList() {
|
148 |
for (const child of this.children) {
|
149 |
child.destroy();
|
150 |
}
|
151 |
}
|
152 |
-
updateAddressList(endpointList, lbConfig) {
|
153 |
this.resetSubchannelList();
|
154 |
trace('Connect to endpoint list ' + endpointList.map(subchannel_address_1.endpointToString));
|
155 |
this.updatesPaused = true;
|
156 |
-
this.children = endpointList.map(endpoint => new load_balancer_pick_first_1.LeafLoadBalancer(endpoint, this.childChannelControlHelper,
|
157 |
for (const child of this.children) {
|
158 |
child.startConnecting();
|
159 |
}
|
|
|
65 |
}
|
66 |
}
|
67 |
class RoundRobinLoadBalancer {
|
68 |
+
constructor(channelControlHelper) {
|
69 |
this.channelControlHelper = channelControlHelper;
|
|
|
|
|
70 |
this.children = [];
|
71 |
this.currentState = connectivity_state_1.ConnectivityState.IDLE;
|
72 |
this.currentReadyPicker = null;
|
73 |
this.updatesPaused = false;
|
74 |
this.lastError = null;
|
75 |
this.childChannelControlHelper = (0, load_balancer_1.createChildChannelControlHelper)(channelControlHelper, {
|
76 |
+
updateState: (connectivityState, picker, errorMessage) => {
|
77 |
/* Ensure that name resolution is requested again after active
|
78 |
* connections are dropped. This is more aggressive than necessary to
|
79 |
* accomplish that, so we are counting on resolvers to have
|
|
|
81 |
if (this.currentState === connectivity_state_1.ConnectivityState.READY && connectivityState !== connectivity_state_1.ConnectivityState.READY) {
|
82 |
this.channelControlHelper.requestReresolution();
|
83 |
}
|
84 |
+
if (errorMessage) {
|
85 |
+
this.lastError = errorMessage;
|
86 |
+
}
|
87 |
this.calculateAndUpdateState();
|
88 |
},
|
89 |
});
|
|
|
109 |
this.updateState(connectivity_state_1.ConnectivityState.READY, new RoundRobinPicker(readyChildren.map(child => ({
|
110 |
endpoint: child.getEndpoint(),
|
111 |
picker: child.getPicker(),
|
112 |
+
})), index), null);
|
113 |
}
|
114 |
else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.CONNECTING) > 0) {
|
115 |
+
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this), null);
|
116 |
}
|
117 |
else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE) > 0) {
|
118 |
+
const errorMessage = `round_robin: No connection established. Last error: ${this.lastError}`;
|
119 |
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
|
120 |
+
details: errorMessage,
|
121 |
+
}), errorMessage);
|
122 |
}
|
123 |
else {
|
124 |
+
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this), null);
|
125 |
}
|
126 |
/* round_robin should keep all children connected, this is how we do that.
|
127 |
* We can't do this more efficiently in the individual child's updateState
|
|
|
133 |
}
|
134 |
}
|
135 |
}
|
136 |
+
updateState(newState, picker, errorMessage) {
|
137 |
trace(connectivity_state_1.ConnectivityState[this.currentState] +
|
138 |
' -> ' +
|
139 |
connectivity_state_1.ConnectivityState[newState]);
|
|
|
144 |
this.currentReadyPicker = null;
|
145 |
}
|
146 |
this.currentState = newState;
|
147 |
+
this.channelControlHelper.updateState(newState, picker, errorMessage);
|
148 |
}
|
149 |
resetSubchannelList() {
|
150 |
for (const child of this.children) {
|
151 |
child.destroy();
|
152 |
}
|
153 |
}
|
154 |
+
updateAddressList(endpointList, lbConfig, options) {
|
155 |
this.resetSubchannelList();
|
156 |
trace('Connect to endpoint list ' + endpointList.map(subchannel_address_1.endpointToString));
|
157 |
this.updatesPaused = true;
|
158 |
+
this.children = endpointList.map(endpoint => new load_balancer_pick_first_1.LeafLoadBalancer(endpoint, this.childChannelControlHelper, options));
|
159 |
for (const child of this.children) {
|
160 |
child.startConnecting();
|
161 |
}
|
.output/server/node_modules/@grpc/grpc-js/build/src/load-balancer.js
CHANGED
@@ -55,10 +55,10 @@ function registerLoadBalancerType(typeName, loadBalancerType, loadBalancingConfi
|
|
55 |
function registerDefaultLoadBalancerType(typeName) {
|
56 |
defaultLoadBalancerType = typeName;
|
57 |
}
|
58 |
-
function createLoadBalancer(config, channelControlHelper
|
59 |
const typeName = config.getLoadBalancerName();
|
60 |
if (typeName in registeredLoadBalancerTypes) {
|
61 |
-
return new registeredLoadBalancerTypes[typeName].LoadBalancer(channelControlHelper
|
62 |
}
|
63 |
else {
|
64 |
return null;
|
|
|
55 |
function registerDefaultLoadBalancerType(typeName) {
|
56 |
defaultLoadBalancerType = typeName;
|
57 |
}
|
58 |
+
function createLoadBalancer(config, channelControlHelper) {
|
59 |
const typeName = config.getLoadBalancerName();
|
60 |
if (typeName in registeredLoadBalancerTypes) {
|
61 |
+
return new registeredLoadBalancerTypes[typeName].LoadBalancer(channelControlHelper);
|
62 |
}
|
63 |
else {
|
64 |
return null;
|
.output/server/node_modules/@grpc/grpc-js/build/src/load-balancing-call.js
CHANGED
@@ -126,10 +126,11 @@ class LoadBalancingCall {
|
|
126 |
((_b = pickResult.status) === null || _b === void 0 ? void 0 : _b.details));
|
127 |
switch (pickResult.pickResultType) {
|
128 |
case picker_1.PickResultType.COMPLETE:
|
129 |
-
this.credentials
|
|
|
130 |
.generateMetadata({ method_name: this.methodName, service_url: this.serviceUrl })
|
131 |
.then(credsMetadata => {
|
132 |
-
var _a
|
133 |
/* If this call was cancelled (e.g. by the deadline) before
|
134 |
* metadata generation finished, we shouldn't do anything with
|
135 |
* it. */
|
@@ -196,8 +197,7 @@ class LoadBalancingCall {
|
|
196 |
}, 'NOT_STARTED');
|
197 |
return;
|
198 |
}
|
199 |
-
(
|
200 |
-
(_c = pickResult.onCallStarted) === null || _c === void 0 ? void 0 : _c.call(pickResult);
|
201 |
this.onCallEnded = pickResult.onCallEnded;
|
202 |
this.trace('Created child call [' + this.child.getCallNumber() + ']');
|
203 |
if (this.readPending) {
|
|
|
126 |
((_b = pickResult.status) === null || _b === void 0 ? void 0 : _b.details));
|
127 |
switch (pickResult.pickResultType) {
|
128 |
case picker_1.PickResultType.COMPLETE:
|
129 |
+
const combinedCallCredentials = this.credentials.compose(pickResult.subchannel.getCallCredentials());
|
130 |
+
combinedCallCredentials
|
131 |
.generateMetadata({ method_name: this.methodName, service_url: this.serviceUrl })
|
132 |
.then(credsMetadata => {
|
133 |
+
var _a;
|
134 |
/* If this call was cancelled (e.g. by the deadline) before
|
135 |
* metadata generation finished, we shouldn't do anything with
|
136 |
* it. */
|
|
|
197 |
}, 'NOT_STARTED');
|
198 |
return;
|
199 |
}
|
200 |
+
(_a = pickResult.onCallStarted) === null || _a === void 0 ? void 0 : _a.call(pickResult);
|
|
|
201 |
this.onCallEnded = pickResult.onCallEnded;
|
202 |
this.trace('Created child call [' + this.child.getCallNumber() + ']');
|
203 |
if (this.readPending) {
|
.output/server/node_modules/@grpc/grpc-js/build/src/resolving-call.js
CHANGED
@@ -17,6 +17,7 @@
|
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
exports.ResolvingCall = void 0;
|
|
|
20 |
const constants_1 = require("./constants");
|
21 |
const deadline_1 = require("./deadline");
|
22 |
const metadata_1 = require("./metadata");
|
@@ -24,11 +25,10 @@ const logging = require("./logging");
|
|
24 |
const control_plane_status_1 = require("./control-plane-status");
|
25 |
const TRACER_NAME = 'resolving_call';
|
26 |
class ResolvingCall {
|
27 |
-
constructor(channel, method, options, filterStackFactory,
|
28 |
this.channel = channel;
|
29 |
this.method = method;
|
30 |
this.filterStackFactory = filterStackFactory;
|
31 |
-
this.credentials = credentials;
|
32 |
this.callNumber = callNumber;
|
33 |
this.child = null;
|
34 |
this.readPending = false;
|
@@ -46,6 +46,12 @@ class ResolvingCall {
|
|
46 |
this.deadlineStartTime = null;
|
47 |
this.configReceivedTime = null;
|
48 |
this.childStartTime = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
this.deadline = options.deadline;
|
50 |
this.host = options.host;
|
51 |
if (options.parentCall) {
|
@@ -190,7 +196,7 @@ class ResolvingCall {
|
|
190 |
this.filterStackFactory.push(config.dynamicFilterFactories);
|
191 |
this.filterStack = this.filterStackFactory.createFilter();
|
192 |
this.filterStack.sendMetadata(Promise.resolve(this.metadata)).then(filteredMetadata => {
|
193 |
-
this.child = this.channel.
|
194 |
this.trace('Created child [' + this.child.getCallNumber() + ']');
|
195 |
this.childStartTime = new Date();
|
196 |
this.child.start(filteredMetadata, {
|
@@ -292,7 +298,7 @@ class ResolvingCall {
|
|
292 |
}
|
293 |
}
|
294 |
setCredentials(credentials) {
|
295 |
-
this.credentials =
|
296 |
}
|
297 |
addStatusWatcher(watcher) {
|
298 |
this.statusWatchers.push(watcher);
|
|
|
17 |
*/
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
exports.ResolvingCall = void 0;
|
20 |
+
const call_credentials_1 = require("./call-credentials");
|
21 |
const constants_1 = require("./constants");
|
22 |
const deadline_1 = require("./deadline");
|
23 |
const metadata_1 = require("./metadata");
|
|
|
25 |
const control_plane_status_1 = require("./control-plane-status");
|
26 |
const TRACER_NAME = 'resolving_call';
|
27 |
class ResolvingCall {
|
28 |
+
constructor(channel, method, options, filterStackFactory, callNumber) {
|
29 |
this.channel = channel;
|
30 |
this.method = method;
|
31 |
this.filterStackFactory = filterStackFactory;
|
|
|
32 |
this.callNumber = callNumber;
|
33 |
this.child = null;
|
34 |
this.readPending = false;
|
|
|
46 |
this.deadlineStartTime = null;
|
47 |
this.configReceivedTime = null;
|
48 |
this.childStartTime = null;
|
49 |
+
/**
|
50 |
+
* Credentials configured for this specific call. Does not include
|
51 |
+
* call credentials associated with the channel credentials used to create
|
52 |
+
* the channel.
|
53 |
+
*/
|
54 |
+
this.credentials = call_credentials_1.CallCredentials.createEmpty();
|
55 |
this.deadline = options.deadline;
|
56 |
this.host = options.host;
|
57 |
if (options.parentCall) {
|
|
|
196 |
this.filterStackFactory.push(config.dynamicFilterFactories);
|
197 |
this.filterStack = this.filterStackFactory.createFilter();
|
198 |
this.filterStack.sendMetadata(Promise.resolve(this.metadata)).then(filteredMetadata => {
|
199 |
+
this.child = this.channel.createRetryingCall(config, this.method, this.host, this.credentials, this.deadline);
|
200 |
this.trace('Created child [' + this.child.getCallNumber() + ']');
|
201 |
this.childStartTime = new Date();
|
202 |
this.child.start(filteredMetadata, {
|
|
|
298 |
}
|
299 |
}
|
300 |
setCredentials(credentials) {
|
301 |
+
this.credentials = credentials;
|
302 |
}
|
303 |
addStatusWatcher(watcher) {
|
304 |
this.statusWatchers.push(watcher);
|
.output/server/node_modules/@grpc/grpc-js/build/src/resolving-load-balancer.js
CHANGED
@@ -72,36 +72,39 @@ function findMatchingConfig(service, method, methodConfigs, matchLevel) {
|
|
72 |
return null;
|
73 |
}
|
74 |
function getDefaultConfigSelector(serviceConfig) {
|
75 |
-
return
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
}
|
97 |
}
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
}
|
|
|
105 |
};
|
106 |
}
|
107 |
class ResolvingLoadBalancer {
|
@@ -117,13 +120,15 @@ class ResolvingLoadBalancer {
|
|
117 |
* In practice, that means using the "pick first" load balancer
|
118 |
* implmentation
|
119 |
*/
|
120 |
-
constructor(target, channelControlHelper,
|
121 |
this.target = target;
|
122 |
this.channelControlHelper = channelControlHelper;
|
|
|
123 |
this.onSuccessfulResolution = onSuccessfulResolution;
|
124 |
this.onFailedResolution = onFailedResolution;
|
125 |
this.latestChildState = connectivity_state_1.ConnectivityState.IDLE;
|
126 |
this.latestChildPicker = new picker_1.QueuePicker(this);
|
|
|
127 |
/**
|
128 |
* This resolving load balancer's current connectivity state.
|
129 |
*/
|
@@ -148,7 +153,7 @@ class ResolvingLoadBalancer {
|
|
148 |
methodConfig: [],
|
149 |
};
|
150 |
}
|
151 |
-
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this));
|
152 |
this.childLoadBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler({
|
153 |
createSubchannel: channelControlHelper.createSubchannel.bind(channelControlHelper),
|
154 |
requestReresolution: () => {
|
@@ -165,14 +170,15 @@ class ResolvingLoadBalancer {
|
|
165 |
this.updateResolution();
|
166 |
}
|
167 |
},
|
168 |
-
updateState: (newState, picker) => {
|
169 |
this.latestChildState = newState;
|
170 |
this.latestChildPicker = picker;
|
171 |
-
this.
|
|
|
172 |
},
|
173 |
addChannelzChild: channelControlHelper.addChannelzChild.bind(channelControlHelper),
|
174 |
removeChannelzChild: channelControlHelper.removeChannelzChild.bind(channelControlHelper),
|
175 |
-
}
|
176 |
this.innerResolver = (0, resolver_1.createResolver)(target, {
|
177 |
onSuccessfulResolution: (endpointList, serviceConfig, serviceConfigError, configSelector, attributes) => {
|
178 |
var _a;
|
@@ -216,9 +222,10 @@ class ResolvingLoadBalancer {
|
|
216 |
details: 'All load balancer options in service config are not compatible',
|
217 |
metadata: new metadata_1.Metadata(),
|
218 |
});
|
|
|
219 |
return;
|
220 |
}
|
221 |
-
this.childLoadBalancer.updateAddressList(endpointList, loadBalancingConfig, attributes);
|
222 |
const finalServiceConfig = workingServiceConfig !== null && workingServiceConfig !== void 0 ? workingServiceConfig : this.defaultServiceConfig;
|
223 |
this.onSuccessfulResolution(finalServiceConfig, configSelector !== null && configSelector !== void 0 ? configSelector : getDefaultConfigSelector(finalServiceConfig));
|
224 |
},
|
@@ -236,7 +243,7 @@ class ResolvingLoadBalancer {
|
|
236 |
this.continueResolving = false;
|
237 |
}
|
238 |
else {
|
239 |
-
this.updateState(this.latestChildState, this.latestChildPicker);
|
240 |
}
|
241 |
}, backoffOptions);
|
242 |
this.backoffTimeout.unref();
|
@@ -248,11 +255,11 @@ class ResolvingLoadBalancer {
|
|
248 |
* is an appropriate value here if the child LB policy is unset.
|
249 |
* Otherwise, we want to delegate to the child here, in case that
|
250 |
* triggers something. */
|
251 |
-
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, this.latestChildPicker);
|
252 |
}
|
253 |
this.backoffTimeout.runOnce();
|
254 |
}
|
255 |
-
updateState(connectivityState, picker) {
|
256 |
trace((0, uri_parser_1.uriToString)(this.target) +
|
257 |
' ' +
|
258 |
connectivity_state_1.ConnectivityState[this.currentState] +
|
@@ -263,11 +270,11 @@ class ResolvingLoadBalancer {
|
|
263 |
picker = new picker_1.QueuePicker(this, picker);
|
264 |
}
|
265 |
this.currentState = connectivityState;
|
266 |
-
this.channelControlHelper.updateState(connectivityState, picker);
|
267 |
}
|
268 |
handleResolutionFailure(error) {
|
269 |
if (this.latestChildState === connectivity_state_1.ConnectivityState.IDLE) {
|
270 |
-
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker(error));
|
271 |
this.onFailedResolution(error);
|
272 |
}
|
273 |
}
|
|
|
72 |
return null;
|
73 |
}
|
74 |
function getDefaultConfigSelector(serviceConfig) {
|
75 |
+
return {
|
76 |
+
invoke(methodName, metadata) {
|
77 |
+
var _a, _b;
|
78 |
+
const splitName = methodName.split('/').filter(x => x.length > 0);
|
79 |
+
const service = (_a = splitName[0]) !== null && _a !== void 0 ? _a : '';
|
80 |
+
const method = (_b = splitName[1]) !== null && _b !== void 0 ? _b : '';
|
81 |
+
if (serviceConfig && serviceConfig.methodConfig) {
|
82 |
+
/* Check for the following in order, and return the first method
|
83 |
+
* config that matches:
|
84 |
+
* 1. A name that exactly matches the service and method
|
85 |
+
* 2. A name with no method set that matches the service
|
86 |
+
* 3. An empty name
|
87 |
+
*/
|
88 |
+
for (const matchLevel of NAME_MATCH_LEVEL_ORDER) {
|
89 |
+
const matchingConfig = findMatchingConfig(service, method, serviceConfig.methodConfig, matchLevel);
|
90 |
+
if (matchingConfig) {
|
91 |
+
return {
|
92 |
+
methodConfig: matchingConfig,
|
93 |
+
pickInformation: {},
|
94 |
+
status: constants_1.Status.OK,
|
95 |
+
dynamicFilterFactories: [],
|
96 |
+
};
|
97 |
+
}
|
98 |
}
|
99 |
}
|
100 |
+
return {
|
101 |
+
methodConfig: { name: [] },
|
102 |
+
pickInformation: {},
|
103 |
+
status: constants_1.Status.OK,
|
104 |
+
dynamicFilterFactories: [],
|
105 |
+
};
|
106 |
+
},
|
107 |
+
unref() { }
|
108 |
};
|
109 |
}
|
110 |
class ResolvingLoadBalancer {
|
|
|
120 |
* In practice, that means using the "pick first" load balancer
|
121 |
* implmentation
|
122 |
*/
|
123 |
+
constructor(target, channelControlHelper, channelOptions, onSuccessfulResolution, onFailedResolution) {
|
124 |
this.target = target;
|
125 |
this.channelControlHelper = channelControlHelper;
|
126 |
+
this.channelOptions = channelOptions;
|
127 |
this.onSuccessfulResolution = onSuccessfulResolution;
|
128 |
this.onFailedResolution = onFailedResolution;
|
129 |
this.latestChildState = connectivity_state_1.ConnectivityState.IDLE;
|
130 |
this.latestChildPicker = new picker_1.QueuePicker(this);
|
131 |
+
this.latestChildErrorMessage = null;
|
132 |
/**
|
133 |
* This resolving load balancer's current connectivity state.
|
134 |
*/
|
|
|
153 |
methodConfig: [],
|
154 |
};
|
155 |
}
|
156 |
+
this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this), null);
|
157 |
this.childLoadBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler({
|
158 |
createSubchannel: channelControlHelper.createSubchannel.bind(channelControlHelper),
|
159 |
requestReresolution: () => {
|
|
|
170 |
this.updateResolution();
|
171 |
}
|
172 |
},
|
173 |
+
updateState: (newState, picker, errorMessage) => {
|
174 |
this.latestChildState = newState;
|
175 |
this.latestChildPicker = picker;
|
176 |
+
this.latestChildErrorMessage = errorMessage;
|
177 |
+
this.updateState(newState, picker, errorMessage);
|
178 |
},
|
179 |
addChannelzChild: channelControlHelper.addChannelzChild.bind(channelControlHelper),
|
180 |
removeChannelzChild: channelControlHelper.removeChannelzChild.bind(channelControlHelper),
|
181 |
+
});
|
182 |
this.innerResolver = (0, resolver_1.createResolver)(target, {
|
183 |
onSuccessfulResolution: (endpointList, serviceConfig, serviceConfigError, configSelector, attributes) => {
|
184 |
var _a;
|
|
|
222 |
details: 'All load balancer options in service config are not compatible',
|
223 |
metadata: new metadata_1.Metadata(),
|
224 |
});
|
225 |
+
configSelector === null || configSelector === void 0 ? void 0 : configSelector.unref();
|
226 |
return;
|
227 |
}
|
228 |
+
this.childLoadBalancer.updateAddressList(endpointList, loadBalancingConfig, Object.assign(Object.assign({}, this.channelOptions), attributes));
|
229 |
const finalServiceConfig = workingServiceConfig !== null && workingServiceConfig !== void 0 ? workingServiceConfig : this.defaultServiceConfig;
|
230 |
this.onSuccessfulResolution(finalServiceConfig, configSelector !== null && configSelector !== void 0 ? configSelector : getDefaultConfigSelector(finalServiceConfig));
|
231 |
},
|
|
|
243 |
this.continueResolving = false;
|
244 |
}
|
245 |
else {
|
246 |
+
this.updateState(this.latestChildState, this.latestChildPicker, this.latestChildErrorMessage);
|
247 |
}
|
248 |
}, backoffOptions);
|
249 |
this.backoffTimeout.unref();
|
|
|
255 |
* is an appropriate value here if the child LB policy is unset.
|
256 |
* Otherwise, we want to delegate to the child here, in case that
|
257 |
* triggers something. */
|
258 |
+
this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, this.latestChildPicker, this.latestChildErrorMessage);
|
259 |
}
|
260 |
this.backoffTimeout.runOnce();
|
261 |
}
|
262 |
+
updateState(connectivityState, picker, errorMessage) {
|
263 |
trace((0, uri_parser_1.uriToString)(this.target) +
|
264 |
' ' +
|
265 |
connectivity_state_1.ConnectivityState[this.currentState] +
|
|
|
270 |
picker = new picker_1.QueuePicker(this, picker);
|
271 |
}
|
272 |
this.currentState = connectivityState;
|
273 |
+
this.channelControlHelper.updateState(connectivityState, picker, errorMessage);
|
274 |
}
|
275 |
handleResolutionFailure(error) {
|
276 |
if (this.latestChildState === connectivity_state_1.ConnectivityState.IDLE) {
|
277 |
+
this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker(error), error.details);
|
278 |
this.onFailedResolution(error);
|
279 |
}
|
280 |
}
|
.output/server/node_modules/@grpc/grpc-js/build/src/retrying-call.js
CHANGED
@@ -140,6 +140,10 @@ class RetryingCall {
|
|
140 |
this.state = 'HEDGING';
|
141 |
this.maxAttempts = Math.min(callConfig.methodConfig.hedgingPolicy.maxAttempts, maxAttemptsLimit);
|
142 |
}
|
|
|
|
|
|
|
|
|
143 |
else {
|
144 |
this.state = 'TRANSPARENT_ONLY';
|
145 |
this.maxAttempts = 1;
|
@@ -216,7 +220,16 @@ class RetryingCall {
|
|
216 |
if (this.state !== 'COMMITTED') {
|
217 |
return;
|
218 |
}
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
for (let messageIndex = this.writeBufferOffset; messageIndex < earliestNeededMessageIndex; messageIndex++) {
|
221 |
const bufferEntry = this.getBufferEntry(messageIndex);
|
222 |
if (bufferEntry.allocated) {
|
@@ -227,17 +240,16 @@ class RetryingCall {
|
|
227 |
this.writeBufferOffset = earliestNeededMessageIndex;
|
228 |
}
|
229 |
commitCall(index) {
|
|
|
230 |
if (this.state === 'COMMITTED') {
|
231 |
return;
|
232 |
}
|
233 |
-
if (this.underlyingCalls[index].state === 'COMPLETED') {
|
234 |
-
return;
|
235 |
-
}
|
236 |
this.trace('Committing call [' +
|
237 |
this.underlyingCalls[index].call.getCallNumber() +
|
238 |
'] at index ' +
|
239 |
index);
|
240 |
this.state = 'COMMITTED';
|
|
|
241 |
this.committedCallIndex = index;
|
242 |
for (let i = 0; i < this.underlyingCalls.length; i++) {
|
243 |
if (i === index) {
|
@@ -339,6 +351,7 @@ class RetryingCall {
|
|
339 |
var _a, _b, _c;
|
340 |
switch (this.state) {
|
341 |
case 'COMMITTED':
|
|
|
342 |
case 'TRANSPARENT_ONLY':
|
343 |
this.commitCall(callIndex);
|
344 |
this.reportStatus(status);
|
@@ -422,6 +435,11 @@ class RetryingCall {
|
|
422 |
this.reportStatus(status);
|
423 |
return;
|
424 |
}
|
|
|
|
|
|
|
|
|
|
|
425 |
if (this.state === 'COMMITTED') {
|
426 |
this.reportStatus(status);
|
427 |
return;
|
|
|
140 |
this.state = 'HEDGING';
|
141 |
this.maxAttempts = Math.min(callConfig.methodConfig.hedgingPolicy.maxAttempts, maxAttemptsLimit);
|
142 |
}
|
143 |
+
else if (channel.getOptions()['grpc.enable_retries'] === 0) {
|
144 |
+
this.state = 'NO_RETRY';
|
145 |
+
this.maxAttempts = 1;
|
146 |
+
}
|
147 |
else {
|
148 |
this.state = 'TRANSPARENT_ONLY';
|
149 |
this.maxAttempts = 1;
|
|
|
220 |
if (this.state !== 'COMMITTED') {
|
221 |
return;
|
222 |
}
|
223 |
+
let earliestNeededMessageIndex;
|
224 |
+
if (this.underlyingCalls[this.committedCallIndex].state === 'COMPLETED') {
|
225 |
+
/* If the committed call is completed, clear all messages, even if some
|
226 |
+
* have not been sent. */
|
227 |
+
earliestNeededMessageIndex = this.getNextBufferIndex();
|
228 |
+
}
|
229 |
+
else {
|
230 |
+
earliestNeededMessageIndex =
|
231 |
+
this.underlyingCalls[this.committedCallIndex].nextMessageToSend;
|
232 |
+
}
|
233 |
for (let messageIndex = this.writeBufferOffset; messageIndex < earliestNeededMessageIndex; messageIndex++) {
|
234 |
const bufferEntry = this.getBufferEntry(messageIndex);
|
235 |
if (bufferEntry.allocated) {
|
|
|
240 |
this.writeBufferOffset = earliestNeededMessageIndex;
|
241 |
}
|
242 |
commitCall(index) {
|
243 |
+
var _a, _b;
|
244 |
if (this.state === 'COMMITTED') {
|
245 |
return;
|
246 |
}
|
|
|
|
|
|
|
247 |
this.trace('Committing call [' +
|
248 |
this.underlyingCalls[index].call.getCallNumber() +
|
249 |
'] at index ' +
|
250 |
index);
|
251 |
this.state = 'COMMITTED';
|
252 |
+
(_b = (_a = this.callConfig).onCommitted) === null || _b === void 0 ? void 0 : _b.call(_a);
|
253 |
this.committedCallIndex = index;
|
254 |
for (let i = 0; i < this.underlyingCalls.length; i++) {
|
255 |
if (i === index) {
|
|
|
351 |
var _a, _b, _c;
|
352 |
switch (this.state) {
|
353 |
case 'COMMITTED':
|
354 |
+
case 'NO_RETRY':
|
355 |
case 'TRANSPARENT_ONLY':
|
356 |
this.commitCall(callIndex);
|
357 |
this.reportStatus(status);
|
|
|
435 |
this.reportStatus(status);
|
436 |
return;
|
437 |
}
|
438 |
+
if (this.state === 'NO_RETRY') {
|
439 |
+
this.commitCall(callIndex);
|
440 |
+
this.reportStatus(status);
|
441 |
+
return;
|
442 |
+
}
|
443 |
if (this.state === 'COMMITTED') {
|
444 |
this.reportStatus(status);
|
445 |
return;
|
.output/server/node_modules/@grpc/grpc-js/build/src/server-credentials.js
CHANGED
@@ -21,9 +21,11 @@ exports.createCertificateProviderServerCredentials = createCertificateProviderSe
|
|
21 |
exports.createServerCredentialsWithInterceptors = createServerCredentialsWithInterceptors;
|
22 |
const tls_helpers_1 = require("./tls-helpers");
|
23 |
class ServerCredentials {
|
24 |
-
constructor() {
|
|
|
25 |
this.watchers = new Set();
|
26 |
this.latestContextOptions = null;
|
|
|
27 |
}
|
28 |
_addWatcher(watcher) {
|
29 |
this.watchers.add(watcher);
|
@@ -40,9 +42,15 @@ class ServerCredentials {
|
|
40 |
watcher(this.latestContextOptions);
|
41 |
}
|
42 |
}
|
43 |
-
|
|
|
|
|
|
|
44 |
return this.latestContextOptions;
|
45 |
}
|
|
|
|
|
|
|
46 |
_getInterceptors() {
|
47 |
return [];
|
48 |
}
|
@@ -77,18 +85,19 @@ class ServerCredentials {
|
|
77 |
key.push(pair.private_key);
|
78 |
}
|
79 |
return new SecureServerCredentials({
|
|
|
|
|
|
|
80 |
ca: (_a = rootCerts !== null && rootCerts !== void 0 ? rootCerts : (0, tls_helpers_1.getDefaultRootsData)()) !== null && _a !== void 0 ? _a : undefined,
|
81 |
cert,
|
82 |
key,
|
83 |
-
requestCert: checkClientCertificate,
|
84 |
-
ciphers: tls_helpers_1.CIPHER_SUITES,
|
85 |
});
|
86 |
}
|
87 |
}
|
88 |
exports.ServerCredentials = ServerCredentials;
|
89 |
class InsecureServerCredentials extends ServerCredentials {
|
90 |
-
|
91 |
-
|
92 |
}
|
93 |
_getSettings() {
|
94 |
return null;
|
@@ -98,15 +107,9 @@ class InsecureServerCredentials extends ServerCredentials {
|
|
98 |
}
|
99 |
}
|
100 |
class SecureServerCredentials extends ServerCredentials {
|
101 |
-
constructor(
|
102 |
-
super();
|
103 |
-
this.options =
|
104 |
-
}
|
105 |
-
_isSecure() {
|
106 |
-
return true;
|
107 |
-
}
|
108 |
-
_getSettings() {
|
109 |
-
return this.options;
|
110 |
}
|
111 |
/**
|
112 |
* Checks equality by checking the options that are actually set by
|
@@ -193,7 +196,11 @@ class SecureServerCredentials extends ServerCredentials {
|
|
193 |
}
|
194 |
class CertificateProviderServerCredentials extends ServerCredentials {
|
195 |
constructor(identityCertificateProvider, caCertificateProvider, requireClientCertificate) {
|
196 |
-
super(
|
|
|
|
|
|
|
|
|
197 |
this.identityCertificateProvider = identityCertificateProvider;
|
198 |
this.caCertificateProvider = caCertificateProvider;
|
199 |
this.requireClientCertificate = requireClientCertificate;
|
@@ -218,9 +225,6 @@ class CertificateProviderServerCredentials extends ServerCredentials {
|
|
218 |
this.identityCertificateProvider.removeIdentityCertificateListener(this.identityCertificateUpdateListener);
|
219 |
}
|
220 |
}
|
221 |
-
_isSecure() {
|
222 |
-
return true;
|
223 |
-
}
|
224 |
_equals(other) {
|
225 |
if (this === other) {
|
226 |
return true;
|
@@ -242,14 +246,13 @@ class CertificateProviderServerCredentials extends ServerCredentials {
|
|
242 |
}
|
243 |
return {
|
244 |
ca: (_a = this.latestCaUpdate) === null || _a === void 0 ? void 0 : _a.caCertificate,
|
245 |
-
cert: this.latestIdentityUpdate.certificate,
|
246 |
-
key: this.latestIdentityUpdate.privateKey,
|
247 |
-
requestCert: this.latestIdentityUpdate !== null,
|
248 |
-
rejectUnauthorized: this.requireClientCertificate
|
249 |
};
|
250 |
}
|
251 |
finalizeUpdate() {
|
252 |
-
this.
|
|
|
253 |
}
|
254 |
handleCaCertificateUpdate(update) {
|
255 |
this.latestCaUpdate = update;
|
@@ -265,7 +268,7 @@ function createCertificateProviderServerCredentials(caCertificateProvider, ident
|
|
265 |
}
|
266 |
class InterceptorServerCredentials extends ServerCredentials {
|
267 |
constructor(childCredentials, interceptors) {
|
268 |
-
super();
|
269 |
this.childCredentials = childCredentials;
|
270 |
this.interceptors = interceptors;
|
271 |
}
|
@@ -298,6 +301,12 @@ class InterceptorServerCredentials extends ServerCredentials {
|
|
298 |
_removeWatcher(watcher) {
|
299 |
this.childCredentials._removeWatcher(watcher);
|
300 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
}
|
302 |
function createServerCredentialsWithInterceptors(credentials, interceptors) {
|
303 |
return new InterceptorServerCredentials(credentials, interceptors);
|
|
|
21 |
exports.createServerCredentialsWithInterceptors = createServerCredentialsWithInterceptors;
|
22 |
const tls_helpers_1 = require("./tls-helpers");
|
23 |
class ServerCredentials {
|
24 |
+
constructor(serverConstructorOptions, contextOptions) {
|
25 |
+
this.serverConstructorOptions = serverConstructorOptions;
|
26 |
this.watchers = new Set();
|
27 |
this.latestContextOptions = null;
|
28 |
+
this.latestContextOptions = contextOptions !== null && contextOptions !== void 0 ? contextOptions : null;
|
29 |
}
|
30 |
_addWatcher(watcher) {
|
31 |
this.watchers.add(watcher);
|
|
|
42 |
watcher(this.latestContextOptions);
|
43 |
}
|
44 |
}
|
45 |
+
_isSecure() {
|
46 |
+
return this.serverConstructorOptions !== null;
|
47 |
+
}
|
48 |
+
_getSecureContextOptions() {
|
49 |
return this.latestContextOptions;
|
50 |
}
|
51 |
+
_getConstructorOptions() {
|
52 |
+
return this.serverConstructorOptions;
|
53 |
+
}
|
54 |
_getInterceptors() {
|
55 |
return [];
|
56 |
}
|
|
|
85 |
key.push(pair.private_key);
|
86 |
}
|
87 |
return new SecureServerCredentials({
|
88 |
+
requestCert: checkClientCertificate,
|
89 |
+
ciphers: tls_helpers_1.CIPHER_SUITES,
|
90 |
+
}, {
|
91 |
ca: (_a = rootCerts !== null && rootCerts !== void 0 ? rootCerts : (0, tls_helpers_1.getDefaultRootsData)()) !== null && _a !== void 0 ? _a : undefined,
|
92 |
cert,
|
93 |
key,
|
|
|
|
|
94 |
});
|
95 |
}
|
96 |
}
|
97 |
exports.ServerCredentials = ServerCredentials;
|
98 |
class InsecureServerCredentials extends ServerCredentials {
|
99 |
+
constructor() {
|
100 |
+
super(null);
|
101 |
}
|
102 |
_getSettings() {
|
103 |
return null;
|
|
|
107 |
}
|
108 |
}
|
109 |
class SecureServerCredentials extends ServerCredentials {
|
110 |
+
constructor(constructorOptions, contextOptions) {
|
111 |
+
super(constructorOptions, contextOptions);
|
112 |
+
this.options = Object.assign(Object.assign({}, constructorOptions), contextOptions);
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
/**
|
115 |
* Checks equality by checking the options that are actually set by
|
|
|
196 |
}
|
197 |
class CertificateProviderServerCredentials extends ServerCredentials {
|
198 |
constructor(identityCertificateProvider, caCertificateProvider, requireClientCertificate) {
|
199 |
+
super({
|
200 |
+
requestCert: caCertificateProvider !== null,
|
201 |
+
rejectUnauthorized: requireClientCertificate,
|
202 |
+
ciphers: tls_helpers_1.CIPHER_SUITES
|
203 |
+
});
|
204 |
this.identityCertificateProvider = identityCertificateProvider;
|
205 |
this.caCertificateProvider = caCertificateProvider;
|
206 |
this.requireClientCertificate = requireClientCertificate;
|
|
|
225 |
this.identityCertificateProvider.removeIdentityCertificateListener(this.identityCertificateUpdateListener);
|
226 |
}
|
227 |
}
|
|
|
|
|
|
|
228 |
_equals(other) {
|
229 |
if (this === other) {
|
230 |
return true;
|
|
|
246 |
}
|
247 |
return {
|
248 |
ca: (_a = this.latestCaUpdate) === null || _a === void 0 ? void 0 : _a.caCertificate,
|
249 |
+
cert: [this.latestIdentityUpdate.certificate],
|
250 |
+
key: [this.latestIdentityUpdate.privateKey],
|
|
|
|
|
251 |
};
|
252 |
}
|
253 |
finalizeUpdate() {
|
254 |
+
const secureContextOptions = this.calculateSecureContextOptions();
|
255 |
+
this.updateSecureContextOptions(secureContextOptions);
|
256 |
}
|
257 |
handleCaCertificateUpdate(update) {
|
258 |
this.latestCaUpdate = update;
|
|
|
268 |
}
|
269 |
class InterceptorServerCredentials extends ServerCredentials {
|
270 |
constructor(childCredentials, interceptors) {
|
271 |
+
super({});
|
272 |
this.childCredentials = childCredentials;
|
273 |
this.interceptors = interceptors;
|
274 |
}
|
|
|
301 |
_removeWatcher(watcher) {
|
302 |
this.childCredentials._removeWatcher(watcher);
|
303 |
}
|
304 |
+
_getConstructorOptions() {
|
305 |
+
return this.childCredentials._getConstructorOptions();
|
306 |
+
}
|
307 |
+
_getSecureContextOptions() {
|
308 |
+
return this.childCredentials._getSecureContextOptions();
|
309 |
+
}
|
310 |
}
|
311 |
function createServerCredentialsWithInterceptors(credentials, interceptors) {
|
312 |
return new InterceptorServerCredentials(credentials, interceptors);
|
.output/server/node_modules/@grpc/grpc-js/build/src/server-interceptors.js
CHANGED
@@ -215,6 +215,7 @@ class ServerInterceptingCall {
|
|
215 |
var _a, _b, _c, _d;
|
216 |
this.nextCall = nextCall;
|
217 |
this.processingMetadata = false;
|
|
|
218 |
this.processingMessage = false;
|
219 |
this.pendingMessage = null;
|
220 |
this.pendingMessageCallback = null;
|
@@ -254,6 +255,7 @@ class ServerInterceptingCall {
|
|
254 |
}
|
255 |
sendMetadata(metadata) {
|
256 |
this.processingMetadata = true;
|
|
|
257 |
this.responder.sendMetadata(metadata, interceptedMetadata => {
|
258 |
this.processingMetadata = false;
|
259 |
this.nextCall.sendMetadata(interceptedMetadata);
|
@@ -263,6 +265,9 @@ class ServerInterceptingCall {
|
|
263 |
}
|
264 |
sendMessage(message, callback) {
|
265 |
this.processingMessage = true;
|
|
|
|
|
|
|
266 |
this.responder.sendMessage(message, interceptedMessage => {
|
267 |
this.processingMessage = false;
|
268 |
if (this.processingMetadata) {
|
|
|
215 |
var _a, _b, _c, _d;
|
216 |
this.nextCall = nextCall;
|
217 |
this.processingMetadata = false;
|
218 |
+
this.sentMetadata = false;
|
219 |
this.processingMessage = false;
|
220 |
this.pendingMessage = null;
|
221 |
this.pendingMessageCallback = null;
|
|
|
255 |
}
|
256 |
sendMetadata(metadata) {
|
257 |
this.processingMetadata = true;
|
258 |
+
this.sentMetadata = true;
|
259 |
this.responder.sendMetadata(metadata, interceptedMetadata => {
|
260 |
this.processingMetadata = false;
|
261 |
this.nextCall.sendMetadata(interceptedMetadata);
|
|
|
265 |
}
|
266 |
sendMessage(message, callback) {
|
267 |
this.processingMessage = true;
|
268 |
+
if (!this.sentMetadata) {
|
269 |
+
this.sendMetadata(new metadata_1.Metadata());
|
270 |
+
}
|
271 |
this.responder.sendMessage(message, interceptedMessage => {
|
272 |
this.processingMessage = false;
|
273 |
if (this.processingMetadata) {
|
.output/server/node_modules/@grpc/grpc-js/build/src/server.js
CHANGED
@@ -69,6 +69,9 @@ const MAX_CONNECTION_IDLE_MS = ~(1 << 31);
|
|
69 |
const { HTTP2_HEADER_PATH } = http2.constants;
|
70 |
const TRACER_NAME = 'server';
|
71 |
const kMaxAge = Buffer.from('max_age');
|
|
|
|
|
|
|
72 |
function noop() { }
|
73 |
/**
|
74 |
* Decorator to wrap a class method with util.deprecate
|
@@ -303,7 +306,12 @@ let Server = (() => {
|
|
303 |
bind(port, creds) {
|
304 |
throw new Error('Not implemented. Use bindAsync() instead');
|
305 |
}
|
306 |
-
|
|
|
|
|
|
|
|
|
|
|
307 |
return (0, channelz_1.registerChannelzSocket)((0, subchannel_address_1.subchannelAddressToString)(boundAddress), () => {
|
308 |
return {
|
309 |
localAddress: boundAddress,
|
@@ -325,15 +333,21 @@ let Server = (() => {
|
|
325 |
};
|
326 |
}, this.channelzEnabled);
|
327 |
}
|
|
|
|
|
|
|
328 |
createHttp2Server(credentials) {
|
329 |
let http2Server;
|
330 |
if (credentials._isSecure()) {
|
331 |
-
const
|
332 |
-
const
|
333 |
-
|
|
|
|
|
334 |
http2Server = http2.createSecureServer(secureServerOptions);
|
335 |
-
http2Server.
|
336 |
if (!areCredentialsValid) {
|
|
|
337 |
socket.destroy();
|
338 |
}
|
339 |
});
|
@@ -346,9 +360,17 @@ let Server = (() => {
|
|
346 |
});
|
347 |
const credsWatcher = options => {
|
348 |
if (options) {
|
349 |
-
http2Server
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
}
|
351 |
areCredentialsValid = options !== null;
|
|
|
352 |
};
|
353 |
credentials._addWatcher(credsWatcher);
|
354 |
http2Server.on('close', () => {
|
@@ -391,11 +413,12 @@ let Server = (() => {
|
|
391 |
port: boundAddress.port,
|
392 |
};
|
393 |
}
|
394 |
-
const channelzRef = this.
|
395 |
this.listenerChildrenTracker.refChild(channelzRef);
|
396 |
this.http2Servers.set(http2Server, {
|
397 |
channelzRef: channelzRef,
|
398 |
sessions: new Set(),
|
|
|
399 |
});
|
400 |
boundPortObject.listeningServers.add(http2Server);
|
401 |
this.trace('Successfully bound ' +
|
@@ -613,19 +636,25 @@ let Server = (() => {
|
|
613 |
};
|
614 |
}, this.channelzEnabled);
|
615 |
}
|
616 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
617 |
if (credentials === null || !(credentials instanceof server_credentials_1.ServerCredentials)) {
|
618 |
throw new TypeError('creds must be a ServerCredentials object');
|
619 |
}
|
620 |
-
const server = this.createHttp2Server(credentials);
|
621 |
-
const channelzRef = this.registerInjectorToChannelz();
|
622 |
if (this.channelzEnabled) {
|
623 |
this.listenerChildrenTracker.refChild(channelzRef);
|
624 |
}
|
|
|
625 |
const sessionsSet = new Set();
|
626 |
this.http2Servers.set(server, {
|
627 |
channelzRef: channelzRef,
|
628 |
-
sessions: sessionsSet
|
|
|
629 |
});
|
630 |
return {
|
631 |
injectConnection: (connection) => {
|
@@ -650,11 +679,18 @@ let Server = (() => {
|
|
650 |
}
|
651 |
};
|
652 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
653 |
closeServer(server, callback) {
|
654 |
this.trace('Closing server with address ' + JSON.stringify(server.address()));
|
655 |
const serverInfo = this.http2Servers.get(server);
|
656 |
server.close(() => {
|
657 |
-
if (serverInfo) {
|
658 |
this.listenerChildrenTracker.unrefChild(serverInfo.channelzRef);
|
659 |
(0, channelz_1.unregisterChannelzRef)(serverInfo.channelzRef);
|
660 |
}
|
@@ -877,13 +913,13 @@ let Server = (() => {
|
|
877 |
return true;
|
878 |
}
|
879 |
_retrieveHandler(path) {
|
880 |
-
|
881 |
path +
|
882 |
' at address ' +
|
883 |
this.serverAddressString);
|
884 |
const handler = this.handlers.get(path);
|
885 |
if (handler === undefined) {
|
886 |
-
|
887 |
path +
|
888 |
'. Sending UNIMPLEMENTED status.');
|
889 |
return null;
|
|
|
69 |
const { HTTP2_HEADER_PATH } = http2.constants;
|
70 |
const TRACER_NAME = 'server';
|
71 |
const kMaxAge = Buffer.from('max_age');
|
72 |
+
function serverCallTrace(text) {
|
73 |
+
logging.trace(constants_1.LogVerbosity.DEBUG, 'server_call', text);
|
74 |
+
}
|
75 |
function noop() { }
|
76 |
/**
|
77 |
* Decorator to wrap a class method with util.deprecate
|
|
|
306 |
bind(port, creds) {
|
307 |
throw new Error('Not implemented. Use bindAsync() instead');
|
308 |
}
|
309 |
+
/**
|
310 |
+
* This API is experimental, so API stability is not guaranteed across minor versions.
|
311 |
+
* @param boundAddress
|
312 |
+
* @returns
|
313 |
+
*/
|
314 |
+
experimentalRegisterListenerToChannelz(boundAddress) {
|
315 |
return (0, channelz_1.registerChannelzSocket)((0, subchannel_address_1.subchannelAddressToString)(boundAddress), () => {
|
316 |
return {
|
317 |
localAddress: boundAddress,
|
|
|
333 |
};
|
334 |
}, this.channelzEnabled);
|
335 |
}
|
336 |
+
experimentalUnregisterListenerFromChannelz(channelzRef) {
|
337 |
+
(0, channelz_1.unregisterChannelzRef)(channelzRef);
|
338 |
+
}
|
339 |
createHttp2Server(credentials) {
|
340 |
let http2Server;
|
341 |
if (credentials._isSecure()) {
|
342 |
+
const constructorOptions = credentials._getConstructorOptions();
|
343 |
+
const contextOptions = credentials._getSecureContextOptions();
|
344 |
+
const secureServerOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, this.commonServerOptions), constructorOptions), contextOptions), { enableTrace: this.options['grpc-node.tls_enable_trace'] === 1 });
|
345 |
+
let areCredentialsValid = contextOptions !== null;
|
346 |
+
this.trace('Initial credentials valid: ' + areCredentialsValid);
|
347 |
http2Server = http2.createSecureServer(secureServerOptions);
|
348 |
+
http2Server.prependListener('connection', (socket) => {
|
349 |
if (!areCredentialsValid) {
|
350 |
+
this.trace('Dropped connection from ' + JSON.stringify(socket.address()) + ' due to unloaded credentials');
|
351 |
socket.destroy();
|
352 |
}
|
353 |
});
|
|
|
360 |
});
|
361 |
const credsWatcher = options => {
|
362 |
if (options) {
|
363 |
+
const secureServer = http2Server;
|
364 |
+
try {
|
365 |
+
secureServer.setSecureContext(options);
|
366 |
+
}
|
367 |
+
catch (e) {
|
368 |
+
logging.log(constants_1.LogVerbosity.ERROR, 'Failed to set secure context with error ' + e.message);
|
369 |
+
options = null;
|
370 |
+
}
|
371 |
}
|
372 |
areCredentialsValid = options !== null;
|
373 |
+
this.trace('Post-update credentials valid: ' + areCredentialsValid);
|
374 |
};
|
375 |
credentials._addWatcher(credsWatcher);
|
376 |
http2Server.on('close', () => {
|
|
|
413 |
port: boundAddress.port,
|
414 |
};
|
415 |
}
|
416 |
+
const channelzRef = this.experimentalRegisterListenerToChannelz(boundSubchannelAddress);
|
417 |
this.listenerChildrenTracker.refChild(channelzRef);
|
418 |
this.http2Servers.set(http2Server, {
|
419 |
channelzRef: channelzRef,
|
420 |
sessions: new Set(),
|
421 |
+
ownsChannelzRef: true
|
422 |
});
|
423 |
boundPortObject.listeningServers.add(http2Server);
|
424 |
this.trace('Successfully bound ' +
|
|
|
636 |
};
|
637 |
}, this.channelzEnabled);
|
638 |
}
|
639 |
+
/**
|
640 |
+
* This API is experimental, so API stability is not guaranteed across minor versions.
|
641 |
+
* @param credentials
|
642 |
+
* @param channelzRef
|
643 |
+
* @returns
|
644 |
+
*/
|
645 |
+
experimentalCreateConnectionInjectorWithChannelzRef(credentials, channelzRef, ownsChannelzRef = false) {
|
646 |
if (credentials === null || !(credentials instanceof server_credentials_1.ServerCredentials)) {
|
647 |
throw new TypeError('creds must be a ServerCredentials object');
|
648 |
}
|
|
|
|
|
649 |
if (this.channelzEnabled) {
|
650 |
this.listenerChildrenTracker.refChild(channelzRef);
|
651 |
}
|
652 |
+
const server = this.createHttp2Server(credentials);
|
653 |
const sessionsSet = new Set();
|
654 |
this.http2Servers.set(server, {
|
655 |
channelzRef: channelzRef,
|
656 |
+
sessions: sessionsSet,
|
657 |
+
ownsChannelzRef
|
658 |
});
|
659 |
return {
|
660 |
injectConnection: (connection) => {
|
|
|
679 |
}
|
680 |
};
|
681 |
}
|
682 |
+
createConnectionInjector(credentials) {
|
683 |
+
if (credentials === null || !(credentials instanceof server_credentials_1.ServerCredentials)) {
|
684 |
+
throw new TypeError('creds must be a ServerCredentials object');
|
685 |
+
}
|
686 |
+
const channelzRef = this.registerInjectorToChannelz();
|
687 |
+
return this.experimentalCreateConnectionInjectorWithChannelzRef(credentials, channelzRef, true);
|
688 |
+
}
|
689 |
closeServer(server, callback) {
|
690 |
this.trace('Closing server with address ' + JSON.stringify(server.address()));
|
691 |
const serverInfo = this.http2Servers.get(server);
|
692 |
server.close(() => {
|
693 |
+
if (serverInfo && serverInfo.ownsChannelzRef) {
|
694 |
this.listenerChildrenTracker.unrefChild(serverInfo.channelzRef);
|
695 |
(0, channelz_1.unregisterChannelzRef)(serverInfo.channelzRef);
|
696 |
}
|
|
|
913 |
return true;
|
914 |
}
|
915 |
_retrieveHandler(path) {
|
916 |
+
serverCallTrace('Received call to method ' +
|
917 |
path +
|
918 |
' at address ' +
|
919 |
this.serverAddressString);
|
920 |
const handler = this.handlers.get(path);
|
921 |
if (handler === undefined) {
|
922 |
+
serverCallTrace('No handler registered for method ' +
|
923 |
path +
|
924 |
'. Sending UNIMPLEMENTED status.');
|
925 |
return null;
|
.output/server/node_modules/@grpc/grpc-js/build/src/subchannel-interface.js
CHANGED
@@ -87,6 +87,9 @@ class BaseSubchannelWrapper {
|
|
87 |
realSubchannelEquals(other) {
|
88 |
return this.getRealSubchannel() === other.getRealSubchannel();
|
89 |
}
|
|
|
|
|
|
|
90 |
}
|
91 |
exports.BaseSubchannelWrapper = BaseSubchannelWrapper;
|
92 |
//# sourceMappingURL=subchannel-interface.js.map
|
|
|
87 |
realSubchannelEquals(other) {
|
88 |
return this.getRealSubchannel() === other.getRealSubchannel();
|
89 |
}
|
90 |
+
getCallCredentials() {
|
91 |
+
return this.child.getCallCredentials();
|
92 |
+
}
|
93 |
}
|
94 |
exports.BaseSubchannelWrapper = BaseSubchannelWrapper;
|
95 |
//# sourceMappingURL=subchannel-interface.js.map
|
.output/server/node_modules/@grpc/grpc-js/build/src/subchannel.js
CHANGED
@@ -45,7 +45,6 @@ class Subchannel {
|
|
45 |
this.channelTarget = channelTarget;
|
46 |
this.subchannelAddress = subchannelAddress;
|
47 |
this.options = options;
|
48 |
-
this.credentials = credentials;
|
49 |
this.connector = connector;
|
50 |
/**
|
51 |
* The subchannel's current connectivity state. Invariant: `session` === `null`
|
@@ -100,7 +99,7 @@ class Subchannel {
|
|
100 |
this.channelzTrace.addTrace('CT_INFO', 'Subchannel created');
|
101 |
this.trace('Subchannel constructed with options ' +
|
102 |
JSON.stringify(options, undefined, 2));
|
103 |
-
credentials.
|
104 |
}
|
105 |
getChannelzInfo() {
|
106 |
return {
|
@@ -152,7 +151,7 @@ class Subchannel {
|
|
152 |
options = Object.assign(Object.assign({}, options), { 'grpc.keepalive_time_ms': adjustedKeepaliveTime });
|
153 |
}
|
154 |
this.connector
|
155 |
-
.connect(this.subchannelAddress, this.
|
156 |
.then(transport => {
|
157 |
if (this.transitionToState([connectivity_state_1.ConnectivityState.CONNECTING], connectivity_state_1.ConnectivityState.READY)) {
|
158 |
this.transport = transport;
|
@@ -253,7 +252,7 @@ class Subchannel {
|
|
253 |
if (this.refcount === 0) {
|
254 |
this.channelzTrace.addTrace('CT_INFO', 'Shutting down');
|
255 |
(0, channelz_1.unregisterChannelzRef)(this.channelzRef);
|
256 |
-
this.
|
257 |
process.nextTick(() => {
|
258 |
this.transitionToState([connectivity_state_1.ConnectivityState.CONNECTING, connectivity_state_1.ConnectivityState.READY], connectivity_state_1.ConnectivityState.IDLE);
|
259 |
});
|
@@ -366,6 +365,9 @@ class Subchannel {
|
|
366 |
this.keepaliveTime = newKeepaliveTime;
|
367 |
}
|
368 |
}
|
|
|
|
|
|
|
369 |
}
|
370 |
exports.Subchannel = Subchannel;
|
371 |
//# sourceMappingURL=subchannel.js.map
|
|
|
45 |
this.channelTarget = channelTarget;
|
46 |
this.subchannelAddress = subchannelAddress;
|
47 |
this.options = options;
|
|
|
48 |
this.connector = connector;
|
49 |
/**
|
50 |
* The subchannel's current connectivity state. Invariant: `session` === `null`
|
|
|
99 |
this.channelzTrace.addTrace('CT_INFO', 'Subchannel created');
|
100 |
this.trace('Subchannel constructed with options ' +
|
101 |
JSON.stringify(options, undefined, 2));
|
102 |
+
this.secureConnector = credentials._createSecureConnector(channelTarget, options);
|
103 |
}
|
104 |
getChannelzInfo() {
|
105 |
return {
|
|
|
151 |
options = Object.assign(Object.assign({}, options), { 'grpc.keepalive_time_ms': adjustedKeepaliveTime });
|
152 |
}
|
153 |
this.connector
|
154 |
+
.connect(this.subchannelAddress, this.secureConnector, options)
|
155 |
.then(transport => {
|
156 |
if (this.transitionToState([connectivity_state_1.ConnectivityState.CONNECTING], connectivity_state_1.ConnectivityState.READY)) {
|
157 |
this.transport = transport;
|
|
|
252 |
if (this.refcount === 0) {
|
253 |
this.channelzTrace.addTrace('CT_INFO', 'Shutting down');
|
254 |
(0, channelz_1.unregisterChannelzRef)(this.channelzRef);
|
255 |
+
this.secureConnector.destroy();
|
256 |
process.nextTick(() => {
|
257 |
this.transitionToState([connectivity_state_1.ConnectivityState.CONNECTING, connectivity_state_1.ConnectivityState.READY], connectivity_state_1.ConnectivityState.IDLE);
|
258 |
});
|
|
|
365 |
this.keepaliveTime = newKeepaliveTime;
|
366 |
}
|
367 |
}
|
368 |
+
getCallCredentials() {
|
369 |
+
return this.secureConnector.getCallCredentials();
|
370 |
+
}
|
371 |
}
|
372 |
exports.Subchannel = Subchannel;
|
373 |
//# sourceMappingURL=subchannel.js.map
|
.output/server/node_modules/@grpc/grpc-js/build/src/transport.js
CHANGED
@@ -18,7 +18,6 @@
|
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
exports.Http2SubchannelConnector = void 0;
|
20 |
const http2 = require("http2");
|
21 |
-
const tls_1 = require("tls");
|
22 |
const channelz_1 = require("./channelz");
|
23 |
const constants_1 = require("./constants");
|
24 |
const http_proxy_1 = require("./http_proxy");
|
@@ -124,8 +123,8 @@ class Http2Transport {
|
|
124 |
this.trace('connection closed with error ' + error.message);
|
125 |
this.handleDisconnect();
|
126 |
});
|
127 |
-
session.socket.once('close', () => {
|
128 |
-
this.trace('connection closed');
|
129 |
this.handleDisconnect();
|
130 |
});
|
131 |
if (logging.isTracerEnabled(TRACER_NAME)) {
|
@@ -478,178 +477,119 @@ class Http2SubchannelConnector {
|
|
478 |
trace(text) {
|
479 |
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + ' ' + text);
|
480 |
}
|
481 |
-
createSession(
|
482 |
if (this.isShutdown) {
|
483 |
return Promise.reject();
|
484 |
}
|
|
|
|
|
|
|
485 |
return new Promise((resolve, reject) => {
|
486 |
-
var _a
|
487 |
-
let remoteName;
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
remoteName = null;
|
495 |
-
this.trace('creating HTTP/2 session to ' + (0, subchannel_address_1.subchannelAddressToString)(address));
|
496 |
-
}
|
497 |
-
const targetAuthority = (0, resolver_1.getDefaultAuthority)((_a = proxyConnectionResult.realTarget) !== null && _a !== void 0 ? _a : this.channelTarget);
|
498 |
-
let connectionOptions = credentials._getConnectionOptions();
|
499 |
-
if (!connectionOptions) {
|
500 |
-
reject('Credentials not loaded');
|
501 |
-
return;
|
502 |
-
}
|
503 |
-
connectionOptions.maxSendHeaderBlockLength = Number.MAX_SAFE_INTEGER;
|
504 |
-
if ('grpc-node.max_session_memory' in options) {
|
505 |
-
connectionOptions.maxSessionMemory =
|
506 |
-
options['grpc-node.max_session_memory'];
|
507 |
-
}
|
508 |
-
else {
|
509 |
-
/* By default, set a very large max session memory limit, to effectively
|
510 |
-
* disable enforcement of the limit. Some testing indicates that Node's
|
511 |
-
* behavior degrades badly when this limit is reached, so we solve that
|
512 |
-
* by disabling the check entirely. */
|
513 |
-
connectionOptions.maxSessionMemory = Number.MAX_SAFE_INTEGER;
|
514 |
-
}
|
515 |
-
let addressScheme = 'http://';
|
516 |
-
if ('secureContext' in connectionOptions) {
|
517 |
-
addressScheme = 'https://';
|
518 |
-
// If provided, the value of grpc.ssl_target_name_override should be used
|
519 |
-
// to override the target hostname when checking server identity.
|
520 |
-
// This option is used for testing only.
|
521 |
-
if (options['grpc.ssl_target_name_override']) {
|
522 |
-
const sslTargetNameOverride = options['grpc.ssl_target_name_override'];
|
523 |
-
const originalCheckServerIdentity = (_b = connectionOptions.checkServerIdentity) !== null && _b !== void 0 ? _b : tls_1.checkServerIdentity;
|
524 |
-
connectionOptions.checkServerIdentity = (host, cert) => {
|
525 |
-
return originalCheckServerIdentity(sslTargetNameOverride, cert);
|
526 |
-
};
|
527 |
-
connectionOptions.servername = sslTargetNameOverride;
|
528 |
-
}
|
529 |
-
else {
|
530 |
-
const authorityHostname = (_d = (_c = (0, uri_parser_1.splitHostPort)(targetAuthority)) === null || _c === void 0 ? void 0 : _c.host) !== null && _d !== void 0 ? _d : 'localhost';
|
531 |
-
// We want to always set servername to support SNI
|
532 |
-
connectionOptions.servername = authorityHostname;
|
533 |
-
}
|
534 |
-
if (proxyConnectionResult.socket) {
|
535 |
-
/* This is part of the workaround for
|
536 |
-
* https://github.com/nodejs/node/issues/32922. Without that bug,
|
537 |
-
* proxyConnectionResult.socket would always be a plaintext socket and
|
538 |
-
* this would say
|
539 |
-
* connectionOptions.socket = proxyConnectionResult.socket; */
|
540 |
-
connectionOptions.createConnection = (authority, option) => {
|
541 |
-
return proxyConnectionResult.socket;
|
542 |
-
};
|
543 |
}
|
544 |
}
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
if (proxyConnectionResult.socket) {
|
551 |
-
return proxyConnectionResult.socket;
|
552 |
-
}
|
553 |
-
else {
|
554 |
-
/* net.NetConnectOpts is declared in a way that is more restrictive
|
555 |
-
* than what net.connect will actually accept, so we use the type
|
556 |
-
* assertion to work around that. */
|
557 |
-
return net.connect(address);
|
558 |
-
}
|
559 |
-
};
|
560 |
-
}
|
561 |
-
connectionOptions = Object.assign(Object.assign(Object.assign({}, connectionOptions), address), { enableTrace: options['grpc-node.tls_enable_trace'] === 1 });
|
562 |
-
/* http2.connect uses the options here:
|
563 |
-
* https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3028-L3036
|
564 |
-
* The spread operator overides earlier values with later ones, so any port
|
565 |
-
* or host values in the options will be used rather than any values extracted
|
566 |
-
* from the first argument. In addition, the path overrides the host and port,
|
567 |
-
* as documented for plaintext connections here:
|
568 |
-
* https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener
|
569 |
-
* and for TLS connections here:
|
570 |
-
* https://nodejs.org/api/tls.html#tls_tls_connect_options_callback. In
|
571 |
-
* earlier versions of Node, http2.connect passes these options to
|
572 |
-
* tls.connect but not net.connect, so in the insecure case we still need
|
573 |
-
* to set the createConnection option above to create the connection
|
574 |
-
* explicitly. We cannot do that in the TLS case because http2.connect
|
575 |
-
* passes necessary additional options to tls.connect.
|
576 |
-
* The first argument just needs to be parseable as a URL and the scheme
|
577 |
-
* determines whether the connection will be established over TLS or not.
|
578 |
-
*/
|
579 |
-
const session = http2.connect(addressScheme + targetAuthority, connectionOptions);
|
580 |
-
this.session = session;
|
581 |
-
let errorMessage = 'Failed to connect';
|
582 |
-
let reportedError = false;
|
583 |
-
session.unref();
|
584 |
-
session.once('connect', () => {
|
585 |
-
session.removeAllListeners();
|
586 |
-
resolve(new Http2Transport(session, address, options, remoteName));
|
587 |
-
this.session = null;
|
588 |
-
});
|
589 |
-
session.once('close', () => {
|
590 |
this.session = null;
|
591 |
// Leave time for error event to happen before rejecting
|
592 |
setImmediate(() => {
|
593 |
if (!reportedError) {
|
594 |
reportedError = true;
|
595 |
-
reject(`${errorMessage} (${new Date().toISOString()})`);
|
596 |
}
|
597 |
});
|
598 |
-
}
|
599 |
-
|
|
|
|
|
600 |
errorMessage = error.message;
|
601 |
this.trace('connection failed with error ' + errorMessage);
|
602 |
if (!reportedError) {
|
603 |
reportedError = true;
|
604 |
reject(`${errorMessage} (${new Date().toISOString()})`);
|
605 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
});
|
|
|
|
|
|
|
|
|
607 |
});
|
608 |
}
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
}
|
614 |
-
/* Pass connection options through to the proxy so that it's able to
|
615 |
-
* upgrade it's connection to support tls if needed.
|
616 |
-
* This is a workaround for https://github.com/nodejs/node/issues/32922
|
617 |
-
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */
|
618 |
-
const connectionOptions = credentials._getConnectionOptions();
|
619 |
-
if (!connectionOptions) {
|
620 |
-
return Promise.reject('Credentials not loaded');
|
621 |
-
}
|
622 |
-
if ('secureContext' in connectionOptions) {
|
623 |
-
connectionOptions.ALPNProtocols = ['h2'];
|
624 |
-
// If provided, the value of grpc.ssl_target_name_override should be used
|
625 |
-
// to override the target hostname when checking server identity.
|
626 |
-
// This option is used for testing only.
|
627 |
-
if (options['grpc.ssl_target_name_override']) {
|
628 |
-
const sslTargetNameOverride = options['grpc.ssl_target_name_override'];
|
629 |
-
const originalCheckServerIdentity = (_a = connectionOptions.checkServerIdentity) !== null && _a !== void 0 ? _a : tls_1.checkServerIdentity;
|
630 |
-
connectionOptions.checkServerIdentity = (host, cert) => {
|
631 |
-
return originalCheckServerIdentity(sslTargetNameOverride, cert);
|
632 |
-
};
|
633 |
-
connectionOptions.servername = sslTargetNameOverride;
|
634 |
}
|
635 |
else {
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
|
|
|
|
|
|
|
|
643 |
});
|
644 |
-
|
645 |
-
|
646 |
-
}
|
647 |
-
}
|
648 |
-
if (options['grpc-node.tls_enable_trace']) {
|
649 |
-
connectionOptions.enableTrace = true;
|
650 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
651 |
}
|
652 |
-
return (0, http_proxy_1.getProxiedConnection)(address, options, connectionOptions).then(result => this.createSession(address, credentials, options, result));
|
653 |
}
|
654 |
shutdown() {
|
655 |
var _a;
|
|
|
18 |
Object.defineProperty(exports, "__esModule", { value: true });
|
19 |
exports.Http2SubchannelConnector = void 0;
|
20 |
const http2 = require("http2");
|
|
|
21 |
const channelz_1 = require("./channelz");
|
22 |
const constants_1 = require("./constants");
|
23 |
const http_proxy_1 = require("./http_proxy");
|
|
|
123 |
this.trace('connection closed with error ' + error.message);
|
124 |
this.handleDisconnect();
|
125 |
});
|
126 |
+
session.socket.once('close', (hadError) => {
|
127 |
+
this.trace('connection closed. hadError=' + hadError);
|
128 |
this.handleDisconnect();
|
129 |
});
|
130 |
if (logging.isTracerEnabled(TRACER_NAME)) {
|
|
|
477 |
trace(text) {
|
478 |
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + ' ' + text);
|
479 |
}
|
480 |
+
createSession(secureConnectResult, address, options) {
|
481 |
if (this.isShutdown) {
|
482 |
return Promise.reject();
|
483 |
}
|
484 |
+
if (secureConnectResult.socket.closed) {
|
485 |
+
return Promise.reject('Connection closed before starting HTTP/2 handshake');
|
486 |
+
}
|
487 |
return new Promise((resolve, reject) => {
|
488 |
+
var _a;
|
489 |
+
let remoteName = null;
|
490 |
+
let realTarget = this.channelTarget;
|
491 |
+
if ('grpc.http_connect_target' in options) {
|
492 |
+
const parsedTarget = (0, uri_parser_1.parseUri)(options['grpc.http_connect_target']);
|
493 |
+
if (parsedTarget) {
|
494 |
+
realTarget = parsedTarget;
|
495 |
+
remoteName = (0, uri_parser_1.uriToString)(parsedTarget);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
}
|
497 |
}
|
498 |
+
const scheme = secureConnectResult.secure ? 'https' : 'http';
|
499 |
+
const targetPath = (0, resolver_1.getDefaultAuthority)(realTarget);
|
500 |
+
const closeHandler = () => {
|
501 |
+
var _a;
|
502 |
+
(_a = this.session) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
this.session = null;
|
504 |
// Leave time for error event to happen before rejecting
|
505 |
setImmediate(() => {
|
506 |
if (!reportedError) {
|
507 |
reportedError = true;
|
508 |
+
reject(`${errorMessage.trim()} (${new Date().toISOString()})`);
|
509 |
}
|
510 |
});
|
511 |
+
};
|
512 |
+
const errorHandler = (error) => {
|
513 |
+
var _a;
|
514 |
+
(_a = this.session) === null || _a === void 0 ? void 0 : _a.destroy();
|
515 |
errorMessage = error.message;
|
516 |
this.trace('connection failed with error ' + errorMessage);
|
517 |
if (!reportedError) {
|
518 |
reportedError = true;
|
519 |
reject(`${errorMessage} (${new Date().toISOString()})`);
|
520 |
}
|
521 |
+
};
|
522 |
+
const session = http2.connect(`${scheme}://${targetPath}`, {
|
523 |
+
createConnection: (authority, option) => {
|
524 |
+
return secureConnectResult.socket;
|
525 |
+
},
|
526 |
+
settings: {
|
527 |
+
initialWindowSize: (_a = options['grpc-node.flow_control_window']) !== null && _a !== void 0 ? _a : http2.getDefaultSettings().initialWindowSize,
|
528 |
+
}
|
529 |
+
});
|
530 |
+
this.session = session;
|
531 |
+
let errorMessage = 'Failed to connect';
|
532 |
+
let reportedError = false;
|
533 |
+
session.unref();
|
534 |
+
session.once('remoteSettings', () => {
|
535 |
+
session.removeAllListeners();
|
536 |
+
secureConnectResult.socket.removeListener('close', closeHandler);
|
537 |
+
secureConnectResult.socket.removeListener('error', errorHandler);
|
538 |
+
resolve(new Http2Transport(session, address, options, remoteName));
|
539 |
+
this.session = null;
|
540 |
});
|
541 |
+
session.once('close', closeHandler);
|
542 |
+
session.once('error', errorHandler);
|
543 |
+
secureConnectResult.socket.once('close', closeHandler);
|
544 |
+
secureConnectResult.socket.once('error', errorHandler);
|
545 |
});
|
546 |
}
|
547 |
+
tcpConnect(address, options) {
|
548 |
+
return (0, http_proxy_1.getProxiedConnection)(address, options).then(proxiedSocket => {
|
549 |
+
if (proxiedSocket) {
|
550 |
+
return proxiedSocket;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
551 |
}
|
552 |
else {
|
553 |
+
return new Promise((resolve, reject) => {
|
554 |
+
const closeCallback = () => {
|
555 |
+
reject(new Error('Socket closed'));
|
556 |
+
};
|
557 |
+
const errorCallback = (error) => {
|
558 |
+
reject(error);
|
559 |
+
};
|
560 |
+
const socket = net.connect(address, () => {
|
561 |
+
socket.removeListener('close', closeCallback);
|
562 |
+
socket.removeListener('error', errorCallback);
|
563 |
+
resolve(socket);
|
564 |
});
|
565 |
+
socket.once('close', closeCallback);
|
566 |
+
socket.once('error', errorCallback);
|
567 |
+
});
|
|
|
|
|
|
|
568 |
}
|
569 |
+
});
|
570 |
+
}
|
571 |
+
async connect(address, secureConnector, options) {
|
572 |
+
if (this.isShutdown) {
|
573 |
+
return Promise.reject();
|
574 |
+
}
|
575 |
+
let tcpConnection = null;
|
576 |
+
let secureConnectResult = null;
|
577 |
+
const addressString = (0, subchannel_address_1.subchannelAddressToString)(address);
|
578 |
+
try {
|
579 |
+
this.trace(addressString + ' Waiting for secureConnector to be ready');
|
580 |
+
await secureConnector.waitForReady();
|
581 |
+
this.trace(addressString + ' secureConnector is ready');
|
582 |
+
tcpConnection = await this.tcpConnect(address, options);
|
583 |
+
this.trace(addressString + ' Established TCP connection');
|
584 |
+
secureConnectResult = await secureConnector.connect(tcpConnection);
|
585 |
+
this.trace(addressString + ' Established secure connection');
|
586 |
+
return this.createSession(secureConnectResult, address, options);
|
587 |
+
}
|
588 |
+
catch (e) {
|
589 |
+
tcpConnection === null || tcpConnection === void 0 ? void 0 : tcpConnection.destroy();
|
590 |
+
secureConnectResult === null || secureConnectResult === void 0 ? void 0 : secureConnectResult.socket.destroy();
|
591 |
+
throw e;
|
592 |
}
|
|
|
593 |
}
|
594 |
shutdown() {
|
595 |
var _a;
|
.output/server/node_modules/@grpc/grpc-js/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"name": "@grpc/grpc-js",
|
3 |
-
"version": "1.
|
4 |
"description": "gRPC Library for Node - pure JS implementation",
|
5 |
"homepage": "https://grpc.io/",
|
6 |
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
|
|
1 |
{
|
2 |
"name": "@grpc/grpc-js",
|
3 |
+
"version": "1.13.0",
|
4 |
"description": "gRPC Library for Node - pure JS implementation",
|
5 |
"homepage": "https://grpc.io/",
|
6 |
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
.output/server/node_modules/jose/dist/webapi/jwe/compact/encrypt.js
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
import { FlattenedEncrypt } from '../flattened/encrypt.js';
|
2 |
export class CompactEncrypt {
|
3 |
-
|
4 |
constructor(plaintext) {
|
5 |
-
this
|
6 |
}
|
7 |
setContentEncryptionKey(cek) {
|
8 |
-
this.
|
9 |
return this;
|
10 |
}
|
11 |
setInitializationVector(iv) {
|
12 |
-
this.
|
13 |
return this;
|
14 |
}
|
15 |
setProtectedHeader(protectedHeader) {
|
16 |
-
this.
|
17 |
return this;
|
18 |
}
|
19 |
setKeyManagementParameters(parameters) {
|
20 |
-
this.
|
21 |
return this;
|
22 |
}
|
23 |
async encrypt(key, options) {
|
24 |
-
const jwe = await this.
|
25 |
return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');
|
26 |
}
|
27 |
}
|
|
|
1 |
import { FlattenedEncrypt } from '../flattened/encrypt.js';
|
2 |
export class CompactEncrypt {
|
3 |
+
#flattened;
|
4 |
constructor(plaintext) {
|
5 |
+
this.#flattened = new FlattenedEncrypt(plaintext);
|
6 |
}
|
7 |
setContentEncryptionKey(cek) {
|
8 |
+
this.#flattened.setContentEncryptionKey(cek);
|
9 |
return this;
|
10 |
}
|
11 |
setInitializationVector(iv) {
|
12 |
+
this.#flattened.setInitializationVector(iv);
|
13 |
return this;
|
14 |
}
|
15 |
setProtectedHeader(protectedHeader) {
|
16 |
+
this.#flattened.setProtectedHeader(protectedHeader);
|
17 |
return this;
|
18 |
}
|
19 |
setKeyManagementParameters(parameters) {
|
20 |
+
this.#flattened.setKeyManagementParameters(parameters);
|
21 |
return this;
|
22 |
}
|
23 |
async encrypt(key, options) {
|
24 |
+
const jwe = await this.#flattened.encrypt(key, options);
|
25 |
return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');
|
26 |
}
|
27 |
}
|
.output/server/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
CHANGED
@@ -9,79 +9,79 @@ import validateCrit from '../../lib/validate_crit.js';
|
|
9 |
import normalizeKey from '../../lib/normalize_key.js';
|
10 |
import checkKeyType from '../../lib/check_key_type.js';
|
11 |
export class FlattenedEncrypt {
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
constructor(plaintext) {
|
21 |
if (!(plaintext instanceof Uint8Array)) {
|
22 |
throw new TypeError('plaintext must be an instance of Uint8Array');
|
23 |
}
|
24 |
-
this
|
25 |
}
|
26 |
setKeyManagementParameters(parameters) {
|
27 |
-
if (this
|
28 |
throw new TypeError('setKeyManagementParameters can only be called once');
|
29 |
}
|
30 |
-
this
|
31 |
return this;
|
32 |
}
|
33 |
setProtectedHeader(protectedHeader) {
|
34 |
-
if (this
|
35 |
throw new TypeError('setProtectedHeader can only be called once');
|
36 |
}
|
37 |
-
this
|
38 |
return this;
|
39 |
}
|
40 |
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
41 |
-
if (this
|
42 |
throw new TypeError('setSharedUnprotectedHeader can only be called once');
|
43 |
}
|
44 |
-
this
|
45 |
return this;
|
46 |
}
|
47 |
setUnprotectedHeader(unprotectedHeader) {
|
48 |
-
if (this
|
49 |
throw new TypeError('setUnprotectedHeader can only be called once');
|
50 |
}
|
51 |
-
this
|
52 |
return this;
|
53 |
}
|
54 |
setAdditionalAuthenticatedData(aad) {
|
55 |
-
this
|
56 |
return this;
|
57 |
}
|
58 |
setContentEncryptionKey(cek) {
|
59 |
-
if (this
|
60 |
throw new TypeError('setContentEncryptionKey can only be called once');
|
61 |
}
|
62 |
-
this
|
63 |
return this;
|
64 |
}
|
65 |
setInitializationVector(iv) {
|
66 |
-
if (this
|
67 |
throw new TypeError('setInitializationVector can only be called once');
|
68 |
}
|
69 |
-
this
|
70 |
return this;
|
71 |
}
|
72 |
async encrypt(key, options) {
|
73 |
-
if (!this
|
74 |
throw new JWEInvalid('either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()');
|
75 |
}
|
76 |
-
if (!isDisjoint(this
|
77 |
throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
|
78 |
}
|
79 |
const joseHeader = {
|
80 |
-
...this
|
81 |
-
...this
|
82 |
-
...this
|
83 |
};
|
84 |
-
validateCrit(JWEInvalid, new Map(), options?.crit, this
|
85 |
if (joseHeader.zip !== undefined) {
|
86 |
throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
|
87 |
}
|
@@ -93,7 +93,7 @@ export class FlattenedEncrypt {
|
|
93 |
throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
|
94 |
}
|
95 |
let encryptedKey;
|
96 |
-
if (this
|
97 |
throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${alg}`);
|
98 |
}
|
99 |
checkKeyType(alg === 'dir' ? enc : alg, key, 'encrypt');
|
@@ -101,41 +101,41 @@ export class FlattenedEncrypt {
|
|
101 |
{
|
102 |
let parameters;
|
103 |
const k = await normalizeKey(key, alg);
|
104 |
-
({ cek, encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, this
|
105 |
if (parameters) {
|
106 |
if (options && unprotected in options) {
|
107 |
-
if (!this
|
108 |
this.setUnprotectedHeader(parameters);
|
109 |
}
|
110 |
else {
|
111 |
-
this
|
112 |
}
|
113 |
}
|
114 |
-
else if (!this
|
115 |
this.setProtectedHeader(parameters);
|
116 |
}
|
117 |
else {
|
118 |
-
this
|
119 |
}
|
120 |
}
|
121 |
}
|
122 |
let additionalData;
|
123 |
let protectedHeader;
|
124 |
let aadMember;
|
125 |
-
if (this
|
126 |
-
protectedHeader = encoder.encode(b64u(JSON.stringify(this
|
127 |
}
|
128 |
else {
|
129 |
protectedHeader = encoder.encode('');
|
130 |
}
|
131 |
-
if (this
|
132 |
-
aadMember = b64u(this
|
133 |
additionalData = concat(protectedHeader, encoder.encode('.'), encoder.encode(aadMember));
|
134 |
}
|
135 |
else {
|
136 |
additionalData = protectedHeader;
|
137 |
}
|
138 |
-
const { ciphertext, tag, iv } = await encrypt(enc, this
|
139 |
const jwe = {
|
140 |
ciphertext: b64u(ciphertext),
|
141 |
};
|
@@ -151,14 +151,14 @@ export class FlattenedEncrypt {
|
|
151 |
if (aadMember) {
|
152 |
jwe.aad = aadMember;
|
153 |
}
|
154 |
-
if (this
|
155 |
jwe.protected = decoder.decode(protectedHeader);
|
156 |
}
|
157 |
-
if (this
|
158 |
-
jwe.unprotected = this
|
159 |
}
|
160 |
-
if (this
|
161 |
-
jwe.header = this
|
162 |
}
|
163 |
return jwe;
|
164 |
}
|
|
|
9 |
import normalizeKey from '../../lib/normalize_key.js';
|
10 |
import checkKeyType from '../../lib/check_key_type.js';
|
11 |
export class FlattenedEncrypt {
|
12 |
+
#plaintext;
|
13 |
+
#protectedHeader;
|
14 |
+
#sharedUnprotectedHeader;
|
15 |
+
#unprotectedHeader;
|
16 |
+
#aad;
|
17 |
+
#cek;
|
18 |
+
#iv;
|
19 |
+
#keyManagementParameters;
|
20 |
constructor(plaintext) {
|
21 |
if (!(plaintext instanceof Uint8Array)) {
|
22 |
throw new TypeError('plaintext must be an instance of Uint8Array');
|
23 |
}
|
24 |
+
this.#plaintext = plaintext;
|
25 |
}
|
26 |
setKeyManagementParameters(parameters) {
|
27 |
+
if (this.#keyManagementParameters) {
|
28 |
throw new TypeError('setKeyManagementParameters can only be called once');
|
29 |
}
|
30 |
+
this.#keyManagementParameters = parameters;
|
31 |
return this;
|
32 |
}
|
33 |
setProtectedHeader(protectedHeader) {
|
34 |
+
if (this.#protectedHeader) {
|
35 |
throw new TypeError('setProtectedHeader can only be called once');
|
36 |
}
|
37 |
+
this.#protectedHeader = protectedHeader;
|
38 |
return this;
|
39 |
}
|
40 |
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
41 |
+
if (this.#sharedUnprotectedHeader) {
|
42 |
throw new TypeError('setSharedUnprotectedHeader can only be called once');
|
43 |
}
|
44 |
+
this.#sharedUnprotectedHeader = sharedUnprotectedHeader;
|
45 |
return this;
|
46 |
}
|
47 |
setUnprotectedHeader(unprotectedHeader) {
|
48 |
+
if (this.#unprotectedHeader) {
|
49 |
throw new TypeError('setUnprotectedHeader can only be called once');
|
50 |
}
|
51 |
+
this.#unprotectedHeader = unprotectedHeader;
|
52 |
return this;
|
53 |
}
|
54 |
setAdditionalAuthenticatedData(aad) {
|
55 |
+
this.#aad = aad;
|
56 |
return this;
|
57 |
}
|
58 |
setContentEncryptionKey(cek) {
|
59 |
+
if (this.#cek) {
|
60 |
throw new TypeError('setContentEncryptionKey can only be called once');
|
61 |
}
|
62 |
+
this.#cek = cek;
|
63 |
return this;
|
64 |
}
|
65 |
setInitializationVector(iv) {
|
66 |
+
if (this.#iv) {
|
67 |
throw new TypeError('setInitializationVector can only be called once');
|
68 |
}
|
69 |
+
this.#iv = iv;
|
70 |
return this;
|
71 |
}
|
72 |
async encrypt(key, options) {
|
73 |
+
if (!this.#protectedHeader && !this.#unprotectedHeader && !this.#sharedUnprotectedHeader) {
|
74 |
throw new JWEInvalid('either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()');
|
75 |
}
|
76 |
+
if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader, this.#sharedUnprotectedHeader)) {
|
77 |
throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
|
78 |
}
|
79 |
const joseHeader = {
|
80 |
+
...this.#protectedHeader,
|
81 |
+
...this.#unprotectedHeader,
|
82 |
+
...this.#sharedUnprotectedHeader,
|
83 |
};
|
84 |
+
validateCrit(JWEInvalid, new Map(), options?.crit, this.#protectedHeader, joseHeader);
|
85 |
if (joseHeader.zip !== undefined) {
|
86 |
throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
|
87 |
}
|
|
|
93 |
throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
|
94 |
}
|
95 |
let encryptedKey;
|
96 |
+
if (this.#cek && (alg === 'dir' || alg === 'ECDH-ES')) {
|
97 |
throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${alg}`);
|
98 |
}
|
99 |
checkKeyType(alg === 'dir' ? enc : alg, key, 'encrypt');
|
|
|
101 |
{
|
102 |
let parameters;
|
103 |
const k = await normalizeKey(key, alg);
|
104 |
+
({ cek, encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, this.#cek, this.#keyManagementParameters));
|
105 |
if (parameters) {
|
106 |
if (options && unprotected in options) {
|
107 |
+
if (!this.#unprotectedHeader) {
|
108 |
this.setUnprotectedHeader(parameters);
|
109 |
}
|
110 |
else {
|
111 |
+
this.#unprotectedHeader = { ...this.#unprotectedHeader, ...parameters };
|
112 |
}
|
113 |
}
|
114 |
+
else if (!this.#protectedHeader) {
|
115 |
this.setProtectedHeader(parameters);
|
116 |
}
|
117 |
else {
|
118 |
+
this.#protectedHeader = { ...this.#protectedHeader, ...parameters };
|
119 |
}
|
120 |
}
|
121 |
}
|
122 |
let additionalData;
|
123 |
let protectedHeader;
|
124 |
let aadMember;
|
125 |
+
if (this.#protectedHeader) {
|
126 |
+
protectedHeader = encoder.encode(b64u(JSON.stringify(this.#protectedHeader)));
|
127 |
}
|
128 |
else {
|
129 |
protectedHeader = encoder.encode('');
|
130 |
}
|
131 |
+
if (this.#aad) {
|
132 |
+
aadMember = b64u(this.#aad);
|
133 |
additionalData = concat(protectedHeader, encoder.encode('.'), encoder.encode(aadMember));
|
134 |
}
|
135 |
else {
|
136 |
additionalData = protectedHeader;
|
137 |
}
|
138 |
+
const { ciphertext, tag, iv } = await encrypt(enc, this.#plaintext, cek, this.#iv, additionalData);
|
139 |
const jwe = {
|
140 |
ciphertext: b64u(ciphertext),
|
141 |
};
|
|
|
151 |
if (aadMember) {
|
152 |
jwe.aad = aadMember;
|
153 |
}
|
154 |
+
if (this.#protectedHeader) {
|
155 |
jwe.protected = decoder.decode(protectedHeader);
|
156 |
}
|
157 |
+
if (this.#sharedUnprotectedHeader) {
|
158 |
+
jwe.unprotected = this.#sharedUnprotectedHeader;
|
159 |
}
|
160 |
+
if (this.#unprotectedHeader) {
|
161 |
+
jwe.header = this.#unprotectedHeader;
|
162 |
}
|
163 |
return jwe;
|
164 |
}
|
.output/server/node_modules/jose/dist/webapi/jwe/general/encrypt.js
CHANGED
@@ -9,12 +9,12 @@ import validateCrit from '../../lib/validate_crit.js';
|
|
9 |
import normalizeKey from '../../lib/normalize_key.js';
|
10 |
import checkKeyType from '../../lib/check_key_type.js';
|
11 |
class IndividualRecipient {
|
12 |
-
parent;
|
13 |
unprotectedHeader;
|
14 |
key;
|
15 |
options;
|
16 |
constructor(enc, key, options) {
|
17 |
-
this
|
18 |
this.key = key;
|
19 |
this.options = options;
|
20 |
}
|
@@ -26,57 +26,57 @@ class IndividualRecipient {
|
|
26 |
return this;
|
27 |
}
|
28 |
addRecipient(...args) {
|
29 |
-
return this
|
30 |
}
|
31 |
encrypt(...args) {
|
32 |
-
return this
|
33 |
}
|
34 |
done() {
|
35 |
-
return this
|
36 |
}
|
37 |
}
|
38 |
export class GeneralEncrypt {
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
constructor(plaintext) {
|
45 |
-
this
|
46 |
}
|
47 |
addRecipient(key, options) {
|
48 |
const recipient = new IndividualRecipient(this, key, { crit: options?.crit });
|
49 |
-
this.
|
50 |
return recipient;
|
51 |
}
|
52 |
setProtectedHeader(protectedHeader) {
|
53 |
-
if (this
|
54 |
throw new TypeError('setProtectedHeader can only be called once');
|
55 |
}
|
56 |
-
this
|
57 |
return this;
|
58 |
}
|
59 |
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
60 |
-
if (this
|
61 |
throw new TypeError('setSharedUnprotectedHeader can only be called once');
|
62 |
}
|
63 |
-
this
|
64 |
return this;
|
65 |
}
|
66 |
setAdditionalAuthenticatedData(aad) {
|
67 |
-
this
|
68 |
return this;
|
69 |
}
|
70 |
async encrypt() {
|
71 |
-
if (!this.
|
72 |
throw new JWEInvalid('at least one recipient must be added');
|
73 |
}
|
74 |
-
if (this.
|
75 |
-
const [recipient] = this
|
76 |
-
const flattened = await new FlattenedEncrypt(this
|
77 |
-
.setAdditionalAuthenticatedData(this
|
78 |
-
.setProtectedHeader(this
|
79 |
-
.setSharedUnprotectedHeader(this
|
80 |
.setUnprotectedHeader(recipient.unprotectedHeader)
|
81 |
.encrypt(recipient.key, { ...recipient.options });
|
82 |
const jwe = {
|
@@ -98,14 +98,14 @@ export class GeneralEncrypt {
|
|
98 |
return jwe;
|
99 |
}
|
100 |
let enc;
|
101 |
-
for (let i = 0; i < this.
|
102 |
-
const recipient = this
|
103 |
-
if (!isDisjoint(this
|
104 |
throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
|
105 |
}
|
106 |
const joseHeader = {
|
107 |
-
...this
|
108 |
-
...this
|
109 |
...recipient.unprotectedHeader,
|
110 |
};
|
111 |
const { alg } = joseHeader;
|
@@ -124,7 +124,7 @@ export class GeneralEncrypt {
|
|
124 |
else if (enc !== joseHeader.enc) {
|
125 |
throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients');
|
126 |
}
|
127 |
-
validateCrit(JWEInvalid, new Map(), recipient.options.crit, this
|
128 |
if (joseHeader.zip !== undefined) {
|
129 |
throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
|
130 |
}
|
@@ -136,22 +136,22 @@ export class GeneralEncrypt {
|
|
136 |
recipients: [],
|
137 |
tag: '',
|
138 |
};
|
139 |
-
for (let i = 0; i < this.
|
140 |
-
const recipient = this
|
141 |
const target = {};
|
142 |
jwe.recipients.push(target);
|
143 |
const joseHeader = {
|
144 |
-
...this
|
145 |
-
...this
|
146 |
...recipient.unprotectedHeader,
|
147 |
};
|
148 |
const p2c = joseHeader.alg.startsWith('PBES2') ? 2048 + i : undefined;
|
149 |
if (i === 0) {
|
150 |
-
const flattened = await new FlattenedEncrypt(this
|
151 |
-
.setAdditionalAuthenticatedData(this
|
152 |
.setContentEncryptionKey(cek)
|
153 |
-
.setProtectedHeader(this
|
154 |
-
.setSharedUnprotectedHeader(this
|
155 |
.setUnprotectedHeader(recipient.unprotectedHeader)
|
156 |
.setKeyManagementParameters({ p2c })
|
157 |
.encrypt(recipient.key, {
|
@@ -173,8 +173,8 @@ export class GeneralEncrypt {
|
|
173 |
continue;
|
174 |
}
|
175 |
const alg = recipient.unprotectedHeader?.alg ||
|
176 |
-
this
|
177 |
-
this
|
178 |
checkKeyType(alg === 'dir' ? enc : alg, recipient.key, 'encrypt');
|
179 |
const k = await normalizeKey(recipient.key, alg);
|
180 |
const { encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, cek, { p2c });
|
|
|
9 |
import normalizeKey from '../../lib/normalize_key.js';
|
10 |
import checkKeyType from '../../lib/check_key_type.js';
|
11 |
class IndividualRecipient {
|
12 |
+
#parent;
|
13 |
unprotectedHeader;
|
14 |
key;
|
15 |
options;
|
16 |
constructor(enc, key, options) {
|
17 |
+
this.#parent = enc;
|
18 |
this.key = key;
|
19 |
this.options = options;
|
20 |
}
|
|
|
26 |
return this;
|
27 |
}
|
28 |
addRecipient(...args) {
|
29 |
+
return this.#parent.addRecipient(...args);
|
30 |
}
|
31 |
encrypt(...args) {
|
32 |
+
return this.#parent.encrypt(...args);
|
33 |
}
|
34 |
done() {
|
35 |
+
return this.#parent;
|
36 |
}
|
37 |
}
|
38 |
export class GeneralEncrypt {
|
39 |
+
#plaintext;
|
40 |
+
#recipients = [];
|
41 |
+
#protectedHeader;
|
42 |
+
#unprotectedHeader;
|
43 |
+
#aad;
|
44 |
constructor(plaintext) {
|
45 |
+
this.#plaintext = plaintext;
|
46 |
}
|
47 |
addRecipient(key, options) {
|
48 |
const recipient = new IndividualRecipient(this, key, { crit: options?.crit });
|
49 |
+
this.#recipients.push(recipient);
|
50 |
return recipient;
|
51 |
}
|
52 |
setProtectedHeader(protectedHeader) {
|
53 |
+
if (this.#protectedHeader) {
|
54 |
throw new TypeError('setProtectedHeader can only be called once');
|
55 |
}
|
56 |
+
this.#protectedHeader = protectedHeader;
|
57 |
return this;
|
58 |
}
|
59 |
setSharedUnprotectedHeader(sharedUnprotectedHeader) {
|
60 |
+
if (this.#unprotectedHeader) {
|
61 |
throw new TypeError('setSharedUnprotectedHeader can only be called once');
|
62 |
}
|
63 |
+
this.#unprotectedHeader = sharedUnprotectedHeader;
|
64 |
return this;
|
65 |
}
|
66 |
setAdditionalAuthenticatedData(aad) {
|
67 |
+
this.#aad = aad;
|
68 |
return this;
|
69 |
}
|
70 |
async encrypt() {
|
71 |
+
if (!this.#recipients.length) {
|
72 |
throw new JWEInvalid('at least one recipient must be added');
|
73 |
}
|
74 |
+
if (this.#recipients.length === 1) {
|
75 |
+
const [recipient] = this.#recipients;
|
76 |
+
const flattened = await new FlattenedEncrypt(this.#plaintext)
|
77 |
+
.setAdditionalAuthenticatedData(this.#aad)
|
78 |
+
.setProtectedHeader(this.#protectedHeader)
|
79 |
+
.setSharedUnprotectedHeader(this.#unprotectedHeader)
|
80 |
.setUnprotectedHeader(recipient.unprotectedHeader)
|
81 |
.encrypt(recipient.key, { ...recipient.options });
|
82 |
const jwe = {
|
|
|
98 |
return jwe;
|
99 |
}
|
100 |
let enc;
|
101 |
+
for (let i = 0; i < this.#recipients.length; i++) {
|
102 |
+
const recipient = this.#recipients[i];
|
103 |
+
if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader, recipient.unprotectedHeader)) {
|
104 |
throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');
|
105 |
}
|
106 |
const joseHeader = {
|
107 |
+
...this.#protectedHeader,
|
108 |
+
...this.#unprotectedHeader,
|
109 |
...recipient.unprotectedHeader,
|
110 |
};
|
111 |
const { alg } = joseHeader;
|
|
|
124 |
else if (enc !== joseHeader.enc) {
|
125 |
throw new JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients');
|
126 |
}
|
127 |
+
validateCrit(JWEInvalid, new Map(), recipient.options.crit, this.#protectedHeader, joseHeader);
|
128 |
if (joseHeader.zip !== undefined) {
|
129 |
throw new JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');
|
130 |
}
|
|
|
136 |
recipients: [],
|
137 |
tag: '',
|
138 |
};
|
139 |
+
for (let i = 0; i < this.#recipients.length; i++) {
|
140 |
+
const recipient = this.#recipients[i];
|
141 |
const target = {};
|
142 |
jwe.recipients.push(target);
|
143 |
const joseHeader = {
|
144 |
+
...this.#protectedHeader,
|
145 |
+
...this.#unprotectedHeader,
|
146 |
...recipient.unprotectedHeader,
|
147 |
};
|
148 |
const p2c = joseHeader.alg.startsWith('PBES2') ? 2048 + i : undefined;
|
149 |
if (i === 0) {
|
150 |
+
const flattened = await new FlattenedEncrypt(this.#plaintext)
|
151 |
+
.setAdditionalAuthenticatedData(this.#aad)
|
152 |
.setContentEncryptionKey(cek)
|
153 |
+
.setProtectedHeader(this.#protectedHeader)
|
154 |
+
.setSharedUnprotectedHeader(this.#unprotectedHeader)
|
155 |
.setUnprotectedHeader(recipient.unprotectedHeader)
|
156 |
.setKeyManagementParameters({ p2c })
|
157 |
.encrypt(recipient.key, {
|
|
|
173 |
continue;
|
174 |
}
|
175 |
const alg = recipient.unprotectedHeader?.alg ||
|
176 |
+
this.#protectedHeader?.alg ||
|
177 |
+
this.#unprotectedHeader?.alg;
|
178 |
checkKeyType(alg === 'dir' ? enc : alg, recipient.key, 'encrypt');
|
179 |
const k = await normalizeKey(recipient.key, alg);
|
180 |
const { encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, cek, { p2c });
|
.output/server/node_modules/jose/dist/webapi/jwks/local.js
CHANGED
@@ -23,25 +23,22 @@ function isJWKSLike(jwks) {
|
|
23 |
function isJWKLike(key) {
|
24 |
return isObject(key);
|
25 |
}
|
26 |
-
function clone(obj) {
|
27 |
-
if (typeof structuredClone === 'function') {
|
28 |
-
return structuredClone(obj);
|
29 |
-
}
|
30 |
-
return JSON.parse(JSON.stringify(obj));
|
31 |
-
}
|
32 |
class LocalJWKSet {
|
33 |
-
|
34 |
-
|
35 |
constructor(jwks) {
|
36 |
if (!isJWKSLike(jwks)) {
|
37 |
throw new JWKSInvalid('JSON Web Key Set malformed');
|
38 |
}
|
39 |
-
this
|
|
|
|
|
|
|
40 |
}
|
41 |
async getKey(protectedHeader, token) {
|
42 |
const { alg, kid } = { ...protectedHeader, ...token?.header };
|
43 |
const kty = getKtyFromAlg(alg);
|
44 |
-
const candidates = this.
|
45 |
let candidate = kty === jwk.kty;
|
46 |
if (candidate && typeof kid === 'string') {
|
47 |
candidate = kid === jwk.kid;
|
@@ -80,7 +77,7 @@ class LocalJWKSet {
|
|
80 |
}
|
81 |
if (length !== 1) {
|
82 |
const error = new JWKSMultipleMatchingKeys();
|
83 |
-
const
|
84 |
error[Symbol.asyncIterator] = async function* () {
|
85 |
for (const jwk of candidates) {
|
86 |
try {
|
@@ -91,7 +88,7 @@ class LocalJWKSet {
|
|
91 |
};
|
92 |
throw error;
|
93 |
}
|
94 |
-
return importWithAlgCache(this
|
95 |
}
|
96 |
}
|
97 |
async function importWithAlgCache(cache, jwk, alg) {
|
@@ -110,8 +107,8 @@ export function createLocalJWKSet(jwks) {
|
|
110 |
const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
111 |
Object.defineProperties(localJWKSet, {
|
112 |
jwks: {
|
113 |
-
value: () =>
|
114 |
-
enumerable:
|
115 |
configurable: false,
|
116 |
writable: false,
|
117 |
},
|
|
|
23 |
function isJWKLike(key) {
|
24 |
return isObject(key);
|
25 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
class LocalJWKSet {
|
27 |
+
#jwks;
|
28 |
+
#cached = new WeakMap();
|
29 |
constructor(jwks) {
|
30 |
if (!isJWKSLike(jwks)) {
|
31 |
throw new JWKSInvalid('JSON Web Key Set malformed');
|
32 |
}
|
33 |
+
this.#jwks = structuredClone(jwks);
|
34 |
+
}
|
35 |
+
jwks() {
|
36 |
+
return this.#jwks;
|
37 |
}
|
38 |
async getKey(protectedHeader, token) {
|
39 |
const { alg, kid } = { ...protectedHeader, ...token?.header };
|
40 |
const kty = getKtyFromAlg(alg);
|
41 |
+
const candidates = this.#jwks.keys.filter((jwk) => {
|
42 |
let candidate = kty === jwk.kty;
|
43 |
if (candidate && typeof kid === 'string') {
|
44 |
candidate = kid === jwk.kid;
|
|
|
77 |
}
|
78 |
if (length !== 1) {
|
79 |
const error = new JWKSMultipleMatchingKeys();
|
80 |
+
const _cached = this.#cached;
|
81 |
error[Symbol.asyncIterator] = async function* () {
|
82 |
for (const jwk of candidates) {
|
83 |
try {
|
|
|
88 |
};
|
89 |
throw error;
|
90 |
}
|
91 |
+
return importWithAlgCache(this.#cached, jwk, alg);
|
92 |
}
|
93 |
}
|
94 |
async function importWithAlgCache(cache, jwk, alg) {
|
|
|
107 |
const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
108 |
Object.defineProperties(localJWKSet, {
|
109 |
jwks: {
|
110 |
+
value: () => structuredClone(set.jwks()),
|
111 |
+
enumerable: false,
|
112 |
configurable: false,
|
113 |
writable: false,
|
114 |
},
|