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

0.47.x #20

Open
wants to merge 45 commits into
base: feat/monaco-core-0.47.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a709db4
Build esm with declarations
bytemain Mar 18, 2024
f48df2c
Upgrade monaco dts recipe
bytemain Mar 18, 2024
88b24f0
Allow set topPadding for overflowWidgets
bytemain Mar 19, 2024
28e88bc
fix: optimize register language performance
Aaaaash Dec 21, 2022
0325bc8
Add apply patches shell script
bytemain Mar 19, 2024
edde1af
Fix node require in performance
bytemain Mar 19, 2024
27d11f3
Adjust get viewLint width logic
bytemain Mar 19, 2024
a66df79
Remove StandaloneServices initialization
bytemain Mar 19, 2024
8684577
Fix monaco build
bytemain Mar 19, 2024
e3ab121
Support custom nls
bytemain Mar 19, 2024
bb78d2b
Update package name
bytemain Mar 19, 2024
969c892
Remove unused log
bytemain Mar 19, 2024
f85ef12
Fix const enum export
bytemain Mar 19, 2024
0376fc7
Release 0.47.0-patch.2
bytemain Mar 19, 2024
01beea5
Add missing export
bytemain Mar 19, 2024
5ac66f3
Transpile code into commonjs
bytemain Mar 19, 2024
f4e0b9e
chore: update comments
bytemain Mar 19, 2024
17246c3
Fix dom purify
bytemain Mar 19, 2024
ffc8061
Release 0.47.0-patch.3
bytemain Mar 19, 2024
5f39076
Fix marked esm comment
bytemain Mar 20, 2024
2497581
Release 0.47.0-patch.4
bytemain Mar 20, 2024
8a1b431
Fix platform check with process polyfill enable
bytemain Mar 20, 2024
1e01a9e
Release 0.47.0-patch.5
bytemain Mar 20, 2024
9e88190
Revert monaco api changes
bytemain Mar 22, 2024
93ab0ca
Support configure widget max dimensions
bytemain Mar 22, 2024
77f1f95
Release 0.47.0-patch.6
bytemain Mar 22, 2024
6c30e81
Remove nls json header comment
bytemain Mar 22, 2024
a18723d
Release 0.47.0-patch.7
bytemain Mar 22, 2024
206cb6e
chore: revert monaco d ts
bytemain Mar 26, 2024
be05ac9
chore(release): release 0.47.0-patch.8
bytemain Mar 27, 2024
1848939
chore(release): release 0.47.0-patch.9
bytemain Mar 27, 2024
920c3b0
Use gulp to build esm version
bytemain Mar 28, 2024
5e6bce4
chore(release): release 0.47.0-patch.10
bytemain Mar 28, 2024
64708b0
Handle default locale
bytemain Mar 28, 2024
42381de
chore(release): release 0.47.0-patch.11
bytemain Mar 28, 2024
3774048
Fix nls.localize2
bytemain Mar 28, 2024
15f99e5
chore: release 0.47.0-patch.12
bytemain Mar 28, 2024
75efbb7
Fix handle zh-Hans
bytemain Mar 29, 2024
cdfc0d8
chore(release): release 0.47.0-patch.13
bytemain Mar 29, 2024
c7d8876
Use classical syntax
bytemain Apr 2, 2024
2e0b587
chore(release): release 0.47.0-patch.14
bytemain Apr 2, 2024
e01993c
Remove patches
bytemain Apr 15, 2024
3fa494b
Revert "fix: optimize register language performance"
bytemain Apr 15, 2024
770c7e4
Make LightBulbWidget extendable
bytemain Apr 15, 2024
b93ab4b
chore(release): release 0.47.0-patch.15
bytemain Apr 15, 2024
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
16 changes: 11 additions & 5 deletions build/gulpfile.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
apiusages,
extrausages
],
shakeLevel: 2, // 0-Files, 1-InnerFile, 2-ClassMembers
shakeLevel: 0, // 0-Files, 1-InnerFile, 2-ClassMembers
importIgnorePattern: /(^vs\/css!)/,
destRoot: path.join(root, 'out-editor-src'),
redirects: []
Expand All @@ -88,6 +88,8 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
// Disable mangling for the editor, as it complicates debugging & quite a few users rely on private/protected fields.
const compileEditorAMDTask = task.define('compile-editor-amd', compilation.compileTask('out-editor-src', 'out-editor-build', true, { disableMangle: true }));

const compileEditorESMTaskPipeline = task.define('compile-editor-esm', compilation.compileTask('out-editor-esm', 'out-monaco-editor-core/esm', true, { disableMangle: true, transformConstEnum: 1 }));

const optimizeEditorAMDTask = task.define('optimize-editor-amd', optimize.optimizeTask(
{
out: 'out-editor',
Expand Down Expand Up @@ -120,8 +122,11 @@ const createESMSourcesAndResourcesTask = task.define('extract-editor-esm', () =>
ignores: [
'inlineEntryPoint:0.ts',
'inlineEntryPoint:1.ts',
'inlineEntryPoint.0.ts',
'inlineEntryPoint.1.ts',
'vs/loader.js',
'vs/base/worker/workerMain.ts',
'vs/nls.ts',
],
renames: {
'vs/nls.mock.ts': 'vs/nls.ts'
Expand Down Expand Up @@ -332,7 +337,7 @@ const finalEditorResourcesTask = task.define('final-editor-resources', () => {
// version.txt
gulp.src('build/monaco/version.txt')
.pipe(es.through(function (data) {
data.contents = Buffer.from(`monaco-editor-core: https://github.com/microsoft/vscode/tree/${sha1}`);
data.contents = Buffer.from(`monaco-editor-core: https://github.com/opensumi/monaco-editor-core/tree/${sha1}`);
this.emit('data', data);
}))
.pipe(gulp.dest('out-monaco-editor-core')),
Expand Down Expand Up @@ -408,12 +413,13 @@ gulp.task('editor-distro',
task.series(
compileEditorAMDTask,
optimizeEditorAMDTask,
minifyEditorAMDTask
// disable minify
// minifyEditorAMDTask
),
task.series(
createESMSourcesAndResourcesTask,
compileEditorESMTask,
appendJSToESMImportsTask
compileEditorESMTaskPipeline,
appendJSToESMImportsTask,
)
),
finalEditorResourcesTask
Expand Down
8 changes: 6 additions & 2 deletions build/hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ function hygiene(some, linting = true) {
const original = result.src.replace(/\r\n/gm, '\n');
const formatted = result.dest.replace(/\r\n/gm, '\n');

if (process.env.WRITE_FAIL) {
fs.writeFileSync(file.path, formatted, 'utf8');
}

if (original !== formatted) {
console.error(
`File not formatted. Run the 'Format Document' command to fix it:`,
Expand Down Expand Up @@ -173,8 +177,8 @@ function hygiene(some, linting = true) {
.pipe(unicodeFilterStream.restore)
.pipe(filter(indentationFilter))
.pipe(indentation)
.pipe(filter(copyrightFilter))
.pipe(copyrights);
.pipe(filter(copyrightFilter));
// .pipe(copyrights);

const streams = [
result.pipe(filter(tsFormattingFilter)).pipe(formatting)
Expand Down
9 changes: 9 additions & 0 deletions build/lib/compilation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion build/lib/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function createCompile(src: string, build: boolean, emitError: boolean, transpil

const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) };

if (!build) {
overrideOptions.inlineSourceMap = true;
}
Expand Down Expand Up @@ -114,7 +115,7 @@ export function transpileTask(src: string, out: string, swc: boolean): task.Stre
return task;
}

export function compileTask(src: string, out: string, build: boolean, options: { disableMangle?: boolean } = {}): task.StreamTask {
export function compileTask(src: string, out: string, build: boolean, options: { disableMangle?: boolean; transformConstEnum?: boolean } = {}): task.StreamTask {

const task = () => {

Expand Down Expand Up @@ -156,6 +157,7 @@ export function compileTask(src: string, out: string, build: boolean, options: {
.pipe(mangleStream)
.pipe(generator.stream)
.pipe(compile())
.pipe(options?.transformConstEnum ? transformConstEnum() : es.through())
.pipe(gulp.dest(out));
};

Expand Down Expand Up @@ -340,3 +342,12 @@ export const watchApiProposalNamesTask = task.define('watch-api-proposal-names',
.pipe(util.debounce(task))
.pipe(gulp.dest('src'));
});

function transformConstEnum() {
return es.map((file: File, cb: any) => {
if (/\.ts$/.test(file.path)) {
file.contents = Buffer.from(file.contents.toString().replace(/const enum/g, 'enum'));
}
cb(null, file);
});
}
55 changes: 44 additions & 11 deletions build/lib/i18n.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 53 additions & 11 deletions build/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function log(message: any, ...rest: any[]): void {
fancyLog(ansiColors.green('[i18n]'), message, ...rest);
}

function consumeUnusedVar(...args: any[]): void {
void args;
}

export interface Language {
id: string; // language id, e.g. zh-tw, de
translationId?: string; // language id used in translation tools, e.g. zh-hant, de (optional, if not set, the id is used)
Expand Down Expand Up @@ -334,9 +338,9 @@ function escapeCharacters(value: string): string {
for (let i = 0; i < value.length; i++) {
const ch = value.charAt(i);
switch (ch) {
case '\'':
result.push('\\\'');
break;
// case '\'':
// result.push('\\\'');
// break;
case '"':
result.push('\\"');
break;
Expand Down Expand Up @@ -366,6 +370,7 @@ function escapeCharacters(value: string): string {
}

function processCoreBundleFormat(fileHeader: string, languages: Language[], json: BundledFormat, emitter: ThroughStream) {
consumeUnusedVar(fileHeader);
const keysSection = json.keys;
const messageSection = json.messages;
const bundleSection = json.bundles;
Expand All @@ -392,11 +397,22 @@ function processCoreBundleFormat(fileHeader: string, languages: Language[], json
});
});

const languageDirectory = path.join(__dirname, '..', '..', '..', 'vscode-loc', 'i18n');
let languageDirectory = path.join(__dirname, '..', '..', '..', 'vscode-loc', 'i18n');
if (!fs.existsSync(languageDirectory)) {
log(`No VS Code localization repository found. Looking at ${languageDirectory}`);
log(`To bundle translations please check out the vscode-loc repository as a sibling of the vscode repository.`);
languageDirectory = path.join(__dirname, '..', '..', 'vscode-loc', 'i18n');
log(`Now looking at ${languageDirectory}`);

if (!fs.existsSync(languageDirectory)) {
log(`No VS Code localization repository found. Looking at ${languageDirectory}`);
log(`To bundle translations please check out the vscode-loc repository as a sibling of the vscode repository.`);
}
}

if (languageDirectory) {
log(`Found VS Code localization repository at ${languageDirectory}`);
}

const sortedLanguages = sortLanguages(languages);
sortedLanguages.forEach((language) => {
if (process.env['VSCODE_BUILD_VERBOSE']) {
Expand Down Expand Up @@ -446,10 +462,10 @@ function processCoreBundleFormat(fileHeader: string, languages: Language[], json
localizedModules[module] = localizedMessages;
});
Object.keys(bundleSection).forEach((bundle) => {

const modules = bundleSection[bundle];
const contents: string[] = [
fileHeader,
`define("${bundle}.nls.${language.id}", {`
'{',
];
modules.forEach((module, index) => {
contents.push(`\t"${module}": [`);
Expand All @@ -459,12 +475,12 @@ function processCoreBundleFormat(fileHeader: string, languages: Language[], json
return;
}
messages.forEach((message, index) => {
contents.push(`\t\t"${escapeCharacters(message)}${index < messages.length ? '",' : '"'}`);
contents.push(`\t\t"${escapeCharacters(message)}${index < messages.length - 1 ? '",' : '"'}`);
});
contents.push(index < modules.length - 1 ? '\t],' : '\t]');
});
contents.push('});');
emitter.queue(new File({ path: bundle + '.nls.' + language.id + '.js', contents: Buffer.from(contents.join('\n'), 'utf-8') }));
contents.push('}');
emitter.queue(new File({ path: bundle + '.nls.' + language.id + '.json', contents: Buffer.from(contents.join('\n'), 'utf-8') }));
});
});
Object.keys(statistics).forEach(key => {
Expand All @@ -479,6 +495,22 @@ function processCoreBundleFormat(fileHeader: string, languages: Language[], json
});
}

const commonHeader1 = `/*---------------------------------------------------------\n`;
const commonHeader2 = `* Copyright (c) Microsoft Corporation. All rights reserved.\n`;
const commonHeader3 = `*--------------------------------------------------------*/`;

// transform nls.js to nls.json
function toJsonNlsFile(content: string, fileHeader: string): string {
return content
.replace(fileHeader, '')
.replace(commonHeader1, '')
.replace(commonHeader2, '')
.replace(commonHeader3, '')
.replace(`define("vs/editor/editor.main.nls", {`, '{')
.replace('});', '}')
.trim();
}

export function processNlsFiles(opts: { fileHeader: string; languages: Language[] }): ThroughStream {
return through(function (this: ThroughStream, file: File) {
const fileName = path.basename(file.path);
Expand All @@ -494,7 +526,17 @@ export function processNlsFiles(opts: { fileHeader: string; languages: Language[
processCoreBundleFormat(opts.fileHeader, opts.languages, json, this);
}
}
this.queue(file);

if (file.path.includes('editor.main.nls.js')) {
this.queue(new File(
{
path: file.path.replace('.js', '.json'),
contents: Buffer.from(toJsonNlsFile(file.contents.toString(), opts.fileHeader)),
}
));
} else {
this.queue(file);
}
});
}

Expand Down
Loading