Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin authored Nov 4, 2024
2 parents 55d9945 + 9adbed1 commit 86c867f
Show file tree
Hide file tree
Showing 13 changed files with 503 additions and 207 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.17
20.14.0
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Monaco Editor Changelog

## [0.52.0]

- Comment added inside of `IModelContentChangedEvent`

## [0.51.0]

- New fields `IEditorOptions.placeholder` and `IEditorOptions.compactMode`
- New fields `IGotoLocationOptions.multipleTests` and `IGotoLocationOptions.alternativeTestsCommand`
- New field `IInlineEditOptions.backgroundColoring`
- New experimental field `IEditorOptions.experimental.useTrueInlineView`
- New options `CommentThreadRevealOptions` for comments

Contributions to `monaco-editor`:

- [@ScottCarda-MS (Scott Carda)](https://github.com/ScottCarda-MS): Update Q# Keywords [PR #4586](https://github.com/microsoft/monaco-editor/pull/4586)

## [0.50.0]

- New field `IEditorMinimapOptions.sectionHeaderLetterSpacing`
Expand Down
41 changes: 39 additions & 2 deletions build/build-monaco-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import path = require('path');
import fs = require('fs');
import { REPO_ROOT, readFiles, writeFiles, IFile } from '../build/utils';
import { REPO_ROOT, readFiles, writeFiles, IFile, readFile } from '../build/utils';
import { removeDir } from '../build/fs';
import ts = require('typescript');
import { generateMetadata } from './releaseMetadata';
Expand Down Expand Up @@ -66,9 +66,10 @@ generateMetadata();
* Release to `dev` or `min`.
*/
function AMD_releaseOne(type: 'dev' | 'min') {
const coreFiles = readFiles(`node_modules/monaco-editor-core/${type}/**/*`, {
let coreFiles = readFiles(`node_modules/monaco-editor-core/${type}/**/*`, {
base: `node_modules/monaco-editor-core/${type}`
});
coreFiles = fixNlsFiles(coreFiles);
AMD_addPluginContribs(type, coreFiles);
writeFiles(coreFiles, `out/monaco-editor/${type}`);

Expand All @@ -79,6 +80,33 @@ function AMD_releaseOne(type: 'dev' | 'min') {
writeFiles(pluginFiles, `out/monaco-editor/${type}`);
}

function fixNlsFiles(files: IFile[]): IFile[] {
return files.map((f) => {
if (!f.path.match(/nls\.messages\.[a-z\-]+\.js/)) {
return f;
}

const dirName = path.dirname(f.path);
const fileName = path.basename(f.path);

const newPath = path.join(dirName, 'vs', fileName);
let contentStr = f.contents.toString('utf-8');

contentStr = `
define([], function () {
${contentStr}
});
`;

const newContents = Buffer.from(contentStr, 'utf-8');

return {
path: newPath,
contents: newContents
};
});
}

/**
* Edit editor.main.js:
* - rename the AMD module 'vs/editor/editor.main' to 'vs/editor/edcore.main'
Expand All @@ -96,6 +124,15 @@ function AMD_addPluginContribs(type: 'dev' | 'min', files: IFile[]) {
// Rename the AMD module 'vs/editor/editor.main' to 'vs/editor/edcore.main'
contents = contents.replace(/"vs\/editor\/editor\.main\"/, '"vs/editor/edcore.main"');

// This ensures that old nls-plugin configurations are still respected by the new localization solution.
const contentPrefixSource = readFile('src/nls-fix.js')
.contents.toString('utf-8')
.replace(/\r\n|\n/g, ' ');

// TODO: Instead of adding this source to the header to maintain the source map indices, it should rewrite the sourcemap!
const searchValue = 'https://github.com/microsoft/vscode/blob/main/LICENSE.txt';
contents = contents.replace(searchValue, searchValue + ' */ ' + contentPrefixSource + ' /*');

const pluginFiles = readFiles(`out/languages/bundled/amd-${type}/**/monaco.contribution.js`, {
base: `out/languages/bundled/amd-${type}`
});
Expand Down
20 changes: 11 additions & 9 deletions build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,18 @@ export function readFiles(
});

const base = options.base;
return files.map((file) => readFile(file, base));
}

export function readFile(file: string, base: string = '') {
const baseLength = base === '' ? 0 : base.endsWith('/') ? base.length : base.length + 1;
return files.map((file) => {
const fullPath = path.join(REPO_ROOT, file);
const contents = fs.readFileSync(fullPath);
const relativePath = file.substring(baseLength);
return {
path: relativePath,
contents
};
});
const fullPath = path.join(REPO_ROOT, file);
const contents = fs.readFileSync(fullPath);
const relativePath = file.substring(baseLength);
return {
path: relativePath,
contents
};
}

export function writeFiles(files: IFile[], dest: string) {
Expand Down
44 changes: 22 additions & 22 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "monaco-editor",
"version": "0.50.0",
"vscodeRef": "5437499feb04f7a586f677b155b039bc2b3669eb",
"version": "0.52.0",
"vscodeRef": "493330cdc6475247184ea459c66776c3da12cd2d",
"private": true,
"description": "A browser based code editor",
"homepage": "https://github.com/microsoft/monaco-editor",
Expand Down Expand Up @@ -52,13 +52,13 @@
"jsdom": "^19.0.0",
"jsonc-parser": "^3.0.0",
"mocha": "^9.2.0",
"monaco-editor-core": "0.51.0-dev-20240725",
"monaco-editor-core": "0.52.0-rc2",
"parcel": "^2.7.0",
"pin-github-action": "^1.8.0",
"playwright": "^1.32.2",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"requirejs": "^2.3.6",
"requirejs": "^2.3.7",
"shelljs": "^0.8.5",
"style-loader": "^3.3.1",
"terser": "^5.14.2",
Expand Down
1 change: 0 additions & 1 deletion samples/browser-script-editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ <h2>Monaco Editor Sync Loading Sample</h2>
var require = { paths: { vs: '../node_modules/monaco-editor/min/vs' } };
</script>
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
<script src="../node_modules/monaco-editor/min/vs/editor/editor.main.nls.js"></script>
<script src="../node_modules/monaco-editor/min/vs/editor/editor.main.js"></script>

<script>
Expand Down
Loading

0 comments on commit 86c867f

Please sign in to comment.