Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump target for build scripts #165287

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion build/lib/compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -153,6 +157,7 @@ class MonacoGenerator {
});
}
}
_executeSoonTimer = null;
_executeSoon() {
if (this._executeSoonTimer !== null) {
clearTimeout(this._executeSoonTimer);
Expand Down
97 changes: 51 additions & 46 deletions build/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' '));
}
Expand All @@ -79,6 +79,7 @@ class Line {
}
exports.Line = Line;
class TextModel {
_lines;
constructor(contents) {
this._lines = contents.split(/\r\n|\r|\n/);
}
Expand All @@ -87,6 +88,10 @@ class TextModel {
}
}
class XLF {
project;
buffer;
files;
numberOfMessages;
constructor(project) {
this.project = project;
this.buffer = [];
Expand Down Expand Up @@ -168,55 +173,55 @@ class XLF {
line.append(content);
this.buffer.push(line.toString());
}
}
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.`));
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 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() });
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);
});
resolve(files);
});
});
};
};
}
exports.XLF = XLF;
function sortLanguages(languages) {
return languages.sort((a, b) => {
return a.id < b.id ? -1 : (a.id > b.id ? 1 : 0);
Expand Down
9 changes: 9 additions & 0 deletions build/lib/monaco-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 12 additions & 6 deletions build/lib/nls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -208,6 +212,8 @@ var _nls;
};
}
class TextModel {
lines;
lineEndings;
constructor(contents) {
const regex = /\r\n|\r|\n/g;
let index = 0;
Expand Down
9 changes: 9 additions & 0 deletions build/lib/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ function renderADMLString(prefix, moduleName, nlsString, translations) {
return `<string id="${prefix}_${nlsString.nlsKey}">${value}</string>`;
}
class BasePolicy {
policyType;
name;
category;
minimumVersion;
description;
moduleName;
constructor(policyType, name, category, minimumVersion, description, moduleName) {
this.policyType = policyType;
this.name = name;
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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') {
Expand Down
7 changes: 4 additions & 3 deletions build/lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions build/lib/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions build/lib/treeshaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -747,6 +751,8 @@ function findSymbolFromHeritageType(ts, checker, type) {
return null;
}
class SymbolImportTuple {
symbol;
symbolImportNode;
constructor(symbol, symbolImportNode) {
this.symbol = symbol;
this.symbolImportNode = symbolImportNode;
Expand Down
25 changes: 19 additions & 6 deletions build/lib/tsb/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -317,6 +319,7 @@ class ScriptSnapshot {
}
}
class VinylScriptSnapshot extends ScriptSnapshot {
_base;
constructor(file) {
super(file.contents.toString(), file.stat.mtime);
this._base = file.base;
Expand All @@ -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();
Expand Down Expand Up @@ -389,6 +397,7 @@ class LanguageServiceHost {
}
return result;
}
static _declareModule = /declare\s+module\s+('|")(.+)\1/g;
addScriptSnapshot(filename, snapshot) {
this._projectVersion++;
filename = normalize(filename);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -488,4 +502,3 @@ class LanguageServiceHost {
});
}
}
LanguageServiceHost._declareModule = /declare\s+module\s+('|")(.+)\1/g;
Loading