@typescript/vfs 1.5.0 → 1.5.2
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/vfs.cjs.development.js +30 -90
- 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 +30 -90
- package/dist/vfs.esm.js.map +1 -1
- package/dist/vfs.globals.js +30 -90
- package/package.json +17 -15
|
@@ -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://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return (\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) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n\nconst requirePath = () => {\n return require(String.fromCharCode(112, 97, 116, 104)) as typeof import(\"path\")\n}\n\nconst requireFS = () => {\n return require(String.fromCharCode(102, 115)) as typeof import(\"fs\")\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","shouldDebug","getItem","env","DEBUG","debugLog","console","log","_message","createVirtualTypeScriptEnvironment","sys","rootFiles","ts","compilerOptions","customTransformers","mergedCompilerOpts","defaultCompilerOptions","createVirtualLanguageServiceHost","languageServiceHost","updateFile","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","length","compilerHost","createVirtualCompilerHost","Error","formatDiagnostics","name","getSourceFile","fileName","getProgram","createFile","content","createSourceFile","target","optPrevTextSpan","prevSourceFile","prevFullContents","text","prevTextSpan","createTextSpan","newText","slice","start","newSourceFile","updateSourceFile","span","newLength","knownLibFilesForCompilerOptions","ScriptTarget","ES5","lib","files","targetToCut","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","getMax","array","reduce","max","current","undefined","indexesForCutting","map","cutIndex","libCutIndex","finalCutIndex","Math","createDefaultMapFromNodeModules","_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","args","res","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","libs","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAtB;;AACA,IAAI;AACFA,EAAAA,eAAe,GAAG,OAAOC,YAAP,gBAAlB;AACD,CAFD,CAEE,OAAOC,KAAP,EAAc;;AAEhB,IAAMC,UAAU,GAAG,OAAOC,OAAP,gBAAnB;AACA,IAAMC,WAAW,GAAIL,eAAe,iBAAIC,YAAY,CAACK,OAAb,CAAqB,OAArB,CAApB,IAAuDH,UAAU,IAAIC,OAAO,CAACG,GAAR,CAAYC,KAArG;AACA,IAAMC,QAAQ,GAAGJ,WAAW,GAAGK,OAAO,CAACC,GAAX,GAAiB,UAACC,QAAD;AAAA,SAA+C,EAA/C;AAAA,CAA7C;AAUA;;;;;;;;;;;SAWgBC,mCACdC,KACAC,WACAC,IACAC,iBACAC;MADAD;AAAAA,IAAAA,kBAAmC;;;AAGnC,MAAME,kBAAkB,gBAAQC,sBAAsB,CAACJ,EAAD,CAA9B,EAAuCC,eAAvC,CAAxB;;8BAE4CI,gCAAgC,CAC1EP,GAD0E,EAE1EC,SAF0E,EAG1EI,kBAH0E,EAI1EH,EAJ0E,EAK1EE,kBAL0E;MAApEI,4CAAAA;MAAqBC,oCAAAA;;AAO7B,MAAMC,eAAe,GAAGR,EAAE,CAACS,qBAAH,CAAyBH,mBAAzB,CAAxB;AACA,MAAMI,WAAW,GAAGF,eAAe,CAACG,6BAAhB,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AyB,EAAzB,EAA6B,GAA7B,EAAkC,GAAlC,CAAD,CAAd;AACD,CAFD;;AAIA,IAAM5I,SAAS,GAAG,SAAZA,SAAY;AAChB,SAAOG,OAAO,CAACwI,MAAM,CAACC,YAAP,CAAoB,GAApB,EAAyB,GAAzB,CAAD,CAAd;AACD,CAFD;;;;;;;;;;;;;"}
|
|
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,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,CAAE,CAAA;AAEhF,EAAA,IAAAK,qBAAA,GAA4CC,gCAAgC,CAC1ET,GAAG,EACHC,SAAS,EACTI,kBAAkB,EAClBH,EAAE,EACF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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,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(){return
|
|
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;
|
|
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://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return (\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) {\n return ts.ScriptSnapshot.fromString(contents)\n }\n return\n },\n getScriptVersion: fileName => {\n return fileVersions.get(fileName) || \"0\"\n },\n writeFile: sys.writeFile,\n }\n\n type Return = {\n languageServiceHost: LanguageServiceHost\n updateFile: (sourceFile: import(\"typescript\").SourceFile) => void\n }\n\n const lsHost: Return = {\n languageServiceHost,\n updateFile: sourceFile => {\n projectVersion++\n fileVersions.set(sourceFile.fileName, projectVersion.toString())\n if (!fileNames.includes(sourceFile.fileName)) {\n fileNames.push(sourceFile.fileName)\n }\n updateFile(sourceFile)\n },\n }\n return lsHost\n}\n\nconst requirePath = () => {\n return require(String.fromCharCode(112, 97, 116, 104)) as typeof import(\"path\")\n}\n\nconst requireFS = () => {\n return require(String.fromCharCode(102, 115)) as typeof import(\"fs\")\n}\n"],"names":["hasLocalStorage","localStorage","error","hasProcess","process","debugLog","getItem","env","DEBUG","console","log","_message","knownLibFilesForCompilerOptions","compilerOptions","ts","array","lib","files","targetToCut","ScriptTarget","target","ES5","matches","filter","f","startsWith","toLowerCase","targetCutIndex","indexOf","pop","libCutIndex","map","length","reduce","max","current","undefined","finalCutIndex","Math","slice","addAllFilesFromFolder","workingDir","path","requirePath","fs","requireFS","walk","dir","results","readdirSync","forEach","file","join","stat","statSync","isDirectory","concat","push","fsPath","replace","content","readFileSync","includes","extname","set","notImplemented","methodName","Error","audit","name","fn","args","res","smallres","defaultCompilerOptions","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createVirtualCompilerHost","sys","sourceFiles","Map","compilerHost","getCanonicalFileName","fileName","getDefaultLibFileName","getDirectories","getNewLine","newLine","getSourceFile","get","sourceFile","createSourceFile","readFile","useCaseSensitiveFileNames","updateFile","alreadyExists","has","writeFile","text","createVirtualLanguageServiceHost","rootFiles","customTransformers","fileNames","fileVersions","projectVersion","languageServiceHost","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","contents","ScriptSnapshot","fromString","getScriptVersion","require","String","fromCharCode","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","fsMap","prefix","storelike","Object","keys","key","removeItem","Promise","all","str","cacheKey","resolve","decompressFromUTF16","then","resp","t","setItem","compressToUTF16","index","_compilerOptions","_ts","tsLibDirectory","knownLibFiles","dirname","endsWith","getLib","_projectRoot","root","nodeSys","tsLib","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","tsLibName","getCurrentDirectory","getExecutingFilePath","readDirectory","result","libs","resolvePath","write","mergedCompilerOpts","languageService","createLanguageService","diagnostics","getCompilerOptionsDiagnostics","formatDiagnostics","getProgram","_languageService$getP","createFile","optPrevTextSpan","prevSourceFile","prevFullContents","prevTextSpan","createTextSpan","newText","start","newSourceFile","updateSourceFile","span","newLength"],"mappings":"mRAQA,IAAIA,GAAkB,EACtB,IACEA,sBAAyBC,aACzB,MAAOC,IAET,IAAMC,sBAAoBC,QAEpBC,EADeL,GAAmBC,aAAaK,QAAQ,UAAcH,GAAcC,QAAQG,IAAIC,MACtEC,QAAQC,IAAM,SAACC,SAA8C,IAyF/EC,EAAkC,SAACC,EAAkCC,OAqGhEC,EAnGVC,EAAMH,EAAgBG,KAAO,GAK7BC,EAAQ,CACZ,WACA,sBACA,6BACA,eACA,wBACA,qBACA,mCACA,8BACA,sBACA,eACA,eACA,6BACA,uBACA,kBACA,4BACA,2BACA,0BACA,wBACA,0BACA,yBACA,mCACA,gCACA,kBACA,uBACA,kBACA,uBACA,uBACA,uBACA,yBACA,+BACA,yBACA,8BACA,iCACA,gCACA,kBACA,uBACA,uBACA,0BACA,yBACA,wBACA,kBACA,uBACA,uBACA,yBACA,yBACA,yBACA,yBACA,kBACA,uBACA,uBACA,uBACA,yBACA,0BACA,+BACA,yBACA,mCACA,kBACA,uBACA,uBACA,0BACA,yBACA,0BACA,wBACA,kBACA,wBACA,uBACA,uBACA,yBACA,yBACA,+BACA,yBACA,wBACA,6BACA,kBACA,uBACA,wBACA,gCACA,yBACA,kBACA,6BACA,6BACA,uBACA,uBACA,0BACA,yBACA,yBACA,2BAGIC,EAAcJ,EAAGK,aAhGRN,EAAgBO,QAAUN,EAAGK,aAAaE,KAiGnDC,EAAUL,EAAMM,QAAO,SAAAC,UAAKA,EAAEC,kBAAkBP,EAAYQ,kBAC5DC,EAAiBV,EAAMW,QAAQN,EAAQO,OAcvCC,IAZ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escript\").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,MAAOC,GAAS,CAElB,IAAMC,EAA2C,oBAAvBC,QAEpBC,EADeL,GAAmBC,aAAaK,Q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