mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
Merge branch 'main' into extend-st-extensions-twincat
This commit is contained in:
commit
31b21cfea6
70 changed files with 8932 additions and 782 deletions
|
|
@ -272,7 +272,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
escapes: /\\(?:[0abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
integersuffix: /([uU](ll|LL|l|L)|(ll|LL|l|L)?[uU]?)/,
|
||||
floatsuffix: /[fFlL]?/,
|
||||
encoding: /u|u8|U|L/,
|
||||
|
|
|
|||
|
|
@ -383,5 +383,32 @@ testTokenization('elixir', [
|
|||
{ startIndex: 15, type: 'delimiter.square.elixir' }
|
||||
]
|
||||
}
|
||||
],
|
||||
// Bitstrings
|
||||
[
|
||||
{
|
||||
line: '<<height::32-integer, width::32-integer, data::binary>>',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.angle.special.elixir' },
|
||||
{ startIndex: 2, type: 'identifier.elixir' },
|
||||
{ startIndex: 8, type: 'operator.elixir' },
|
||||
{ startIndex: 10, type: 'number.elixir' },
|
||||
{ startIndex: 12, type: 'operator.elixir' },
|
||||
{ startIndex: 13, type: 'identifier.elixir' },
|
||||
{ startIndex: 20, type: 'punctuation.elixir' },
|
||||
{ startIndex: 21, type: 'white.elixir' },
|
||||
{ startIndex: 22, type: 'identifier.elixir' },
|
||||
{ startIndex: 27, type: 'operator.elixir' },
|
||||
{ startIndex: 29, type: 'number.elixir' },
|
||||
{ startIndex: 31, type: 'operator.elixir' },
|
||||
{ startIndex: 32, type: 'identifier.elixir' },
|
||||
{ startIndex: 39, type: 'punctuation.elixir' },
|
||||
{ startIndex: 40, type: 'white.elixir' },
|
||||
{ startIndex: 41, type: 'identifier.elixir' },
|
||||
{ startIndex: 45, type: 'operator.elixir' },
|
||||
{ startIndex: 47, type: 'identifier.elixir' },
|
||||
{ startIndex: 53, type: 'delimiter.angle.special.elixir' }
|
||||
]
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
// Keyword list shorthand
|
||||
|
||||
keywordsShorthand: [
|
||||
[/(@atomName)(:)/, ['constant', 'constant.punctuation']],
|
||||
[/(@atomName)(:)(\s+)/, ['constant', 'constant.punctuation', 'white']],
|
||||
// Use positive look-ahead to ensure the string is followed by :
|
||||
// and should be considered a keyword.
|
||||
[
|
||||
|
|
@ -532,6 +532,13 @@ export const language = <languages.IMonarchLanguage>{
|
|||
next: '@doubleQuotedHeredocDocstring'
|
||||
}
|
||||
],
|
||||
[
|
||||
/\@(module|type)?doc (~[sS])?'''/,
|
||||
{
|
||||
token: 'comment.block.documentation',
|
||||
next: '@singleQuotedHeredocDocstring'
|
||||
}
|
||||
],
|
||||
[
|
||||
/\@(module|type)?doc (~[sS])?"/,
|
||||
{
|
||||
|
|
@ -539,6 +546,13 @@ export const language = <languages.IMonarchLanguage>{
|
|||
next: '@doubleQuotedStringDocstring'
|
||||
}
|
||||
],
|
||||
[
|
||||
/\@(module|type)?doc (~[sS])?'/,
|
||||
{
|
||||
token: 'comment.block.documentation',
|
||||
next: '@singleQuotedStringDocstring'
|
||||
}
|
||||
],
|
||||
[/\@(module|type)?doc false/, 'comment.block.documentation'],
|
||||
// Module attributes
|
||||
[/\@(@variableName)/, 'variable']
|
||||
|
|
@ -549,11 +563,21 @@ export const language = <languages.IMonarchLanguage>{
|
|||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
singleQuotedHeredocDocstring: [
|
||||
[/'''/, { token: 'comment.block.documentation', next: '@pop' }],
|
||||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
doubleQuotedStringDocstring: [
|
||||
[/"/, { token: 'comment.block.documentation', next: '@pop' }],
|
||||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
singleQuotedStringDocstring: [
|
||||
[/'/, { token: 'comment.block.documentation', next: '@pop' }],
|
||||
{ include: '@docstringContent' }
|
||||
],
|
||||
|
||||
// Operators, punctuation, brackets
|
||||
|
||||
symbols: [
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ declare var require: any;
|
|||
|
||||
registerLanguage({
|
||||
id: 'kotlin',
|
||||
extensions: ['.kt'],
|
||||
extensions: ['.kt', '.kts'],
|
||||
aliases: ['Kotlin', 'kotlin'],
|
||||
mimetypes: ['text/x-kotlin-source', 'text/x-kotlin'],
|
||||
loader: () => {
|
||||
|
|
|
|||
|
|
@ -862,6 +862,7 @@ export const language = <languages.IMonarchLanguage>{
|
|||
[/"/, { token: 'string.double', next: '@stringDouble' }]
|
||||
],
|
||||
string: [
|
||||
[/\\'/, 'string'],
|
||||
[/[^']+/, 'string'],
|
||||
[/''/, 'string'],
|
||||
[/'/, { token: 'string', next: '@pop' }]
|
||||
|
|
|
|||
|
|
@ -627,11 +627,15 @@ export const language = <languages.IMonarchLanguage>{
|
|||
'range_intersect_agg',
|
||||
'range_merge',
|
||||
'rank',
|
||||
'regexp_count',
|
||||
'regexp_instr',
|
||||
'regexp_like',
|
||||
'regexp_match',
|
||||
'regexp_matches',
|
||||
'regexp_replace',
|
||||
'regexp_split_to_array',
|
||||
'regexp_split_to_table',
|
||||
'regexp_substr',
|
||||
'regr_avgx',
|
||||
'regr_avgy',
|
||||
'regr_count',
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ export const language = {
|
|||
'require',
|
||||
'global',
|
||||
'return',
|
||||
'satisfies',
|
||||
'set',
|
||||
'static',
|
||||
'string',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ registerLanguage({
|
|||
'.ascx',
|
||||
'.csproj',
|
||||
'.config',
|
||||
'.props',
|
||||
'.targets',
|
||||
'.wxi',
|
||||
'.wxl',
|
||||
'.wxs',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
//
|
||||
// **NOTE**: Do not edit directly! This file is generated using `npm run import-typescript`
|
||||
//
|
||||
|
||||
/* MONACOCHANGE */
|
||||
var require = undefined;
|
||||
var module = { exports: {} };
|
||||
/* END MONACOCHANGE */
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
|
|
@ -2554,9 +2559,7 @@ var ts;
|
|||
return true;
|
||||
}
|
||||
function fail(message, stackCrawlMark) {
|
||||
// MONACOCHANGE
|
||||
// debugger;
|
||||
// END MONACOCHANGE
|
||||
debugger;
|
||||
var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure.");
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(e, stackCrawlMark || fail);
|
||||
|
|
@ -3058,9 +3061,7 @@ var ts;
|
|||
try {
|
||||
if (ts.sys && ts.sys.require) {
|
||||
var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath()));
|
||||
// MONACOCHANGE
|
||||
var result = undefined;
|
||||
// END MONACOCHANGE
|
||||
var result = ts.sys.require(basePath, "./compiler-debug");
|
||||
if (!result.error) {
|
||||
result.module.init(ts);
|
||||
extendedDebugModule = result.module;
|
||||
|
|
@ -3512,10 +3513,10 @@ var ts;
|
|||
}
|
||||
}
|
||||
function tryGetNodePerformanceHooks() {
|
||||
if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && /* MONACOCHANGE */false/* END MONACOCHANGE */) {
|
||||
if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") {
|
||||
try {
|
||||
var performance_1;
|
||||
var _a /* MONACOCHANGE */= {}/* END MONACOCHANGE */, nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver;
|
||||
var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver;
|
||||
if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) {
|
||||
performance_1 = nodePerformance_1;
|
||||
// There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not
|
||||
|
|
@ -3746,9 +3747,7 @@ var ts;
|
|||
var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw";
|
||||
// require() will throw an exception if the module is not found
|
||||
// It may also return undefined if not installed properly
|
||||
// MONACOCHANGE
|
||||
etwModule = undefined;
|
||||
// END MONACOCHANGE
|
||||
etwModule = require(etwModulePath);
|
||||
}
|
||||
catch (e) {
|
||||
etwModule = undefined;
|
||||
|
|
@ -3777,9 +3776,7 @@ var ts;
|
|||
ts.Debug.assert(!ts.tracing, "Tracing already started");
|
||||
if (fs === undefined) {
|
||||
try {
|
||||
// MONACOCHANGE
|
||||
fs = undefined;
|
||||
// END MONACOCHANGE
|
||||
fs = require("fs");
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")"));
|
||||
|
|
@ -7463,9 +7460,596 @@ var ts;
|
|||
ts.getNodeMajorVersion = getNodeMajorVersion;
|
||||
// TODO: GH#18217 this is used as if it's certainly defined in many places.
|
||||
// eslint-disable-next-line prefer-const
|
||||
// MONACOCHANGE
|
||||
ts.sys = undefined;
|
||||
// END MONACOCHANGE
|
||||
ts.sys = (function () {
|
||||
// NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual
|
||||
// byte order mark from the specified encoding. Using any other byte order mark does
|
||||
// not actually work.
|
||||
var byteOrderMarkIndicator = "\uFEFF";
|
||||
function getNodeSystem() {
|
||||
var _a;
|
||||
var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
|
||||
var _fs = require("fs");
|
||||
var _path = require("path");
|
||||
var _os = require("os");
|
||||
// crypto can be absent on reduced node installations
|
||||
var _crypto;
|
||||
try {
|
||||
_crypto = require("crypto");
|
||||
}
|
||||
catch (_b) {
|
||||
_crypto = undefined;
|
||||
}
|
||||
var activeSession;
|
||||
var profilePath = "./profile.cpuprofile";
|
||||
var hitSystemWatcherLimit = false;
|
||||
var Buffer = require("buffer").Buffer;
|
||||
var nodeVersion = getNodeMajorVersion();
|
||||
var isNode4OrLater = nodeVersion >= 4;
|
||||
var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
|
||||
var platform = _os.platform();
|
||||
var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
|
||||
var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync;
|
||||
var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
|
||||
var getCurrentDirectory = ts.memoize(function () { return process.cwd(); });
|
||||
var _c = createSystemWatchFunctions({
|
||||
pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
|
||||
getModifiedTime: getModifiedTime,
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
fsWatch: fsWatch,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
getCurrentDirectory: getCurrentDirectory,
|
||||
fileExists: fileExists,
|
||||
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
||||
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
||||
fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
|
||||
directoryExists: directoryExists,
|
||||
getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
|
||||
realpath: realpath,
|
||||
tscWatchFile: process.env.TSC_WATCHFILE,
|
||||
useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
|
||||
tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
|
||||
defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
||||
}), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
|
||||
var nodeSystem = {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write: function (s) {
|
||||
process.stdout.write(s);
|
||||
},
|
||||
getWidthOfTerminal: function () {
|
||||
return process.stdout.columns;
|
||||
},
|
||||
writeOutputIsTTY: function () {
|
||||
return process.stdout.isTTY;
|
||||
},
|
||||
readFile: readFile,
|
||||
writeFile: writeFile,
|
||||
watchFile: watchFile,
|
||||
watchDirectory: watchDirectory,
|
||||
resolvePath: function (path) { return _path.resolve(path); },
|
||||
fileExists: fileExists,
|
||||
directoryExists: directoryExists,
|
||||
createDirectory: function (directoryName) {
|
||||
if (!nodeSystem.directoryExists(directoryName)) {
|
||||
// Wrapped in a try-catch to prevent crashing if we are in a race
|
||||
// with another copy of ourselves to create the same directory
|
||||
try {
|
||||
_fs.mkdirSync(directoryName);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code !== "EEXIST") {
|
||||
// Failed for some other reason (access denied?); still throw
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return __filename;
|
||||
},
|
||||
getCurrentDirectory: getCurrentDirectory,
|
||||
getDirectories: getDirectories,
|
||||
getEnvironmentVariable: function (name) {
|
||||
return process.env[name] || "";
|
||||
},
|
||||
readDirectory: readDirectory,
|
||||
getModifiedTime: getModifiedTime,
|
||||
setModifiedTime: setModifiedTime,
|
||||
deleteFile: deleteFile,
|
||||
createHash: _crypto ? createSHA256Hash : generateDjb2Hash,
|
||||
createSHA256Hash: _crypto ? createSHA256Hash : undefined,
|
||||
getMemoryUsage: function () {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
return process.memoryUsage().heapUsed;
|
||||
},
|
||||
getFileSize: function (path) {
|
||||
try {
|
||||
var stat = statSync(path);
|
||||
if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
|
||||
return stat.size;
|
||||
}
|
||||
}
|
||||
catch ( /*ignore*/_a) { /*ignore*/ }
|
||||
return 0;
|
||||
},
|
||||
exit: function (exitCode) {
|
||||
disableCPUProfiler(function () { return process.exit(exitCode); });
|
||||
},
|
||||
enableCPUProfiler: enableCPUProfiler,
|
||||
disableCPUProfiler: disableCPUProfiler,
|
||||
cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); },
|
||||
realpath: realpath,
|
||||
debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }),
|
||||
tryEnableSourceMapsForHost: function () {
|
||||
try {
|
||||
require("source-map-support").install();
|
||||
}
|
||||
catch (_a) {
|
||||
// Could not enable source maps.
|
||||
}
|
||||
},
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
clearScreen: function () {
|
||||
process.stdout.write("\x1Bc");
|
||||
},
|
||||
setBlocking: function () {
|
||||
if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
|
||||
process.stdout._handle.setBlocking(true);
|
||||
}
|
||||
},
|
||||
bufferFrom: bufferFrom,
|
||||
base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); },
|
||||
base64encode: function (input) { return bufferFrom(input).toString("base64"); },
|
||||
require: function (baseDir, moduleName) {
|
||||
try {
|
||||
var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem);
|
||||
return { module: require(modulePath), modulePath: modulePath, error: undefined };
|
||||
}
|
||||
catch (error) {
|
||||
return { module: undefined, modulePath: undefined, error: error };
|
||||
}
|
||||
}
|
||||
};
|
||||
return nodeSystem;
|
||||
/**
|
||||
* `throwIfNoEntry` was added so recently that it's not in the node types.
|
||||
* This helper encapsulates the mitigating usage of `any`.
|
||||
* See https://github.com/nodejs/node/pull/33716
|
||||
*/
|
||||
function statSync(path) {
|
||||
// throwIfNoEntry will be ignored by older versions of node
|
||||
return _fs.statSync(path, { throwIfNoEntry: false });
|
||||
}
|
||||
/**
|
||||
* Uses the builtin inspector APIs to capture a CPU profile
|
||||
* See https://nodejs.org/api/inspector.html#inspector_example_usage for details
|
||||
*/
|
||||
function enableCPUProfiler(path, cb) {
|
||||
if (activeSession) {
|
||||
cb();
|
||||
return false;
|
||||
}
|
||||
var inspector = require("inspector");
|
||||
if (!inspector || !inspector.Session) {
|
||||
cb();
|
||||
return false;
|
||||
}
|
||||
var session = new inspector.Session();
|
||||
session.connect();
|
||||
session.post("Profiler.enable", function () {
|
||||
session.post("Profiler.start", function () {
|
||||
activeSession = session;
|
||||
profilePath = path;
|
||||
cb();
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Strips non-TS paths from the profile, so users with private projects shouldn't
|
||||
* need to worry about leaking paths by submitting a cpu profile to us
|
||||
*/
|
||||
function cleanupPaths(profile) {
|
||||
var externalFileCounter = 0;
|
||||
var remappedPaths = new ts.Map();
|
||||
var normalizedDir = ts.normalizeSlashes(__dirname);
|
||||
// Windows rooted dir names need an extra `/` prepended to be valid file:/// urls
|
||||
var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir);
|
||||
for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
|
||||
var node = _a[_i];
|
||||
if (node.callFrame.url) {
|
||||
var url = ts.normalizeSlashes(node.callFrame.url);
|
||||
if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
|
||||
node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true);
|
||||
}
|
||||
else if (!nativePattern.test(url)) {
|
||||
node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url);
|
||||
externalFileCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
function disableCPUProfiler(cb) {
|
||||
if (activeSession && activeSession !== "stopping") {
|
||||
var s_1 = activeSession;
|
||||
activeSession.post("Profiler.stop", function (err, _a) {
|
||||
var _b;
|
||||
var profile = _a.profile;
|
||||
if (!err) {
|
||||
try {
|
||||
if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) {
|
||||
profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile"));
|
||||
}
|
||||
}
|
||||
catch (_c) {
|
||||
// do nothing and ignore fallible fs operation
|
||||
}
|
||||
try {
|
||||
_fs.mkdirSync(_path.dirname(profilePath), { recursive: true });
|
||||
}
|
||||
catch (_d) {
|
||||
// do nothing and ignore fallible fs operation
|
||||
}
|
||||
_fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile)));
|
||||
}
|
||||
activeSession = undefined;
|
||||
s_1.disconnect();
|
||||
cb();
|
||||
});
|
||||
activeSession = "stopping";
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
cb();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function bufferFrom(input, encoding) {
|
||||
// See https://github.com/Microsoft/TypeScript/issues/25652
|
||||
return Buffer.from && Buffer.from !== Int8Array.from
|
||||
? Buffer.from(input, encoding)
|
||||
: new Buffer(input, encoding);
|
||||
}
|
||||
function isFileSystemCaseSensitive() {
|
||||
// win32\win64 are case insensitive platforms
|
||||
if (platform === "win32" || platform === "win64") {
|
||||
return false;
|
||||
}
|
||||
// If this file exists under a different case, we must be case-insensitve.
|
||||
return !fileExists(swapCase(__filename));
|
||||
}
|
||||
/** Convert all lowercase chars to uppercase, and vice-versa */
|
||||
function swapCase(s) {
|
||||
return s.replace(/\w/g, function (ch) {
|
||||
var up = ch.toUpperCase();
|
||||
return ch === up ? ch.toLowerCase() : up;
|
||||
});
|
||||
}
|
||||
function fsWatchFileWorker(fileName, callback, pollingInterval) {
|
||||
_fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
|
||||
var eventKind;
|
||||
return {
|
||||
close: function () { return _fs.unwatchFile(fileName, fileChanged); }
|
||||
};
|
||||
function fileChanged(curr, prev) {
|
||||
// previous event kind check is to ensure we recongnize the file as previously also missing when it is restored or renamed twice (that is it disappears and reappears)
|
||||
// In such case, prevTime returned is same as prev time of event when file was deleted as per node documentation
|
||||
var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
|
||||
if (+curr.mtime === 0) {
|
||||
if (isPreviouslyDeleted) {
|
||||
// Already deleted file, no need to callback again
|
||||
return;
|
||||
}
|
||||
eventKind = FileWatcherEventKind.Deleted;
|
||||
}
|
||||
else if (isPreviouslyDeleted) {
|
||||
eventKind = FileWatcherEventKind.Created;
|
||||
}
|
||||
// If there is no change in modified time, ignore the event
|
||||
else if (+curr.mtime === +prev.mtime) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// File changed
|
||||
eventKind = FileWatcherEventKind.Changed;
|
||||
}
|
||||
callback(fileName, eventKind);
|
||||
}
|
||||
}
|
||||
function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
|
||||
var options;
|
||||
var lastDirectoryPartWithDirectorySeparator;
|
||||
var lastDirectoryPart;
|
||||
if (isLinuxOrMacOs) {
|
||||
lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
|
||||
lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
|
||||
}
|
||||
/** Watcher for the file system entry depending on whether it is missing or present */
|
||||
var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
||||
watchMissingFileSystemEntry() :
|
||||
watchPresentFileSystemEntry();
|
||||
return {
|
||||
close: function () {
|
||||
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
||||
watcher.close();
|
||||
watcher = undefined;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Invoke the callback with rename and update the watcher if not closed
|
||||
* @param createWatcher
|
||||
*/
|
||||
function invokeCallbackAndUpdateWatcher(createWatcher) {
|
||||
ts.sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher"));
|
||||
// Call the callback for current directory
|
||||
callback("rename", "");
|
||||
// If watcher is not closed, update it
|
||||
if (watcher) {
|
||||
watcher.close();
|
||||
watcher = createWatcher();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Watch the file or directory that is currently present
|
||||
* and when the watched file or directory is deleted, switch to missing file system entry watcher
|
||||
*/
|
||||
function watchPresentFileSystemEntry() {
|
||||
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
||||
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
||||
if (options === undefined) {
|
||||
if (fsSupportsRecursiveFsWatch) {
|
||||
options = { persistent: true, recursive: !!recursive };
|
||||
}
|
||||
else {
|
||||
options = { persistent: true };
|
||||
}
|
||||
}
|
||||
if (hitSystemWatcherLimit) {
|
||||
ts.sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile"));
|
||||
return watchPresentFileSystemEntryWithFsWatchFile();
|
||||
}
|
||||
try {
|
||||
var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
|
||||
callbackChangingToMissingFileSystemEntry :
|
||||
callback);
|
||||
// Watch the missing file or directory or error
|
||||
presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
|
||||
return presentWatcher;
|
||||
}
|
||||
catch (e) {
|
||||
// Catch the exception and use polling instead
|
||||
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
||||
// so instead of throwing error, use fs.watchFile
|
||||
hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
|
||||
ts.sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile"));
|
||||
return watchPresentFileSystemEntryWithFsWatchFile();
|
||||
}
|
||||
}
|
||||
function callbackChangingToMissingFileSystemEntry(event, relativeName) {
|
||||
// because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
|
||||
// Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
|
||||
return event === "rename" &&
|
||||
(!relativeName ||
|
||||
relativeName === lastDirectoryPart ||
|
||||
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
|
||||
!fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
||||
invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
|
||||
callback(event, relativeName);
|
||||
}
|
||||
/**
|
||||
* Watch the file or directory using fs.watchFile since fs.watch threw exception
|
||||
* Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
||||
*/
|
||||
function watchPresentFileSystemEntryWithFsWatchFile() {
|
||||
return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
|
||||
}
|
||||
/**
|
||||
* Watch the file or directory that is missing
|
||||
* and switch to existing file or directory when the missing filesystem entry is created
|
||||
*/
|
||||
function watchMissingFileSystemEntry() {
|
||||
return watchFile(fileOrDirectory, function (_fileName, eventKind) {
|
||||
if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
||||
// Call the callback for current file or directory
|
||||
// For now it could be callback for the inner directory creation,
|
||||
// but just return current directory, better than current no-op
|
||||
invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
|
||||
}
|
||||
}, fallbackPollingInterval, fallbackOptions);
|
||||
}
|
||||
}
|
||||
function readFileWorker(fileName, _encoding) {
|
||||
var buffer;
|
||||
try {
|
||||
buffer = _fs.readFileSync(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
var len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
// flip all byte pairs and treat as little endian.
|
||||
len &= ~1; // Round down to a multiple of 2
|
||||
for (var i = 0; i < len; i += 2) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
||||
// Little endian UTF-16 byte order mark detected
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
||||
// UTF-8 byte order mark detected
|
||||
return buffer.toString("utf8", 3);
|
||||
}
|
||||
// Default is UTF-8 with no byte order mark
|
||||
return buffer.toString("utf8");
|
||||
}
|
||||
function readFile(fileName, _encoding) {
|
||||
ts.perfLogger.logStartReadFile(fileName);
|
||||
var file = readFileWorker(fileName, _encoding);
|
||||
ts.perfLogger.logStopReadFile();
|
||||
return file;
|
||||
}
|
||||
function writeFile(fileName, data, writeByteOrderMark) {
|
||||
ts.perfLogger.logEvent("WriteFile: " + fileName);
|
||||
// If a BOM is required, emit one
|
||||
if (writeByteOrderMark) {
|
||||
data = byteOrderMarkIndicator + data;
|
||||
}
|
||||
var fd;
|
||||
try {
|
||||
fd = _fs.openSync(fileName, "w");
|
||||
_fs.writeSync(fd, data, /*position*/ undefined, "utf8");
|
||||
}
|
||||
finally {
|
||||
if (fd !== undefined) {
|
||||
_fs.closeSync(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
function getAccessibleFileSystemEntries(path) {
|
||||
ts.perfLogger.logEvent("ReadDir: " + (path || "."));
|
||||
try {
|
||||
var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
|
||||
var files = [];
|
||||
var directories = [];
|
||||
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
||||
var dirent = entries_1[_i];
|
||||
// withFileTypes is not supported before Node 10.10.
|
||||
var entry = typeof dirent === "string" ? dirent : dirent.name;
|
||||
// This is necessary because on some file system node fails to exclude
|
||||
// "." and "..". See https://github.com/nodejs/node/issues/4002
|
||||
if (entry === "." || entry === "..") {
|
||||
continue;
|
||||
}
|
||||
var stat = void 0;
|
||||
if (typeof dirent === "string" || dirent.isSymbolicLink()) {
|
||||
var name = ts.combinePaths(path, entry);
|
||||
try {
|
||||
stat = statSync(name);
|
||||
if (!stat) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
stat = dirent;
|
||||
}
|
||||
if (stat.isFile()) {
|
||||
files.push(entry);
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(entry);
|
||||
}
|
||||
}
|
||||
files.sort();
|
||||
directories.sort();
|
||||
return { files: files, directories: directories };
|
||||
}
|
||||
catch (e) {
|
||||
return ts.emptyFileSystemEntries;
|
||||
}
|
||||
}
|
||||
function readDirectory(path, extensions, excludes, includes, depth) {
|
||||
return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
|
||||
}
|
||||
function fileSystemEntryExists(path, entryKind) {
|
||||
// Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
|
||||
// the CPU time performance.
|
||||
var originalStackTraceLimit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 0;
|
||||
try {
|
||||
var stat = statSync(path);
|
||||
if (!stat) {
|
||||
return false;
|
||||
}
|
||||
switch (entryKind) {
|
||||
case 0 /* File */: return stat.isFile();
|
||||
case 1 /* Directory */: return stat.isDirectory();
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
Error.stackTraceLimit = originalStackTraceLimit;
|
||||
}
|
||||
}
|
||||
function fileExists(path) {
|
||||
return fileSystemEntryExists(path, 0 /* File */);
|
||||
}
|
||||
function directoryExists(path) {
|
||||
return fileSystemEntryExists(path, 1 /* Directory */);
|
||||
}
|
||||
function getDirectories(path) {
|
||||
return getAccessibleFileSystemEntries(path).directories.slice();
|
||||
}
|
||||
function realpath(path) {
|
||||
try {
|
||||
return realpathSync(path);
|
||||
}
|
||||
catch (_a) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
function getModifiedTime(path) {
|
||||
var _a;
|
||||
try {
|
||||
return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function setModifiedTime(path, time) {
|
||||
try {
|
||||
_fs.utimesSync(path, time, time);
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
function deleteFile(path) {
|
||||
try {
|
||||
return _fs.unlinkSync(path);
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
function createSHA256Hash(data) {
|
||||
var hash = _crypto.createHash("sha256");
|
||||
hash.update(data);
|
||||
return hash.digest("hex");
|
||||
}
|
||||
}
|
||||
var sys;
|
||||
if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
|
||||
// process and process.nextTick checks if current environment is node-like
|
||||
// process.browser check excludes webpack and browserify
|
||||
sys = getNodeSystem();
|
||||
}
|
||||
if (sys) {
|
||||
// patch writefile to create folder before writing the file
|
||||
patchWriteFileEnsuringDirectory(sys);
|
||||
}
|
||||
return sys;
|
||||
})();
|
||||
/*@internal*/
|
||||
function setSys(s) {
|
||||
ts.sys = s;
|
||||
|
|
@ -162604,7 +163188,7 @@ if (typeof process === "undefined" || process.browser) {
|
|||
globalThis.toolsVersion = ts.versionMajorMinor;
|
||||
}
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
/* MONACOCHANGE */ /*module.exports = ts;*/ /* END MONACOCHANGE */
|
||||
module.exports = ts;
|
||||
}
|
||||
var ts;
|
||||
(function (ts) {
|
||||
|
|
@ -163529,6 +164113,7 @@ var ts;
|
|||
|
||||
|
||||
|
||||
|
||||
// MONACOCHANGE
|
||||
// Defining the entire module name because r.js has an issue and cannot bundle this file
|
||||
// correctly with an anonymous define call
|
||||
|
|
|
|||
|
|
@ -7594,6 +7594,4 @@ declare namespace ts {
|
|||
const isIdentifierOrPrivateIdentifier: (node: Node) => node is MemberName;
|
||||
}
|
||||
|
||||
// MONACOCHANGE
|
||||
export = ts;
|
||||
// END MONACOCHANGE
|
||||
export = ts;
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
//
|
||||
// **NOTE**: Do not edit directly! This file is generated using `npm run import-typescript`
|
||||
//
|
||||
|
||||
/* MONACOCHANGE */
|
||||
var require = undefined;
|
||||
var module = { exports: {} };
|
||||
/* END MONACOCHANGE */
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
|
|
@ -17,7 +22,7 @@ and limitations under the License.
|
|||
***************************************************************************** */
|
||||
|
||||
"use strict";
|
||||
var __spreadArray = function (to, from, pack) {
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
|
|
@ -26,7 +31,7 @@ var __spreadArray = function (to, from, pack) {
|
|||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
var __assign = function () {
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
|
|
@ -37,11 +42,11 @@ var __assign = function () {
|
|||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __makeTemplateObject = function (cooked, raw) {
|
||||
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
var __generator = function (thisArg, body) {
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
|
|
@ -68,7 +73,7 @@ var __generator = function (thisArg, body) {
|
|||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __rest = function (s, e) {
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
|
|
@ -79,7 +84,7 @@ var __rest = function (s, e) {
|
|||
}
|
||||
return t;
|
||||
};
|
||||
var __extends = (function () {
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
|
|
@ -2554,9 +2559,7 @@ var ts;
|
|||
return true;
|
||||
}
|
||||
function fail(message, stackCrawlMark) {
|
||||
// MONACOCHANGE
|
||||
// debugger;
|
||||
// END MONACOCHANGE
|
||||
debugger;
|
||||
var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure.");
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(e, stackCrawlMark || fail);
|
||||
|
|
@ -3058,9 +3061,7 @@ var ts;
|
|||
try {
|
||||
if (ts.sys && ts.sys.require) {
|
||||
var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath()));
|
||||
// MONACOCHANGE
|
||||
var result = undefined;
|
||||
// END MONACOCHANGE
|
||||
var result = ts.sys.require(basePath, "./compiler-debug");
|
||||
if (!result.error) {
|
||||
result.module.init(ts);
|
||||
extendedDebugModule = result.module;
|
||||
|
|
@ -3512,10 +3513,10 @@ var ts;
|
|||
}
|
||||
}
|
||||
function tryGetNodePerformanceHooks() {
|
||||
if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && /* MONACOCHANGE */false/* END MONACOCHANGE */) {
|
||||
if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") {
|
||||
try {
|
||||
var performance_1;
|
||||
var _a /* MONACOCHANGE */= {}/* END MONACOCHANGE */, nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver;
|
||||
var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver;
|
||||
if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) {
|
||||
performance_1 = nodePerformance_1;
|
||||
// There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not
|
||||
|
|
@ -3746,9 +3747,7 @@ var ts;
|
|||
var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw";
|
||||
// require() will throw an exception if the module is not found
|
||||
// It may also return undefined if not installed properly
|
||||
// MONACOCHANGE
|
||||
etwModule = undefined;
|
||||
// END MONACOCHANGE
|
||||
etwModule = require(etwModulePath);
|
||||
}
|
||||
catch (e) {
|
||||
etwModule = undefined;
|
||||
|
|
@ -3777,9 +3776,7 @@ var ts;
|
|||
ts.Debug.assert(!ts.tracing, "Tracing already started");
|
||||
if (fs === undefined) {
|
||||
try {
|
||||
// MONACOCHANGE
|
||||
fs = undefined;
|
||||
// END MONACOCHANGE
|
||||
fs = require("fs");
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")"));
|
||||
|
|
@ -7463,9 +7460,596 @@ var ts;
|
|||
ts.getNodeMajorVersion = getNodeMajorVersion;
|
||||
// TODO: GH#18217 this is used as if it's certainly defined in many places.
|
||||
// eslint-disable-next-line prefer-const
|
||||
// MONACOCHANGE
|
||||
ts.sys = undefined;
|
||||
// END MONACOCHANGE
|
||||
ts.sys = (function () {
|
||||
// NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual
|
||||
// byte order mark from the specified encoding. Using any other byte order mark does
|
||||
// not actually work.
|
||||
var byteOrderMarkIndicator = "\uFEFF";
|
||||
function getNodeSystem() {
|
||||
var _a;
|
||||
var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
|
||||
var _fs = require("fs");
|
||||
var _path = require("path");
|
||||
var _os = require("os");
|
||||
// crypto can be absent on reduced node installations
|
||||
var _crypto;
|
||||
try {
|
||||
_crypto = require("crypto");
|
||||
}
|
||||
catch (_b) {
|
||||
_crypto = undefined;
|
||||
}
|
||||
var activeSession;
|
||||
var profilePath = "./profile.cpuprofile";
|
||||
var hitSystemWatcherLimit = false;
|
||||
var Buffer = require("buffer").Buffer;
|
||||
var nodeVersion = getNodeMajorVersion();
|
||||
var isNode4OrLater = nodeVersion >= 4;
|
||||
var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
|
||||
var platform = _os.platform();
|
||||
var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
|
||||
var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync;
|
||||
var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
|
||||
var getCurrentDirectory = ts.memoize(function () { return process.cwd(); });
|
||||
var _c = createSystemWatchFunctions({
|
||||
pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
|
||||
getModifiedTime: getModifiedTime,
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
fsWatch: fsWatch,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
getCurrentDirectory: getCurrentDirectory,
|
||||
fileExists: fileExists,
|
||||
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
||||
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
||||
fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
|
||||
directoryExists: directoryExists,
|
||||
getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
|
||||
realpath: realpath,
|
||||
tscWatchFile: process.env.TSC_WATCHFILE,
|
||||
useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
|
||||
tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
|
||||
defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
||||
}), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
|
||||
var nodeSystem = {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write: function (s) {
|
||||
process.stdout.write(s);
|
||||
},
|
||||
getWidthOfTerminal: function () {
|
||||
return process.stdout.columns;
|
||||
},
|
||||
writeOutputIsTTY: function () {
|
||||
return process.stdout.isTTY;
|
||||
},
|
||||
readFile: readFile,
|
||||
writeFile: writeFile,
|
||||
watchFile: watchFile,
|
||||
watchDirectory: watchDirectory,
|
||||
resolvePath: function (path) { return _path.resolve(path); },
|
||||
fileExists: fileExists,
|
||||
directoryExists: directoryExists,
|
||||
createDirectory: function (directoryName) {
|
||||
if (!nodeSystem.directoryExists(directoryName)) {
|
||||
// Wrapped in a try-catch to prevent crashing if we are in a race
|
||||
// with another copy of ourselves to create the same directory
|
||||
try {
|
||||
_fs.mkdirSync(directoryName);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code !== "EEXIST") {
|
||||
// Failed for some other reason (access denied?); still throw
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return __filename;
|
||||
},
|
||||
getCurrentDirectory: getCurrentDirectory,
|
||||
getDirectories: getDirectories,
|
||||
getEnvironmentVariable: function (name) {
|
||||
return process.env[name] || "";
|
||||
},
|
||||
readDirectory: readDirectory,
|
||||
getModifiedTime: getModifiedTime,
|
||||
setModifiedTime: setModifiedTime,
|
||||
deleteFile: deleteFile,
|
||||
createHash: _crypto ? createSHA256Hash : generateDjb2Hash,
|
||||
createSHA256Hash: _crypto ? createSHA256Hash : undefined,
|
||||
getMemoryUsage: function () {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
return process.memoryUsage().heapUsed;
|
||||
},
|
||||
getFileSize: function (path) {
|
||||
try {
|
||||
var stat = statSync(path);
|
||||
if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
|
||||
return stat.size;
|
||||
}
|
||||
}
|
||||
catch ( /*ignore*/_a) { /*ignore*/ }
|
||||
return 0;
|
||||
},
|
||||
exit: function (exitCode) {
|
||||
disableCPUProfiler(function () { return process.exit(exitCode); });
|
||||
},
|
||||
enableCPUProfiler: enableCPUProfiler,
|
||||
disableCPUProfiler: disableCPUProfiler,
|
||||
cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); },
|
||||
realpath: realpath,
|
||||
debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }),
|
||||
tryEnableSourceMapsForHost: function () {
|
||||
try {
|
||||
require("source-map-support").install();
|
||||
}
|
||||
catch (_a) {
|
||||
// Could not enable source maps.
|
||||
}
|
||||
},
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
clearScreen: function () {
|
||||
process.stdout.write("\x1Bc");
|
||||
},
|
||||
setBlocking: function () {
|
||||
if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
|
||||
process.stdout._handle.setBlocking(true);
|
||||
}
|
||||
},
|
||||
bufferFrom: bufferFrom,
|
||||
base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); },
|
||||
base64encode: function (input) { return bufferFrom(input).toString("base64"); },
|
||||
require: function (baseDir, moduleName) {
|
||||
try {
|
||||
var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem);
|
||||
return { module: require(modulePath), modulePath: modulePath, error: undefined };
|
||||
}
|
||||
catch (error) {
|
||||
return { module: undefined, modulePath: undefined, error: error };
|
||||
}
|
||||
}
|
||||
};
|
||||
return nodeSystem;
|
||||
/**
|
||||
* `throwIfNoEntry` was added so recently that it's not in the node types.
|
||||
* This helper encapsulates the mitigating usage of `any`.
|
||||
* See https://github.com/nodejs/node/pull/33716
|
||||
*/
|
||||
function statSync(path) {
|
||||
// throwIfNoEntry will be ignored by older versions of node
|
||||
return _fs.statSync(path, { throwIfNoEntry: false });
|
||||
}
|
||||
/**
|
||||
* Uses the builtin inspector APIs to capture a CPU profile
|
||||
* See https://nodejs.org/api/inspector.html#inspector_example_usage for details
|
||||
*/
|
||||
function enableCPUProfiler(path, cb) {
|
||||
if (activeSession) {
|
||||
cb();
|
||||
return false;
|
||||
}
|
||||
var inspector = require("inspector");
|
||||
if (!inspector || !inspector.Session) {
|
||||
cb();
|
||||
return false;
|
||||
}
|
||||
var session = new inspector.Session();
|
||||
session.connect();
|
||||
session.post("Profiler.enable", function () {
|
||||
session.post("Profiler.start", function () {
|
||||
activeSession = session;
|
||||
profilePath = path;
|
||||
cb();
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Strips non-TS paths from the profile, so users with private projects shouldn't
|
||||
* need to worry about leaking paths by submitting a cpu profile to us
|
||||
*/
|
||||
function cleanupPaths(profile) {
|
||||
var externalFileCounter = 0;
|
||||
var remappedPaths = new ts.Map();
|
||||
var normalizedDir = ts.normalizeSlashes(__dirname);
|
||||
// Windows rooted dir names need an extra `/` prepended to be valid file:/// urls
|
||||
var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir);
|
||||
for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
|
||||
var node = _a[_i];
|
||||
if (node.callFrame.url) {
|
||||
var url = ts.normalizeSlashes(node.callFrame.url);
|
||||
if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
|
||||
node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true);
|
||||
}
|
||||
else if (!nativePattern.test(url)) {
|
||||
node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url);
|
||||
externalFileCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
function disableCPUProfiler(cb) {
|
||||
if (activeSession && activeSession !== "stopping") {
|
||||
var s_1 = activeSession;
|
||||
activeSession.post("Profiler.stop", function (err, _a) {
|
||||
var _b;
|
||||
var profile = _a.profile;
|
||||
if (!err) {
|
||||
try {
|
||||
if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) {
|
||||
profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile"));
|
||||
}
|
||||
}
|
||||
catch (_c) {
|
||||
// do nothing and ignore fallible fs operation
|
||||
}
|
||||
try {
|
||||
_fs.mkdirSync(_path.dirname(profilePath), { recursive: true });
|
||||
}
|
||||
catch (_d) {
|
||||
// do nothing and ignore fallible fs operation
|
||||
}
|
||||
_fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile)));
|
||||
}
|
||||
activeSession = undefined;
|
||||
s_1.disconnect();
|
||||
cb();
|
||||
});
|
||||
activeSession = "stopping";
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
cb();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function bufferFrom(input, encoding) {
|
||||
// See https://github.com/Microsoft/TypeScript/issues/25652
|
||||
return Buffer.from && Buffer.from !== Int8Array.from
|
||||
? Buffer.from(input, encoding)
|
||||
: new Buffer(input, encoding);
|
||||
}
|
||||
function isFileSystemCaseSensitive() {
|
||||
// win32\win64 are case insensitive platforms
|
||||
if (platform === "win32" || platform === "win64") {
|
||||
return false;
|
||||
}
|
||||
// If this file exists under a different case, we must be case-insensitve.
|
||||
return !fileExists(swapCase(__filename));
|
||||
}
|
||||
/** Convert all lowercase chars to uppercase, and vice-versa */
|
||||
function swapCase(s) {
|
||||
return s.replace(/\w/g, function (ch) {
|
||||
var up = ch.toUpperCase();
|
||||
return ch === up ? ch.toLowerCase() : up;
|
||||
});
|
||||
}
|
||||
function fsWatchFileWorker(fileName, callback, pollingInterval) {
|
||||
_fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
|
||||
var eventKind;
|
||||
return {
|
||||
close: function () { return _fs.unwatchFile(fileName, fileChanged); }
|
||||
};
|
||||
function fileChanged(curr, prev) {
|
||||
// previous event kind check is to ensure we recongnize the file as previously also missing when it is restored or renamed twice (that is it disappears and reappears)
|
||||
// In such case, prevTime returned is same as prev time of event when file was deleted as per node documentation
|
||||
var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
|
||||
if (+curr.mtime === 0) {
|
||||
if (isPreviouslyDeleted) {
|
||||
// Already deleted file, no need to callback again
|
||||
return;
|
||||
}
|
||||
eventKind = FileWatcherEventKind.Deleted;
|
||||
}
|
||||
else if (isPreviouslyDeleted) {
|
||||
eventKind = FileWatcherEventKind.Created;
|
||||
}
|
||||
// If there is no change in modified time, ignore the event
|
||||
else if (+curr.mtime === +prev.mtime) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// File changed
|
||||
eventKind = FileWatcherEventKind.Changed;
|
||||
}
|
||||
callback(fileName, eventKind);
|
||||
}
|
||||
}
|
||||
function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
|
||||
var options;
|
||||
var lastDirectoryPartWithDirectorySeparator;
|
||||
var lastDirectoryPart;
|
||||
if (isLinuxOrMacOs) {
|
||||
lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
|
||||
lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
|
||||
}
|
||||
/** Watcher for the file system entry depending on whether it is missing or present */
|
||||
var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
||||
watchMissingFileSystemEntry() :
|
||||
watchPresentFileSystemEntry();
|
||||
return {
|
||||
close: function () {
|
||||
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
||||
watcher.close();
|
||||
watcher = undefined;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Invoke the callback with rename and update the watcher if not closed
|
||||
* @param createWatcher
|
||||
*/
|
||||
function invokeCallbackAndUpdateWatcher(createWatcher) {
|
||||
ts.sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher"));
|
||||
// Call the callback for current directory
|
||||
callback("rename", "");
|
||||
// If watcher is not closed, update it
|
||||
if (watcher) {
|
||||
watcher.close();
|
||||
watcher = createWatcher();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Watch the file or directory that is currently present
|
||||
* and when the watched file or directory is deleted, switch to missing file system entry watcher
|
||||
*/
|
||||
function watchPresentFileSystemEntry() {
|
||||
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
||||
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
||||
if (options === undefined) {
|
||||
if (fsSupportsRecursiveFsWatch) {
|
||||
options = { persistent: true, recursive: !!recursive };
|
||||
}
|
||||
else {
|
||||
options = { persistent: true };
|
||||
}
|
||||
}
|
||||
if (hitSystemWatcherLimit) {
|
||||
ts.sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to fsWatchFile"));
|
||||
return watchPresentFileSystemEntryWithFsWatchFile();
|
||||
}
|
||||
try {
|
||||
var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
|
||||
callbackChangingToMissingFileSystemEntry :
|
||||
callback);
|
||||
// Watch the missing file or directory or error
|
||||
presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
|
||||
return presentWatcher;
|
||||
}
|
||||
catch (e) {
|
||||
// Catch the exception and use polling instead
|
||||
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
||||
// so instead of throwing error, use fs.watchFile
|
||||
hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
|
||||
ts.sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to fsWatchFile"));
|
||||
return watchPresentFileSystemEntryWithFsWatchFile();
|
||||
}
|
||||
}
|
||||
function callbackChangingToMissingFileSystemEntry(event, relativeName) {
|
||||
// because relativeName is not guaranteed to be correct we need to check on each rename with few combinations
|
||||
// Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path
|
||||
return event === "rename" &&
|
||||
(!relativeName ||
|
||||
relativeName === lastDirectoryPart ||
|
||||
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
|
||||
!fileSystemEntryExists(fileOrDirectory, entryKind) ?
|
||||
invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
|
||||
callback(event, relativeName);
|
||||
}
|
||||
/**
|
||||
* Watch the file or directory using fs.watchFile since fs.watch threw exception
|
||||
* Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
||||
*/
|
||||
function watchPresentFileSystemEntryWithFsWatchFile() {
|
||||
return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
|
||||
}
|
||||
/**
|
||||
* Watch the file or directory that is missing
|
||||
* and switch to existing file or directory when the missing filesystem entry is created
|
||||
*/
|
||||
function watchMissingFileSystemEntry() {
|
||||
return watchFile(fileOrDirectory, function (_fileName, eventKind) {
|
||||
if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
|
||||
// Call the callback for current file or directory
|
||||
// For now it could be callback for the inner directory creation,
|
||||
// but just return current directory, better than current no-op
|
||||
invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
|
||||
}
|
||||
}, fallbackPollingInterval, fallbackOptions);
|
||||
}
|
||||
}
|
||||
function readFileWorker(fileName, _encoding) {
|
||||
var buffer;
|
||||
try {
|
||||
buffer = _fs.readFileSync(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
var len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
// flip all byte pairs and treat as little endian.
|
||||
len &= ~1; // Round down to a multiple of 2
|
||||
for (var i = 0; i < len; i += 2) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
|
||||
// Little endian UTF-16 byte order mark detected
|
||||
return buffer.toString("utf16le", 2);
|
||||
}
|
||||
if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
|
||||
// UTF-8 byte order mark detected
|
||||
return buffer.toString("utf8", 3);
|
||||
}
|
||||
// Default is UTF-8 with no byte order mark
|
||||
return buffer.toString("utf8");
|
||||
}
|
||||
function readFile(fileName, _encoding) {
|
||||
ts.perfLogger.logStartReadFile(fileName);
|
||||
var file = readFileWorker(fileName, _encoding);
|
||||
ts.perfLogger.logStopReadFile();
|
||||
return file;
|
||||
}
|
||||
function writeFile(fileName, data, writeByteOrderMark) {
|
||||
ts.perfLogger.logEvent("WriteFile: " + fileName);
|
||||
// If a BOM is required, emit one
|
||||
if (writeByteOrderMark) {
|
||||
data = byteOrderMarkIndicator + data;
|
||||
}
|
||||
var fd;
|
||||
try {
|
||||
fd = _fs.openSync(fileName, "w");
|
||||
_fs.writeSync(fd, data, /*position*/ undefined, "utf8");
|
||||
}
|
||||
finally {
|
||||
if (fd !== undefined) {
|
||||
_fs.closeSync(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
function getAccessibleFileSystemEntries(path) {
|
||||
ts.perfLogger.logEvent("ReadDir: " + (path || "."));
|
||||
try {
|
||||
var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
|
||||
var files = [];
|
||||
var directories = [];
|
||||
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
||||
var dirent = entries_1[_i];
|
||||
// withFileTypes is not supported before Node 10.10.
|
||||
var entry = typeof dirent === "string" ? dirent : dirent.name;
|
||||
// This is necessary because on some file system node fails to exclude
|
||||
// "." and "..". See https://github.com/nodejs/node/issues/4002
|
||||
if (entry === "." || entry === "..") {
|
||||
continue;
|
||||
}
|
||||
var stat = void 0;
|
||||
if (typeof dirent === "string" || dirent.isSymbolicLink()) {
|
||||
var name = ts.combinePaths(path, entry);
|
||||
try {
|
||||
stat = statSync(name);
|
||||
if (!stat) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
stat = dirent;
|
||||
}
|
||||
if (stat.isFile()) {
|
||||
files.push(entry);
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(entry);
|
||||
}
|
||||
}
|
||||
files.sort();
|
||||
directories.sort();
|
||||
return { files: files, directories: directories };
|
||||
}
|
||||
catch (e) {
|
||||
return ts.emptyFileSystemEntries;
|
||||
}
|
||||
}
|
||||
function readDirectory(path, extensions, excludes, includes, depth) {
|
||||
return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
|
||||
}
|
||||
function fileSystemEntryExists(path, entryKind) {
|
||||
// Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve
|
||||
// the CPU time performance.
|
||||
var originalStackTraceLimit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 0;
|
||||
try {
|
||||
var stat = statSync(path);
|
||||
if (!stat) {
|
||||
return false;
|
||||
}
|
||||
switch (entryKind) {
|
||||
case 0 /* File */: return stat.isFile();
|
||||
case 1 /* Directory */: return stat.isDirectory();
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
Error.stackTraceLimit = originalStackTraceLimit;
|
||||
}
|
||||
}
|
||||
function fileExists(path) {
|
||||
return fileSystemEntryExists(path, 0 /* File */);
|
||||
}
|
||||
function directoryExists(path) {
|
||||
return fileSystemEntryExists(path, 1 /* Directory */);
|
||||
}
|
||||
function getDirectories(path) {
|
||||
return getAccessibleFileSystemEntries(path).directories.slice();
|
||||
}
|
||||
function realpath(path) {
|
||||
try {
|
||||
return realpathSync(path);
|
||||
}
|
||||
catch (_a) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
function getModifiedTime(path) {
|
||||
var _a;
|
||||
try {
|
||||
return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function setModifiedTime(path, time) {
|
||||
try {
|
||||
_fs.utimesSync(path, time, time);
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
function deleteFile(path) {
|
||||
try {
|
||||
return _fs.unlinkSync(path);
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
function createSHA256Hash(data) {
|
||||
var hash = _crypto.createHash("sha256");
|
||||
hash.update(data);
|
||||
return hash.digest("hex");
|
||||
}
|
||||
}
|
||||
var sys;
|
||||
if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
|
||||
// process and process.nextTick checks if current environment is node-like
|
||||
// process.browser check excludes webpack and browserify
|
||||
sys = getNodeSystem();
|
||||
}
|
||||
if (sys) {
|
||||
// patch writefile to create folder before writing the file
|
||||
patchWriteFileEnsuringDirectory(sys);
|
||||
}
|
||||
return sys;
|
||||
})();
|
||||
/*@internal*/
|
||||
function setSys(s) {
|
||||
ts.sys = s;
|
||||
|
|
@ -162604,7 +163188,7 @@ if (typeof process === "undefined" || process.browser) {
|
|||
globalThis.toolsVersion = ts.versionMajorMinor;
|
||||
}
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
/* MONACOCHANGE */ /*module.exports = ts;*/ /* END MONACOCHANGE */
|
||||
module.exports = ts;
|
||||
}
|
||||
var ts;
|
||||
(function (ts) {
|
||||
|
|
@ -163529,6 +164113,7 @@ var ts;
|
|||
|
||||
|
||||
|
||||
|
||||
// MONACOCHANGE
|
||||
export var createClassifier = ts.createClassifier;
|
||||
export var createLanguageService = ts.createLanguageService;
|
||||
|
|
|
|||
|
|
@ -226,6 +226,73 @@ interface OutputFile {
|
|||
text: string;
|
||||
}
|
||||
|
||||
export interface ModeConfiguration {
|
||||
/**
|
||||
* Defines whether the built-in completionItemProvider is enabled.
|
||||
*/
|
||||
readonly completionItems?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in hoverProvider is enabled.
|
||||
*/
|
||||
readonly hovers?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in documentSymbolProvider is enabled.
|
||||
*/
|
||||
readonly documentSymbols?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in definitions provider is enabled.
|
||||
*/
|
||||
readonly definitions?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in references provider is enabled.
|
||||
*/
|
||||
readonly references?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in references provider is enabled.
|
||||
*/
|
||||
readonly documentHighlights?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in rename provider is enabled.
|
||||
*/
|
||||
readonly rename?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in diagnostic provider is enabled.
|
||||
*/
|
||||
readonly diagnostics?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in document formatting range edit provider is enabled.
|
||||
*/
|
||||
readonly documentRangeFormattingEdits?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in signature help provider is enabled.
|
||||
*/
|
||||
readonly signatureHelp?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in onType formatting edit provider is enabled.
|
||||
*/
|
||||
readonly onTypeFormattingEdits?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in code actions provider is enabled.
|
||||
*/
|
||||
readonly codeActions?: boolean;
|
||||
|
||||
/**
|
||||
* Defines whether the built-in inlay hints provider is enabled.
|
||||
*/
|
||||
readonly inlayHints?: boolean;
|
||||
}
|
||||
|
||||
export interface LanguageServiceDefaults {
|
||||
/**
|
||||
* Event fired when compiler options or diagnostics options are changed.
|
||||
|
|
@ -241,6 +308,9 @@ export interface LanguageServiceDefaults {
|
|||
|
||||
readonly inlayHintsOptions: InlayHintsOptions;
|
||||
|
||||
readonly modeConfiguration: ModeConfiguration;
|
||||
setModeConfiguration(modeConfiguration: ModeConfiguration): void;
|
||||
|
||||
/**
|
||||
* Get the current extra libs registered with the language service.
|
||||
*/
|
||||
|
|
@ -491,12 +561,14 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
private _workerOptions!: WorkerOptions;
|
||||
private _onDidExtraLibsChangeTimeout: number;
|
||||
private _inlayHintsOptions!: InlayHintsOptions;
|
||||
private _modeConfiguration!: ModeConfiguration;
|
||||
|
||||
constructor(
|
||||
compilerOptions: CompilerOptions,
|
||||
diagnosticsOptions: DiagnosticsOptions,
|
||||
workerOptions: WorkerOptions,
|
||||
inlayHintsOptions: InlayHintsOptions
|
||||
inlayHintsOptions: InlayHintsOptions,
|
||||
modeConfiguration: ModeConfiguration
|
||||
) {
|
||||
this._extraLibs = Object.create(null);
|
||||
this._removedExtraLibs = Object.create(null);
|
||||
|
|
@ -505,6 +577,7 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
this.setDiagnosticsOptions(diagnosticsOptions);
|
||||
this.setWorkerOptions(workerOptions);
|
||||
this.setInlayHintsOptions(inlayHintsOptions);
|
||||
this.setModeConfiguration(modeConfiguration);
|
||||
this._onDidExtraLibsChangeTimeout = -1;
|
||||
}
|
||||
|
||||
|
|
@ -516,6 +589,10 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
return this._onDidExtraLibsChange.event;
|
||||
}
|
||||
|
||||
get modeConfiguration(): ModeConfiguration {
|
||||
return this._modeConfiguration;
|
||||
}
|
||||
|
||||
get workerOptions(): WorkerOptions {
|
||||
return this._workerOptions;
|
||||
}
|
||||
|
|
@ -650,22 +727,45 @@ class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|||
getEagerModelSync() {
|
||||
return this._eagerModelSync;
|
||||
}
|
||||
|
||||
setModeConfiguration(modeConfiguration: ModeConfiguration): void {
|
||||
this._modeConfiguration = modeConfiguration || Object.create(null);
|
||||
this._onDidChange.fire(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
export const typescriptVersion: string = tsversion;
|
||||
|
||||
const modeConfigurationDefault: Required<ModeConfiguration> = {
|
||||
completionItems: true,
|
||||
hovers: true,
|
||||
documentSymbols: true,
|
||||
definitions: true,
|
||||
references: true,
|
||||
documentHighlights: true,
|
||||
rename: true,
|
||||
diagnostics: true,
|
||||
documentRangeFormattingEdits: true,
|
||||
signatureHelp: true,
|
||||
onTypeFormattingEdits: true,
|
||||
codeActions: true,
|
||||
inlayHints: true
|
||||
};
|
||||
|
||||
export const typescriptDefaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
|
||||
{ allowNonTsExtensions: true, target: ScriptTarget.Latest },
|
||||
{ noSemanticValidation: false, noSyntaxValidation: false, onlyVisible: false },
|
||||
{},
|
||||
{}
|
||||
{},
|
||||
modeConfigurationDefault
|
||||
);
|
||||
|
||||
export const javascriptDefaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
|
||||
{ allowNonTsExtensions: true, allowJs: true, target: ScriptTarget.Latest },
|
||||
{ noSemanticValidation: true, noSyntaxValidation: false, onlyVisible: false },
|
||||
{},
|
||||
{}
|
||||
{},
|
||||
modeConfigurationDefault
|
||||
);
|
||||
|
||||
export const getTypeScriptWorker = (): Promise<(...uris: Uri[]) => Promise<TypeScriptWorker>> => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { WorkerManager } from './workerManager';
|
|||
import type { TypeScriptWorker } from './tsWorker';
|
||||
import { LanguageServiceDefaults } from './monaco.contribution';
|
||||
import * as languageFeatures from './languageFeatures';
|
||||
import { languages, Uri } from '../../fillers/monaco-editor-core';
|
||||
import { languages, IDisposable, Uri } from '../../fillers/monaco-editor-core';
|
||||
|
||||
let javaScriptWorker: (...uris: Uri[]) => Promise<TypeScriptWorker>;
|
||||
let typeScriptWorker: (...uris: Uri[]) => Promise<TypeScriptWorker>;
|
||||
|
|
@ -44,46 +44,133 @@ function setupMode(
|
|||
defaults: LanguageServiceDefaults,
|
||||
modeId: string
|
||||
): (...uris: Uri[]) => Promise<TypeScriptWorker> {
|
||||
const disposables: IDisposable[] = [];
|
||||
const providers: IDisposable[] = [];
|
||||
|
||||
const client = new WorkerManager(modeId, defaults);
|
||||
disposables.push(client);
|
||||
|
||||
const worker = (...uris: Uri[]): Promise<TypeScriptWorker> => {
|
||||
return client.getLanguageServiceWorker(...uris);
|
||||
};
|
||||
|
||||
const libFiles = new languageFeatures.LibFiles(worker);
|
||||
|
||||
languages.registerCompletionItemProvider(modeId, new languageFeatures.SuggestAdapter(worker));
|
||||
languages.registerSignatureHelpProvider(
|
||||
modeId,
|
||||
new languageFeatures.SignatureHelpAdapter(worker)
|
||||
);
|
||||
languages.registerHoverProvider(modeId, new languageFeatures.QuickInfoAdapter(worker));
|
||||
languages.registerDocumentHighlightProvider(
|
||||
modeId,
|
||||
new languageFeatures.OccurrencesAdapter(worker)
|
||||
);
|
||||
languages.registerDefinitionProvider(
|
||||
modeId,
|
||||
new languageFeatures.DefinitionAdapter(libFiles, worker)
|
||||
);
|
||||
languages.registerReferenceProvider(
|
||||
modeId,
|
||||
new languageFeatures.ReferenceAdapter(libFiles, worker)
|
||||
);
|
||||
languages.registerDocumentSymbolProvider(modeId, new languageFeatures.OutlineAdapter(worker));
|
||||
languages.registerDocumentRangeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatAdapter(worker)
|
||||
);
|
||||
languages.registerOnTypeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatOnTypeAdapter(worker)
|
||||
);
|
||||
languages.registerCodeActionProvider(modeId, new languageFeatures.CodeActionAdaptor(worker));
|
||||
languages.registerRenameProvider(modeId, new languageFeatures.RenameAdapter(libFiles, worker));
|
||||
languages.registerInlayHintsProvider(modeId, new languageFeatures.InlayHintsAdapter(worker));
|
||||
new languageFeatures.DiagnosticsAdapter(libFiles, defaults, modeId, worker);
|
||||
function registerProviders(): void {
|
||||
const { modeConfiguration } = defaults;
|
||||
|
||||
disposeAll(providers);
|
||||
|
||||
if (modeConfiguration.completionItems) {
|
||||
providers.push(
|
||||
languages.registerCompletionItemProvider(
|
||||
modeId,
|
||||
new languageFeatures.SuggestAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.signatureHelp) {
|
||||
providers.push(
|
||||
languages.registerSignatureHelpProvider(
|
||||
modeId,
|
||||
new languageFeatures.SignatureHelpAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.hovers) {
|
||||
providers.push(
|
||||
languages.registerHoverProvider(modeId, new languageFeatures.QuickInfoAdapter(worker))
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.documentHighlights) {
|
||||
providers.push(
|
||||
languages.registerDocumentHighlightProvider(
|
||||
modeId,
|
||||
new languageFeatures.OccurrencesAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.definitions) {
|
||||
providers.push(
|
||||
languages.registerDefinitionProvider(
|
||||
modeId,
|
||||
new languageFeatures.DefinitionAdapter(libFiles, worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.references) {
|
||||
providers.push(
|
||||
languages.registerReferenceProvider(
|
||||
modeId,
|
||||
new languageFeatures.ReferenceAdapter(libFiles, worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.documentSymbols) {
|
||||
providers.push(
|
||||
languages.registerDocumentSymbolProvider(
|
||||
modeId,
|
||||
new languageFeatures.OutlineAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.rename) {
|
||||
providers.push(
|
||||
languages.registerRenameProvider(
|
||||
modeId,
|
||||
new languageFeatures.RenameAdapter(libFiles, worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.documentRangeFormattingEdits) {
|
||||
providers.push(
|
||||
languages.registerDocumentRangeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.onTypeFormattingEdits) {
|
||||
providers.push(
|
||||
languages.registerOnTypeFormattingEditProvider(
|
||||
modeId,
|
||||
new languageFeatures.FormatOnTypeAdapter(worker)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.codeActions) {
|
||||
providers.push(
|
||||
languages.registerCodeActionProvider(modeId, new languageFeatures.CodeActionAdaptor(worker))
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.inlayHints) {
|
||||
providers.push(
|
||||
languages.registerInlayHintsProvider(modeId, new languageFeatures.InlayHintsAdapter(worker))
|
||||
);
|
||||
}
|
||||
if (modeConfiguration.diagnostics) {
|
||||
providers.push(new languageFeatures.DiagnosticsAdapter(libFiles, defaults, modeId, worker));
|
||||
}
|
||||
}
|
||||
|
||||
registerProviders();
|
||||
|
||||
disposables.push(asDisposable(providers));
|
||||
|
||||
//return asDisposable(disposables);
|
||||
|
||||
return worker;
|
||||
}
|
||||
|
||||
function asDisposable(disposables: IDisposable[]): IDisposable {
|
||||
return { dispose: () => disposeAll(disposables) };
|
||||
}
|
||||
|
||||
function disposeAll(disposables: IDisposable[]) {
|
||||
while (disposables.length) {
|
||||
disposables.pop()!.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export { WorkerManager } from './workerManager';
|
||||
export * from './languageFeatures';
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
|
|||
|
||||
getScriptFileNames(): string[] {
|
||||
const allModels = this._ctx.getMirrorModels().map((model) => model.uri);
|
||||
const models = allModels.filter((uri) => !fileNameIsLib(uri)).map((uri) => uri.toString(true));
|
||||
const models = allModels.filter((uri) => !fileNameIsLib(uri)).map((uri) => uri.toString());
|
||||
return models.concat(Object.keys(this._extraLibs));
|
||||
}
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ export function create(ctx: worker.IWorkerContext, createData: ICreateData): Typ
|
|||
'Monaco is not using webworkers for background tasks, and that is needed to support the customWorkerPath flag'
|
||||
);
|
||||
} else {
|
||||
importScripts(createData.customWorkerPath);
|
||||
self.importScripts(createData.customWorkerPath);
|
||||
|
||||
const workerFactoryFunc: CustomTSWebWorkerFactory | undefined = self.customTSWorkerFactory;
|
||||
if (!workerFactoryFunc) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue