UNPKG

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.2 kB
import{_t as e,a as t,lt as n}from"./i18n.store-Bkc9i0ZB.js";import{i as r,n as i}from"./socket.service-CwqYs11N.js";function a(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var o=class{type;data;constructor(e,t){this.type=e,this.data=t}},s=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 ee(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function c(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function l(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var te=4294967295,ne=17179869183;function re({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=ne)if(t===0&&e<=te){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),ee(r,4,e),n}}function ie(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 ae(e){return e instanceof Date?re(ie(e)):null}function oe(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:c(t,4),nsec:t.getUint32(0)};default:throw new s(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function u(e){let t=oe(e);return new Date(t.sec*1e3+t.nsec/1e6)}var d={type:-1,encode:ae,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 i=r(e,t);if(i!=null)return new o(-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 o(n,i)}}return e instanceof o?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new o(t,e)}};new TextEncoder;var se=4096;function p(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>=se&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}var m=new TextDecoder,h=200;function g(e,t,n){let r=e.subarray(t,t+n);return m.decode(r)}function ce(e,t,n){return n>h?g(e,t,n):p(e,t,n)}function le(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function _(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):le(e)?new Uint8Array(e):Uint8Array.from(e)}var v=16,y=16,b=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=v,t=y){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=p(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}},x=`array`,S=`map_key`,C=`map_value`,w=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new s(`The type of key must be string or number but `+typeof e)},ue=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=x,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=S,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===x){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===S||e.type===C){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}},T=-1,E=new DataView(new ArrayBuffer(0)),de=new Uint8Array(E.buffer);try{E.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 D=RangeError(`Insufficient data`),fe=new b,O=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=E;bytes=de;headByte=T;stack=new ue;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?fe:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??w}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=T,this.stack.reset()}setBuffer(e){let t=_(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===T&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=_(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:o}=this;throw RangeError(`Insufficient data in parsing ${a(r)} at ${o} (${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 s(`Unrecognized type byte: ${a(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===x)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===S){if(t===`__proto__`)throw new s(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=C;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=S;continue DECODE}}return t}}readHeadByte(){return this.headByte===T&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=T}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 s(`Unrecognized array type byte: ${a(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new s(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new s(`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 s(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw D;let n=this.pos+t,r;return r=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):ce(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===S:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new s(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw D;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 s(`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=l(this.view,this.pos);return this.pos+=8,e}readI64(){let e=c(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 k(e,t){return new O(t).decode(e)}n();var A=`p3xr-profiler-entries`,j=`p3xr-pubsub-entries`,M=1e4,N=2e3,P=new Set,F=new Set,I=null,L=null,R=()=>`en`,z=!1,B=!1,V=!1,H=0,U=0,W=null,G=null;function pe(e){if(e instanceof ArrayBuffer)try{let t=k(new Uint8Array(e));return JSON.stringify(t,null,2)}catch{return new TextDecoder().decode(e)}return String(e)}function K(e,t){let n=t.slice(-100);try{localStorage.setItem(e,JSON.stringify(n))}catch{try{localStorage.removeItem(e)}catch{}}}function me(){let e=[],t=[];try{let t=localStorage.getItem(A);t&&(e=JSON.parse(t))}catch{}try{let e=localStorage.getItem(j);e&&(t=JSON.parse(e))}catch{}return{profiler:e,pubsub:t}}var q=null,J=e=>{let t=R(),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(` `)};if(q){let e=[...q.profilerEntries,r];e.length>M&&(e=e.slice(-1e4)),q.profilerEntries=e}P.forEach(e=>e(r)),I||=setTimeout(()=>{I=null,q&&K(A,q.profilerEntries)},N)},Y=e=>{let t=R(),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:pe(e.message)};if(q){let e=[...q.pubsubEntries,r];e.length>M&&(e=e.slice(-1e4)),q.pubsubEntries=e}F.forEach(e=>e(r)),L||=setTimeout(()=>{L=null,q&&K(j,q.pubsubEntries)},N)},X=t(`monitoringData`,()=>{let{profiler:t,pubsub:n}=me();return{profilerEntries:e(t),pubsubEntries:e(n),profilerStarted:e(!1),pubsubStarted:e(!1),pubsubPattern:e(`*`)}});function he(e){R=e,z||=!0}function ge(){q=X()}async function Z(){if(B=!0,q?.profilerStarted)return;if(W)return W;let e=++H,t=(async()=>{if(await r({action:`monitor/set`,payload:{enabled:!0}}),e!==H||!B)return;let t=i();t?.removeListener(`monitor-data`,J),t?.on(`monitor-data`,J),q&&(q.profilerStarted=!0)})().finally(()=>{W===t&&(W=null)});return W=t,W}function _e(){let e=q?.profilerStarted??!1;B=!1,H++,W=null,i()?.removeListener(`monitor-data`,J),q&&(q.profilerStarted=!1),e&&r({action:`monitor/set`,payload:{enabled:!1}}).catch(()=>{}),I&&=(clearTimeout(I),null),q&&K(A,q.profilerEntries)}async function Q(){if(V=!0,q?.pubsubStarted)return;if(G)return G;let e=++U,t=q?.pubsubPattern??`*`,n=(async()=>{if(await r({action:`settings/subscription`,payload:{subscription:!0,subscriberPattern:t}}),e!==U||!V)return;let n=i();n?.removeListener(`pubsub-message`,Y),n?.on(`pubsub-message`,Y),q&&(q.pubsubStarted=!0)})().finally(()=>{G===n&&(G=null)});return G=n,G}function $(){let e=q?.pubsubStarted??!1;V=!1,U++,G=null,i()?.removeListener(`pubsub-message`,Y),q&&(q.pubsubStarted=!1),e&&r({action:`settings/subscription`,payload:{subscription:!1,subscriberPattern:`*`}}).catch(()=>{}),L&&=(clearTimeout(L),null),q&&K(j,q.pubsubEntries)}async function ve(){$(),await Q()}function ye(){q&&(q.profilerEntries=[]);try{localStorage.removeItem(A)}catch{}}function be(){q&&(q.pubsubEntries=[]);try{localStorage.removeItem(j)}catch{}}function xe(){I&&=(clearTimeout(I),null),L&&=(clearTimeout(L),null),q&&(K(A,q.profilerEntries),K(j,q.pubsubEntries))}function Se(e){return P.add(e),()=>P.delete(e)}function Ce(e){return F.add(e),()=>F.delete(e)}export{he as a,ve as c,_e as d,$ as f,xe as i,Z as l,ye as n,Se as o,X as p,be as r,Ce as s,ge as t,Q as u};