@typescript/vfs 1.5.2 → 1.6.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 +17 -1
- package/dist/vfs.cjs.development.js +42 -10
- package/dist/vfs.cjs.development.js.map +1 -1
- package/dist/vfs.cjs.production.min.js +1 -1
- package/dist/vfs.cjs.production.min.js.map +1 -1
- package/dist/vfs.esm.js +42 -10
- package/dist/vfs.esm.js.map +1 -1
- package/dist/vfs.globals.js +42 -10
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,22 @@ type LanguageServiceHost = import("typescript").LanguageServiceHost;
|
|
|
5
5
|
type CompilerHost = import("typescript").CompilerHost;
|
|
6
6
|
type SourceFile = import("typescript").SourceFile;
|
|
7
7
|
type TS = typeof import("typescript");
|
|
8
|
+
type FetchLike = (url: string) => Promise<{
|
|
9
|
+
json(): Promise<any>;
|
|
10
|
+
text(): Promise<string>;
|
|
11
|
+
}>;
|
|
12
|
+
interface LocalStorageLike {
|
|
13
|
+
getItem(key: string): string | null;
|
|
14
|
+
setItem(key: string, value: string): void;
|
|
15
|
+
removeItem(key: string): void;
|
|
16
|
+
}
|
|
8
17
|
export interface VirtualTypeScriptEnvironment {
|
|
9
18
|
sys: System;
|
|
10
19
|
languageService: import("typescript").LanguageService;
|
|
11
20
|
getSourceFile: (fileName: string) => import("typescript").SourceFile | undefined;
|
|
12
21
|
createFile: (fileName: string, content: string) => void;
|
|
13
22
|
updateFile: (fileName: string, content: string, replaceTextSpan?: import("typescript").TextSpan) => void;
|
|
23
|
+
deleteFile: (fileName: string) => void;
|
|
14
24
|
}
|
|
15
25
|
/**
|
|
16
26
|
* Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with
|
|
@@ -46,6 +56,10 @@ export declare const createDefaultMapFromNodeModules: (_compilerOptions: Compile
|
|
|
46
56
|
export declare const addAllFilesFromFolder: (map: Map<string, string>, workingDir: string) => void;
|
|
47
57
|
/** Adds all files from node_modules/@types into the FS Map */
|
|
48
58
|
export declare const addFilesForTypesIntoFolder: (map: Map<string, string>) => void;
|
|
59
|
+
export interface LZString {
|
|
60
|
+
compressToUTF16(input: string): string;
|
|
61
|
+
decompressFromUTF16(compressed: string): string;
|
|
62
|
+
}
|
|
49
63
|
/**
|
|
50
64
|
* Create a virtual FS Map with the lib files from a particular TypeScript
|
|
51
65
|
* version based on the target, Always includes dom ATM.
|
|
@@ -58,7 +72,7 @@ export declare const addFilesForTypesIntoFolder: (map: Map<string, string>) => v
|
|
|
58
72
|
* @param fetcher an optional replacement for the global fetch function (tests mainly)
|
|
59
73
|
* @param storer an optional replacement for the localStorage global (tests mainly)
|
|
60
74
|
*/
|
|
61
|
-
export declare const createDefaultMapFromCDN: (options: CompilerOptions, version: string, cache: boolean, ts: TS, lzstring?:
|
|
75
|
+
export declare const createDefaultMapFromCDN: (options: CompilerOptions, version: string, cache: boolean, ts: TS, lzstring?: LZString, fetcher?: FetchLike, storer?: LocalStorageLike) => Promise<Map<string, string>>;
|
|
62
76
|
/**
|
|
63
77
|
* Creates an in-memory System object which can be used in a TypeScript program, this
|
|
64
78
|
* is what provides read/write aspects of the virtual fs
|
|
@@ -78,6 +92,7 @@ export declare function createFSBackedSystem(files: Map<string, string>, _projec
|
|
|
78
92
|
export declare function createVirtualCompilerHost(sys: System, compilerOptions: CompilerOptions, ts: TS): {
|
|
79
93
|
compilerHost: CompilerHost;
|
|
80
94
|
updateFile: (sourceFile: SourceFile) => boolean;
|
|
95
|
+
deleteFile: (sourceFile: SourceFile) => boolean;
|
|
81
96
|
};
|
|
82
97
|
/**
|
|
83
98
|
* Creates an object which can host a language service against the virtual file-system
|
|
@@ -85,5 +100,6 @@ export declare function createVirtualCompilerHost(sys: System, compilerOptions:
|
|
|
85
100
|
export declare function createVirtualLanguageServiceHost(sys: System, rootFiles: string[], compilerOptions: CompilerOptions, ts: TS, customTransformers?: CustomTransformers): {
|
|
86
101
|
languageServiceHost: LanguageServiceHost;
|
|
87
102
|
updateFile: (sourceFile: import("typescript").SourceFile) => void;
|
|
103
|
+
deleteFile: (sourceFile: import("typescript").SourceFile) => void;
|
|
88
104
|
};
|
|
89
105
|
export {};
|
|
@@ -43,7 +43,8 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
|
|
|
43
43
|
var mergedCompilerOpts = _extends({}, defaultCompilerOptions(ts), compilerOptions);
|
|
44
44
|
var _createVirtualLanguag = createVirtualLanguageServiceHost(sys, rootFiles, mergedCompilerOpts, ts, customTransformers),
|
|
45
45
|
languageServiceHost = _createVirtualLanguag.languageServiceHost,
|
|
46
|
-
_updateFile = _createVirtualLanguag.updateFile
|
|
46
|
+
_updateFile = _createVirtualLanguag.updateFile,
|
|
47
|
+
_deleteFile = _createVirtualLanguag.deleteFile;
|
|
47
48
|
var languageService = ts.createLanguageService(languageServiceHost);
|
|
48
49
|
var diagnostics = languageService.getCompilerOptionsDiagnostics();
|
|
49
50
|
if (diagnostics.length) {
|
|
@@ -76,6 +77,12 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
|
|
|
76
77
|
newLength: content.length
|
|
77
78
|
});
|
|
78
79
|
_updateFile(newSourceFile);
|
|
80
|
+
},
|
|
81
|
+
deleteFile: function deleteFile(fileName) {
|
|
82
|
+
var sourceFile = languageService.getProgram().getSourceFile(fileName);
|
|
83
|
+
if (sourceFile) {
|
|
84
|
+
_deleteFile(sourceFile);
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
87
|
};
|
|
81
88
|
}
|
|
@@ -133,9 +140,12 @@ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_
|
|
|
133
140
|
var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));
|
|
134
141
|
return fs.readFileSync(path.join(lib, name), "utf8");
|
|
135
142
|
};
|
|
143
|
+
var isDtsFile = function isDtsFile(file) {
|
|
144
|
+
return /\.d\.([^\.]+\.)?[cm]?ts$/i.test(file);
|
|
145
|
+
};
|
|
136
146
|
var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve("typescript")));
|
|
137
147
|
var knownLibFiles = libFiles.filter(function (f) {
|
|
138
|
-
return f.startsWith("lib.") && f
|
|
148
|
+
return f.startsWith("lib.") && isDtsFile(f);
|
|
139
149
|
});
|
|
140
150
|
var fsMap = new Map();
|
|
141
151
|
knownLibFiles.forEach(function (lib) {
|
|
@@ -323,7 +333,8 @@ function createSystem(files) {
|
|
|
323
333
|
return directory === "/" ? Array.from(files.keys()) : [];
|
|
324
334
|
}),
|
|
325
335
|
readFile: audit("readFile", function (fileName) {
|
|
326
|
-
|
|
336
|
+
var _files$get;
|
|
337
|
+
return (_files$get = files.get(fileName)) != null ? _files$get : files.get(libize(fileName));
|
|
327
338
|
}),
|
|
328
339
|
resolvePath: function resolvePath(path) {
|
|
329
340
|
return path;
|
|
@@ -335,6 +346,9 @@ function createSystem(files) {
|
|
|
335
346
|
},
|
|
336
347
|
writeFile: function writeFile(fileName, contents) {
|
|
337
348
|
files.set(fileName, contents);
|
|
349
|
+
},
|
|
350
|
+
deleteFile: function deleteFile(fileName) {
|
|
351
|
+
files["delete"](fileName);
|
|
338
352
|
}
|
|
339
353
|
};
|
|
340
354
|
}
|
|
@@ -414,7 +428,11 @@ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
|
|
|
414
428
|
},
|
|
415
429
|
writeFile: function writeFile(fileName, contents) {
|
|
416
430
|
files.set(fileName, contents);
|
|
417
|
-
}
|
|
431
|
+
},
|
|
432
|
+
deleteFile: function deleteFile(fileName) {
|
|
433
|
+
files["delete"](fileName);
|
|
434
|
+
},
|
|
435
|
+
realpath: nodeSys.realpath
|
|
418
436
|
};
|
|
419
437
|
}
|
|
420
438
|
/**
|
|
@@ -438,14 +456,12 @@ function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
|
438
456
|
},
|
|
439
457
|
// '/lib.d.ts',
|
|
440
458
|
// getDefaultLibLocation: () => '/',
|
|
441
|
-
getDirectories: function getDirectories() {
|
|
442
|
-
return [];
|
|
443
|
-
},
|
|
444
459
|
getNewLine: function getNewLine() {
|
|
445
460
|
return sys.newLine;
|
|
446
461
|
},
|
|
447
|
-
getSourceFile: function getSourceFile(fileName) {
|
|
448
|
-
|
|
462
|
+
getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
|
|
463
|
+
var _ref;
|
|
464
|
+
return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
|
|
449
465
|
},
|
|
450
466
|
useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
|
|
451
467
|
return sys.useCaseSensitiveFileNames;
|
|
@@ -456,6 +472,12 @@ function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
|
456
472
|
sys.writeFile(sourceFile.fileName, sourceFile.text);
|
|
457
473
|
sourceFiles.set(sourceFile.fileName, sourceFile);
|
|
458
474
|
return alreadyExists;
|
|
475
|
+
},
|
|
476
|
+
deleteFile: function deleteFile(sourceFile) {
|
|
477
|
+
var alreadyExists = sourceFiles.has(sourceFile.fileName);
|
|
478
|
+
sourceFiles["delete"](sourceFile.fileName);
|
|
479
|
+
sys.deleteFile(sourceFile.fileName);
|
|
480
|
+
return alreadyExists;
|
|
459
481
|
}
|
|
460
482
|
};
|
|
461
483
|
return vHost;
|
|
@@ -467,7 +489,8 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
|
|
|
467
489
|
var fileNames = [].concat(rootFiles);
|
|
468
490
|
var _createVirtualCompile = createVirtualCompilerHost(sys, compilerOptions, ts),
|
|
469
491
|
compilerHost = _createVirtualCompile.compilerHost,
|
|
470
|
-
_updateFile2 = _createVirtualCompile.updateFile
|
|
492
|
+
_updateFile2 = _createVirtualCompile.updateFile,
|
|
493
|
+
_deleteFile2 = _createVirtualCompile.deleteFile;
|
|
471
494
|
var fileVersions = new Map();
|
|
472
495
|
var projectVersion = 0;
|
|
473
496
|
var languageServiceHost = _extends({}, compilerHost, {
|
|
@@ -512,6 +535,15 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
|
|
|
512
535
|
fileNames.push(sourceFile.fileName);
|
|
513
536
|
}
|
|
514
537
|
_updateFile2(sourceFile);
|
|
538
|
+
},
|
|
539
|
+
deleteFile: function deleteFile(sourceFile) {
|
|
540
|
+
projectVersion++;
|
|
541
|
+
fileVersions.set(sourceFile.fileName, projectVersion.toString());
|
|
542
|
+
var index = fileNames.indexOf(sourceFile.fileName);
|
|
543
|
+
if (index !== -1) {
|
|
544
|
+
fileNames.splice(index, 1);
|
|
545
|
+
}
|
|
546
|
+
_deleteFile2(sourceFile);
|
|
515
547
|
}
|
|
516
548
|
};
|
|
517
549
|
return lsHost;
|
|
@@ -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// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json\n// and then using that to generate the list of files from the server, but it is not included in the npm package\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, we're really working with the constraint that you can't get a list of files\n * when running in a browser.\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 // Note that this will include files which can't be found for particular versions of TS\n // TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011\n // or similar is merged.\n const files = [\n \"lib.d.ts\",\n \"lib.decorators.d.ts\",\n \"lib.decorators.legacy.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.webworker.iterable.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.date.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.intl.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.date.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2020.number.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.intl.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.es2022.array.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2022.error.d.ts\",\n \"lib.es2022.full.d.ts\",\n \"lib.es2022.intl.d.ts\",\n \"lib.es2022.object.d.ts\",\n \"lib.es2022.regexp.d.ts\",\n \"lib.es2022.sharedmemory.d.ts\",\n \"lib.es2022.string.d.ts\",\n \"lib.es2023.array.d.ts\",\n \"lib.es2023.collection.d.ts\",\n \"lib.es2023.d.ts\",\n \"lib.es2023.full.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.decorators.d.ts\",\n \"lib.esnext.disposable.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.symbol.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 *\n * The first two args are un-used, but kept around so as to not cause a\n * semver major bump for no gain to module users.\n */\nexport const createDefaultMapFromNodeModules = (\n _compilerOptions: CompilerOptions,\n _ts?: typeof import(\"typescript\"),\n tsLibDirectory?: string\n) => {\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 libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve(\"typescript\")))\n const knownLibFiles = libFiles.filter(f => f.startsWith(\"lib.\") && f.endsWith(\".d.ts\"))\n\n const fsMap = new Map<string, string>()\n knownLibFiles.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://playgroundcdn.typescriptlang.org/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 (\n Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text())))\n .then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\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(storelike)\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 (\n fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\n )\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n if (text) {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n }\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(\n files: Map<string, string>,\n _projectRoot: string,\n ts: TS,\n tsLibDirectory?: string\n): 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 && typeof contents === \"string\") {\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","_extends","defaultCompilerOptions","_createVirtualLanguag","createVirtualLanguageServiceHost","languageServiceHost","updateFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","_languageService$getP","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","_compilerOptions","_ts","tsLibDirectory","path","requirePath","fs","requireFS","getLib","dirname","require","resolve","readFileSync","join","libFiles","readdirSync","knownLibFiles","endsWith","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","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","_len","arguments","args","Array","_key","res","apply","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","libs","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","_createVirtualCompile","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAK,CAAA;AAC3B,IAAI;EACFA,eAAe,GAAG,OAAOC,YAAY,KAAgB,WAAA,CAAA;AACvD,CAAC,CAAC,OAAOC,KAAK,EAAE,EAAE;AAElB,IAAMC,UAAU,GAAG,OAAOC,OAAO,KAAgB,WAAA,CAAA;AACjD,IAAMC,WAAW,GAAIL,eAAe,iBAAIC,YAAY,CAACK,OAAO,CAAC,OAAO,CAAC,IAAMH,UAAU,IAAIC,OAAO,CAACG,GAAG,CAACC,KAAM,CAAA;AAC3G,IAAMC,QAAQ,GAAGJ,WAAW,GAAGK,OAAO,CAACC,GAAG,GAAG,UAACC,QAAc,EAAA;AAAA,EAAA,OAAgC,EAAE,CAAA;AAAA,CAAA,CAAA;AAU9F;;;;;;;;;AASG;AAEa,SAAAC,kCAAkCA,CAChDC,GAAW,EACXC,SAAmB,EACnB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CAACE,QAAQ,EAAE,CAAC,CAAA;MAChE,IAAI,CAACL,SAAS,CAACnG,QAAQ,CAAC6F,UAAU,CAACjL,QAAQ,CAAC,EAAE;AAC5CuL,QAAAA,SAAS,CAACxG,IAAI,CAACkG,UAAU,CAACjL,QAAQ,CAAC,CAAA;AACrC,OAAA;MACAZ,YAAU,CAAC6L,UAAU,CAAC,CAAA;AACxB,KAAA;GACD,CAAA;AACD,EAAA,OAAOmB,MAAM,CAAA;AACf,CAAA;AAEA,IAAMjJ,WAAW,GAAG,SAAdA,WAAWA,GAAQ;AACvB,EAAA,OAAOK,OAAO,CAAC6I,MAAM,CAACC,YAAY,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAA0B,CAAA;AACjF,CAAC,CAAA;AAED,IAAMjJ,SAAS,GAAG,SAAZA,SAASA,GAAQ;EACrB,OAAOG,OAAO,CAAC6I,MAAM,CAACC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAwB,CAAA;AACtE,CAAC;;;;;;;;;;;;;"}
|
|
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\ntype FetchLike = (url: string) => Promise<{ json(): Promise<any>; text(): Promise<string> }>\n\ninterface LocalStorageLike {\n getItem(key: string): string | null\n setItem(key: string, value: string): void\n removeItem(key: string): void\n}\n\ndeclare var localStorage: LocalStorageLike | undefined;\ndeclare var fetch: FetchLike | undefined;\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 deleteFile: (fileName: string) => 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, deleteFile } = 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 deleteFile(fileName) {\n const sourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (sourceFile) {\n deleteFile(sourceFile)\n }\n }\n }\n}\n\n// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json\n// and then using that to generate the list of files from the server, but it is not included in the npm package\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, we're really working with the constraint that you can't get a list of files\n * when running in a browser.\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 // Note that this will include files which can't be found for particular versions of TS\n // TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011\n // or similar is merged.\n const files = [\n \"lib.d.ts\",\n \"lib.decorators.d.ts\",\n \"lib.decorators.legacy.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.webworker.iterable.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.date.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.intl.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.date.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2020.number.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.intl.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.es2022.array.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2022.error.d.ts\",\n \"lib.es2022.full.d.ts\",\n \"lib.es2022.intl.d.ts\",\n \"lib.es2022.object.d.ts\",\n \"lib.es2022.regexp.d.ts\",\n \"lib.es2022.sharedmemory.d.ts\",\n \"lib.es2022.string.d.ts\",\n \"lib.es2023.array.d.ts\",\n \"lib.es2023.collection.d.ts\",\n \"lib.es2023.d.ts\",\n \"lib.es2023.full.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.decorators.d.ts\",\n \"lib.esnext.disposable.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.symbol.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 *\n * The first two args are un-used, but kept around so as to not cause a\n * semver major bump for no gain to module users.\n */\nexport const createDefaultMapFromNodeModules = (\n _compilerOptions: CompilerOptions,\n _ts?: typeof import(\"typescript\"),\n tsLibDirectory?: string\n) => {\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 isDtsFile = (file: string) => /\\.d\\.([^\\.]+\\.)?[cm]?ts$/i.test(file)\n\n const libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve(\"typescript\")))\n const knownLibFiles = libFiles.filter(f => f.startsWith(\"lib.\") && isDtsFile(f))\n\n const fsMap = new Map<string, string>()\n knownLibFiles.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\nexport interface LZString {\n compressToUTF16(input: string): string\n decompressFromUTF16(compressed: string): string\n}\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?: LZString,\n fetcher?: FetchLike,\n storer?: LocalStorageLike\n) => {\n const fetchlike = fetcher || fetch!\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://playgroundcdn.typescriptlang.org/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 (\n Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text())))\n .then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\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(storelike)\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 (\n fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\n )\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n if (text) {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n }\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 deleteFile: (fileName) => {\n files.delete(fileName)\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(\n files: Map<string, string>,\n _projectRoot: string,\n ts: TS,\n tsLibDirectory?: string\n): 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 deleteFile: (fileName) => {\n files.delete(fileName)\n },\n realpath: nodeSys.realpath,\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 deleteFile: (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 getNewLine: () => sys.newLine,\n getSourceFile: (fileName, languageVersionOrOptions) => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n languageVersionOrOptions ?? 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 deleteFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sourceFiles.delete(sourceFile.fileName)\n sys.deleteFile!(sourceFile.fileName)\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, deleteFile } = 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 && typeof contents === \"string\") {\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 deleteFile: (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 deleteFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n const index = fileNames.indexOf(sourceFile.fileName)\n if (index !== -1) {\n fileNames.splice(index, 1)\n }\n deleteFile(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","_extends","defaultCompilerOptions","_createVirtualLanguag","createVirtualLanguageServiceHost","languageServiceHost","updateFile","deleteFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","_languageService$getP","getProgram","createFile","content","createSourceFile","target","optPrevTextSpan","prevSourceFile","prevFullContents","text","prevTextSpan","createTextSpan","newText","slice","start","newSourceFile","updateSourceFile","span","newLength","sourceFile","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","_compilerOptions","_ts","tsLibDirectory","path","requirePath","fs","requireFS","getLib","dirname","require","resolve","readFileSync","join","isDtsFile","file","test","libFiles","readdirSync","knownLibFiles","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","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","_len","arguments","args","Array","_key","res","apply","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","_files$get","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","libs","realpath","sourceFiles","save","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","languageVersionOrOptions","_ref","alreadyExists","fileNames","_createVirtualCompile","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","splice","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,IAAIA,eAAe,GAAG,KAAK,CAAA;AAC3B,IAAI;EACFA,eAAe,GAAG,OAAOC,YAAY,KAAgB,WAAA,CAAA;AACvD,CAAC,CAAC,OAAOC,KAAK,EAAE,EAAE;AAElB,IAAMC,UAAU,GAAG,OAAOC,OAAO,KAAgB,WAAA,CAAA;AACjD,IAAMC,WAAW,GAAIL,eAAe,iBAAIC,YAAa,CAACK,OAAO,CAAC,OAAO,CAAC,IAAMH,UAAU,IAAIC,OAAO,CAACG,GAAG,CAACC,KAAM,CAAA;AAC5G,IAAMC,QAAQ,GAAGJ,WAAW,GAAGK,OAAO,CAACC,GAAG,GAAG,UAACC,QAAc,EAAA;AAAA,EAAA,OAAgC,EAAE,CAAA;AAAA,CAAA,CAAA;AAW9F;;;;;;;;;AASG;AAEa,SAAAC,kCAAkCA,CAChDC,GAAW,EACXC,SAAmB,EACnBC,EAAM,EACNC,eAAA,EACAC,kBAAuC,EAAA;AAAA,EAAA,IADvCD,eAAA,KAAA,KAAA,CAAA,EAAA;IAAAA,eAAA,GAAmC,EAAE,CAAA;AAAA,GAAA;EAGrC,IAAME,kBAAkB,GAAAC,QAAA,CAAQC,EAAAA,EAAAA,sBAAsB,CAACL,EAAE,CAAC,EAAKC,eAAe,C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B;AACDhC,IAAAA,UAAU,EAAE,SAAAA,UAAAgC,CAAAA,UAAU,EAAG;AACvB2K,MAAAA,cAAc,EAAE,CAAA;AAChBD,MAAAA,YAAY,CAACxH,GAAG,CAAClD,UAAU,CAACpB,QAAQ,EAAE+L,cAAc,CAACE,QAAQ,EAAE,CAAC,CAAA;MAChE,IAAMnF,KAAK,GAAG8E,SAAS,CAAC3J,OAAO,CAACb,UAAU,CAACpB,QAAQ,CAAC,CAAA;AACpD,MAAA,IAAI8G,KAAK,KAAK,CAAC,CAAC,EAAE;AAChB8E,QAAAA,SAAS,CAACc,MAAM,CAAC5F,KAAK,EAAE,CAAC,CAAC,CAAA;AAC5B,OAAA;MACA1H,YAAU,CAACgC,UAAU,CAAC,CAAA;AACxB,KAAA;GACD,CAAA;AACD,EAAA,OAAOqL,MAAM,CAAA;AACf,CAAA;AAEA,IAAMrJ,WAAW,GAAG,SAAdA,WAAWA,GAAQ;AACvB,EAAA,OAAOK,OAAO,CAACkJ,MAAM,CAACC,YAAY,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAA0B,CAAA;AACjF,CAAC,CAAA;AAED,IAAMtJ,SAAS,GAAG,SAAZA,SAASA,GAAQ;EACrB,OAAOG,OAAO,CAACkJ,MAAM,CAACC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAwB,CAAA;AACtE,CAAC;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},e.apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=!1;try{t="undefined"!=typeof localStorage}catch(e){}var r="undefined"!=typeof process,i=t&&localStorage.getItem("DEBUG")||r&&process.env.DEBUG?console.log:function(e){return""},n=function(e,t){var r,i=e.lib||[],n=["lib.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts","lib.webworker.d.ts","lib.webworker.importscripts.d.ts","lib.webworker.iterable.d.ts","lib.scripthost.d.ts","lib.es5.d.ts","lib.es6.d.ts","lib.es2015.collection.d.ts","lib.es2015.core.d.ts","lib.es2015.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.d.ts","lib.es2016.full.d.ts","lib.es2017.d.ts","lib.es2017.date.d.ts","lib.es2017.full.d.ts","lib.es2017.intl.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.d.ts","lib.es2018.full.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.d.ts","lib.es2019.full.d.ts","lib.es2019.intl.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2020.bigint.d.ts","lib.es2020.d.ts","lib.es2020.date.d.ts","lib.es2020.full.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2021.d.ts","lib.es2021.full.d.ts","lib.es2021.intl.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2022.array.d.ts","lib.es2022.d.ts","lib.es2022.error.d.ts","lib.es2022.full.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.regexp.d.ts","lib.es2022.sharedmemory.d.ts","lib.es2022.string.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.d.ts","lib.es2023.full.d.ts","lib.esnext.array.d.ts","lib.esnext.asynciterable.d.ts","lib.esnext.bigint.d.ts","lib.esnext.d.ts","lib.esnext.decorators.d.ts","lib.esnext.disposable.d.ts","lib.esnext.full.d.ts","lib.esnext.intl.d.ts","lib.esnext.promise.d.ts","lib.esnext.string.d.ts","lib.esnext.symbol.d.ts","lib.esnext.weakref.d.ts"],s=t.ScriptTarget[e.target||t.ScriptTarget.ES5],o=n.filter((function(e){return e.startsWith("lib."+s.toLowerCase())})),l=n.indexOf(o.pop()),a=i.map((function(e){var t=n.filter((function(t){return t.startsWith("lib."+e.toLowerCase())}));return 0===t.length?0:n.indexOf(t.pop())})),u=((r=a)&&r.length?r.reduce((function(e,t){return t>e?t:e})):void 0)||0,c=Math.max(l,u);return n.slice(0,c+1)},s=function(e,t){var r=f(),i=b();(function e(t){var n=[];return i.readdirSync(t).forEach((function(s){s=r.join(t,s);var o=i.statSync(s);o&&o.isDirectory()?n=n.concat(e(s)):n.push(s)})),n})(t).forEach((function(n){var s="/node_modules/@types"+n.replace(t,""),o=i.readFileSync(n,"utf8");[".ts",".tsx"].includes(r.extname(s))&&e.set(s,o)}))};function o(e){throw new Error("Method '"+e+"' is not implemented.")}function l(e,t){return function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];var o=t.apply(void 0,n),l="string"==typeof o?o.slice(0,80)+"...":o;return i.apply(void 0,["> "+e].concat(n)),i("< "+l),o}}var a=function(t){return e({},t.getDefaultCompilerOptions(),{jsx:t.JsxEmit.React,strict:!0,esModuleInterop:!0,module:t.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0,moduleResolution:t.ModuleResolutionKind.NodeJs})},u=function(e){return e.replace("/","/lib.").toLowerCase()};function c(t,r,i){var n=new Map;return{compilerHost:e({},t,{getCanonicalFileName:function(e){return e},getDefaultLibFileName:function(){return"/"+i.getDefaultLibFileName(r)},getDirectories:function(){return[]},getNewLine:function(){return t.newLine},getSourceFile:function(e){return n.get(e)||(s=i.createSourceFile(e,t.readFile(e),r.target||a(i).target,!1),n.set(s.fileName,s),s);var s},useCaseSensitiveFileNames:function(){return t.useCaseSensitiveFileNames}}),updateFile:function(e){var r=n.has(e.fileName);return t.writeFile(e.fileName,e.text),n.set(e.fileName,e),r}}}function d(t,r,i,n,s){var o=[].concat(r),l=c(t,i,n),a=l.compilerHost,u=l.updateFile,d=new Map,f=0;return{languageServiceHost:e({},a,{getProjectVersion:function(){return f.toString()},getCompilationSettings:function(){return i},getCustomTransformers:function(){return s},getScriptFileNames:function(){return o.slice()},getScriptSnapshot:function(e){var r=t.readFile(e);if(r&&"string"==typeof r)return n.ScriptSnapshot.fromString(r)},getScriptVersion:function(e){return d.get(e)||"0"},writeFile:t.writeFile}),updateFile:function(e){f++,d.set(e.fileName,f.toString()),o.includes(e.fileName)||o.push(e.fileName),u(e)}}}var f=function(){return require(String.fromCharCode(112,97,116,104))},b=function(){return require(String.fromCharCode(102,115))};exports.addAllFilesFromFolder=s,exports.addFilesForTypesIntoFolder=function(e){return s(e,"node_modules/@types")},exports.createDefaultMapFromCDN=function(e,t,r,i,s,o,l){var a=o||fetch,u=new Map,c=n(e,i),d="https://playgroundcdn.typescriptlang.org/cdn/"+t+"/typescript/lib/";return(r?function(){var e=l||localStorage;return Object.keys(e).forEach((function(r){r.startsWith("ts-lib-")&&!r.startsWith("ts-lib-"+t)&&e.removeItem(r)})),Promise.all(c.map((function(r){var i,n="ts-lib-"+t+"-"+r,o=e.getItem(n);return o?Promise.resolve((i=o,s?s.decompressFromUTF16(i):i)):a(d+r).then((function(e){return e.text()})).then((function(t){var r;return e.setItem(n,(r=t,s?s.compressToUTF16(r):r)),t})).catch((function(){}))}))).then((function(e){e.forEach((function(e,t){e&&u.set("/"+c[t],e)}))}))}:function(){return Promise.all(c.map((function(e){return a(d+e).then((function(e){return e.text()}))}))).then((function(e){e.forEach((function(e,t){return u.set("/"+c[t],e)}))})).catch((function(){}))})().then((function(){return u}))},exports.createDefaultMapFromNodeModules=function(e,t,r){var i=f(),n=b(),s=n.readdirSync(r||i.dirname(require.resolve("typescript"))).filter((function(e){return e.startsWith("lib.")&&e.endsWith(".d.ts")})),o=new Map;return s.forEach((function(e){o.set("/"+e,function(e){var t=r||i.dirname(require.resolve("typescript"));return n.readFileSync(i.join(t,e),"utf8")}(e))})),o},exports.createFSBackedSystem=function(e,t,r,i){var n=t+"/vfs",s=f(),a=r.sys,u=null!=i?i:s.dirname(require.resolve("typescript"));return{name:"fs-vfs",root:n,args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))||a.directoryExists(t)})),exit:a.exit,fileExists:l("fileExists",(function(t){if(e.has(t))return!0;if(t.includes("tsconfig.json")||t.includes("tsconfig.json"))return!1;if(t.startsWith("/lib")){var r=u+"/"+t.replace("/","");return a.fileExists(r)}return a.fileExists(t)})),getCurrentDirectory:function(){return n},getDirectories:a.getDirectories,getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(){return"/"===(arguments.length<=0?void 0:arguments[0])?Array.from(e.keys()):a.readDirectory.apply(a,arguments)})),readFile:l("readFile",(function(t){if(e.has(t))return e.get(t);if(t.startsWith("/lib")){var r=u+"/"+t.replace("/",""),i=a.readFile(r);if(!i){var n=a.readDirectory(u);throw new Error("TSVFS: A request was made for "+r+" but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: "+n+".")}return i}return a.readFile(t)})),resolvePath:function(t){return e.has(t)?t:a.resolvePath(t)},newLine:"\n",useCaseSensitiveFileNames:!0,write:function(){return o("write")},writeFile:function(t,r){e.set(t,r)}}},exports.createSystem=function(e){return{args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))})),exit:function(){return o("exit")},fileExists:l("fileExists",(function(t){return e.has(t)||e.has(u(t))})),getCurrentDirectory:function(){return"/"},getDirectories:function(){return[]},getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(t){return"/"===t?Array.from(e.keys()):[]})),readFile:l("readFile",(function(t){return e.get(t)||e.get(u(t))})),resolvePath:function(e){return e},newLine:"\n",useCaseSensitiveFileNames:!0,write:function(){return o("write")},writeFile:function(t,r){e.set(t,r)}}},exports.createVirtualCompilerHost=c,exports.createVirtualLanguageServiceHost=d,exports.createVirtualTypeScriptEnvironment=function(t,r,i,n,s){void 0===n&&(n={});var o=e({},a(i),n),l=d(t,r,o,i,s),u=l.updateFile,f=i.createLanguageService(l.languageServiceHost),b=f.getCompilerOptionsDiagnostics();if(b.length){var p=c(t,n,i);throw new Error(i.formatDiagnostics(b,p.compilerHost))}return{name:"vfs",sys:t,languageService:f,getSourceFile:function(e){var t;return null==(t=f.getProgram())?void 0:t.getSourceFile(e)},createFile:function(e,t){u(i.createSourceFile(e,t,o.target,!1))},updateFile:function(e,t,r){var n=f.getProgram().getSourceFile(e);if(!n)throw new Error("Did not find a source file for "+e);var s=n.text,o=null!=r?r:i.createTextSpan(0,s.length),l=s.slice(0,o.start)+t+s.slice(o.start+o.length),a=i.updateSourceFile(n,l,{span:o,newLength:t.length});u(a)}}},exports.knownLibFilesForCompilerOptions=n;
|
|
1
|
+
"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},e.apply(this,arguments)}Object.defineProperty(exports,"__esModule",{value:!0});var t=!1;try{t="undefined"!=typeof localStorage}catch(e){}var r="undefined"!=typeof process,i=t&&localStorage.getItem("DEBUG")||r&&process.env.DEBUG?console.log:function(e){return""},n=function(e,t){var r,i=e.lib||[],n=["lib.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts","lib.webworker.d.ts","lib.webworker.importscripts.d.ts","lib.webworker.iterable.d.ts","lib.scripthost.d.ts","lib.es5.d.ts","lib.es6.d.ts","lib.es2015.collection.d.ts","lib.es2015.core.d.ts","lib.es2015.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.d.ts","lib.es2016.full.d.ts","lib.es2017.d.ts","lib.es2017.date.d.ts","lib.es2017.full.d.ts","lib.es2017.intl.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.d.ts","lib.es2018.full.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.d.ts","lib.es2019.full.d.ts","lib.es2019.intl.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2020.bigint.d.ts","lib.es2020.d.ts","lib.es2020.date.d.ts","lib.es2020.full.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2021.d.ts","lib.es2021.full.d.ts","lib.es2021.intl.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2022.array.d.ts","lib.es2022.d.ts","lib.es2022.error.d.ts","lib.es2022.full.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.regexp.d.ts","lib.es2022.sharedmemory.d.ts","lib.es2022.string.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.d.ts","lib.es2023.full.d.ts","lib.esnext.array.d.ts","lib.esnext.asynciterable.d.ts","lib.esnext.bigint.d.ts","lib.esnext.d.ts","lib.esnext.decorators.d.ts","lib.esnext.disposable.d.ts","lib.esnext.full.d.ts","lib.esnext.intl.d.ts","lib.esnext.promise.d.ts","lib.esnext.string.d.ts","lib.esnext.symbol.d.ts","lib.esnext.weakref.d.ts"],s=t.ScriptTarget[e.target||t.ScriptTarget.ES5],o=n.filter((function(e){return e.startsWith("lib."+s.toLowerCase())})),l=n.indexOf(o.pop()),a=i.map((function(e){var t=n.filter((function(t){return t.startsWith("lib."+e.toLowerCase())}));return 0===t.length?0:n.indexOf(t.pop())})),u=((r=a)&&r.length?r.reduce((function(e,t){return t>e?t:e})):void 0)||0,c=Math.max(l,u);return n.slice(0,c+1)},s=function(e,t){var r=f(),i=b();(function e(t){var n=[];return i.readdirSync(t).forEach((function(s){s=r.join(t,s);var o=i.statSync(s);o&&o.isDirectory()?n=n.concat(e(s)):n.push(s)})),n})(t).forEach((function(n){var s="/node_modules/@types"+n.replace(t,""),o=i.readFileSync(n,"utf8");[".ts",".tsx"].includes(r.extname(s))&&e.set(s,o)}))};function o(e){throw new Error("Method '"+e+"' is not implemented.")}function l(e,t){return function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];var o=t.apply(void 0,n),l="string"==typeof o?o.slice(0,80)+"...":o;return i.apply(void 0,["> "+e].concat(n)),i("< "+l),o}}var a=function(t){return e({},t.getDefaultCompilerOptions(),{jsx:t.JsxEmit.React,strict:!0,esModuleInterop:!0,module:t.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0,moduleResolution:t.ModuleResolutionKind.NodeJs})},u=function(e){return e.replace("/","/lib.").toLowerCase()};function c(t,r,i){var n=new Map;return{compilerHost:e({},t,{getCanonicalFileName:function(e){return e},getDefaultLibFileName:function(){return"/"+i.getDefaultLibFileName(r)},getNewLine:function(){return t.newLine},getSourceFile:function(e,s){var o,l;return n.get(e)||(l=i.createSourceFile(e,t.readFile(e),null!=(o=null!=s?s:r.target)?o:a(i).target,!1),n.set(l.fileName,l),l)},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},deleteFile:function(e){var r=n.has(e.fileName);return n.delete(e.fileName),t.deleteFile(e.fileName),r}}}function d(t,r,i,n,s){var o=[].concat(r),l=c(t,i,n),a=l.compilerHost,u=l.updateFile,d=l.deleteFile,f=new Map,b=0;return{languageServiceHost:e({},a,{getProjectVersion:function(){return b.toString()},getCompilationSettings:function(){return i},getCustomTransformers:function(){return s},getScriptFileNames:function(){return o.slice()},getScriptSnapshot:function(e){var r=t.readFile(e);if(r&&"string"==typeof r)return n.ScriptSnapshot.fromString(r)},getScriptVersion:function(e){return f.get(e)||"0"},writeFile:t.writeFile}),updateFile:function(e){b++,f.set(e.fileName,b.toString()),o.includes(e.fileName)||o.push(e.fileName),u(e)},deleteFile:function(e){b++,f.set(e.fileName,b.toString());var t=o.indexOf(e.fileName);-1!==t&&o.splice(t,1),d(e)}}}var f=function(){return require(String.fromCharCode(112,97,116,104))},b=function(){return require(String.fromCharCode(102,115))};exports.addAllFilesFromFolder=s,exports.addFilesForTypesIntoFolder=function(e){return s(e,"node_modules/@types")},exports.createDefaultMapFromCDN=function(e,t,r,i,s,o,l){var a=o||fetch,u=new Map,c=n(e,i),d="https://playgroundcdn.typescriptlang.org/cdn/"+t+"/typescript/lib/";return(r?function(){var e=l||localStorage;return Object.keys(e).forEach((function(r){r.startsWith("ts-lib-")&&!r.startsWith("ts-lib-"+t)&&e.removeItem(r)})),Promise.all(c.map((function(r){var i,n="ts-lib-"+t+"-"+r,o=e.getItem(n);return o?Promise.resolve((i=o,s?s.decompressFromUTF16(i):i)):a(d+r).then((function(e){return e.text()})).then((function(t){var r;return e.setItem(n,(r=t,s?s.compressToUTF16(r):r)),t})).catch((function(){}))}))).then((function(e){e.forEach((function(e,t){e&&u.set("/"+c[t],e)}))}))}:function(){return Promise.all(c.map((function(e){return a(d+e).then((function(e){return e.text()}))}))).then((function(e){e.forEach((function(e,t){return u.set("/"+c[t],e)}))})).catch((function(){}))})().then((function(){return u}))},exports.createDefaultMapFromNodeModules=function(e,t,r){var i=f(),n=b(),s=n.readdirSync(r||i.dirname(require.resolve("typescript"))).filter((function(e){return e.startsWith("lib.")&&/\.d\.([^\.]+\.)?[cm]?ts$/i.test(e)})),o=new Map;return s.forEach((function(e){o.set("/"+e,function(e){var t=r||i.dirname(require.resolve("typescript"));return n.readFileSync(i.join(t,e),"utf8")}(e))})),o},exports.createFSBackedSystem=function(e,t,r,i){var n=t+"/vfs",s=f(),a=r.sys,u=null!=i?i:s.dirname(require.resolve("typescript"));return{name:"fs-vfs",root:n,args:[],createDirectory:function(){return o("createDirectory")},directoryExists:l("directoryExists",(function(t){return Array.from(e.keys()).some((function(e){return e.startsWith(t)}))||a.directoryExists(t)})),exit:a.exit,fileExists:l("fileExists",(function(t){if(e.has(t))return!0;if(t.includes("tsconfig.json")||t.includes("tsconfig.json"))return!1;if(t.startsWith("/lib")){var r=u+"/"+t.replace("/","");return a.fileExists(r)}return a.fileExists(t)})),getCurrentDirectory:function(){return n},getDirectories:a.getDirectories,getExecutingFilePath:function(){return o("getExecutingFilePath")},readDirectory:l("readDirectory",(function(){return"/"===(arguments.length<=0?void 0:arguments[0])?Array.from(e.keys()):a.readDirectory.apply(a,arguments)})),readFile:l("readFile",(function(t){if(e.has(t))return e.get(t);if(t.startsWith("/lib")){var r=u+"/"+t.replace("/",""),i=a.readFile(r);if(!i){var n=a.readDirectory(u);throw new Error("TSVFS: A request was made for "+r+" but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: "+n+".")}return i}return a.readFile(t)})),resolvePath:function(t){return e.has(t)?t:a.resolvePath(t)},newLine:"\n",useCaseSensitiveFileNames:!0,write:function(){return o("write")},writeFile:function(t,r){e.set(t,r)},deleteFile:function(t){e.delete(t)},realpath:a.realpath}},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){var r;return null!=(r=e.get(t))?r: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)},deleteFile:function(t){e.delete(t)}}},exports.createVirtualCompilerHost=c,exports.createVirtualLanguageServiceHost=d,exports.createVirtualTypeScriptEnvironment=function(t,r,i,n,s){void 0===n&&(n={});var o=e({},a(i),n),l=d(t,r,o,i,s),u=l.updateFile,f=l.deleteFile,b=i.createLanguageService(l.languageServiceHost),p=b.getCompilerOptionsDiagnostics();if(p.length){var g=c(t,n,i);throw new Error(i.formatDiagnostics(p,g.compilerHost))}return{name:"vfs",sys:t,languageService:b,getSourceFile:function(e){var t;return null==(t=b.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=b.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)},deleteFile:function(e){var t=b.getProgram().getSourceFile(e);t&&f(t)}}},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// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json\n// and then using that to generate the list of files from the server, but it is not included in the npm package\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, we're really working with the constraint that you can't get a list of files\n * when running in a browser.\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 // Note that this will include files which can't be found for particular versions of TS\n // TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011\n // or similar is merged.\n const files = [\n \"lib.d.ts\",\n \"lib.decorators.d.ts\",\n \"lib.decorators.legacy.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.webworker.iterable.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.date.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.intl.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.date.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2020.number.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.intl.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.es2022.array.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2022.error.d.ts\",\n \"lib.es2022.full.d.ts\",\n \"lib.es2022.intl.d.ts\",\n \"lib.es2022.object.d.ts\",\n \"lib.es2022.regexp.d.ts\",\n \"lib.es2022.sharedmemory.d.ts\",\n \"lib.es2022.string.d.ts\",\n \"lib.es2023.array.d.ts\",\n \"lib.es2023.collection.d.ts\",\n \"lib.es2023.d.ts\",\n \"lib.es2023.full.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.decorators.d.ts\",\n \"lib.esnext.disposable.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.symbol.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 *\n * The first two args are un-used, but kept around so as to not cause a\n * semver major bump for no gain to module users.\n */\nexport const createDefaultMapFromNodeModules = (\n _compilerOptions: CompilerOptions,\n _ts?: typeof import(\"typescript\"),\n tsLibDirectory?: string\n) => {\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 libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve(\"typescript\")))\n const knownLibFiles = libFiles.filter(f => f.startsWith(\"lib.\") && f.endsWith(\".d.ts\"))\n\n const fsMap = new Map<string, string>()\n knownLibFiles.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://playgroundcdn.typescriptlang.org/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 (\n Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text())))\n .then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\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(storelike)\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 (\n fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\n )\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n if (text) {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n }\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(\n files: Map<string, string>,\n _projectRoot: string,\n ts: TS,\n tsLibDirectory?: string\n): 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 && typeof contents === \"string\") {\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","indexesForCutting","map","length","libCutIndex","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","_len","arguments","args","Array","_key","res","apply","smallres","defaultCompilerOptions","_extends","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","_createVirtualCompile","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","_compilerOptions","_ts","tsLibDirectory","knownLibFiles","dirname","endsWith","getLib","_projectRoot","root","nodeSys","tsLib","createDirectory","directoryExists","directory","from","some","exit","fileExists","tsLibName","getCurrentDirectory","getExecutingFilePath","readDirectory","result","libs","resolvePath","write","mergedCompilerOpts","_createVirtualLanguag","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","formatDiagnostics","_languageService$getP","getProgram","createFile","optPrevTextSpan","prevSourceFile","prevFullContents","prevTextSpan","createTextSpan","newText","start","newSourceFile","updateSourceFile","span","newLength"],"mappings":"wSAQA,IAAIA,GAAkB,EACtB,IACEA,EAAqD,oBAA5BC,YAC3B,CAAE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7B,SAGrBmF,EAAWgG,EACb,EAEJ"}
|
|
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\ntype FetchLike = (url: string) => Promise<{ json(): Promise<any>; text(): Promise<string> }>\n\ninterface LocalStorageLike {\n getItem(key: string): string | null\n setItem(key: string, value: string): void\n removeItem(key: string): void\n}\n\ndeclare var localStorage: LocalStorageLike | undefined;\ndeclare var fetch: FetchLike | undefined;\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 deleteFile: (fileName: string) => 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, deleteFile } = 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 deleteFile(fileName) {\n const sourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (sourceFile) {\n deleteFile(sourceFile)\n }\n }\n }\n}\n\n// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json\n// and then using that to generate the list of files from the server, but it is not included in the npm package\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, we're really working with the constraint that you can't get a list of files\n * when running in a browser.\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 // Note that this will include files which can't be found for particular versions of TS\n // TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011\n // or similar is merged.\n const files = [\n \"lib.d.ts\",\n \"lib.decorators.d.ts\",\n \"lib.decorators.legacy.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.webworker.iterable.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.date.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.intl.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.date.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2020.number.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.intl.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.es2022.array.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2022.error.d.ts\",\n \"lib.es2022.full.d.ts\",\n \"lib.es2022.intl.d.ts\",\n \"lib.es2022.object.d.ts\",\n \"lib.es2022.regexp.d.ts\",\n \"lib.es2022.sharedmemory.d.ts\",\n \"lib.es2022.string.d.ts\",\n \"lib.es2023.array.d.ts\",\n \"lib.es2023.collection.d.ts\",\n \"lib.es2023.d.ts\",\n \"lib.es2023.full.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.decorators.d.ts\",\n \"lib.esnext.disposable.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.symbol.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 *\n * The first two args are un-used, but kept around so as to not cause a\n * semver major bump for no gain to module users.\n */\nexport const createDefaultMapFromNodeModules = (\n _compilerOptions: CompilerOptions,\n _ts?: typeof import(\"typescript\"),\n tsLibDirectory?: string\n) => {\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 isDtsFile = (file: string) => /\\.d\\.([^\\.]+\\.)?[cm]?ts$/i.test(file)\n\n const libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve(\"typescript\")))\n const knownLibFiles = libFiles.filter(f => f.startsWith(\"lib.\") && isDtsFile(f))\n\n const fsMap = new Map<string, string>()\n knownLibFiles.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\nexport interface LZString {\n compressToUTF16(input: string): string\n decompressFromUTF16(compressed: string): string\n}\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?: LZString,\n fetcher?: FetchLike,\n storer?: LocalStorageLike\n) => {\n const fetchlike = fetcher || fetch!\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://playgroundcdn.typescriptlang.org/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 (\n Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text())))\n .then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\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(storelike)\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 (\n fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\n )\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n if (text) {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n }\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 deleteFile: (fileName) => {\n files.delete(fileName)\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(\n files: Map<string, string>,\n _projectRoot: string,\n ts: TS,\n tsLibDirectory?: string\n): 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 deleteFile: (fileName) => {\n files.delete(fileName)\n },\n realpath: nodeSys.realpath,\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 deleteFile: (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 getNewLine: () => sys.newLine,\n getSourceFile: (fileName, languageVersionOrOptions) => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n languageVersionOrOptions ?? 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 deleteFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sourceFiles.delete(sourceFile.fileName)\n sys.deleteFile!(sourceFile.fileName)\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, deleteFile } = 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 && typeof contents === \"string\") {\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 deleteFile: (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 deleteFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n const index = fileNames.indexOf(sourceFile.fileName)\n if (index !== -1) {\n fileNames.splice(index, 1)\n }\n deleteFile(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","indexesForCutting","map","length","libCutIndex","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","_len","arguments","args","Array","_key","res","apply","smallres","defaultCompilerOptions","_extends","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createVirtualCompilerHost","sys","sourceFiles","Map","compilerHost","getCanonicalFileName","fileName","getDefaultLibFileName","getNewLine","newLine","getSourceFile","languageVersionOrOptions","_ref","sourceFile","get","createSourceFile","readFile","useCaseSensitiveFileNames","updateFile","alreadyExists","has","writeFile","text","deleteFile","createVirtualLanguageServiceHost","rootFiles","customTransformers","fileNames","_createVirtualCompile","fileVersions","projectVersion","languageServiceHost","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","contents","ScriptSnapshot","fromString","getScriptVersion","index","splice","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","_compilerOptions","_ts","tsLibDirectory","knownLibFiles","dirname","test","getLib","_projectRoot","root","nodeSys","tsLib","createDirectory","directoryExists","directory","from","some","exit","fileExists","tsLibName","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","result","libs","resolvePath","write","realpath","_files$get","mergedCompilerOpts","_createVirtualLanguag","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","formatDiagnostics","_languageService$getP","getProgram","createFile","optPrevTextSpan","prevSourceFile","prevFullContents","prevTextSpan","createTextSpan","newText","start","newSourceFile","updateSourceFile","span","newLength"],"mappings":"wSAmBA,IAAIA,GAAkB,EACtB,IACEA,EAAqD,oBAA5BC,YAC3B,CAAE,MAAOC,GAAS,CAElB,IAAMC,EAA2C,oBAAvBC,QAEpBC,EADeL,GAAmBC,aAAcK,QAAQ,UAAcH,GAAcC,QAAQG,IAAIC,MACvEC,QAAQC,IAAM,SAACC,GAAc,MAAgC,EAAE,EAgGjFC,EAAkC,SAACC,EAAkCC,GAChF,IAoGgBC,EAnGVC,EAAMH,EAAgBG,KAAO,GAK7BC,EAAQ,CACZ,WACA,sBACA,6BACA,eACA,wBACA,qBACA,mCACA,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AmBD,EAAe3F,KAGlC6F,EAA8B,MAAfH,EAAAA,EAAmBpM,EAAGwM,eAAe,EAAGF,EAAiBpL,QACxEuL,EACJH,EAAiB5K,MAAM,EAAG6K,EAAaG,OACvC3J,EACAuJ,EAAiB5K,MAAM6K,EAAaG,MAAQH,EAAarL,QACrDyL,EAAgB3M,EAAG4M,iBAAiBP,EAAgBI,EAAS,CACjEI,KAAMN,EACNO,UAAW/J,EAAQ7B,SAGrBoF,EAAWqG,EACZ,EACDhG,WAAU,SAACjB,GACT,IAAMO,EAAa2F,EAAgBM,aAAcpG,cAAcJ,GAC3DO,GACFU,EAAWV,EAEf,EAEJ"}
|
package/dist/vfs.esm.js
CHANGED
|
@@ -39,7 +39,8 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
|
|
|
39
39
|
var mergedCompilerOpts = _extends({}, defaultCompilerOptions(ts), compilerOptions);
|
|
40
40
|
var _createVirtualLanguag = createVirtualLanguageServiceHost(sys, rootFiles, mergedCompilerOpts, ts, customTransformers),
|
|
41
41
|
languageServiceHost = _createVirtualLanguag.languageServiceHost,
|
|
42
|
-
_updateFile = _createVirtualLanguag.updateFile
|
|
42
|
+
_updateFile = _createVirtualLanguag.updateFile,
|
|
43
|
+
_deleteFile = _createVirtualLanguag.deleteFile;
|
|
43
44
|
var languageService = ts.createLanguageService(languageServiceHost);
|
|
44
45
|
var diagnostics = languageService.getCompilerOptionsDiagnostics();
|
|
45
46
|
if (diagnostics.length) {
|
|
@@ -72,6 +73,12 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
|
|
|
72
73
|
newLength: content.length
|
|
73
74
|
});
|
|
74
75
|
_updateFile(newSourceFile);
|
|
76
|
+
},
|
|
77
|
+
deleteFile: function deleteFile(fileName) {
|
|
78
|
+
var sourceFile = languageService.getProgram().getSourceFile(fileName);
|
|
79
|
+
if (sourceFile) {
|
|
80
|
+
_deleteFile(sourceFile);
|
|
81
|
+
}
|
|
75
82
|
}
|
|
76
83
|
};
|
|
77
84
|
}
|
|
@@ -129,9 +136,12 @@ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_
|
|
|
129
136
|
var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));
|
|
130
137
|
return fs.readFileSync(path.join(lib, name), "utf8");
|
|
131
138
|
};
|
|
139
|
+
var isDtsFile = function isDtsFile(file) {
|
|
140
|
+
return /\.d\.([^\.]+\.)?[cm]?ts$/i.test(file);
|
|
141
|
+
};
|
|
132
142
|
var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve("typescript")));
|
|
133
143
|
var knownLibFiles = libFiles.filter(function (f) {
|
|
134
|
-
return f.startsWith("lib.") && f
|
|
144
|
+
return f.startsWith("lib.") && isDtsFile(f);
|
|
135
145
|
});
|
|
136
146
|
var fsMap = new Map();
|
|
137
147
|
knownLibFiles.forEach(function (lib) {
|
|
@@ -319,7 +329,8 @@ function createSystem(files) {
|
|
|
319
329
|
return directory === "/" ? Array.from(files.keys()) : [];
|
|
320
330
|
}),
|
|
321
331
|
readFile: audit("readFile", function (fileName) {
|
|
322
|
-
|
|
332
|
+
var _files$get;
|
|
333
|
+
return (_files$get = files.get(fileName)) != null ? _files$get : files.get(libize(fileName));
|
|
323
334
|
}),
|
|
324
335
|
resolvePath: function resolvePath(path) {
|
|
325
336
|
return path;
|
|
@@ -331,6 +342,9 @@ function createSystem(files) {
|
|
|
331
342
|
},
|
|
332
343
|
writeFile: function writeFile(fileName, contents) {
|
|
333
344
|
files.set(fileName, contents);
|
|
345
|
+
},
|
|
346
|
+
deleteFile: function deleteFile(fileName) {
|
|
347
|
+
files["delete"](fileName);
|
|
334
348
|
}
|
|
335
349
|
};
|
|
336
350
|
}
|
|
@@ -410,7 +424,11 @@ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
|
|
|
410
424
|
},
|
|
411
425
|
writeFile: function writeFile(fileName, contents) {
|
|
412
426
|
files.set(fileName, contents);
|
|
413
|
-
}
|
|
427
|
+
},
|
|
428
|
+
deleteFile: function deleteFile(fileName) {
|
|
429
|
+
files["delete"](fileName);
|
|
430
|
+
},
|
|
431
|
+
realpath: nodeSys.realpath
|
|
414
432
|
};
|
|
415
433
|
}
|
|
416
434
|
/**
|
|
@@ -434,14 +452,12 @@ function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
|
434
452
|
},
|
|
435
453
|
// '/lib.d.ts',
|
|
436
454
|
// getDefaultLibLocation: () => '/',
|
|
437
|
-
getDirectories: function getDirectories() {
|
|
438
|
-
return [];
|
|
439
|
-
},
|
|
440
455
|
getNewLine: function getNewLine() {
|
|
441
456
|
return sys.newLine;
|
|
442
457
|
},
|
|
443
|
-
getSourceFile: function getSourceFile(fileName) {
|
|
444
|
-
|
|
458
|
+
getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
|
|
459
|
+
var _ref;
|
|
460
|
+
return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
|
|
445
461
|
},
|
|
446
462
|
useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
|
|
447
463
|
return sys.useCaseSensitiveFileNames;
|
|
@@ -452,6 +468,12 @@ function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
|
452
468
|
sys.writeFile(sourceFile.fileName, sourceFile.text);
|
|
453
469
|
sourceFiles.set(sourceFile.fileName, sourceFile);
|
|
454
470
|
return alreadyExists;
|
|
471
|
+
},
|
|
472
|
+
deleteFile: function deleteFile(sourceFile) {
|
|
473
|
+
var alreadyExists = sourceFiles.has(sourceFile.fileName);
|
|
474
|
+
sourceFiles["delete"](sourceFile.fileName);
|
|
475
|
+
sys.deleteFile(sourceFile.fileName);
|
|
476
|
+
return alreadyExists;
|
|
455
477
|
}
|
|
456
478
|
};
|
|
457
479
|
return vHost;
|
|
@@ -463,7 +485,8 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
|
|
|
463
485
|
var fileNames = [].concat(rootFiles);
|
|
464
486
|
var _createVirtualCompile = createVirtualCompilerHost(sys, compilerOptions, ts),
|
|
465
487
|
compilerHost = _createVirtualCompile.compilerHost,
|
|
466
|
-
_updateFile2 = _createVirtualCompile.updateFile
|
|
488
|
+
_updateFile2 = _createVirtualCompile.updateFile,
|
|
489
|
+
_deleteFile2 = _createVirtualCompile.deleteFile;
|
|
467
490
|
var fileVersions = new Map();
|
|
468
491
|
var projectVersion = 0;
|
|
469
492
|
var languageServiceHost = _extends({}, compilerHost, {
|
|
@@ -508,6 +531,15 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
|
|
|
508
531
|
fileNames.push(sourceFile.fileName);
|
|
509
532
|
}
|
|
510
533
|
_updateFile2(sourceFile);
|
|
534
|
+
},
|
|
535
|
+
deleteFile: function deleteFile(sourceFile) {
|
|
536
|
+
projectVersion++;
|
|
537
|
+
fileVersions.set(sourceFile.fileName, projectVersion.toString());
|
|
538
|
+
var index = fileNames.indexOf(sourceFile.fileName);
|
|
539
|
+
if (index !== -1) {
|
|
540
|
+
fileNames.splice(index, 1);
|
|
541
|
+
}
|
|
542
|
+
_deleteFile2(sourceFile);
|
|
511
543
|
}
|
|
512
544
|
};
|
|
513
545
|
return lsHost;
|
package/dist/vfs.esm.js.map
CHANGED
|
@@ -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// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json\n// and then using that to generate the list of files from the server, but it is not included in the npm package\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, we're really working with the constraint that you can't get a list of files\n * when running in a browser.\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 // Note that this will include files which can't be found for particular versions of TS\n // TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011\n // or similar is merged.\n const files = [\n \"lib.d.ts\",\n \"lib.decorators.d.ts\",\n \"lib.decorators.legacy.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.webworker.iterable.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.date.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.intl.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.date.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2020.number.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.intl.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.es2022.array.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2022.error.d.ts\",\n \"lib.es2022.full.d.ts\",\n \"lib.es2022.intl.d.ts\",\n \"lib.es2022.object.d.ts\",\n \"lib.es2022.regexp.d.ts\",\n \"lib.es2022.sharedmemory.d.ts\",\n \"lib.es2022.string.d.ts\",\n \"lib.es2023.array.d.ts\",\n \"lib.es2023.collection.d.ts\",\n \"lib.es2023.d.ts\",\n \"lib.es2023.full.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.decorators.d.ts\",\n \"lib.esnext.disposable.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.symbol.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 *\n * The first two args are un-used, but kept around so as to not cause a\n * semver major bump for no gain to module users.\n */\nexport const createDefaultMapFromNodeModules = (\n _compilerOptions: CompilerOptions,\n _ts?: typeof import(\"typescript\"),\n tsLibDirectory?: string\n) => {\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 libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve(\"typescript\")))\n const knownLibFiles = libFiles.filter(f => f.startsWith(\"lib.\") && f.endsWith(\".d.ts\"))\n\n const fsMap = new Map<string, string>()\n knownLibFiles.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://playgroundcdn.typescriptlang.org/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 (\n Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text())))\n .then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\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(storelike)\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 (\n fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\n )\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n if (text) {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n }\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(\n files: Map<string, string>,\n _projectRoot: string,\n ts: TS,\n tsLibDirectory?: string\n): 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 && typeof contents === \"string\") {\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","_extends","defaultCompilerOptions","_createVirtualLanguag","createVirtualLanguageServiceHost","languageServiceHost","updateFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","_languageService$getP","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","_compilerOptions","_ts","tsLibDirectory","path","requirePath","fs","requireFS","getLib","dirname","require","resolve","readFileSync","join","libFiles","readdirSync","knownLibFiles","endsWith","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","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","_len","arguments","args","Array","_key","res","apply","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","libs","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","_createVirtualCompile","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAK,CAAA;AAC3B,IAAI;EACFA,eAAe,GAAG,OAAOC,YAAY,KAAgB,WAAA,CAAA;AACvD,CAAC,CAAC,OAAOC,KAAK,EAAE,EAAE;AAElB,IAAMC,UAAU,GAAG,OAAOC,OAAO,KAAgB,WAAA,CAAA;AACjD,IAAMC,WAAW,GAAIL,eAA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A;KACzC;IACDsK,SAAS,EAAE7L,GAAG,CAAC6L,SAAAA;GAChB,CAAA,CAAA;AAOD,EAAA,IAAM8B,MAAM,GAAW;AACrBjN,IAAAA,mBAAmB,EAAnBA,mBAAmB;AACnBC,IAAAA,UAAU,EAAE,SAAAA,UAAA6L,CAAAA,UAAU,EAAG;AACvBS,MAAAA,cAAc,EAAE,CAAA;AAChBD,MAAAA,YAAY,CAACtH,GAAG,CAAC8G,UAAU,CAACjL,QAAQ,EAAE0L,cAAc,CAACE,QAAQ,EAAE,CAAC,CAAA;MAChE,IAAI,CAACL,SAAS,CAACnG,QAAQ,CAAC6F,UAAU,CAACjL,QAAQ,CAAC,EAAE;AAC5CuL,QAAAA,SAAS,CAACxG,IAAI,CAACkG,UAAU,CAACjL,QAAQ,CAAC,CAAA;AACrC,OAAA;MACAZ,YAAU,CAAC6L,UAAU,CAAC,CAAA;AACxB,KAAA;GACD,CAAA;AACD,EAAA,OAAOmB,MAAM,CAAA;AACf,CAAA;AAEA,IAAMjJ,WAAW,GAAG,SAAdA,WAAWA,GAAQ;AACvB,EAAA,OAAOK,OAAO,CAAC6I,MAAM,CAACC,YAAY,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAA0B,CAAA;AACjF,CAAC,CAAA;AAED,IAAMjJ,SAAS,GAAG,SAAZA,SAASA,GAAQ;EACrB,OAAOG,OAAO,CAAC6I,MAAM,CAACC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAwB,CAAA;AACtE,CAAC;;;;"}
|
|
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\ntype FetchLike = (url: string) => Promise<{ json(): Promise<any>; text(): Promise<string> }>\n\ninterface LocalStorageLike {\n getItem(key: string): string | null\n setItem(key: string, value: string): void\n removeItem(key: string): void\n}\n\ndeclare var localStorage: LocalStorageLike | undefined;\ndeclare var fetch: FetchLike | undefined;\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 deleteFile: (fileName: string) => 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, deleteFile } = 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 deleteFile(fileName) {\n const sourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (sourceFile) {\n deleteFile(sourceFile)\n }\n }\n }\n}\n\n// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json\n// and then using that to generate the list of files from the server, but it is not included in the npm package\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, we're really working with the constraint that you can't get a list of files\n * when running in a browser.\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 // Note that this will include files which can't be found for particular versions of TS\n // TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011\n // or similar is merged.\n const files = [\n \"lib.d.ts\",\n \"lib.decorators.d.ts\",\n \"lib.decorators.legacy.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.webworker.iterable.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.date.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.intl.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.date.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2020.number.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.intl.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.es2022.array.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2022.error.d.ts\",\n \"lib.es2022.full.d.ts\",\n \"lib.es2022.intl.d.ts\",\n \"lib.es2022.object.d.ts\",\n \"lib.es2022.regexp.d.ts\",\n \"lib.es2022.sharedmemory.d.ts\",\n \"lib.es2022.string.d.ts\",\n \"lib.es2023.array.d.ts\",\n \"lib.es2023.collection.d.ts\",\n \"lib.es2023.d.ts\",\n \"lib.es2023.full.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.decorators.d.ts\",\n \"lib.esnext.disposable.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.symbol.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 *\n * The first two args are un-used, but kept around so as to not cause a\n * semver major bump for no gain to module users.\n */\nexport const createDefaultMapFromNodeModules = (\n _compilerOptions: CompilerOptions,\n _ts?: typeof import(\"typescript\"),\n tsLibDirectory?: string\n) => {\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 isDtsFile = (file: string) => /\\.d\\.([^\\.]+\\.)?[cm]?ts$/i.test(file)\n\n const libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve(\"typescript\")))\n const knownLibFiles = libFiles.filter(f => f.startsWith(\"lib.\") && isDtsFile(f))\n\n const fsMap = new Map<string, string>()\n knownLibFiles.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\nexport interface LZString {\n compressToUTF16(input: string): string\n decompressFromUTF16(compressed: string): string\n}\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?: LZString,\n fetcher?: FetchLike,\n storer?: LocalStorageLike\n) => {\n const fetchlike = fetcher || fetch!\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://playgroundcdn.typescriptlang.org/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 (\n Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text())))\n .then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\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(storelike)\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 (\n fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n // Return a NOOP for .d.ts files which aren't in the current build of TypeScript\n .catch(() => { })\n )\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n if (text) {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n }\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 deleteFile: (fileName) => {\n files.delete(fileName)\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(\n files: Map<string, string>,\n _projectRoot: string,\n ts: TS,\n tsLibDirectory?: string\n): 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 deleteFile: (fileName) => {\n files.delete(fileName)\n },\n realpath: nodeSys.realpath,\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 deleteFile: (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 getNewLine: () => sys.newLine,\n getSourceFile: (fileName, languageVersionOrOptions) => {\n return (\n sourceFiles.get(fileName) ||\n save(\n ts.createSourceFile(\n fileName,\n sys.readFile(fileName)!,\n languageVersionOrOptions ?? 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 deleteFile: sourceFile => {\n const alreadyExists = sourceFiles.has(sourceFile.fileName)\n sourceFiles.delete(sourceFile.fileName)\n sys.deleteFile!(sourceFile.fileName)\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, deleteFile } = 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 && typeof contents === \"string\") {\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 deleteFile: (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 deleteFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n const index = fileNames.indexOf(sourceFile.fileName)\n if (index !== -1) {\n fileNames.splice(index, 1)\n }\n deleteFile(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","_extends","defaultCompilerOptions","_createVirtualLanguag","createVirtualLanguageServiceHost","languageServiceHost","updateFile","deleteFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","_languageService$getP","getProgram","createFile","content","createSourceFile","target","optPrevTextSpan","prevSourceFile","prevFullContents","text","prevTextSpan","createTextSpan","newText","slice","start","newSourceFile","updateSourceFile","span","newLength","sourceFile","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","_compilerOptions","_ts","tsLibDirectory","path","requirePath","fs","requireFS","getLib","dirname","require","resolve","readFileSync","join","isDtsFile","file","test","libFiles","readdirSync","knownLibFiles","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","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","_len","arguments","args","Array","_key","res","apply","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","_files$get","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","libs","realpath","sourceFiles","save","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","languageVersionOrOptions","_ref","alreadyExists","fileNames","_createVirtualCompile","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","splice","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;AAmBA,IAAIA,eAAe,GAAG,KAAK,CAAA;AAC3B,IAAI;EACFA,eAAe,GAAG,OAAOC,YAAY,KAAgB,WAAA,CAAA;AACvD,CAAC,CAAC,OAAOC,KAAK,EAAE,EAAE;AAElB,IAAMC,UAAU,GAAG,OAAOC,OAAO,KAAgB,WAAA,CAAA;AACjD,IAAMC,WAAW,GAAIL,eAAe,iBAAIC,YAAa,CAACK,OAAO,CAAC,OAAO,CAAC,IAAMH,UAAU,IAAIC,OAAO,CAACG,GAAG,CAACC,KAAM,CAAA;AAC5G,IAAMC,QAAQ,GAAGJ,WAAW,GAAGK,OAAO,CAACC,GAAG,GAAG,UAACC,QAAc,EAAA;AAAA,EAAA,OAAgC,EAAE,CAAA;AAAA,CAAA,CAAA;AAW9F;;;;;;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nvironment(sys, rootFiles, ts, compilerOptions,
|
|
|
39
39
|
var mergedCompilerOpts = _extends({}, defaultCompilerOptions(ts), compilerOptions);
|
|
40
40
|
var _createVirtualLanguag = createVirtualLanguageServiceHost(sys, rootFiles, mergedCompilerOpts, ts, customTransformers),
|
|
41
41
|
languageServiceHost = _createVirtualLanguag.languageServiceHost,
|
|
42
|
-
_updateFile = _createVirtualLanguag.updateFile
|
|
42
|
+
_updateFile = _createVirtualLanguag.updateFile,
|
|
43
|
+
_deleteFile = _createVirtualLanguag.deleteFile;
|
|
43
44
|
var languageService = ts.createLanguageService(languageServiceHost);
|
|
44
45
|
var diagnostics = languageService.getCompilerOptionsDiagnostics();
|
|
45
46
|
if (diagnostics.length) {
|
|
@@ -72,6 +73,12 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
|
|
|
72
73
|
newLength: content.length
|
|
73
74
|
});
|
|
74
75
|
_updateFile(newSourceFile);
|
|
76
|
+
},
|
|
77
|
+
deleteFile: function deleteFile(fileName) {
|
|
78
|
+
var sourceFile = languageService.getProgram().getSourceFile(fileName);
|
|
79
|
+
if (sourceFile) {
|
|
80
|
+
_deleteFile(sourceFile);
|
|
81
|
+
}
|
|
75
82
|
}
|
|
76
83
|
};
|
|
77
84
|
}
|
|
@@ -129,9 +136,12 @@ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_
|
|
|
129
136
|
var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));
|
|
130
137
|
return fs.readFileSync(path.join(lib, name), "utf8");
|
|
131
138
|
};
|
|
139
|
+
var isDtsFile = function isDtsFile(file) {
|
|
140
|
+
return /\.d\.([^\.]+\.)?[cm]?ts$/i.test(file);
|
|
141
|
+
};
|
|
132
142
|
var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve("typescript")));
|
|
133
143
|
var knownLibFiles = libFiles.filter(function (f) {
|
|
134
|
-
return f.startsWith("lib.") && f
|
|
144
|
+
return f.startsWith("lib.") && isDtsFile(f);
|
|
135
145
|
});
|
|
136
146
|
var fsMap = new Map();
|
|
137
147
|
knownLibFiles.forEach(function (lib) {
|
|
@@ -319,7 +329,8 @@ function createSystem(files) {
|
|
|
319
329
|
return directory === "/" ? Array.from(files.keys()) : [];
|
|
320
330
|
}),
|
|
321
331
|
readFile: audit("readFile", function (fileName) {
|
|
322
|
-
|
|
332
|
+
var _files$get;
|
|
333
|
+
return (_files$get = files.get(fileName)) != null ? _files$get : files.get(libize(fileName));
|
|
323
334
|
}),
|
|
324
335
|
resolvePath: function resolvePath(path) {
|
|
325
336
|
return path;
|
|
@@ -331,6 +342,9 @@ function createSystem(files) {
|
|
|
331
342
|
},
|
|
332
343
|
writeFile: function writeFile(fileName, contents) {
|
|
333
344
|
files.set(fileName, contents);
|
|
345
|
+
},
|
|
346
|
+
deleteFile: function deleteFile(fileName) {
|
|
347
|
+
files["delete"](fileName);
|
|
334
348
|
}
|
|
335
349
|
};
|
|
336
350
|
}
|
|
@@ -410,7 +424,11 @@ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
|
|
|
410
424
|
},
|
|
411
425
|
writeFile: function writeFile(fileName, contents) {
|
|
412
426
|
files.set(fileName, contents);
|
|
413
|
-
}
|
|
427
|
+
},
|
|
428
|
+
deleteFile: function deleteFile(fileName) {
|
|
429
|
+
files["delete"](fileName);
|
|
430
|
+
},
|
|
431
|
+
realpath: nodeSys.realpath
|
|
414
432
|
};
|
|
415
433
|
}
|
|
416
434
|
/**
|
|
@@ -434,14 +452,12 @@ function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
|
434
452
|
},
|
|
435
453
|
// '/lib.d.ts',
|
|
436
454
|
// getDefaultLibLocation: () => '/',
|
|
437
|
-
getDirectories: function getDirectories() {
|
|
438
|
-
return [];
|
|
439
|
-
},
|
|
440
455
|
getNewLine: function getNewLine() {
|
|
441
456
|
return sys.newLine;
|
|
442
457
|
},
|
|
443
|
-
getSourceFile: function getSourceFile(fileName) {
|
|
444
|
-
|
|
458
|
+
getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
|
|
459
|
+
var _ref;
|
|
460
|
+
return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
|
|
445
461
|
},
|
|
446
462
|
useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
|
|
447
463
|
return sys.useCaseSensitiveFileNames;
|
|
@@ -452,6 +468,12 @@ function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
|
452
468
|
sys.writeFile(sourceFile.fileName, sourceFile.text);
|
|
453
469
|
sourceFiles.set(sourceFile.fileName, sourceFile);
|
|
454
470
|
return alreadyExists;
|
|
471
|
+
},
|
|
472
|
+
deleteFile: function deleteFile(sourceFile) {
|
|
473
|
+
var alreadyExists = sourceFiles.has(sourceFile.fileName);
|
|
474
|
+
sourceFiles["delete"](sourceFile.fileName);
|
|
475
|
+
sys.deleteFile(sourceFile.fileName);
|
|
476
|
+
return alreadyExists;
|
|
455
477
|
}
|
|
456
478
|
};
|
|
457
479
|
return vHost;
|
|
@@ -463,7 +485,8 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
|
|
|
463
485
|
var fileNames = [].concat(rootFiles);
|
|
464
486
|
var _createVirtualCompile = createVirtualCompilerHost(sys, compilerOptions, ts),
|
|
465
487
|
compilerHost = _createVirtualCompile.compilerHost,
|
|
466
|
-
_updateFile2 = _createVirtualCompile.updateFile
|
|
488
|
+
_updateFile2 = _createVirtualCompile.updateFile,
|
|
489
|
+
_deleteFile2 = _createVirtualCompile.deleteFile;
|
|
467
490
|
var fileVersions = new Map();
|
|
468
491
|
var projectVersion = 0;
|
|
469
492
|
var languageServiceHost = _extends({}, compilerHost, {
|
|
@@ -508,6 +531,15 @@ function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, c
|
|
|
508
531
|
fileNames.push(sourceFile.fileName);
|
|
509
532
|
}
|
|
510
533
|
_updateFile2(sourceFile);
|
|
534
|
+
},
|
|
535
|
+
deleteFile: function deleteFile(sourceFile) {
|
|
536
|
+
projectVersion++;
|
|
537
|
+
fileVersions.set(sourceFile.fileName, projectVersion.toString());
|
|
538
|
+
var index = fileNames.indexOf(sourceFile.fileName);
|
|
539
|
+
if (index !== -1) {
|
|
540
|
+
fileNames.splice(index, 1);
|
|
541
|
+
}
|
|
542
|
+
_deleteFile2(sourceFile);
|
|
511
543
|
}
|
|
512
544
|
};
|
|
513
545
|
return lsHost;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript/vfs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "TypeScript team",
|
|
6
6
|
"homepage": "https://github.com/microsoft/TypeScript-Website",
|
|
@@ -42,11 +42,13 @@
|
|
|
42
42
|
"jest": "^29.5.0",
|
|
43
43
|
"jest-environment-jsdom": "^29.5.0",
|
|
44
44
|
"jest-watch-typeahead": "^2.2.2",
|
|
45
|
-
"lz-string": "^1.5.0",
|
|
46
45
|
"ts-jest": "^29.0.5",
|
|
47
46
|
"tslib": "^2.6.2",
|
|
48
47
|
"typescript": "*"
|
|
49
48
|
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"typescript": "*"
|
|
51
|
+
},
|
|
50
52
|
"scripts": {
|
|
51
53
|
"start": "dts watch",
|
|
52
54
|
"bootstrap": "pnpm build",
|