From 432ba74523f602a7ddd21eb829ddbb8be9d5504e Mon Sep 17 00:00:00 2001 From: nenoNaninu Date: Wed, 10 Jan 2024 20:00:36 +0900 Subject: [PATCH 1/2] fix signalr-dev UI --- .../EmbeddedResourcePathProvider.cs | 6 +++--- .../signalr-dev/404.html | 2 +- .../static/chunks/pages/index-35305f187aac133c.js | 1 + .../static/chunks/pages/index-da9b02e27c214c1f.js | 1 - .../_buildManifest.js | 2 +- .../_ssgManifest.js | 0 .../signalr-dev/index.html | 2 +- src/signalr-dev-ui/components/HubMethodInvoker.tsx | 10 ++++------ 8 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-35305f187aac133c.js delete mode 100644 src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-da9b02e27c214c1f.js rename src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/{EXbk27KQSM-qv6yzRb185 => u2a4sJjRy5SZLBxPesZ5w}/_buildManifest.js (80%) rename src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/{EXbk27KQSM-qv6yzRb185 => u2a4sJjRy5SZLBxPesZ5w}/_ssgManifest.js (100%) diff --git a/src/TypedSignalR.Client.DevTools.UI/EmbeddedResourcePathProvider.cs b/src/TypedSignalR.Client.DevTools.UI/EmbeddedResourcePathProvider.cs index 9b6a7dd..83e9521 100644 --- a/src/TypedSignalR.Client.DevTools.UI/EmbeddedResourcePathProvider.cs +++ b/src/TypedSignalR.Client.DevTools.UI/EmbeddedResourcePathProvider.cs @@ -18,12 +18,12 @@ internal static class EmbeddedResourcePathProvider "signalr-dev/_next/static/chunks/main-558fc47eb84446ba.js", "signalr-dev/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js", "signalr-dev/_next/static/chunks/webpack-e65c1d101fc3e111.js", - "signalr-dev/_next/static/chunks/pages/index-da9b02e27c214c1f.js", + "signalr-dev/_next/static/chunks/pages/index-35305f187aac133c.js", "signalr-dev/_next/static/chunks/pages/_app-3fbddd7878bee85f.js", "signalr-dev/_next/static/chunks/pages/_error-8353112a01355ec2.js", "signalr-dev/_next/static/css/eecc0ebe6e775f93.css", - "signalr-dev/_next/static/EXbk27KQSM-qv6yzRb185/_buildManifest.js", - "signalr-dev/_next/static/EXbk27KQSM-qv6yzRb185/_ssgManifest.js", + "signalr-dev/_next/static/u2a4sJjRy5SZLBxPesZ5w/_buildManifest.js", + "signalr-dev/_next/static/u2a4sJjRy5SZLBxPesZ5w/_ssgManifest.js", }; public static IReadOnlyList GetPaths() => _paths; diff --git a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/404.html b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/404.html index d345200..b0b65e3 100644 --- a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/404.html +++ b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/404.html @@ -1 +1 @@ -404: This page could not be found

404

This page could not be found.

\ No newline at end of file +404: This page could not be found

404

This page could not be found.

\ No newline at end of file diff --git a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-35305f187aac133c.js b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-35305f187aac133c.js new file mode 100644 index 0000000..e0e040f --- /dev/null +++ b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-35305f187aac133c.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return t(2129)}])},2129:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return P}});var a=t(5893),l=t(7294);let n=e=>(0,a.jsx)(a.Fragment,{children:e.text&&(0,a.jsx)("pre",{className:"has-background-dark has-text-white pre-code",children:(0,a.jsx)("code",{className:"wrap-anywhere",children:e.text})})}),r=e=>{let[s,t]=(0,l.useState)(""),r=e.options,c=e.message;return(0,l.useEffect)(()=>{let e=JSON.stringify(c.content,null,4);t(e)},[c,r]),(0,a.jsxs)("div",{className:"box m-2",children:[(0,a.jsx)("div",{className:"is-large",children:(0,a.jsx)("strong",{children:e.message.methodName})}),(0,a.jsx)("div",{className:"m-3",children:r.indent?(0,a.jsx)(n,{text:s}):(0,a.jsx)("div",{className:"wrap-anywhere",children:s})})]})},c=e=>{let[s,t]=(0,l.useState)(!1),n=e.messages.map((e,t)=>(0,a.jsx)("div",{children:(0,a.jsx)(r,{message:{methodName:e.methodName,content:e.content},options:{indent:s}})},t)).reverse();return(0,a.jsxs)("div",{className:"h-screen vertical-container",children:[(0,a.jsx)("div",{className:"box",children:(0,a.jsxs)("div",{className:"level",children:[(0,a.jsx)("div",{className:"level-left",children:(0,a.jsx)("div",{className:"is-large",children:(0,a.jsx)("strong",{children:"Receive Message Log"})})}),(0,a.jsx)("div",{className:"level-right",children:(0,a.jsx)("div",{className:"content",children:(0,a.jsxs)("label",{className:"checkbox",children:[(0,a.jsx)("input",{type:"checkbox",onChange:e=>{t(e.target.checked)}}),"indent"]})})})]})}),(0,a.jsx)("div",{className:"h-max w-max",children:(0,a.jsx)("div",{className:"has-background-light scrollarea h-max",children:n})})]})};var i=t(7830),o=t(239);let d=e=>{let s=e.toLowerCase();return"true"===s},m=e=>Number(e),h=e=>new Date(e),u=e=>e?JSON.parse(e):null,x={bool:d,char:e=>e,byte:m,sbyte:m,decimal:m,double:m,float:m,int:m,uint:m,long:m,ulong:m,short:m,ushort:m,"byte[]":e=>e,string:e=>e,"global::System.Uri":e=>e,"global::System.Guid":e=>e,"global::System.DateTime":h,"global::System.DateTimeOffset":h},g=e=>e in x?x[e]:u,j=e=>{let s=e.method,t=e.hubConnection,[r,c]=(0,l.useState)([]),[i,o]=(0,l.useState)(null);(0,l.useEffect)(()=>{let s=Array(e.method.parameters.length);c(s)},[e.method]);let d=(0,l.useCallback)(()=>{let e=async()=>{console.log(r);try{let e=await (null==t?void 0:t.invoke(s.methodName,...r)),a="global::System.Threading.Tasks.Task"===s.returnType?"Invocation completed.":JSON.stringify(e,null,4);o(a)}catch(e){o("".concat(e))}};e()},[r,s,t,o]),m=e.method.parameters.map((e,s)=>(0,a.jsx)(p,{name:e.name,typeName:e.typeName,index:s,setArgs:c},s));return(0,a.jsxs)("div",{className:"box",children:[(0,a.jsx)("label",{className:"label is-large",children:s.methodName}),m,(0,a.jsx)("button",{className:"button is-info",disabled:!t,onClick:e=>d(),children:"Invoke"}),i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h5",{className:"m-3",children:["response : ",s.returnType]}),(0,a.jsx)(n,{text:i})]})]})},p=e=>{let[s,t]=(0,l.useState)(null),{name:n,typeName:r,index:c,setArgs:i}=e;return(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[n," : ",r]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:s?"input is-danger":"input",placeholder:r,onBlur:e=>{try{let s=e.target.value,a=g(r),l=a(s);i(e=>(e[c]=l,[...e])),t(void 0)}catch(e){i(e=>(e[c]=null,[...e])),t("".concat(e))}}})}),s&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(s)})]})},b=e=>{let s=e.method,t=e.hubConnection,r=e.setStreamMessage,[c,i]=(0,l.useState)([]),[o,d]=(0,l.useState)(null);(0,l.useEffect)(()=>{let s=Array(e.method.parameters.length);i(s)},[e.method]);let m=(0,l.useCallback)(()=>{let e=async()=>{console.log("=== ServerToClientStreamingHubMethodInvoker ==="),console.log(c);let e=v(s,c);console.log(e);try{null==t||t.stream(s.methodName,...e).subscribe({next:e=>{r({methodName:"".concat(s.methodName," : OnNext"),content:e})},complete:()=>{r({methodName:"".concat(s.methodName," : OnCompleted"),content:""}),d("Stream stoped.")},error:e=>{r({methodName:"".concat(s.methodName," : OnError"),content:"".concat(e)}),d("Stream stoped.")}}),d("Stream started.")}catch(e){d("".concat(e))}};e()},[c,s,t,d,r]),h=e.method.parameters.map((e,s)=>(0,a.jsx)(N,{name:e.name,typeName:e.typeName,index:s,setArgs:i},s));return(0,a.jsxs)("div",{className:"box",children:[(0,a.jsx)("label",{className:"label is-large",children:s.methodName}),h,(0,a.jsx)("button",{className:"button is-info",disabled:!t,onClick:e=>m(),children:"Invoke"}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h5",{className:"m-3",children:["response : ",s.returnType]}),(0,a.jsx)(n,{text:o})]})]})},N=e=>{let[s,t]=(0,l.useState)(null),{name:n,typeName:r,index:c,setArgs:i}=e;return(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[n," : ",r]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:s?"input is-danger":"input",placeholder:r,disabled:"global::System.Threading.CancellationToken"===r,onBlur:e=>{try{let s=e.target.value,a=g(r),l=a(s);i(e=>(e[c]=l,[...e])),t(void 0)}catch(e){i(e=>(e[c]=null,[...e])),t("".concat(e))}}})}),s&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(s)})]})},v=(e,s)=>{let t=e.parameters.map(e=>e.typeName).indexOf("global::System.Threading.CancellationToken");if(t<0)return s;let a=[...s];return a.splice(t,1),a};var y=t(5403);let f=e=>{let s=e.method,t=e.hubConnection,[r,c]=(0,l.useState)([]),[i,o]=(0,l.useState)(null),[d,m]=(0,l.useState)(null);(0,l.useEffect)(()=>{let s=Array(e.method.parameters.length);c(s)},[e.method]);let h=(0,l.useCallback)(()=>{let e=async()=>{console.log(r);let e=new y.x;o(e);try{let a=A(s,r,e);await (null==t?void 0:t.send(s.methodName,...a)),m("Stream started.")}catch(s){m("".concat(s)),o(null),null==e||e.error(s)}};e()},[r,s,t]),u=w(s),x=e.method.parameters.map((e,s)=>(0,a.jsx)(S,{name:e.name,typeName:e.typeName,index:s,setArgs:c},s));return(0,a.jsxs)("div",{className:"box",children:[(0,a.jsx)("label",{className:"label is-large",children:s.methodName}),x,(0,a.jsx)("button",{className:"button is-info",disabled:!t||!!i,onClick:e=>h(),children:"Invoke"}),(0,a.jsx)(R,{typeName:s.parameters[u].typeName,name:s.parameters[u].name,subject:i}),(0,a.jsx)("button",{className:"button is-info ml-3",disabled:!i,onClick:e=>{null==i||i.complete(),o(null),m("Stream stopped.")},children:"Complete"}),(0,a.jsx)("button",{className:"button is-info ml-3",disabled:!i,onClick:e=>{null==i||i.error("The stream has been canceled."),o(null),m("Stream stopped.")},children:"Cancel"}),d&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h5",{className:"m-3",children:["response : ",s.returnType]}),(0,a.jsx)(n,{text:d})]})]})},S=e=>{let[s,t]=(0,l.useState)(null),{name:n,typeName:r,index:c,setArgs:i}=e;return(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[n," : ",r]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:s?"input is-danger":"input",placeholder:r,disabled:T(r),onBlur:e=>{try{let s=e.target.value,a=g(r),l=a(s);i(e=>(e[c]=l,[...e])),t(void 0)}catch(e){i(e=>(e[c]=null,[...e])),t("".concat(e))}}})}),s&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(s)})]})},C="global::System.Collections.Generic.IAsyncEnumerable",k="global::System.Threading.Channels.ChannelReader",T=e=>!!(e.startsWith(C)||e.startsWith(k)),w=e=>{for(let s=0;s{let a=w(e);return a<0||(s[a]=t),s},R=e=>{let[s,t]=(0,l.useState)(null),[n,r]=(0,l.useState)(null),{name:c,typeName:i,subject:o}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[c," : ",i]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:n?"input is-danger":"input",placeholder:i,disabled:!o,onBlur:e=>{try{let s=e.target.value,a=g(E(i)),l=a(s);t(l),r(void 0)}catch(e){t(null),r("".concat(e))}}})}),n&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(n)})]}),(0,a.jsx)("button",{className:"button is-info",disabled:!o,onClick:e=>null==o?void 0:o.next(s),children:"Next"})]})},E=e=>{if(e.startsWith(C)){let s=C.length+1,t=e.length-1;return e.substring(s,t)}if(e.startsWith(k)){let s=k.length+1,t=e.length-1;return e.substring(s,t)}return""},_=e=>{let{method:s,hubConnection:t,setReceivedMessage:l}=e;return I(s)?(0,a.jsx)(b,{method:s,hubConnection:t,setStreamMessage:l}):W(s)?(0,a.jsx)(f,{method:s,hubConnection:t}):(0,a.jsx)(j,{method:s,hubConnection:t})},I=e=>!!(e.returnType.startsWith("global::System.Collections.Generic.IAsyncEnumerable")||e.returnType.startsWith("global::System.Threading.Tasks.Task{for(let s of e.parameters)if(s.typeName.startsWith("global::System.Collections.Generic.IAsyncEnumerable")||s.typeName.startsWith("global::System.Threading.Channels.ChannelReader"))return!0;return!1},M=["has-background-info-light","has-background-primary-light","has-background-danger-light"],O=e=>{let s=e.service,t=e.setReceivedMessage,[r,c]=(0,l.useState)(null),[d,m]=(0,l.useState)(null),[h,u]=(0,l.useState)(null),x=(0,l.useCallback)(()=>{let e=async()=>{if(r&&await r.stop(),s.isAuthRequired&&!h){m("Please input JWT.");return}let e=s.isAuthRequired?{accessTokenFactory:()=>h}:{},a=new i.s().withUrl(s.path,e).withAutomaticReconnect().configureLogging(o.i.Information).build();for(let e of s.receiverType.methods)a.on(e.methodName,function(){for(var s=arguments.length,a=Array(s),l=0;lx(),children:"Connect to Hub"}),(0,a.jsx)(n,{text:d}),(0,a.jsx)(J,{methods:s.hubType.methods,hubConnection:r,setReceivedMessage:t})]})})},F=e=>{let s=e.service;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h1",{className:"is-size-2",children:s.name}),(0,a.jsxs)("ul",{children:[(0,a.jsxs)("li",{children:["Hub Type: ",(0,a.jsx)("strong",{children:s.hubType.interfaceName})]}),(0,a.jsxs)("li",{children:["Receiver Type: ",(0,a.jsx)("strong",{children:s.receiverType.interfaceName})]}),(0,a.jsxs)("li",{children:["Path: ",(0,a.jsx)("strong",{children:s.path})]}),s.isAuthRequired&&(0,a.jsx)("li",{children:(0,a.jsx)("strong",{children:"Authorization Required"})})]})]})},q=e=>{let{isAuthRequired:s,hubConnection:t,setJwt:l}=e;return(0,a.jsx)(a.Fragment,{children:s&&(0,a.jsx)("div",{className:"field",children:(0,a.jsx)("p",{className:"control",children:(0,a.jsx)("input",{className:"input",type:"password",placeholder:"Input JWT",onBlur:e=>{let s=e.target.value;l(s)},disabled:!!t})})})})},J=e=>{let{methods:s,hubConnection:t,setReceivedMessage:l}=e,n=s.map((e,s)=>(0,a.jsx)(_,{method:e,hubConnection:t,setReceivedMessage:l},s));return(0,a.jsx)(a.Fragment,{children:n})},B=e=>{let s=e.services.map((s,t)=>(0,a.jsx)(O,{service:s,index:t,setReceivedMessage:e.setReceivedMessage},t));return(0,a.jsx)("div",{className:"m-5",children:s})},G=()=>{let[e,s]=(0,l.useState)([]),[t,n]=(0,l.useState)([]),r=(0,l.useCallback)(e=>s(s=>[...s,e]),[]);return(0,l.useEffect)(()=>{let e=async()=>{let e=await fetch("/signalr-dev/spec.json"),s=await e.json();console.log(s),n(s)};e()},[]),(0,a.jsxs)("div",{className:"columns h-screen w-screen",children:[(0,a.jsx)("div",{className:"column is-two-thirds scrollarea",children:(0,a.jsx)(B,{services:t,setReceivedMessage:r})}),(0,a.jsx)("div",{className:"column is-one-thirds",children:(0,a.jsx)("div",{children:(0,a.jsx)(c,{messages:e})})})]})};var P=G}},function(e){e.O(0,[830,774,888,179],function(){return e(e.s=8312)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-da9b02e27c214c1f.js b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-da9b02e27c214c1f.js deleted file mode 100644 index e0ba2b4..0000000 --- a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/chunks/pages/index-da9b02e27c214c1f.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return t(2129)}])},2129:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return P}});var a=t(5893),l=t(7294);let n=e=>(0,a.jsx)(a.Fragment,{children:e.text&&(0,a.jsx)("pre",{className:"has-background-dark has-text-white pre-code",children:(0,a.jsx)("code",{className:"wrap-anywhere",children:e.text})})}),r=e=>{let[s,t]=(0,l.useState)(""),r=e.options,c=e.message;return(0,l.useEffect)(()=>{let e=JSON.stringify(c.content,null,4);t(e)},[c,r]),(0,a.jsxs)("div",{className:"box m-2",children:[(0,a.jsx)("div",{className:"is-large",children:(0,a.jsx)("strong",{children:e.message.methodName})}),(0,a.jsx)("div",{className:"m-3",children:r.indent?(0,a.jsx)(n,{text:s}):(0,a.jsx)("div",{className:"wrap-anywhere",children:s})})]})},c=e=>{let[s,t]=(0,l.useState)(!1),n=e.messages.map((e,t)=>(0,a.jsx)("div",{children:(0,a.jsx)(r,{message:{methodName:e.methodName,content:e.content},options:{indent:s}})},t)).reverse();return(0,a.jsxs)("div",{className:"h-screen vertical-container",children:[(0,a.jsx)("div",{className:"box",children:(0,a.jsxs)("div",{className:"level",children:[(0,a.jsx)("div",{className:"level-left",children:(0,a.jsx)("div",{className:"is-large",children:(0,a.jsx)("strong",{children:"Receive Message Log"})})}),(0,a.jsx)("div",{className:"level-right",children:(0,a.jsx)("div",{className:"content",children:(0,a.jsxs)("label",{className:"checkbox",children:[(0,a.jsx)("input",{type:"checkbox",onChange:e=>{t(e.target.checked)}}),"indent"]})})})]})}),(0,a.jsx)("div",{className:"h-max w-max",children:(0,a.jsx)("div",{className:"has-background-light scrollarea h-max",children:n})})]})};var i=t(7830),o=t(239);let d=e=>{let s=e.toLowerCase();return"true"===s},m=e=>Number(e),h=e=>new Date(e),u=e=>e?JSON.parse(e):null,x={bool:d,char:e=>e,byte:m,sbyte:m,decimal:m,double:m,float:m,int:m,uint:m,long:m,ulong:m,short:m,ushort:m,"byte[]":e=>e,string:e=>e,"global::System.Uri":e=>e,"global::System.Guid":e=>e,"global::System.DateTime":h,"global::System.DateTimeOffset":h},g=e=>e in x?x[e]:u,j=e=>{let s=e.method,t=e.hubConnection,[r,c]=(0,l.useState)([]),[i,o]=(0,l.useState)(null);(0,l.useEffect)(()=>{let s=Array(e.method.parameters.length);c(s)},[e.method]);let d=(0,l.useCallback)(()=>{let e=async()=>{console.log(r);try{let e=await (null==t?void 0:t.invoke(s.methodName,...r)),a=e?JSON.stringify(e,null,4):"global::System.Threading.Tasks.Task"===s.returnType?"Invocation completed.":"null";o(a)}catch(e){o("".concat(e))}};e()},[r,s,t,o]),m=e.method.parameters.map((e,s)=>(0,a.jsx)(p,{name:e.name,typeName:e.typeName,index:s,setArgs:c},s));return(0,a.jsxs)("div",{className:"box",children:[(0,a.jsx)("label",{className:"label is-large",children:s.methodName}),m,(0,a.jsx)("button",{className:"button is-info",disabled:!t,onClick:e=>d(),children:"Invoke"}),i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h5",{className:"m-3",children:["response : ",s.returnType]}),(0,a.jsx)(n,{text:i})]})]})},p=e=>{let[s,t]=(0,l.useState)(null),{name:n,typeName:r,index:c,setArgs:i}=e;return(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[n," : ",r]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:s?"input is-danger":"input",placeholder:r,onBlur:e=>{try{let s=e.target.value,a=g(r),l=a(s);i(e=>(e[c]=l,[...e])),t(void 0)}catch(e){i(e=>(e[c]=null,[...e])),t("".concat(e))}}})}),s&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(s)})]})},b=e=>{let s=e.method,t=e.hubConnection,r=e.setStreamMessage,[c,i]=(0,l.useState)([]),[o,d]=(0,l.useState)(null);(0,l.useEffect)(()=>{let s=Array(e.method.parameters.length);i(s)},[e.method]);let m=(0,l.useCallback)(()=>{let e=async()=>{console.log("=== ServerToClientStreamingHubMethodInvoker ==="),console.log(c);let e=v(s,c);console.log(e);try{null==t||t.stream(s.methodName,...e).subscribe({next:e=>{r({methodName:"".concat(s.methodName," : OnNext"),content:e})},complete:()=>{r({methodName:"".concat(s.methodName," : OnCompleted"),content:""}),d("Stream stoped.")},error:e=>{r({methodName:"".concat(s.methodName," : OnError"),content:"".concat(e)}),d("Stream stoped.")}}),d("Stream started.")}catch(e){d("".concat(e))}};e()},[c,s,t,d,r]),h=e.method.parameters.map((e,s)=>(0,a.jsx)(N,{name:e.name,typeName:e.typeName,index:s,setArgs:i},s));return(0,a.jsxs)("div",{className:"box",children:[(0,a.jsx)("label",{className:"label is-large",children:s.methodName}),h,(0,a.jsx)("button",{className:"button is-info",disabled:!t,onClick:e=>m(),children:"Invoke"}),o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h5",{className:"m-3",children:["response : ",s.returnType]}),(0,a.jsx)(n,{text:o})]})]})},N=e=>{let[s,t]=(0,l.useState)(null),{name:n,typeName:r,index:c,setArgs:i}=e;return(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[n," : ",r]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:s?"input is-danger":"input",placeholder:r,disabled:"global::System.Threading.CancellationToken"===r,onBlur:e=>{try{let s=e.target.value,a=g(r),l=a(s);i(e=>(e[c]=l,[...e])),t(void 0)}catch(e){i(e=>(e[c]=null,[...e])),t("".concat(e))}}})}),s&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(s)})]})},v=(e,s)=>{let t=e.parameters.map(e=>e.typeName).indexOf("global::System.Threading.CancellationToken");if(t<0)return s;let a=[...s];return a.splice(t,1),a};var y=t(5403);let f=e=>{let s=e.method,t=e.hubConnection,[r,c]=(0,l.useState)([]),[i,o]=(0,l.useState)(null),[d,m]=(0,l.useState)(null);(0,l.useEffect)(()=>{let s=Array(e.method.parameters.length);c(s)},[e.method]);let h=(0,l.useCallback)(()=>{let e=async()=>{console.log(r);let e=new y.x;o(e);try{let a=A(s,r,e);await (null==t?void 0:t.send(s.methodName,...a)),m("Stream started.")}catch(s){m("".concat(s)),o(null),null==e||e.error(s)}};e()},[r,s,t]),u=w(s),x=e.method.parameters.map((e,s)=>(0,a.jsx)(S,{name:e.name,typeName:e.typeName,index:s,setArgs:c},s));return(0,a.jsxs)("div",{className:"box",children:[(0,a.jsx)("label",{className:"label is-large",children:s.methodName}),x,(0,a.jsx)("button",{className:"button is-info",disabled:!t||!!i,onClick:e=>h(),children:"Invoke"}),(0,a.jsx)(R,{typeName:s.parameters[u].typeName,name:s.parameters[u].name,subject:i}),(0,a.jsx)("button",{className:"button is-info ml-3",disabled:!i,onClick:e=>{null==i||i.complete(),o(null),m("Stream stopped.")},children:"Complete"}),(0,a.jsx)("button",{className:"button is-info ml-3",disabled:!i,onClick:e=>{null==i||i.error("The stream has been canceled."),o(null),m("Stream stopped.")},children:"Cancel"}),d&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("h5",{className:"m-3",children:["response : ",s.returnType]}),(0,a.jsx)(n,{text:d})]})]})},S=e=>{let[s,t]=(0,l.useState)(null),{name:n,typeName:r,index:c,setArgs:i}=e;return(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[n," : ",r]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:s?"input is-danger":"input",placeholder:r,disabled:T(r),onBlur:e=>{try{let s=e.target.value,a=g(r),l=a(s);i(e=>(e[c]=l,[...e])),t(void 0)}catch(e){i(e=>(e[c]=null,[...e])),t("".concat(e))}}})}),s&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(s)})]})},C="global::System.Collections.Generic.IAsyncEnumerable",k="global::System.Threading.Channels.ChannelReader",T=e=>!!(e.startsWith(C)||e.startsWith(k)),w=e=>{for(let s=0;s{let a=w(e);return a<0||(s[a]=t),s},R=e=>{let[s,t]=(0,l.useState)(null),[n,r]=(0,l.useState)(null),{name:c,typeName:i,subject:o}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"field",children:[(0,a.jsxs)("label",{className:"label",children:[c," : ",i]}),(0,a.jsx)("div",{className:"control",children:(0,a.jsx)("textarea",{className:n?"input is-danger":"input",placeholder:i,disabled:!o,onBlur:e=>{try{let s=e.target.value,a=g(E(i)),l=a(s);t(l),r(void 0)}catch(e){t(null),r("".concat(e))}}})}),n&&(0,a.jsx)("p",{className:"help is-danger",children:"".concat(n)})]}),(0,a.jsx)("button",{className:"button is-info",disabled:!o,onClick:e=>null==o?void 0:o.next(s),children:"Next"})]})},E=e=>{if(e.startsWith(C)){let s=C.length+1,t=e.length-1;return e.substring(s,t)}if(e.startsWith(k)){let s=k.length+1,t=e.length-1;return e.substring(s,t)}return""},_=e=>{let{method:s,hubConnection:t,setReceivedMessage:l}=e;return I(s)?(0,a.jsx)(b,{method:s,hubConnection:t,setStreamMessage:l}):W(s)?(0,a.jsx)(f,{method:s,hubConnection:t}):(0,a.jsx)(j,{method:s,hubConnection:t})},I=e=>!!(e.returnType.startsWith("global::System.Collections.Generic.IAsyncEnumerable")||e.returnType.startsWith("global::System.Threading.Tasks.Task{for(let s of e.parameters)if(s.typeName.startsWith("global::System.Collections.Generic.IAsyncEnumerable")||s.typeName.startsWith("global::System.Threading.Channels.ChannelReader"))return!0;return!1},M=["has-background-info-light","has-background-primary-light","has-background-danger-light"],O=e=>{let s=e.service,t=e.setReceivedMessage,[r,c]=(0,l.useState)(null),[d,m]=(0,l.useState)(null),[h,u]=(0,l.useState)(null),x=(0,l.useCallback)(()=>{let e=async()=>{if(r&&await r.stop(),s.isAuthRequired&&!h){m("Please input JWT.");return}let e=s.isAuthRequired?{accessTokenFactory:()=>h}:{},a=new i.s().withUrl(s.path,e).withAutomaticReconnect().configureLogging(o.i.Information).build();for(let e of s.receiverType.methods)a.on(e.methodName,function(){for(var s=arguments.length,a=Array(s),l=0;lx(),children:"Connect to Hub"}),(0,a.jsx)(n,{text:d}),(0,a.jsx)(J,{methods:s.hubType.methods,hubConnection:r,setReceivedMessage:t})]})})},F=e=>{let s=e.service;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h1",{className:"is-size-2",children:s.name}),(0,a.jsxs)("ul",{children:[(0,a.jsxs)("li",{children:["Hub Type: ",(0,a.jsx)("strong",{children:s.hubType.interfaceName})]}),(0,a.jsxs)("li",{children:["Receiver Type: ",(0,a.jsx)("strong",{children:s.receiverType.interfaceName})]}),(0,a.jsxs)("li",{children:["Path: ",(0,a.jsx)("strong",{children:s.path})]}),s.isAuthRequired&&(0,a.jsx)("li",{children:(0,a.jsx)("strong",{children:"Authorization Required"})})]})]})},q=e=>{let{isAuthRequired:s,hubConnection:t,setJwt:l}=e;return(0,a.jsx)(a.Fragment,{children:s&&(0,a.jsx)("div",{className:"field",children:(0,a.jsx)("p",{className:"control",children:(0,a.jsx)("input",{className:"input",type:"password",placeholder:"Input JWT",onBlur:e=>{let s=e.target.value;l(s)},disabled:!!t})})})})},J=e=>{let{methods:s,hubConnection:t,setReceivedMessage:l}=e,n=s.map((e,s)=>(0,a.jsx)(_,{method:e,hubConnection:t,setReceivedMessage:l},s));return(0,a.jsx)(a.Fragment,{children:n})},B=e=>{let s=e.services.map((s,t)=>(0,a.jsx)(O,{service:s,index:t,setReceivedMessage:e.setReceivedMessage},t));return(0,a.jsx)("div",{className:"m-5",children:s})},G=()=>{let[e,s]=(0,l.useState)([]),[t,n]=(0,l.useState)([]),r=(0,l.useCallback)(e=>s(s=>[...s,e]),[]);return(0,l.useEffect)(()=>{let e=async()=>{let e=await fetch("/signalr-dev/spec.json"),s=await e.json();console.log(s),n(s)};e()},[]),(0,a.jsxs)("div",{className:"columns h-screen w-screen",children:[(0,a.jsx)("div",{className:"column is-two-thirds scrollarea",children:(0,a.jsx)(B,{services:t,setReceivedMessage:r})}),(0,a.jsx)("div",{className:"column is-one-thirds",children:(0,a.jsx)("div",{children:(0,a.jsx)(c,{messages:e})})})]})};var P=G}},function(e){e.O(0,[830,774,888,179],function(){return e(e.s=8312)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/EXbk27KQSM-qv6yzRb185/_buildManifest.js b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/u2a4sJjRy5SZLBxPesZ5w/_buildManifest.js similarity index 80% rename from src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/EXbk27KQSM-qv6yzRb185/_buildManifest.js rename to src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/u2a4sJjRy5SZLBxPesZ5w/_buildManifest.js index f450b84..c883941 100644 --- a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/EXbk27KQSM-qv6yzRb185/_buildManifest.js +++ b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/u2a4sJjRy5SZLBxPesZ5w/_buildManifest.js @@ -1 +1 @@ -self.__BUILD_MANIFEST={__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":["static/chunks/830-9d48ffa709498335.js","static/chunks/pages/index-da9b02e27c214c1f.js"],"/_error":["static/chunks/pages/_error-8353112a01355ec2.js"],sortedPages:["/","/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file +self.__BUILD_MANIFEST={__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":["static/chunks/830-9d48ffa709498335.js","static/chunks/pages/index-35305f187aac133c.js"],"/_error":["static/chunks/pages/_error-8353112a01355ec2.js"],sortedPages:["/","/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); \ No newline at end of file diff --git a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/EXbk27KQSM-qv6yzRb185/_ssgManifest.js b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/u2a4sJjRy5SZLBxPesZ5w/_ssgManifest.js similarity index 100% rename from src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/EXbk27KQSM-qv6yzRb185/_ssgManifest.js rename to src/TypedSignalR.Client.DevTools.UI/signalr-dev/_next/static/u2a4sJjRy5SZLBxPesZ5w/_ssgManifest.js diff --git a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/index.html b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/index.html index b504cad..ff2a328 100644 --- a/src/TypedSignalR.Client.DevTools.UI/signalr-dev/index.html +++ b/src/TypedSignalR.Client.DevTools.UI/signalr-dev/index.html @@ -1 +1 @@ -
Receive Message Log
\ No newline at end of file +
Receive Message Log
\ No newline at end of file diff --git a/src/signalr-dev-ui/components/HubMethodInvoker.tsx b/src/signalr-dev-ui/components/HubMethodInvoker.tsx index 94e2cd3..afff8e0 100644 --- a/src/signalr-dev-ui/components/HubMethodInvoker.tsx +++ b/src/signalr-dev-ui/components/HubMethodInvoker.tsx @@ -24,14 +24,12 @@ export const HubMethodInvoker: FC = props => { const invoke = useCallback(() => { const f = async () => { - console.log(args) - try { const ret = await hubConnection?.invoke(method.methodName, ...args); - const viewText = ret - ? JSON.stringify(ret, null, 4) - : method.returnType === "global::System.Threading.Tasks.Task" - ? "Invocation completed." : "null"; + + const viewText = method.returnType === "global::System.Threading.Tasks.Task" + ? "Invocation completed." + : JSON.stringify(ret, null, 4); setMessage(viewText); } catch (e) { From 9203ce2f4a4ec542e87352559730d6839c9e99f4 Mon Sep 17 00:00:00 2001 From: nenoNaninu Date: Wed, 10 Jan 2024 20:01:01 +0900 Subject: [PATCH 2/2] update examples --- examples/Server/Hubs/UnaryHub.cs | 16 +++++++++++++++- examples/Shared/IUnaryHub.cs | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/examples/Server/Hubs/UnaryHub.cs b/examples/Server/Hubs/UnaryHub.cs index 431efcf..d8ba635 100644 --- a/examples/Server/Hubs/UnaryHub.cs +++ b/examples/Server/Hubs/UnaryHub.cs @@ -48,10 +48,24 @@ public Task Echo4(DateTime dateTime) return Task.FromResult(dateTime.ToUniversalTime()); } - public Task Get() + public Task GetString() { _logger.Log(LogLevel.Information, "UnaryHub.Get"); return Task.FromResult("TypedSignalR.Client"); } + public Task GetEmptyString() + { + return Task.FromResult(string.Empty); + } + + public Task GetFalse() + { + return Task.FromResult(false); + } + + public Task GetTrue() + { + return Task.FromResult(true); + } } diff --git a/examples/Shared/IUnaryHub.cs b/examples/Shared/IUnaryHub.cs index 2081fdf..ddbf6df 100644 --- a/examples/Shared/IUnaryHub.cs +++ b/examples/Shared/IUnaryHub.cs @@ -13,13 +13,18 @@ public class UserDefinedType [Hub] public interface IUnaryHub { - Task Get(); + Task GetString(); + Task GetEmptyString(); + Task Add(int x, int y); Task Cat(string x, string y); Task Echo(UserDefinedType instance); Task Echo2(byte[] binary); Task Echo3(Guid id); Task Echo4(DateTime dateTime); + + Task GetTrue(); + Task GetFalse(); } [Receiver]