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.
2 lines
27 KiB
JavaScript
2 lines
27 KiB
JavaScript
(this["webpackJsonpmitmproxy-client"]=this["webpackJsonpmitmproxy-client"]||[]).push([[0],{62:function(e,t,s){},68:function(e,t,s){"use strict";s.r(t);var n,i=s(1),r=s.n(i),o=s(20),a=s.n(o),c=(s(61),s(7)),l=s(8),h=s(15),d=s(14),u=s(55),p=s(10),j=s(13),v=s(51),b=s.n(v),y=(s(62),s(2)),f=s(22),w=s(16),O=s(45),x=s(31),S=s(0),R=function(e){Object(h.a)(s,e);var t=Object(d.a)(s);function s(e){var n;return Object(c.a)(this,s),(n=t.call(this,e)).state={show:!1,rule:{method:"ALL",url:"",action:1},haveRules:!1},n.handleClose=n.handleClose.bind(Object(f.a)(n)),n.handleShow=n.handleShow.bind(Object(f.a)(n)),n.handleSave=n.handleSave.bind(Object(f.a)(n)),n}return Object(l.a)(s,[{key:"handleClose",value:function(){this.setState({show:!1})}},{key:"handleShow",value:function(){this.setState({show:!0})}},{key:"handleSave",value:function(){var e=this.state.rule,t=[];e.url&&t.push({method:"ALL"===e.method?"":e.method,url:e.url,action:e.action}),this.props.onSave(t),this.handleClose(),this.setState({haveRules:!!t.length})}},{key:"render",value:function(){var e=this,t=this.state,s=t.rule,n=t.haveRules?"success":"primary";return Object(S.jsxs)("div",{children:[Object(S.jsx)(j.a,{variant:n,size:"sm",onClick:this.handleShow,children:"BreakPoint"}),Object(S.jsxs)(w.a,{show:this.state.show,onHide:this.handleClose,children:[Object(S.jsx)(w.a.Header,{closeButton:!0,children:Object(S.jsx)(w.a.Title,{children:"Set BreakPoint"})}),Object(S.jsxs)(w.a.Body,{children:[Object(S.jsxs)(p.a.Group,{as:O.a,children:[Object(S.jsx)(p.a.Label,{column:!0,sm:2,children:"Method"}),Object(S.jsx)(x.a,{sm:10,children:Object(S.jsxs)(p.a.Control,{as:"select",value:s.method,onChange:function(t){e.setState({rule:Object(y.a)(Object(y.a)({},s),{},{method:t.target.value})})},children:[Object(S.jsx)("option",{children:"ALL"}),Object(S.jsx)("option",{children:"GET"}),Object(S.jsx)("option",{children:"POST"}),Object(S.jsx)("option",{children:"PUT"}),Object(S.jsx)("option",{children:"DELETE"})]})})]}),Object(S.jsxs)(p.a.Group,{as:O.a,children:[Object(S.jsx)(p.a.Label,{column:!0,sm:2,children:"URL"}),Object(S.jsx)(x.a,{sm:10,children:Object(S.jsx)(p.a.Control,{value:s.url,onChange:function(t){e.setState({rule:Object(y.a)(Object(y.a)({},s),{},{url:t.target.value})})}})})]}),Object(S.jsxs)(p.a.Group,{as:O.a,children:[Object(S.jsx)(p.a.Label,{column:!0,sm:2,children:"Action"}),Object(S.jsx)(x.a,{sm:10,children:Object(S.jsxs)(p.a.Control,{as:"select",value:s.action,onChange:function(t){e.setState({rule:Object(y.a)(Object(y.a)({},s),{},{action:parseInt(t.target.value)})})},children:[Object(S.jsx)("option",{value:"1",children:"Request"}),Object(S.jsx)("option",{value:"2",children:"Response"}),Object(S.jsx)("option",{value:"3",children:"Both"})]})})]})]}),Object(S.jsxs)(w.a.Footer,{children:[Object(S.jsx)(j.a,{variant:"secondary",onClick:this.handleClose,children:"Close"}),Object(S.jsx)(j.a,{variant:"primary",onClick:this.handleSave,children:"Save"})]})]})]})}}]),s}(r.a.Component),m=function(e){return!!e&&(!!e.header&&(!!e.header["Content-Type"]&&/text|javascript|json|x-www-form-urlencoded|xml|form-data/.test(e.header["Content-Type"].join(""))))},g=function(e){return e?isNaN(e)||e<=0?"0":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(2)," KB"):"".concat((e/1048576).toFixed(2)," MB"):"0"},E=function(e){for(var t="",s=new Uint8Array(e),n=s.byteLength,i=0;i<n;i++)t+=String.fromCharCode(s[i]);return btoa(t)},T=function(e){var t="",s=new Uint8Array(e),n=s.byteLength,i="";t+="00000000: ";for(var r=0;r<n;r++)t+=s[r].toString(16).padStart(2,"0")+" ",s[r]>=32&&s[r]<=126?i+=String.fromCharCode(s[r]):i+=".",(r+1)%16===0?(t+=" "+i,i="",t+="\n".concat((r+1).toString(16).padStart(8,"0"),": ")):(r+1)%8===0&&(t+=" ");if(i.length>0){for(var o=i.length;o<16;o++)t+=" ",(o+1)%8===0&&(t+=" ");t+=" "+i}return t},B=function(e){Object(h.a)(s,e);var t=Object(d.a)(s);function s(){return Object(c.a)(this,s),t.apply(this,arguments)}return Object(l.a)(s,[{key:"shouldComponentUpdate",value:function(e){return e.isSelected!==this.props.isSelected||!function(e,t){if(e===t)return!0;var s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(var i=0;i<s.length;i++){var r=s[i];if(void 0===t[r]||e[r]!==t[r])return!1}return!0}(e.flow,this.props.flow)}},{key:"render",value:function(){var e=this,t=this.props.flow,s=[];return this.props.isSelected&&s.push("tr-selected"),t.waitIntercept&&s.push("tr-wait-intercept"),Object(S.jsxs)("tr",{className:s.length?s.join(" "):void 0,onClick:function(){e.props.onShowDetail()},children:[Object(S.jsx)("td",{children:t.no}),Object(S.jsx)("td",{children:t.method}),Object(S.jsx)("td",{children:t.host}),Object(S.jsx)("td",{children:t.path}),Object(S.jsx)("td",{children:t.contentType}),Object(S.jsx)("td",{children:t.statusCode}),Object(S.jsx)("td",{children:t.size}),Object(S.jsx)("td",{children:t.costTime})]})}}]),s}(r.a.Component),C=s(26),_=s(52),k=s.n(_),q=s(53),N=s.n(q),L=s(48),P=s.n(L),U=s(49),D=s(6),A=s(56),M=s(3);!function(e){e[e.REQUEST=1]="REQUEST",e[e.REQUEST_BODY=2]="REQUEST_BODY",e[e.RESPONSE=3]="RESPONSE",e[e.RESPONSE_BODY=4]="RESPONSE_BODY"}(n||(n={}));var H=function(){function e(t){Object(c.a)(this,e),this.no=void 0,this.id=void 0,this.waitIntercept=void 0,this.request=void 0,this.response=null,this.url=void 0,this.path=void 0,this._size=0,this.size="0",this.headerContentLengthExist=!1,this.contentType="",this.startTime=Date.now(),this.endTime=0,this.costTime="(pending)",this.status=n.REQUEST,this._isTextRequest=void 0,this._isTextResponse=void 0,this._requestBody=void 0,this._hexviewRequestBody=null,this._responseBody=void 0,this._previewResponseBody=null,this._previewRequestBody=null,this._hexviewResponseBody=null,this.no=++e.curNo,this.id=t.id,this.waitIntercept=t.waitIntercept,this.request=t.content,this.url=new URL(this.request.url),this.path=this.url.pathname+this.url.search,this._isTextRequest=null,this._isTextResponse=null,this._requestBody=null,this._responseBody=null}return Object(l.a)(e,[{key:"addRequestBody",value:function(e){return this.status=n.REQUEST_BODY,this.waitIntercept=e.waitIntercept,this.request.body=e.content,this}},{key:"addResponse",value:function(e){return this.status=n.RESPONSE,this.waitIntercept=e.waitIntercept,this.response=e.content,this.response&&this.response.header&&(null!=this.response.header["Content-Type"]&&(this.contentType=this.response.header["Content-Type"][0].split(";")[0],this.contentType.includes("javascript")&&(this.contentType="javascript")),null!=this.response.header["Content-Length"]&&(this.headerContentLengthExist=!0,this._size=parseInt(this.response.header["Content-Length"][0]),this.size=g(this._size))),this}},{key:"addResponseBody",value:function(e){return this.status=n.RESPONSE_BODY,this.waitIntercept=e.waitIntercept,this.response&&(this.response.body=e.content),this.endTime=Date.now(),this.costTime=String(this.endTime-this.startTime)+" ms",!this.headerContentLengthExist&&this.response&&this.response.body&&(this._size=this.response.body.byteLength,this.size=g(this._size)),this}},{key:"preview",value:function(){return{no:this.no,id:this.id,waitIntercept:this.waitIntercept,host:this.url.host,path:this.path,method:this.request.method,statusCode:this.response?String(this.response.statusCode):"(pending)",size:this.size,costTime:this.costTime,contentType:this.contentType}}},{key:"isTextRequest",value:function(){return null!==this._isTextRequest||(this._isTextRequest=m(this.request)),this._isTextRequest}},{key:"requestBody",value:function(){return null!==this._requestBody?this._requestBody:this.isTextRequest()?this.status<n.REQUEST_BODY?"":(this._requestBody=(new TextDecoder).decode(this.request.body),this._requestBody):(this._requestBody="",this._requestBody)}},{key:"hexviewRequestBody",value:function(){var e,t;return null!==this._hexviewRequestBody?this._hexviewRequestBody:this.status<n.REQUEST_BODY?null:(null===(e=this.request)||void 0===e||null===(t=e.body)||void 0===t?void 0:t.byteLength)?(this._hexviewRequestBody=T(this.request.body),this._hexviewRequestBody):null}},{key:"isTextResponse",value:function(){return this.status<n.RESPONSE?null:(null!==this._isTextResponse||(this._isTextResponse=m(this.response)),this._isTextResponse)}},{key:"responseBody",value:function(){var e;return null!==this._responseBody?this._responseBody:this.status<n.RESPONSE?"":this.isTextResponse()?this.status<n.RESPONSE_BODY?"":(this._responseBody=(new TextDecoder).decode(null===(e=this.response)||void 0===e?void 0:e.body),this._responseBody):(this._responseBody="",this._responseBody)}},{key:"previewResponseBody",value:function(){var e,t,s;return this._previewResponseBody?this._previewResponseBody:this.status<n.RESPONSE_BODY?null:(null===(e=this.response)||void 0===e||null===(t=e.body)||void 0===t?void 0:t.byteLength)?(this.response.header["Content-Type"]&&(s=this.response.header["Content-Type"][0]),s?(s.startsWith("image/")?this._previewResponseBody={type:"image",data:E(this.response.body)}:s.includes("application/json")&&(this._previewResponseBody={type:"json",data:this.responseBody()}),this._previewResponseBody):null):null}},{key:"previewRequestBody",value:function(){var e;return this._previewRequestBody?this._previewRequestBody:this.status<n.REQUEST_BODY?null:(null===(e=this.request.body)||void 0===e?void 0:e.byteLength)?(this.isTextRequest()?/json/.test(this.request.header["Content-Type"].join(""))&&(this._previewRequestBody={type:"json",data:this.requestBody()}):this._previewRequestBody={type:"binary",data:this.hexviewRequestBody()},this._previewRequestBody):null}},{key:"hexviewResponseBody",value:function(){var e,t;return null!==this._hexviewResponseBody?this._hexviewResponseBody:this.status<n.RESPONSE_BODY?null:(null===(e=this.response)||void 0===e||null===(t=e.body)||void 0===t?void 0:t.byteLength)?(this._hexviewResponseBody=T(this.response.body),this._hexviewResponseBody):null}}]),e}();H.curNo=0;var I,z=[n.REQUEST,n.REQUEST_BODY,n.RESPONSE,n.RESPONSE_BODY];!function(e){e[e.CHANGE_REQUEST=11]="CHANGE_REQUEST",e[e.CHANGE_RESPONSE=12]="CHANGE_RESPONSE",e[e.DROP_REQUEST=13]="DROP_REQUEST",e[e.DROP_RESPONSE=14]="DROP_RESPONSE",e[e.CHANGE_BREAK_POINT_RULES=21]="CHANGE_BREAK_POINT_RULES"}(I||(I={}));var Q=function(e,t){if(e===I.DROP_REQUEST||e===I.DROP_RESPONSE){var s=new Uint8Array(38);return s[0]=1,s[1]=e,s.set((new TextEncoder).encode(t.id),2),s}var n,i;if(e===I.CHANGE_REQUEST){var r=t.request;i=r.body,n=Object(M.a)(r,["body"])}else{if(e!==I.CHANGE_RESPONSE)throw new Error("invalid message type");var o=t.response;i=o.body,n=Object(M.a)(o,["body"])}i instanceof ArrayBuffer&&(i=new Uint8Array(i));var a=i&&i.byteLength?i.byteLength:0;"Content-Encoding"in n.header&&delete n.header["Content-Encoding"],"Transfer-Encoding"in n.header&&delete n.header["Transfer-Encoding"],n.header["Content-Length"]=[String(a)];var c=(new TextEncoder).encode(JSON.stringify(n)),l=42+c.byteLength+4+a,h=new ArrayBuffer(l),d=new Uint8Array(h);d[0]=1,d[1]=e,d.set((new TextEncoder).encode(t.id),2),d.set(c,42),a&&d.set(i,42+c.byteLength+4);var u=new DataView(h);return u.setUint32(38,c.byteLength),u.setUint32(42+c.byteLength,a),d},G=function(e){Object(h.a)(s,e);var t=Object(d.a)(s);function s(e){var n;return Object(c.a)(this,s),(n=t.call(this,e)).state={show:!1,alertMsg:"",content:""},n.handleClose=n.handleClose.bind(Object(f.a)(n)),n.handleShow=n.handleShow.bind(Object(f.a)(n)),n.handleSave=n.handleSave.bind(Object(f.a)(n)),n}return Object(l.a)(s,[{key:"showAlert",value:function(e){this.setState({alertMsg:e})}},{key:"handleClose",value:function(){this.setState({show:!1})}},{key:"handleShow",value:function(){var e=this.props.flow,t="";t="request"===(e.response?"response":"request")?function(e){var t="".concat(e.method," ").concat(e.url),s=Object.keys(e.header).map((function(t){var s=e.header[t].join(" \t ");return"".concat(t,": ").concat(s)})).join("\n"),n="";return e.body&&m(e)&&(n=(new TextDecoder).decode(e.body)),"".concat(t,"\n\n").concat(s,"\n\n").concat(n)}(e.request):function(e){var t="".concat(e.statusCode),s=Object.keys(e.header).map((function(t){var s=e.header[t].join(" \t ");return"".concat(t,": ").concat(s)})).join("\n"),n="";return e.body&&m(e)&&(n=(new TextDecoder).decode(e.body)),"".concat(t,"\n\n").concat(s,"\n\n").concat(n)}(e.response),this.setState({show:!0,alertMsg:"",content:t})}},{key:"handleSave",value:function(){var e=this.props.flow.response?"response":"request",t=this.state.content;if("request"===e){var s=function(e){var t=e.indexOf("\n\n");if(!(t<=0)){var s=e.slice(0,t).split(" "),n=Object(D.a)(s,2),i=n[0],r=n[1];if(i&&r){var o=e.indexOf("\n\n",t+2);if(!(o<=0)){var a,c=e.slice(t+2,o),l={},h=Object(U.a)(c.split("\n"));try{for(h.s();!(a=h.n()).done;){var d=a.value.split(": "),u=Object(D.a)(d,2),p=u[0],j=u[1];if(!p||!j)return;l[p]=j.split(" \t ")}}catch(y){h.e(y)}finally{h.f()}var v,b=e.slice(o+2);return b&&(v=(new TextEncoder).encode(b)),{method:i,url:r,proto:"",header:l,body:v}}}}}(t);if(!s)return void this.showAlert("parse error");this.props.onChangeRequest(s),this.handleClose()}else{var n=function(e){var t=e.indexOf("\n\n");if(!(t<=0)){var s=e.slice(0,t),n=parseInt(s);if(!isNaN(n)){var i=e.indexOf("\n\n",t+2);if(!(i<=0)){var r,o=e.slice(t+2,i),a={},c=Object(U.a)(o.split("\n"));try{for(c.s();!(r=c.n()).done;){var l=r.value.split(": "),h=Object(D.a)(l,2),d=h[0],u=h[1];if(!d||!u)return;a[d]=u.split(" \t ")}}catch(v){c.e(v)}finally{c.f()}var p,j=e.slice(i+2);return j&&(p=(new TextEncoder).encode(j)),{statusCode:n,header:a,body:p}}}}}(t);if(!n)return void this.showAlert("parse error");this.props.onChangeResponse(n),this.handleClose()}}},{key:"render",value:function(){var e=this,t=this.props.flow;if(!t.waitIntercept)return null;var s=this.state.alertMsg,n=t.response?"response":"request";return Object(S.jsxs)("div",{className:"flow-wait-area",children:[Object(S.jsx)(j.a,{size:"sm",onClick:this.handleShow,children:"Edit"}),Object(S.jsx)(j.a,{size:"sm",onClick:function(){var s="response"===n?I.CHANGE_RESPONSE:I.CHANGE_REQUEST,i=Q(s,t);e.props.onMessage(i)},children:"Continue"}),Object(S.jsx)(j.a,{size:"sm",onClick:function(){var s="response"===n?I.DROP_RESPONSE:I.DROP_REQUEST,i=Q(s,t);e.props.onMessage(i)},children:"Drop"}),Object(S.jsxs)(w.a,{size:"lg",show:this.state.show,onHide:this.handleClose,children:[Object(S.jsx)(w.a.Header,{closeButton:!0,children:Object(S.jsxs)(w.a.Title,{children:["Edit ","request"===n?"Request":"Response"]})}),Object(S.jsxs)(w.a.Body,{children:[Object(S.jsx)(p.a.Group,{children:Object(S.jsx)(p.a.Control,{as:"textarea",rows:10,value:this.state.content,onChange:function(t){e.setState({content:t.target.value})}})}),s?Object(S.jsx)(A.a,{variant:"danger",children:s}):null]}),Object(S.jsxs)(w.a.Footer,{children:[Object(S.jsx)(j.a,{variant:"secondary",onClick:this.handleClose,children:"Close"}),Object(S.jsx)(j.a,{variant:"primary",onClick:this.handleSave,children:"Save"})]})]})]})}}]),s}(r.a.Component),Y=function(e){Object(h.a)(s,e);var t=Object(d.a)(s);function s(e){var n;return Object(c.a)(this,s),(n=t.call(this,e)).state={flowTab:"Headers",copied:!1,requestBodyViewTab:"Raw",responseBodyLineBreak:!1},n}return Object(l.a)(s,[{key:"preview",value:function(){var e=this.props.flow;if(!e)return null;var t=e.response;if(!t)return null;if(!t.body||!t.body.byteLength)return Object(S.jsx)("div",{style:{color:"gray"},children:"No response"});var s=e.previewResponseBody();return s?"image"===s.type?Object(S.jsx)("img",{src:"data:image/png;base64,".concat(s.data)}):"json"===s.type?Object(S.jsx)("div",{children:Object(S.jsx)(P.a,{data:s.data,keyStyle:"color: rgb(130,40,144);",stringStyle:"color: rgb(153,68,60);",valueStyle:"color: rgb(25,1,199);",booleanStyle:"color: rgb(94,105,192);"})}):Object(S.jsx)("div",{style:{color:"gray"},children:"Not support preview"}):Object(S.jsx)("div",{style:{color:"gray"},children:"Not support preview"})}},{key:"requestBodyPreview",value:function(){var e=this.props.flow;if(!e)return null;var t=e.previewRequestBody();return t?"json"===t.type?Object(S.jsx)("div",{children:Object(S.jsx)(P.a,{data:t.data,keyStyle:"color: rgb(130,40,144);",stringStyle:"color: rgb(153,68,60);",valueStyle:"color: rgb(25,1,199);",booleanStyle:"color: rgb(94,105,192);"})}):"binary"===t.type?Object(S.jsx)("div",{children:Object(S.jsx)("pre",{children:t.data})}):Object(S.jsx)("div",{style:{color:"gray"},children:"Not support preview"}):Object(S.jsx)("div",{style:{color:"gray"},children:"Not support preview"})}},{key:"hexview",value:function(){var e=this.props.flow;if(!e)return null;var t=e.response;return t?t.body&&t.body.byteLength?Object(S.jsx)("pre",{children:e.hexviewResponseBody()}):Object(S.jsx)("div",{style:{color:"gray"},children:"No response"}):null}},{key:"render",value:function(){var e=this;if(!this.props.flow)return null;var t=this.props.flow,s=this.state.flowTab,n=t.request,i=t.response||{},r=[];return t.url&&t.url.search&&t.url.searchParams.forEach((function(e,t){r.push({key:t,value:e})})),Object(S.jsxs)("div",{className:"flow-detail",children:[Object(S.jsxs)("div",{className:"header-tabs",children:[Object(S.jsx)("span",{onClick:function(){e.props.onClose()},children:"x"}),Object(S.jsx)("span",{className:"Headers"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Headers"})},children:"Headers"}),Object(S.jsx)("span",{className:"Preview"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Preview"})},children:"Preview"}),Object(S.jsx)("span",{className:"Response"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Response"})},children:"Response"}),Object(S.jsx)("span",{className:"Hexview"===s?"selected":void 0,onClick:function(){e.setState({flowTab:"Hexview"})},children:"Hexview"}),Object(S.jsx)(G,{flow:t,onChangeRequest:function(s){t.request.method=s.method,t.request.url=s.url,t.request.header=s.header,m(t.request)&&(t.request.body=s.body),e.props.onReRenderFlows()},onChangeResponse:function(s){t.response||(t.response={}),t.response.statusCode=s.statusCode,t.response.header=s.header,m(t.response)&&(t.response.body=s.body),e.props.onReRenderFlows()},onMessage:function(s){e.props.onMessage(s),t.waitIntercept=!1,e.props.onReRenderFlows()}})]}),Object(S.jsxs)("div",{style:{padding:"20px"},children:["Headers"!==s?null:Object(S.jsxs)("div",{children:[Object(S.jsx)("p",{children:Object(S.jsx)(j.a,{size:"sm",variant:this.state.copied?"success":"primary",disabled:this.state.copied,onClick:function(){var s=k()({url:t.request.url,method:t.request.method,headers:Object.keys(t.request.header).reduce((function(e,s){return e[s]=t.request.header[s][0],e}),{}),body:t.requestBody()});N()(s),e.setState({copied:!0},(function(){setTimeout((function(){e.setState({copied:!1})}),1e3)}))},children:this.state.copied?"Copied":"Copy as cURL"})}),Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"General"}),Object(S.jsxs)("div",{className:"header-block-content",children:[Object(S.jsxs)("p",{children:["Request URL: ",n.url]}),Object(S.jsxs)("p",{children:["Request Method: ",n.method]}),Object(S.jsxs)("p",{children:["Status Code: ","".concat(i.statusCode||"(pending)")]})]})]}),i.header?Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"Response Headers"}),Object(S.jsx)("div",{className:"header-block-content",children:Object.keys(i.header).map((function(e){return Object(S.jsxs)("p",{children:[e,": ",i.header[e].join(" ")]},e)}))})]}):null,Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"Request Headers"}),Object(S.jsx)("div",{className:"header-block-content",children:n.header?Object.keys(n.header).map((function(e){return Object(S.jsxs)("p",{children:[e,": ",n.header[e].join(" ")]},e)})):null})]}),r.length?Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"Query String Parameters"}),Object(S.jsx)("div",{className:"header-block-content",children:r.map((function(e){var t=e.key,s=e.value;return Object(S.jsxs)("p",{children:[t,": ",s]},t)}))})]}):null,n.body&&n.body.byteLength?Object(S.jsxs)("div",{className:"header-block",children:[Object(S.jsx)("p",{children:"Request Body"}),Object(S.jsx)("div",{className:"header-block-content",children:Object(S.jsxs)("div",{children:[Object(S.jsxs)("div",{className:"request-body-detail",style:{marginBottom:"15px"},children:[Object(S.jsx)("span",{className:"Raw"===this.state.requestBodyViewTab?"selected":void 0,onClick:function(){e.setState({requestBodyViewTab:"Raw"})},children:"Raw"}),Object(S.jsx)("span",{className:"Preview"===this.state.requestBodyViewTab?"selected":void 0,onClick:function(){e.setState({requestBodyViewTab:"Preview"})},children:"Preview"})]}),"Raw"!==this.state.requestBodyViewTab?null:Object(S.jsx)("div",{children:t.isTextRequest()?t.requestBody():Object(S.jsx)("span",{style:{color:"gray"},children:"Not text Request"})}),"Preview"!==this.state.requestBodyViewTab?null:Object(S.jsx)("div",{children:this.requestBodyPreview()})]})})]}):null]}),"Response"!==s?null:i.body&&i.body.byteLength?t.isTextResponse()?Object(S.jsxs)("div",{children:[Object(S.jsx)("div",{style:{marginBottom:"20px"},children:Object(S.jsx)(C.a,{inline:!0,type:"checkbox",checked:this.state.responseBodyLineBreak,onChange:function(t){e.setState({responseBodyLineBreak:t.target.checked})},label:"\u81ea\u52a8\u6362\u884c"})}),Object(S.jsx)("div",{style:{whiteSpace:this.state.responseBodyLineBreak?"pre-wrap":"pre"},children:t.responseBody()})]}):Object(S.jsx)("div",{style:{color:"gray"},children:"Not text response"}):Object(S.jsx)("div",{style:{color:"gray"},children:"No response"}),"Preview"!==s?null:Object(S.jsx)("div",{children:this.preview()}),"Hexview"!==s?null:Object(S.jsx)("div",{children:this.hexview()})]})]})}}]),s}(r.a.Component),F=function(){function e(){Object(c.a)(this,e),this.items=void 0,this._map=void 0,this.filterText=void 0,this.filterTimer=void 0,this.num=void 0,this.max=void 0,this.items=[],this._map=new Map,this.filterText="",this.filterTimer=null,this.num=0,this.max=1e3}return Object(l.a)(e,[{key:"showList",value:function(){var e=this.filterText;if(e&&(e=e.trim()),!e)return this.items;if(e.startsWith("/")&&e.endsWith("/")){if(!(e=e.slice(1,e.length-1).trim()))return this.items;try{var t=new RegExp(e);return this.items.filter((function(e){return t.test(e.request.url)}))}catch(s){return this.items}}return this.items.filter((function(t){return t.request.url.includes(e)}))}},{key:"add",value:function(e){if(e.no=++this.num,this.items.push(e),this._map.set(e.id,e),this.items.length>this.max){var t=this.items.shift();t&&this._map.delete(t.id)}}},{key:"get",value:function(e){return this._map.get(e)}},{key:"changeFilter",value:function(e){this.filterText=e}},{key:"changeFilterLazy",value:function(e,t){var s=this;this.filterTimer&&(clearTimeout(this.filterTimer),this.filterTimer=null),this.filterTimer=setTimeout((function(){s.filterText=e,t()}),300)}},{key:"clear",value:function(){this.items=[],this._map=new Map}}]),e}(),V=[1,1,2,2,4,4,8,8,16,16,32,32],W=function(e){Object(h.a)(s,e);var t=Object(d.a)(s);function s(e){var n;return Object(c.a)(this,s),(n=t.call(this,e)).flowMgr=void 0,n.ws=void 0,n.wsUnmountClose=void 0,n.autoScore=!1,n.wsReconnCount=-1,n.flowMgr=new F,n.state={flows:n.flowMgr.showList(),flow:null,flowTab:"Headers",wsStatus:"close"},n.ws=null,n.wsUnmountClose=!1,n.initScrollMonitor(),n}return Object(l.a)(s,[{key:"componentDidMount",value:function(){this.initWs()}},{key:"componentWillUnmount",value:function(){this.ws&&(this.wsUnmountClose=!0,this.ws.close(),this.ws=null)}},{key:"initWs",value:function(){var e,t=this;this.ws||(this.setState({wsStatus:"connecting"}),e=new URL(document.URL).host,this.ws=new WebSocket("ws://".concat(e,"/echo")),this.ws.binaryType="arraybuffer",this.ws.onopen=function(){t.wsReconnCount=-1,t.setState({wsStatus:"open"})},this.ws.onerror=function(e){var s;console.error("ERROR:",e),null===(s=t.ws)||void 0===s||s.close()},this.ws.onclose=function(){if(t.setState({wsStatus:"close"}),!t.wsUnmountClose){t.wsReconnCount++,t.ws=null;var e=V[t.wsReconnCount]||V[V.length-1];console.info("will reconnect after ".concat(e," seconds")),setTimeout((function(){t.initWs()}),1e3*e)}},this.ws.onmessage=function(e){var s=function(e){if(e.byteLength<39)return null;var t=new Int8Array(e.slice(0,39));if(1!==t[0])return null;var s=t[1];if(!z.includes(s))return null;var i={type:s,id:(new TextDecoder).decode(e.slice(2,38)),waitIntercept:1===t[38]};if(39===e.byteLength)return i;if(s===n.REQUEST_BODY||s===n.RESPONSE_BODY)return i.content=e.slice(39),i;var r,o=(new TextDecoder).decode(e.slice(39));try{r=JSON.parse(o)}catch(a){return null}return i.content=r,i}(e.data);if(s){if(s.type===n.REQUEST){var i=new H(s);t.flowMgr.add(i),t.setState({flows:t.flowMgr.showList()},(function(){t.autoScore&&t.props.pageBottom.scrollIntoView({behavior:"auto"})}))}else if(s.type===n.REQUEST_BODY){var r=t.flowMgr.get(s.id);if(!r)return;r.addRequestBody(s),t.setState({flows:t.state.flows})}else if(s.type===n.RESPONSE){var o=t.flowMgr.get(s.id);if(!o)return;o.addResponse(s),t.setState({flows:t.state.flows})}else if(s.type===n.RESPONSE_BODY){var a=t.flowMgr.get(s.id);if(!a||!a.response)return;a.addResponseBody(s),t.setState({flows:t.state.flows})}}else console.error("parse error:",e.data)})}},{key:"initScrollMonitor",value:function(){var e=this,t=b.a.create(this.props.pageBottom);t.enterViewport((function(){e.autoScore=!0})),t.exitViewport((function(){e.autoScore=!1}))}},{key:"render",value:function(){var e=this,t=this.state.flows;return Object(S.jsxs)("div",{className:"main-table-wrap",children:[Object(S.jsxs)("div",{className:"top-control",children:[Object(S.jsx)("div",{children:Object(S.jsx)(j.a,{size:"sm",onClick:function(){e.flowMgr.clear(),e.setState({flows:e.flowMgr.showList(),flow:null})},children:"Clear"})}),Object(S.jsx)("div",{children:Object(S.jsx)(p.a.Control,{size:"sm",placeholder:"Filter",onChange:function(t){var s=t.target.value;e.flowMgr.changeFilterLazy(s,(function(){e.setState({flows:e.flowMgr.showList()})}))}})}),Object(S.jsx)(R,{onSave:function(t){var s=function(e,t){if(e!==I.CHANGE_BREAK_POINT_RULES)throw new Error("invalid message type");var s=(new TextEncoder).encode(JSON.stringify(t)),n=new Uint8Array(2+s.byteLength);return n[0]=1,n[1]=e,n.set(s,2),n}(I.CHANGE_BREAK_POINT_RULES,t);e.ws&&e.ws.send(s)}}),Object(S.jsxs)("span",{children:["status: ",this.state.wsStatus]})]}),Object(S.jsxs)(u.a,{striped:!0,bordered:!0,size:"sm",style:{tableLayout:"fixed"},children:[Object(S.jsx)("thead",{children:Object(S.jsxs)("tr",{children:[Object(S.jsx)("th",{style:{width:"50px"},children:"No"}),Object(S.jsx)("th",{style:{width:"80px"},children:"Method"}),Object(S.jsx)("th",{style:{width:"200px"},children:"Host"}),Object(S.jsx)("th",{style:{width:"auto"},children:"Path"}),Object(S.jsx)("th",{style:{width:"150px"},children:"Type"}),Object(S.jsx)("th",{style:{width:"80px"},children:"Status"}),Object(S.jsx)("th",{style:{width:"90px"},children:"Size"}),Object(S.jsx)("th",{style:{width:"90px"},children:"Time"})]})}),Object(S.jsx)("tbody",{children:t.map((function(t){var s=t.preview();return Object(S.jsx)(B,{flow:s,isSelected:!(!e.state.flow||e.state.flow.id!==s.id),onShowDetail:function(){e.setState({flow:t})}},s.id)}))})]}),Object(S.jsx)(Y,{flow:this.state.flow,onClose:function(){e.setState({flow:null})},onReRenderFlows:function(){e.setState({flows:e.state.flows})},onMessage:function(t){e.ws&&e.ws.send(t)}})]})}}]),s}(r.a.Component),J=function(e){e&&e instanceof Function&&s.e(3).then(s.bind(null,70)).then((function(t){var s=t.getCLS,n=t.getFID,i=t.getFCP,r=t.getLCP,o=t.getTTFB;s(e),n(e),i(e),r(e),o(e)}))},K=document.getElementById("hidden-bottom");a.a.render(Object(S.jsx)(r.a.StrictMode,{children:Object(S.jsx)(W,{pageBottom:K})}),document.getElementById("root")),J()}},[[68,1,2]]]);
|
|
//# sourceMappingURL=main.479f2438.chunk.js.map
|