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-cEFY1tQT.js";import{d as t,l as n}from"./index-B6abhTyw.js";function r(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var i=class{type;data;constructor(e,t){this.type=e,this.data=t}},a=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 o(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function s(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function c(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var l=4294967295,ee=17179869183;function te({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=ee)if(t===0&&e<=l){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),o(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 ie(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:s(t,4),nsec:t.getUint32(0)};default:throw new a(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function u(e){let t=ie(e);return new Date(t.sec*1e3+t.nsec/1e6)}var d={type:-1,encode:re,decode:u},f=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(d)}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 a=r(e,t);if(a!=null)return new i(-1-n,a)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let a=r(e,t);if(a!=null)return new i(n,a)}}return e instanceof i?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new i(t,e)}};new TextEncoder;var p=4096;function m(e,t,n){let r=t,i=r+n,a=[],o=``;for(;r<i;){let t=e[r++];if(!(t&128))a.push(t);else if((t&224)==192){let n=e[r++]&63;a.push((t&31)<<6|n)}else if((t&240)==224){let n=e[r++]&63,i=e[r++]&63;a.push((t&31)<<12|n<<6|i)}else if((t&248)==240){let n=e[r++]&63,i=e[r++]&63,o=e[r++]&63,s=(t&7)<<18|n<<12|i<<6|o;s>65535&&(s-=65536,a.push(s>>>10&1023|55296),s=56320|s&1023),a.push(s)}else a.push(t);a.length>=p&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}var h=new TextDecoder,g=200;function _(e,t,n){let r=e.subarray(t,t+n);return h.decode(r)}function v(e,t,n){return n>g?_(e,t,n):m(e,t,n)}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)}var ae=16,x=16,S=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=ae,t=x){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 i=m(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}},C=`array`,w=`map_key`,T=`map_value`,oe=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new a(`The type of key must be string or number but `+typeof e)},se=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=C,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=w,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===C){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===w||e.type===T){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}},E=-1,D=new DataView(new ArrayBuffer(0)),O=new Uint8Array(D.buffer);try{D.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 k=RangeError(`Insufficient data`),A=new S,j=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=D;bytes=O;headByte=E;stack=new se;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??f.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?A:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??oe}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=E,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===E&&!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:i,pos:a,totalPos:o}=this;throw RangeError(`Insufficient data in parsing ${r(i)} at ${o} (${a} 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 a(`Unrecognized type byte: ${r(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===C)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===w){if(t===`__proto__`)throw new a(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=T;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=w;continue DECODE}}return t}}readHeadByte(){return this.headByte===E&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=E}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 a(`Unrecognized array type byte: ${r(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new a(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new a(`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 a(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw k;let n=this.pos+t,r;return r=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):v(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===w:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new a(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw k;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 a(`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=c(this.view,this.pos);return this.pos+=8,e}readI64(){let e=s(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 M(e,t){return new j(t).decode(e)}var N=`p3xr-profiler-entries`,P=`p3xr-pubsub-entries`,F=1e4,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 ce(e){if(e instanceof ArrayBuffer)try{let t=M(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(-100);try{localStorage.setItem(e,JSON.stringify(n))}catch{try{localStorage.removeItem(e)}catch{}}}function le(){let e=[],t=[];try{let t=localStorage.getItem(N);t&&(e=JSON.parse(t))}catch{}try{let e=localStorage.getItem(P);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>F&&(i=i.slice(-1e4)),Q.setState({profilerEntries:i}),L.forEach(e=>e(r)),z||=setTimeout(()=>{z=null,Y(N,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:ce(e.message)},i=[...Q.getState().pubsubEntries,r];i.length>F&&(i=i.slice(-1e4)),Q.setState({pubsubEntries:i}),R.forEach(e=>e(r)),B||=setTimeout(()=>{B=null,Y(P,Q.getState().pubsubEntries)},I)},Q=e(()=>{let{profiler:e,pubsub:t}=le();return{profilerEntries:e,pubsubEntries:t,profilerStarted:!1,pubsubStarted:!1,pubsubPattern:`*`}});function ue(e){V=e,H||=!0}async function de(){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 fe(){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(N,Q.getState().profilerEntries)}async function pe(){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 $(){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(P,Q.getState().pubsubEntries)}function me(){Q.setState({profilerEntries:[]});try{localStorage.removeItem(N)}catch{}}function he(){Q.setState({pubsubEntries:[]});try{localStorage.removeItem(P)}catch{}}function ge(){z&&=(clearTimeout(z),null),B&&=(clearTimeout(B),null),Y(N,Q.getState().profilerEntries),Y(P,Q.getState().pubsubEntries)}function _e(e){return L.add(e),()=>L.delete(e)}function ve(e){return R.add(e),()=>R.delete(e)}export{me as clearProfiler,he as clearPubSub,ge as destroyMonitoringData,ue as initMonitoringData,_e as onProfilerEntry,ve as onPubsubEntry,de as startProfiler,pe as startPubSub,fe as stopProfiler,$ as stopPubSub,Q as useMonitoringDataStore};