UNPKG

@jsjoeio/code-server

Version:

Run VS Code on a remote server.

1 lines 30.5 kB
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=42)}([function(e,t){e.exports=require("path")},function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.config=t.loadMessageBundle=void 0;var o=n(0),r=n(1),s=n(9),i=n(10),a=n(10);Object.defineProperty(t,"MessageFormat",{enumerable:!0,get:function(){return a.MessageFormat}}),Object.defineProperty(t,"BundleFormat",{enumerable:!0,get:function(){return a.BundleFormat}});var c,u,l=Object.prototype.toString;function d(e){return"[object Number]"===l.call(e)}function p(e){return"[object String]"===l.call(e)}function f(e){return JSON.parse(r.readFileSync(e,"utf8"))}function g(e){return function(t,n){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];return d(t)?t>=e.length?void console.error("Broken localize call found. Index out of bounds. Stacktrace is\n: "+new Error("").stack):i.format(e[t],o):p(n)?(console.warn("Message "+n+" didn't get externalized correctly."),i.format(n,o)):void console.error("Broken localize call found. Stacktrace is\n: "+new Error("").stack)}}function m(e,t){return c[e]=t,t}function h(e,t){var n,s,i,a=o.join(u.cacheRoot,e.id+"-"+e.hash+".json"),c=!1,l=!1;try{return n=JSON.parse(r.readFileSync(a,{encoding:"utf8",flag:"r"})),s=a,i=new Date,r.utimes(s,i,i,(function(){})),n}catch(e){if("ENOENT"===e.code)l=!0;else{if(!(e instanceof SyntaxError))throw e;console.log("Syntax error parsing message bundle: "+e.message+"."),r.unlink(a,(function(e){e&&console.error("Deleting corrupted bundle "+a+" failed.")})),c=!0}}if(!(n=function(e,t){var n=u.translationsConfig[e.id];if(n){var r=f(n).contents,s=f(o.join(t,"nls.metadata.json")),i=Object.create(null);for(var a in s){var c=s[a],l=r[e.outDir+"/"+a];if(l){for(var d=[],g=0;g<c.keys.length;g++){var m=c.keys[g],h=l[p(m)?m:m.key];void 0===h&&(h=c.messages[g]),d.push(h)}i[a]=d}else i[a]=c.messages}return i}}(e,t))||c)return n;if(l)try{r.writeFileSync(a,JSON.stringify(n),{encoding:"utf8",flag:"wx"})}catch(e){if("EEXIST"===e.code)return n;throw e}return n}function b(e){try{return function(e){var t=f(o.join(e,"nls.metadata.json")),n=Object.create(null);for(var r in t){var s=t[r];n[r]=s.messages}return n}(e)}catch(e){return void console.log("Generating default bundle from meta data failed.",e)}}function v(e,t){var n;if(!0===u.languagePackSupport&&void 0!==u.cacheRoot&&void 0!==u.languagePackId&&void 0!==u.translationsConfigFile&&void 0!==u.translationsConfig)try{n=h(e,t)}catch(e){console.log("Load or create bundle failed ",e)}if(!n){if(u.languagePackSupport)return b(t);var s=function(e){for(var t=u.language;t;){var n=o.join(e,"nls.bundle."+t+".json");if(r.existsSync(n))return n;var s=t.lastIndexOf("-");t=s>0?t.substring(0,s):void 0}if(void 0===t){n=o.join(e,"nls.bundle.json");if(r.existsSync(n))return n}}(t);if(s)try{return f(s)}catch(e){console.log("Loading in the box message bundle failed.",e)}n=b(t)}return n}function w(e){if(!e)return i.localize;var t=o.extname(e);if(t&&(e=e.substr(0,e.length-t.length)),u.messageFormat===i.MessageFormat.both||u.messageFormat===i.MessageFormat.bundle){var n=function(e){for(var t,n=o.dirname(e);t=o.join(n,"nls.metadata.header.json"),!r.existsSync(t);){var s=o.dirname(n);if(s===n){t=void 0;break}n=s}return t}(e);if(n){var s=o.dirname(n),a=c[s];if(void 0===a)try{var l=JSON.parse(r.readFileSync(n,"utf8"));try{var d=v(l,s);a=m(s,d?{header:l,nlsBundle:d}:null)}catch(e){console.error("Failed to load nls bundle",e),a=m(s,null)}}catch(e){console.error("Failed to read header file",e),a=m(s,null)}if(a){var p=e.substr(s.length+1).replace(/\\/g,"/"),h=a.nlsBundle[p];return void 0===h?(console.error("Messages for file "+e+" not found. See console for details."),function(){return"Messages not found."}):g(h)}}}if(u.messageFormat===i.MessageFormat.both||u.messageFormat===i.MessageFormat.file)try{var b=f(function(e){var t;if(u.cacheLanguageResolution&&t)t=t;else{if(i.isPseudo||!u.language)t=".nls.json";else for(var n=u.language;n;){var o=".nls."+n+".json";if(r.existsSync(e+o)){t=o;break}var s=n.lastIndexOf("-");s>0?n=n.substring(0,s):(t=".nls.json",n=null)}u.cacheLanguageResolution&&(t=t)}return e+t}(e));return Array.isArray(b)?g(b):i.isDefined(b.messages)&&i.isDefined(b.keys)?g(b.messages):(console.error("String bundle '"+e+"' uses an unsupported format."),function(){return"File bundle has unsupported format. See console for details"})}catch(e){"ENOENT"!==e.code&&console.error("Failed to load single file bundle",e)}return console.error("Failed to load message bundle for file "+e),function(){return"Failed to load message bundle. See console for details."}}function y(e){return e&&(p(e.locale)&&(u.locale=e.locale.toLowerCase(),u.language=u.locale,c=Object.create(null)),void 0!==e.messageFormat&&(u.messageFormat=e.messageFormat),e.bundleFormat===i.BundleFormat.standalone&&!0===u.languagePackSupport&&(u.languagePackSupport=!1)),i.setPseudo("pseudo"===u.locale),w}!function(){if(u={locale:void 0,language:void 0,languagePackSupport:!1,cacheLanguageResolution:!0,messageFormat:i.MessageFormat.bundle},p(process.env.VSCODE_NLS_CONFIG))try{var e=JSON.parse(process.env.VSCODE_NLS_CONFIG),t=void 0;if(e.availableLanguages){var n=e.availableLanguages["*"];p(n)&&(t=n)}if(p(e.locale)&&(u.locale=e.locale.toLowerCase()),void 0===t?u.language=u.locale:"en"!==t&&(u.language=t),function(e){return!0===e||!1===e}(e._languagePackSupport)&&(u.languagePackSupport=e._languagePackSupport),p(e._cacheRoot)&&(u.cacheRoot=e._cacheRoot),p(e._languagePackId)&&(u.languagePackId=e._languagePackId),p(e._translationsConfigFile)){u.translationsConfigFile=e._translationsConfigFile;try{u.translationsConfig=f(u.translationsConfigFile)}catch(t){if(e._corruptedFile){var s=o.dirname(e._corruptedFile);r.exists(s,(function(t){t&&r.writeFile(e._corruptedFile,"corrupted","utf8",(function(e){console.error(e)}))}))}}}}catch(e){}i.setPseudo("pseudo"===u.locale),c=Object.create(null)}(),t.loadMessageBundle=w,t.config=y,s.default.install(Object.freeze({loadMessageBundle:w,config:y}))},function(e,t){e.exports=require("child_process")},,,function(e,t){e.exports=require("vscode")},function(e,t){e.exports=require("net")},,function(e,t,n){"use strict";var o;function r(){if(void 0===o)throw new Error("No runtime abstraction layer installed");return o}Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.install=function(e){if(void 0===e)throw new Error("No runtime abstraction layer provided");o=e}}(r||(r={})),t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.config=t.loadMessageBundle=t.localize=t.format=t.setPseudo=t.isPseudo=t.isDefined=t.BundleFormat=t.MessageFormat=void 0;var o,r=n(9);function s(e){return void 0!==e}function i(e,n){return t.isPseudo&&(e="["+e.replace(/[aouei]/g,"$&$&")+"]"),0===n.length?e:e.replace(/\{(\d+)\}/g,(function(e,t){var o=t[0],r=n[o],s=e;return"string"==typeof r?s=r:"number"!=typeof r&&"boolean"!=typeof r&&null!=r||(s=String(r)),s}))}!function(e){e.file="file",e.bundle="bundle",e.both="both"}(t.MessageFormat||(t.MessageFormat={})),function(e){e.standalone="standalone",e.languagePack="languagePack"}(t.BundleFormat||(t.BundleFormat={})),function(e){e.is=function(e){var t=e;return t&&s(t.key)&&s(t.comment)}}(o||(o={})),t.isDefined=s,t.isPseudo=!1,t.setPseudo=function(e){t.isPseudo=e},t.format=i,t.localize=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return i(t,n)},t.loadMessageBundle=function(e){return r.default().loadMessageBundle(e)},t.config=function(e){return r.default().config(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(2),r=n(3),s=n(23),i=n(7),a=n(14),c=o.loadMessageBundle(n(0).join(__dirname,"node/extension/protocolDetection.ts"));t.INSPECTOR_PORT_DEFAULT=9229,t.LEGACY_PORT_DEFAULT=5858;function u(e){return new Promise(t=>{r.exec(`lsof -i:${e} -F p`,(e,n)=>{if(e||!n)return void t(-1);const o=n.match(/p(\d+)/);o&&o[1]?t(Number(o[1])):t(-1)})})}t.detectDebugType=function(e,t){switch(e.request){case"attach":return function(e,t){const n=e.address||"127.0.0.1",o=e.port,r=new i.Socket;return new Promise((e,s)=>{r.once("data",n=>{let o,r=void 0;n.toString().indexOf("WebSockets request was expected")>=0?(t.debug("Debugging with inspector protocol because it was detected."),o="inspector"):(r=c(0,null),o="legacy"),e({reason:r,protocol:o})}),r.once("error",e=>{s(e)}),r.connect(o,n),r.on("connect",()=>{r.write('Content-Length: 102\r\n\r\n{"command":"evaluate","arguments":{"expression":"process.pid","global":true},"type":"request","seq":1}')}),setTimeout(()=>{s(new Error("timeout"))},2e3)}).catch(e=>({reason:c(1,null,e.toString()),protocol:"inspector"})).then(e=>((()=>{try{r.write('"Content-Length: 50\r\n\r\n{"command":"disconnect","type":"request","seq":2}"'),r.end()}catch(e){}})(),e.reason&&(s.writeToConsole(e.reason),t.debug(e.reason)),e.protocol))}(e,t).then(e=>"inspector"===e?"node2":"node");case"launch":return Promise.resolve("inspector"===function(e,t){if(e.runtimeExecutable)return t.debug("Debugging with inspector protocol because a runtime executable is set."),"inspector";{let n=process.env;e.env&&(n=s.extendObject(s.extendObject({},process.env),e.env));const o=a.spawnSync(e.useWSL,"node",["--version"],{shell:!0,env:n}),r=o.stdout?o.stdout.toString():void 0;return r?(e.__nodeVersion=r.trim(),function(e){const t=e.match(/v(\d+)\.(\d+)\.(\d+)/);if(t&&4===t.length)return 100*(100*parseInt(t[1])+parseInt(t[2]))+parseInt(t[3]);return-1}(e.__nodeVersion)>=8e4?(t.debug(`Debugging with inspector protocol because Node.js ${e.__nodeVersion} was detected.`),"inspector"):(s.writeToConsole(c(2,null,e.__nodeVersion)),t.debug(`Debugging with legacy protocol because Node.js ${e.__nodeVersion} was detected.`),"legacy")):(t.debug("Debugging with inspector protocol because Node.js version could not be determined."),"inspector")}}(e,t)?"node2":"node")}return Promise.resolve(null)},t.detectProtocolForPid=function(e){return"win32"===process.platform?function(e){return function(e){return new Promise(t=>{r.exec("netstat -a -n -o -p TCP",(n,o)=>{!n&&o||t([]);const r=o.split(/\r?\n/).map(e=>e.trim().split(/\s+/)).filter(t=>t[4]&&t[4]===String(e)).map(e=>{const t=e[1];return parseInt(t.split(":")[1])});t(r)})})}(e).then(e=>e.indexOf(t.INSPECTOR_PORT_DEFAULT)>=0?"inspector":e.indexOf(t.LEGACY_PORT_DEFAULT)>=0?"legacy":null)}(e):function(e){return u(t.INSPECTOR_PORT_DEFAULT).then(n=>n===e?"inspector":u(t.LEGACY_PORT_DEFAULT).then(t=>t===e?"legacy":null))}(e)},t.analyseArguments=function(e){const n={usePort:!1,port:-1};let o=/--(inspect|debug)(-brk)?(=((\[[0-9a-fA-F:]*\]|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z0-9\.]*):)?(\d+))?/.exec(e);return o&&o.length>=2&&(n.usePort=!0,o.length>=6&&o[5]&&(n.address=o[5]),o.length>=7&&o[6]&&(n.port=parseInt(o[6])),n.protocol="debug"===o[1]?"legacy":"inspector"),o=/--(inspect|debug)-port=(\d+)/.exec(e),o&&3===o.length&&(n.port=parseInt(o[2]),n.protocol="debug"===o[1]?"legacy":"inspector"),n.port<0&&(n.port="inspector"===n.protocol?t.INSPECTOR_PORT_DEFAULT:t.LEGACY_PORT_DEFAULT),n}},,,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(0),r=n(1),s=n(3),i="win32"===process.platform,a="x64"===process.arch;function c(){if(!i)return!1;const e=process.env.SystemRoot||"C:\\WINDOWS",t=o.join(e,"Sysnative","bash.exe"),n=o.join(e,"System32","bash.exe"),s=a?n:t;return r.existsSync(s)}function u(e){if(i&&e)return o.isAbsolute(e)?`/mnt/${e.substr(0,1).toLowerCase()}/${e.substr(3).replace(/\\/g,"/")}`:e.replace(/\\/g,"/")}function l(e,t,n,r,s,i){if(e&&c()){const e=process.env.SystemRoot||"C:\\WINDOWS",c=o.join(e,"Sysnative","bash.exe"),l=o.join(e,"System32","bash.exe"),d=a?l:c,p=t?l:d;let f=[r].concat(s||[]).map(e=>(e===i&&(e=e.replace(/\\/g,"/")),e.indexOf(" ")>0?`'${e}'`:e)).join(" ");return{cwd:n,executable:p,args:["-c",f],combined:[p].concat(["-c",f]),localRoot:n,remoteRoot:u(n)}}return{cwd:n,executable:r,args:s||[],combined:[r].concat(s||[])}}t.subsystemLinuxPresent=c,t.createLaunchArg=l,t.spawnSync=function(e,t,n,o){const r=l(e,!1,void 0,t,n);return s.spawnSync(r.executable,r.args,e?void 0:o)}},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(3),s=n(0);class i{constructor(e,t,n,o){this.pid=e,this.ppid=t,this.command=n,this.args=o}}function a(e){function t(e){let t="";return n=>{const o=n.toString().split(/\r?\n/),r=o.slice(0,o.length-1);r[0]=t+r[0],t=o[o.length-1];for(const t of r)e(t)}}return new Promise((n,o)=>{let i;if("win32"===process.platform){const n=/^(.*)\s+([0-9]+)\.[0-9]+[+-][0-9]+\s+([0-9]+)\s+([0-9]+)$/,o=s.join(process.env.WINDIR||"C:\\Windows","System32","wbem","WMIC.exe");i=r.spawn(o,["process","get","CommandLine,CreationDate,ParentProcessId,ProcessId"]),i.stdout.setEncoding("utf8"),i.stdout.on("data",t(t=>{let o=n.exec(t.trim());if(o&&5===o.length){const t=Number(o[4]),n=Number(o[3]),r=Number(o[2]);let s=o[1].trim();if(!isNaN(t)&&!isNaN(n)&&s){let o=s;if('"'===s[0]){const e=s.indexOf('"',1);e>0&&(o=s.substr(1,e-1),s=s.substr(e+2))}else{const e=s.indexOf(" ");e>0?(o=s.substr(0,e),s=s.substr(e+1)):s=""}e(t,n,o,s,r)}}}))}else"darwin"===process.platform?(i=r.spawn("/bin/ps",["-x","-o",`pid,ppid,comm=${"a".repeat(256)},command`]),i.stdout.setEncoding("utf8"),i.stdout.on("data",t(t=>{const n=Number(t.substr(0,5)),o=Number(t.substr(6,5)),r=t.substr(12,256).trim(),s=t.substr(269+r.length);isNaN(n)||isNaN(o)||e(n,o,r,s)}))):(i=r.spawn("/bin/ps",["-ax","-o","pid:6,ppid:6,comm:20,command"]),i.stdout.setEncoding("utf8"),i.stdout.on("data",t(t=>{const n=Number(t.substr(0,6)),o=Number(t.substr(7,6));let r=t.substr(14,20).trim(),s=t.substr(35),i=s.indexOf(r);if(i>=0){for(i+=r.length;i<s.length&&" "!==s[i];)i++;r=s.substr(0,i),s=s.substr(i+1)}isNaN(n)||isNaN(o)||e(n,o,r,s)})));i.on("error",e=>{o(e)}),i.stderr.setEncoding("utf8"),i.stderr.on("data",e=>{e.toString().indexOf("screen size is bogus")>=0||o(new Error(e.toString()))}),i.on("close",(e,t)=>{0===e?n():e>0&&o(new Error("process terminated with exit code: "+e)),t&&o(new Error("process terminated with signal: "+t))}),i.on("exit",(e,t)=>{"number"==typeof e&&(0===e||e>0&&o(new Error("process terminated with exit code: "+e))),t&&o(new Error("process terminated with signal: "+t))})})}t.ProcessTreeNode=i,t.getProcessTree=function(e){return o(this,void 0,void 0,(function*(){const t=new Map;t.set(0,new i(0,0,"???",""));try{yield a((e,n,o,r)=>{e!==n&&t.set(e,new i(e,n,o,r))})}catch(e){return}const n=t.values();for(const e of n){const n=t.get(e.ppid);n&&n!==e&&(n.children||(n.children=[]),n.children.push(e))}return!isNaN(e)&&e>0?t.get(e):t.get(0)}))},t.getProcesses=a},,,,,,,,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(6),r=n(1);t.Logger=class{debug(e){}},t.writeToConsole=function(e){o.debug.activeDebugConsole.appendLine(e)},t.extendObject=function(e,t){for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},t.mkdirP=function(e){return new Promise((t,n)=>{r.mkdir(e,e=>{if(e)return n(e);t()})})}},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(2),s=n(6),i=n(0),a=n(15),c=n(3),u=n(11),l=n(11),d=r.loadMessageBundle(n(0).join(__dirname,"node/extension/processPicker.ts"));function p(e){return o(this,void 0,void 0,(function*(){let t=e.processId.trim();const n=/^(inspector|legacy)?([0-9]+)(inspector|legacy)?([0-9]+)?$/.exec(t);if(!n||5!==n.length)throw new Error(d(1,null,t));if(n[2]&&n[3]&&n[4]){g(Number(n[2])),e.port=Number(n[4]),e.protocol=n[3],delete e.processId}else if(n[1])e.port=Number(n[2]),e.protocol=n[1],delete e.processId;else{const o=Number(n[2]);g(o);const r=yield function(e,t){let n;n=e.port===u.INSPECTOR_PORT_DEFAULT?Promise.resolve("inspector"):e.port===u.LEGACY_PORT_DEFAULT?Promise.resolve("legacy"):e.protocol?Promise.resolve(e.protocol):u.detectProtocolForPid(t);return n.then(e=>"inspector"===e?"node2":"legacy"===e?"node":null)}(e,o);if(!r)throw new Error(d(0,null,t));delete e.processId,e.port="node2"===r?u.INSPECTOR_PORT_DEFAULT:u.LEGACY_PORT_DEFAULT,e.protocol="node2"===r?"inspector":"legacy"}}))}function f(e){return function(e){const t=[],n=new RegExp("^(?:node|iojs)$","i");let o=0;return a.getProcesses((r,s,a,c,u)=>{"win32"===process.platform&&0===a.indexOf("\\??\\")&&(a=a.replace("\\??\\",""));const p=i.basename(a,".exe");let f=-1,g="",m=!0;if(e){const e=l.analyseArguments(c);m=e.usePort,g=e.protocol,f=e.port}let h="",b="";m?(h=d("inspector"===g?4:5,null,r,f),b=`${g}${f}`):g&&f>0?(h=d(6,null,r,f,"SIGUSR1"),b=`${r}${g}${f}`):n.test(p)&&(h=d(7,null,r,"SIGUSR1"),b=r.toString()),h&&b&&t.push({label:p,description:c,detail:h,pidOrPort:b,sortKey:u||o++})}).then(()=>t.sort((e,t)=>t.sortKey-e.sortKey))}(e).then(e=>{let t={placeHolder:d(2,null),matchOnDescription:!0,matchOnDetail:!0};return s.window.showQuickPick(e,t).then(e=>e?e.pidOrPort:null)}).catch(e=>s.window.showErrorMessage(d(3,null,e.message),{modal:!0}).then(e=>null))}function g(e){try{if("win32"===process.platform){const t=`node -e process._debugProcess(${e})`;c.execSync(t)}else process.kill(e,"SIGUSR1")}catch(t){throw new Error(d(8,null,e,t))}}t.attachProcess=function(){return o(this,void 0,void 0,(function*(){const e=yield f(!0);if(e){const t={type:"node",request:"attach",name:"process",processId:e};return yield p(t),s.debug.startDebugging(void 0,t)}}))},t.resolveProcessId=p,t.pickProcess=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(6),r=n(2),s=n(26),i=n(15),a=n(11),c=r.loadMessageBundle(n(0).join(__dirname,"node/extension/cluster.ts"));class u{constructor(e,t){this._folder=e,this._config=t,this._subProcesses=new Set,this._childCounter=1}static prepareAutoAttachChildProcesses(e,t){this.clusters.set(t.name,new u(e,t))}static startSession(e){const t=this.clusters.get(e.name);t&&t.startWatching(e)}static stopSession(e){const t=this.clusters.get(e.name);t&&(t.stopWatching(),this.clusters.delete(e.name))}startWatching(e){s.getPidFromSession(e).then(t=>{this._poller=function(e,t,n){let r=!1;return function t(){(function(e,t){return i.getProcessTree(e).then(n=>{n&&function n(o){if(o.pid!==e){let{protocol:e}=a.analyseArguments(o.args);e&&t(o.pid,o.command,o.args)}for(const e of o.children||[])n(e)}(n)})})(e,n).then(e=>{setTimeout(e=>{r||t()},1e3)})}(),new o.Disposable(()=>r=!0)}(t,0,(t,n,o)=>{if(!this._subProcesses.has(t)){this._subProcesses.add(t);const n=c(0,null,this._childCounter++);s.attachToProcess(this._folder,n,t,o,this._config,e)}})})}stopWatching(){this._poller&&(this._poller.dispose(),this._poller=void 0)}}t.Cluster=u,u.clusters=new Map},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(6),r=n(2),s=n(0),i=n(11),a=n(15),c=r.loadMessageBundle(n(0).join(__dirname,"node/extension/autoAttach.ts")),u=[];let l;function d(e){return new Promise((t,n)=>{setTimeout(n=>{const o=setTimeout(e=>{t(NaN)},100);e?e.customRequest("evaluate",{expression:"process.pid"}).then(e=>{clearTimeout(o),t(parseInt(e.result))},e=>{clearTimeout(o),t(NaN)}):(clearTimeout(o),t(NaN))},"node2"===e.type?500:100)})}function p(e,t,n,r,s,a){(function(e){return Promise.all(u).then(t=>t.indexOf(e)>=0)})(n).then(c=>{if(c);else{u.push(Promise.resolve(n));const c={type:"node",request:"attach",name:t,stopOnEntry:!1,__autoAttach:!0};s&&("number"==typeof s.timeout&&(c.timeout=s.timeout),"boolean"==typeof s.sourceMaps&&(c.sourceMaps=s.sourceMaps),s.outFiles&&(c.outFiles=s.outFiles),s.sourceMapPathOverrides&&(c.sourceMapPathOverrides=s.sourceMapPathOverrides),"boolean"==typeof s.smartStep&&(c.smartStep=s.smartStep),s.skipFiles&&(c.skipFiles=s.skipFiles),"boolean"==typeof s.showAsyncStacks&&(c.showAsyncStacks=s.showAsyncStacks),"boolean"!=typeof s.trace&&"string"!=typeof s.trace||(c.trace=s.trace),"boolean"==typeof s.stopOnEntry&&(c.stopOnEntry=s.stopOnEntry));let{usePort:l,protocol:d,port:p}=i.analyseArguments(r);c.processId=l?`${d}${p}`:d&&p>0?`${n}${d}${p}`:n.toString(),o.debug.startDebugging(e,c,a)}})}t.getPidFromSession=d,t.initializeAutoAttach=function(e){e.subscriptions.push(o.debug.onDidStartDebugSession(e=>{"node"!==e.type&&"node2"!==e.type||u.push(d(e))})),e.subscriptions.push(o.commands.registerCommand("extension.node-debug.startAutoAttach",e=>{"number"==typeof e&&(l=function(e,t,n){let r=!1;function s(){(function(e,t,n){return a.getProcessTree(e).then(e=>{if(e){const r=o.window.terminals;r.length>0&&Promise.all(r.map(e=>e.processId)).then(o=>{!function e(t,o,r){r.indexOf(t.pid)>=0&&(o=!0);let{protocol:s}=i.analyseArguments(t.args);o&&s&&n(t.pid,t.command,t.args);for(const n of t.children||[])e(n,o,r)}(e,!t,o)})}})})(e,t,n).then(e=>{setTimeout(e=>{r||s()},1e3)})}return s(),new o.Disposable(()=>r=!0)}(e,!0,(e,t,n)=>{if("node"===s.basename(t,".exe")){p(void 0,c(0,null,e),e,n)}}))})),e.subscriptions.push(o.commands.registerCommand("extension.node-debug.stopAutoAttach",()=>{l&&(l.dispose(),l=void 0)}))},t.attachToProcess=p},,,,,,,,,,,,,,,,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=n(6),r=n(43),s=n(24),i=n(25),a=n(26);function c(e){let t=e;if(!t){const e=o.window.activeTextEditor;t=e&&e.document.fileName}if(t&&o.debug.activeDebugSession){const e="string"==typeof t?{resource:t}:{sourceReference:t};o.debug.activeDebugSession.customRequest("toggleSkipFileStatus",e)}}t.activate=function(e){e.subscriptions.push(o.debug.registerDebugConfigurationProvider("node",new r.NodeConfigurationProvider(e))),a.initializeAutoAttach(e),e.subscriptions.push(o.commands.registerCommand("extension.node-debug.toggleSkippingFile",c)),e.subscriptions.push(o.commands.registerCommand("extension.pickNodeProcess",s.pickProcess)),e.subscriptions.push(o.commands.registerCommand("extension.node-debug.attachNodeProcess",s.attachProcess)),e.subscriptions.push(o.debug.onDidStartDebugSession(e=>i.Cluster.startSession(e))),e.subscriptions.push(o.debug.onDidTerminateDebugSession(e=>i.Cluster.stopSession(e)))},t.deactivate=function(){}},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const r=n(2),s=n(6),i=n(0),a=n(1),c=n(23),u=n(11),l=n(24),d=n(25),p=["*.js","*.es6","*.jsx","*.mjs"],f=r.loadMessageBundle(n(0).join(__dirname,"node/extension/configurationProvider.ts"));function g(e,t,n){const o={type:"node",request:"launch",name:f(7,null),skipFiles:["<node_internals>/**"]};n&&n.noDebug&&(o.noDebug=!0);const r=m(e,"package.json");if(r&&"mern-starter"===r.name)t&&c.writeToConsole(f(8,null,"Mern Starter")),function(e){e.protocol="inspector",e.runtimeExecutable="nodemon",e.program="${workspaceFolder}/index.js",e.restart=!0,e.env={BABEL_DISABLE_CACHE:"1",NODE_ENV:"development"},e.console="integratedTerminal",e.internalConsoleOptions="neverOpen"}(o);else{let n,u=!1;if(r&&(n=function(e,t,n){let o;try{if(t.main?o=t.main:t.scripts&&"string"==typeof t.scripts.start&&(o=t.scripts.start.split(" ").pop()),o){let t;if(i.isAbsolute(o)?t=o:(t=e?i.join(e.uri.fsPath,o):void 0,o=i.join("${workspaceFolder}",o)),n&&t&&!a.existsSync(t)&&!a.existsSync(t+".js"))return}}catch(e){}return o}(e,r,t),n&&t&&c.writeToConsole(f(9,null))),!n){const t=s.window.activeTextEditor;if(t){const o=t.document.languageId;if("javascript"===o||h(o)){const o=s.workspace.getWorkspaceFolder(t.document.uri);o&&o===e&&(n=i.relative(o.uri.fsPath||"/",t.document.uri.fsPath||"/"),n&&!i.isAbsolute(n)&&(n=i.join("${workspaceFolder}",n)))}u=h(o)}}if(n||(n="${file}"),n&&(o.program=n),u||s.workspace.textDocuments.some(e=>h(e.languageId))){t&&c.writeToConsole(f(10,null));let n="";const r=m(e,"tsconfig.json");if(r&&r.compilerOptions&&r.compilerOptions.outDir){const e=r.compilerOptions.outDir;i.isAbsolute(e)||(n=e,0===n.indexOf("./")&&(n=n.substr(2)),"/"!==n[n.length-1]&&(n+="/")),o.preLaunchTask="tsc: build - tsconfig.json"}o.outFiles=["${workspaceFolder}/"+n+"**/*.js"]}}return o}function m(e,t){if(e)try{const n=i.join(e.uri.fsPath,t),o=a.readFileSync(n,"utf8");return JSON.parse(o)}catch(e){}}function h(e){return"typescript"===e||"coffeescript"===e}function b(){var e;return null==(e=function(e){var t,n,o;const r=s.workspace.getConfiguration().inspect(e);return null!==(n=null===(t=r)||void 0===t?void 0:t.workspaceValue)&&void 0!==n?n:null===(o=r)||void 0===o?void 0:o.globalValue}("debug.javascript.usePreview"))||e}t.NodeConfigurationProvider=class{constructor(e){this._extensionContext=e,this._logger=new c.Logger}provideDebugConfigurations(e,t){return[g(e,!1)]}resolveDebugConfiguration(e,t,n){return this.resolveConfigAsync(e,t).catch(e=>s.window.showErrorMessage(e.message,{modal:!0}).then(e=>{}))}resolveConfigAsync(e,t,n){return o(this,void 0,void 0,(function*(){if(!(t.type||t.request||t.name||(t=g(e,!0,t)).program))throw new Error(f(0,null));if(t.cwd||(e&&(t.cwd=e.uri.fsPath),!t.cwd&&s.workspace.workspaceFolders&&s.workspace.workspaceFolders.length>0&&(t.cwd=s.workspace.workspaceFolders[0].uri.fsPath),t.cwd||"${file}"!==t.program||(t.cwd="${fileDirname}"),!t.cwd&&t.program&&i.isAbsolute(t.program)&&(t.cwd=i.dirname(t.program)),!t.cwd&&e&&(t.cwd="${workspaceFolder}")),t.remoteRoot&&!t.localRoot&&(t.localRoot="${workspaceFolder}"),void 0!==t.useWSL&&this.warnAboutUseWSL(),"win32"!==process.platform&&t.useWSL&&(this._logger.debug("useWSL attribute ignored on non-Windows OS."),delete t.useWSL),"launch"===t.request&&"string"==typeof t.runtimeVersion&&"default"!==t.runtimeVersion&&(yield this.nvmSupport(t)),t.autoAttachChildProcesses&&(d.Cluster.prepareAutoAttachChildProcesses(e,t),t.console||(t.console="integratedTerminal")),"integratedTerminal"!==t.console||t.internalConsoleOptions||(t.internalConsoleOptions="neverOpen"),t.trace&&!t.logFilePath){const e="node"===t.type?"debugadapter-legacy.txt":"debugadapter.txt";if(this._extensionContext.logPath){try{yield c.mkdirP(this._extensionContext.logPath)}catch(e){}t.logFilePath=i.join(this._extensionContext.logPath,e)}}return t.__debuggablePatterns=this.getJavaScriptPatterns(),b()&&(t.__workspaceFolder=e?"${workspaceFolder}":t.cwd),t}))}resolveDebugConfigurationWithSubstitutedVariables(e,t,n){return this.resolveConfigWithSubstitutedVariablesAsync(e,t).catch(e=>s.window.showErrorMessage(e.message,{modal:!0}).then(e=>{}))}resolveConfigWithSubstitutedVariablesAsync(e,t){return o(this,void 0,void 0,(function*(){"attach"===t.request&&"string"==typeof t.processId&&(yield l.resolveProcessId(t));const e=yield function(e,t){return o(this,void 0,void 0,(function*(){return b()?"pwa-node":"legacy"===e.protocol?"node":"inspector"===e.protocol?"node2":u.detectDebugType(e,t)}))}(t,this._logger);return e&&(t.type=e),t}))}getJavaScriptPatterns(){const e=s.workspace.getConfiguration("files.associations"),t=s.extensions.getExtension("ms-vscode.node-debug");if(!t)throw new Error("Expected to be able to load extension data");const n=t.packageJSON.contributes.breakpoints.map(e=>e.language);return Object.keys(e).filter(t=>-1!==n.indexOf(e[t])).concat(p)}warnAboutUseWSL(){s.workspace.getConfiguration("debug.node").get("showUseWslIsDeprecatedWarning",!0)&&s.window.showWarningMessage(f(1,null,"https://go.microsoft.com/fwlink/?linkid=2097212"),{title:f(2,null),id:1}).then(e=>{if(e)switch(e.id){case 1:s.workspace.getConfiguration("debug.node").update("showUseWslIsDeprecatedWarning",!1,s.ConfigurationTarget.Global)}})}nvmSupport(e){return o(this,void 0,void 0,(function*(){let t=void 0,n=void 0,o=process.env.NVS_HOME;if(!o){const e="win32"===process.platform?i.join(process.env.LOCALAPPDATA||"","nvs"):i.join(process.env.HOME||"",".nvs");a.existsSync(e)&&(o=e)}const{nvsFormat:r,remoteName:s,semanticVersion:c,arch:u}=function(e){const t=/^(([\w-]+)\/)?(v?(\d+(\.\d+(\.\d+)?)?))(\/((x86)|(32)|((x)?64)|(arm\w*)|(ppc\w*)))?$/i.exec(e);if(!t)throw new Error("Invalid version string: "+e);const n=!(!t[2]&&!t[8]),o=t[2]||"node",r=t[4]||"",s=function(e){switch(e){case"32":case"x86":case"ia32":return"x86";case"64":case"x64":case"amd64":return"x64";case"arm":const t=process.config.variables.arm_version;return t?"armv"+t+"l":"arm";default:return e}}(t[8]||process.arch);return{nvsFormat:n,remoteName:o,semanticVersion:r,arch:s}}(e.runtimeVersion);if(r||o){if(!o)throw new Error(f(3,null));t=i.join(o,s,c,u),"win32"!==process.platform&&(t=i.join(t,"bin")),n="nvs"}if(!t)if("win32"===process.platform){const o=process.env.NVM_HOME;if(!o)throw new Error(f(4,null));t=i.join(o,"v"+e.runtimeVersion),n="nvm-windows"}else{let o=process.env.NVM_DIR;if(!o){const e=i.join(process.env.HOME||"",".nvm");a.existsSync(e)&&(o=e)}if(!o)throw new Error(f(5,null));t=i.join(o,"versions","node","v"+e.runtimeVersion,"bin"),n="nvm"}if(!a.existsSync(t))throw new Error(f(6,null,e.runtimeVersion,n));e.env||(e.env={}),"win32"===process.platform?e.env.Path=`${t};${process.env.Path}`:e.env.PATH=`${t}:${process.env.PATH}`}))}}}]);