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

2 lines (1 loc) • 18.2 kB
import{U as $,d as B}from"./chunk-MHKTEXY5.js";import{h as p,i as U,j as z,k as A,l as v}from"./chunk-O7S4L63H.js";var fe=new TextEncoder;var J=4096;function I(n,e,t){let i=e,s=i+t,r=[],o="";for(;i<s;){let a=n[i++];if((a&128)===0)r.push(a);else if((a&224)===192){let h=n[i++]&63;r.push((a&31)<<6|h)}else if((a&240)===224){let h=n[i++]&63,f=n[i++]&63;r.push((a&31)<<12|h<<6|f)}else if((a&248)===240){let h=n[i++]&63,f=n[i++]&63,l=n[i++]&63,d=(a&7)<<18|h<<12|f<<6|l;d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|d&1023),r.push(d)}else r.push(a);r.length>=J&&(o+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(o+=String.fromCharCode(...r)),o}var Y=new TextDecoder,j=200;function q(n,e,t){let i=n.subarray(e,e+t);return Y.decode(i)}function H(n,e,t){return t>j?q(n,e,t):I(n,e,t)}var u=class{type;data;constructor(e,t){this.type=e,this.data=t}};var c=class n extends Error{constructor(e){super(e);let t=Object.create(n.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:n.name})}};function K(n,e,t){let i=Math.floor(t/4294967296),s=t;n.setUint32(e,i),n.setUint32(e+4,s)}function y(n,e){let t=n.getInt32(e),i=n.getUint32(e+4);return t*4294967296+i}function F(n,e){let t=n.getUint32(e),i=n.getUint32(e+4);return t*4294967296+i}var G=-1,Q=4294967296-1,W=17179869184-1;function Z({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=W)if(e===0&&n<=Q){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,i=n&4294967295,s=new Uint8Array(8),r=new DataView(s.buffer);return r.setUint32(0,e<<2|t&3),r.setUint32(4,i),s}else{let t=new Uint8Array(12),i=new DataView(t.buffer);return i.setUint32(0,e),K(i,4,n),t}}function ee(n){let e=n.getTime(),t=Math.floor(e/1e3),i=(e-t*1e3)*1e6,s=Math.floor(i/1e9);return{sec:t+s,nsec:i-s*1e9}}function te(n){if(n instanceof Date){let e=ee(n);return Z(e)}else return null}function se(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),i=e.getUint32(4),s=(t&3)*4294967296+i,r=t>>>2;return{sec:s,nsec:r}}case 12:{let t=y(e,4),i=e.getUint32(0);return{sec:t,nsec:i}}default:throw new c(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function ie(n){let e=se(n);return new Date(e.sec*1e3+e.nsec/1e6)}var N={type:G,encode:te,decode:ie};var S=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(N)}register({type:e,encode:t,decode:i}){if(e>=0)this.encoders[e]=t,this.decoders[e]=i;else{let s=-1-e;this.builtInEncoders[s]=t,this.builtInDecoders[s]=i}}tryToEncode(e,t){for(let i=0;i<this.builtInEncoders.length;i++){let s=this.builtInEncoders[i];if(s!=null){let r=s(e,t);if(r!=null){let o=-1-i;return new u(o,r)}}}for(let i=0;i<this.encoders.length;i++){let s=this.encoders[i];if(s!=null){let r=s(e,t);if(r!=null){let o=i;return new u(o,r)}}}return e instanceof u?e:null}decode(e,t,i){let s=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return s?s(e,t,i):new u(t,e)}};function ne(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function M(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):ne(n)?new Uint8Array(n):Uint8Array.from(n)}function b(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}var re=16,oe=16,w=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=re,t=oe){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,i){let s=this.caches[i-1];e:for(let r of s){let o=r.bytes;for(let a=0;a<i;a++)if(o[a]!==e[t+a])continue e;return r.str}return null}store(e,t){let i=this.caches[e.length-1],s={bytes:e,str:t};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=s:i.push(s)}decode(e,t,i){let s=this.find(e,t,i);if(s!=null)return this.hit++,s;this.miss++;let r=I(e,t,i),o=Uint8Array.prototype.slice.call(e,t,t+i);return this.store(o,r),r}};var P="array",g="map_key",V="map_value",ae=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new c("The type of key must be string or number but "+typeof n)},k=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=P,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=g,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===P){let i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===g||e.type===V){let i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},m=-1,L=new DataView(new ArrayBuffer(0)),ce=new Uint8Array(L.buffer);try{L.getInt8(0)}catch(n){if(!(n instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var O=new RangeError("Insufficient data"),he=new w,E=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=L;bytes=ce;headByte=m;stack=new k;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??S.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?e.keyDecoder:he,this.mapKeyConverter=e?.mapKeyConverter??ae}clone(){return new n({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=m,this.stack.reset()}setBuffer(e){let t=M(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===m&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),i=M(e),s=new Uint8Array(t.length+i.length);s.set(t),s.set(i,t.length),this.setBuffer(s)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:i}=this;return new RangeError(`Extra ${t.byteLength-i} 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){let t=this.clone();yield*A(t.decodeMulti(e));return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}decodeAsync(e){return p(this,null,function*(){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let o=!1,a;try{for(var t=v(e),i,s,r;i=!(s=yield t.next()).done;i=!1){let d=s.value;if(o)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(d);try{a=this.doDecodeSync(),o=!0}catch(R){if(!(R instanceof RangeError))throw R}this.totalPos+=this.pos}}catch(s){r=[s]}finally{try{i&&(s=t.return)&&(yield s.call(t))}finally{if(r)throw r[0]}}if(o){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return a}let{headByte:h,pos:f,totalPos:l}=this;throw new RangeError(`Insufficient data in parsing ${b(h)} at ${l} (${f} in the current buffer)`)}finally{this.entered=!1}})}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}decodeMultiAsync(e,t){return z(this,null,function*(){if(this.entered){let a=this.clone();yield*A(a.decodeMultiAsync(e,t));return}try{this.entered=!0;let a=t,h=-1;try{for(var i=v(e),s,r,o;s=!(r=yield new U(i.next())).done;s=!1){let f=r.value;if(t&&h===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(f),a&&(h=this.readArraySize(),a=!1,this.complete());try{for(;yield this.doDecodeSync(),--h!==0;);}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}}catch(r){o=[r]}finally{try{s&&(r=i.return)&&(yield new U(r.call(i)))}finally{if(o)throw o[0]}}}finally{this.entered=!1}})}doDecodeSync(){e: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 s=e-128;if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e<160){let s=e-144;if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else{let s=e-160;t=this.decodeString(s,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)this.useBigInt64?t=this.readU64AsBigInt():t=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)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let s=this.lookU8();t=this.decodeString(s,1)}else if(e===218){let s=this.lookU16();t=this.decodeString(s,2)}else if(e===219){let s=this.lookU32();t=this.decodeString(s,4)}else if(e===220){let s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===221){let s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===222){let s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===223){let s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===196){let s=this.lookU8();t=this.decodeBinary(s,1)}else if(e===197){let s=this.lookU16();t=this.decodeBinary(s,2)}else if(e===198){let s=this.lookU32();t=this.decodeBinary(s,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 s=this.lookU8();t=this.decodeExtension(s,1)}else if(e===200){let s=this.lookU16();t=this.decodeExtension(s,2)}else if(e===201){let s=this.lookU32();t=this.decodeExtension(s,4)}else throw new c(`Unrecognized type byte: ${b(e)}`);this.complete();let i=this.stack;for(;i.length>0;){let s=i.top();if(s.type===P)if(s.array[s.position]=t,s.position++,s.position===s.size)t=s.array,i.release(s);else continue e;else if(s.type===g){if(t==="__proto__")throw new c("The key __proto__ is not allowed");s.key=this.mapKeyConverter(t),s.type=V;continue e}else if(s.map[s.key]=t,s.readCount++,s.readCount===s.size)t=s.map,i.release(s);else{s.key=null,s.type=g;continue e}}return t}}readHeadByte(){return this.headByte===m&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=m}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 c(`Unrecognized array type byte: ${b(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new c(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new c(`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 c(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw O;let i=this.pos+t,s;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?s=this.keyDecoder.decode(this.bytes,i,e):s=H(this.bytes,i,e),this.pos+=t+e,s}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===g:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new c(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw O;let i=this.pos+t,s=this.bytes.subarray(i,i+e);return this.pos+=t+e,s}decodeExtension(e,t){if(e>this.maxExtLength)throw new c(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let i=this.view.getInt8(this.pos+t),s=this.decodeBinary(e,t+1);return this.extensionCodec.decode(s,i,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=F(this.view,this.pos);return this.pos+=8,e}readI64(){let e=y(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 D(n,e){return new E(e).decode(n)}var _="p3xr-profiler-entries",C="p3xr-pubsub-entries",T=1e4,de=100,X=2e3,Oe=(()=>{class n{profilerEntries=[];pubsubEntries=[];profilerEntry$=new B;pubsubEntry$=new B;profilerStarted=!1;pubsubStarted=!1;pubsubPattern="*";socket;langFn;profilerSaveTimeout=null;pubsubSaveTimeout=null;initialized=!1;init(t,i){this.socket=t,this.langFn=i,this.initialized||(this.restoreFromStorage(),this.initialized=!0)}destroy(){this.saveProfilerNow(),this.savePubSubNow()}startProfiler(){return p(this,null,function*(){this.profilerStarted||(yield this.socket.request({action:"monitor/set",payload:{enabled:!0}}),this.profilerStarted=!0,this.socket.getClient()?.on?.("monitor-data",this.onMonitorData))})}stopProfiler(){this.profilerStarted&&(this.socket.request({action:"monitor/set",payload:{enabled:!1}}).catch(()=>{}),this.socket.getClient()?.removeListener?.("monitor-data",this.onMonitorData),this.profilerStarted=!1,this.saveProfilerNow())}startPubSub(){return p(this,null,function*(){this.pubsubStarted||(yield this.socket.request({action:"settings/subscription",payload:{subscription:!0,subscriberPattern:this.pubsubPattern}}),this.pubsubStarted=!0,this.socket.getClient()?.on?.("pubsub-message",this.onPubSubMessage))})}stopPubSub(){this.pubsubStarted&&(this.socket.request({action:"settings/subscription",payload:{subscription:!1,subscriberPattern:"*"}}).catch(()=>{}),this.socket.getClient()?.removeListener?.("pubsub-message",this.onPubSubMessage),this.pubsubStarted=!1,this.savePubSubNow())}restartPubSub(){return p(this,null,function*(){this.stopPubSub(),yield this.startPubSub()})}clearProfiler(){this.profilerEntries=[];try{localStorage.removeItem(_)}catch(t){}}clearPubSub(){this.pubsubEntries=[];try{localStorage.removeItem(C)}catch(t){}}onMonitorData=t=>{let i=this.langFn()||"en",s=new Date(parseFloat(t.time)*1e3),o={displayTime:s.toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,fractionalSecondDigits:3}),fullTimestamp:s.toISOString(),database:t.database,source:t.source,command:(t.args||[]).join(" ")};this.profilerEntries.push(o),this.profilerEntries.length>T&&(this.profilerEntries=this.profilerEntries.slice(-T)),this.profilerEntry$.next(o),this.debounceSaveProfiler()};decodePubsubMessage(t){if(t instanceof ArrayBuffer)try{let i=D(new Uint8Array(t));return JSON.stringify(i,null,2)}catch(i){return new TextDecoder().decode(t)}return String(t)}onPubSubMessage=t=>{let i=this.langFn()||"en",s=new Date,o={displayTime:s.toLocaleTimeString(i,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),fullTimestamp:s.toISOString(),channel:t.channel,message:this.decodePubsubMessage(t.message)};this.pubsubEntries.push(o),this.pubsubEntries.length>T&&(this.pubsubEntries=this.pubsubEntries.slice(-T)),this.pubsubEntry$.next(o),this.debounceSavePubSub()};debounceSaveProfiler(){this.profilerSaveTimeout||(this.profilerSaveTimeout=setTimeout(()=>{this.profilerSaveTimeout=null,this.saveProfilerNow()},X))}debounceSavePubSub(){this.pubsubSaveTimeout||(this.pubsubSaveTimeout=setTimeout(()=>{this.pubsubSaveTimeout=null,this.savePubSubNow()},X))}saveProfilerNow(){this.profilerSaveTimeout&&(clearTimeout(this.profilerSaveTimeout),this.profilerSaveTimeout=null),this.saveToStorage(_,this.profilerEntries)}savePubSubNow(){this.pubsubSaveTimeout&&(clearTimeout(this.pubsubSaveTimeout),this.pubsubSaveTimeout=null),this.saveToStorage(C,this.pubsubEntries)}saveToStorage(t,i){let s=i.slice(-de);try{localStorage.setItem(t,JSON.stringify(s))}catch(r){try{localStorage.removeItem(t)}catch(o){}}}restoreFromStorage(){try{let t=localStorage.getItem(_);t&&(this.profilerEntries=JSON.parse(t))}catch(t){}try{let t=localStorage.getItem(C);t&&(this.pubsubEntries=JSON.parse(t))}catch(t){}}static \u0275fac=function(i){return new(i||n)};static \u0275prov=$({token:n,factory:n.\u0275fac,providedIn:"root"})}return n})();export{Oe as a};