UNPKG

code-server

Version:

Run VS Code on a remote server.

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