You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
9.8 KiB
JavaScript
1 line
9.8 KiB
JavaScript
exports.id=223,exports.ids=[223],exports.modules={9127:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r,a,i=n(6413);function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}let l=function(e){return i.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),r||(r=i.createElement("defs",null,i.createElement("path",{id:"edit_svg__a",d:"M0 0h16v16H0z"}))),i.createElement("g",null,a||(a=i.createElement("mask",{id:"edit_svg__b",fill:"#fff"},i.createElement("use",{xlinkHref:"#edit_svg__a"}))),i.createElement("g",{mask:"url(#edit_svg__b)"},i.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M2.83 0v3c0 .37-.3.67-.66.67H0",transform:"translate(10.5 11)"}),i.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M10.67 4V.67c0-.37-.3-.67-.67-.67H.67C.3 0 0 .3 0 .67v12c0 .36.3.66.67.66h2",transform:"translate(2.667 1.333)"}),i.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M0 0h4.67",transform:"translate(5.333 5.333)"}),i.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"m0 7 5.67-7",transform:"translate(7.667 7.667)"}),i.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M0 0h2.67",transform:"translate(5.333 8)"}))))}},35223:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PluginPage:()=>E});var r=n(95344),a=n(75499),i=n(11980),s=n.n(i),l=n(1191),c=n(99608),u=n(70580),o=n(99668),d=n(94313),h=n.n(d),m=n(4563),g=n.n(m),x=n(9127),p=n(32263),k=n(26989),f=n(12670),_=n(99992),j=n(30841),v=n(47572),P=n(91969),y=n(6068),b=n(9719),Z=n(17304),w=n(3729),C=n(56815);function E(){let e=(0,Z.s0)(),t=(0,P.RQ)(),n=t.getAll(),[i,d]=(0,w.useState)([]),[m,E]=(0,w.useState)(""),N=m.length>0?i:n,T=e=>{E(e),e.length>0?d(n.filter(t=>t?.title.toLowerCase().includes(e.toLowerCase()))):d(n)},[H,M]=(0,w.useState)(),R=t.get(H),A=P.aN.get(R?.id),L=(0,a.y1)((e,n)=>{let r=n.target.innerText;try{new(s())({definition:l.ZP.load(r)}).init().then(()=>{r!=e.content&&t.updatePlugin(e.id,e=>{e.content=r;let t=P.aN.add(e,!0);e.title=t.api.definition.info.title,e.version=t.api.definition.info.version})}).catch(e=>{console.error(e),(0,y.CF)(b.ZP.Plugin.EditModal.Error)})}catch(e){console.error(e),(0,y.CF)(b.ZP.Plugin.EditModal.Error)}},100).bind(null,R),[O,D]=(0,w.useState)(""),I=e=>fetch(e).catch(t=>{let n=new URL(e);return fetch(`/api/proxy/${n.pathname}?${n.search}`,{headers:{"X-Base-URL":n.origin}})}).then(e=>e.text()).then(e=>{try{return JSON.stringify(JSON.parse(e),null," ")}catch(t){return e}}).then(e=>{t.updatePlugin(R.id,t=>{t.content=e;let n=P.aN.add(t,!0);t.title=n.api.definition.info.title,t.version=n.api.definition.info.version})}).catch(e=>{(0,y.CF)(b.ZP.Plugin.EditModal.Error)});return(0,r.jsxs)(o.S,{children:[(0,r.jsxs)("div",{className:h()["mask-page"],children:[(0,r.jsxs)("div",{className:"window-header",children:[(0,r.jsxs)("div",{className:"window-header-title",children:[r.jsx("div",{className:"window-header-main-title",children:b.ZP.Plugin.Page.Title}),r.jsx("div",{className:"window-header-submai-title",children:b.ZP.Plugin.Page.SubTitle(N.length)})]}),(0,r.jsxs)("div",{className:"window-actions",children:[r.jsx("div",{className:"window-action-button",children:r.jsx("a",{href:c.m9,target:"_blank",rel:"noopener noreferrer",children:r.jsx(u.h,{icon:r.jsx(v.Z,{}),bordered:!0})})}),r.jsx("div",{className:"window-action-button",children:r.jsx(u.h,{icon:r.jsx(k.Z,{}),bordered:!0,onClick:()=>e(-1)})})]})]}),(0,r.jsxs)("div",{className:h()["mask-page-body"],children:[(0,r.jsxs)("div",{className:h()["mask-filter"],children:[r.jsx("input",{type:"text",className:h()["search-bar"],placeholder:b.ZP.Plugin.Page.Search,autoFocus:!0,onInput:e=>T(e.currentTarget.value)}),r.jsx(u.h,{className:h()["mask-create"],icon:r.jsx(p.Z,{}),text:b.ZP.Plugin.Page.Create,bordered:!0,onClick:()=>{M(t.create().id)}})]}),(0,r.jsxs)("div",{children:[0==N.length&&(0,r.jsxs)("div",{style:{display:"flex",margin:"60px auto",alignItems:"center",justifyContent:"center"},children:[b.ZP.Plugin.Page.Find,r.jsx("a",{href:c.m9,target:"_blank",rel:"noopener noreferrer",style:{marginLeft:16},children:r.jsx(u.h,{icon:r.jsx(v.Z,{}),bordered:!0})})]}),N.map(e=>(0,r.jsxs)("div",{className:h()["mask-item"],children:[(0,r.jsxs)("div",{className:h()["mask-header"],children:[r.jsx("div",{className:h()["mask-icon"]}),(0,r.jsxs)("div",{className:h()["mask-title"],children:[(0,r.jsxs)("div",{className:h()["mask-name"],children:[e.title,"@",r.jsx("small",{children:e.version})]}),r.jsx("div",{className:(0,C.Z)(h()["mask-info"],"one-line"),children:b.ZP.Plugin.Item.Info(P.aN.add(e).length)})]})]}),(0,r.jsxs)("div",{className:h()["mask-actions"],children:[r.jsx(u.h,{icon:r.jsx(x.Z,{}),text:b.ZP.Plugin.Item.Edit,onClick:()=>M(e.id)}),!e.builtin&&r.jsx(u.h,{icon:r.jsx(f.Z,{}),text:b.ZP.Plugin.Item.Delete,onClick:async()=>{await (0,y.i0)(b.ZP.Plugin.Item.DeleteConfirm)&&t.delete(e.id)}})]})]},e.id))]})]})]}),R&&r.jsx("div",{className:"modal-mask",children:(0,r.jsxs)(y.u_,{title:b.ZP.Plugin.EditModal.Title(R?.builtin),onClose:()=>M(void 0),actions:[r.jsx(u.h,{icon:r.jsx(_.Z,{}),text:b.ZP.UI.Confirm,bordered:!0,onClick:()=>M("")},"export")],children:[(0,r.jsxs)(y.aV,{children:[r.jsx(y.HC,{title:b.ZP.Plugin.EditModal.Auth,children:(0,r.jsxs)("select",{value:R?.authType,onChange:e=>{t.updatePlugin(R.id,t=>{t.authType=e.target.value})},children:[r.jsx("option",{value:"",children:b.ZP.Plugin.Auth.None}),r.jsx("option",{value:"bearer",children:b.ZP.Plugin.Auth.Bearer}),r.jsx("option",{value:"basic",children:b.ZP.Plugin.Auth.Basic}),r.jsx("option",{value:"custom",children:b.ZP.Plugin.Auth.Custom})]})}),["bearer","basic","custom"].includes(R.authType)&&r.jsx(y.HC,{title:b.ZP.Plugin.Auth.Location,children:(0,r.jsxs)("select",{value:R?.authLocation,onChange:e=>{t.updatePlugin(R.id,t=>{t.authLocation=e.target.value})},children:[r.jsx("option",{value:"header",children:b.ZP.Plugin.Auth.LocationHeader}),r.jsx("option",{value:"query",children:b.ZP.Plugin.Auth.LocationQuery}),r.jsx("option",{value:"body",children:b.ZP.Plugin.Auth.LocationBody})]})}),"custom"==R.authType&&r.jsx(y.HC,{title:b.ZP.Plugin.Auth.CustomHeader,children:r.jsx("input",{type:"text",value:R?.authHeader,onChange:e=>{t.updatePlugin(R.id,t=>{t.authHeader=e.target.value})}})}),["bearer","basic","custom"].includes(R.authType)&&r.jsx(y.HC,{title:b.ZP.Plugin.Auth.Token,children:r.jsx(y.WU,{type:"text",value:R?.authToken,onChange:e=>{t.updatePlugin(R.id,t=>{t.authToken=e.currentTarget.value})}})})]}),(0,r.jsxs)(y.aV,{children:[r.jsx(y.HC,{title:b.ZP.Plugin.EditModal.Content,children:(0,r.jsxs)("div",{className:g()["plugin-schema"],children:[r.jsx("input",{type:"text",style:{minWidth:200},onInput:e=>D(e.currentTarget.value)}),r.jsx(u.h,{icon:r.jsx(j.Z,{}),text:b.ZP.Plugin.EditModal.Load,bordered:!0,onClick:()=>I(O)})]})}),r.jsx(y.HC,{subTitle:r.jsx("div",{className:(0,C.Z)("markdown-body",g()["plugin-content"]),dir:"auto",children:r.jsx("pre",{children:r.jsx("code",{contentEditable:!0,dangerouslySetInnerHTML:{__html:R.content},onBlur:L})})})}),A?.tools.map((e,t)=>r.jsx(y.HC,{title:e?.function?.name,subTitle:e?.function?.description},t))]})]})})]})}},75499:(e,t,n)=>{"use strict";n.d(t,{y1:()=>a});var r=n(3729);function a(e,t,n){var a=this,i=(0,r.useRef)(null),s=(0,r.useRef)(0),l=(0,r.useRef)(null),c=(0,r.useRef)([]),u=(0,r.useRef)(),o=(0,r.useRef)(),d=(0,r.useRef)(e),h=(0,r.useRef)(!0);(0,r.useEffect)(function(){d.current=e},[e]);var m=!t&&0!==t&&!1;if("function"!=typeof e)throw TypeError("Expected a function");t=+t||0;var g=!!(n=n||{}).leading,x=!("trailing"in n)||!!n.trailing,p="maxWait"in n,k=p?Math.max(+n.maxWait||0,t):null;return(0,r.useEffect)(function(){return h.current=!0,function(){h.current=!1}},[]),(0,r.useMemo)(function(){var e=function(e){var t=c.current,n=u.current;return c.current=u.current=null,s.current=e,o.current=d.current.apply(n,t)},n=function(e,t){m&&cancelAnimationFrame(l.current),l.current=m?requestAnimationFrame(e):setTimeout(e,t)},r=function(e){if(!h.current)return!1;var n=e-i.current;return!i.current||n>=t||n<0||p&&e-s.current>=k},f=function(t){return l.current=null,x&&c.current?e(t):(c.current=u.current=null,o.current)},_=function e(){var a=Date.now();if(r(a))return f(a);if(h.current){var l=t-(a-i.current);n(e,p?Math.min(l,k-(a-s.current)):l)}},j=function(){var d=Date.now(),m=r(d);if(c.current=[].slice.call(arguments),u.current=a,i.current=d,m){if(!l.current&&h.current)return s.current=i.current,n(_,t),g?e(i.current):o.current;if(p)return n(_,t),e(i.current)}return l.current||n(_,t),o.current};return j.cancel=function(){l.current&&(m?cancelAnimationFrame(l.current):clearTimeout(l.current)),s.current=0,c.current=i.current=u.current=l.current=null},j.isPending=function(){return!!l.current},j.flush=function(){return l.current?f(Date.now()):o.current},j},[g,p,t,k,x,m])}},94313:e=>{e.exports={"mask-page":"mask_mask-page__ou14k","mask-page-body":"mask_mask-page-body__kBXsJ","mask-filter":"mask_mask-filter__OdpU3","slide-in":"mask_slide-in__unpXH","search-bar":"mask_search-bar__7_Msn","mask-filter-lang":"mask_mask-filter-lang__mRxyv","mask-create":"mask_mask-create__BjAzk","mask-item":"mask_mask-item__dinia","mask-header":"mask_mask-header__RXJXI","mask-icon":"mask_mask-icon__wO1ER","mask-title":"mask_mask-title__IDEbR","mask-name":"mask_mask-name__77Rjh","mask-info":"mask_mask-info__2gtiu","mask-actions":"mask_mask-actions__rsWn_","slide-in-from-top":"mask_slide-in-from-top__DOEYB"}},4563:e=>{e.exports={"plugin-title":"plugin_plugin-title__Yr4S3","plugin-content":"plugin_plugin-content__xCgR_","plugin-schema":"plugin_plugin-schema__Lbtdv"}}}; |