UNPKG

cloudstudio

Version:

Run VS Code on a remote server.

1 lines 8.56 kB
(()=>{var e={857:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shaHashFile=t.hashFile=t.shaHash=t.hash=void 0;const s=r(749),a=r(147),i=r(576),n=r(113),c=Buffer.alloc(20);t.hash=e=>{const t=new s.Hasher;return t.update(f(e)),t.digest(c),t.free(),c.toString("hex")},t.shaHash=e=>{const t=(0,n.createHash)("sha256");return t.update(h(e)),t.digest("hex")},t.hashFile=async(e,t=4096)=>{t%2==1&&t++;const r=Buffer.alloc(t),n=new s.Hasher;let o;try{o=await a.promises.open(e,"r");let t=await o.read(r,0,r.length,null);const s=r.slice(0,t.bytesRead);if(u(s))for(n.update(s.slice(2));t.bytesRead===r.length;)t=await o.read(r,0,r.length,null),n.update(r.slice(0,t.bytesRead));else if(d(s))for(n.update(s.slice(2).swap16());t.bytesRead===r.length;)t=await o.read(r,0,r.length,null),n.update(r.slice(0,t.bytesRead).swap16());else if(l(s)){const e=new i.StringDecoder("utf8");for(n.update(Buffer.from(e.write(s.slice(3)),"utf16le"));t.bytesRead===r.length;)t=await o.read(r,0,r.length,null),n.update(Buffer.from(e.write(r.slice(0,t.bytesRead)),"utf16le"))}else{const e=new i.StringDecoder("utf8");for(n.update(Buffer.from(e.write(s),"utf16le"));t.bytesRead===r.length;)t=await o.read(r,0,r.length,null),n.update(Buffer.from(e.write(r.slice(0,t.bytesRead)),"utf16le"))}return n.digest(c),c.toString("hex")}finally{n.free(),void 0!==o&&await o.close()}};const o={stream:!0};t.shaHashFile=async(e,t=4096)=>{t%2==1&&t++;const r=Buffer.alloc(t),s=(0,n.createHash)("sha256");let i;try{i=await a.promises.open(e,"r");let t=await i.read(r,0,r.length,null);const n=r.slice(0,t.bytesRead);if(u(n)){const e=new TextDecoder("utf-16le");for(s.update(e.decode(n.slice(2),o));t.bytesRead>0;)t=await i.read(r,0,r.length,null),s.update(e.decode(r.slice(0,t.bytesRead),o))}else if(d(n)){const e=new TextDecoder("utf-16be");for(s.update(e.decode(n.slice(2),o));t.bytesRead>0;)t=await i.read(r,0,r.length,null),s.update(e.decode(r.slice(0,t.bytesRead),o))}else if(l(n))for(s.update(n.slice(3));t.bytesRead>0;)t=await i.read(r,0,r.length,null),s.update(r.slice(0,t.bytesRead));else for(s.update(n);t.bytesRead>0;)t=await i.read(r,0,r.length,null),s.update(r.slice(0,t.bytesRead));return s.digest("hex")}finally{await(i?.close())}};const l=e=>e.length>=3&&239===e[0]&&187===e[1]&&191===e[2],u=e=>e.length>=2&&255===e[0]&&254===e[1],d=e=>e.length>=2&&254===e[0]&&255===e[1],f=e=>l(e)?w(e.slice(3)):u(e)?e.slice(2):d(e)?e.slice(2).swap16():w(e),h=e=>l(e)?e.slice(3):u(e)?(new TextEncoder).encode(new TextDecoder("utf-16le").decode(e.slice(2))):d(e)?(new TextEncoder).encode(new TextDecoder("utf-16be").decode(e.slice(2))):e,w=e=>Buffer.from(e.toString("utf8"),"utf16le")},749:(e,t,r)=>{let s,a={};a.__wbindgen_placeholder__=e.exports;const{TextDecoder:i}=r(837);let n=new i("utf-8",{ignoreBOM:!0,fatal:!0});n.decode();let c=null;function o(){return null!==c&&c.buffer===s.memory.buffer||(c=new Uint8Array(s.memory.buffer)),c}let l=0;function u(e,t){const r=t(1*e.length);return o().set(e,r/1),l=e.length,r}class d{static __wrap(e){const t=Object.create(d.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();s.__wbg_hasher_free(e)}constructor(){var e=s.hasher_new();return d.__wrap(e)}update(e){var t=u(e,s.__wbindgen_malloc),r=l;s.hasher_update(this.ptr,t,r)}digest(e){try{var t=u(e,s.__wbindgen_malloc),r=l;s.hasher_digest(this.ptr,t,r)}finally{e.set(o().subarray(t/1,t/1+r)),s.__wbindgen_free(t,1*r)}}}e.exports.Hasher=d,e.exports.__wbindgen_throw=function(e,t){throw new Error((r=e,s=t,n.decode(o().subarray(r,r+s))));var r,s};const f=r(17).join(__dirname,"chromehash_bg.wasm"),h=r(147).readFileSync(f),w=new WebAssembly.Module(h),p=new WebAssembly.Instance(w,a);s=p.exports,e.exports.__wasm=s},379:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,a)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.LocalAndRemoteFsUtils=t.RemoteFsThroughDapUtils=t.LocalFsUtils=t.IFsUtils=t.readFileRaw=t.writeFile=t.readfile=t.readdir=t.stat=t.moveFile=t.existsWithoutDeref=t.existsInjected=t.copyFile=t.canAccess=t.fsModule=void 0;const n=i(r(147)),c=i(r(837));async function o({access:e},t){if(!t)return!1;try{return await e(t),!0}catch(e){return!1}}t.fsModule=n,t.canAccess=o,t.copyFile=async function(e,t,r){try{await e.copyFile(t,r)}catch(s){try{if(!await o(e,r))throw s;await e.unlink(r),await e.copyFile(t,r)}catch(e){throw s}}},t.existsInjected=async function({stat:e},t){if(t)try{return await e(t)}catch(e){return}},t.existsWithoutDeref=async function({lstat:e},t){if(t)try{return await e(t)}catch(e){return}},t.moveFile=async function({copyFile:e,rename:t,unlink:r},s,a){try{await t(s,a)}catch(t){await e(s,a),await r(s)}},t.stat=function(e){return new Promise((t=>{n.stat(e,((e,r)=>t(e?void 0:r)))}))},t.readdir=function(e){return new Promise((t=>{n.readdir(e,"utf8",(async(e,r)=>{t(e?[]:r)}))}))},t.readfile=function(e){return new Promise((t=>{n.readFile(e,"utf8",(async(e,r)=>{t(e?"":r)}))}))},t.writeFile=c.promisify(n.writeFile),t.readFileRaw=function(e){return n.promises.readFile(e).catch((()=>Buffer.alloc(0)))},t.IFsUtils=Symbol("FsUtils");class l{constructor(e){this.fs=e}realPath(e){return this.fs.realpath(e)}async exists(e){try{return await this.fs.access(e,n.constants.F_OK),!0}catch(e){return!1}}readFile(e){return this.fs.readFile(e)}}t.LocalFsUtils=l;class u{constructor(e){this.dap=e}async realPath(){throw new Error("not implemented")}async exists(e){try{const{doesExists:t}=await this.dap.remoteFileExistsRequest({localFilePath:e});return t}catch(e){return!1}}readFile(){throw new Error("not implemented")}}t.RemoteFsThroughDapUtils=u,t.LocalAndRemoteFsUtils=class{constructor(e,t,r){this.remoteFilePrefix=e,this.localFsUtils=t,this.remoteFsUtils=r}static create(e,t,r){const s=new l(t);return void 0!==e?new this(e.toLowerCase(),s,new u(r)):s}async exists(e){return this.selectFs(e).exists(e)}async readFile(e){return this.selectFs(e).readFile(e)}async realPath(e){return this.selectFs(e).realPath(e)}selectFs(e){return e.toLowerCase().startsWith(this.remoteFilePrefix)?this.remoteFsUtils:this.localFsUtils}}},113:e=>{"use strict";e.exports=require("crypto")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},576:e=>{"use strict";e.exports=require("string_decoder")},837:e=>{"use strict";e.exports=require("util")},267:e=>{"use strict";e.exports=require("worker_threads")}},t={};function r(s){var a=t[s];if(void 0!==a)return a.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,r),i.exports}(()=>{"use strict";const e=r(857),t=r(267),s=r(379),a=Buffer.from("(function (exports, require, module, __filename, __dirname) { "),i=Buffer.from("\n});"),n=Buffer.from("(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { "),c=Buffer.from("\n}.call(this, exports, require, module, __filename, __dirname); });"),o=Buffer.from("#!"),l=Buffer.from("\r")[0],u=Buffer.from("\n")[0],d=(t,r,s)=>{const d=64===r.length?e.shaHash:e.hash;if(d(t)===r)return!0;if(s){if(f=o,t.slice(0,f.length).equals(f)){let e=t.indexOf(u);return t[e-1]===l&&e--,d(t.slice(e))===r}if(d(Buffer.concat([a,t,i]))===r)return!0}var f;return d(Buffer.concat([n,t,c]))===r},f=e=>e instanceof Buffer?e:Buffer.from(e,"utf-8");var h;t.parentPort&&(h=t.parentPort).on("message",(t=>{(async function(t){switch(t.type){case 0:try{const r=await(0,s.readFileRaw)(t.file);return{id:t.id,hash:0===t.mode?(0,e.hash)(r):(0,e.shaHash)(r)}}catch(e){return{id:t.id}}case 1:try{return{id:t.id,hash:(0,e.hash)(f(t.data))}}catch(e){return{id:t.id}}case 2:try{const e=await(0,s.readFileRaw)(t.file);return{id:t.id,matches:d(e,t.expected,t.checkNode)}}catch(e){return{id:t.id,matches:!1}}case 3:try{return{id:t.id,matches:d(f(t.data),t.expected,t.checkNode)}}catch(e){return{id:t.id,matches:!1}}}})(t).then((e=>h.postMessage(e)))}))})()})();