p3x-redis-ui-material
Version:
💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity
1 lines • 17.4 kB
JavaScript
import{a as e}from"./i18n.store-DddRY7Ub.js";import{r as t,t as n}from"./socket.service-5KD-6c7U.js";new TextEncoder;var r=4096;function i(e,t,n){let i=t,a=i+n,o=[],s=``;for(;i<a;){let t=e[i++];if(!(t&128))o.push(t);else if((t&224)==192){let n=e[i++]&63;o.push((t&31)<<6|n)}else if((t&240)==224){let n=e[i++]&63,r=e[i++]&63;o.push((t&31)<<12|n<<6|r)}else if((t&248)==240){let n=e[i++]&63,r=e[i++]&63,a=e[i++]&63,s=(t&7)<<18|n<<12|r<<6|a;s>65535&&(s-=65536,o.push(s>>>10&1023|55296),s=56320|s&1023),o.push(s)}else o.push(t);o.length>=r&&(s+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(s+=String.fromCharCode(...o)),s}var a=new TextDecoder,o=200;function s(e,t,n){let r=e.subarray(t,t+n);return a.decode(r)}function c(e,t,n){return n>o?s(e,t,n):i(e,t,n)}var l=class{type;data;constructor(e,t){this.type=e,this.data=t}},u=class e extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,`name`,{configurable:!0,enumerable:!1,value:e.name})}};function d(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function f(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function p(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var m=4294967295,ee=17179869183;function te({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=ee)if(t===0&&e<=m){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let n=e/4294967296,r=e&4294967295,i=new Uint8Array(8),a=new DataView(i.buffer);return a.setUint32(0,t<<2|n&3),a.setUint32(4,r),i}else{let n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,t),d(r,4,e),n}}function ne(e){let t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function re(e){return e instanceof Date?te(ne(e)):null}function h(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let e=t.getUint32(0),n=t.getUint32(4);return{sec:(e&3)*4294967296+n,nsec:e>>>2}}case 12:return{sec:f(t,4),nsec:t.getUint32(0)};default:throw new u(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function g(e){let t=h(e);return new Date(t.sec*1e3+t.nsec/1e6)}var _={type:-1,encode:re,decode:g},v=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(_)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new l(-1-n,i)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new l(n,i)}}return e instanceof l?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new l(t,e)}};function y(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function b(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):y(e)?new Uint8Array(e):Uint8Array.from(e)}function x(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var S=16,C=16,w=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=S,t=C){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];FIND_CHUNK:for(let i of r){let r=i.bytes;for(let i=0;i<n;i++)if(r[i]!==e[t+i])continue FIND_CHUNK;return i.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let a=i(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,a),a}},T=`array`,E=`map_key`,D=`map_value`,ie=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new u(`The type of key must be string or number but `+typeof e)},ae=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=T,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=E,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error(`Invalid stack state. Released state is not on top of the stack.`);if(e.type===T){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===E||e.type===D){let t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},O=-1,k=new DataView(new ArrayBuffer(0)),oe=new Uint8Array(k.buffer);try{k.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error(`This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access`)}var A=RangeError(`Insufficient data`),se=new w,ce=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=k;bytes=oe;headByte=O;stack=new ae;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??v.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder===void 0?se:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??ie}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=O,this.stack.reset()}setBuffer(e){let t=b(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===O&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=b(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let r of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(r);try{n=this.doDecodeSync(),t=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:i,totalPos:a}=this;throw RangeError(`Insufficient data in parsing ${x(r)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let i of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){DECODE:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue DECODE}else t={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue DECODE}else t=[]}else{let n=e-160;t=this.decodeString(n,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)t=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)t=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(e===217){let e=this.lookU8();t=this.decodeString(e,1)}else if(e===218){let e=this.lookU16();t=this.decodeString(e,2)}else if(e===219){let e=this.lookU32();t=this.decodeString(e,4)}else if(e===220){let e=this.readU16();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===221){let e=this.readU32();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===222){let e=this.readU16();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===223){let e=this.readU32();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===196){let e=this.lookU8();t=this.decodeBinary(e,1)}else if(e===197){let e=this.lookU16();t=this.decodeBinary(e,2)}else if(e===198){let e=this.lookU32();t=this.decodeBinary(e,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let e=this.lookU8();t=this.decodeExtension(e,1)}else if(e===200){let e=this.lookU16();t=this.decodeExtension(e,2)}else if(e===201){let e=this.lookU32();t=this.decodeExtension(e,4)}else throw new u(`Unrecognized type byte: ${x(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===T)if(e.array[e.position]=t,e.position++,e.position===e.size)t=e.array,n.release(e);else continue DECODE;else if(e.type===E){if(t===`__proto__`)throw new u(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=D;continue DECODE}else if(e.map[e.key]=t,e.readCount++,e.readCount===e.size)t=e.map,n.release(e);else{e.key=null,e.type=E;continue DECODE}}return t}}readHeadByte(){return this.headByte===O&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=O}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new u(`Unrecognized array type byte: ${x(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new u(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new u(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new u(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw A;let n=this.pos+t,r;return r=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):c(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===E:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new u(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw A;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new u(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=p(this.view,this.pos);return this.pos+=8,e}readI64(){let e=f(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function j(e,t){return new ce(t).decode(e)}var M=`p3xr-profiler-entries`,N=`p3xr-pubsub-entries`,P=1e4,F=100,I=2e3,L=new Set,R=new Set,z=null,B=null,V=()=>`en`,H=!1,U=!1,W=!1,G=0,K=0,q=null,J=null;function le(e){if(e instanceof ArrayBuffer)try{let t=j(new Uint8Array(e));return JSON.stringify(t,null,2)}catch{return new TextDecoder().decode(e)}return String(e)}function Y(e,t){let n=t.slice(-F);try{localStorage.setItem(e,JSON.stringify(n))}catch{try{localStorage.removeItem(e)}catch{}}}function ue(){let e=[],t=[];try{let t=localStorage.getItem(M);t&&(e=JSON.parse(t))}catch{}try{let e=localStorage.getItem(N);e&&(t=JSON.parse(e))}catch{}return{profiler:e,pubsub:t}}var X=e=>{let t=V(),n=new Date(parseFloat(e.time)*1e3),r={displayTime:n.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1,fractionalSecondDigits:3}),fullTimestamp:n.toISOString(),database:e.database,source:e.source,command:(e.args||[]).join(` `)},i=[...Q.getState().profilerEntries,r];i.length>P&&(i=i.slice(-P)),Q.setState({profilerEntries:i}),L.forEach(e=>e(r)),z||=setTimeout(()=>{z=null,Y(M,Q.getState().profilerEntries)},I)},Z=e=>{let t=V(),n=new Date,r={displayTime:n.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),fullTimestamp:n.toISOString(),channel:e.channel,message:le(e.message)},i=[...Q.getState().pubsubEntries,r];i.length>P&&(i=i.slice(-P)),Q.setState({pubsubEntries:i}),R.forEach(e=>e(r)),B||=setTimeout(()=>{B=null,Y(N,Q.getState().pubsubEntries)},I)},Q=e(()=>{let{profiler:e,pubsub:t}=ue();return{profilerEntries:e,pubsubEntries:t,profilerStarted:!1,pubsubStarted:!1,pubsubPattern:`*`}});function de(e){V=e,H||=!0}async function fe(){if(U=!0,Q.getState().profilerStarted)return;if(q)return q;let e=++G,r=(async()=>{if(await t({action:`monitor/set`,payload:{enabled:!0}}),e!==G||!U)return;let r=n();r?.removeListener(`monitor-data`,X),r?.on(`monitor-data`,X),Q.setState({profilerStarted:!0})})().finally(()=>{q===r&&(q=null)});return q=r,q}function pe(){let e=Q.getState().profilerStarted;U=!1,G++,q=null,n()?.removeListener(`monitor-data`,X),Q.setState({profilerStarted:!1}),e&&t({action:`monitor/set`,payload:{enabled:!1}}).catch(()=>{}),z&&=(clearTimeout(z),null),Y(M,Q.getState().profilerEntries)}async function me(){if(W=!0,Q.getState().pubsubStarted)return;if(J)return J;let e=++K,r=Q.getState().pubsubPattern,i=(async()=>{if(await t({action:`settings/subscription`,payload:{subscription:!0,subscriberPattern:r}}),e!==K||!W)return;let i=n();i?.removeListener(`pubsub-message`,Z),i?.on(`pubsub-message`,Z),Q.setState({pubsubStarted:!0})})().finally(()=>{J===i&&(J=null)});return J=i,J}function he(){let e=Q.getState().pubsubStarted;W=!1,K++,J=null,n()?.removeListener(`pubsub-message`,Z),Q.setState({pubsubStarted:!1}),e&&t({action:`settings/subscription`,payload:{subscription:!1,subscriberPattern:`*`}}).catch(()=>{}),B&&=(clearTimeout(B),null),Y(N,Q.getState().pubsubEntries)}function ge(){Q.setState({profilerEntries:[]});try{localStorage.removeItem(M)}catch{}}function $(){Q.setState({pubsubEntries:[]});try{localStorage.removeItem(N)}catch{}}function _e(){z&&=(clearTimeout(z),null),B&&=(clearTimeout(B),null),Y(M,Q.getState().profilerEntries),Y(N,Q.getState().pubsubEntries)}function ve(e){return L.add(e),()=>L.delete(e)}function ye(e){return R.add(e),()=>R.delete(e)}export{ge as clearProfiler,$ as clearPubSub,_e as destroyMonitoringData,de as initMonitoringData,ve as onProfilerEntry,ye as onPubsubEntry,fe as startProfiler,me as startPubSub,pe as stopProfiler,he as stopPubSub,Q as useMonitoringDataStore};