UNPKG

code-server

Version:

Run VS Code on a remote server.

87 lines (74 loc) • 27.9 kB
"use strict";var xe=Object.create;var H=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var Ae=(s,i)=>{for(var t in i)H(s,t,{get:i[t],enumerable:!0})},ve=(s,i,t,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of Be(i))!Ee.call(s,p)&&p!==t&&H(s,p,{get:()=>i[p],enumerable:!(n=Ce(i,p))||n.enumerable});return s};var T=(s,i,t)=>(t=s!=null?xe(_e(s)):{},ve(i||!s||!s.__esModule?H(t,"default",{value:s,enumerable:!0}):t,s)),ze=s=>ve(H({},"__esModule",{value:!0}),s);var Re={};Ae(Re,{activate:()=>Oe});module.exports=ze(Re);var $=T(require("vscode"));var R=T(require("vscode"));var me;(()=>{"use strict";var s={470:p=>{function m(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function w(r,u){for(var v,l="",d=0,h=-1,S=0,f=0;f<=r.length;++f){if(f<r.length)v=r.charCodeAt(f);else{if(v===47)break;v=47}if(v===47){if(!(h===f-1||S===1))if(h!==f-1&&S===2){if(l.length<2||d!==2||l.charCodeAt(l.length-1)!==46||l.charCodeAt(l.length-2)!==46){if(l.length>2){var C=l.lastIndexOf("/");if(C!==l.length-1){C===-1?(l="",d=0):d=(l=l.slice(0,C)).length-1-l.lastIndexOf("/"),h=f,S=0;continue}}else if(l.length===2||l.length===1){l="",d=0,h=f,S=0;continue}}u&&(l.length>0?l+="/..":l="..",d=2)}else l.length>0?l+="/"+r.slice(h+1,f):l=r.slice(h+1,f),d=f-h-1;h=f,S=0}else v===46&&S!==-1?++S:S=-1}return l}var b={resolve:function(){for(var r,u="",v=!1,l=arguments.length-1;l>=-1&&!v;l--){var d;l>=0?d=arguments[l]:(r===void 0&&(r=process.cwd()),d=r),m(d),d.length!==0&&(u=d+"/"+u,v=d.charCodeAt(0)===47)}return u=w(u,!v),v?u.length>0?"/"+u:"/":u.length>0?u:"."},normalize:function(r){if(m(r),r.length===0)return".";var u=r.charCodeAt(0)===47,v=r.charCodeAt(r.length-1)===47;return(r=w(r,!u)).length!==0||u||(r="."),r.length>0&&v&&(r+="/"),u?"/"+r:r},isAbsolute:function(r){return m(r),r.length>0&&r.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var r,u=0;u<arguments.length;++u){var v=arguments[u];m(v),v.length>0&&(r===void 0?r=v:r+="/"+v)}return r===void 0?".":b.normalize(r)},relative:function(r,u){if(m(r),m(u),r===u||(r=b.resolve(r))===(u=b.resolve(u)))return"";for(var v=1;v<r.length&&r.charCodeAt(v)===47;++v);for(var l=r.length,d=l-v,h=1;h<u.length&&u.charCodeAt(h)===47;++h);for(var S=u.length-h,f=d<S?d:S,C=-1,x=0;x<=f;++x){if(x===f){if(S>f){if(u.charCodeAt(h+x)===47)return u.slice(h+x+1);if(x===0)return u.slice(h+x)}else d>f&&(r.charCodeAt(v+x)===47?C=x:x===0&&(C=0));break}var D=r.charCodeAt(v+x);if(D!==u.charCodeAt(h+x))break;D===47&&(C=x)}var k="";for(x=v+C+1;x<=l;++x)x!==l&&r.charCodeAt(x)!==47||(k.length===0?k+="..":k+="/..");return k.length>0?k+u.slice(h+C):(h+=C,u.charCodeAt(h)===47&&++h,u.slice(h))},_makeLong:function(r){return r},dirname:function(r){if(m(r),r.length===0)return".";for(var u=r.charCodeAt(0),v=u===47,l=-1,d=!0,h=r.length-1;h>=1;--h)if((u=r.charCodeAt(h))===47){if(!d){l=h;break}}else d=!1;return l===-1?v?"/":".":v&&l===1?"//":r.slice(0,l)},basename:function(r,u){if(u!==void 0&&typeof u!="string")throw new TypeError('"ext" argument must be a string');m(r);var v,l=0,d=-1,h=!0;if(u!==void 0&&u.length>0&&u.length<=r.length){if(u.length===r.length&&u===r)return"";var S=u.length-1,f=-1;for(v=r.length-1;v>=0;--v){var C=r.charCodeAt(v);if(C===47){if(!h){l=v+1;break}}else f===-1&&(h=!1,f=v+1),S>=0&&(C===u.charCodeAt(S)?--S==-1&&(d=v):(S=-1,d=f))}return l===d?d=f:d===-1&&(d=r.length),r.slice(l,d)}for(v=r.length-1;v>=0;--v)if(r.charCodeAt(v)===47){if(!h){l=v+1;break}}else d===-1&&(h=!1,d=v+1);return d===-1?"":r.slice(l,d)},extname:function(r){m(r);for(var u=-1,v=0,l=-1,d=!0,h=0,S=r.length-1;S>=0;--S){var f=r.charCodeAt(S);if(f!==47)l===-1&&(d=!1,l=S+1),f===46?u===-1?u=S:h!==1&&(h=1):u!==-1&&(h=-1);else if(!d){v=S+1;break}}return u===-1||l===-1||h===0||h===1&&u===l-1&&u===v+1?"":r.slice(u,l)},format:function(r){if(r===null||typeof r!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof r);return(function(u,v){var l=v.dir||v.root,d=v.base||(v.name||"")+(v.ext||"");return l?l===v.root?l+d:l+"/"+d:d})(0,r)},parse:function(r){m(r);var u={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return u;var v,l=r.charCodeAt(0),d=l===47;d?(u.root="/",v=1):v=0;for(var h=-1,S=0,f=-1,C=!0,x=r.length-1,D=0;x>=v;--x)if((l=r.charCodeAt(x))!==47)f===-1&&(C=!1,f=x+1),l===46?h===-1?h=x:D!==1&&(D=1):h!==-1&&(D=-1);else if(!C){S=x+1;break}return h===-1||f===-1||D===0||D===1&&h===f-1&&h===S+1?f!==-1&&(u.base=u.name=S===0&&d?r.slice(1,f):r.slice(S,f)):(S===0&&d?(u.name=r.slice(1,h),u.base=r.slice(1,f)):(u.name=r.slice(S,h),u.base=r.slice(S,f)),u.ext=r.slice(h,f)),S>0?u.dir=r.slice(0,S-1):d&&(u.dir="/"),u},sep:"/",delimiter:":",win32:null,posix:null};b.posix=b,p.exports=b}},i={};function t(p){var m=i[p];if(m!==void 0)return m.exports;var w=i[p]={exports:{}};return s[p](w,w.exports,t),w.exports}t.d=(p,m)=>{for(var w in m)t.o(m,w)&&!t.o(p,w)&&Object.defineProperty(p,w,{enumerable:!0,get:m[w]})},t.o=(p,m)=>Object.prototype.hasOwnProperty.call(p,m),t.r=p=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(p,"__esModule",{value:!0})};var n={};(()=>{var p;if(t.r(n),t.d(n,{URI:()=>f,Utils:()=>se}),typeof process=="object")p=process.platform==="win32";else if(typeof navigator=="object"){var m=navigator.userAgent;p=m.indexOf("Windows")>=0}var w,b,r=(w=function(a,e){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,c){o.__proto__=c}||function(o,c){for(var y in c)Object.prototype.hasOwnProperty.call(c,y)&&(o[y]=c[y])},w(a,e)},function(a,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=a}w(a,e),a.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}),u=/^\w[\w\d+.-]*$/,v=/^\//,l=/^\/\//,d="",h="/",S=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,f=(function(){function a(e,o,c,y,g,P){P===void 0&&(P=!1),typeof e=="object"?(this.scheme=e.scheme||d,this.authority=e.authority||d,this.path=e.path||d,this.query=e.query||d,this.fragment=e.fragment||d):(this.scheme=(function(B,E){return B||E?B:"file"})(e,P),this.authority=o||d,this.path=(function(B,E){switch(B){case"https":case"http":case"file":E?E[0]!==h&&(E=h+E):E=h}return E})(this.scheme,c||d),this.query=y||d,this.fragment=g||d,(function(B,E){if(!B.scheme&&E)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'.concat(B.authority,'", path: "').concat(B.path,'", query: "').concat(B.query,'", fragment: "').concat(B.fragment,'"}'));if(B.scheme&&!u.test(B.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(B.path){if(B.authority){if(!v.test(B.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(l.test(B.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}})(this,P))}return a.isUri=function(e){return e instanceof a||!!e&&typeof e.authority=="string"&&typeof e.fragment=="string"&&typeof e.path=="string"&&typeof e.query=="string"&&typeof e.scheme=="string"&&typeof e.fsPath=="string"&&typeof e.with=="function"&&typeof e.toString=="function"},Object.defineProperty(a.prototype,"fsPath",{get:function(){return de(this,!1)},enumerable:!1,configurable:!0}),a.prototype.with=function(e){if(!e)return this;var o=e.scheme,c=e.authority,y=e.path,g=e.query,P=e.fragment;return o===void 0?o=this.scheme:o===null&&(o=d),c===void 0?c=this.authority:c===null&&(c=d),y===void 0?y=this.path:y===null&&(y=d),g===void 0?g=this.query:g===null&&(g=d),P===void 0?P=this.fragment:P===null&&(P=d),o===this.scheme&&c===this.authority&&y===this.path&&g===this.query&&P===this.fragment?this:new x(o,c,y,g,P)},a.parse=function(e,o){o===void 0&&(o=!1);var c=S.exec(e);return c?new x(c[2]||d,K(c[4]||d),K(c[5]||d),K(c[7]||d),K(c[9]||d),o):new x(d,d,d,d,d)},a.file=function(e){var o=d;if(p&&(e=e.replace(/\\/g,h)),e[0]===h&&e[1]===h){var c=e.indexOf(h,2);c===-1?(o=e.substring(2),e=h):(o=e.substring(2,c),e=e.substring(c)||h)}return new x("file",o,e,d,d)},a.from=function(e){return new x(e.scheme,e.authority,e.path,e.query,e.fragment)},a.prototype.toString=function(e){return e===void 0&&(e=!1),re(this,e)},a.prototype.toJSON=function(){return this},a.revive=function(e){if(e){if(e instanceof a)return e;var o=new x(e);return o._formatted=e.external,o._fsPath=e._sep===C?e.fsPath:null,o}return e},a})(),C=p?1:void 0,x=(function(a){function e(){var o=a!==null&&a.apply(this,arguments)||this;return o._formatted=null,o._fsPath=null,o}return r(e,a),Object.defineProperty(e.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=de(this,!1)),this._fsPath},enumerable:!1,configurable:!0}),e.prototype.toString=function(o){return o===void 0&&(o=!1),o?re(this,!0):(this._formatted||(this._formatted=re(this,!1)),this._formatted)},e.prototype.toJSON=function(){var o={$mid:1};return this._fsPath&&(o.fsPath=this._fsPath,o._sep=C),this._formatted&&(o.external=this._formatted),this.path&&(o.path=this.path),this.scheme&&(o.scheme=this.scheme),this.authority&&(o.authority=this.authority),this.query&&(o.query=this.query),this.fragment&&(o.fragment=this.fragment),o},e})(f),D=((b={})[58]="%3A",b[47]="%2F",b[63]="%3F",b[35]="%23",b[91]="%5B",b[93]="%5D",b[64]="%40",b[33]="%21",b[36]="%24",b[38]="%26",b[39]="%27",b[40]="%28",b[41]="%29",b[42]="%2A",b[43]="%2B",b[44]="%2C",b[59]="%3B",b[61]="%3D",b[32]="%20",b);function k(a,e){for(var o=void 0,c=-1,y=0;y<a.length;y++){var g=a.charCodeAt(y);if(g>=97&&g<=122||g>=65&&g<=90||g>=48&&g<=57||g===45||g===46||g===95||g===126||e&&g===47)c!==-1&&(o+=encodeURIComponent(a.substring(c,y)),c=-1),o!==void 0&&(o+=a.charAt(y));else{o===void 0&&(o=a.substr(0,y));var P=D[g];P!==void 0?(c!==-1&&(o+=encodeURIComponent(a.substring(c,y)),c=-1),o+=P):c===-1&&(c=y)}}return c!==-1&&(o+=encodeURIComponent(a.substring(c))),o!==void 0?o:a}function Pe(a){for(var e=void 0,o=0;o<a.length;o++){var c=a.charCodeAt(o);c===35||c===63?(e===void 0&&(e=a.substr(0,o)),e+=D[c]):e!==void 0&&(e+=a[o])}return e!==void 0?e:a}function de(a,e){var o;return o=a.authority&&a.path.length>1&&a.scheme==="file"?"//".concat(a.authority).concat(a.path):a.path.charCodeAt(0)===47&&(a.path.charCodeAt(1)>=65&&a.path.charCodeAt(1)<=90||a.path.charCodeAt(1)>=97&&a.path.charCodeAt(1)<=122)&&a.path.charCodeAt(2)===58?e?a.path.substr(1):a.path[1].toLowerCase()+a.path.substr(2):a.path,p&&(o=o.replace(/\//g,"\\")),o}function re(a,e){var o=e?Pe:k,c="",y=a.scheme,g=a.authority,P=a.path,B=a.query,E=a.fragment;if(y&&(c+=y,c+=":"),(g||y==="file")&&(c+=h,c+=h),g){var O=g.indexOf("@");if(O!==-1){var N=g.substr(0,O);g=g.substr(O+1),(O=N.indexOf(":"))===-1?c+=o(N,!1):(c+=o(N.substr(0,O),!1),c+=":",c+=o(N.substr(O+1),!1)),c+="@"}(O=(g=g.toLowerCase()).indexOf(":"))===-1?c+=o(g,!1):(c+=o(g.substr(0,O),!1),c+=g.substr(O))}if(P){if(P.length>=3&&P.charCodeAt(0)===47&&P.charCodeAt(2)===58)(q=P.charCodeAt(1))>=65&&q<=90&&(P="/".concat(String.fromCharCode(q+32),":").concat(P.substr(3)));else if(P.length>=2&&P.charCodeAt(1)===58){var q;(q=P.charCodeAt(0))>=65&&q<=90&&(P="".concat(String.fromCharCode(q+32),":").concat(P.substr(2)))}c+=o(P,!0)}return B&&(c+="?",c+=o(B,!1)),E&&(c+="#",c+=e?E:k(E,!1)),c}function ue(a){try{return decodeURIComponent(a)}catch{return a.length>3?a.substr(0,3)+ue(a.substr(3)):a}}var pe=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function K(a){return a.match(pe)?a.replace(pe,(function(e){return ue(e)})):a}var se,he=t(470),le=function(a,e,o){if(o||arguments.length===2)for(var c,y=0,g=e.length;y<g;y++)!c&&y in e||(c||(c=Array.prototype.slice.call(e,0,y)),c[y]=e[y]);return a.concat(c||Array.prototype.slice.call(e))},j=he.posix||he,J="/";(function(a){a.joinPath=function(e){for(var o=[],c=1;c<arguments.length;c++)o[c-1]=arguments[c];return e.with({path:j.join.apply(j,le([e.path],o,!1))})},a.resolvePath=function(e){for(var o=[],c=1;c<arguments.length;c++)o[c-1]=arguments[c];var y=e.path,g=!1;y[0]!==J&&(y=J+y,g=!0);var P=j.resolve.apply(j,le([y],o,!1));return g&&P[0]===J&&!e.authority&&(P=P.substring(1)),e.with({path:P})},a.dirname=function(e){if(e.path.length===0||e.path===J)return e;var o=j.dirname(e.path);return o.length===1&&o.charCodeAt(0)===46&&(o=""),e.with({path:o})},a.basename=function(e){return j.basename(e.path)},a.extname=function(e){return j.extname(e.path)}})(se||(se={}))})(),me=n})();var{URI:Ie,Utils:fe}=me;function De(s){for(;s.length;){let i=s.pop();i&&i.dispose()}}var L=class{_isDisposed=!1;_disposables=[];dispose(){this._isDisposed||(this._isDisposed=!0,De(this._disposables))}_register(i){return this._isDisposed?i.dispose():this._disposables.push(i),i}get isDisposed(){return this._isDisposed}};async function F(s,i){await R.commands.executeCommand("vscode.openWith",s,"default",i)}var Ue="version https://git-lfs.github.com/spec/v1";async function V(s){if(s.scheme!=="git")return!1;try{let i=await R.workspace.fs.stat(s);if(i.size===0||i.size>1024)return!1;let t=await R.workspace.fs.readFile(s);return new TextDecoder().decode(t).startsWith(Ue)}catch{return!1}}var W=class extends L{constructor(t,n,p,m){super();this._resource=n;this._webviewEditor=p;this._binarySizeStatusBarEntry=m;let w=fe.dirname(n).with({query:"",fragment:""});p.webview.options={enableScripts:!0,enableForms:!1,localResourceRoots:[w,t]},this._register(p.onDidChangeViewState(()=>{this.updateState()})),this._register(p.onDidDispose(()=>{this.previewState=0,this.dispose()}));let b=this._register(R.workspace.createFileSystemWatcher(new R.RelativePattern(n,"*")));this._register(b.onDidChange(r=>{r.toString()===this._resource.toString()&&(this.updateBinarySize(),this.render())})),this._register(b.onDidDelete(r=>{r.toString()===this._resource.toString()&&this._webviewEditor.dispose()}))}_resource;_webviewEditor;_binarySizeStatusBarEntry;previewState=1;_binarySize;dispose(){super.dispose(),this._binarySizeStatusBarEntry.hide(this)}get resource(){return this._resource}updateBinarySize(){R.workspace.fs.stat(this._resource).then(({size:t})=>{this._binarySize=t,this.updateState()})}async render(){if(this.previewState===0)return;let t=await this.getWebviewContents();this.previewState!==0&&(this._webviewEditor.webview.html=t)}updateState(){this.previewState!==0&&(this._webviewEditor.active?(this.previewState=2,this._binarySizeStatusBarEntry.show(this,this._binarySize)):(this._binarySizeStatusBarEntry.hide(this),this.previewState=1))}};function A(s){return s.toString().replace(/"/g,"&quot;")}function G(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID.bind(crypto)();let s=new Uint8Array(16),i=[];for(let p=0;p<256;p++)i.push(p.toString(16).padStart(2,"0"));crypto.getRandomValues(s),s[6]=s[6]&15|64,s[8]=s[8]&63|128;let t=0,n="";return n+=i[s[t++]],n+=i[s[t++]],n+=i[s[t++]],n+=i[s[t++]],n+="-",n+=i[s[t++]],n+=i[s[t++]],n+="-",n+=i[s[t++]],n+=i[s[t++]],n+="-",n+=i[s[t++]],n+=i[s[t++]],n+="-",n+=i[s[t++]],n+=i[s[t++]],n+=i[s[t++]],n+=i[s[t++]],n+=i[s[t++]],n+=i[s[t++]],n}var Y=class{constructor(i,t){this.extensionRoot=i;this.binarySizeStatusBarEntry=t}extensionRoot;binarySizeStatusBarEntry;static viewType="vscode.audioPreview";async openCustomDocument(i){return{uri:i,dispose:()=>{}}}async resolveCustomEditor(i,t){new oe(this.extensionRoot,i.uri,t,this.binarySizeStatusBarEntry)}},oe=class extends W{constructor(t,n,p,m){super(t,n,p,m);this.extensionRoot=t;this._register(p.webview.onDidReceiveMessage(w=>{w.type==="reopen-as-text"&&F(n,p.viewColumn)})),this.updateBinarySize(),this.render(),this.updateState()}extensionRoot;async getWebviewContents(){let t=Date.now().toString(),n=await this.getResourcePath(this._webviewEditor,this._resource,t),p={src:n,isGitLfs:n===null},m=G(),w=this._webviewEditor.webview.cspSource;return`<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- Disable pinch zooming --> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <title>Audio Preview</title> <link rel="stylesheet" href="${A(this.extensionResource("media","audioPreview.css"))}" type="text/css" media="screen" nonce="${m}"> <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: ${w}; media-src ${w}; script-src 'nonce-${m}'; style-src ${w} 'nonce-${m}';"> <meta id="settings" data-settings="${A(JSON.stringify(p))}"> </head> <body class="container loading" data-vscode-context='{ "preventDefaultContextMenuItems": true }'> <div class="loading-indicator"></div> <div class="loading-error"> <p>${$.l10n.t("An error occurred while loading the audio file.")}</p> <a href="#" class="open-file-link">${$.l10n.t("Open file using VS Code's standard text/binary editor?")}</a> </div> <div class="git-lfs-info"> <p>${$.l10n.t("The audio file is stored with Git LFS and is not available for preview.")}</p> <a href="#" class="open-file-link">${$.l10n.t("Open file using VS Code's standard text/binary editor?")}</a> </div> <script src="${A(this.extensionResource("media","audioPreview.js"))}" nonce="${m}"></script> </body> </html>`}async getResourcePath(t,n,p){return await V(n)?null:n.query?t.webview.asWebviewUri(n).toString():t.webview.asWebviewUri(n).with({query:`version=${p}`}).toString()}extensionResource(...t){return this._webviewEditor.webview.asWebviewUri($.Uri.joinPath(this.extensionRoot,...t))}};function ge(s,i){let t=new Y(s.extensionUri,i);return $.window.registerCustomEditorProvider(Y.viewType,t,{supportsMultipleEditorsPerDocument:!0,webviewOptions:{retainContextWhenHidden:!0}})}var I=T(require("vscode"));var we=T(require("vscode"));var M=class extends L{_showOwner;entry;constructor(i,t,n,p){super(),this.entry=this._register(we.window.createStatusBarItem(i,n,p)),this.entry.name=t}showItem(i,t){this._showOwner=i,this.entry.text=t,this.entry.show()}hide(i){i===this._showOwner&&(this.entry.hide(),this._showOwner=void 0)}};var ne=class s{static KB=1024;static MB=s.KB*s.KB;static GB=s.MB*s.KB;static TB=s.GB*s.KB;static formatSize(i){return i<s.KB?I.l10n.t("{0}B",i):i<s.MB?I.l10n.t("{0}KB",(i/s.KB).toFixed(2)):i<s.GB?I.l10n.t("{0}MB",(i/s.MB).toFixed(2)):i<s.TB?I.l10n.t("{0}GB",(i/s.GB).toFixed(2)):I.l10n.t("{0}TB",(i/s.TB).toFixed(2))}},Q=class extends M{constructor(){super("status.imagePreview.binarySize",I.l10n.t("Image Binary Size"),I.StatusBarAlignment.Right,100)}show(i,t){typeof t=="number"?super.showItem(i,ne.formatSize(t)):this.hide(i)}};var _=T(require("vscode"));var ee=T(require("vscode"));var X=class extends M{constructor(){super("status.imagePreview.size",ee.l10n.t("Image Size"),ee.StatusBarAlignment.Right,101)}show(i,t){this.showItem(i,t)}};var z=T(require("vscode"));var ye="_imagePreview.selectZoomLevel",te=class extends M{_onDidChangeScale=this._register(new z.EventEmitter);onDidChangeScale=this._onDidChangeScale.event;constructor(){super("status.imagePreview.zoom",z.l10n.t("Image Zoom"),z.StatusBarAlignment.Right,102),this._register(z.commands.registerCommand(ye,async()=>{let t=[10,5,2,1,.5,.2,"fit"].map(p=>({label:this.zoomLabel(p),scale:p})),n=await z.window.showQuickPick(t,{placeHolder:z.l10n.t("Select zoom level")});n&&this._onDidChangeScale.fire({scale:n.scale})})),this.entry.command=ye}show(i,t){this.showItem(i,this.zoomLabel(t))}zoomLabel(i){return i==="fit"?z.l10n.t("Whole Image"):`${Math.round(i*100)}%`}};var Z=class{constructor(i,t,n,p){this.extensionRoot=i;this.sizeStatusBarEntry=t;this.binarySizeStatusBarEntry=n;this.zoomStatusBarEntry=p}extensionRoot;sizeStatusBarEntry;binarySizeStatusBarEntry;zoomStatusBarEntry;static viewType="imagePreview.previewEditor";_previews=new Set;_activePreview;async openCustomDocument(i){return{uri:i,dispose:()=>{}}}async resolveCustomEditor(i,t){let n=new ae(this.extensionRoot,i.uri,t,this.sizeStatusBarEntry,this.binarySizeStatusBarEntry,this.zoomStatusBarEntry);this._previews.add(n),this.setActivePreview(n),t.onDidDispose(()=>{this._previews.delete(n)}),t.onDidChangeViewState(()=>{t.active?this.setActivePreview(n):this._activePreview===n&&!t.active&&this.setActivePreview(void 0)})}get activePreview(){return this._activePreview}getPreviewFor(i,t){for(let n of this._previews)if(n.resource.toString()===i.toString()&&(!t||n.viewColumn===t))return n}setActivePreview(i){this._activePreview=i}},ae=class extends W{constructor(t,n,p,m,w,b){super(t,n,p,w);this.extensionRoot=t;this.sizeStatusBarEntry=m;this.zoomStatusBarEntry=b;this._register(p.webview.onDidReceiveMessage(r=>{switch(r.type){case"size":{this._imageSize=r.value,this.updateState();break}case"zoom":{this._imageZoom=r.value,this.updateState();break}case"reopen-as-text":{F(n,p.viewColumn);break}}})),this._register(b.onDidChangeScale(r=>{this.previewState===2&&this._webviewEditor.webview.postMessage({type:"setScale",scale:r.scale})})),this._register(p.onDidChangeViewState(()=>{this._webviewEditor.webview.postMessage({type:"setActive",value:this._webviewEditor.active})})),this._register(p.onDidDispose(()=>{this.previewState===2&&(this.sizeStatusBarEntry.hide(this),this.zoomStatusBarEntry.hide(this)),this.previewState=0})),this.updateBinarySize(),this.render(),this.updateState()}extensionRoot;sizeStatusBarEntry;zoomStatusBarEntry;_imageSize;_imageZoom;dispose(){super.dispose(),this.sizeStatusBarEntry.hide(this),this.zoomStatusBarEntry.hide(this)}get viewColumn(){return this._webviewEditor.viewColumn}zoomIn(){this.previewState===2&&this._webviewEditor.webview.postMessage({type:"zoomIn"})}zoomOut(){this.previewState===2&&this._webviewEditor.webview.postMessage({type:"zoomOut"})}copyImage(){this.previewState===2&&(this._webviewEditor.reveal(),this._webviewEditor.webview.postMessage({type:"copyImage"}))}updateState(){super.updateState(),this.previewState!==0&&(this._webviewEditor.active?(this.sizeStatusBarEntry.show(this,this._imageSize||""),this.zoomStatusBarEntry.show(this,this._imageZoom||"fit")):(this.sizeStatusBarEntry.hide(this),this.zoomStatusBarEntry.hide(this)))}async render(){await super.render(),this._webviewEditor.webview.postMessage({type:"setActive",value:this._webviewEditor.active})}async getWebviewContents(){let t=Date.now().toString(),n=await this.getResourcePath(this._webviewEditor,this._resource,t),p={src:n,isGitLfs:n===null},m=G(),w=this._webviewEditor.webview.cspSource;return`<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- Disable pinch zooming --> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <title>Image Preview</title> <link rel="stylesheet" href="${A(this.extensionResource("media","imagePreview.css"))}" type="text/css" media="screen" nonce="${m}"> <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: ${w}; connect-src ${w}; script-src 'nonce-${m}'; style-src ${w} 'nonce-${m}';"> <meta id="image-preview-settings" data-settings="${A(JSON.stringify(p))}"> </head> <body class="container image scale-to-fit loading" data-vscode-context='{ "preventDefaultContextMenuItems": true }'> <div class="loading-indicator"></div> <div class="image-load-error"> <p>${_.l10n.t("An error occurred while loading the image.")}</p> <a href="#" class="open-file-link">${_.l10n.t("Open file using VS Code's standard text/binary editor?")}</a> </div> <div class="git-lfs-info"> <p>${_.l10n.t("The image is stored with Git LFS and is not available for preview.")}</p> <a href="#" class="open-file-link">${_.l10n.t("Open file using VS Code's standard text/binary editor?")}</a> </div> <script src="${A(this.extensionResource("media","imagePreview.js"))}" nonce="${m}"></script> </body> </html>`}async getResourcePath(t,n,p){return await V(n)?null:n.query?t.webview.asWebviewUri(n).toString():t.webview.asWebviewUri(n).with({query:`version=${p}`}).toString()}extensionResource(...t){return this._webviewEditor.webview.asWebviewUri(_.Uri.joinPath(this.extensionRoot,...t))}async reopenAsText(){await _.commands.executeCommand("reopenActiveEditorWith","default"),this._webviewEditor.dispose()}};function be(s,i){let t=[],n=new X;t.push(n);let p=new te;t.push(p);let m=new Z(s.extensionUri,n,i,p);return t.push(_.window.registerCustomEditorProvider(Z.viewType,m,{supportsMultipleEditorsPerDocument:!0})),t.push(_.commands.registerCommand("imagePreview.zoomIn",()=>{m.activePreview?.zoomIn()})),t.push(_.commands.registerCommand("imagePreview.zoomOut",()=>{m.activePreview?.zoomOut()})),t.push(_.commands.registerCommand("imagePreview.copyImage",()=>{m.activePreview?.copyImage()})),t.push(_.commands.registerCommand("imagePreview.reopenAsText",async()=>m.activePreview?.reopenAsText())),t.push(_.commands.registerCommand("imagePreview.reopenAsPreview",async()=>{await _.commands.executeCommand("reopenActiveEditorWith",Z.viewType)})),_.Disposable.from(...t)}var U=T(require("vscode"));var ie=class{constructor(i,t){this.extensionRoot=i;this.binarySizeStatusBarEntry=t}extensionRoot;binarySizeStatusBarEntry;static viewType="vscode.videoPreview";async openCustomDocument(i){return{uri:i,dispose:()=>{}}}async resolveCustomEditor(i,t){new ce(this.extensionRoot,i.uri,t,this.binarySizeStatusBarEntry)}},ce=class extends W{constructor(t,n,p,m){super(t,n,p,m);this.extensionRoot=t;this._register(p.webview.onDidReceiveMessage(w=>{w.type==="reopen-as-text"&&F(n,p.viewColumn)})),this.updateBinarySize(),this.render(),this.updateState()}extensionRoot;async getWebviewContents(){let t=Date.now().toString(),n=U.workspace.getConfiguration("mediaPreview.video"),p=await this.getResourcePath(this._webviewEditor,this._resource,t),m={src:p,isGitLfs:p===null,autoplay:n.get("autoPlay"),loop:n.get("loop")},w=G(),b=this._webviewEditor.webview.cspSource;return`<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- Disable pinch zooming --> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> <title>Video Preview</title> <link rel="stylesheet" href="${A(this.extensionResource("media","videoPreview.css"))}" type="text/css" media="screen" nonce="${w}"> <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: ${b}; media-src ${b}; script-src 'nonce-${w}'; style-src ${b} 'nonce-${w}';"> <meta id="settings" data-settings="${A(JSON.stringify(m))}"> </head> <body class="loading" data-vscode-context='{ "preventDefaultContextMenuItems": true }'> <div class="loading-indicator"></div> <div class="loading-error"> <p>${U.l10n.t("An error occurred while loading the video file.")}</p> <a href="#" class="open-file-link">${U.l10n.t("Open file using VS Code's standard text/binary editor?")}</a> </div> <div class="git-lfs-info"> <p>${U.l10n.t("The video file is stored with Git LFS and is not available for preview.")}</p> <a href="#" class="open-file-link">${U.l10n.t("Open file using VS Code's standard text/binary editor?")}</a> </div> <script src="${A(this.extensionResource("media","videoPreview.js"))}" nonce="${w}"></script> </body> </html>`}async getResourcePath(t,n,p){return await V(n)?null:n.query?t.webview.asWebviewUri(n).toString():t.webview.asWebviewUri(n).with({query:`version=${p}`}).toString()}extensionResource(...t){return this._webviewEditor.webview.asWebviewUri(U.Uri.joinPath(this.extensionRoot,...t))}};function Se(s,i){let t=new ie(s.extensionUri,i);return U.window.registerCustomEditorProvider(ie.viewType,t,{supportsMultipleEditorsPerDocument:!0,webviewOptions:{retainContextWhenHidden:!0}})}function Oe(s){let i=new Q;s.subscriptions.push(i),s.subscriptions.push(be(s,i)),s.subscriptions.push(ge(s,i)),s.subscriptions.push(Se(s,i))}0&&(module.exports={activate}); //# sourceMappingURL=extension.js.map