@typescript/vfs 1.3.6 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +89 -85
- package/dist/vfs.cjs.development.js +74 -60
- 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 +74 -60
- package/dist/vfs.esm.js.map +1 -1
- package/dist/vfs.globals.js +74 -60
- package/package.json +13 -2
- package/CHANGELOG.md +0 -15
package/dist/vfs.esm.js
CHANGED
|
@@ -27,15 +27,15 @@ var shouldDebug = hasLocalStorage && /*#__PURE__*/localStorage.getItem("DEBUG")
|
|
|
27
27
|
var debugLog = shouldDebug ? console.log : function (_message) {
|
|
28
28
|
return "";
|
|
29
29
|
};
|
|
30
|
-
/**
|
|
31
|
-
* Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with
|
|
32
|
-
* @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.
|
|
33
|
-
*
|
|
34
|
-
* @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)
|
|
35
|
-
* @param rootFiles a list of files which are considered inside the project
|
|
36
|
-
* @param ts a copy pf the TypeScript module
|
|
37
|
-
* @param compilerOptions the options for this compiler run
|
|
38
|
-
* @param customTransformers custom transformers for this compiler run
|
|
30
|
+
/**
|
|
31
|
+
* Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with
|
|
32
|
+
* @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.
|
|
33
|
+
*
|
|
34
|
+
* @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)
|
|
35
|
+
* @param rootFiles a list of files which are considered inside the project
|
|
36
|
+
* @param ts a copy pf the TypeScript module
|
|
37
|
+
* @param compilerOptions the options for this compiler run
|
|
38
|
+
* @param customTransformers custom transformers for this compiler run
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions, customTransformers) {
|
|
@@ -89,19 +89,25 @@ function createVirtualTypeScriptEnvironment(sys, rootFiles, ts, compilerOptions,
|
|
|
89
89
|
_updateFile(newSourceFile);
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
92
|
+
} // TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json
|
|
93
|
+
// and then using that to generate the list of files from the server, but it is not included in the npm package
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Grab the list of lib files for a particular target, will return a bit more than necessary (by including
|
|
97
|
+
* the dom) but that's OK, we're really working with the constraint that you can't get a list of files
|
|
98
|
+
* when running in a browser.
|
|
99
|
+
*
|
|
100
|
+
* @param target The compiler settings target baseline
|
|
101
|
+
* @param ts A copy of the TypeScript module
|
|
99
102
|
*/
|
|
100
103
|
|
|
101
104
|
var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
|
|
102
105
|
var target = compilerOptions.target || ts.ScriptTarget.ES5;
|
|
103
|
-
var lib = compilerOptions.lib || [];
|
|
104
|
-
|
|
106
|
+
var lib = compilerOptions.lib || []; // Note that this will include files which can't be found for particular versions of TS
|
|
107
|
+
// TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011
|
|
108
|
+
// or similar is merged.
|
|
109
|
+
|
|
110
|
+
var files = ["lib.d.ts", "lib.decorators.d.ts", "lib.decorators.legacy.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.d.ts", "lib.webworker.iterable.d.ts", "lib.scripthost.d.ts", "lib.es5.d.ts", "lib.es6.d.ts", "lib.es2015.collection.d.ts", "lib.es2015.core.d.ts", "lib.es2015.d.ts", "lib.es2015.generator.d.ts", "lib.es2015.iterable.d.ts", "lib.es2015.promise.d.ts", "lib.es2015.proxy.d.ts", "lib.es2015.reflect.d.ts", "lib.es2015.symbol.d.ts", "lib.es2015.symbol.wellknown.d.ts", "lib.es2016.array.include.d.ts", "lib.es2016.d.ts", "lib.es2016.full.d.ts", "lib.es2017.d.ts", "lib.es2017.date.d.ts", "lib.es2017.full.d.ts", "lib.es2017.intl.d.ts", "lib.es2017.object.d.ts", "lib.es2017.sharedmemory.d.ts", "lib.es2017.string.d.ts", "lib.es2017.typedarrays.d.ts", "lib.es2018.asyncgenerator.d.ts", "lib.es2018.asynciterable.d.ts", "lib.es2018.d.ts", "lib.es2018.full.d.ts", "lib.es2018.intl.d.ts", "lib.es2018.promise.d.ts", "lib.es2018.regexp.d.ts", "lib.es2019.array.d.ts", "lib.es2019.d.ts", "lib.es2019.full.d.ts", "lib.es2019.intl.d.ts", "lib.es2019.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.d.ts", "lib.es2020.date.d.ts", "lib.es2020.full.d.ts", "lib.es2020.intl.d.ts", "lib.es2020.number.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.intl.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.es2022.array.d.ts", "lib.es2022.d.ts", "lib.es2022.error.d.ts", "lib.es2022.full.d.ts", "lib.es2022.intl.d.ts", "lib.es2022.object.d.ts", "lib.es2022.regexp.d.ts", "lib.es2022.sharedmemory.d.ts", "lib.es2022.string.d.ts", "lib.es2023.array.d.ts", "lib.es2023.collection.d.ts", "lib.es2023.d.ts", "lib.es2023.full.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.d.ts", "lib.esnext.decorators.d.ts", "lib.esnext.disposable.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.string.d.ts", "lib.esnext.symbol.d.ts", "lib.esnext.weakref.d.ts"];
|
|
105
111
|
var targetToCut = ts.ScriptTarget[target];
|
|
106
112
|
var matches = files.filter(function (f) {
|
|
107
113
|
return f.startsWith("lib." + targetToCut.toLowerCase());
|
|
@@ -127,31 +133,35 @@ var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(c
|
|
|
127
133
|
var finalCutIndex = Math.max(targetCutIndex, libCutIndex);
|
|
128
134
|
return files.slice(0, finalCutIndex + 1);
|
|
129
135
|
};
|
|
130
|
-
/**
|
|
131
|
-
* Sets up a Map with lib contents by grabbing the necessary files from
|
|
132
|
-
* the local copy of typescript via the file system.
|
|
136
|
+
/**
|
|
137
|
+
* Sets up a Map with lib contents by grabbing the necessary files from
|
|
138
|
+
* the local copy of typescript via the file system.
|
|
139
|
+
*
|
|
140
|
+
* The first two args are un-used, but kept around so as to not cause a
|
|
141
|
+
* semver major bump for no gain to module users.
|
|
133
142
|
*/
|
|
134
143
|
|
|
135
|
-
var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(
|
|
136
|
-
var tsModule = ts || require("typescript");
|
|
137
|
-
|
|
144
|
+
var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_compilerOptions, _ts, tsLibDirectory) {
|
|
138
145
|
var path = requirePath();
|
|
139
146
|
var fs = requireFS();
|
|
140
147
|
|
|
141
148
|
var getLib = function getLib(name) {
|
|
142
|
-
var lib = path.dirname(require.resolve("typescript"));
|
|
149
|
+
var lib = tsLibDirectory || path.dirname(require.resolve("typescript"));
|
|
143
150
|
return fs.readFileSync(path.join(lib, name), "utf8");
|
|
144
151
|
};
|
|
145
152
|
|
|
146
|
-
var
|
|
153
|
+
var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve("typescript")));
|
|
154
|
+
var knownLibFiles = libFiles.filter(function (f) {
|
|
155
|
+
return f.startsWith("lib.") && f.endsWith(".d.ts");
|
|
156
|
+
});
|
|
147
157
|
var fsMap = new Map();
|
|
148
|
-
|
|
158
|
+
knownLibFiles.forEach(function (lib) {
|
|
149
159
|
fsMap.set("/" + lib, getLib(lib));
|
|
150
160
|
});
|
|
151
161
|
return fsMap;
|
|
152
162
|
};
|
|
153
|
-
/**
|
|
154
|
-
* Adds recursively files from the FS into the map based on the folder
|
|
163
|
+
/**
|
|
164
|
+
* Adds recursively files from the FS into the map based on the folder
|
|
155
165
|
*/
|
|
156
166
|
|
|
157
167
|
var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
|
|
@@ -192,17 +202,17 @@ var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
|
|
|
192
202
|
var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {
|
|
193
203
|
return addAllFilesFromFolder(map, "node_modules/@types");
|
|
194
204
|
};
|
|
195
|
-
/**
|
|
196
|
-
* Create a virtual FS Map with the lib files from a particular TypeScript
|
|
197
|
-
* version based on the target, Always includes dom ATM.
|
|
198
|
-
*
|
|
199
|
-
* @param options The compiler target, which dictates the libs to set up
|
|
200
|
-
* @param version the versions of TypeScript which are supported
|
|
201
|
-
* @param cache should the values be stored in local storage
|
|
202
|
-
* @param ts a copy of the typescript import
|
|
203
|
-
* @param lzstring an optional copy of the lz-string import
|
|
204
|
-
* @param fetcher an optional replacement for the global fetch function (tests mainly)
|
|
205
|
-
* @param storer an optional replacement for the localStorage global (tests mainly)
|
|
205
|
+
/**
|
|
206
|
+
* Create a virtual FS Map with the lib files from a particular TypeScript
|
|
207
|
+
* version based on the target, Always includes dom ATM.
|
|
208
|
+
*
|
|
209
|
+
* @param options The compiler target, which dictates the libs to set up
|
|
210
|
+
* @param version the versions of TypeScript which are supported
|
|
211
|
+
* @param cache should the values be stored in local storage
|
|
212
|
+
* @param ts a copy of the typescript import
|
|
213
|
+
* @param lzstring an optional copy of the lz-string import
|
|
214
|
+
* @param fetcher an optional replacement for the global fetch function (tests mainly)
|
|
215
|
+
* @param storer an optional replacement for the localStorage global (tests mainly)
|
|
206
216
|
*/
|
|
207
217
|
|
|
208
218
|
var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache, ts, lzstring, fetcher, storer) {
|
|
@@ -229,13 +239,14 @@ var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version,
|
|
|
229
239
|
contents.forEach(function (text, index) {
|
|
230
240
|
return fsMap.set("/" + files[index], text);
|
|
231
241
|
});
|
|
232
|
-
})
|
|
242
|
+
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
|
|
243
|
+
["catch"](function () {});
|
|
233
244
|
} // A localstorage and lzzip aware version of the lib files
|
|
234
245
|
|
|
235
246
|
|
|
236
247
|
function cached() {
|
|
237
248
|
var storelike = storer || localStorage;
|
|
238
|
-
var keys = Object.keys(
|
|
249
|
+
var keys = Object.keys(storelike);
|
|
239
250
|
keys.forEach(function (key) {
|
|
240
251
|
// Remove anything which isn't from this version
|
|
241
252
|
if (key.startsWith("ts-lib-") && !key.startsWith("ts-lib-" + version)) {
|
|
@@ -253,14 +264,17 @@ var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version,
|
|
|
253
264
|
}).then(function (t) {
|
|
254
265
|
storelike.setItem(cacheKey, zip(t));
|
|
255
266
|
return t;
|
|
256
|
-
})
|
|
267
|
+
}) // Return a NOOP for .d.ts files which aren't in the current build of TypeScript
|
|
268
|
+
["catch"](function () {});
|
|
257
269
|
} else {
|
|
258
270
|
return Promise.resolve(unzip(content));
|
|
259
271
|
}
|
|
260
272
|
})).then(function (contents) {
|
|
261
273
|
contents.forEach(function (text, index) {
|
|
262
|
-
|
|
263
|
-
|
|
274
|
+
if (text) {
|
|
275
|
+
var name = "/" + files[index];
|
|
276
|
+
fsMap.set(name, text);
|
|
277
|
+
}
|
|
264
278
|
});
|
|
265
279
|
});
|
|
266
280
|
}
|
|
@@ -308,9 +322,9 @@ var defaultCompilerOptions = function defaultCompilerOptions(ts) {
|
|
|
308
322
|
var libize = function libize(path) {
|
|
309
323
|
return path.replace("/", "/lib.").toLowerCase();
|
|
310
324
|
};
|
|
311
|
-
/**
|
|
312
|
-
* Creates an in-memory System object which can be used in a TypeScript program, this
|
|
313
|
-
* is what provides read/write aspects of the virtual fs
|
|
325
|
+
/**
|
|
326
|
+
* Creates an in-memory System object which can be used in a TypeScript program, this
|
|
327
|
+
* is what provides read/write aspects of the virtual fs
|
|
314
328
|
*/
|
|
315
329
|
|
|
316
330
|
|
|
@@ -360,20 +374,20 @@ function createSystem(files) {
|
|
|
360
374
|
}
|
|
361
375
|
};
|
|
362
376
|
}
|
|
363
|
-
/**
|
|
364
|
-
* Creates a file-system backed System object which can be used in a TypeScript program, you provide
|
|
365
|
-
* a set of virtual files which are prioritised over the FS versions, then a path to the root of your
|
|
366
|
-
* project (basically the folder your node_modules lives)
|
|
377
|
+
/**
|
|
378
|
+
* Creates a file-system backed System object which can be used in a TypeScript program, you provide
|
|
379
|
+
* a set of virtual files which are prioritised over the FS versions, then a path to the root of your
|
|
380
|
+
* project (basically the folder your node_modules lives)
|
|
367
381
|
*/
|
|
368
382
|
|
|
369
|
-
function createFSBackedSystem(files, _projectRoot, ts) {
|
|
383
|
+
function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
|
|
370
384
|
// We need to make an isolated folder for the tsconfig, but also need to be able to resolve the
|
|
371
385
|
// existing node_modules structures going back through the history
|
|
372
386
|
var root = _projectRoot + "/vfs";
|
|
373
387
|
var path = requirePath(); // The default System in TypeScript
|
|
374
388
|
|
|
375
389
|
var nodeSys = ts.sys;
|
|
376
|
-
var tsLib = path.dirname(require.resolve("typescript"));
|
|
390
|
+
var tsLib = tsLibDirectory != null ? tsLibDirectory : path.dirname(require.resolve("typescript"));
|
|
377
391
|
return {
|
|
378
392
|
// @ts-ignore
|
|
379
393
|
name: "fs-vfs",
|
|
@@ -446,10 +460,10 @@ function createFSBackedSystem(files, _projectRoot, ts) {
|
|
|
446
460
|
}
|
|
447
461
|
};
|
|
448
462
|
}
|
|
449
|
-
/**
|
|
450
|
-
* Creates an in-memory CompilerHost -which is essentially an extra wrapper to System
|
|
451
|
-
* which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile
|
|
452
|
-
* instances to the in-memory file system.
|
|
463
|
+
/**
|
|
464
|
+
* Creates an in-memory CompilerHost -which is essentially an extra wrapper to System
|
|
465
|
+
* which works with TypeScript objects - returns both a compiler host, and a way to add new SourceFile
|
|
466
|
+
* instances to the in-memory file system.
|
|
453
467
|
*/
|
|
454
468
|
|
|
455
469
|
function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
@@ -491,8 +505,8 @@ function createVirtualCompilerHost(sys, compilerOptions, ts) {
|
|
|
491
505
|
};
|
|
492
506
|
return vHost;
|
|
493
507
|
}
|
|
494
|
-
/**
|
|
495
|
-
* Creates an object which can host a language service against the virtual file-system
|
|
508
|
+
/**
|
|
509
|
+
* Creates an object which can host a language service against the virtual file-system
|
|
496
510
|
*/
|
|
497
511
|
|
|
498
512
|
function createVirtualLanguageServiceHost(sys, rootFiles, compilerOptions, ts, customTransformers) {
|
package/dist/vfs.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vfs.esm.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) { }\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n const files = [\n \"lib.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.promise.d.ts\",\n \"lib.esnext.string.d.ts\",\n \"lib.esnext.weakref.d.ts\",\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n */\nexport const createDefaultMapFromNodeModules = (compilerOptions: CompilerOptions, ts?: typeof import(\"typescript\")) => {\n const tsModule = ts || require(\"typescript\")\n const path = requirePath()\n const fs = requireFS()\n\n const getLib = (name: string) => {\n const lib = path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libs = knownLibFilesForCompilerOptions(compilerOptions, tsModule)\n const fsMap = new Map<string, string>()\n libs.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = requirePath()\n const fs = requireFS()\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://typescript.azureedge.net/cdn/${version}/typescript/lib/`\n\n function zip(str: string) {\n return lzstring ? lzstring.compressToUTF16(str) : str\n }\n\n function unzip(str: string) {\n return lzstring ? lzstring.decompressFromUTF16(str) : str\n }\n\n // Map the known libs to a node fetch promise, then return the contents\n function uncached() {\n return Promise.all(files.map(lib => fetchlike(prefix + lib).then(resp => resp.text()))).then(contents => {\n contents.forEach((text, index) => fsMap.set(\"/\" + files[index], text))\n })\n }\n\n // A localstorage and lzzip aware version of the lib files\n function cached() {\n const storelike = storer || localStorage\n\n const keys = Object.keys(localStorage)\n keys.forEach(key => {\n // Remove anything which isn't from this version\n if (key.startsWith(\"ts-lib-\") && !key.startsWith(\"ts-lib-\" + version)) {\n storelike.removeItem(key)\n }\n })\n\n return Promise.all(\n files.map(lib => {\n const cacheKey = `ts-lib-${version}-${lib}`\n const content = storelike.getItem(cacheKey)\n\n if (!content) {\n // Make the API call and store the text concent in the cache\n return fetchlike(prefix + lib)\n .then(resp => resp.text())\n .then(t => {\n storelike.setItem(cacheKey, zip(t))\n return t\n })\n } else {\n return Promise.resolve(unzip(content))\n }\n })\n ).then(contents => {\n contents.forEach((text, index) => {\n const name = \"/\" + files[index]\n fsMap.set(name, text)\n })\n })\n }\n\n const func = cache ? cached : uncached\n return func().then(() => fsMap)\n}\n\nfunction notImplemented(methodName: string): any {\n throw new Error(`Method '${methodName}' is not implemented.`)\n}\n\nfunction audit<ArgsT extends any[], ReturnT>(\n name: string,\n fn: (...args: ArgsT) => ReturnT\n): (...args: ArgsT) => ReturnT {\n return (...args) => {\n const res = fn(...args)\n\n const smallres = typeof res === \"string\" ? res.slice(0, 80) + \"...\" : res\n debugLog(\"> \" + name, ...args)\n debugLog(\"< \" + smallres)\n\n return res\n }\n}\n\n/** The default compiler options if TypeScript could ever change the compiler options */\nconst defaultCompilerOptions = (ts: typeof import(\"typescript\")): CompilerOptions => {\n return {\n ...ts.getDefaultCompilerOptions(),\n jsx: ts.JsxEmit.React,\n strict: true,\n esModuleInterop: true,\n module: ts.ModuleKind.ESNext,\n suppressOutputPathCheck: true,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.NodeJs,\n }\n}\n\n// \"/DOM.d.ts\" => \"/lib.dom.d.ts\"\nconst libize = (path: string) => path.replace(\"/\", \"/lib.\").toLowerCase()\n\n/**\n * Creates an in-memory System object which can be used in a TypeScript program, this\n * is what provides read/write aspects of the virtual fs\n */\nexport function createSystem(files: Map<string, string>): System {\n return {\n args: [],\n createDirectory: () => notImplemented(\"createDirectory\"),\n // TODO: could make a real file tree\n directoryExists: audit(\"directoryExists\", directory => {\n return Array.from(files.keys()).some(path => path.startsWith(directory))\n }),\n exit: () => notImplemented(\"exit\"),\n fileExists: audit(\"fileExists\", fileName => files.has(fileName) || files.has(libize(fileName))),\n getCurrentDirectory: () => \"/\",\n getDirectories: () => [],\n getExecutingFilePath: () => notImplemented(\"getExecutingFilePath\"),\n readDirectory: audit(\"readDirectory\", directory => (directory === \"/\" ? Array.from(files.keys()) : [])),\n readFile: audit(\"readFile\", fileName => files.get(fileName) || files.get(libize(fileName))),\n resolvePath: path => path,\n newLine: \"\\n\",\n useCaseSensitiveFileNames: true,\n write: () => notImplemented(\"write\"),\n writeFile: (fileName, contents) => {\n files.set(fileName, contents)\n },\n }\n}\n\n/**\n * Creates a file-system backed System object which can be used in a TypeScript program, you provide\n * a set of virtual files which are prioritised over the FS versions, then a path to the root of your\n * project (basically the folder your node_modules lives)\n */\nexport function createFSBackedSystem(files: Map<string, string>, _projectRoot: string, ts: TS): 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 = 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","tsModule","require","path","requirePath","fs","requireFS","getLib","dirname","resolve","readFileSync","join","libs","fsMap","Map","forEach","set","addAllFilesFromFolder","workingDir","walk","dir","results","list","readdirSync","file","stat","statSync","isDirectory","concat","push","allFiles","fsPath","replace","validExtensions","includes","extname","addFilesForTypesIntoFolder","createDefaultMapFromCDN","options","version","cache","lzstring","fetcher","storer","fetchlike","fetch","prefix","zip","str","compressToUTF16","unzip","decompressFromUTF16","uncached","Promise","all","then","resp","contents","index","cached","storelike","keys","Object","key","removeItem","cacheKey","t","setItem","func","notImplemented","methodName","audit","fn","args","res","smallres","getDefaultCompilerOptions","jsx","JsxEmit","React","strict","esModuleInterop","module","ModuleKind","ESNext","suppressOutputPathCheck","skipLibCheck","skipDefaultLibCheck","moduleResolution","ModuleResolutionKind","NodeJs","libize","createSystem","createDirectory","directoryExists","directory","Array","from","some","exit","fileExists","has","getCurrentDirectory","getDirectories","getExecutingFilePath","readDirectory","readFile","get","resolvePath","newLine","useCaseSensitiveFileNames","write","writeFile","createFSBackedSystem","_projectRoot","root","nodeSys","tsLib","tsLibName","result","sourceFiles","save","sourceFile","vHost","getCanonicalFileName","getDefaultLibFileName","getNewLine","alreadyExists","fileNames","fileVersions","projectVersion","getProjectVersion","toString","getCompilationSettings","getCustomTransformers","getScriptFileNames","getScriptSnapshot","ScriptSnapshot","fromString","getScriptVersion","lsHost","String","fromCharCode"],"mappings":";;;;;;;;;;;;;;;;;;AAQA,IAAIA,eAAe,GAAG,KAAtB;;AACA,IAAI;AACFA,EAAAA,eAAe,GAAG,OAAOC,YAAP,gBAAlB;AACD,CAFD,CAEE,OAAOC,KAAP,EAAc;;AAEhB,IAAMC,UAAU,GAAG,OAAOC,OAAP,gBAAnB;AACA,IAAMC,WAAW,GAAIL,eAAe,iBAAIC,YAAY,CAACK,OAAb,CAAqB,OAArB,CAApB,IAAuDH,UAAU,IAAIC,OAAO,CAACG,GAAR,CAAYC,KAArG;AACA,IAAMC,QAAQ,GAAGJ,WAAW,GAAGK,OAAO,CAACC,GAAX,GAAiB,UAACC,QAAD;AAAA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GAAG,CAAC4K,QAAJ,CAAavJ,QAAb,CAAjB;;AACA,UAAIsG,QAAJ,EAAc;AACZ,eAAOzH,EAAE,CAACyM,cAAH,CAAkBC,UAAlB,CAA6BjF,QAA7B,CAAP;AACD;;AACD;AACD,KApBsB;AAqBvBkF,IAAAA,gBAAgB,EAAE,0BAAAxL,QAAQ;AACxB,aAAO8K,YAAY,CAACtB,GAAb,CAAiBxJ,QAAjB,KAA8B,GAArC;AACD,KAvBsB;AAwBvB6J,IAAAA,SAAS,EAAElL,GAAG,CAACkL;AAxBQ,IAAzB;;AAgCA,MAAM4B,MAAM,GAAW;AACrBtM,IAAAA,mBAAmB,EAAnBA,mBADqB;AAErBC,IAAAA,UAAU,EAAE,oBAAAmL,UAAU;AACpBQ,MAAAA,cAAc;AACdD,MAAAA,YAAY,CAACjH,GAAb,CAAiB0G,UAAU,CAACvK,QAA5B,EAAsC+K,cAAc,CAACE,QAAf,EAAtC;;AACA,UAAI,CAACJ,SAAS,CAAC9F,QAAV,CAAmBwF,UAAU,CAACvK,QAA9B,CAAL,EAA8C;AAC5C6K,QAAAA,SAAS,CAACnG,IAAV,CAAe6F,UAAU,CAACvK,QAA1B;AACD;;AACDZ,MAAAA,YAAU,CAACmL,UAAD,CAAV;AACD;AAToB,GAAvB;AAWA,SAAOkB,MAAP;AACD;;AAED,IAAMxI,WAAW,GAAG,SAAdA,WAAc;AAClB,SAAOF,OAAO,CAAC2I,MAAM,CAACC,YAAP,CAAoB,GAApB,EAAyB,EAAzB,EAA6B,GAA7B,EAAkC,GAAlC,CAAD,CAAd;AACD,CAFD;;AAIA,IAAMxI,SAAS,GAAG,SAAZA,SAAY;AAChB,SAAOJ,OAAO,CAAC2I,MAAM,CAACC,YAAP,CAAoB,GAApB,EAAyB,GAAzB,CAAD,CAAd;AACD,CAFD;;;;"}
|
|
1
|
+
{"version":3,"file":"vfs.esm.js","sources":["../src/index.ts"],"sourcesContent":["type System = import(\"typescript\").System\ntype CompilerOptions = import(\"typescript\").CompilerOptions\ntype CustomTransformers = import(\"typescript\").CustomTransformers\ntype LanguageServiceHost = import(\"typescript\").LanguageServiceHost\ntype CompilerHost = import(\"typescript\").CompilerHost\ntype SourceFile = import(\"typescript\").SourceFile\ntype TS = typeof import(\"typescript\")\n\nlet hasLocalStorage = false\ntry {\n hasLocalStorage = typeof localStorage !== `undefined`\n} catch (error) { }\n\nconst hasProcess = typeof process !== `undefined`\nconst shouldDebug = (hasLocalStorage && localStorage.getItem(\"DEBUG\")) || (hasProcess && process.env.DEBUG)\nconst debugLog = shouldDebug ? console.log : (_message?: any, ..._optionalParams: any[]) => \"\"\n\nexport interface VirtualTypeScriptEnvironment {\n sys: System\n languageService: import(\"typescript\").LanguageService\n getSourceFile: (fileName: string) => import(\"typescript\").SourceFile | undefined\n createFile: (fileName: string, content: string) => void\n updateFile: (fileName: string, content: string, replaceTextSpan?: import(\"typescript\").TextSpan) => void\n}\n\n/**\n * Makes a virtual copy of the TypeScript environment. This is the main API you want to be using with\n * @typescript/vfs. A lot of the other exposed functions are used by this function to get set up.\n *\n * @param sys an object which conforms to the TS Sys (a shim over read/write access to the fs)\n * @param rootFiles a list of files which are considered inside the project\n * @param ts a copy pf the TypeScript module\n * @param compilerOptions the options for this compiler run\n * @param customTransformers custom transformers for this compiler run\n */\n\nexport function createVirtualTypeScriptEnvironment(\n sys: System,\n rootFiles: string[],\n ts: TS,\n compilerOptions: CompilerOptions = {},\n customTransformers?: CustomTransformers\n): VirtualTypeScriptEnvironment {\n const mergedCompilerOpts = { ...defaultCompilerOptions(ts), ...compilerOptions }\n\n const { languageServiceHost, updateFile } = createVirtualLanguageServiceHost(\n sys,\n rootFiles,\n mergedCompilerOpts,\n ts,\n customTransformers\n )\n const languageService = ts.createLanguageService(languageServiceHost)\n const diagnostics = languageService.getCompilerOptionsDiagnostics()\n\n if (diagnostics.length) {\n const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)\n throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))\n }\n\n return {\n // @ts-ignore\n name: \"vfs\",\n sys,\n languageService,\n getSourceFile: fileName => languageService.getProgram()?.getSourceFile(fileName),\n\n createFile: (fileName, content) => {\n updateFile(ts.createSourceFile(fileName, content, mergedCompilerOpts.target!, false))\n },\n updateFile: (fileName, content, optPrevTextSpan) => {\n const prevSourceFile = languageService.getProgram()!.getSourceFile(fileName)\n if (!prevSourceFile) {\n throw new Error(\"Did not find a source file for \" + fileName)\n }\n const prevFullContents = prevSourceFile.text\n\n // TODO: Validate if the default text span has a fencepost error?\n const prevTextSpan = optPrevTextSpan ?? ts.createTextSpan(0, prevFullContents.length)\n const newText =\n prevFullContents.slice(0, prevTextSpan.start) +\n content +\n prevFullContents.slice(prevTextSpan.start + prevTextSpan.length)\n const newSourceFile = ts.updateSourceFile(prevSourceFile, newText, {\n span: prevTextSpan,\n newLength: content.length,\n })\n\n updateFile(newSourceFile)\n },\n }\n}\n\n// TODO: This could be replaced by grabbing: https://github.com/microsoft/TypeScript/blob/main/src/lib/libs.json\n// and then using that to generate the list of files from the server, but it is not included in the npm package\n\n/**\n * Grab the list of lib files for a particular target, will return a bit more than necessary (by including\n * the dom) but that's OK, we're really working with the constraint that you can't get a list of files\n * when running in a browser.\n *\n * @param target The compiler settings target baseline\n * @param ts A copy of the TypeScript module\n */\nexport const knownLibFilesForCompilerOptions = (compilerOptions: CompilerOptions, ts: TS) => {\n const target = compilerOptions.target || ts.ScriptTarget.ES5\n const lib = compilerOptions.lib || []\n\n // Note that this will include files which can't be found for particular versions of TS\n // TODO: Replace this with some sort of API call if https://github.com/microsoft/TypeScript/pull/54011\n // or similar is merged.\n const files = [\n \"lib.d.ts\",\n \"lib.decorators.d.ts\",\n \"lib.decorators.legacy.d.ts\",\n \"lib.dom.d.ts\",\n \"lib.dom.iterable.d.ts\",\n \"lib.webworker.d.ts\",\n \"lib.webworker.importscripts.d.ts\",\n \"lib.webworker.iterable.d.ts\",\n \"lib.scripthost.d.ts\",\n \"lib.es5.d.ts\",\n \"lib.es6.d.ts\",\n \"lib.es2015.collection.d.ts\",\n \"lib.es2015.core.d.ts\",\n \"lib.es2015.d.ts\",\n \"lib.es2015.generator.d.ts\",\n \"lib.es2015.iterable.d.ts\",\n \"lib.es2015.promise.d.ts\",\n \"lib.es2015.proxy.d.ts\",\n \"lib.es2015.reflect.d.ts\",\n \"lib.es2015.symbol.d.ts\",\n \"lib.es2015.symbol.wellknown.d.ts\",\n \"lib.es2016.array.include.d.ts\",\n \"lib.es2016.d.ts\",\n \"lib.es2016.full.d.ts\",\n \"lib.es2017.d.ts\",\n \"lib.es2017.date.d.ts\",\n \"lib.es2017.full.d.ts\",\n \"lib.es2017.intl.d.ts\",\n \"lib.es2017.object.d.ts\",\n \"lib.es2017.sharedmemory.d.ts\",\n \"lib.es2017.string.d.ts\",\n \"lib.es2017.typedarrays.d.ts\",\n \"lib.es2018.asyncgenerator.d.ts\",\n \"lib.es2018.asynciterable.d.ts\",\n \"lib.es2018.d.ts\",\n \"lib.es2018.full.d.ts\",\n \"lib.es2018.intl.d.ts\",\n \"lib.es2018.promise.d.ts\",\n \"lib.es2018.regexp.d.ts\",\n \"lib.es2019.array.d.ts\",\n \"lib.es2019.d.ts\",\n \"lib.es2019.full.d.ts\",\n \"lib.es2019.intl.d.ts\",\n \"lib.es2019.object.d.ts\",\n \"lib.es2019.string.d.ts\",\n \"lib.es2019.symbol.d.ts\",\n \"lib.es2020.bigint.d.ts\",\n \"lib.es2020.d.ts\",\n \"lib.es2020.date.d.ts\",\n \"lib.es2020.full.d.ts\",\n \"lib.es2020.intl.d.ts\",\n \"lib.es2020.number.d.ts\",\n \"lib.es2020.promise.d.ts\",\n \"lib.es2020.sharedmemory.d.ts\",\n \"lib.es2020.string.d.ts\",\n \"lib.es2020.symbol.wellknown.d.ts\",\n \"lib.es2021.d.ts\",\n \"lib.es2021.full.d.ts\",\n \"lib.es2021.intl.d.ts\",\n \"lib.es2021.promise.d.ts\",\n \"lib.es2021.string.d.ts\",\n \"lib.es2021.weakref.d.ts\",\n \"lib.es2022.array.d.ts\",\n \"lib.es2022.d.ts\",\n \"lib.es2022.error.d.ts\",\n \"lib.es2022.full.d.ts\",\n \"lib.es2022.intl.d.ts\",\n \"lib.es2022.object.d.ts\",\n \"lib.es2022.regexp.d.ts\",\n \"lib.es2022.sharedmemory.d.ts\",\n \"lib.es2022.string.d.ts\",\n \"lib.es2023.array.d.ts\",\n \"lib.es2023.collection.d.ts\",\n \"lib.es2023.d.ts\",\n \"lib.es2023.full.d.ts\",\n \"lib.esnext.array.d.ts\",\n \"lib.esnext.asynciterable.d.ts\",\n \"lib.esnext.bigint.d.ts\",\n \"lib.esnext.d.ts\",\n \"lib.esnext.decorators.d.ts\",\n \"lib.esnext.disposable.d.ts\",\n \"lib.esnext.full.d.ts\",\n \"lib.esnext.intl.d.ts\",\n \"lib.esnext.promise.d.ts\",\n \"lib.esnext.string.d.ts\",\n \"lib.esnext.symbol.d.ts\",\n \"lib.esnext.weakref.d.ts\"\n ]\n\n const targetToCut = ts.ScriptTarget[target]\n const matches = files.filter(f => f.startsWith(`lib.${targetToCut.toLowerCase()}`))\n const targetCutIndex = files.indexOf(matches.pop()!)\n\n const getMax = (array: number[]) =>\n array && array.length ? array.reduce((max, current) => (current > max ? current : max)) : undefined\n\n // Find the index for everything in\n const indexesForCutting = lib.map(lib => {\n const matches = files.filter(f => f.startsWith(`lib.${lib.toLowerCase()}`))\n if (matches.length === 0) return 0\n\n const cutIndex = files.indexOf(matches.pop()!)\n return cutIndex\n })\n\n const libCutIndex = getMax(indexesForCutting) || 0\n\n const finalCutIndex = Math.max(targetCutIndex, libCutIndex)\n return files.slice(0, finalCutIndex + 1)\n}\n\n/**\n * Sets up a Map with lib contents by grabbing the necessary files from\n * the local copy of typescript via the file system.\n *\n * The first two args are un-used, but kept around so as to not cause a\n * semver major bump for no gain to module users.\n */\nexport const createDefaultMapFromNodeModules = (\n _compilerOptions: CompilerOptions,\n _ts?: typeof import(\"typescript\"),\n tsLibDirectory?: string\n) => {\n const path = requirePath()\n const fs = requireFS()\n\n const getLib = (name: string) => {\n const lib = tsLibDirectory || path.dirname(require.resolve(\"typescript\"))\n return fs.readFileSync(path.join(lib, name), \"utf8\")\n }\n\n const libFiles = fs.readdirSync(tsLibDirectory || path.dirname(require.resolve(\"typescript\")))\n const knownLibFiles = libFiles.filter(f => f.startsWith(\"lib.\") && f.endsWith(\".d.ts\"))\n\n const fsMap = new Map<string, string>()\n knownLibFiles.forEach(lib => {\n fsMap.set(\"/\" + lib, getLib(lib))\n })\n return fsMap\n}\n\n/**\n * Adds recursively files from the FS into the map based on the folder\n */\nexport const addAllFilesFromFolder = (map: Map<string, string>, workingDir: string): void => {\n const path = requirePath()\n const fs = requireFS()\n\n const walk = function (dir: string) {\n let results: string[] = []\n const list = fs.readdirSync(dir)\n list.forEach(function (file: string) {\n file = path.join(dir, file)\n const stat = fs.statSync(file)\n if (stat && stat.isDirectory()) {\n /* Recurse into a subdirectory */\n results = results.concat(walk(file))\n } else {\n /* Is a file */\n results.push(file)\n }\n })\n return results\n }\n\n const allFiles = walk(workingDir)\n\n allFiles.forEach(lib => {\n const fsPath = \"/node_modules/@types\" + lib.replace(workingDir, \"\")\n const content = fs.readFileSync(lib, \"utf8\")\n const validExtensions = [\".ts\", \".tsx\"]\n\n if (validExtensions.includes(path.extname(fsPath))) {\n map.set(fsPath, content)\n }\n })\n}\n\n/** Adds all files from node_modules/@types into the FS Map */\nexport const addFilesForTypesIntoFolder = (map: Map<string, string>) =>\n addAllFilesFromFolder(map, \"node_modules/@types\")\n\n/**\n * Create a virtual FS Map with the lib files from a particular TypeScript\n * version based on the target, Always includes dom ATM.\n *\n * @param options The compiler target, which dictates the libs to set up\n * @param version the versions of TypeScript which are supported\n * @param cache should the values be stored in local storage\n * @param ts a copy of the typescript import\n * @param lzstring an optional copy of the lz-string import\n * @param fetcher an optional replacement for the global fetch function (tests mainly)\n * @param storer an optional replacement for the localStorage global (tests mainly)\n */\nexport const createDefaultMapFromCDN = (\n options: CompilerOptions,\n version: string,\n cache: boolean,\n ts: TS,\n lzstring?: typeof import(\"lz-string\"),\n fetcher?: typeof fetch,\n storer?: typeof localStorage\n) => {\n const fetchlike = fetcher || fetch\n const fsMap = new Map<string, string>()\n const files = knownLibFilesForCompilerOptions(options, ts)\n const prefix = `https://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,e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