code-server
Version:
Run VS Code on a remote server.
2 lines (1 loc) • 7.56 kB
JavaScript
var l=class e{constructor(t,n){if(this.start=t,this.endExclusive=n,t>n)throw new Error(`Invalid range: [${t}, ${n})`)}static fromTo(t,n){return new e(t,n)}static ofLength(t){return new e(0,t)}static ofStartAndLength(t,n){return new e(t,t+n)}static emptyAt(t){return new e(t,t)}get isEmpty(){return this.start===this.endExclusive}get length(){return this.endExclusive-this.start}delta(t){return new e(this.start+t,this.endExclusive+t)}deltaStart(t){return new e(this.start+t,this.endExclusive)}deltaEnd(t){return new e(this.start,this.endExclusive+t)}contains(t){return this.start<=t&&t<this.endExclusive}containsRange(t){return this.start<=t.start&&t.endExclusive<=this.endExclusive}intersects(t){return Math.max(this.start,t.start)<Math.min(this.endExclusive,t.endExclusive)}intersectsOrTouches(t){return Math.max(this.start,t.start)<=Math.min(this.endExclusive,t.endExclusive)}intersect(t){let n=Math.max(this.start,t.start),r=Math.min(this.endExclusive,t.endExclusive);if(n<=r)return new e(n,r)}join(t){return new e(Math.min(this.start,t.start),Math.max(this.endExclusive,t.endExclusive))}isBefore(t){return this.endExclusive<=t.start}isAfter(t){return this.start>=t.endExclusive}substring(t){return t.substring(this.start,this.endExclusive)}slice(t){return t.slice(this.start,this.endExclusive)}equals(t){return this.start===t.start&&this.endExclusive===t.endExclusive}toString(){return`[${this.start}, ${this.endExclusive})`}},a=class e{constructor(t,n){this.replaceRange=t,this.newText=n}static insert(t,n){return new e(l.emptyAt(t),n)}static replace(t,n){return new e(t,n)}static delete(t){return new e(t,"")}get isEmpty(){return this.replaceRange.isEmpty&&this.newText.length===0}equals(t){return this.replaceRange.equals(t.replaceRange)&&this.newText===t.newText}removeCommonSuffixPrefix(t){let n=this.replaceRange.substring(t),r=R(n,this.newText),i=Math.min(n.length-r,this.newText.length-r,H(n,this.newText));return new e(new l(this.replaceRange.start+r,this.replaceRange.endExclusive-i),this.newText.substring(r,this.newText.length-i))}toString(){return`${this.replaceRange} -> ${JSON.stringify(this.newText)}`}};function R(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r}function H(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e.charCodeAt(e.length-r-1)===t.charCodeAt(t.length-r-1);)r++;return r}var g=class e{static empty=new e([]);static single(t){return new e([t])}static replace(t,n){return new e([a.replace(t,n)])}static insert(t,n){return new e([a.insert(t,n)])}static delete(t){return new e([a.delete(t)])}replacements;constructor(t){let n=-1;for(let r of t){if(r.replaceRange.start<n)throw new Error(`Edits must be disjoint and sorted. Found ${r} after ${n}`);n=r.replaceRange.endExclusive}this.replacements=t}get isEmpty(){return this.replacements.length===0}apply(t){let n=[],r=0;for(let i of this.replacements)n.push(t.substring(r,i.replaceRange.start)),n.push(i.newText),r=i.replaceRange.endExclusive;return n.push(t.substring(r)),n.join("")}inverse(t){let n=[],r=0;for(let i of this.replacements){let s=t.substring(i.replaceRange.start,i.replaceRange.endExclusive);n.push(a.replace(l.ofStartAndLength(i.replaceRange.start+r,i.newText.length),s)),r+=i.newText.length-i.replaceRange.length}return new e(n)}equals(t){if(this.replacements.length!==t.replacements.length)return!1;for(let n=0;n<this.replacements.length;n++)if(!this.replacements[n].equals(t.replacements[n]))return!1;return!0}mapOffset(t){let n=0;for(let r of this.replacements){if(r.replaceRange.start>t)break;if(r.replaceRange.endExclusive<=t)n+=r.newText.length-r.replaceRange.length;else return r.replaceRange.start+n+r.newText.length}return t+n}toString(){return`[${this.replacements.map(t=>t.toString()).join(", ")}]`}};function C(e,t){return e===t?g.empty:g.single(a.replace(new l(0,e.length),t).removeCommonSuffixPrefix(e))}var f=class e{constructor(t,n){this.x=t,this.y=n}static ZERO=new e(0,0);translate(t,n){return new e(this.x+t,this.y+n)}},h=class e{constructor(t,n,r,i){this.x=t,this.y=n,this.width=r,this.height=i}static EMPTY=new e(0,0,0,0);static fromPointPoint(t,n,r,i){return new e(t,n,r-t,i-n)}static fromPointSize(t,n,r,i){return new e(t,n,r,i)}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get topLeft(){return new f(this.x,this.y)}containsX(t){return t>=this.left&&t<this.right}containsY(t){return t>=this.top&&t<this.bottom}containsPoint(t){return this.containsX(t.x)&&this.containsY(t.y)}withZeroWidthAt(t){return new e(t,this.y,0,this.height)}translate(t,n){return new e(this.x+t,this.y+n,this.width,this.height)}},x=1;function P(e,t,n){if(M(e))return;let r=e.ownerDocument;if(e===r.scrollingElement)return T(r.defaultView??window,t,n);let i=b(e,t,n,e.clientWidth,e.clientHeight);return{eventTarget:e,isReached:()=>y(e.scrollLeft,e.scrollTop,i)}}function T(e,t,n){let r=e.document,i=b(r.scrollingElement??r.documentElement,t,n,r.documentElement.clientWidth||e.innerWidth,r.documentElement.clientHeight||e.innerHeight);return{eventTarget:r,isReached:()=>y(e.scrollX,e.scrollY,i)}}function b(e,t,n,r,i){let s=Math.max(0,e.scrollWidth-r),o=Math.max(0,e.scrollHeight-i),c=(e.ownerDocument.defaultView??window).getComputedStyle(e).direction==="rtl";return new f(c?Math.max(-s,Math.min(0,t)):Math.max(0,Math.min(s,t)),Math.max(0,Math.min(o,n)))}function y(e,t,n){return Math.abs(e-n.x)<=x&&Math.abs(t-n.y)<=x}function A(e){let t=e.ownerDocument,n=t.defaultView??window,r=h.fromPointSize(0,0,t.documentElement.clientWidth||n.innerWidth,t.documentElement.clientHeight||n.innerHeight);for(let i=e.parentElement;i;i=i.parentElement){let s=n.getComputedStyle(i),o=E(s.overflowX),c=E(s.overflowY);if(!o&&!c)continue;let u=S(i),d=o?Math.max(r.left,u.left):r.left,w=o?Math.min(r.right,u.right):r.right,m=c?Math.max(r.top,u.top):r.top,p=c?Math.min(r.bottom,u.bottom):r.bottom;if(w<=d||p<=m)return h.fromPointSize(d,m,0,0);r=h.fromPointPoint(d,m,w,p)}return r}function S(e){let t=e.getBoundingClientRect(),n=e.offsetWidth>0?t.width/e.offsetWidth:1,r=e.offsetHeight>0?t.height/e.offsetHeight:1;return h.fromPointSize(t.left+e.clientLeft*n,t.top+e.clientTop*r,e.clientWidth*n,e.clientHeight*r)}function $(e,t,n){let r=e.getBoundingClientRect(),i=e.offsetWidth>0?r.width/e.offsetWidth:1,s=e.offsetHeight>0?r.height/e.offsetHeight:1;return{x:t/i,y:n/s}}function W(e){let t=Math.max(e.horizontalScrollbarHeight,0);return e.scrollHeight-e.clientHeight>t}function M(e){let t=e.ownerDocument;if(e!==t.body)return!1;let n=t.defaultView?.getComputedStyle(t.documentElement);return n!==void 0&&n.overflowX==="visible"&&n.overflowY==="visible"}function Y(e){if(M(e))return!1;let t=e.ownerDocument.defaultView?.getComputedStyle(e),n=t?parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth):0;return W({scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,horizontalScrollbarHeight:e.offsetHeight-e.clientHeight-(Number.isFinite(n)?n:0)})}function L(e){let t=e.ownerDocument.defaultView??window,n=[];for(let r=e.parentElement;r;r=r.parentElement){let i=t.getComputedStyle(r),s=v(i.overflowX)&&r.scrollWidth>r.clientWidth,o=v(i.overflowY)&&r.scrollHeight>r.clientHeight;(s||o)&&n.push(r)}return n}function V(e,t){return e.left<=t.left&&t.right<=e.right&&e.top<=t.top&&t.bottom<=e.bottom}function E(e){return e==="auto"||e==="scroll"||e==="hidden"||e==="clip"}function v(e){return e==="auto"||e==="scroll"||e==="hidden"}export{l as a,a as b,g as c,C as d,f as e,h as f,P as g,T as h,A as i,S as j,$ as k,Y as l,L as m,V as n};