diff --git a/build/lib/compilation.js b/build/lib/compilation.js index f5d46d7b20c..8a5e93cbb4c 100644 --- a/build/lib/compilation.js +++ b/build/lib/compilation.js @@ -122,8 +122,12 @@ function watchTask(out, build) { exports.watchTask = watchTask; const REPO_SRC_FOLDER = path.join(__dirname, '../../src'); class MonacoGenerator { + _isWatch; + stream; + _watchedFiles; + _fsProvider; + _declarationResolver; constructor(isWatch) { - this._executeSoonTimer = null; this._isWatch = isWatch; this.stream = es.through(); this._watchedFiles = {}; @@ -153,6 +157,7 @@ class MonacoGenerator { }); } } + _executeSoonTimer = null; _executeSoon() { if (this._executeSoonTimer !== null) { clearTimeout(this._executeSoonTimer); diff --git a/build/lib/i18n.js b/build/lib/i18n.js index 95338e5befe..b65f27227d5 100644 --- a/build/lib/i18n.js +++ b/build/lib/i18n.js @@ -63,8 +63,8 @@ var BundledFormat; BundledFormat.is = is; })(BundledFormat || (BundledFormat = {})); class Line { + buffer = []; constructor(indent = 0) { - this.buffer = []; if (indent > 0) { this.buffer.push(new Array(indent + 1).join(' ')); } @@ -79,6 +79,7 @@ class Line { } exports.Line = Line; class TextModel { + _lines; constructor(contents) { this._lines = contents.split(/\r\n|\r|\n/); } @@ -87,6 +88,10 @@ class TextModel { } } class XLF { + project; + buffer; + files; + numberOfMessages; constructor(project) { this.project = project; this.buffer = []; @@ -168,55 +173,55 @@ class XLF { line.append(content); this.buffer.push(line.toString()); } + static parse = function (xlfString) { + return new Promise((resolve, reject) => { + const parser = new xml2js.Parser(); + const files = []; + parser.parseString(xlfString, function (err, result) { + if (err) { + reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`)); + } + const fileNodes = result['xliff']['file']; + if (!fileNodes) { + reject(new Error(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`)); + } + fileNodes.forEach((file) => { + const name = file.$.original; + if (!name) { + reject(new Error(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`)); + } + const language = file.$['target-language']; + if (!language) { + reject(new Error(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`)); + } + const messages = {}; + const transUnits = file.body[0]['trans-unit']; + if (transUnits) { + transUnits.forEach((unit) => { + const key = unit.$.id; + if (!unit.target) { + return; // No translation available + } + let val = unit.target[0]; + if (typeof val !== 'string') { + // We allow empty source values so support them for translations as well. + val = val._ ? val._ : ''; + } + if (!key) { + reject(new Error(`XLF parsing error: trans-unit ${JSON.stringify(unit, undefined, 0)} defined in file ${name} is missing the ID attribute.`)); + return; + } + messages[key] = decodeEntities(val); + }); + files.push({ messages, name, language: language.toLowerCase() }); + } + }); + resolve(files); + }); + }); + }; } exports.XLF = XLF; -XLF.parse = function (xlfString) { - return new Promise((resolve, reject) => { - const parser = new xml2js.Parser(); - const files = []; - parser.parseString(xlfString, function (err, result) { - if (err) { - reject(new Error(`XLF parsing error: Failed to parse XLIFF string. ${err}`)); - } - const fileNodes = result['xliff']['file']; - if (!fileNodes) { - reject(new Error(`XLF parsing error: XLIFF file does not contain "xliff" or "file" node(s) required for parsing.`)); - } - fileNodes.forEach((file) => { - const name = file.$.original; - if (!name) { - reject(new Error(`XLF parsing error: XLIFF file node does not contain original attribute to determine the original location of the resource file.`)); - } - const language = file.$['target-language']; - if (!language) { - reject(new Error(`XLF parsing error: XLIFF file node does not contain target-language attribute to determine translated language.`)); - } - const messages = {}; - const transUnits = file.body[0]['trans-unit']; - if (transUnits) { - transUnits.forEach((unit) => { - const key = unit.$.id; - if (!unit.target) { - return; // No translation available - } - let val = unit.target[0]; - if (typeof val !== 'string') { - // We allow empty source values so support them for translations as well. - val = val._ ? val._ : ''; - } - if (!key) { - reject(new Error(`XLF parsing error: trans-unit ${JSON.stringify(unit, undefined, 0)} defined in file ${name} is missing the ID attribute.`)); - return; - } - messages[key] = decodeEntities(val); - }); - files.push({ messages, name, language: language.toLowerCase() }); - } - }); - resolve(files); - }); - }); -}; function sortLanguages(languages) { return languages.sort((a, b) => { return a.id < b.id ? -1 : (a.id > b.id ? 1 : 0); diff --git a/build/lib/monaco-api.js b/build/lib/monaco-api.js index a7542b711df..adabc35e711 100644 --- a/build/lib/monaco-api.js +++ b/build/lib/monaco-api.js @@ -492,12 +492,17 @@ class FSProvider { } exports.FSProvider = FSProvider; class CacheEntry { + sourceFile; + mtime; constructor(sourceFile, mtime) { this.sourceFile = sourceFile; this.mtime = mtime; } } class DeclarationResolver { + _fsProvider; + ts; + _sourceFileCache; constructor(_fsProvider) { this._fsProvider = _fsProvider; this.ts = require('typescript'); @@ -553,6 +558,10 @@ function run3(resolver) { } exports.run3 = run3; class TypeScriptLanguageServiceHost { + _ts; + _libs; + _files; + _compilerOptions; constructor(ts, libs, files, compilerOptions) { this._ts = ts; this._libs = libs; diff --git a/build/lib/nls.js b/build/lib/nls.js index 7dd43a78207..d8144e33eac 100644 --- a/build/lib/nls.js +++ b/build/lib/nls.js @@ -95,18 +95,22 @@ var _nls; return { line: position.line - 1, character: position.column }; } class SingleFileServiceHost { + options; + filename; + file; + lib; constructor(ts, options, filename, contents) { this.options = options; this.filename = filename; - this.getCompilationSettings = () => this.options; - this.getScriptFileNames = () => [this.filename]; - this.getScriptVersion = () => '1'; - this.getScriptSnapshot = (name) => name === this.filename ? this.file : this.lib; - this.getCurrentDirectory = () => ''; - this.getDefaultLibFileName = () => 'lib.d.ts'; this.file = ts.ScriptSnapshot.fromString(contents); this.lib = ts.ScriptSnapshot.fromString(''); } + getCompilationSettings = () => this.options; + getScriptFileNames = () => [this.filename]; + getScriptVersion = () => '1'; + getScriptSnapshot = (name) => name === this.filename ? this.file : this.lib; + getCurrentDirectory = () => ''; + getDefaultLibFileName = () => 'lib.d.ts'; readFile(path, _encoding) { if (path === this.filename) { return this.file.getText(0, this.file.getLength()); @@ -208,6 +212,8 @@ var _nls; }; } class TextModel { + lines; + lineEndings; constructor(contents) { const regex = /\r\n|\r|\n/g; let index = 0; diff --git a/build/lib/policies.js b/build/lib/policies.js index 37bb8e36d0c..3dcc3c13b36 100644 --- a/build/lib/policies.js +++ b/build/lib/policies.js @@ -41,6 +41,12 @@ function renderADMLString(prefix, moduleName, nlsString, translations) { return `${value}`; } class BasePolicy { + policyType; + name; + category; + minimumVersion; + description; + moduleName; constructor(policyType, name, category, minimumVersion, description, moduleName) { this.policyType = policyType; this.name = name; @@ -96,6 +102,7 @@ class BooleanPolicy extends BasePolicy { } } class IntPolicy extends BasePolicy { + defaultValue; static from(name, category, minimumVersion, description, moduleName, settingNode) { const type = getStringProperty(settingNode, 'type'); if (type !== 'number') { @@ -140,6 +147,8 @@ class StringPolicy extends BasePolicy { } } class StringEnumPolicy extends BasePolicy { + enum_; + enumDescriptions; static from(name, category, minimumVersion, description, moduleName, settingNode) { const type = getStringProperty(settingNode, 'type'); if (type !== 'string') { diff --git a/build/lib/reporter.js b/build/lib/reporter.js index 0c735614324..340f0a5f5ec 100644 --- a/build/lib/reporter.js +++ b/build/lib/reporter.js @@ -12,12 +12,13 @@ const ansiColors = require("ansi-colors"); const fs = require("fs"); const path = require("path"); class ErrorLog { + id; constructor(id) { this.id = id; - this.allErrors = []; - this.startTime = null; - this.count = 0; } + allErrors = []; + startTime = null; + count = 0; onStart() { if (this.count++ > 0) { return; diff --git a/build/lib/stats.js b/build/lib/stats.js index 869ac2043b3..e1315741079 100644 --- a/build/lib/stats.js +++ b/build/lib/stats.js @@ -9,6 +9,9 @@ const es = require("event-stream"); const fancyLog = require("fancy-log"); const ansiColors = require("ansi-colors"); class Entry { + name; + totalCount; + totalSize; constructor(name, totalCount, totalSize) { this.name = name; this.totalCount = totalCount; diff --git a/build/lib/treeshaking.js b/build/lib/treeshaking.js index 029235f7709..b532e425f0d 100644 --- a/build/lib/treeshaking.js +++ b/build/lib/treeshaking.js @@ -163,6 +163,10 @@ function processLibFiles(ts, options) { * A TypeScript language service host */ class TypeScriptLanguageServiceHost { + _ts; + _libs; + _files; + _compilerOptions; constructor(ts, libs, files, compilerOptions) { this._ts = ts; this._libs = libs; @@ -747,6 +751,8 @@ function findSymbolFromHeritageType(ts, checker, type) { return null; } class SymbolImportTuple { + symbol; + symbolImportNode; constructor(symbol, symbolImportNode) { this.symbol = symbol; this.symbolImportNode = symbolImportNode; diff --git a/build/lib/tsb/builder.js b/build/lib/tsb/builder.js index be74a30a17a..1476a345523 100644 --- a/build/lib/tsb/builder.js +++ b/build/lib/tsb/builder.js @@ -299,6 +299,8 @@ function createTypeScriptBuilder(config, projectFile, cmd) { } exports.createTypeScriptBuilder = createTypeScriptBuilder; class ScriptSnapshot { + _text; + _mtime; constructor(text, mtime) { this._text = text; this._mtime = mtime; @@ -317,6 +319,7 @@ class ScriptSnapshot { } } class VinylScriptSnapshot extends ScriptSnapshot { + _base; constructor(file) { super(file.contents.toString(), file.stat.mtime); this._base = file.base; @@ -326,15 +329,20 @@ class VinylScriptSnapshot extends ScriptSnapshot { } } class LanguageServiceHost { + _cmdLine; + _projectPath; + _log; + _snapshots; + _filesInProject; + _filesAdded; + _dependencies; + _dependenciesRecomputeList; + _fileNameToDeclaredModule; + _projectVersion; constructor(_cmdLine, _projectPath, _log) { this._cmdLine = _cmdLine; this._projectPath = _projectPath; this._log = _log; - this.directoryExists = ts.sys.directoryExists; - this.getDirectories = ts.sys.getDirectories; - this.fileExists = ts.sys.fileExists; - this.readFile = ts.sys.readFile; - this.readDirectory = ts.sys.readDirectory; this._snapshots = Object.create(null); this._filesInProject = new Set(_cmdLine.fileNames); this._filesAdded = new Set(); @@ -389,6 +397,7 @@ class LanguageServiceHost { } return result; } + static _declareModule = /declare\s+module\s+('|")(.+)\1/g; addScriptSnapshot(filename, snapshot) { this._projectVersion++; filename = normalize(filename); @@ -432,6 +441,11 @@ class LanguageServiceHost { getDefaultLibFileName(options) { return ts.getDefaultLibFilePath(options); } + directoryExists = ts.sys.directoryExists; + getDirectories = ts.sys.getDirectories; + fileExists = ts.sys.fileExists; + readFile = ts.sys.readFile; + readDirectory = ts.sys.readDirectory; // ---- dependency management collectDependents(filename, target) { while (this._dependenciesRecomputeList.length) { @@ -488,4 +502,3 @@ class LanguageServiceHost { }); } } -LanguageServiceHost._declareModule = /declare\s+module\s+('|")(.+)\1/g; diff --git a/build/lib/tsb/transpiler.js b/build/lib/tsb/transpiler.js index e5e90128d09..9086642128a 100644 --- a/build/lib/tsb/transpiler.js +++ b/build/lib/tsb/transpiler.js @@ -3,7 +3,6 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.SwcTranspiler = exports.TscTranspiler = void 0; const swc = require("@swc/core"); @@ -39,6 +38,7 @@ if (!threads.isMainThread) { }); } class OutputFileNameOracle { + getOutputFileName; constructor(cmdLine, configFilePath) { this.getOutputFileName = (file) => { try { @@ -68,10 +68,12 @@ class OutputFileNameOracle { } } class TranspileWorker { + static pool = 1; + id = TranspileWorker.pool++; + _worker = new threads.Worker(__filename); + _pending; + _durations = []; constructor(outFileFn) { - this.id = TranspileWorker.pool++; - this._worker = new threads.Worker(__filename); - this._durations = []; this._worker.addListener('message', (res) => { if (!this._pending) { console.error('RECEIVING data WITHOUT request'); @@ -142,14 +144,18 @@ class TranspileWorker { }); } } -TranspileWorker.pool = 1; class TscTranspiler { + _onError; + _cmdLine; + static P = Math.floor((0, node_os_1.cpus)().length * .5); + _outputFileNames; + onOutfile; + _workerPool = []; + _queue = []; + _allJobs = []; constructor(logFn, _onError, configFilePath, _cmdLine) { this._onError = _onError; this._cmdLine = _cmdLine; - this._workerPool = []; - this._queue = []; - this._allJobs = []; logFn('Transpile', `will use ${TscTranspiler.P} transpile worker`); this._outputFileNames = new OutputFileNameOracle(_cmdLine, configFilePath); } @@ -218,7 +224,6 @@ class TscTranspiler { } } exports.TscTranspiler = TscTranspiler; -TscTranspiler.P = Math.floor((0, node_os_1.cpus)().length * .5); function _isDefaultEmpty(src) { return src .replace('"use strict";', '') @@ -226,11 +231,16 @@ function _isDefaultEmpty(src) { .trim().length === 0; } class SwcTranspiler { + _logFn; + _onError; + _cmdLine; + onOutfile; + _outputFileNames; + _jobs = []; constructor(_logFn, _onError, configFilePath, _cmdLine) { this._logFn = _logFn; this._onError = _onError; this._cmdLine = _cmdLine; - this._jobs = []; _logFn('Transpile', `will use SWC to transpile source files`); this._outputFileNames = new OutputFileNameOracle(_cmdLine, configFilePath); } @@ -274,41 +284,40 @@ class SwcTranspiler { this._onError(err); })); } + // --- .swcrc + static _swcrcAmd = { + exclude: '\.js$', + jsc: { + parser: { + syntax: 'typescript', + tsx: false, + decorators: true + }, + target: 'es2020', + loose: false, + minify: { + compress: false, + mangle: false + } + }, + module: { + type: 'amd', + noInterop: true + }, + minify: false, + }; + static _swcrcCommonJS = { + ...this._swcrcAmd, + module: { + type: 'commonjs', + importInterop: 'none' + } + }; + static _swcrcEsm = { + ...this._swcrcAmd, + module: { + type: 'es6' + } + }; } exports.SwcTranspiler = SwcTranspiler; -_a = SwcTranspiler; -// --- .swcrc -SwcTranspiler._swcrcAmd = { - exclude: '\.js$', - jsc: { - parser: { - syntax: 'typescript', - tsx: false, - decorators: true - }, - target: 'es2020', - loose: false, - minify: { - compress: false, - mangle: false - } - }, - module: { - type: 'amd', - noInterop: true - }, - minify: false, -}; -SwcTranspiler._swcrcCommonJS = { - ..._a._swcrcAmd, - module: { - type: 'commonjs', - importInterop: 'none' - } -}; -SwcTranspiler._swcrcEsm = { - ..._a._swcrcAmd, - module: { - type: 'es6' - } -}; diff --git a/build/lib/tsb/utils.js b/build/lib/tsb/utils.js index cc8605758ce..10d8f37d196 100644 --- a/build/lib/tsb/utils.js +++ b/build/lib/tsb/utils.js @@ -71,9 +71,10 @@ var graph; } graph.newNode = newNode; class Graph { + _hashFn; + _nodes = {}; constructor(_hashFn) { this._hashFn = _hashFn; - this._nodes = {}; // empty } traverse(start, inwards, callback) { diff --git a/build/tsconfig.json b/build/tsconfig.json index ac3ce923add..8211139f396 100644 --- a/build/tsconfig.json +++ b/build/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2020", + "target": "es2022", "lib": ["ES2020"], "module": "commonjs", "alwaysStrict": true, @@ -8,7 +8,6 @@ "preserveConstEnums": true, "sourceMap": false, "resolveJsonModule": true, - "experimentalDecorators": true, // enable JavaScript type checking for the language service // use the tsconfig.build.json for compiling which disable JavaScript // type checking so that JavaScript file are not transpiled