UNPKG

filecat

Version:
2 lines 19.1 kB
/*! For license information please see 502.779cee91ac6ead6dc4ea.js.LICENSE.txt */ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[502],{2502:(t,e,r)=>{r.r(e),r.d(e,{default:()=>H});var n=r(6540),o=r(4238),i=r(4944),a=r(7444),c=r(6417),l=r(7952),u=r(5997),s=r(7022),f=r(4289),h=r(2042),p=r(3033),v=r(2389),y=r(4694),d=r(447);function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function g(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=E(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function x(t){return function(t){if(Array.isArray(t))return L(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||E(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(){_=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),c=new O(n||[]);return o(a,"_invoke",{value:T(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var h="suspendedStart",p="suspendedYield",v="executing",y="completed",d={};function g(){}function x(){}function w(){}var b={};u(b,a,(function(){return this}));var k=Object.getPrototypeOf,E=k&&k(k(N([])));E&&E!==r&&n.call(E,a)&&(b=E);var L=w.prototype=g.prototype=Object.create(b);function S(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){function r(o,i,a,c){var l=f(t[o],t,i);if("throw"!==l.type){var u=l.arg,s=u.value;return s&&"object"==m(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(l.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function T(e,r,n){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var l=C(c,n);if(l){if(l===d)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===d)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(m(e)+" is not iterable")}return x.prototype=w,o(L,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=u(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,u(t,l,"GeneratorFunction")),t.prototype=Object.create(L),t},e.awrap=function(t){return{__await:t}},S(A.prototype),u(A.prototype,c,(function(){return this})),e.AsyncIterator=A,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new A(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(L),u(L,l,"Generator"),u(L,a,(function(){return this})),u(L,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}function w(t,e,r,n,o,i,a){try{var c=t[i](a),l=c.value}catch(t){return void r(t)}c.done?e(l):Promise.resolve(l).then(n,o)}function b(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){w(i,n,o,a,c,"next",t)}function c(t){w(i,n,o,a,c,"throw",t)}a(void 0)}))}}function k(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],l=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);l=!0);}catch(t){u=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||E(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(t,e){if(t){if("string"==typeof t)return L(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(t,e):void 0}}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var S,A=300,T=!1,C=0,I=!0,j=[],O=-1,N=[];function H(t){var e=k((0,a.L4)(c.A.log_viewer),2),r=e[0],m=e[1],w=(0,n.useRef)(null),E=k((0,n.useState)(0),2),L=E[0],H=E[1],z=k((0,n.useState)(100),2),G=z[0],P=z[1],M=k((0,n.useState)(!1),2),K=M[0],F=M[1],D=k((0,n.useState)(""),2),Y=D[0],$=D[1],q=k((0,n.useState)(0),2),B=q[0],R=q[1],W=k((0,n.useState)(0),2),Z=W[0],U=W[1],X=k((0,n.useState)(0),2),J=(X[0],X[1]),Q=(0,v.Bd)().t,V=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0,i=document.createElement("div");return-1===O?i.textContent=t:i.innerHTML=t,i.style.whiteSpace="pre-wrap",i.style.overflowWrap="break-word",i.setAttribute("position","".concat(e)),i.setAttribute("start_position","".concat(r)),n?(w.current.insertBefore(i,o),j.unshift(i)):(w.current.appendChild(i),j.push(i)),i},tt=function(t){var e=(0,y.I)(j,(function(e){return e===t}));e&&w.current.removeChild(e)},et=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t){var o=Array.isArray(t)?t:t.split("\n");if(n){for(var i,a=0;a<o.length;a++)i=V(o[a],e[a],r[a],!0,0===a?w.current.firstChild:i);if(j.length>A)for(var c=j.length-1;c>=A;)tt(j[j.length-1]),c--}else{for(var l=0;l<o.length;l++)V(o[l],e[l],r[l]);if(j.length>A)for(var u=j.length-A;u>0;)tt(j[0]),u--}}},rt=function(){var t=b(_().mark((function t(){var e,r,n,a,c;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return S.context="",t.next=3,i.ws.sendData(o.HK.log_viewer,S);case 3:if(e=t.sent){if(r=e.context,S=r,r.find_back_enter_index&&r.context_list.length>0)for(n=0;n<r.context_list.length;n++)a=new RegExp(r.query_text,"g"),r.context_list[n]=r.context_list[n].replace(a,'<span style="color: blue;">'.concat(r.query_text,"</span>"));S.find_back_enter_index=!1,et(r.context_list,r.context_position_list,r.context_start_position_list,S.back),S.context_list.length>0&&(S.back&&j.length>0?(S.context_list.length>j.length?H(Math.floor(100*parseInt(j[S.context_list.length-j.length].getAttribute("position"))/S.max_size)):H(Math.floor(100*parseInt(j[j.length-S.context_list.length].getAttribute("position"))/S.max_size)),I=!1):H(Math.floor(100*(null!==(c=S.context_position_list[S.context_position_list.length-1])&&void 0!==c?c:0)/S.max_size))),w.current.clientHeight===w.current.scrollHeight&&nt(S.max_size)}case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),nt=function(t){T||(T=!0,H(100),i.ws.addMsg(o.HK.log_viewer_watch,(function(t){var e=t.context;e&&(S=e,et(e.context_list,e.context_position_list,e.context_start_position_list,!1),w.current.scrollTop=w.current.scrollHeight)})),S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],S.position=t,i.ws.sendData(o.HK.log_viewer_watch,S),F(!0))},ot=function(){var t=b(_().mark((function t(){var e,n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=b(_().mark((function t(){var e,r,n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=w.current)){t.next=38;break}if(C>e.scrollTop&&T&&(T=!1,i.ws.unConnect(),F(!1)),!T){t.next=6;break}return C=e.scrollTop,t.abrupt("return");case 6:if(!(C<e.scrollTop&&j.length>0&&e.scrollTop+e.clientHeight+500>=e.scrollHeight)){t.next=22;break}if(!((r=parseInt(j[j.length-1].getAttribute("position")))>=S.max_size)){t.next=11;break}return nt(r),t.abrupt("return");case 11:return S.line=20,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],S.back=!1,S.position=r,t.next=20,rt();case 20:t.next=37;break;case 22:if(!(C>e.scrollTop&&j.length>0&&e.scrollTop-300<=0)){t.next=37;break}if(!((n=parseInt(j[0].getAttribute("start_position")))<=0)){t.next=28;break}return I||(I=!0,(0,h.N9)("到达顶部")),C=e.scrollTop,t.abrupt("return");case 28:return S.line=10,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],S.back=!0,S.position=n,t.next=37,rt();case 37:C=e.scrollTop;case 38:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),w.current.addEventListener("scroll",e),n=function(t){var e=w.current;if(e){t.preventDefault();t.deltaY>0?e.scrollTop+=20:e.scrollTop-=20}},w.current.addEventListener("wheel",n,{passive:!1}),F(!1),R(0),U(0),$(""),T=!1,J(0),C=0,N=[],O=-1,j=[],(S=new s.d2).line=A,S.path="".concat((0,f.GG)("file",(0,f.vX)())).concat(r.fileName),S.token=localStorage.getItem("token"),t.next=20,rt();case 20:i.ws.addMsg(o.HK.search_file_progress,(function(t){try{R(parseInt(t.context))}catch(t){(0,h.zN)(t.message)}})),i.ws.addMsg(o.HK.search_file_index,(function(t){try{var e;(e=N).push.apply(e,x(t.context)),J(t.context.length)}catch(t){(0,h.zN)(t.message)}}));case 22:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),it=function(){var t=b(_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return w.current&&w.current.remove(),t.next=3,i.ws.unConnect();case 3:j=[];case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();if((0,n.useEffect)((function(){r.show?ot():it()}),[r]),(0,n.useEffect)((function(){return function(){it()}}),[]),r.show){var at=function(){var t=b(_().mark((function t(){var e,r,n,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(S.line=A,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=0,t.prev=6,!((e=parseInt(G))>100||e<0)){t.next=11;break}throw(0,h.zN)("范围在0-100"),"超过最大范围";case 11:r=g(j);try{for(r.s();!(n=r.n()).done;)o=n.value,w.current.removeChild(o)}catch(t){r.e(t)}finally{r.f()}j=[],t.next=20;break;case 16:return t.prev=16,t.t0=t.catch(6),(0,h.N9)(t.t0),t.abrupt("return");case 20:return S.back=e>=100,S.position=Math.floor(S.max_size*(e/100)),t.next=24,rt();case 24:case"end":return t.stop()}}),t,null,[[6,16]])})));return function(){return t.apply(this,arguments)}}(),ct=function(){var t=b(_().mark((function t(){var e,r,n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!T){t.next=2;break}return t.abrupt("return");case 2:S.line=A,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=g(j);try{for(e.s();!(r=e.n()).done;)n=r.value,w.current.removeChild(n)}catch(t){e.e(t)}finally{e.f()}return j=[],S.back=!0,S.position=S.max_size,t.next=14,rt();case 14:w.current.scrollTop=w.current.scrollHeight,nt(S.max_size);case 16:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),lt=function(){var t=b(_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Y){t.next=2;break}return t.abrupt("return");case 2:R(.1),U(0),J(0),O=-1,N=[],S.query_text=Y,i.ws.sendData(o.HK.search_file,S);case 9:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),ut=function(){var t=b(_().mark((function t(){var e,r,n,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==N.length){t.next=2;break}return t.abrupt("return");case 2:S.line=A,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=g(j);try{for(e.s();!(r=e.n()).done;)n=r.value,w.current.removeChild(n)}catch(t){e.e(t)}finally{e.f()}return j=[],o=O+1>=N.length?0:O+1,U(o+1),O=o,S.find_back_enter_index=!0,S.back=!1,S.position=N[O],t.next=18,rt();case 18:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),st=function(){var t=b(_().mark((function t(){var e,r,n,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==N.length){t.next=2;break}return t.abrupt("return");case 2:S.line=A,S.context="",S.context_list=[],S.context_position_list=[],S.context_start_position_list=[],e=g(j);try{for(e.s();!(r=e.n()).done;)n=r.value,w.current.removeChild(n)}catch(t){e.e(t)}finally{e.f()}return j=[],o=O-1<0?N.length-1:O-1,U(o+1),O=o,S.back=!1,S.find_back_enter_index=!0,S.position=N[O],t.next=18,rt();case 18:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return n.createElement("div",{id:"editor-container"},n.createElement(l.A,{ignore_tags:!0,left_children:[n.createElement(u.rA,{key:1,title:"取消",icon:"close",onClick:function(){m({show:!1})}}),n.createElement("div",{key:2,style:{width:"4rem"}},n.createElement(d.WA,{context:r.fileName})),n.createElement(n.Fragment,{key:3}," ",n.createElement(p.$Z,{handleEnterPress:lt,placeholder:Q("回车搜索整个文件"),icon:"search",value:Y,handleInputChange:function(t){$(t)},max_width:"25em"})),Y&&n.createElement("div",{key:5,style:{paddingLeft:"1.5rem",cursor:"pointer"},onClick:ut},"↓"),Y&&n.createElement("div",{key:6,style:{paddingLeft:"1.5rem",cursor:"pointer"},onClick:st},"↑"),Y&&n.createElement("div",{key:7,style:{paddingLeft:"1.5rem"}},Z,"/",N.length),Y&&n.createElement("div",{key:8,style:{paddingLeft:"1.5rem"}},"搜索进度$",B,"%"),0!==B&&100!==B&&n.createElement(u.rA,{key:4,title:"取消",icon:"cancel",onClick:function(){i.ws.sendData(o.HK.search_file_cancel,{}),$(""),R(0)}})]},K&&n.createElement("span",{style:{color:"var(--icon-green)",whiteSpace:"pre"}},"正在实时监听 "),n.createElement("span",null,"当前加载进度",L),n.createElement(p.$Z,{max_width:"10rem",placeholder:Q("跳转进度"),icon:"percent",value:G,handleInputChange:function(t){P(t)}}),n.createElement(u.rA,{icon:"play_arrow",title:Q("跳转进度"),onClick:at}),n.createElement(u.rA,{icon:"text_rotate_vertical",title:Q("滑动到文件最底部,实时输出"),onClick:ct})),n.createElement("div",{style:{height:"100%"}},n.createElement("div",{ref:w,style:{overflowY:"auto",height:"100%"}})))}}}}]);