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 • 16.2 kB
import{a as F,i as E$1}from"./main-OCJB5534.js";import{c as S,r as G$1,t as A$1,v as le$1,w as vt,x as q}from"./chunk-DqaCTAv8.js";import{H as os,P as gr,U as pt,V as oa,b as Ul,c as J,d as N$1,h as Q,k as ct,p as O$1,q as rt,z as ml}from"./chunk-pcoW9sAP2.js";var I=class{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}};var T=class t{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let s=i.facet(v).markerFilter;s&&(e=s(e,i));let o=e.slice().sort((u,b)=>u.from-b.from||u.to-b.to),r=new G$1,l=[],a=0,c=i.doc.iter(),d=0,w=i.doc.length;for(let u=0;;){let b=u==o.length?null:o[u];if(!b&&!l.length)break;let g,m;if(l.length)g=a,m=l.reduce((f,x)=>Math.min(f,x.to),b&&b.from>g?b.from:1e8);else{if(g=b.from,g>w)break;m=b.to,l.push(b),u++}for(;u<o.length;){let f=o[u];if(f.from==g&&(f.to>f.from||f.to==g))l.push(f),u++,m=Math.min(f.to,m);else{m=Math.min(f.from,m);break}}m=Math.min(m,w);let F=!1;if(l.some(f=>f.from==g&&(f.to==m||m==w))&&(F=g==m,!F&&m-g<10)){let f=g-(d+c.value.length);f>0&&(c.next(f),d=g);for(let x=g;;){if(x>=m){F=!0;break}if(!c.lineBreak&&d+c.value.length>x)break;x=d+c.value.length,d+=c.value.length,c.next()}}let Y=me(l);if(F)r.add(g,g,O$1.widget({widget:new K(Y),diagnostics:l.slice()}));else{let f=l.reduce((x,_)=>_.markClass?x+` `+_.markClass:x,``);r.add(g,m,O$1.mark({class:`cm-lintRange cm-lintRange-`+Y+f,diagnostics:l.slice(),inclusiveEnd:l.some(x=>x.to>m)}))}if(a=m,a==w)break;for(let f=0;f<l.length;f++)l[f].to<=a&&l.splice(f--,1)}let p=r.finish();return new t(p,n,y(p))}};function y(t,e=null,n=0){let i=null;return t.between(n,1e9,(s,o,{spec:r})=>{if(!(e&&r.diagnostics.indexOf(e)<0))if(!i)i=new I(s,o,e||r.diagnostics[0]);else{if(r.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new I(i.from,o,i.diagnostic)}}),i}function le(t,e){let n=e.pos,i=e.end||n,s=t.state.facet(v).hideOn(t,n,i);if(s!=null)return s;let o=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(r=>r.is(O))||t.changes.touchesRange(o.from,Math.max(o.to,i)))}function re(t,e){return t.field(h,!1)?e:e.concat(A$1.appendConfig.of(ge))}function pe(t,e){return{effects:re(t,[O.of(e)])}}var O=A$1.define();var j=A$1.define();var ae=A$1.define();var h=q.define({create(){return new T(O$1.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,s=t.panel;if(t.selected){let o=e.changes.mapPos(t.selected.from,1);i=y(n,t.selected.diagnostic,o)||y(n,null,o)}!n.size&&s&&e.state.facet(v).autoPanel&&(s=null),t=new T(n,s,i)}for(let n of e.effects)if(n.is(O)){let i=e.state.facet(v).autoPanel?n.value.length?P.open:null:t.panel;t=T.init(n.value,i,e.state)}else n.is(j)?t=new T(t.diagnostics,n.value?P.open:null,t.selected):n.is(ae)&&(t=new T(t.diagnostics,t.panel,n.value));return t},provide:t=>[os.from(t,e=>e.panel),pt.decorations.from(t,e=>e.diagnostics)]});function Ae(t){let e=t.field(h,!1);return e?e.diagnostics.size:0}var be=O$1.mark({class:`cm-lintRange cm-lintRange-active`});function we(t,e,n){let{diagnostics:i}=t.state.field(h),s,o=-1,r=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(a,c,{spec:d})=>{if(e>=a&&e<=c&&(a==c||(e>a||n>0)&&(e<c||n<0)))return s=d.diagnostics,o=a,r=c,!1});let l=t.state.facet(v).tooltipFilter;return s&&l&&(s=l(s,t.state)),s?{pos:o,end:r,above:t.state.doc.lineAt(o).to<r,create(){return{dom:ce(t,s)}}}:null}function ce(t,e){return ct(`ul`,{class:`cm-tooltip-lint`},e.map(n=>ue(t,n,!1)))}var ke=t=>{let e=t.state.field(h,!1);(!e||!e.panel)&&t.dispatch({effects:re(t.state,[j.of(!0)])});let n=ml(t,P.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0};var se=t=>{let e=t.state.field(h,!1);return!e||!e.panel?!1:(t.dispatch({effects:j.of(!1)}),!0)};var xe=t=>{let e=t.state.field(h,!1);if(!e)return!1;let n=t.state.selection.main,i=y(e.diagnostics,null,n.to+1);return!i&&(i=y(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)};var Ie=t=>{let{state:e}=t,n=e.field(h,!1);if(!n)return!1;let i=e.selection.main,s,o,r,l;return n.diagnostics.between(0,e.doc.length,(a,c)=>{c<i.to&&(s==null||s<a)&&(s=a,o=c),(r==null||a>r)&&(r=a,l=c)}),r==null||s==null&&r==i.from?!1:(t.dispatch({selection:{anchor:s??r,head:o??l},scrollIntoView:!0}),!0)};var Ee=[{key:`Mod-Shift-m`,run:ke,preventDefault:!0},{key:`F8`,run:xe}];var fe=N$1.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(v);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:n}=e.facet(v);n.length&&ve(n.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(pe(this.view.state,i.reduce((s,o)=>s.concat(o))))},i=>{Q(this.view.state,i)})}}update(t){let e=t.state.facet(v);(t.docChanged||e!=t.startState.facet(v)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function ve(t,e,n){let i=[],s=-1;for(let o of t)o.then(r=>{i.push(r),clearTimeout(s),i.length==t.length?e(i):s=setTimeout(()=>e(i),200)},n)}var v=S.define({combine(t){return E$1({sources:t.map(e=>e.source).filter(e=>e!=null)},vt(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:oe,tooltipFilter:oe,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,s,o)=>e(i,s,o)||n(i,s,o):e:n,autoPanel:(e,n)=>e||n}))}});function oe(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function Be(t,e={}){return[v.of({source:t,config:e}),fe,ge]}function Oe(t){let e=t.plugin(fe);e&&e.force()}function de(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let s=n[i];if(/[a-zA-Z]/.test(s)&&!e.some(o=>o.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push(``)}return e}function ue(t,e,n){var i;let s=n?de(e.actions):[];return ct(`li`,{class:`cm-diagnostic cm-diagnostic-`+e.severity},ct(`span`,{class:`cm-diagnosticText`},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,r)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let b=y(t.state.field(h).diagnostics,e);b&&o.apply(t,b.from,b.to)},{name:c}=o,d=s[r]?c.indexOf(s[r]):-1,w=d<0?c:[c.slice(0,d),ct(`u`,c.slice(d,d+1)),c.slice(d+1)];return ct(`button`,{type:`button`,class:`cm-diagnosticAction`+(o.markClass?` `+o.markClass:``),onclick:a,onmousedown:a,"aria-label":` Action: ${c}${d<0?``:` (access key "${s[r]})"`}.`},w)}),e.source&&ct(`div`,{class:`cm-diagnosticSource`},e.source))}var K=class extends rt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ct(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}};var E=class{constructor(e,n){this.diagnostic=n,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=ue(e,n,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}};var P=class t{constructor(e){this.view=e,this.items=[];let n=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)se(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],r=de(o.actions);for(let l=0;l<r.length;l++)if(r[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=y(this.view.state.field(h).diagnostics,o);a&&o.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()}},i=s=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(s.target)&&this.moveSelection(o)};this.list=ct(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:n,onclick:i}),this.dom=ct(`div`,{class:`cm-panel-lint`},this.list,ct(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>se(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(h).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(h),i=0,s=!1,o=null,r=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:c})=>{for(let d of c.diagnostics){if(r.has(d))continue;r.add(d);let w=-1,p;for(let u=i;u<this.items.length;u++)if(this.items[u].diagnostic==d){w=u;break}w<0?(p=new E(this.view,d),this.items.splice(i,0,p),s=!0):(p=this.items[w],w>i&&(this.items.splice(i,w-i),s=!0)),n&&p.diagnostic==n.diagnostic?p.dom.hasAttribute(`aria-selected`)||(p.dom.setAttribute(`aria-selected`,`true`),o=p):p.dom.hasAttribute(`aria-selected`)&&p.dom.removeAttribute(`aria-selected`),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new E(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),s=!0),o?(this.list.setAttribute(`aria-activedescendant`,o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let c=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/c:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),s&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let i=y(this.view.state.field(h).diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:ae.of(i)})}static open(e){return new t(e)}};function A(t,e=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function D(t){return A(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var ye=pt.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:D(`#d11`)},".cm-lintRange-warning":{backgroundImage:D(`orange`)},".cm-lintRange-info":{backgroundImage:D(`#999`)},".cm-lintRange-hint":{backgroundImage:D(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ce(t){return t==`error`?4:t==`warning`?3:t==`info`?2:1}function me(t){let e=`hint`,n=1;for(let i of t){let s=Ce(i.severity);s>n&&(n=s,e=i.severity)}return e}var B=class extends J{constructor(e){super(),this.diagnostics=e,this.severity=me(e)}toDOM(e){let n=document.createElement(`div`);n.className=`cm-lint-marker cm-lint-marker-`+this.severity;let i=this.diagnostics,s=e.state.facet(G).tooltipFilter;return s&&(i=s(i,e.state)),i.length&&(n.onmouseover=()=>Re(e,n,i)),n}};function Te(t,e){let n=i=>{let s=e.getBoundingClientRect();if(!(i.clientX>s.left-10&&i.clientX<s.right+10&&i.clientY>s.top-10&&i.clientY<s.bottom+10)){for(let o=i.target;o;o=o.parentNode)if(o.nodeType==1&&o.classList.contains(`cm-tooltip-lint`))return;window.removeEventListener(`mousemove`,n),t.state.field(he)&&t.dispatch({effects:N.of(null)})}};window.addEventListener(`mousemove`,n)}function Re(t,e,n){function i(){let r=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(r.from)&&t.dispatch({effects:N.of({pos:r.from,above:!1,clip:!1,create(){return{dom:ce(t,n),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,Te(t,e)}let{hoverTime:s}=t.state.facet(G),o=setTimeout(i,s);e.onmouseout=()=>{clearTimeout(o),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(o),o=setTimeout(i,s)}}function Se(t,e){let n=Object.create(null);for(let s of e){let o=t.lineAt(s.from);(n[o.from]||(n[o.from]=[])).push(s)}let i=[];for(let s in n)i.push(new B(n[s]).range(+s));return le$1.of(i,!0)}var Pe=oa({class:`cm-gutter-lint`,markers:t=>t.state.field(V),widgetMarker:(t,e,n)=>{let i=[];return t.state.field(V).between(n.from,n.to,(s,o,r)=>{s>n.from&&s<n.to&&i.push(...r.diagnostics)}),i.length?new B(i):null}});var V=q.define({create(){return le$1.empty},update(t,e){t=t.map(e.changes);let n=e.state.facet(G).markerFilter;for(let i of e.effects)if(i.is(O)){let s=i.value;n&&(s=n(s||[],e.state)),t=Se(e.state.doc,s.slice(0))}return t}});var N=A$1.define();var he=q.define({create(){return null},update(t,e){return t&&e.docChanged&&(t=le(e,t)?null:F(E$1({},t),{pos:e.changes.mapPos(t.pos)})),e.effects.reduce((n,i)=>i.is(N)?i.value:n,t)},provide:t=>gr.from(t)});var Fe=pt.baseTheme({".cm-gutter-lint":{width:`1.4em`,"& .cm-gutterElement":{padding:`.2em`}},".cm-lint-marker":{width:`1em`,height:`1em`},".cm-lint-marker-info":{content:A(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)},".cm-lint-marker-warning":{content:A(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`)},".cm-lint-marker-error":{content:A(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)}});var ge=[h,pt.decorations.compute([h],t=>{let{selected:e,panel:n}=t.field(h);return!e||!n||e.from==e.to?O$1.none:O$1.set([be.range(e.from,e.to)])}),Ul(we,{hideOn:le}),ye];var G=S.define({combine(t){return vt(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Ge(t={}){return[G.of(t),V,Pe,Fe,he]}function ze(t,e){let n=t.field(h,!1);if(n&&n.diagnostics.size){let i=[],s=[],o=-1;for(let r=le$1.iter([n.diagnostics]);;r.next()){for(let l=0;l<i.length;l++)(!r.value||r.value.spec.diagnostics.indexOf(i[l])<0)&&(e(i[l],s[l],o),i.splice(l,1),s.splice(l--,1));if(!r.value)break;for(let l of r.value.spec.diagnostics)i.indexOf(l)<0&&(i.push(l),s.push(r.from));o=r.to}}}export{se as closeLintPanel,Ae as diagnosticCount,ze as forEachDiagnostic,Oe as forceLinting,Ge as lintGutter,Ee as lintKeymap,Be as linter,xe as nextDiagnostic,ke as openLintPanel,Ie as previousDiagnostic,pe as setDiagnostics,O as setDiagnosticsEffect};