@typescript/vfs 1.3.4 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="lz-string" />
2
1
  declare type System = import("typescript").System;
3
2
  declare type CompilerOptions = import("typescript").CompilerOptions;
4
3
  declare type CustomTransformers = import("typescript").CustomTransformers;
@@ -36,7 +35,7 @@ export declare const knownLibFilesForCompilerOptions: (compilerOptions: Compiler
36
35
  * Sets up a Map with lib contents by grabbing the necessary files from
37
36
  * the local copy of typescript via the file system.
38
37
  */
39
- export declare const createDefaultMapFromNodeModules: (compilerOptions: CompilerOptions, ts?: typeof import("typescript") | undefined) => Map<string, string>;
38
+ export declare const createDefaultMapFromNodeModules: (compilerOptions: CompilerOptions, ts?: typeof import("typescript"), tsLibDirectory?: string) => Map<string, string>;
40
39
  /**
41
40
  * Adds recursively files from the FS into the map based on the folder
42
41
  */
@@ -55,7 +54,7 @@ export declare const addFilesForTypesIntoFolder: (map: Map<string, string>) => v
55
54
  * @param fetcher an optional replacement for the global fetch function (tests mainly)
56
55
  * @param storer an optional replacement for the localStorage global (tests mainly)
57
56
  */
58
- export declare const createDefaultMapFromCDN: (options: CompilerOptions, version: string, cache: boolean, ts: TS, lzstring?: import("lz-string").LZStringStatic | undefined, fetcher?: typeof fetch | undefined, storer?: Storage | undefined) => Promise<Map<string, string>>;
57
+ export declare const createDefaultMapFromCDN: (options: CompilerOptions, version: string, cache: boolean, ts: TS, lzstring?: typeof import("lz-string"), fetcher?: typeof fetch, storer?: typeof localStorage) => Promise<Map<string, string>>;
59
58
  /**
60
59
  * Creates an in-memory System object which can be used in a TypeScript program, this
61
60
  * is what provides read/write aspects of the virtual fs
@@ -66,7 +65,7 @@ export declare function createSystem(files: Map<string, string>): System;
66
65
  * a set of virtual files which are prioritised over the FS versions, then a path to the root of your
67
66
  * project (basically the folder your node_modules lives)
68
67
  */
69
- export declare function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS): System;
68
+ export declare function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS, tsLibDirectory?: string): System;
70
69
  /**
71
70
  * Creates an in-memory CompilerHost -which is essentially an extra wrapper to System
72
71
  * which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile
@@ -27,9 +27,7 @@ try {
27
27
  } catch (error) {}
28
28
 
29
29
  var hasProcess = typeof process !== "undefined";
30
- var shouldDebug = hasLocalStorage &&
31
- /*#__PURE__*/
32
- localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
30
+ var shouldDebug = hasLocalStorage && /*#__PURE__*/localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
33
31
  var debugLog = shouldDebug ? console.log : function (_message) {
34
32
  return "";
35
33
  };
@@ -107,7 +105,7 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
107
105
  var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
108
106
  var target = compilerOptions.target || ts.ScriptTarget.ES5;
109
107
  var lib = compilerOptions.lib || [];
110
- var files = ["lib.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.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.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.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.d.ts", "lib.es2020.full.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.intl.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.symbol.d.ts"];
108
+ var files = ["lib.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.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.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.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.d.ts", "lib.es2020.full.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.intl.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.esnext.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.string.d.ts", "lib.esnext.weakref.d.ts"];
111
109
  var targetToCut = ts.ScriptTarget[target];
112
110
  var matches = files.filter(function (f) {
113
111
  return f.startsWith("lib." + targetToCut.toLowerCase());
@@ -138,15 +136,14 @@ var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(c
138
136
  * the local copy of typescript via the file system.
139
137
  */
140
138
 
141
- var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(compilerOptions, ts) {
139
+ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(compilerOptions, ts, tsLibDirectory) {
142
140
  var tsModule = ts || require("typescript");
143
141
 
144
- var path = require("path");
145
-
146
- var fs = require("fs");
142
+ var path = requirePath();
143
+ var fs = requireFS();
147
144
 
148
145
  var getLib = function getLib(name) {
149
- var lib = path.dirname(require.resolve("typescript"));
146
+ var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));
150
147
  return fs.readFileSync(path.join(lib, name), "utf8");
151
148
  };
152
149
 
@@ -162,9 +159,8 @@ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(c
162
159
  */
163
160
 
164
161
  var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
165
- var path = require("path");
166
-
167
- var fs = require("fs");
162
+ var path = requirePath();
163
+ var fs = requireFS();
168
164
 
169
165
  var walk = function walk(dir) {
170
166
  var results = [];
@@ -215,7 +211,6 @@ var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {
215
211
 
216
212
  var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache, ts, lzstring, fetcher, storer) {
217
213
  var fetchlike = fetcher || fetch;
218
- var storelike = storer || localStorage;
219
214
  var fsMap = new Map();
220
215
  var files = knownLibFilesForCompilerOptions(options, ts);
221
216
  var prefix = "https://typescript.azureedge.net/cdn/" + version + "/typescript/lib/";
@@ -243,6 +238,7 @@ var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version,
243
238
 
244
239
 
245
240
  function cached() {
241
+ var storelike = storer || localStorage;
246
242
  var keys = Object.keys(localStorage);
247
243
  keys.forEach(function (key) {
248
244
  // Remove anything which isn't from this version
@@ -374,16 +370,14 @@ function createSystem(files) {
374
370
  * project (basically the folder your node_modules lives)
375
371
  */
376
372
 
377
- function createFSBackedSystem(files, _projectRoot, ts) {
373
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
378
374
  // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the
379
375
  // existing node_modules structures going back through the history
380
376
  var root = _projectRoot + "/vfs";
381
-
382
- var path = require("path"); // The default System in TypeScript
383
-
377
+ var path = requirePath(); // The default System in TypeScript
384
378
 
385
379
  var nodeSys = ts.sys;
386
- var tsLib = path.dirname(require.resolve("typescript"));
380
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path.dirname(require.resolve("typescript"));
387
381
  return {
388
382
  // @ts-ignore
389
383
  name: "fs-vfs",
@@ -525,8 +519,16 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
525
519
  getCustomTransformers: function getCustomTransformers() {
526
520
  return customTransformers;
527
521
  },
522
+ // A couple weeks of 4.8 TypeScript nightlies had a bug where the Program's
523
+ // list of files was just a reference to the array returned by this host method,
524
+ // which means mutations by the host that ought to result in a new Program being
525
+ // created were not detected, since the old list of files and the new list of files
526
+ // were in fact a reference to the same underlying array. That was fixed in
527
+ // https://github.com/microsoft/TypeScript/pull/49813, but since the twoslash runner
528
+ // is used in bisecting for changes, it needs to guard against being busted in that
529
+ // couple-week period, so we defensively make a slice here.
528
530
  getScriptFileNames: function getScriptFileNames() {
529
- return fileNames;
531
+ return fileNames.slice();
530
532
  },
531
533
  getScriptSnapshot: function getScriptSnapshot(fileName) {
532
534
  var contents = sys.readFile(fileName);
@@ -559,6 +561,14 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
559
561
  return lsHost;
560
562
  }
561
563
 
564
+ var requirePath = function requirePath() {
565
+ return require(String.fromCharCode(112, 97, 116, 104));
566
+ };
567
+
568
+ var requireFS = function requireFS() {
569
+ return require(String.fromCharCode(102, 115));
570
+ };
571
+
562
572
  exports.addAllFilesFromFolder = addAllFilesFromFolder;
563
573
  exports.addFilesForTypesIntoFolder = addFilesForTypesIntoFolder;
564
574
  exports.createDefaultMapFromCDN = createDefaultMapFromCDN;
@@ -1 +1 @@
1
- {"version":3,"file":"vfs.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) {}\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n const files = [\n \"lib.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.esnext.array.d.ts\",\n \"lib.esnext.asynciterable.d.ts\",\n \"lib.esnext.bigint.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.symbol.d.ts\",\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n */\nexport const createDefaultMapFromNodeModules = (compilerOptions: CompilerOptions, ts?: typeof import(\"typescript\")) => {\n const tsModule = ts || require(\"typescript\")\n const path = require(\"path\")\n const fs = require(\"fs\")\n\n const getLib = (name: string) => {\n const lib = path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libs = knownLibFilesForCompilerOptions(compilerOptions, tsModule)\n const fsMap = new Map<string, string>()\n libs.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = require(\"path\")\n const fs = require(\"fs\")\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const storelike = storer || localStorage\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text()))).then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n }\n\n // A localstorage and lzzip aware version of the lib files\n function cached() {\n const keys = Object.keys(localStorage)\n keys.forEach(key => {\n // Remove anything which isn't from this version\n if (key.startsWith(\"ts-lib-\") && !key.startsWith(\"ts-lib-\" + version)) {\n storelike.removeItem(key)\n }\n })\n\n return Promise.all(\n files.map(lib => {\n const cacheKey = `ts-lib-${version}-${lib}`\n const content = storelike.getItem(cacheKey)\n\n if (!content) {\n // Make the API call and store the text concent in the cache\n return fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n })\n })\n }\n\n const func = cache ? cached : uncached\n return func().then(() => fsMap)\n}\n\nfunction notImplemented(methodName: string): any {\n throw new Error(`Method '${methodName}' is not implemented.`)\n}\n\nfunction audit<ArgsT extends any[], ReturnT>(\n name: string,\n fn: (...args: ArgsT) => ReturnT\n): (...args: ArgsT) => ReturnT {\n return (...args) => {\n const res = fn(...args)\n\n const smallres = typeof res === \"string\" ? res.slice(0, 80) + \"...\" : res\n debugLog(\"> \" + name, ...args)\n debugLog(\"< \" + smallres)\n\n return res\n }\n}\n\n/** The default compiler options if TypeScript could ever change the compiler options */\nconst defaultCompilerOptions = (ts: typeof import(\"typescript\")): CompilerOptions => {\n return {\n ...ts.getDefaultCompilerOptions(),\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n module: ts.ModuleKind.ESNext,\n suppressOutputPathCheck: true,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n }\n}\n\n// \"/DOM.d.ts\" => \"/lib.dom.d.ts\"\nconst libize = (path: string) => path.replace(\"/\", \"/lib.\").toLowerCase()\n\n/**\n * Creates an in-memory System object which can be used in a TypeScript program, this\n * is what provides read/write aspects of the virtual fs\n */\nexport function createSystem(files: Map<string, string>): System {\n return {\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory))\n }),\n exit: () => notImplemented(\"exit\"),\n fileExists: audit(\"fileExists\", fileName => files.has(fileName) || files.has(libize(fileName))),\n getCurrentDirectory: () => \"/\",\n getDirectories: () => [],\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", directory => (directory === \"/\" ? Array.from(files.keys()) : [])),\n readFile: audit(\"readFile\", fileName => files.get(fileName) || files.get(libize(fileName))),\n resolvePath: path => path,\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates a file-system backed System object which can be used in a TypeScript program, you provide\n * a set of virtual files which are prioritised over the FS versions, then a path to the root of your\n * project (basically the folder your node_modules lives)\n */\nexport function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS): System {\n // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the\n // existing node_modules structures going back through the history\n const root = _projectRoot + \"/vfs\"\n const path = require(\"path\")\n\n // The default System in TypeScript\n const nodeSys = ts.sys\n const tsLib = path.dirname(require.resolve(\"typescript\"))\n\n return {\n // @ts-ignore\n name: \"fs-vfs\",\n root,\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory)) || nodeSys.directoryExists(directory)\n }),\n exit: nodeSys.exit,\n fileExists: audit(\"fileExists\", fileName => {\n if (files.has(fileName)) return true\n // Don't let other tsconfigs end up touching the vfs\n if (fileName.includes(\"tsconfig.json\") || fileName.includes(\"tsconfig.json\")) return false\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n return nodeSys.fileExists(tsLibName)\n }\n return nodeSys.fileExists(fileName)\n }),\n getCurrentDirectory: () => root,\n getDirectories: nodeSys.getDirectories,\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", (...args) => {\n if (args[0] === \"/\") {\n return Array.from(files.keys())\n } else {\n return nodeSys.readDirectory(...args)\n }\n }),\n readFile: audit(\"readFile\", fileName => {\n if (files.has(fileName)) return files.get(fileName)\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n const result = nodeSys.readFile(tsLibName)\n if (!result) {\n const libs = nodeSys.readDirectory(tsLib)\n throw new Error(\n `TSVFS: A request was made for ${tsLibName} 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: ${libs}.`\n )\n }\n return result\n }\n return nodeSys.readFile(fileName)\n }),\n resolvePath: path => {\n if (files.has(path)) return path\n return nodeSys.resolvePath(path)\n },\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates an in-memory CompilerHost -which is essentially an extra wrapper to System\n * which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile\n * instances to the in-memory file system.\n */\nexport function createVirtualCompilerHost(sys: System, compilerOptions: CompilerOptions, ts: TS) {\n const sourceFiles = new Map<string, SourceFile>()\n const save = (sourceFile: SourceFile) => {\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return sourceFile\n }\n\n type Return = {\n compilerHost: CompilerHost\n updateFile: (sourceFile: SourceFile) => boolean\n }\n\n const vHost: Return = {\n compilerHost: {\n ...sys,\n getCanonicalFileName: fileName => fileName,\n getDefaultLibFileName: () => \"/\" + ts.getDefaultLibFileName(compilerOptions), // '/lib.d.ts',\n // getDefaultLibLocation: () => '/',\n getDirectories: () => [],\n getNewLine: () => sys.newLine,\n getSourceFile: fileName => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n compilerOptions.target || defaultCompilerOptions(ts).target!,\n false\n )\n )\n )\n },\n useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,\n },\n updateFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sys.writeFile(sourceFile.fileName, sourceFile.text)\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return alreadyExists\n },\n }\n return vHost\n}\n\n/**\n * Creates an object which can host a language service against the virtual file-system\n */\nexport function createVirtualLanguageServiceHost(\n sys: System,\n rootFiles: string[],\n compilerOptions: CompilerOptions,\n ts: TS,\n customTransformers?: CustomTransformers\n) {\n const fileNames = [...rootFiles]\n const { compilerHost, updateFile } = createVirtualCompilerHost(sys, compilerOptions, ts)\n const fileVersions = new Map<string, string>()\n let projectVersion = 0\n const languageServiceHost: LanguageServiceHost = {\n ...compilerHost,\n getProjectVersion: () => projectVersion.toString(),\n getCompilationSettings: () => compilerOptions,\n getCustomTransformers: () => customTransformers,\n getScriptFileNames: () => fileNames,\n getScriptSnapshot: fileName => {\n const contents = sys.readFile(fileName)\n if (contents) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","shouldDebug","getItem","env","DEBUG","debugLog","console","log","_message","createVirtualTypeScriptEnvironment","sys","rootFiles","ts","compilerOptions","customTransformers","mergedCompilerOpts","defaultCompilerOptions","createVirtualLanguageServiceHost","languageServiceHost","updateFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","getProgram","createFile","content","createSourceFile","target","optPrevTextSpan","prevSourceFile","prevFullContents","text","prevTextSpan","createTextSpan","newText","slice","start","newSourceFile","updateSourceFile","span","newLength","knownLibFilesForCompilerOptions","ScriptTarget","ES5","lib","files","targetToCut","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","getMax","array","reduce","max","current","undefined","indexesForCutting","map","cutIndex","libCutIndex","finalCutIndex","Math","createDefaultMapFromNodeModules","tsModule","require","path","fs","getLib","dirname","resolve","readFileSync","join","libs","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","readdirSync","file","stat","statSync","isDirectory","concat","push","allFiles","fsPath","replace","validExtensions","includes","extname","addFilesForTypesIntoFolder","createDefaultMapFromCDN","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","storelike","prefix","zip","str","compressToUTF16","unzip","decompressFromUTF16","uncached","Promise","all","then","resp","contents","index","cached","keys","Object","key","removeItem","cacheKey","t","setItem","func","notImplemented","methodName","audit","fn","args","res","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAtB;;AACA,IAAI;AACFA,EAAAA,eAAe,GAAG,OAAOC,YAAP,gBAAlB;AACD,CAFD,CAEE,OAAOC,KAAP,EAAc;;AAEhB,IAAMC,UAAU,GAAG,OAAOC,OAAP,gBAAnB;AACA,IAAMC,WAAW,GAAIL,eAAe;AAAA;AAAIC,YAAY,CAACK,OAAb,CAAqB,OAArB,CAApB,IAAuDH,UAAU,IAAIC,OAAO,CAACG,GAAR,CAAYC,KAArG;AACA,IAAMC,QAAQ,GAAGJ,WAAW,GAAGK,OAAO,CAACC,GAAX,GAAiB,UAACC,QAAD;AAAA,SAA+C,EAA/C;AAAA,CAA7C;AAUA;;;;;;;;;;;SAWgBC,mCACdC,KACAC,WACAC,IACAC,iBACAC;MADAD;AAAAA,IAAAA,kBAAmC;;;AAGnC,MAAME,kBAAkB,gBAAQC,sBAAsB,CAACJ,EAAD,CAA9B,EAAuCC,eAAvC,CAAxB;;8BAE4CI,gCAAgC,CAC1EP,GAD0E,EAE1EC,SAF0E,EAG1EI,kBAH0E,EAI1EH,EAJ0E,EAK1EE,kBAL0E;MAApEI,4CAAAA;MAAqBC,oCAAAA;;AAO7B,MAAMC,eAAe,GAAGR,EAAE,CAACS,qBAAH,CAAyBH,mBAAzB,CAAxB;AACA,MAAMI,WAAW,GAAGF,eAAe,CAACG,6BAAhB,EAApB;;AAEA,MAAID,WAAW,CAACE,MAAhB,EAAwB;AACtB,QAAMC,YAAY,GAAGC,yBAAyB,CAAChB,GAAD,EAAMG,eAAN,EAAuBD,EAAvB,CAA9C;AACA,UAAM,IAAIe,KAAJ,CAAUf,EA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AAA,SAAS,CAACnG,IAAV,CAAe6F,UAAU,CAACrK,QAA1B;AACD;;AACDZ,MAAAA,YAAU,CAACiL,UAAD,CAAV;AACD;AAToB,GAAvB;AAWA,SAAOkB,MAAP;AACD;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"vfs.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) { }\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n const files = [\n \"lib.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.promise.d.ts\",\n \"lib.esnext.string.d.ts\",\n \"lib.esnext.weakref.d.ts\",\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n */\nexport const createDefaultMapFromNodeModules = (compilerOptions: CompilerOptions, ts?: typeof import(\"typescript\"), tsLibDirectory?: string) => {\n const tsModule = ts || require(\"typescript\")\n const path = requirePath()\n const fs = requireFS()\n\n const getLib = (name: string) => {\n const lib = tsLibDirectory || path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libs = knownLibFilesForCompilerOptions(compilerOptions, tsModule)\n const fsMap = new Map<string, string>()\n libs.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = requirePath()\n const fs = requireFS()\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text()))).then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n }\n\n // A localstorage and lzzip aware version of the lib files\n function cached() {\n const storelike = storer || localStorage\n\n const keys = Object.keys(localStorage)\n keys.forEach(key => {\n // Remove anything which isn't from this version\n if (key.startsWith(\"ts-lib-\") && !key.startsWith(\"ts-lib-\" + version)) {\n storelike.removeItem(key)\n }\n })\n\n return Promise.all(\n files.map(lib => {\n const cacheKey = `ts-lib-${version}-${lib}`\n const content = storelike.getItem(cacheKey)\n\n if (!content) {\n // Make the API call and store the text concent in the cache\n return fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n })\n })\n }\n\n const func = cache ? cached : uncached\n return func().then(() => fsMap)\n}\n\nfunction notImplemented(methodName: string): any {\n throw new Error(`Method '${methodName}' is not implemented.`)\n}\n\nfunction audit<ArgsT extends any[], ReturnT>(\n name: string,\n fn: (...args: ArgsT) => ReturnT\n): (...args: ArgsT) => ReturnT {\n return (...args) => {\n const res = fn(...args)\n\n const smallres = typeof res === \"string\" ? res.slice(0, 80) + \"...\" : res\n debugLog(\"> \" + name, ...args)\n debugLog(\"< \" + smallres)\n\n return res\n }\n}\n\n/** The default compiler options if TypeScript could ever change the compiler options */\nconst defaultCompilerOptions = (ts: typeof import(\"typescript\")): CompilerOptions => {\n return {\n ...ts.getDefaultCompilerOptions(),\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n module: ts.ModuleKind.ESNext,\n suppressOutputPathCheck: true,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n }\n}\n\n// \"/DOM.d.ts\" => \"/lib.dom.d.ts\"\nconst libize = (path: string) => path.replace(\"/\", \"/lib.\").toLowerCase()\n\n/**\n * Creates an in-memory System object which can be used in a TypeScript program, this\n * is what provides read/write aspects of the virtual fs\n */\nexport function createSystem(files: Map<string, string>): System {\n return {\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory))\n }),\n exit: () => notImplemented(\"exit\"),\n fileExists: audit(\"fileExists\", fileName => files.has(fileName) || files.has(libize(fileName))),\n getCurrentDirectory: () => \"/\",\n getDirectories: () => [],\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", directory => (directory === \"/\" ? Array.from(files.keys()) : [])),\n readFile: audit(\"readFile\", fileName => files.get(fileName) || files.get(libize(fileName))),\n resolvePath: path => path,\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates a file-system backed System object which can be used in a TypeScript program, you provide\n * a set of virtual files which are prioritised over the FS versions, then a path to the root of your\n * project (basically the folder your node_modules lives)\n */\nexport function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS, tsLibDirectory?: string): System {\n // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the\n // existing node_modules structures going back through the history\n const root = _projectRoot + \"/vfs\"\n const path = requirePath()\n\n // The default System in TypeScript\n const nodeSys = ts.sys\n const tsLib = tsLibDirectory ?? path.dirname(require.resolve(\"typescript\"))\n\n return {\n // @ts-ignore\n name: \"fs-vfs\",\n root,\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory)) || nodeSys.directoryExists(directory)\n }),\n exit: nodeSys.exit,\n fileExists: audit(\"fileExists\", fileName => {\n if (files.has(fileName)) return true\n // Don't let other tsconfigs end up touching the vfs\n if (fileName.includes(\"tsconfig.json\") || fileName.includes(\"tsconfig.json\")) return false\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n return nodeSys.fileExists(tsLibName)\n }\n return nodeSys.fileExists(fileName)\n }),\n getCurrentDirectory: () => root,\n getDirectories: nodeSys.getDirectories,\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", (...args) => {\n if (args[0] === \"/\") {\n return Array.from(files.keys())\n } else {\n return nodeSys.readDirectory(...args)\n }\n }),\n readFile: audit(\"readFile\", fileName => {\n if (files.has(fileName)) return files.get(fileName)\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n const result = nodeSys.readFile(tsLibName)\n if (!result) {\n const libs = nodeSys.readDirectory(tsLib)\n throw new Error(\n `TSVFS: A request was made for ${tsLibName} 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: ${libs}.`\n )\n }\n return result\n }\n return nodeSys.readFile(fileName)\n }),\n resolvePath: path => {\n if (files.has(path)) return path\n return nodeSys.resolvePath(path)\n },\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates an in-memory CompilerHost -which is essentially an extra wrapper to System\n * which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile\n * instances to the in-memory file system.\n */\nexport function createVirtualCompilerHost(sys: System, compilerOptions: CompilerOptions, ts: TS) {\n const sourceFiles = new Map<string, SourceFile>()\n const save = (sourceFile: SourceFile) => {\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return sourceFile\n }\n\n type Return = {\n compilerHost: CompilerHost\n updateFile: (sourceFile: SourceFile) => boolean\n }\n\n const vHost: Return = {\n compilerHost: {\n ...sys,\n getCanonicalFileName: fileName => fileName,\n getDefaultLibFileName: () => \"/\" + ts.getDefaultLibFileName(compilerOptions), // '/lib.d.ts',\n // getDefaultLibLocation: () => '/',\n getDirectories: () => [],\n getNewLine: () => sys.newLine,\n getSourceFile: fileName => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n compilerOptions.target || defaultCompilerOptions(ts).target!,\n false\n )\n )\n )\n },\n useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,\n },\n updateFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sys.writeFile(sourceFile.fileName, sourceFile.text)\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return alreadyExists\n },\n }\n return vHost\n}\n\n/**\n * Creates an object which can host a language service against the virtual file-system\n */\nexport function createVirtualLanguageServiceHost(\n sys: System,\n rootFiles: string[],\n compilerOptions: CompilerOptions,\n ts: TS,\n customTransformers?: CustomTransformers\n) {\n const fileNames = [...rootFiles]\n const { compilerHost, updateFile } = createVirtualCompilerHost(sys, compilerOptions, ts)\n const fileVersions = new Map<string, string>()\n let projectVersion = 0\n const languageServiceHost: LanguageServiceHost = {\n ...compilerHost,\n getProjectVersion: () => projectVersion.toString(),\n getCompilationSettings: () => compilerOptions,\n getCustomTransformers: () => customTransformers,\n // A couple weeks of 4.8 TypeScript nightlies had a bug where the Program's\n // list of files was just a reference to the array returned by this host method,\n // which means mutations by the host that ought to result in a new Program being\n // created were not detected, since the old list of files and the new list of files\n // were in fact a reference to the same underlying array. That was fixed in\n // https://github.com/microsoft/TypeScript/pull/49813, but since the twoslash runner\n // is used in bisecting for changes, it needs to guard against being busted in that\n // couple-week period, so we defensively make a slice here.\n getScriptFileNames: () => fileNames.slice(),\n getScriptSnapshot: fileName => {\n const contents = sys.readFile(fileName)\n if (contents) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n\nconst requirePath = () => {\n return require(String.fromCharCode(112, 97, 116, 104)) as typeof import(\"path\")\n}\n\nconst requireFS = () => {\n return require(String.fromCharCode(102, 115)) as typeof import(\"fs\")\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","shouldDebug","getItem","env","DEBUG","debugLog","console","log","_message","createVirtualTypeScriptEnvironment","sys","rootFiles","ts","compilerOptions","customTransformers","mergedCompilerOpts","defaultCompilerOptions","createVirtualLanguageServiceHost","languageServiceHost","updateFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","getProgram","createFile","content","createSourceFile","target","optPrevTextSpan","prevSourceFile","prevFullContents","text","prevTextSpan","createTextSpan","newText","slice","start","newSourceFile","updateSourceFile","span","newLength","knownLibFilesForCompilerOptions","ScriptTarget","ES5","lib","files","targetToCut","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","getMax","array","reduce","max","current","undefined","indexesForCutting","map","cutIndex","libCutIndex","finalCutIndex","Math","createDefaultMapFromNodeModules","tsLibDirectory","tsModule","require","path","requirePath","fs","requireFS","getLib","dirname","resolve","readFileSync","join","libs","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","readdirSync","file","stat","statSync","isDirectory","concat","push","allFiles","fsPath","replace","validExtensions","includes","extname","addFilesForTypesIntoFolder","createDefaultMapFromCDN","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","prefix","zip","str","compressToUTF16","unzip","decompressFromUTF16","uncached","Promise","all","then","resp","contents","index","cached","storelike","keys","Object","key","removeItem","cacheKey","t","setItem","func","notImplemented","methodName","audit","fn","args","res","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAtB;;AACA,IAAI;AACFA,EAAAA,eAAe,GAAG,OAAOC,YAAP,gBAAlB;AACD,CAFD,CAEE,OAAOC,KAAP,EAAc;;AAEhB,IAAMC,UAAU,GAAG,OAAOC,OAAP,gBAAnB;AACA,IAAMC,WAAW,GAAIL,eAAe,iBAAIC,YAAY,CAACK,OAAb,CAAqB,OAArB,CAApB,IAAuDH,UAAU,IAAIC,OAAO,CAACG,GAAR,CAAYC,KAArG;AACA,IAAMC,QAAQ,GAAGJ,WAAW,GAAGK,OAAO,CAACC,GAAX,GAAiB,UAACC,QAAD;AAAA,SAA+C,EAA/C;AAAA,CAA7C;AAUA;;;;;;;;;;;SAWgBC,mCACdC,KACAC,WACAC,IACAC,iBACAC;MADAD;AAAAA,IAAAA,kBAAmC;;;AAGnC,MAAME,kBAAkB,gBAAQC,sBAAsB,CAACJ,EAAD,CAA9B,EAAuCC,eAAvC,CAAxB;;8BAE4CI,gCAAgC,CAC1EP,GAD0E,EAE1EC,SAF0E,EAG1EI,kBAH0E,EAI1EH,EAJ0E,EAK1EE,kBAL0E;MAApEI,4CAAAA;MAAqBC,oCAAAA;;AAO7B,MAAMC,eAAe,GAAGR,EAAE,CAACS,qBAAH,CAAyBH,mBAAzB,CAAxB;AACA,MAAMI,WAAW,GAAGF,eAAe,CAACG,6BAAhB,EAApB;;AAEA,MAAID,WAAW,CAACE,MAAhB,EAAwB;AACtB,QAAMC,YAAY,GAAGC,yBAAyB,CAAChB,GAAD,EAAMG,eAAN,EA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,YAAY,CAACjH,GAAb,CAAiB0G,UAAU,CAACxK,QAA5B,EAAsCgL,cAAc,CAACE,QAAf,EAAtC;;AACA,UAAI,CAACJ,SAAS,CAAC9F,QAAV,CAAmBwF,UAAU,CAACxK,QAA9B,CAAL,EAA8C;AAC5C8K,QAAAA,SAAS,CAACnG,IAAV,CAAe6F,UAAU,CAACxK,QAA1B;AACD;;AACDZ,MAAAA,YAAU,CAACoL,UAAD,CAAV;AACD;AAToB,GAAvB;AAWA,SAAOkB,MAAP;AACD;;AAED,IAAMxI,WAAW,GAAG,SAAdA,WAAc;AAClB,SAAOF,OAAO,CAAC2I,MAAM,CAACC,YAAP,CAAoB,GAApB,EAAyB,EAAzB,EAA6B,GAA7B,EAAkC,GAAlC,CAAD,CAAd;AACD,CAFD;;AAIA,IAAMxI,SAAS,GAAG,SAAZA,SAAY;AAChB,SAAOJ,OAAO,CAAC2I,MAAM,CAACC,YAAP,CAAoB,GAApB,EAAyB,GAAzB,CAAD,CAAd;AACD,CAFD;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "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.dom.d.ts","lib.dom.iterable.d.ts","lib.webworker.d.ts","lib.webworker.importscripts.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.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.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2020.d.ts","lib.es2020.full.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2020.bigint.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.intl.d.ts","lib.esnext.array.d.ts","lib.esnext.asynciterable.d.ts","lib.esnext.bigint.d.ts","lib.esnext.d.ts","lib.esnext.full.d.ts","lib.esnext.intl.d.ts","lib.esnext.symbol.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=require("path"),i=require("fs");(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 f(t,r,i,n,s){var o=[].concat(r),l=c(t,i,n),a=l.compilerHost,u=l.updateFile,f=new Map,d=0;return{languageServiceHost:e({},a,{getProjectVersion:function(){return d.toString()},getCompilationSettings:function(){return i},getCustomTransformers:function(){return s},getScriptFileNames:function(){return o},getScriptSnapshot:function(e){var r=t.readFile(e);if(r)return n.ScriptSnapshot.fromString(r)},getScriptVersion:function(e){return f.get(e)||"0"},writeFile:t.writeFile}),updateFile:function(e){d++,f.set(e.fileName,d.toString()),o.includes(e.fileName)||o.push(e.fileName),u(e)}}}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=l||localStorage,c=new Map,f=n(e,i),d="https://typescript.azureedge.net/cdn/"+t+"/typescript/lib/";return(r?function(){return Object.keys(localStorage).forEach((function(e){e.startsWith("ts-lib-")&&!e.startsWith("ts-lib-"+t)&&u.removeItem(e)})),Promise.all(f.map((function(e){var r,i="ts-lib-"+t+"-"+e,n=u.getItem(i);return n?Promise.resolve((r=n,s?s.decompressFromUTF16(r):r)):a(d+e).then((function(e){return e.text()})).then((function(e){var t;return u.setItem(i,(t=e,s?s.compressToUTF16(t):t)),e}))}))).then((function(e){e.forEach((function(e,t){c.set("/"+f[t],e)}))}))}:function(){return Promise.all(f.map((function(e){return a(d+e).then((function(e){return e.text()}))}))).then((function(e){e.forEach((function(e,t){return c.set("/"+f[t],e)}))}))})().then((function(){return c}))},exports.createDefaultMapFromNodeModules=function(e,t){var r=t||require("typescript"),i=require("path"),s=require("fs"),o=n(e,r),l=new Map;return o.forEach((function(e){l.set("/"+e,function(e){var t=i.dirname(require.resolve("typescript"));return s.readFileSync(i.join(t,e),"utf8")}(e))})),l},exports.createFSBackedSystem=function(e,t,r){var i=t+"/vfs",n=require("path"),s=r.sys,a=n.dirname(require.resolve("typescript"));return{name:"fs-vfs",root:i,args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))||s.directoryExists(t)})),exit:s.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=a+"/"+t.replace("/","");return s.fileExists(r)}return s.fileExists(t)})),getCurrentDirectory:function(){return i},getDirectories:s.getDirectories,getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(){return"/"===(arguments.length<=0?void 0:arguments[0])?Array.from(e.keys()):s.readDirectory.apply(s,arguments)})),readFile:l("readFile",(function(t){if(e.has(t))return e.get(t);if(t.startsWith("/lib")){var r=a+"/"+t.replace("/",""),i=s.readFile(r);if(!i){var n=s.readDirectory(a);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 s.readFile(t)})),resolvePath:function(t){return e.has(t)?t:s.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=f,exports.createVirtualTypeScriptEnvironment=function(t,r,i,n,s){void 0===n&&(n={});var o=e({},a(i),n),l=f(t,r,o,i,s),u=l.updateFile,d=i.createLanguageService(l.languageServiceHost),p=d.getCompilerOptionsDiagnostics();if(p.length){var g=c(t,n,i);throw new Error(i.formatDiagnostics(p,g.compilerHost))}return{name:"vfs",sys:t,languageService:d,getSourceFile:function(e){var t;return null==(t=d.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=d.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;
1
+ "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.dom.d.ts","lib.dom.iterable.d.ts","lib.webworker.d.ts","lib.webworker.importscripts.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.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.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2020.d.ts","lib.es2020.full.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2020.bigint.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.intl.d.ts","lib.es2021.d.ts","lib.es2021.full.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.esnext.d.ts","lib.esnext.full.d.ts","lib.esnext.intl.d.ts","lib.esnext.promise.d.ts","lib.esnext.string.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=d(),i=p();(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 f(t,r,i,n,s){var o=[].concat(r),l=c(t,i,n),a=l.compilerHost,u=l.updateFile,f=new Map,d=0;return{languageServiceHost:e({},a,{getProjectVersion:function(){return d.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 f.get(e)||"0"},writeFile:t.writeFile}),updateFile:function(e){d++,f.set(e.fileName,d.toString()),o.includes(e.fileName)||o.push(e.fileName),u(e)}}}var d=function(){return require(String.fromCharCode(112,97,116,104))},p=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),f="https://typescript.azureedge.net/cdn/"+t+"/typescript/lib/";return(r?function(){var e=l||localStorage;return Object.keys(localStorage).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(f+r).then((function(e){return e.text()})).then((function(t){var r;return e.setItem(n,(r=t,s?s.compressToUTF16(r):r)),t}))}))).then((function(e){e.forEach((function(e,t){u.set("/"+c[t],e)}))}))}:function(){return Promise.all(c.map((function(e){return a(f+e).then((function(e){return e.text()}))}))).then((function(e){e.forEach((function(e,t){return u.set("/"+c[t],e)}))}))})().then((function(){return u}))},exports.createDefaultMapFromNodeModules=function(e,t,r){var i=t||require("typescript"),s=d(),o=p(),l=n(e,i),a=new Map;return l.forEach((function(e){a.set("/"+e,function(e){var t=r||s.dirname(require.resolve("typescript"));return o.readFileSync(s.join(t,e),"utf8")}(e))})),a},exports.createFSBackedSystem=function(e,t,r,i){var n=t+"/vfs",s=d(),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=f,exports.createVirtualTypeScriptEnvironment=function(t,r,i,n,s){void 0===n&&(n={});var o=e({},a(i),n),l=f(t,r,o,i,s),u=l.updateFile,d=i.createLanguageService(l.languageServiceHost),p=d.getCompilerOptionsDiagnostics();if(p.length){var g=c(t,n,i);throw new Error(i.formatDiagnostics(p,g.compilerHost))}return{name:"vfs",sys:t,languageService:d,getSourceFile:function(e){var t;return null==(t=d.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=d.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;
2
2
  //# sourceMappingURL=vfs.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vfs.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) {}\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n const files = [\n \"lib.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.esnext.array.d.ts\",\n \"lib.esnext.asynciterable.d.ts\",\n \"lib.esnext.bigint.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.symbol.d.ts\",\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n */\nexport const createDefaultMapFromNodeModules = (compilerOptions: CompilerOptions, ts?: typeof import(\"typescript\")) => {\n const tsModule = ts || require(\"typescript\")\n const path = require(\"path\")\n const fs = require(\"fs\")\n\n const getLib = (name: string) => {\n const lib = path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libs = knownLibFilesForCompilerOptions(compilerOptions, tsModule)\n const fsMap = new Map<string, string>()\n libs.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = require(\"path\")\n const fs = require(\"fs\")\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const storelike = storer || localStorage\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text()))).then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n }\n\n // A localstorage and lzzip aware version of the lib files\n function cached() {\n const keys = Object.keys(localStorage)\n keys.forEach(key => {\n // Remove anything which isn't from this version\n if (key.startsWith(\"ts-lib-\") && !key.startsWith(\"ts-lib-\" + version)) {\n storelike.removeItem(key)\n }\n })\n\n return Promise.all(\n files.map(lib => {\n const cacheKey = `ts-lib-${version}-${lib}`\n const content = storelike.getItem(cacheKey)\n\n if (!content) {\n // Make the API call and store the text concent in the cache\n return fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n })\n })\n }\n\n const func = cache ? cached : uncached\n return func().then(() => fsMap)\n}\n\nfunction notImplemented(methodName: string): any {\n throw new Error(`Method '${methodName}' is not implemented.`)\n}\n\nfunction audit<ArgsT extends any[], ReturnT>(\n name: string,\n fn: (...args: ArgsT) => ReturnT\n): (...args: ArgsT) => ReturnT {\n return (...args) => {\n const res = fn(...args)\n\n const smallres = typeof res === \"string\" ? res.slice(0, 80) + \"...\" : res\n debugLog(\"> \" + name, ...args)\n debugLog(\"< \" + smallres)\n\n return res\n }\n}\n\n/** The default compiler options if TypeScript could ever change the compiler options */\nconst defaultCompilerOptions = (ts: typeof import(\"typescript\")): CompilerOptions => {\n return {\n ...ts.getDefaultCompilerOptions(),\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n module: ts.ModuleKind.ESNext,\n suppressOutputPathCheck: true,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n }\n}\n\n// \"/DOM.d.ts\" => \"/lib.dom.d.ts\"\nconst libize = (path: string) => path.replace(\"/\", \"/lib.\").toLowerCase()\n\n/**\n * Creates an in-memory System object which can be used in a TypeScript program, this\n * is what provides read/write aspects of the virtual fs\n */\nexport function createSystem(files: Map<string, string>): System {\n return {\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory))\n }),\n exit: () => notImplemented(\"exit\"),\n fileExists: audit(\"fileExists\", fileName => files.has(fileName) || files.has(libize(fileName))),\n getCurrentDirectory: () => \"/\",\n getDirectories: () => [],\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", directory => (directory === \"/\" ? Array.from(files.keys()) : [])),\n readFile: audit(\"readFile\", fileName => files.get(fileName) || files.get(libize(fileName))),\n resolvePath: path => path,\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates a file-system backed System object which can be used in a TypeScript program, you provide\n * a set of virtual files which are prioritised over the FS versions, then a path to the root of your\n * project (basically the folder your node_modules lives)\n */\nexport function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS): System {\n // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the\n // existing node_modules structures going back through the history\n const root = _projectRoot + \"/vfs\"\n const path = require(\"path\")\n\n // The default System in TypeScript\n const nodeSys = ts.sys\n const tsLib = path.dirname(require.resolve(\"typescript\"))\n\n return {\n // @ts-ignore\n name: \"fs-vfs\",\n root,\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory)) || nodeSys.directoryExists(directory)\n }),\n exit: nodeSys.exit,\n fileExists: audit(\"fileExists\", fileName => {\n if (files.has(fileName)) return true\n // Don't let other tsconfigs end up touching the vfs\n if (fileName.includes(\"tsconfig.json\") || fileName.includes(\"tsconfig.json\")) return false\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n return nodeSys.fileExists(tsLibName)\n }\n return nodeSys.fileExists(fileName)\n }),\n getCurrentDirectory: () => root,\n getDirectories: nodeSys.getDirectories,\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", (...args) => {\n if (args[0] === \"/\") {\n return Array.from(files.keys())\n } else {\n return nodeSys.readDirectory(...args)\n }\n }),\n readFile: audit(\"readFile\", fileName => {\n if (files.has(fileName)) return files.get(fileName)\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n const result = nodeSys.readFile(tsLibName)\n if (!result) {\n const libs = nodeSys.readDirectory(tsLib)\n throw new Error(\n `TSVFS: A request was made for ${tsLibName} 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: ${libs}.`\n )\n }\n return result\n }\n return nodeSys.readFile(fileName)\n }),\n resolvePath: path => {\n if (files.has(path)) return path\n return nodeSys.resolvePath(path)\n },\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates an in-memory CompilerHost -which is essentially an extra wrapper to System\n * which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile\n * instances to the in-memory file system.\n */\nexport function createVirtualCompilerHost(sys: System, compilerOptions: CompilerOptions, ts: TS) {\n const sourceFiles = new Map<string, SourceFile>()\n const save = (sourceFile: SourceFile) => {\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return sourceFile\n }\n\n type Return = {\n compilerHost: CompilerHost\n updateFile: (sourceFile: SourceFile) => boolean\n }\n\n const vHost: Return = {\n compilerHost: {\n ...sys,\n getCanonicalFileName: fileName => fileName,\n getDefaultLibFileName: () => \"/\" + ts.getDefaultLibFileName(compilerOptions), // '/lib.d.ts',\n // getDefaultLibLocation: () => '/',\n getDirectories: () => [],\n getNewLine: () => sys.newLine,\n getSourceFile: fileName => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n compilerOptions.target || defaultCompilerOptions(ts).target!,\n false\n )\n )\n )\n },\n useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,\n },\n updateFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sys.writeFile(sourceFile.fileName, sourceFile.text)\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return alreadyExists\n },\n }\n return vHost\n}\n\n/**\n * Creates an object which can host a language service against the virtual file-system\n */\nexport function createVirtualLanguageServiceHost(\n sys: System,\n rootFiles: string[],\n compilerOptions: CompilerOptions,\n ts: TS,\n customTransformers?: CustomTransformers\n) {\n const fileNames = [...rootFiles]\n const { compilerHost, updateFile } = createVirtualCompilerHost(sys, compilerOptions, ts)\n const fileVersions = new Map<string, string>()\n let projectVersion = 0\n const languageServiceHost: LanguageServiceHost = {\n ...compilerHost,\n getProjectVersion: () => projectVersion.toString(),\n getCompilationSettings: () => compilerOptions,\n getCustomTransformers: () => customTransformers,\n getScriptFileNames: () => fileNames,\n getScriptSnapshot: fileName => {\n const contents = sys.readFile(fileName)\n if (contents) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","debugLog","getItem","env","DEBUG","console","log","_message","knownLibFilesForCompilerOptions","compilerOptions","ts","array","lib","files","targetToCut","ScriptTarget","target","ES5","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","libCutIndex","map","length","reduce","max","current","undefined","finalCutIndex","Math","slice","addAllFilesFromFolder","workingDir","path","require","fs","walk","dir","results","readdirSync","forEach","file","join","stat","statSync","isDirectory","concat","push","fsPath","replace","content","readFileSync","includes","extname","set","notImplemented","methodName","Error","audit","name","fn","args","res","smallres","defaultCompilerOptions","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createVirtualCompilerHost","sys","sourceFiles","Map","compilerHost","getCanonicalFileName","fileName","getDefaultLibFileName","getDirectories","getNewLine","newLine","getSourceFile","get","sourceFile","createSourceFile","readFile","useCaseSensitiveFileNames","updateFile","alreadyExists","has","writeFile","text","createVirtualLanguageServiceHost","rootFiles","customTransformers","fileNames","fileVersions","projectVersion","languageServiceHost","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","contents","ScriptSnapshot","fromString","getScriptVersion","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","storelike","fsMap","prefix","Object","keys","key","removeItem","Promise","all","str","cacheKey","resolve","decompressFromUTF16","then","resp","t","setItem","compressToUTF16","index","tsModule","libs","dirname","getLib","_projectRoot","root","nodeSys","tsLib","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","tsLibName","getCurrentDirectory","getExecutingFilePath","readDirectory","result","resolvePath","write","mergedCompilerOpts","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","formatDiagnostics","getProgram","_languageService$getP","createFile","optPrevTextSpan","prevSourceFile","prevFullContents","prevTextSpan","createTextSpan","newText","start","newSourceFile","updateSourceFile","span","newLength"],"mappings":"mRAQA,IAAIA,GAAkB,EACtB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G0F,iBAAiBR,EAAUrC,EAASwH,EAAmB/J,QAAS,KAEhFuF,WAAY,SAACX,EAAUrC,EAASiI,OACxBC,EAAiBT,EAAgBK,aAAcpF,cAAcL,OAC9D6F,QACG,IAAI3H,MAAM,kCAAoC8B,OAEhD8F,EAAmBD,EAAe9E,KAGlCgF,QAAeH,EAAAA,EAAmB9K,EAAGkL,eAAe,EAAGF,EAAiB9J,QACxEiK,EACJH,EAAiBvJ,MAAM,EAAGwJ,EAAaG,OACvCvI,EACAmI,EAAiBvJ,MAAMwJ,EAAaG,MAAQH,EAAa/J,QACrDmK,EAAgBrL,EAAGsL,iBAAiBP,EAAgBI,EAAS,CACjEI,KAAMN,EACNO,UAAW3I,EAAQ3B,SAGrB2E,EAAWwF"}
1
+ {"version":3,"file":"vfs.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) { }\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n const files = [\n \"lib.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.promise.d.ts\",\n \"lib.esnext.string.d.ts\",\n \"lib.esnext.weakref.d.ts\",\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n */\nexport const createDefaultMapFromNodeModules = (compilerOptions: CompilerOptions, ts?: typeof import(\"typescript\"), tsLibDirectory?: string) => {\n const tsModule = ts || require(\"typescript\")\n const path = requirePath()\n const fs = requireFS()\n\n const getLib = (name: string) => {\n const lib = tsLibDirectory || path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libs = knownLibFilesForCompilerOptions(compilerOptions, tsModule)\n const fsMap = new Map<string, string>()\n libs.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = requirePath()\n const fs = requireFS()\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text()))).then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n }\n\n // A localstorage and lzzip aware version of the lib files\n function cached() {\n const storelike = storer || localStorage\n\n const keys = Object.keys(localStorage)\n keys.forEach(key => {\n // Remove anything which isn't from this version\n if (key.startsWith(\"ts-lib-\") && !key.startsWith(\"ts-lib-\" + version)) {\n storelike.removeItem(key)\n }\n })\n\n return Promise.all(\n files.map(lib => {\n const cacheKey = `ts-lib-${version}-${lib}`\n const content = storelike.getItem(cacheKey)\n\n if (!content) {\n // Make the API call and store the text concent in the cache\n return fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n })\n })\n }\n\n const func = cache ? cached : uncached\n return func().then(() => fsMap)\n}\n\nfunction notImplemented(methodName: string): any {\n throw new Error(`Method '${methodName}' is not implemented.`)\n}\n\nfunction audit<ArgsT extends any[], ReturnT>(\n name: string,\n fn: (...args: ArgsT) => ReturnT\n): (...args: ArgsT) => ReturnT {\n return (...args) => {\n const res = fn(...args)\n\n const smallres = typeof res === \"string\" ? res.slice(0, 80) + \"...\" : res\n debugLog(\"> \" + name, ...args)\n debugLog(\"< \" + smallres)\n\n return res\n }\n}\n\n/** The default compiler options if TypeScript could ever change the compiler options */\nconst defaultCompilerOptions = (ts: typeof import(\"typescript\")): CompilerOptions => {\n return {\n ...ts.getDefaultCompilerOptions(),\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n module: ts.ModuleKind.ESNext,\n suppressOutputPathCheck: true,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n }\n}\n\n// \"/DOM.d.ts\" => \"/lib.dom.d.ts\"\nconst libize = (path: string) => path.replace(\"/\", \"/lib.\").toLowerCase()\n\n/**\n * Creates an in-memory System object which can be used in a TypeScript program, this\n * is what provides read/write aspects of the virtual fs\n */\nexport function createSystem(files: Map<string, string>): System {\n return {\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory))\n }),\n exit: () => notImplemented(\"exit\"),\n fileExists: audit(\"fileExists\", fileName => files.has(fileName) || files.has(libize(fileName))),\n getCurrentDirectory: () => \"/\",\n getDirectories: () => [],\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", directory => (directory === \"/\" ? Array.from(files.keys()) : [])),\n readFile: audit(\"readFile\", fileName => files.get(fileName) || files.get(libize(fileName))),\n resolvePath: path => path,\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates a file-system backed System object which can be used in a TypeScript program, you provide\n * a set of virtual files which are prioritised over the FS versions, then a path to the root of your\n * project (basically the folder your node_modules lives)\n */\nexport function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS, tsLibDirectory?: string): System {\n // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the\n // existing node_modules structures going back through the history\n const root = _projectRoot + \"/vfs\"\n const path = requirePath()\n\n // The default System in TypeScript\n const nodeSys = ts.sys\n const tsLib = tsLibDirectory ?? path.dirname(require.resolve(\"typescript\"))\n\n return {\n // @ts-ignore\n name: \"fs-vfs\",\n root,\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory)) || nodeSys.directoryExists(directory)\n }),\n exit: nodeSys.exit,\n fileExists: audit(\"fileExists\", fileName => {\n if (files.has(fileName)) return true\n // Don't let other tsconfigs end up touching the vfs\n if (fileName.includes(\"tsconfig.json\") || fileName.includes(\"tsconfig.json\")) return false\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n return nodeSys.fileExists(tsLibName)\n }\n return nodeSys.fileExists(fileName)\n }),\n getCurrentDirectory: () => root,\n getDirectories: nodeSys.getDirectories,\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", (...args) => {\n if (args[0] === \"/\") {\n return Array.from(files.keys())\n } else {\n return nodeSys.readDirectory(...args)\n }\n }),\n readFile: audit(\"readFile\", fileName => {\n if (files.has(fileName)) return files.get(fileName)\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n const result = nodeSys.readFile(tsLibName)\n if (!result) {\n const libs = nodeSys.readDirectory(tsLib)\n throw new Error(\n `TSVFS: A request was made for ${tsLibName} 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: ${libs}.`\n )\n }\n return result\n }\n return nodeSys.readFile(fileName)\n }),\n resolvePath: path => {\n if (files.has(path)) return path\n return nodeSys.resolvePath(path)\n },\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates an in-memory CompilerHost -which is essentially an extra wrapper to System\n * which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile\n * instances to the in-memory file system.\n */\nexport function createVirtualCompilerHost(sys: System, compilerOptions: CompilerOptions, ts: TS) {\n const sourceFiles = new Map<string, SourceFile>()\n const save = (sourceFile: SourceFile) => {\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return sourceFile\n }\n\n type Return = {\n compilerHost: CompilerHost\n updateFile: (sourceFile: SourceFile) => boolean\n }\n\n const vHost: Return = {\n compilerHost: {\n ...sys,\n getCanonicalFileName: fileName => fileName,\n getDefaultLibFileName: () => \"/\" + ts.getDefaultLibFileName(compilerOptions), // '/lib.d.ts',\n // getDefaultLibLocation: () => '/',\n getDirectories: () => [],\n getNewLine: () => sys.newLine,\n getSourceFile: fileName => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n compilerOptions.target || defaultCompilerOptions(ts).target!,\n false\n )\n )\n )\n },\n useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,\n },\n updateFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sys.writeFile(sourceFile.fileName, sourceFile.text)\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return alreadyExists\n },\n }\n return vHost\n}\n\n/**\n * Creates an object which can host a language service against the virtual file-system\n */\nexport function createVirtualLanguageServiceHost(\n sys: System,\n rootFiles: string[],\n compilerOptions: CompilerOptions,\n ts: TS,\n customTransformers?: CustomTransformers\n) {\n const fileNames = [...rootFiles]\n const { compilerHost, updateFile } = createVirtualCompilerHost(sys, compilerOptions, ts)\n const fileVersions = new Map<string, string>()\n let projectVersion = 0\n const languageServiceHost: LanguageServiceHost = {\n ...compilerHost,\n getProjectVersion: () => projectVersion.toString(),\n getCompilationSettings: () => compilerOptions,\n getCustomTransformers: () => customTransformers,\n // A couple weeks of 4.8 TypeScript nightlies had a bug where the Program's\n // list of files was just a reference to the array returned by this host method,\n // which means mutations by the host that ought to result in a new Program being\n // created were not detected, since the old list of files and the new list of files\n // were in fact a reference to the same underlying array. That was fixed in\n // https://github.com/microsoft/TypeScript/pull/49813, but since the twoslash runner\n // is used in bisecting for changes, it needs to guard against being busted in that\n // couple-week period, so we defensively make a slice here.\n getScriptFileNames: () => fileNames.slice(),\n getScriptSnapshot: fileName => {\n const contents = sys.readFile(fileName)\n if (contents) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n\nconst requirePath = () => {\n return require(String.fromCharCode(112, 97, 116, 104)) as typeof import(\"path\")\n}\n\nconst requireFS = () => {\n return require(String.fromCharCode(102, 115)) as typeof import(\"fs\")\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","debugLog","getItem","env","DEBUG","console","log","_message","knownLibFilesForCompilerOptions","compilerOptions","ts","array","lib","files","targetToCut","ScriptTarget","target","ES5","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","libCutIndex","map","length","reduce","max","current","undefined","finalCutIndex","Math","slice","addAllFilesFromFolder","workingDir","path","requirePath","fs","requireFS","walk","dir","results","readdirSync","forEach","file","join","stat","statSync","isDirectory","concat","push","fsPath","replace","content","readFileSync","includes","extname","set","notImplemented","methodName","Error","audit","name","fn","args","res","smallres","defaultCompilerOptions","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createVirtualCompilerHost","sys","sourceFiles","Map","compilerHost","getCanonicalFileName","fileName","getDefaultLibFileName","getDirectories","getNewLine","newLine","getSourceFile","get","sourceFile","createSourceFile","readFile","useCaseSensitiveFileNames","updateFile","alreadyExists","has","writeFile","text","createVirtualLanguageServiceHost","rootFiles","customTransformers","fileNames","fileVersions","projectVersion","languageServiceHost","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","contents","ScriptSnapshot","fromString","getScriptVersion","require","String","fromCharCode","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","fsMap","prefix","storelike","Object","keys","key","removeItem","Promise","all","str","cacheKey","resolve","decompressFromUTF16","then","resp","t","setItem","compressToUTF16","index","tsLibDirectory","tsModule","libs","dirname","getLib","_projectRoot","root","nodeSys","tsLib","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","tsLibName","getCurrentDirectory","getExecutingFilePath","readDirectory","result","resolvePath","write","mergedCompilerOpts","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","formatDiagnostics","getProgram","_languageService$getP","createFile","optPrevTextSpan","prevSourceFile","prevFullContents","prevTextSpan","createTextSpan","newText","start","newSourceFile","updateSourceFile","span","newLength"],"mappings":"mRAQA,IAAIA,GAAkB,EACtB,IACEA,sBAAyBC,aACzB,MAAOC,IAET,IAAMC,sBAAoBC,QAEpBC,EADeL,GAAmBC,aAAaK,QAAQ,UAAcH,GAAcC,QAAQG,IAAIC,MACtEC,QAAQC,IAAM,SAACC,SAA8C,IAqF/EC,EAAkC,SAACC,EAAkCC,OAuEhEC,EArEVC,EAAMH,EAAgBG,KAAO,GAE7BC,EAAQ,CACZ,WACA,eACA,wBACA,qBACA,mCACA,sBACA,eACA,eACA,6BACA,uBACA,kBACA,4BACA,2BACA,0BACA,wBACA,0BACA,yBACA,mCACA,gCACA,kBACA,uBACA,kBACA,uBACA,uBACA,yBACA,+BACA,yBACA,8BACA,iCACA,gCACA,kBACA,uBACA,uBACA,0BACA,yBACA,wBACA,kBACA,uBACA,yBACA,yBACA,yBACA,kBACA,uBACA,yBACA,mCACA,yBACA,0BACA,+BACA,uBACA,kBACA,uBACA,0BACA,yBACA,0BACA,kBACA,uBACA,uBACA,0BACA,yBACA,2BAGIC,EAAcJ,EAAGK,aAlERN,EAAgBO,QAAUN,EAAGK,aAAaE,KAmEnDC,EAAUL,EAAMM,QAAO,SAAAC,UAAKA,EAAEC,kBAAkBP,EAAYQ,kBAC5DC,EAAiBV,EAAMW,QAAQN,EAAQO,OAcvCC,IAZUf,EAIUC,EAAIe,KA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AAe,UAC5B8C,UAAW,SAACd,EAAU6B,GACpB7G,EAAM+C,IAAIiC,EAAU6B,yIAtWxBlC,EACAsB,EACApG,EACAD,EACAsG,YADAtG,IAAAA,EAAmC,QAG7B2K,OAA0B9G,EAAuB5D,GAAQD,KAEnBoG,EAC1CrB,EACAsB,EACAsE,EACA1K,EACAqG,GAL2BP,IAAAA,WAOvB6E,EAAkB3K,EAAG4K,wBAPnBnE,qBAQFoE,EAAcF,EAAgBG,mCAEhCD,EAAY3J,OAAQ,KAChB+D,EAAeJ,EAA0BC,EAAK/E,EAAiBC,SAC/D,IAAIqD,MAAMrD,EAAG+K,kBAAkBF,EAAa5F,EAAaA,qBAG1D,CAEL1B,KAAM,MACNuB,IAAAA,EACA6F,gBAAAA,EACAnF,cAAe,SAAAL,yBAAYwF,EAAgBK,qBAAhBC,EAA8BzF,cAAcL,IAEvE+F,WAAY,SAAC/F,EAAUrC,GACrBgD,EAAW9F,EAAG2F,iBAAiBR,EAAUrC,EAAS4H,EAAmBpK,QAAS,KAEhFwF,WAAY,SAACX,EAAUrC,EAASqI,OACxBC,EAAiBT,EAAgBK,aAAcxF,cAAcL,OAC9DiG,QACG,IAAI/H,MAAM,kCAAoC8B,OAEhDkG,EAAmBD,EAAelF,KAGlCoF,QAAeH,EAAAA,EAAmBnL,EAAGuL,eAAe,EAAGF,EAAiBnK,QACxEsK,EACJH,EAAiB5J,MAAM,EAAG6J,EAAaG,OACvC3I,EACAuI,EAAiB5J,MAAM6J,EAAaG,MAAQH,EAAapK,QACrDwK,EAAgB1L,EAAG2L,iBAAiBP,EAAgBI,EAAS,CACjEI,KAAMN,EACNO,UAAW/I,EAAQ5B,SAGrB4E,EAAW4F"}
package/dist/vfs.esm.js CHANGED
@@ -23,9 +23,7 @@ try {
23
23
  } catch (error) {}
24
24
 
25
25
  var hasProcess = typeof process !== "undefined";
26
- var shouldDebug = hasLocalStorage &&
27
- /*#__PURE__*/
28
- localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
26
+ var shouldDebug = hasLocalStorage && /*#__PURE__*/localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
29
27
  var debugLog = shouldDebug ? console.log : function (_message) {
30
28
  return "";
31
29
  };
@@ -103,7 +101,7 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
103
101
  var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
104
102
  var target = compilerOptions.target || ts.ScriptTarget.ES5;
105
103
  var lib = compilerOptions.lib || [];
106
- var files = ["lib.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.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.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.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.d.ts", "lib.es2020.full.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.intl.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.symbol.d.ts"];
104
+ var files = ["lib.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.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.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.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.d.ts", "lib.es2020.full.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.intl.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.esnext.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.string.d.ts", "lib.esnext.weakref.d.ts"];
107
105
  var targetToCut = ts.ScriptTarget[target];
108
106
  var matches = files.filter(function (f) {
109
107
  return f.startsWith("lib." + targetToCut.toLowerCase());
@@ -134,15 +132,14 @@ var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(c
134
132
  * the local copy of typescript via the file system.
135
133
  */
136
134
 
137
- var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(compilerOptions, ts) {
135
+ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(compilerOptions, ts, tsLibDirectory) {
138
136
  var tsModule = ts || require("typescript");
139
137
 
140
- var path = require("path");
141
-
142
- var fs = require("fs");
138
+ var path = requirePath();
139
+ var fs = requireFS();
143
140
 
144
141
  var getLib = function getLib(name) {
145
- var lib = path.dirname(require.resolve("typescript"));
142
+ var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));
146
143
  return fs.readFileSync(path.join(lib, name), "utf8");
147
144
  };
148
145
 
@@ -158,9 +155,8 @@ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(c
158
155
  */
159
156
 
160
157
  var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
161
- var path = require("path");
162
-
163
- var fs = require("fs");
158
+ var path = requirePath();
159
+ var fs = requireFS();
164
160
 
165
161
  var walk = function walk(dir) {
166
162
  var results = [];
@@ -211,7 +207,6 @@ var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {
211
207
 
212
208
  var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache, ts, lzstring, fetcher, storer) {
213
209
  var fetchlike = fetcher || fetch;
214
- var storelike = storer || localStorage;
215
210
  var fsMap = new Map();
216
211
  var files = knownLibFilesForCompilerOptions(options, ts);
217
212
  var prefix = "https://typescript.azureedge.net/cdn/" + version + "/typescript/lib/";
@@ -239,6 +234,7 @@ var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version,
239
234
 
240
235
 
241
236
  function cached() {
237
+ var storelike = storer || localStorage;
242
238
  var keys = Object.keys(localStorage);
243
239
  keys.forEach(function (key) {
244
240
  // Remove anything which isn't from this version
@@ -370,16 +366,14 @@ function createSystem(files) {
370
366
  * project (basically the folder your node_modules lives)
371
367
  */
372
368
 
373
- function createFSBackedSystem(files, _projectRoot, ts) {
369
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
374
370
  // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the
375
371
  // existing node_modules structures going back through the history
376
372
  var root = _projectRoot + "/vfs";
377
-
378
- var path = require("path"); // The default System in TypeScript
379
-
373
+ var path = requirePath(); // The default System in TypeScript
380
374
 
381
375
  var nodeSys = ts.sys;
382
- var tsLib = path.dirname(require.resolve("typescript"));
376
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path.dirname(require.resolve("typescript"));
383
377
  return {
384
378
  // @ts-ignore
385
379
  name: "fs-vfs",
@@ -521,8 +515,16 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
521
515
  getCustomTransformers: function getCustomTransformers() {
522
516
  return customTransformers;
523
517
  },
518
+ // A couple weeks of 4.8 TypeScript nightlies had a bug where the Program's
519
+ // list of files was just a reference to the array returned by this host method,
520
+ // which means mutations by the host that ought to result in a new Program being
521
+ // created were not detected, since the old list of files and the new list of files
522
+ // were in fact a reference to the same underlying array. That was fixed in
523
+ // https://github.com/microsoft/TypeScript/pull/49813, but since the twoslash runner
524
+ // is used in bisecting for changes, it needs to guard against being busted in that
525
+ // couple-week period, so we defensively make a slice here.
524
526
  getScriptFileNames: function getScriptFileNames() {
525
- return fileNames;
527
+ return fileNames.slice();
526
528
  },
527
529
  getScriptSnapshot: function getScriptSnapshot(fileName) {
528
530
  var contents = sys.readFile(fileName);
@@ -555,5 +557,13 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
555
557
  return lsHost;
556
558
  }
557
559
 
560
+ var requirePath = function requirePath() {
561
+ return require(String.fromCharCode(112, 97, 116, 104));
562
+ };
563
+
564
+ var requireFS = function requireFS() {
565
+ return require(String.fromCharCode(102, 115));
566
+ };
567
+
558
568
  export { addAllFilesFromFolder, addFilesForTypesIntoFolder, createDefaultMapFromCDN, createDefaultMapFromNodeModules, createFSBackedSystem, createSystem, createVirtualCompilerHost, createVirtualLanguageServiceHost, createVirtualTypeScriptEnvironment, knownLibFilesForCompilerOptions };
559
569
  //# sourceMappingURL=vfs.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vfs.esm.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) {}\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n const files = [\n \"lib.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.esnext.array.d.ts\",\n \"lib.esnext.asynciterable.d.ts\",\n \"lib.esnext.bigint.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.symbol.d.ts\",\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n */\nexport const createDefaultMapFromNodeModules = (compilerOptions: CompilerOptions, ts?: typeof import(\"typescript\")) => {\n const tsModule = ts || require(\"typescript\")\n const path = require(\"path\")\n const fs = require(\"fs\")\n\n const getLib = (name: string) => {\n const lib = path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libs = knownLibFilesForCompilerOptions(compilerOptions, tsModule)\n const fsMap = new Map<string, string>()\n libs.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = require(\"path\")\n const fs = require(\"fs\")\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const storelike = storer || localStorage\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text()))).then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n }\n\n // A localstorage and lzzip aware version of the lib files\n function cached() {\n const keys = Object.keys(localStorage)\n keys.forEach(key => {\n // Remove anything which isn't from this version\n if (key.startsWith(\"ts-lib-\") && !key.startsWith(\"ts-lib-\" + version)) {\n storelike.removeItem(key)\n }\n })\n\n return Promise.all(\n files.map(lib => {\n const cacheKey = `ts-lib-${version}-${lib}`\n const content = storelike.getItem(cacheKey)\n\n if (!content) {\n // Make the API call and store the text concent in the cache\n return fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n })\n })\n }\n\n const func = cache ? cached : uncached\n return func().then(() => fsMap)\n}\n\nfunction notImplemented(methodName: string): any {\n throw new Error(`Method '${methodName}' is not implemented.`)\n}\n\nfunction audit<ArgsT extends any[], ReturnT>(\n name: string,\n fn: (...args: ArgsT) => ReturnT\n): (...args: ArgsT) => ReturnT {\n return (...args) => {\n const res = fn(...args)\n\n const smallres = typeof res === \"string\" ? res.slice(0, 80) + \"...\" : res\n debugLog(\"> \" + name, ...args)\n debugLog(\"< \" + smallres)\n\n return res\n }\n}\n\n/** The default compiler options if TypeScript could ever change the compiler options */\nconst defaultCompilerOptions = (ts: typeof import(\"typescript\")): CompilerOptions => {\n return {\n ...ts.getDefaultCompilerOptions(),\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n module: ts.ModuleKind.ESNext,\n suppressOutputPathCheck: true,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n }\n}\n\n// \"/DOM.d.ts\" => \"/lib.dom.d.ts\"\nconst libize = (path: string) => path.replace(\"/\", \"/lib.\").toLowerCase()\n\n/**\n * Creates an in-memory System object which can be used in a TypeScript program, this\n * is what provides read/write aspects of the virtual fs\n */\nexport function createSystem(files: Map<string, string>): System {\n return {\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory))\n }),\n exit: () => notImplemented(\"exit\"),\n fileExists: audit(\"fileExists\", fileName => files.has(fileName) || files.has(libize(fileName))),\n getCurrentDirectory: () => \"/\",\n getDirectories: () => [],\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", directory => (directory === \"/\" ? Array.from(files.keys()) : [])),\n readFile: audit(\"readFile\", fileName => files.get(fileName) || files.get(libize(fileName))),\n resolvePath: path => path,\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates a file-system backed System object which can be used in a TypeScript program, you provide\n * a set of virtual files which are prioritised over the FS versions, then a path to the root of your\n * project (basically the folder your node_modules lives)\n */\nexport function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS): System {\n // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the\n // existing node_modules structures going back through the history\n const root = _projectRoot + \"/vfs\"\n const path = require(\"path\")\n\n // The default System in TypeScript\n const nodeSys = ts.sys\n const tsLib = path.dirname(require.resolve(\"typescript\"))\n\n return {\n // @ts-ignore\n name: \"fs-vfs\",\n root,\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory)) || nodeSys.directoryExists(directory)\n }),\n exit: nodeSys.exit,\n fileExists: audit(\"fileExists\", fileName => {\n if (files.has(fileName)) return true\n // Don't let other tsconfigs end up touching the vfs\n if (fileName.includes(\"tsconfig.json\") || fileName.includes(\"tsconfig.json\")) return false\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n return nodeSys.fileExists(tsLibName)\n }\n return nodeSys.fileExists(fileName)\n }),\n getCurrentDirectory: () => root,\n getDirectories: nodeSys.getDirectories,\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", (...args) => {\n if (args[0] === \"/\") {\n return Array.from(files.keys())\n } else {\n return nodeSys.readDirectory(...args)\n }\n }),\n readFile: audit(\"readFile\", fileName => {\n if (files.has(fileName)) return files.get(fileName)\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n const result = nodeSys.readFile(tsLibName)\n if (!result) {\n const libs = nodeSys.readDirectory(tsLib)\n throw new Error(\n `TSVFS: A request was made for ${tsLibName} 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: ${libs}.`\n )\n }\n return result\n }\n return nodeSys.readFile(fileName)\n }),\n resolvePath: path => {\n if (files.has(path)) return path\n return nodeSys.resolvePath(path)\n },\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates an in-memory CompilerHost -which is essentially an extra wrapper to System\n * which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile\n * instances to the in-memory file system.\n */\nexport function createVirtualCompilerHost(sys: System, compilerOptions: CompilerOptions, ts: TS) {\n const sourceFiles = new Map<string, SourceFile>()\n const save = (sourceFile: SourceFile) => {\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return sourceFile\n }\n\n type Return = {\n compilerHost: CompilerHost\n updateFile: (sourceFile: SourceFile) => boolean\n }\n\n const vHost: Return = {\n compilerHost: {\n ...sys,\n getCanonicalFileName: fileName => fileName,\n getDefaultLibFileName: () => \"/\" + ts.getDefaultLibFileName(compilerOptions), // '/lib.d.ts',\n // getDefaultLibLocation: () => '/',\n getDirectories: () => [],\n getNewLine: () => sys.newLine,\n getSourceFile: fileName => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n compilerOptions.target || defaultCompilerOptions(ts).target!,\n false\n )\n )\n )\n },\n useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,\n },\n updateFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sys.writeFile(sourceFile.fileName, sourceFile.text)\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return alreadyExists\n },\n }\n return vHost\n}\n\n/**\n * Creates an object which can host a language service against the virtual file-system\n */\nexport function createVirtualLanguageServiceHost(\n sys: System,\n rootFiles: string[],\n compilerOptions: CompilerOptions,\n ts: TS,\n customTransformers?: CustomTransformers\n) {\n const fileNames = [...rootFiles]\n const { compilerHost, updateFile } = createVirtualCompilerHost(sys, compilerOptions, ts)\n const fileVersions = new Map<string, string>()\n let projectVersion = 0\n const languageServiceHost: LanguageServiceHost = {\n ...compilerHost,\n getProjectVersion: () => projectVersion.toString(),\n getCompilationSettings: () => compilerOptions,\n getCustomTransformers: () => customTransformers,\n getScriptFileNames: () => fileNames,\n getScriptSnapshot: fileName => {\n const contents = sys.readFile(fileName)\n if (contents) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","shouldDebug","getItem","env","DEBUG","debugLog","console","log","_message","createVirtualTypeScriptEnvironment","sys","rootFiles","ts","compilerOptions","customTransformers","mergedCompilerOpts","defaultCompilerOptions","createVirtualLanguageServiceHost","languageServiceHost","updateFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","getProgram","createFile","content","createSourceFile","target","optPrevTextSpan","prevSourceFile","prevFullContents","text","prevTextSpan","createTextSpan","newText","slice","start","newSourceFile","updateSourceFile","span","newLength","knownLibFilesForCompilerOptions","ScriptTarget","ES5","lib","files","targetToCut","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","getMax","array","reduce","max","current","undefined","indexesForCutting","map","cutIndex","libCutIndex","finalCutIndex","Math","createDefaultMapFromNodeModules","tsModule","require","path","fs","getLib","dirname","resolve","readFileSync","join","libs","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","readdirSync","file","stat","statSync","isDirectory","concat","push","allFiles","fsPath","replace","validExtensions","includes","extname","addFilesForTypesIntoFolder","createDefaultMapFromCDN","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","storelike","prefix","zip","str","compressToUTF16","unzip","decompressFromUTF16","uncached","Promise","all","then","resp","contents","index","cached","keys","Object","key","removeItem","cacheKey","t","setItem","func","notImplemented","methodName","audit","fn","args","res","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost"],"mappings":";;;;;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAtB;;AACA,IAAI;AACFA,EAAAA,eAAe,GAAG,OAAOC,YAAP,gBAAlB;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,EAAE;AAAA,aAAMlM,eAAN;AAAA,KAHD;AAIvBmM,IAAAA,qBAAqB,EAAE;AAAA,aAAMlM,kBAAN;AAAA,KAJA;AAKvBmM,IAAAA,kBAAkB,EAAE;AAAA,aAAMP,SAAN;AAAA,KALG;AAMvBQ,IAAAA,iBAAiB,EAAE,2BAAAnL,QAAQ;AACzB,UAAMqG,QAAQ,GAAG1H,GAAG,CAAC0K,QAAJ,CAAarJ,QAAb,CAAjB;;AACA,UAAIqG,QAAJ,EAAc;AACZ,eAAOxH,EAAE,CAACuM,cAAH,CAAkBC,UAAlB,CAA6BhF,QAA7B,CAAP;AACD;;AACD;AACD,KAZsB;AAavBiF,IAAAA,gBAAgB,EAAE,0BAAAtL,QAAQ;AACxB,aAAO4K,YAAY,CAACtB,GAAb,CAAiBtJ,QAAjB,KAA8B,GAArC;AACD,KAfsB;AAgBvB2J,IAAAA,SAAS,EAAEhL,GAAG,CAACgL;AAhBQ,IAAzB;;AAwBA,MAAM4B,MAAM,GAAW;AACrBpM,IAAAA,mBAAmB,EAAnBA,mBADqB;AAErBC,IAAAA,UAAU,EAAE,oBAAAiL,UAAU;AACpBQ,MAAAA,cAAc;AACdD,MAAAA,YAAY,CAACjH,GAAb,CAAiB0G,UAAU,CAACrK,QAA5B,EAAsC6K,cAAc,CAACE,QAAf,EAAtC;;AACA,UAAI,CAACJ,SAAS,CAAC9F,QAAV,CAAmBwF,UAAU,CAACrK,QAA9B,CAAL,EAA8C;AAC5C2K,QAAAA,SAAS,CAACnG,IAAV,CAAe6F,UAAU,CAACrK,QAA1B;AACD;;AACDZ,MAAAA,YAAU,CAACiL,UAAD,CAAV;AACD;AAToB,GAAvB;AAWA,SAAOkB,MAAP;AACD;;;;"}
1
+ {"version":3,"file":"vfs.esm.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) { }\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n const files = [\n \"lib.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.promise.d.ts\",\n \"lib.esnext.string.d.ts\",\n \"lib.esnext.weakref.d.ts\",\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n */\nexport const createDefaultMapFromNodeModules = (compilerOptions: CompilerOptions, ts?: typeof import(\"typescript\"), tsLibDirectory?: string) => {\n const tsModule = ts || require(\"typescript\")\n const path = requirePath()\n const fs = requireFS()\n\n const getLib = (name: string) => {\n const lib = tsLibDirectory || path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libs = knownLibFilesForCompilerOptions(compilerOptions, tsModule)\n const fsMap = new Map<string, string>()\n libs.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = requirePath()\n const fs = requireFS()\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text()))).then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n }\n\n // A localstorage and lzzip aware version of the lib files\n function cached() {\n const storelike = storer || localStorage\n\n const keys = Object.keys(localStorage)\n keys.forEach(key => {\n // Remove anything which isn't from this version\n if (key.startsWith(\"ts-lib-\") && !key.startsWith(\"ts-lib-\" + version)) {\n storelike.removeItem(key)\n }\n })\n\n return Promise.all(\n files.map(lib => {\n const cacheKey = `ts-lib-${version}-${lib}`\n const content = storelike.getItem(cacheKey)\n\n if (!content) {\n // Make the API call and store the text concent in the cache\n return fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n })\n })\n }\n\n const func = cache ? cached : uncached\n return func().then(() => fsMap)\n}\n\nfunction notImplemented(methodName: string): any {\n throw new Error(`Method '${methodName}' is not implemented.`)\n}\n\nfunction audit<ArgsT extends any[], ReturnT>(\n name: string,\n fn: (...args: ArgsT) => ReturnT\n): (...args: ArgsT) => ReturnT {\n return (...args) => {\n const res = fn(...args)\n\n const smallres = typeof res === \"string\" ? res.slice(0, 80) + \"...\" : res\n debugLog(\"> \" + name, ...args)\n debugLog(\"< \" + smallres)\n\n return res\n }\n}\n\n/** The default compiler options if TypeScript could ever change the compiler options */\nconst defaultCompilerOptions = (ts: typeof import(\"typescript\")): CompilerOptions => {\n return {\n ...ts.getDefaultCompilerOptions(),\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n module: ts.ModuleKind.ESNext,\n suppressOutputPathCheck: true,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n }\n}\n\n// \"/DOM.d.ts\" => \"/lib.dom.d.ts\"\nconst libize = (path: string) => path.replace(\"/\", \"/lib.\").toLowerCase()\n\n/**\n * Creates an in-memory System object which can be used in a TypeScript program, this\n * is what provides read/write aspects of the virtual fs\n */\nexport function createSystem(files: Map<string, string>): System {\n return {\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory))\n }),\n exit: () => notImplemented(\"exit\"),\n fileExists: audit(\"fileExists\", fileName => files.has(fileName) || files.has(libize(fileName))),\n getCurrentDirectory: () => \"/\",\n getDirectories: () => [],\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", directory => (directory === \"/\" ? Array.from(files.keys()) : [])),\n readFile: audit(\"readFile\", fileName => files.get(fileName) || files.get(libize(fileName))),\n resolvePath: path => path,\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates a file-system backed System object which can be used in a TypeScript program, you provide\n * a set of virtual files which are prioritised over the FS versions, then a path to the root of your\n * project (basically the folder your node_modules lives)\n */\nexport function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS, tsLibDirectory?: string): System {\n // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the\n // existing node_modules structures going back through the history\n const root = _projectRoot + \"/vfs\"\n const path = requirePath()\n\n // The default System in TypeScript\n const nodeSys = ts.sys\n const tsLib = tsLibDirectory ?? path.dirname(require.resolve(\"typescript\"))\n\n return {\n // @ts-ignore\n name: \"fs-vfs\",\n root,\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory)) || nodeSys.directoryExists(directory)\n }),\n exit: nodeSys.exit,\n fileExists: audit(\"fileExists\", fileName => {\n if (files.has(fileName)) return true\n // Don't let other tsconfigs end up touching the vfs\n if (fileName.includes(\"tsconfig.json\") || fileName.includes(\"tsconfig.json\")) return false\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n return nodeSys.fileExists(tsLibName)\n }\n return nodeSys.fileExists(fileName)\n }),\n getCurrentDirectory: () => root,\n getDirectories: nodeSys.getDirectories,\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", (...args) => {\n if (args[0] === \"/\") {\n return Array.from(files.keys())\n } else {\n return nodeSys.readDirectory(...args)\n }\n }),\n readFile: audit(\"readFile\", fileName => {\n if (files.has(fileName)) return files.get(fileName)\n if (fileName.startsWith(\"/lib\")) {\n const tsLibName = `${tsLib}/${fileName.replace(\"/\", \"\")}`\n const result = nodeSys.readFile(tsLibName)\n if (!result) {\n const libs = nodeSys.readDirectory(tsLib)\n throw new Error(\n `TSVFS: A request was made for ${tsLibName} 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: ${libs}.`\n )\n }\n return result\n }\n return nodeSys.readFile(fileName)\n }),\n resolvePath: path => {\n if (files.has(path)) return path\n return nodeSys.resolvePath(path)\n },\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates an in-memory CompilerHost -which is essentially an extra wrapper to System\n * which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile\n * instances to the in-memory file system.\n */\nexport function createVirtualCompilerHost(sys: System, compilerOptions: CompilerOptions, ts: TS) {\n const sourceFiles = new Map<string, SourceFile>()\n const save = (sourceFile: SourceFile) => {\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return sourceFile\n }\n\n type Return = {\n compilerHost: CompilerHost\n updateFile: (sourceFile: SourceFile) => boolean\n }\n\n const vHost: Return = {\n compilerHost: {\n ...sys,\n getCanonicalFileName: fileName => fileName,\n getDefaultLibFileName: () => \"/\" + ts.getDefaultLibFileName(compilerOptions), // '/lib.d.ts',\n // getDefaultLibLocation: () => '/',\n getDirectories: () => [],\n getNewLine: () => sys.newLine,\n getSourceFile: fileName => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n compilerOptions.target || defaultCompilerOptions(ts).target!,\n false\n )\n )\n )\n },\n useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,\n },\n updateFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sys.writeFile(sourceFile.fileName, sourceFile.text)\n sourceFiles.set(sourceFile.fileName, sourceFile)\n return alreadyExists\n },\n }\n return vHost\n}\n\n/**\n * Creates an object which can host a language service against the virtual file-system\n */\nexport function createVirtualLanguageServiceHost(\n sys: System,\n rootFiles: string[],\n compilerOptions: CompilerOptions,\n ts: TS,\n customTransformers?: CustomTransformers\n) {\n const fileNames = [...rootFiles]\n const { compilerHost, updateFile } = createVirtualCompilerHost(sys, compilerOptions, ts)\n const fileVersions = new Map<string, string>()\n let projectVersion = 0\n const languageServiceHost: LanguageServiceHost = {\n ...compilerHost,\n getProjectVersion: () => projectVersion.toString(),\n getCompilationSettings: () => compilerOptions,\n getCustomTransformers: () => customTransformers,\n // A couple weeks of 4.8 TypeScript nightlies had a bug where the Program's\n // list of files was just a reference to the array returned by this host method,\n // which means mutations by the host that ought to result in a new Program being\n // created were not detected, since the old list of files and the new list of files\n // were in fact a reference to the same underlying array. That was fixed in\n // https://github.com/microsoft/TypeScript/pull/49813, but since the twoslash runner\n // is used in bisecting for changes, it needs to guard against being busted in that\n // couple-week period, so we defensively make a slice here.\n getScriptFileNames: () => fileNames.slice(),\n getScriptSnapshot: fileName => {\n const contents = sys.readFile(fileName)\n if (contents) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n\nconst requirePath = () => {\n return require(String.fromCharCode(112, 97, 116, 104)) as typeof import(\"path\")\n}\n\nconst requireFS = () => {\n return require(String.fromCharCode(102, 115)) as typeof import(\"fs\")\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","shouldDebug","getItem","env","DEBUG","debugLog","console","log","_message","createVirtualTypeScriptEnvironment","sys","rootFiles","ts","compilerOptions","customTransformers","mergedCompilerOpts","defaultCompilerOptions","createVirtualLanguageServiceHost","languageServiceHost","updateFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","getProgram","createFile","content","createSourceFile","target","optPrevTextSpan","prevSourceFile","prevFullContents","text","prevTextSpan","createTextSpan","newText","slice","start","newSourceFile","updateSourceFile","span","newLength","knownLibFilesForCompilerOptions","ScriptTarget","ES5","lib","files","targetToCut","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","getMax","array","reduce","max","current","undefined","indexesForCutting","map","cutIndex","libCutIndex","finalCutIndex","Math","createDefaultMapFromNodeModules","tsLibDirectory","tsModule","require","path","requirePath","fs","requireFS","getLib","dirname","resolve","readFileSync","join","libs","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","readdirSync","file","stat","statSync","isDirectory","concat","push","allFiles","fsPath","replace","validExtensions","includes","extname","addFilesForTypesIntoFolder","createDefaultMapFromCDN","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","prefix","zip","str","compressToUTF16","unzip","decompressFromUTF16","uncached","Promise","all","then","resp","contents","index","cached","storelike","keys","Object","key","removeItem","cacheKey","t","setItem","func","notImplemented","methodName","audit","fn","args","res","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAtB;;AACA,IAAI;AACFA,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AMxI,WAAW,GAAG,SAAdA,WAAc;AAClB,SAAOF,OAAO,CAAC2I,MAAM,CAACC,YAAP,CAAoB,GAApB,EAAyB,EAAzB,EAA6B,GAA7B,EAAkC,GAAlC,CAAD,CAAd;AACD,CAFD;;AAIA,IAAMxI,SAAS,GAAG,SAAZA,SAAY;AAChB,SAAOJ,OAAO,CAAC2I,MAAM,CAACC,YAAP,CAAoB,GAApB,EAAyB,GAAzB,CAAD,CAAd;AACD,CAFD;;;;"}
@@ -23,9 +23,7 @@ try {
23
23
  } catch (error) {}
24
24
 
25
25
  var hasProcess = typeof process !== "undefined";
26
- var shouldDebug = hasLocalStorage &&
27
- /*#__PURE__*/
28
- localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
26
+ var shouldDebug = hasLocalStorage && /*#__PURE__*/localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
29
27
  var debugLog = shouldDebug ? console.log : function (_message) {
30
28
  return "";
31
29
  };
@@ -103,7 +101,7 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
103
101
  var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
104
102
  var target = compilerOptions.target || ts.ScriptTarget.ES5;
105
103
  var lib = compilerOptions.lib || [];
106
- var files = ["lib.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.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.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.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.d.ts", "lib.es2020.full.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.intl.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.symbol.d.ts"];
104
+ var files = ["lib.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.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.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.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.d.ts", "lib.es2020.full.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.intl.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.esnext.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.string.d.ts", "lib.esnext.weakref.d.ts"];
107
105
  var targetToCut = ts.ScriptTarget[target];
108
106
  var matches = files.filter(function (f) {
109
107
  return f.startsWith("lib." + targetToCut.toLowerCase());
@@ -134,15 +132,14 @@ var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(c
134
132
  * the local copy of typescript via the file system.
135
133
  */
136
134
 
137
- var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(compilerOptions, ts) {
135
+ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(compilerOptions, ts, tsLibDirectory) {
138
136
  var tsModule = ts || require("typescript");
139
137
 
140
- var path = require("path");
141
-
142
- var fs = require("fs");
138
+ var path = requirePath();
139
+ var fs = requireFS();
143
140
 
144
141
  var getLib = function getLib(name) {
145
- var lib = path.dirname(require.resolve("typescript"));
142
+ var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));
146
143
  return fs.readFileSync(path.join(lib, name), "utf8");
147
144
  };
148
145
 
@@ -158,9 +155,8 @@ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(c
158
155
  */
159
156
 
160
157
  var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
161
- var path = require("path");
162
-
163
- var fs = require("fs");
158
+ var path = requirePath();
159
+ var fs = requireFS();
164
160
 
165
161
  var walk = function walk(dir) {
166
162
  var results = [];
@@ -211,7 +207,6 @@ var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {
211
207
 
212
208
  var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache, ts, lzstring, fetcher, storer) {
213
209
  var fetchlike = fetcher || fetch;
214
- var storelike = storer || localStorage;
215
210
  var fsMap = new Map();
216
211
  var files = knownLibFilesForCompilerOptions(options, ts);
217
212
  var prefix = "https://typescript.azureedge.net/cdn/" + version + "/typescript/lib/";
@@ -239,6 +234,7 @@ var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version,
239
234
 
240
235
 
241
236
  function cached() {
237
+ var storelike = storer || localStorage;
242
238
  var keys = Object.keys(localStorage);
243
239
  keys.forEach(function (key) {
244
240
  // Remove anything which isn't from this version
@@ -370,16 +366,14 @@ function createSystem(files) {
370
366
  * project (basically the folder your node_modules lives)
371
367
  */
372
368
 
373
- function createFSBackedSystem(files, _projectRoot, ts) {
369
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
374
370
  // We need to make an isolated folder for the tsconfig, but also need to be able to resolve the
375
371
  // existing node_modules structures going back through the history
376
372
  var root = _projectRoot + "/vfs";
377
-
378
- var path = require("path"); // The default System in TypeScript
379
-
373
+ var path = requirePath(); // The default System in TypeScript
380
374
 
381
375
  var nodeSys = ts.sys;
382
- var tsLib = path.dirname(require.resolve("typescript"));
376
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path.dirname(require.resolve("typescript"));
383
377
  return {
384
378
  // @ts-ignore
385
379
  name: "fs-vfs",
@@ -521,8 +515,16 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
521
515
  getCustomTransformers: function getCustomTransformers() {
522
516
  return customTransformers;
523
517
  },
518
+ // A couple weeks of 4.8 TypeScript nightlies had a bug where the Program's
519
+ // list of files was just a reference to the array returned by this host method,
520
+ // which means mutations by the host that ought to result in a new Program being
521
+ // created were not detected, since the old list of files and the new list of files
522
+ // were in fact a reference to the same underlying array. That was fixed in
523
+ // https://github.com/microsoft/TypeScript/pull/49813, but since the twoslash runner
524
+ // is used in bisecting for changes, it needs to guard against being busted in that
525
+ // couple-week period, so we defensively make a slice here.
524
526
  getScriptFileNames: function getScriptFileNames() {
525
- return fileNames;
527
+ return fileNames.slice();
526
528
  },
527
529
  getScriptSnapshot: function getScriptSnapshot(fileName) {
528
530
  var contents = sys.readFile(fileName);
@@ -555,6 +557,14 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
555
557
  return lsHost;
556
558
  }
557
559
 
560
+ var requirePath = function requirePath() {
561
+ return require(String.fromCharCode(112, 97, 116, 104));
562
+ };
563
+
564
+ var requireFS = function requireFS() {
565
+ return require(String.fromCharCode(102, 115));
566
+ };
567
+
558
568
  const tsvfs = { addAllFilesFromFolder, addFilesForTypesIntoFolder, createDefaultMapFromCDN, createDefaultMapFromNodeModules, createFSBackedSystem, createSystem, createVirtualCompilerHost, createVirtualLanguageServiceHost, createVirtualTypeScriptEnvironment, knownLibFilesForCompilerOptions };
559
569
  //# sourceMappingURL=vfs.esm.js.map
560
570
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript/vfs",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "license": "MIT",
5
5
  "author": "TypeScript team",
6
6
  "homepage": "https://github.com/microsoft/TypeScript-Website",
@@ -37,6 +37,7 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/jest": "^25.1.3",
40
+ "babel-jest": "^26.0.6",
40
41
  "cpy-cli": "^3.1.1",
41
42
  "tsdx": "^0.14.1",
42
43
  "tslib": "^1.10.0",