p3x-redis-ui-material
Version:
💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io
1 lines • 11.3 kB
JavaScript
"use strict";(self.webpackChunkp3x_redis_ui_material=self.webpackChunkp3x_redis_ui_material||[]).push([[7189],{46541(e,t,i){i.d(t,{lintKeymap:()=>w});var o=i(43599),s=i(41762),n=i(40662);class l{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class a{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let n=i.facet(k).markerFilter;n&&(e=n(e,i));let l=e.slice().sort(((e,t)=>e.from-t.from||e.to-t.to)),c=new s.vB,d=[],f=0,m=i.doc.iter(),h=0,u=i.doc.length;for(let e=0;;){let t,i,s=e==l.length?null:l[e];if(!s&&!d.length)break;if(d.length)t=f,i=d.reduce(((e,t)=>Math.min(e,t.to)),s&&s.from>t?s.from:1e8);else{if(t=s.from,t>u)break;i=s.to,d.push(s),e++}for(;e<l.length;){let o=l[e];if(o.from!=t||!(o.to>o.from||o.to==t)){i=Math.min(o.from,i);break}d.push(o),e++,i=Math.min(o.to,i)}i=Math.min(i,u);let n=!1;if(d.some((e=>e.from==t&&(e.to==i||i==u)))&&(n=t==i,!n&&i-t<10)){let e=t-(h+m.value.length);e>0&&(m.next(e),h=t);for(let e=t;;){if(e>=i){n=!0;break}if(!m.lineBreak&&h+m.value.length>e)break;e=h+m.value.length,h+=m.value.length,m.next()}}let a=L(d);if(n)c.add(t,t,o.NZ.widget({widget:new A(a),diagnostics:d.slice()}));else{let e=d.reduce(((e,t)=>t.markClass?e+" "+t.markClass:e),"");c.add(t,i,o.NZ.mark({class:"cm-lintRange cm-lintRange-"+a+e,diagnostics:d.slice(),inclusiveEnd:d.some((e=>e.to>i))}))}if(f=i,f==u)break;for(let e=0;e<d.length;e++)d[e].to<=f&&d.splice(e--,1)}let g=c.finish();return new a(g,t,r(g))}}function r(e,t=null,i=0){let o=null;return e.between(i,1e9,((e,i,{spec:s})=>{if(!(t&&s.diagnostics.indexOf(t)<0))if(o){if(s.diagnostics.indexOf(o.diagnostic)<0)return!1;o=new l(o.from,i,o.diagnostic)}else o=new l(e,i,t||s.diagnostics[0])})),o}function c(e,t){let i=t.pos,o=t.end||i,s=e.state.facet(k).hideOn(e,i,o);if(null!=s)return s;let n=e.startState.doc.lineAt(t.pos);return!(!e.effects.some((e=>e.is(f)))&&!e.changes.touchesRange(n.from,Math.max(n.to,o)))}function d(e,t){return e.field(u,!1)?t:t.concat(s.Pe.appendConfig.of(O))}const f=s.Pe.define(),m=s.Pe.define(),h=s.Pe.define(),u=s.sU.define({create:()=>new a(o.NZ.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),o=null,s=e.panel;if(e.selected){let s=t.changes.mapPos(e.selected.from,1);o=r(i,e.selected.diagnostic,s)||r(i,null,s)}!i.size&&s&&t.state.facet(k).autoPanel&&(s=null),e=new a(i,s,o)}for(let i of t.effects)if(i.is(f)){let o=t.state.facet(k).autoPanel?i.value.length?S.open:null:e.panel;e=a.init(i.value,o,t.state)}else i.is(m)?e=new a(e.diagnostics,i.value?S.open:null,e.selected):i.is(h)&&(e=new a(e.diagnostics,e.panel,i.value));return e},provide:e=>[o.S7.from(e,(e=>e.panel)),o.EditorView.decorations.from(e,(e=>e.diagnostics))]});const g=o.NZ.mark({class:"cm-lintRange cm-lintRange-active"});function p(e,t,i){let o,{diagnostics:s}=e.state.field(u),n=-1,l=-1;s.between(t-(i<0?1:0),t+(i>0?1:0),((e,s,{spec:a})=>{if(t>=e&&t<=s&&(e==s||(t>e||i>0)&&(t<s||i<0)))return o=a.diagnostics,n=e,l=s,!1}));let a=e.state.facet(k).tooltipFilter;return o&&a&&(o=a(o,e.state)),o?{pos:n,end:l,above:e.state.doc.lineAt(n).to<l,create:()=>({dom:b(e,o)})}:null}function b(e,t){return(0,n.A)("ul",{class:"cm-tooltip-lint"},t.map((t=>y(e,t,!1))))}const v=e=>{let t=e.state.field(u,!1);return!(!t||!t.panel)&&(e.dispatch({effects:m.of(!1)}),!0)},w=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(u,!1);t&&t.panel||e.dispatch({effects:d(e.state,[m.of(!0)])});let i=(0,o.ld)(e,S.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(u,!1);if(!t)return!1;let i=e.state.selection.main,o=r(t.diagnostics,null,i.to+1);return!(!o&&(o=r(t.diagnostics,null,0),!o||o.from==i.from&&o.to==i.to))&&(e.dispatch({selection:{anchor:o.from,head:o.to},scrollIntoView:!0}),!0)}}];const k=s.sj.define({combine:e=>({sources:e.map((e=>e.source)).filter((e=>null!=e)),...(0,s.QR)(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:x,tooltipFilter:x,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,o,s)=>e(i,o,s)||t(i,o,s):e:t,autoPanel:(e,t)=>e||t})})});function x(e,t){return e?t?(i,o)=>t(e(i,o),o):e:t}function C(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let o=i[e];if(/[a-zA-Z]/.test(o)&&!t.some((e=>e.toLowerCase()==o.toLowerCase()))){t.push(o);continue e}}t.push("")}return t}function y(e,t,i){var o;let s=i?C(t.actions):[];return(0,n.A)("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},(0,n.A)("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(o=t.actions)||void 0===o?void 0:o.map(((i,o)=>{let l=!1,a=o=>{if(o.preventDefault(),l)return;l=!0;let s=r(e.state.field(u).diagnostics,t);s&&i.apply(e,s.from,s.to)},{name:c}=i,d=s[o]?c.indexOf(s[o]):-1,f=d<0?c:[c.slice(0,d),(0,n.A)("u",c.slice(d,d+1)),c.slice(d+1)],m=i.markClass?" "+i.markClass:"";return(0,n.A)("button",{type:"button",class:"cm-diagnosticAction"+m,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${d<0?"":` (access key "${s[o]})"`}.`},f)})),t.source&&(0,n.A)("div",{class:"cm-diagnosticSource"},t.source))}class A extends o.xO{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return(0,n.A)("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class R{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=y(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class S{constructor(e){this.view=e,this.items=[];this.list=(0,n.A)("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(27==t.keyCode)v(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],o=C(i.actions);for(let s=0;s<o.length;s++)if(o[s].toUpperCase().charCodeAt(0)==t.keyCode){let t=r(this.view.state.field(u).diagnostics,i);t&&i.actions[s].apply(e,t.from,t.to)}}}t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=(0,n.A)("div",{class:"cm-panel-lint"},this.list,(0,n.A)("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>v(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(u).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(u),i=0,o=!1,s=null,n=new Set;for(e.between(0,this.view.state.doc.length,((e,l,{spec:a})=>{for(let e of a.diagnostics){if(n.has(e))continue;n.add(e);let l,a=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(l=new R(this.view,e),this.items.splice(i,0,l),o=!0):(l=this.items[a],a>i&&(this.items.splice(i,a-i),o=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),s=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),i++}}));i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();0==this.items.length&&(this.items.push(new R(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/i:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=r(this.view.state.field(u).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:h.of(t)})}static open(e){return new S(e)}}function I(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function P(e){return I(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const M=o.EditorView.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:P("#d11")},".cm-lintRange-warning":{backgroundImage:P("orange")},".cm-lintRange-info":{backgroundImage:P("#999")},".cm-lintRange-hint":{backgroundImage:P("#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 B(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function L(e){let t="hint",i=1;for(let o of e){let e=B(o.severity);e>i&&(i=e,t=o.severity)}return t}o.wJ;const O=[u,o.EditorView.decorations.compute([u],(e=>{let{selected:t,panel:i}=e.field(u);return t&&i&&t.from!=t.to?o.NZ.set([g.range(t.from,t.to)]):o.NZ.none})),(0,o.Ux)(p,{hideOn:c}),M]}}]);