Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@typescript/vfs

Package Overview
Dependencies
Maintainers
8
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typescript/vfs - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

118

dist/vfs.cjs.development.js

@@ -6,6 +6,5 @@ 'use strict';

function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -17,6 +16,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);

@@ -26,7 +23,5 @@ }

var hasLocalStorage = false;
try {
hasLocalStorage = typeof localStorage !== "undefined";
} catch (error) {}
var hasProcess = typeof process !== "undefined";

@@ -47,3 +42,2 @@ var shouldDebug = hasLocalStorage && /*#__PURE__*/localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;

*/
function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions, customTransformers) {

@@ -53,12 +47,8 @@ if (compilerOptions === void 0) {

}
var mergedCompilerOpts = _extends({}, defaultCompilerOptions(ts), compilerOptions);
var _createVirtualLanguag = createVirtualLanguageServiceHost(sys, rootFiles, mergedCompilerOpts, ts, customTransformers),
languageServiceHost = _createVirtualLanguag.languageServiceHost,
_updateFile = _createVirtualLanguag.updateFile;
languageServiceHost = _createVirtualLanguag.languageServiceHost,
_updateFile = _createVirtualLanguag.updateFile;
var languageService = ts.createLanguageService(languageServiceHost);
var diagnostics = languageService.getCompilerOptionsDiagnostics();
if (diagnostics.length) {

@@ -68,3 +58,2 @@ var compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts);

}
return {

@@ -77,3 +66,2 @@ // @ts-ignore

var _languageService$getP;
return (_languageService$getP = languageService.getProgram()) == null ? void 0 : _languageService$getP.getSourceFile(fileName);

@@ -86,9 +74,7 @@ },

var prevSourceFile = languageService.getProgram().getSourceFile(fileName);
if (!prevSourceFile) {
throw new Error("Did not find a source file for " + fileName);
}
var prevFullContents = prevSourceFile.text; // TODO: Validate if the default text span has a fencepost error?
var prevFullContents = prevSourceFile.text;
// TODO: Validate if the default text span has a fencepost error?
var prevTextSpan = optPrevTextSpan != null ? optPrevTextSpan : ts.createTextSpan(0, prevFullContents.length);

@@ -100,9 +86,8 @@ var newText = prevFullContents.slice(0, prevTextSpan.start) + content + prevFullContents.slice(prevTextSpan.start + prevTextSpan.length);

});
_updateFile(newSourceFile);
}
};
} // TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json
}
// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json
// and then using that to generate the list of files from the server, but it is not included in the npm package
/**

@@ -116,9 +101,8 @@ * Grab the list of lib files for a particular target, will return a bit more than necessary (by including

*/
var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
var target = compilerOptions.target || ts.ScriptTarget.ES5;
var lib = compilerOptions.lib || []; // Note that this will include files which can't be found for particular versions of TS
var lib = compilerOptions.lib || [];
// Note that this will include files which can't be found for particular versions of TS
// TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011
// or similar is merged.
var files = ["lib.d.ts", "lib.decorators.d.ts", "lib.decorators.legacy.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.d.ts", "lib.webworker.iterable.d.ts", "lib.scripthost.d.ts", "lib.es5.d.ts", "lib.es6.d.ts", "lib.es2015.collection.d.ts", "lib.es2015.core.d.ts", "lib.es2015.d.ts", "lib.es2015.generator.d.ts", "lib.es2015.iterable.d.ts", "lib.es2015.promise.d.ts", "lib.es2015.proxy.d.ts", "lib.es2015.reflect.d.ts", "lib.es2015.symbol.d.ts", "lib.es2015.symbol.wellknown.d.ts", "lib.es2016.array.include.d.ts", "lib.es2016.d.ts", "lib.es2016.full.d.ts", "lib.es2017.d.ts", "lib.es2017.date.d.ts", "lib.es2017.full.d.ts", "lib.es2017.intl.d.ts", "lib.es2017.object.d.ts", "lib.es2017.sharedmemory.d.ts", "lib.es2017.string.d.ts", "lib.es2017.typedarrays.d.ts", "lib.es2018.asyncgenerator.d.ts", "lib.es2018.asynciterable.d.ts", "lib.es2018.d.ts", "lib.es2018.full.d.ts", "lib.es2018.intl.d.ts", "lib.es2018.promise.d.ts", "lib.es2018.regexp.d.ts", "lib.es2019.array.d.ts", "lib.es2019.d.ts", "lib.es2019.full.d.ts", "lib.es2019.intl.d.ts", "lib.es2019.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.d.ts", "lib.es2020.date.d.ts", "lib.es2020.full.d.ts", "lib.es2020.intl.d.ts", "lib.es2020.number.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.intl.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.es2022.array.d.ts", "lib.es2022.d.ts", "lib.es2022.error.d.ts", "lib.es2022.full.d.ts", "lib.es2022.intl.d.ts", "lib.es2022.object.d.ts", "lib.es2022.regexp.d.ts", "lib.es2022.sharedmemory.d.ts", "lib.es2022.string.d.ts", "lib.es2023.array.d.ts", "lib.es2023.collection.d.ts", "lib.es2023.d.ts", "lib.es2023.full.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.d.ts", "lib.esnext.decorators.d.ts", "lib.esnext.disposable.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.string.d.ts", "lib.esnext.symbol.d.ts", "lib.esnext.weakref.d.ts"];

@@ -130,3 +114,2 @@ var targetToCut = ts.ScriptTarget[target];

var targetCutIndex = files.indexOf(matches.pop());
var getMax = function getMax(array) {

@@ -136,5 +119,4 @@ return array && array.length ? array.reduce(function (max, current) {

}) : undefined;
}; // Find the index for everything in
};
// Find the index for everything in
var indexesForCutting = lib.map(function (lib) {

@@ -159,7 +141,5 @@ var matches = files.filter(function (f) {

*/
var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_compilerOptions, _ts, tsLibDirectory) {
var path = requirePath();
var fs = requireFS();
var getLib = function getLib(name) {

@@ -169,3 +149,2 @@ var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));

};
var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve("typescript")));

@@ -184,7 +163,5 @@ var knownLibFiles = libFiles.filter(function (f) {

*/
var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
var path = requirePath();
var fs = requireFS();
var walk = function walk(dir) {

@@ -196,3 +173,2 @@ var results = [];

var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {

@@ -208,3 +184,2 @@ /* Recurse into a subdirectory */

};
var allFiles = walk(workingDir);

@@ -215,3 +190,2 @@ allFiles.forEach(function (lib) {

var validExtensions = [".ts", ".tsx"];
if (validExtensions.includes(path.extname(fsPath))) {

@@ -223,3 +197,2 @@ map.set(fsPath, content);

/** Adds all files from node_modules/@types into the FS Map */
var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {

@@ -240,3 +213,2 @@ return addAllFilesFromFolder(map, "node_modules/@types");

*/
var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache, ts, lzstring, fetcher, storer) {

@@ -247,12 +219,9 @@ var fetchlike = fetcher || fetch;

var prefix = "https://typescript.azureedge.net/cdn/" + version + "/typescript/lib/";
function zip(str) {
return lzstring ? lzstring.compressToUTF16(str) : str;
}
function unzip(str) {
return lzstring ? lzstring.decompressFromUTF16(str) : str;
} // Map the known libs to a node fetch promise, then return the contents
}
// Map the known libs to a node fetch promise, then return the contents
function uncached() {

@@ -267,7 +236,7 @@ return Promise.all(files.map(function (lib) {

});
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
})
// Return a NOOP for .d.ts files which aren't in the current build of TypeScript
["catch"](function () {});
} // A localstorage and lzzip aware version of the lib files
}
// A localstorage and lzzip aware version of the lib files
function cached() {

@@ -285,3 +254,2 @@ var storelike = storer || localStorage;

var content = storelike.getItem(cacheKey);
if (!content) {

@@ -294,3 +262,4 @@ // Make the API call and store the text concent in the cache

return t;
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
})
// Return a NOOP for .d.ts files which aren't in the current build of TypeScript
["catch"](function () {});

@@ -309,3 +278,2 @@ } else {

}
var func = cache ? cached : uncached;

@@ -316,7 +284,5 @@ return func().then(function () {

};
function notImplemented(methodName) {
throw new Error("Method '" + methodName + "' is not implemented.");
}
function audit(name, fn) {

@@ -327,3 +293,2 @@ return function () {

}
var res = fn.apply(void 0, args);

@@ -337,4 +302,2 @@ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;

/** The default compiler options if TypeScript could ever change the compiler options */
var defaultCompilerOptions = function defaultCompilerOptions(ts) {

@@ -351,5 +314,4 @@ return _extends({}, ts.getDefaultCompilerOptions(), {

});
}; // "/DOM.d.ts" => "/lib.dom.d.ts"
};
// "/DOM.d.ts" => "/lib.dom.d.ts"
var libize = function libize(path) {

@@ -362,4 +324,2 @@ return path.replace("/", "/lib.").toLowerCase();

*/
function createSystem(files) {

@@ -416,3 +376,2 @@ return {

*/
function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {

@@ -422,4 +381,4 @@ // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the

var root = _projectRoot + "/vfs";
var path = requirePath(); // The default System in TypeScript
var path = requirePath();
// The default System in TypeScript
var nodeSys = ts.sys;

@@ -443,6 +402,5 @@ var tsLib = tsLibDirectory != null ? tsLibDirectory : path.dirname(require.resolve("typescript"));

fileExists: audit("fileExists", function (fileName) {
if (files.has(fileName)) return true; // Don't let other tsconfigs end up touching the vfs
if (files.has(fileName)) return true;
// Don't let other tsconfigs end up touching the vfs
if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
if (fileName.startsWith("/lib")) {

@@ -452,3 +410,2 @@ var tsLibName = tsLib + "/" + fileName.replace("/", "");

}
return nodeSys.fileExists(fileName);

@@ -472,7 +429,5 @@ }),

if (files.has(fileName)) return files.get(fileName);
if (fileName.startsWith("/lib")) {
var tsLibName = tsLib + "/" + fileName.replace("/", "");
var result = nodeSys.readFile(tsLibName);
if (!result) {

@@ -482,6 +437,4 @@ var libs = nodeSys.readDirectory(tsLib);

}
return result;
}
return nodeSys.readFile(fileName);

@@ -508,6 +461,4 @@ }),

*/
function createVirtualCompilerHost(sys, compilerOptions, ts) {
var sourceFiles = new Map();
var save = function save(sourceFile) {

@@ -517,3 +468,2 @@ sourceFiles.set(sourceFile.fileName, sourceFile);

};
var vHost = {

@@ -527,2 +477,3 @@ compilerHost: _extends({}, sys, {

},
// '/lib.d.ts',
// getDefaultLibLocation: () => '/',

@@ -554,13 +505,9 @@ getDirectories: function getDirectories() {

*/
function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, customTransformers) {
var fileNames = [].concat(rootFiles);
var _createVirtualCompile = createVirtualCompilerHost(sys, compilerOptions, ts),
compilerHost = _createVirtualCompile.compilerHost,
_updateFile2 = _createVirtualCompile.updateFile;
compilerHost = _createVirtualCompile.compilerHost,
_updateFile2 = _createVirtualCompile.updateFile;
var fileVersions = new Map();
var projectVersion = 0;
var languageServiceHost = _extends({}, compilerHost, {

@@ -589,7 +536,5 @@ getProjectVersion: function getProjectVersion() {

var contents = sys.readFile(fileName);
if (contents) {
if (contents && typeof contents === "string") {
return ts.ScriptSnapshot.fromString(contents);
}
return;

@@ -602,3 +547,2 @@ },

});
var lsHost = {

@@ -609,7 +553,5 @@ languageServiceHost: languageServiceHost,

fileVersions.set(sourceFile.fileName, projectVersion.toString());
if (!fileNames.includes(sourceFile.fileName)) {
fileNames.push(sourceFile.fileName);
}
_updateFile2(sourceFile);

@@ -620,7 +562,5 @@ }

}
var requirePath = function requirePath() {
return require(String.fromCharCode(112, 97, 116, 104));
};
var requireFS = function requireFS() {

@@ -627,0 +567,0 @@ return require(String.fromCharCode(102, 115));

@@ -1,2 +0,2 @@

"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e}).apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=!1;try{t="undefined"!=typeof localStorage}catch(e){}var r="undefined"!=typeof process,i=t&&localStorage.getItem("DEBUG")||r&&process.env.DEBUG?console.log:function(e){return""},n=function(e,t){var r,i=e.lib||[],n=["lib.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts","lib.webworker.d.ts","lib.webworker.importscripts.d.ts","lib.webworker.iterable.d.ts","lib.scripthost.d.ts","lib.es5.d.ts","lib.es6.d.ts","lib.es2015.collection.d.ts","lib.es2015.core.d.ts","lib.es2015.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.d.ts","lib.es2016.full.d.ts","lib.es2017.d.ts","lib.es2017.date.d.ts","lib.es2017.full.d.ts","lib.es2017.intl.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.d.ts","lib.es2018.full.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.d.ts","lib.es2019.full.d.ts","lib.es2019.intl.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2020.bigint.d.ts","lib.es2020.d.ts","lib.es2020.date.d.ts","lib.es2020.full.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2021.d.ts","lib.es2021.full.d.ts","lib.es2021.intl.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2022.array.d.ts","lib.es2022.d.ts","lib.es2022.error.d.ts","lib.es2022.full.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.regexp.d.ts","lib.es2022.sharedmemory.d.ts","lib.es2022.string.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.d.ts","lib.es2023.full.d.ts","lib.esnext.array.d.ts","lib.esnext.asynciterable.d.ts","lib.esnext.bigint.d.ts","lib.esnext.d.ts","lib.esnext.decorators.d.ts","lib.esnext.disposable.d.ts","lib.esnext.full.d.ts","lib.esnext.intl.d.ts","lib.esnext.promise.d.ts","lib.esnext.string.d.ts","lib.esnext.symbol.d.ts","lib.esnext.weakref.d.ts"],s=t.ScriptTarget[e.target||t.ScriptTarget.ES5],o=n.filter((function(e){return e.startsWith("lib."+s.toLowerCase())})),l=n.indexOf(o.pop()),a=((r=i.map((function(e){var t=n.filter((function(t){return t.startsWith("lib."+e.toLowerCase())}));return 0===t.length?0:n.indexOf(t.pop())})))&&r.length?r.reduce((function(e,t){return t>e?t:e})):void 0)||0,u=Math.max(l,a);return n.slice(0,u+1)},s=function(e,t){var r=f(),i=b();(function e(t){var n=[];return i.readdirSync(t).forEach((function(s){s=r.join(t,s);var o=i.statSync(s);o&&o.isDirectory()?n=n.concat(e(s)):n.push(s)})),n})(t).forEach((function(n){var s="/node_modules/@types"+n.replace(t,""),o=i.readFileSync(n,"utf8");[".ts",".tsx"].includes(r.extname(s))&&e.set(s,o)}))};function o(e){throw new Error("Method '"+e+"' is not implemented.")}function l(e,t){return function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];var o=t.apply(void 0,n),l="string"==typeof o?o.slice(0,80)+"...":o;return i.apply(void 0,["> "+e].concat(n)),i("< "+l),o}}var a=function(t){return e({},t.getDefaultCompilerOptions(),{jsx:t.JsxEmit.React,strict:!0,esModuleInterop:!0,module:t.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0,moduleResolution:t.ModuleResolutionKind.NodeJs})},u=function(e){return e.replace("/","/lib.").toLowerCase()};function c(t,r,i){var n=new Map;return{compilerHost:e({},t,{getCanonicalFileName:function(e){return e},getDefaultLibFileName:function(){return"/"+i.getDefaultLibFileName(r)},getDirectories:function(){return[]},getNewLine:function(){return t.newLine},getSourceFile:function(e){return n.get(e)||(s=i.createSourceFile(e,t.readFile(e),r.target||a(i).target,!1),n.set(s.fileName,s),s);var s},useCaseSensitiveFileNames:function(){return t.useCaseSensitiveFileNames}}),updateFile:function(e){var r=n.has(e.fileName);return t.writeFile(e.fileName,e.text),n.set(e.fileName,e),r}}}function d(t,r,i,n,s){var o=[].concat(r),l=c(t,i,n),a=l.compilerHost,u=l.updateFile,d=new Map,f=0;return{languageServiceHost:e({},a,{getProjectVersion:function(){return f.toString()},getCompilationSettings:function(){return i},getCustomTransformers:function(){return s},getScriptFileNames:function(){return o.slice()},getScriptSnapshot:function(e){var r=t.readFile(e);if(r)return n.ScriptSnapshot.fromString(r)},getScriptVersion:function(e){return d.get(e)||"0"},writeFile:t.writeFile}),updateFile:function(e){f++,d.set(e.fileName,f.toString()),o.includes(e.fileName)||o.push(e.fileName),u(e)}}}var f=function(){return require(String.fromCharCode(112,97,116,104))},b=function(){return require(String.fromCharCode(102,115))};exports.addAllFilesFromFolder=s,exports.addFilesForTypesIntoFolder=function(e){return s(e,"node_modules/@types")},exports.createDefaultMapFromCDN=function(e,t,r,i,s,o,l){var a=o||fetch,u=new Map,c=n(e,i),d="https://typescript.azureedge.net/cdn/"+t+"/typescript/lib/";return(r?function(){var e=l||localStorage;return Object.keys(e).forEach((function(r){r.startsWith("ts-lib-")&&!r.startsWith("ts-lib-"+t)&&e.removeItem(r)})),Promise.all(c.map((function(r){var i,n="ts-lib-"+t+"-"+r,o=e.getItem(n);return o?Promise.resolve((i=o,s?s.decompressFromUTF16(i):i)):a(d+r).then((function(e){return e.text()})).then((function(t){var r;return e.setItem(n,(r=t,s?s.compressToUTF16(r):r)),t})).catch((function(){}))}))).then((function(e){e.forEach((function(e,t){e&&u.set("/"+c[t],e)}))}))}:function(){return Promise.all(c.map((function(e){return a(d+e).then((function(e){return e.text()}))}))).then((function(e){e.forEach((function(e,t){return u.set("/"+c[t],e)}))})).catch((function(){}))})().then((function(){return u}))},exports.createDefaultMapFromNodeModules=function(e,t,r){var i=f(),n=b(),s=n.readdirSync(r||i.dirname(require.resolve("typescript"))).filter((function(e){return e.startsWith("lib.")&&e.endsWith(".d.ts")})),o=new Map;return s.forEach((function(e){o.set("/"+e,function(e){var t=r||i.dirname(require.resolve("typescript"));return n.readFileSync(i.join(t,e),"utf8")}(e))})),o},exports.createFSBackedSystem=function(e,t,r,i){var n=t+"/vfs",s=f(),a=r.sys,u=null!=i?i:s.dirname(require.resolve("typescript"));return{name:"fs-vfs",root:n,args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))||a.directoryExists(t)})),exit:a.exit,fileExists:l("fileExists",(function(t){if(e.has(t))return!0;if(t.includes("tsconfig.json")||t.includes("tsconfig.json"))return!1;if(t.startsWith("/lib")){var r=u+"/"+t.replace("/","");return a.fileExists(r)}return a.fileExists(t)})),getCurrentDirectory:function(){return n},getDirectories:a.getDirectories,getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(){return"/"===(arguments.length<=0?void 0:arguments[0])?Array.from(e.keys()):a.readDirectory.apply(a,arguments)})),readFile:l("readFile",(function(t){if(e.has(t))return e.get(t);if(t.startsWith("/lib")){var r=u+"/"+t.replace("/",""),i=a.readFile(r);if(!i){var n=a.readDirectory(u);throw new Error("TSVFS: A request was made for "+r+" but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: "+n+".")}return i}return a.readFile(t)})),resolvePath:function(t){return e.has(t)?t:a.resolvePath(t)},newLine:"\n",useCaseSensitiveFileNames:!0,write:function(){return o("write")},writeFile:function(t,r){e.set(t,r)}}},exports.createSystem=function(e){return{args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))})),exit:function(){return o("exit")},fileExists:l("fileExists",(function(t){return e.has(t)||e.has(u(t))})),getCurrentDirectory:function(){return"/"},getDirectories:function(){return[]},getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(t){return"/"===t?Array.from(e.keys()):[]})),readFile:l("readFile",(function(t){return e.get(t)||e.get(u(t))})),resolvePath:function(e){return e},newLine:"\n",useCaseSensitiveFileNames:!0,write:function(){return o("write")},writeFile:function(t,r){e.set(t,r)}}},exports.createVirtualCompilerHost=c,exports.createVirtualLanguageServiceHost=d,exports.createVirtualTypeScriptEnvironment=function(t,r,i,n,s){void 0===n&&(n={});var o=e({},a(i),n),l=d(t,r,o,i,s),u=l.updateFile,f=i.createLanguageService(l.languageServiceHost),b=f.getCompilerOptionsDiagnostics();if(b.length){var p=c(t,n,i);throw new Error(i.formatDiagnostics(b,p.compilerHost))}return{name:"vfs",sys:t,languageService:f,getSourceFile:function(e){var t;return null==(t=f.getProgram())?void 0:t.getSourceFile(e)},createFile:function(e,t){u(i.createSourceFile(e,t,o.target,!1))},updateFile:function(e,t,r){var n=f.getProgram().getSourceFile(e);if(!n)throw new Error("Did not find a source file for "+e);var s=n.text,o=null!=r?r:i.createTextSpan(0,s.length),l=s.slice(0,o.start)+t+s.slice(o.start+o.length),a=i.updateSourceFile(n,l,{span:o,newLength:t.length});u(a)}}},exports.knownLibFilesForCompilerOptions=n;
"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},e.apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=!1;try{t="undefined"!=typeof localStorage}catch(e){}var r="undefined"!=typeof process,i=t&&localStorage.getItem("DEBUG")||r&&process.env.DEBUG?console.log:function(e){return""},n=function(e,t){var r,i=e.lib||[],n=["lib.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts","lib.webworker.d.ts","lib.webworker.importscripts.d.ts","lib.webworker.iterable.d.ts","lib.scripthost.d.ts","lib.es5.d.ts","lib.es6.d.ts","lib.es2015.collection.d.ts","lib.es2015.core.d.ts","lib.es2015.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.d.ts","lib.es2016.full.d.ts","lib.es2017.d.ts","lib.es2017.date.d.ts","lib.es2017.full.d.ts","lib.es2017.intl.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.d.ts","lib.es2018.full.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.d.ts","lib.es2019.full.d.ts","lib.es2019.intl.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2020.bigint.d.ts","lib.es2020.d.ts","lib.es2020.date.d.ts","lib.es2020.full.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2021.d.ts","lib.es2021.full.d.ts","lib.es2021.intl.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2022.array.d.ts","lib.es2022.d.ts","lib.es2022.error.d.ts","lib.es2022.full.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.regexp.d.ts","lib.es2022.sharedmemory.d.ts","lib.es2022.string.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.d.ts","lib.es2023.full.d.ts","lib.esnext.array.d.ts","lib.esnext.asynciterable.d.ts","lib.esnext.bigint.d.ts","lib.esnext.d.ts","lib.esnext.decorators.d.ts","lib.esnext.disposable.d.ts","lib.esnext.full.d.ts","lib.esnext.intl.d.ts","lib.esnext.promise.d.ts","lib.esnext.string.d.ts","lib.esnext.symbol.d.ts","lib.esnext.weakref.d.ts"],s=t.ScriptTarget[e.target||t.ScriptTarget.ES5],o=n.filter((function(e){return e.startsWith("lib."+s.toLowerCase())})),l=n.indexOf(o.pop()),a=i.map((function(e){var t=n.filter((function(t){return t.startsWith("lib."+e.toLowerCase())}));return 0===t.length?0:n.indexOf(t.pop())})),u=((r=a)&&r.length?r.reduce((function(e,t){return t>e?t:e})):void 0)||0,c=Math.max(l,u);return n.slice(0,c+1)},s=function(e,t){var r=f(),i=b();(function e(t){var n=[];return i.readdirSync(t).forEach((function(s){s=r.join(t,s);var o=i.statSync(s);o&&o.isDirectory()?n=n.concat(e(s)):n.push(s)})),n})(t).forEach((function(n){var s="/node_modules/@types"+n.replace(t,""),o=i.readFileSync(n,"utf8");[".ts",".tsx"].includes(r.extname(s))&&e.set(s,o)}))};function o(e){throw new Error("Method '"+e+"' is not implemented.")}function l(e,t){return function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];var o=t.apply(void 0,n),l="string"==typeof o?o.slice(0,80)+"...":o;return i.apply(void 0,["> "+e].concat(n)),i("< "+l),o}}var a=function(t){return e({},t.getDefaultCompilerOptions(),{jsx:t.JsxEmit.React,strict:!0,esModuleInterop:!0,module:t.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0,moduleResolution:t.ModuleResolutionKind.NodeJs})},u=function(e){return e.replace("/","/lib.").toLowerCase()};function c(t,r,i){var n=new Map;return{compilerHost:e({},t,{getCanonicalFileName:function(e){return e},getDefaultLibFileName:function(){return"/"+i.getDefaultLibFileName(r)},getDirectories:function(){return[]},getNewLine:function(){return t.newLine},getSourceFile:function(e){return n.get(e)||(s=i.createSourceFile(e,t.readFile(e),r.target||a(i).target,!1),n.set(s.fileName,s),s);var s},useCaseSensitiveFileNames:function(){return t.useCaseSensitiveFileNames}}),updateFile:function(e){var r=n.has(e.fileName);return t.writeFile(e.fileName,e.text),n.set(e.fileName,e),r}}}function d(t,r,i,n,s){var o=[].concat(r),l=c(t,i,n),a=l.compilerHost,u=l.updateFile,d=new Map,f=0;return{languageServiceHost:e({},a,{getProjectVersion:function(){return f.toString()},getCompilationSettings:function(){return i},getCustomTransformers:function(){return s},getScriptFileNames:function(){return o.slice()},getScriptSnapshot:function(e){var r=t.readFile(e);if(r&&"string"==typeof r)return n.ScriptSnapshot.fromString(r)},getScriptVersion:function(e){return d.get(e)||"0"},writeFile:t.writeFile}),updateFile:function(e){f++,d.set(e.fileName,f.toString()),o.includes(e.fileName)||o.push(e.fileName),u(e)}}}var f=function(){return require(String.fromCharCode(112,97,116,104))},b=function(){return require(String.fromCharCode(102,115))};exports.addAllFilesFromFolder=s,exports.addFilesForTypesIntoFolder=function(e){return s(e,"node_modules/@types")},exports.createDefaultMapFromCDN=function(e,t,r,i,s,o,l){var a=o||fetch,u=new Map,c=n(e,i),d="https://typescript.azureedge.net/cdn/"+t+"/typescript/lib/";return(r?function(){var e=l||localStorage;return Object.keys(e).forEach((function(r){r.startsWith("ts-lib-")&&!r.startsWith("ts-lib-"+t)&&e.removeItem(r)})),Promise.all(c.map((function(r){var i,n="ts-lib-"+t+"-"+r,o=e.getItem(n);return o?Promise.resolve((i=o,s?s.decompressFromUTF16(i):i)):a(d+r).then((function(e){return e.text()})).then((function(t){var r;return e.setItem(n,(r=t,s?s.compressToUTF16(r):r)),t})).catch((function(){}))}))).then((function(e){e.forEach((function(e,t){e&&u.set("/"+c[t],e)}))}))}:function(){return Promise.all(c.map((function(e){return a(d+e).then((function(e){return e.text()}))}))).then((function(e){e.forEach((function(e,t){return u.set("/"+c[t],e)}))})).catch((function(){}))})().then((function(){return u}))},exports.createDefaultMapFromNodeModules=function(e,t,r){var i=f(),n=b(),s=n.readdirSync(r||i.dirname(require.resolve("typescript"))).filter((function(e){return e.startsWith("lib.")&&e.endsWith(".d.ts")})),o=new Map;return s.forEach((function(e){o.set("/"+e,function(e){var t=r||i.dirname(require.resolve("typescript"));return n.readFileSync(i.join(t,e),"utf8")}(e))})),o},exports.createFSBackedSystem=function(e,t,r,i){var n=t+"/vfs",s=f(),a=r.sys,u=null!=i?i:s.dirname(require.resolve("typescript"));return{name:"fs-vfs",root:n,args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))||a.directoryExists(t)})),exit:a.exit,fileExists:l("fileExists",(function(t){if(e.has(t))return!0;if(t.includes("tsconfig.json")||t.includes("tsconfig.json"))return!1;if(t.startsWith("/lib")){var r=u+"/"+t.replace("/","");return a.fileExists(r)}return a.fileExists(t)})),getCurrentDirectory:function(){return n},getDirectories:a.getDirectories,getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(){return"/"===(arguments.length<=0?void 0:arguments[0])?Array.from(e.keys()):a.readDirectory.apply(a,arguments)})),readFile:l("readFile",(function(t){if(e.has(t))return e.get(t);if(t.startsWith("/lib")){var r=u+"/"+t.replace("/",""),i=a.readFile(r);if(!i){var n=a.readDirectory(u);throw new Error("TSVFS: A request was made for "+r+" but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: "+n+".")}return i}return a.readFile(t)})),resolvePath:function(t){return e.has(t)?t:a.resolvePath(t)},newLine:"\n",useCaseSensitiveFileNames:!0,write:function(){return o("write")},writeFile:function(t,r){e.set(t,r)}}},exports.createSystem=function(e){return{args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))})),exit:function(){return o("exit")},fileExists:l("fileExists",(function(t){return e.has(t)||e.has(u(t))})),getCurrentDirectory:function(){return"/"},getDirectories:function(){return[]},getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(t){return"/"===t?Array.from(e.keys()):[]})),readFile:l("readFile",(function(t){return e.get(t)||e.get(u(t))})),resolvePath:function(e){return e},newLine:"\n",useCaseSensitiveFileNames:!0,write:function(){return o("write")},writeFile:function(t,r){e.set(t,r)}}},exports.createVirtualCompilerHost=c,exports.createVirtualLanguageServiceHost=d,exports.createVirtualTypeScriptEnvironment=function(t,r,i,n,s){void 0===n&&(n={});var o=e({},a(i),n),l=d(t,r,o,i,s),u=l.updateFile,f=i.createLanguageService(l.languageServiceHost),b=f.getCompilerOptionsDiagnostics();if(b.length){var p=c(t,n,i);throw new Error(i.formatDiagnostics(b,p.compilerHost))}return{name:"vfs",sys:t,languageService:f,getSourceFile:function(e){var t;return null==(t=f.getProgram())?void 0:t.getSourceFile(e)},createFile:function(e,t){u(i.createSourceFile(e,t,o.target,!1))},updateFile:function(e,t,r){var n=f.getProgram().getSourceFile(e);if(!n)throw new Error("Did not find a source file for "+e);var s=n.text,o=null!=r?r:i.createTextSpan(0,s.length),l=s.slice(0,o.start)+t+s.slice(o.start+o.length),a=i.updateSourceFile(n,l,{span:o,newLength:t.length});u(a)}}},exports.knownLibFilesForCompilerOptions=n;
//# sourceMappingURL=vfs.cjs.production.min.js.map
function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -12,6 +11,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);

@@ -21,7 +18,5 @@ }

var hasLocalStorage = false;
try {
hasLocalStorage = typeof localStorage !== "undefined";
} catch (error) {}
var hasProcess = typeof process !== "undefined";

@@ -42,3 +37,2 @@ var shouldDebug = hasLocalStorage && /*#__PURE__*/localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;

*/
function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions, customTransformers) {

@@ -48,12 +42,8 @@ if (compilerOptions === void 0) {

}
var mergedCompilerOpts = _extends({}, defaultCompilerOptions(ts), compilerOptions);
var _createVirtualLanguag = createVirtualLanguageServiceHost(sys, rootFiles, mergedCompilerOpts, ts, customTransformers),
languageServiceHost = _createVirtualLanguag.languageServiceHost,
_updateFile = _createVirtualLanguag.updateFile;
languageServiceHost = _createVirtualLanguag.languageServiceHost,
_updateFile = _createVirtualLanguag.updateFile;
var languageService = ts.createLanguageService(languageServiceHost);
var diagnostics = languageService.getCompilerOptionsDiagnostics();
if (diagnostics.length) {

@@ -63,3 +53,2 @@ var compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts);

}
return {

@@ -72,3 +61,2 @@ // @ts-ignore

var _languageService$getP;
return (_languageService$getP = languageService.getProgram()) == null ? void 0 : _languageService$getP.getSourceFile(fileName);

@@ -81,9 +69,7 @@ },

var prevSourceFile = languageService.getProgram().getSourceFile(fileName);
if (!prevSourceFile) {
throw new Error("Did not find a source file for " + fileName);
}
var prevFullContents = prevSourceFile.text; // TODO: Validate if the default text span has a fencepost error?
var prevFullContents = prevSourceFile.text;
// TODO: Validate if the default text span has a fencepost error?
var prevTextSpan = optPrevTextSpan != null ? optPrevTextSpan : ts.createTextSpan(0, prevFullContents.length);

@@ -95,9 +81,8 @@ var newText = prevFullContents.slice(0, prevTextSpan.start) + content + prevFullContents.slice(prevTextSpan.start + prevTextSpan.length);

});
_updateFile(newSourceFile);
}
};
} // TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json
}
// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json
// and then using that to generate the list of files from the server, but it is not included in the npm package
/**

@@ -111,9 +96,8 @@ * Grab the list of lib files for a particular target, will return a bit more than necessary (by including

*/
var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
var target = compilerOptions.target || ts.ScriptTarget.ES5;
var lib = compilerOptions.lib || []; // Note that this will include files which can't be found for particular versions of TS
var lib = compilerOptions.lib || [];
// Note that this will include files which can't be found for particular versions of TS
// TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011
// or similar is merged.
var files = ["lib.d.ts", "lib.decorators.d.ts", "lib.decorators.legacy.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.d.ts", "lib.webworker.iterable.d.ts", "lib.scripthost.d.ts", "lib.es5.d.ts", "lib.es6.d.ts", "lib.es2015.collection.d.ts", "lib.es2015.core.d.ts", "lib.es2015.d.ts", "lib.es2015.generator.d.ts", "lib.es2015.iterable.d.ts", "lib.es2015.promise.d.ts", "lib.es2015.proxy.d.ts", "lib.es2015.reflect.d.ts", "lib.es2015.symbol.d.ts", "lib.es2015.symbol.wellknown.d.ts", "lib.es2016.array.include.d.ts", "lib.es2016.d.ts", "lib.es2016.full.d.ts", "lib.es2017.d.ts", "lib.es2017.date.d.ts", "lib.es2017.full.d.ts", "lib.es2017.intl.d.ts", "lib.es2017.object.d.ts", "lib.es2017.sharedmemory.d.ts", "lib.es2017.string.d.ts", "lib.es2017.typedarrays.d.ts", "lib.es2018.asyncgenerator.d.ts", "lib.es2018.asynciterable.d.ts", "lib.es2018.d.ts", "lib.es2018.full.d.ts", "lib.es2018.intl.d.ts", "lib.es2018.promise.d.ts", "lib.es2018.regexp.d.ts", "lib.es2019.array.d.ts", "lib.es2019.d.ts", "lib.es2019.full.d.ts", "lib.es2019.intl.d.ts", "lib.es2019.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.d.ts", "lib.es2020.date.d.ts", "lib.es2020.full.d.ts", "lib.es2020.intl.d.ts", "lib.es2020.number.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.intl.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.es2022.array.d.ts", "lib.es2022.d.ts", "lib.es2022.error.d.ts", "lib.es2022.full.d.ts", "lib.es2022.intl.d.ts", "lib.es2022.object.d.ts", "lib.es2022.regexp.d.ts", "lib.es2022.sharedmemory.d.ts", "lib.es2022.string.d.ts", "lib.es2023.array.d.ts", "lib.es2023.collection.d.ts", "lib.es2023.d.ts", "lib.es2023.full.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.d.ts", "lib.esnext.decorators.d.ts", "lib.esnext.disposable.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.string.d.ts", "lib.esnext.symbol.d.ts", "lib.esnext.weakref.d.ts"];

@@ -125,3 +109,2 @@ var targetToCut = ts.ScriptTarget[target];

var targetCutIndex = files.indexOf(matches.pop());
var getMax = function getMax(array) {

@@ -131,5 +114,4 @@ return array && array.length ? array.reduce(function (max, current) {

}) : undefined;
}; // Find the index for everything in
};
// Find the index for everything in
var indexesForCutting = lib.map(function (lib) {

@@ -154,7 +136,5 @@ var matches = files.filter(function (f) {

*/
var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_compilerOptions, _ts, tsLibDirectory) {
var path = requirePath();
var fs = requireFS();
var getLib = function getLib(name) {

@@ -164,3 +144,2 @@ var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));

};
var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve("typescript")));

@@ -179,7 +158,5 @@ var knownLibFiles = libFiles.filter(function (f) {

*/
var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
var path = requirePath();
var fs = requireFS();
var walk = function walk(dir) {

@@ -191,3 +168,2 @@ var results = [];

var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {

@@ -203,3 +179,2 @@ /* Recurse into a subdirectory */

};
var allFiles = walk(workingDir);

@@ -210,3 +185,2 @@ allFiles.forEach(function (lib) {

var validExtensions = [".ts", ".tsx"];
if (validExtensions.includes(path.extname(fsPath))) {

@@ -218,3 +192,2 @@ map.set(fsPath, content);

/** Adds all files from node_modules/@types into the FS Map */
var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {

@@ -235,3 +208,2 @@ return addAllFilesFromFolder(map, "node_modules/@types");

*/
var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache, ts, lzstring, fetcher, storer) {

@@ -242,12 +214,9 @@ var fetchlike = fetcher || fetch;

var prefix = "https://typescript.azureedge.net/cdn/" + version + "/typescript/lib/";
function zip(str) {
return lzstring ? lzstring.compressToUTF16(str) : str;
}
function unzip(str) {
return lzstring ? lzstring.decompressFromUTF16(str) : str;
} // Map the known libs to a node fetch promise, then return the contents
}
// Map the known libs to a node fetch promise, then return the contents
function uncached() {

@@ -262,7 +231,7 @@ return Promise.all(files.map(function (lib) {

});
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
})
// Return a NOOP for .d.ts files which aren't in the current build of TypeScript
["catch"](function () {});
} // A localstorage and lzzip aware version of the lib files
}
// A localstorage and lzzip aware version of the lib files
function cached() {

@@ -280,3 +249,2 @@ var storelike = storer || localStorage;

var content = storelike.getItem(cacheKey);
if (!content) {

@@ -289,3 +257,4 @@ // Make the API call and store the text concent in the cache

return t;
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
})
// Return a NOOP for .d.ts files which aren't in the current build of TypeScript
["catch"](function () {});

@@ -304,3 +273,2 @@ } else {

}
var func = cache ? cached : uncached;

@@ -311,7 +279,5 @@ return func().then(function () {

};
function notImplemented(methodName) {
throw new Error("Method '" + methodName + "' is not implemented.");
}
function audit(name, fn) {

@@ -322,3 +288,2 @@ return function () {

}
var res = fn.apply(void 0, args);

@@ -332,4 +297,2 @@ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;

/** The default compiler options if TypeScript could ever change the compiler options */
var defaultCompilerOptions = function defaultCompilerOptions(ts) {

@@ -346,5 +309,4 @@ return _extends({}, ts.getDefaultCompilerOptions(), {

});
}; // "/DOM.d.ts" => "/lib.dom.d.ts"
};
// "/DOM.d.ts" => "/lib.dom.d.ts"
var libize = function libize(path) {

@@ -357,4 +319,2 @@ return path.replace("/", "/lib.").toLowerCase();

*/
function createSystem(files) {

@@ -411,3 +371,2 @@ return {

*/
function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {

@@ -417,4 +376,4 @@ // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the

var root = _projectRoot + "/vfs";
var path = requirePath(); // The default System in TypeScript
var path = requirePath();
// The default System in TypeScript
var nodeSys = ts.sys;

@@ -438,6 +397,5 @@ var tsLib = tsLibDirectory != null ? tsLibDirectory : path.dirname(require.resolve("typescript"));

fileExists: audit("fileExists", function (fileName) {
if (files.has(fileName)) return true; // Don't let other tsconfigs end up touching the vfs
if (files.has(fileName)) return true;
// Don't let other tsconfigs end up touching the vfs
if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
if (fileName.startsWith("/lib")) {

@@ -447,3 +405,2 @@ var tsLibName = tsLib + "/" + fileName.replace("/", "");

}
return nodeSys.fileExists(fileName);

@@ -467,7 +424,5 @@ }),

if (files.has(fileName)) return files.get(fileName);
if (fileName.startsWith("/lib")) {
var tsLibName = tsLib + "/" + fileName.replace("/", "");
var result = nodeSys.readFile(tsLibName);
if (!result) {

@@ -477,6 +432,4 @@ var libs = nodeSys.readDirectory(tsLib);

}
return result;
}
return nodeSys.readFile(fileName);

@@ -503,6 +456,4 @@ }),

*/
function createVirtualCompilerHost(sys, compilerOptions, ts) {
var sourceFiles = new Map();
var save = function save(sourceFile) {

@@ -512,3 +463,2 @@ sourceFiles.set(sourceFile.fileName, sourceFile);

};
var vHost = {

@@ -522,2 +472,3 @@ compilerHost: _extends({}, sys, {

},
// '/lib.d.ts',
// getDefaultLibLocation: () => '/',

@@ -549,13 +500,9 @@ getDirectories: function getDirectories() {

*/
function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, customTransformers) {
var fileNames = [].concat(rootFiles);
var _createVirtualCompile = createVirtualCompilerHost(sys, compilerOptions, ts),
compilerHost = _createVirtualCompile.compilerHost,
_updateFile2 = _createVirtualCompile.updateFile;
compilerHost = _createVirtualCompile.compilerHost,
_updateFile2 = _createVirtualCompile.updateFile;
var fileVersions = new Map();
var projectVersion = 0;
var languageServiceHost = _extends({}, compilerHost, {

@@ -584,7 +531,5 @@ getProjectVersion: function getProjectVersion() {

var contents = sys.readFile(fileName);
if (contents) {
if (contents && typeof contents === "string") {
return ts.ScriptSnapshot.fromString(contents);
}
return;

@@ -597,3 +542,2 @@ },

});
var lsHost = {

@@ -604,7 +548,5 @@ languageServiceHost: languageServiceHost,

fileVersions.set(sourceFile.fileName, projectVersion.toString());
if (!fileNames.includes(sourceFile.fileName)) {
fileNames.push(sourceFile.fileName);
}
_updateFile2(sourceFile);

@@ -615,7 +557,5 @@ }

}
var requirePath = function requirePath() {
return require(String.fromCharCode(112, 97, 116, 104));
};
var requireFS = function requireFS() {

@@ -622,0 +562,0 @@ return require(String.fromCharCode(102, 115));

function _extends() {
_extends = Object.assign || function (target) {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {

@@ -12,6 +11,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;
};
return _extends.apply(this, arguments);

@@ -21,7 +18,5 @@ }

var hasLocalStorage = false;
try {
hasLocalStorage = typeof localStorage !== "undefined";
} catch (error) {}
var hasProcess = typeof process !== "undefined";

@@ -42,3 +37,2 @@ var shouldDebug = hasLocalStorage && /*#__PURE__*/localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;

*/
function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions, customTransformers) {

@@ -48,12 +42,8 @@ if (compilerOptions === void 0) {

}
var mergedCompilerOpts = _extends({}, defaultCompilerOptions(ts), compilerOptions);
var _createVirtualLanguag = createVirtualLanguageServiceHost(sys, rootFiles, mergedCompilerOpts, ts, customTransformers),
languageServiceHost = _createVirtualLanguag.languageServiceHost,
_updateFile = _createVirtualLanguag.updateFile;
languageServiceHost = _createVirtualLanguag.languageServiceHost,
_updateFile = _createVirtualLanguag.updateFile;
var languageService = ts.createLanguageService(languageServiceHost);
var diagnostics = languageService.getCompilerOptionsDiagnostics();
if (diagnostics.length) {

@@ -63,3 +53,2 @@ var compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts);

}
return {

@@ -72,3 +61,2 @@ // @ts-ignore

var _languageService$getP;
return (_languageService$getP = languageService.getProgram()) == null ? void 0 : _languageService$getP.getSourceFile(fileName);

@@ -81,9 +69,7 @@ },

var prevSourceFile = languageService.getProgram().getSourceFile(fileName);
if (!prevSourceFile) {
throw new Error("Did not find a source file for " + fileName);
}
var prevFullContents = prevSourceFile.text; // TODO: Validate if the default text span has a fencepost error?
var prevFullContents = prevSourceFile.text;
// TODO: Validate if the default text span has a fencepost error?
var prevTextSpan = optPrevTextSpan != null ? optPrevTextSpan : ts.createTextSpan(0, prevFullContents.length);

@@ -95,9 +81,8 @@ var newText = prevFullContents.slice(0, prevTextSpan.start) + content + prevFullContents.slice(prevTextSpan.start + prevTextSpan.length);

});
_updateFile(newSourceFile);
}
};
} // TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json
}
// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json
// and then using that to generate the list of files from the server, but it is not included in the npm package
/**

@@ -111,9 +96,8 @@ * Grab the list of lib files for a particular target, will return a bit more than necessary (by including

*/
var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
var target = compilerOptions.target || ts.ScriptTarget.ES5;
var lib = compilerOptions.lib || []; // Note that this will include files which can't be found for particular versions of TS
var lib = compilerOptions.lib || [];
// Note that this will include files which can't be found for particular versions of TS
// TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011
// or similar is merged.
var files = ["lib.d.ts", "lib.decorators.d.ts", "lib.decorators.legacy.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.d.ts", "lib.webworker.iterable.d.ts", "lib.scripthost.d.ts", "lib.es5.d.ts", "lib.es6.d.ts", "lib.es2015.collection.d.ts", "lib.es2015.core.d.ts", "lib.es2015.d.ts", "lib.es2015.generator.d.ts", "lib.es2015.iterable.d.ts", "lib.es2015.promise.d.ts", "lib.es2015.proxy.d.ts", "lib.es2015.reflect.d.ts", "lib.es2015.symbol.d.ts", "lib.es2015.symbol.wellknown.d.ts", "lib.es2016.array.include.d.ts", "lib.es2016.d.ts", "lib.es2016.full.d.ts", "lib.es2017.d.ts", "lib.es2017.date.d.ts", "lib.es2017.full.d.ts", "lib.es2017.intl.d.ts", "lib.es2017.object.d.ts", "lib.es2017.sharedmemory.d.ts", "lib.es2017.string.d.ts", "lib.es2017.typedarrays.d.ts", "lib.es2018.asyncgenerator.d.ts", "lib.es2018.asynciterable.d.ts", "lib.es2018.d.ts", "lib.es2018.full.d.ts", "lib.es2018.intl.d.ts", "lib.es2018.promise.d.ts", "lib.es2018.regexp.d.ts", "lib.es2019.array.d.ts", "lib.es2019.d.ts", "lib.es2019.full.d.ts", "lib.es2019.intl.d.ts", "lib.es2019.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.d.ts", "lib.es2020.date.d.ts", "lib.es2020.full.d.ts", "lib.es2020.intl.d.ts", "lib.es2020.number.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.intl.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.es2022.array.d.ts", "lib.es2022.d.ts", "lib.es2022.error.d.ts", "lib.es2022.full.d.ts", "lib.es2022.intl.d.ts", "lib.es2022.object.d.ts", "lib.es2022.regexp.d.ts", "lib.es2022.sharedmemory.d.ts", "lib.es2022.string.d.ts", "lib.es2023.array.d.ts", "lib.es2023.collection.d.ts", "lib.es2023.d.ts", "lib.es2023.full.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.d.ts", "lib.esnext.decorators.d.ts", "lib.esnext.disposable.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.string.d.ts", "lib.esnext.symbol.d.ts", "lib.esnext.weakref.d.ts"];

@@ -125,3 +109,2 @@ var targetToCut = ts.ScriptTarget[target];

var targetCutIndex = files.indexOf(matches.pop());
var getMax = function getMax(array) {

@@ -131,5 +114,4 @@ return array && array.length ? array.reduce(function (max, current) {

}) : undefined;
}; // Find the index for everything in
};
// Find the index for everything in
var indexesForCutting = lib.map(function (lib) {

@@ -154,7 +136,5 @@ var matches = files.filter(function (f) {

*/
var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_compilerOptions, _ts, tsLibDirectory) {
var path = requirePath();
var fs = requireFS();
var getLib = function getLib(name) {

@@ -164,3 +144,2 @@ var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));

};
var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve("typescript")));

@@ -179,7 +158,5 @@ var knownLibFiles = libFiles.filter(function (f) {

*/
var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
var path = requirePath();
var fs = requireFS();
var walk = function walk(dir) {

@@ -191,3 +168,2 @@ var results = [];

var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {

@@ -203,3 +179,2 @@ /* Recurse into a subdirectory */

};
var allFiles = walk(workingDir);

@@ -210,3 +185,2 @@ allFiles.forEach(function (lib) {

var validExtensions = [".ts", ".tsx"];
if (validExtensions.includes(path.extname(fsPath))) {

@@ -218,3 +192,2 @@ map.set(fsPath, content);

/** Adds all files from node_modules/@types into the FS Map */
var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {

@@ -235,3 +208,2 @@ return addAllFilesFromFolder(map, "node_modules/@types");

*/
var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache, ts, lzstring, fetcher, storer) {

@@ -242,12 +214,9 @@ var fetchlike = fetcher || fetch;

var prefix = "https://typescript.azureedge.net/cdn/" + version + "/typescript/lib/";
function zip(str) {
return lzstring ? lzstring.compressToUTF16(str) : str;
}
function unzip(str) {
return lzstring ? lzstring.decompressFromUTF16(str) : str;
} // Map the known libs to a node fetch promise, then return the contents
}
// Map the known libs to a node fetch promise, then return the contents
function uncached() {

@@ -262,7 +231,7 @@ return Promise.all(files.map(function (lib) {

});
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
})
// Return a NOOP for .d.ts files which aren't in the current build of TypeScript
["catch"](function () {});
} // A localstorage and lzzip aware version of the lib files
}
// A localstorage and lzzip aware version of the lib files
function cached() {

@@ -280,3 +249,2 @@ var storelike = storer || localStorage;

var content = storelike.getItem(cacheKey);
if (!content) {

@@ -289,3 +257,4 @@ // Make the API call and store the text concent in the cache

return t;
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
})
// Return a NOOP for .d.ts files which aren't in the current build of TypeScript
["catch"](function () {});

@@ -304,3 +273,2 @@ } else {

}
var func = cache ? cached : uncached;

@@ -311,7 +279,5 @@ return func().then(function () {

};
function notImplemented(methodName) {
throw new Error("Method '" + methodName + "' is not implemented.");
}
function audit(name, fn) {

@@ -322,3 +288,2 @@ return function () {

}
var res = fn.apply(void 0, args);

@@ -332,4 +297,2 @@ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;

/** The default compiler options if TypeScript could ever change the compiler options */
var defaultCompilerOptions = function defaultCompilerOptions(ts) {

@@ -346,5 +309,4 @@ return _extends({}, ts.getDefaultCompilerOptions(), {

});
}; // "/DOM.d.ts" => "/lib.dom.d.ts"
};
// "/DOM.d.ts" => "/lib.dom.d.ts"
var libize = function libize(path) {

@@ -357,4 +319,2 @@ return path.replace("/", "/lib.").toLowerCase();

*/
function createSystem(files) {

@@ -411,3 +371,2 @@ return {

*/
function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {

@@ -417,4 +376,4 @@ // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the

var root = _projectRoot + "/vfs";
var path = requirePath(); // The default System in TypeScript
var path = requirePath();
// The default System in TypeScript
var nodeSys = ts.sys;

@@ -438,6 +397,5 @@ var tsLib = tsLibDirectory != null ? tsLibDirectory : path.dirname(require.resolve("typescript"));

fileExists: audit("fileExists", function (fileName) {
if (files.has(fileName)) return true; // Don't let other tsconfigs end up touching the vfs
if (files.has(fileName)) return true;
// Don't let other tsconfigs end up touching the vfs
if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
if (fileName.startsWith("/lib")) {

@@ -447,3 +405,2 @@ var tsLibName = tsLib + "/" + fileName.replace("/", "");

}
return nodeSys.fileExists(fileName);

@@ -467,7 +424,5 @@ }),

if (files.has(fileName)) return files.get(fileName);
if (fileName.startsWith("/lib")) {
var tsLibName = tsLib + "/" + fileName.replace("/", "");
var result = nodeSys.readFile(tsLibName);
if (!result) {

@@ -477,6 +432,4 @@ var libs = nodeSys.readDirectory(tsLib);

}
return result;
}
return nodeSys.readFile(fileName);

@@ -503,6 +456,4 @@ }),

*/
function createVirtualCompilerHost(sys, compilerOptions, ts) {
var sourceFiles = new Map();
var save = function save(sourceFile) {

@@ -512,3 +463,2 @@ sourceFiles.set(sourceFile.fileName, sourceFile);

};
var vHost = {

@@ -522,2 +472,3 @@ compilerHost: _extends({}, sys, {

},
// '/lib.d.ts',
// getDefaultLibLocation: () => '/',

@@ -549,13 +500,9 @@ getDirectories: function getDirectories() {

*/
function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, customTransformers) {
var fileNames = [].concat(rootFiles);
var _createVirtualCompile = createVirtualCompilerHost(sys, compilerOptions, ts),
compilerHost = _createVirtualCompile.compilerHost,
_updateFile2 = _createVirtualCompile.updateFile;
compilerHost = _createVirtualCompile.compilerHost,
_updateFile2 = _createVirtualCompile.updateFile;
var fileVersions = new Map();
var projectVersion = 0;
var languageServiceHost = _extends({}, compilerHost, {

@@ -584,7 +531,5 @@ getProjectVersion: function getProjectVersion() {

var contents = sys.readFile(fileName);
if (contents) {
if (contents && typeof contents === "string") {
return ts.ScriptSnapshot.fromString(contents);
}
return;

@@ -597,3 +542,2 @@ },

});
var lsHost = {

@@ -604,7 +548,5 @@ languageServiceHost: languageServiceHost,

fileVersions.set(sourceFile.fileName, projectVersion.toString());
if (!fileNames.includes(sourceFile.fileName)) {
fileNames.push(sourceFile.fileName);
}
_updateFile2(sourceFile);

@@ -615,7 +557,5 @@ }

}
var requirePath = function requirePath() {
return require(String.fromCharCode(112, 97, 116, 104));
};
var requireFS = function requireFS() {

@@ -622,0 +562,0 @@ return require(String.fromCharCode(102, 115));

{
"name": "@typescript/vfs",
"version": "1.5.0",
"version": "1.5.1",
"license": "MIT",

@@ -21,11 +21,2 @@ "author": "TypeScript team",

],
"scripts": {
"start": "tsdx watch",
"bootstrap": "yarn build",
"build": "tsdx build && yarn make-for-website && yarn make-global",
"make-for-website": "cpy src/index.ts ../sandbox/src/vendor --rename=typescript-vfs.ts",
"make-global": "node scripts/makeGlobals.js",
"test": "jest",
"lint": "tsdx lint"
},
"jest": {

@@ -48,12 +39,23 @@ "preset": "ts-jest",

"devDependencies": {
"@types/jest": "^25.1.3",
"babel-jest": "^26.0.6",
"@types/jest": "^29.5.12",
"babel-jest": "^29.7.0",
"cpy-cli": "^3.1.1",
"dts-cli": "^2.0.5",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-watch-typeahead": "^2.2.2",
"lz-string": "^1.5.0",
"ts-jest": "^29.0.5",
"tsdx": "^0.14.1",
"tslib": "^1.10.0",
"tslib": "^2.6.2",
"typescript": "*"
},
"scripts": {
"start": "dts watch",
"bootstrap": "pnpm build",
"build": "dts build && pnpm make-for-website && pnpm make-global",
"make-for-website": "cpy src/index.ts ../sandbox/src/vendor --rename=typescript-vfs.ts",
"make-global": "node scripts/makeGlobals.js",
"test": "dts test",
"lint": "dts lint"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc