Merge branch 'main' into mn/fix/expose-all-module-resolutions

This commit is contained in:
Michael Nahkies 2024-09-20 12:33:46 +01:00 committed by GitHub
commit f7512b812b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 240 additions and 141 deletions

View file

@ -1,29 +0,0 @@
name: Info Needed Closer
on:
schedule:
- cron: 20 12 * * * # 5:20am Redmond
repository_dispatch:
types: [trigger-needs-more-info]
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions
uses: actions/checkout@v2
with:
repository: 'microsoft/vscode-github-triage-actions'
path: ./actions
ref: stable
- name: Install Actions
run: npm install --production --prefix ./actions
- name: Run Info Needed Closer
uses: ./actions/needs-more-info-closer
with:
label: info-needed
closeDays: 7
additionalTeam: 'spahnke|rcjsuen'
closeComment: "This issue has been closed automatically because it needs more information and has not had recent activity. See also our [issue reporting](https://aka.ms/vscodeissuereporting) guidelines.\n\nHappy Coding!"
pingDays: 120
pingComment: "Hey @${assignee}, this issue might need further attention.\n\n@${author}, you can help us out by closing this issue if the problem no longer exists, or adding more information."

View file

@ -1,27 +0,0 @@
name: Locker
on:
schedule:
- cron: 21 23 * * * # 5:20pm Redmond
repository_dispatch:
types: [trigger-locker]
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions
uses: actions/checkout@v2
with:
repository: 'microsoft/vscode-github-triage-actions'
path: ./actions
ref: stable
- name: Install Actions
run: npm install --production --prefix ./actions
- name: Run Locker
uses: ./actions/locker
with:
daysSinceClose: 45
appInsightsKey: ${{secrets.TRIAGE_ACTIONS_APP_INSIGHTS}}
daysSinceUpdate: 3
ignoredLabel: '*out-of-scope'

2
.nvmrc
View file

@ -1 +1 @@
18.17
20.14.0

View file

@ -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`

View file

@ -25,7 +25,9 @@ Make sure every unassigned issue is labeled properly:
- API Changes / Breaking Changes / New and noteworthy (use the diff from the compare step)
- Add thank you mentions ([use this tool](https://tools.code.visualstudio.com/acknowledgement) and select only the monaco-editor)
- Commit & Create PR
- [Trigger build](https://dev.azure.com/monacotools/Monaco/_build?definitionId=416) once merged
- [Trigger build](https://dev.azure.com/monacotools/Monaco/_build?definitionId=416) once merged. Tick the following checkboxes:
- Publish Monaco Editor Core
- Publish Monaco Editor
#### Publish new webpack plugin

View file

@ -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';
@ -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}`);
@ -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'
@ -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}`
});

View file

@ -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) {

18
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "monaco-editor",
"version": "0.50.0",
"version": "0.52.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "monaco-editor",
"version": "0.50.0",
"version": "0.52.0",
"hasInstallScript": true,
"license": "MIT",
"devDependencies": {
@ -25,7 +25,7 @@
"jsdom": "^19.0.0",
"jsonc-parser": "^3.0.0",
"mocha": "^9.2.0",
"monaco-editor-core": "0.50.0-rc",
"monaco-editor-core": "0.52.0-rc2",
"parcel": "^2.7.0",
"pin-github-action": "^1.8.0",
"playwright": "^1.32.2",
@ -5394,9 +5394,9 @@
"dev": true
},
"node_modules/monaco-editor-core": {
"version": "0.50.0-rc",
"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.50.0-rc.tgz",
"integrity": "sha512-DM/rRS4/dxWvHnszmSA81hpAhy8k5k1zE/aYc+lvH+4SxEJNsdHhindo8xM7VavawujvGhs+X3SPbi3ytl3rJQ==",
"version": "0.52.0-rc2",
"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.52.0-rc2.tgz",
"integrity": "sha512-buoH7pURwcTnmnO+aQ69jlbJ1Nop7w3sQm1pmBJ6pr/M9/WhAD2GsgL/bOf7kK+Vzd9FlzitlThImezQ28s9+g==",
"dev": true
},
"node_modules/mri": {
@ -11150,9 +11150,9 @@
}
},
"monaco-editor-core": {
"version": "0.50.0-rc",
"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.50.0-rc.tgz",
"integrity": "sha512-DM/rRS4/dxWvHnszmSA81hpAhy8k5k1zE/aYc+lvH+4SxEJNsdHhindo8xM7VavawujvGhs+X3SPbi3ytl3rJQ==",
"version": "0.52.0-rc2",
"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.52.0-rc2.tgz",
"integrity": "sha512-buoH7pURwcTnmnO+aQ69jlbJ1Nop7w3sQm1pmBJ6pr/M9/WhAD2GsgL/bOf7kK+Vzd9FlzitlThImezQ28s9+g==",
"dev": true
},
"mri": {

View file

@ -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",
@ -52,7 +52,7 @@
"jsdom": "^19.0.0",
"jsonc-parser": "^3.0.0",
"mocha": "^9.2.0",
"monaco-editor-core": "0.50.0-rc",
"monaco-editor-core": "0.52.0-rc2",
"parcel": "^2.7.0",
"pin-github-action": "^1.8.0",
"playwright": "^1.32.2",

View file

@ -16,7 +16,6 @@
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>

View file

@ -6,7 +6,6 @@
import { testTokenization } from '../test/testRunner';
testTokenization('qsharp', [
// Generated from sample: https://github.com/microsoft/Quantum/blob/main/samples/azure-quantum/parallel-qrng/ParallelQrng.ipynb
[
{
line: 'open Microsoft.Quantum.Arrays;',
@ -21,19 +20,6 @@ testTokenization('qsharp', [
{ startIndex: 29, type: 'delimiter.qsharp' }
]
},
{
line: 'open Microsoft.Quantum.Measurement;',
tokens: [
{ startIndex: 0, type: 'keyword.open.qsharp' },
{ startIndex: 4, type: 'white.qsharp' },
{ startIndex: 5, type: 'namespace.qsharp' },
{ startIndex: 14, type: 'delimiter.qsharp' },
{ startIndex: 15, type: 'namespace.qsharp' },
{ startIndex: 22, type: 'delimiter.qsharp' },
{ startIndex: 23, type: 'namespace.qsharp' },
{ startIndex: 34, type: 'delimiter.qsharp' }
]
},
{
line: '',
tokens: []
@ -67,20 +53,6 @@ testTokenization('qsharp', [
{ startIndex: 1, type: 'comment.qsharp' }
]
},
{
line: ' // superposition state, such that when we measure,',
tokens: [
{ startIndex: 0, type: 'white.qsharp' },
{ startIndex: 1, type: 'comment.qsharp' }
]
},
{
line: ' // all bitstrings occur with equal probability.',
tokens: [
{ startIndex: 0, type: 'white.qsharp' },
{ startIndex: 1, type: 'comment.qsharp' }
]
},
{
line: ' use register = Qubit[nQubits] {',
tokens: [
@ -99,13 +71,6 @@ testTokenization('qsharp', [
{ startIndex: 31, type: 'delimiter.curly.qsharp' }
]
},
{
line: ' // Set qubits in superposition.',
tokens: [
{ startIndex: 0, type: 'white.qsharp' },
{ startIndex: 2, type: 'comment.qsharp' }
]
},
{
line: ' ApplyToEachA(H, register);',
tokens: [
@ -120,17 +85,6 @@ testTokenization('qsharp', [
{ startIndex: 27, type: 'delimiter.qsharp' }
]
},
{
line: '',
tokens: []
},
{
line: ' // Measure all qubits and return.',
tokens: [
{ startIndex: 0, type: 'white.qsharp' },
{ startIndex: 2, type: 'comment.qsharp' }
]
},
{
line: ' return ForEach(MResetZ, register);',
tokens: [
@ -157,6 +111,76 @@ testTokenization('qsharp', [
{
line: '}',
tokens: [{ startIndex: 0, type: 'delimiter.curly.qsharp' }]
},
{
line: 'struct Foo { First : Int, Second : Int }',
tokens: [
{ startIndex: 0, type: 'keyword.qsharp' },
{ startIndex: 6, type: 'white.qsharp' },
{ startIndex: 7, type: 'identifier.qsharp' },
{ startIndex: 10, type: 'white.qsharp' },
{ startIndex: 11, type: 'delimiter.curly.qsharp' },
{ startIndex: 12, type: 'white.qsharp' },
{ startIndex: 13, type: 'identifier.qsharp' },
{ startIndex: 18, type: 'white.qsharp' },
{ startIndex: 19, type: 'operator.qsharp' },
{ startIndex: 20, type: 'white.qsharp' },
{ startIndex: 21, type: 'type.qsharp' },
{ startIndex: 24, type: 'delimiter.qsharp' },
{ startIndex: 25, type: 'white.qsharp' },
{ startIndex: 26, type: 'identifier.qsharp' },
{ startIndex: 32, type: 'white.qsharp' },
{ startIndex: 33, type: 'operator.qsharp' },
{ startIndex: 34, type: 'white.qsharp' },
{ startIndex: 35, type: 'type.qsharp' },
{ startIndex: 38, type: 'white.qsharp' },
{ startIndex: 39, type: 'delimiter.curly.qsharp' }
]
},
{
line: 'Foo.First',
tokens: [
{ startIndex: 0, type: 'identifier.qsharp' },
{ startIndex: 3, type: 'operator.qsharp' },
{ startIndex: 4, type: 'identifier.qsharp' }
]
},
{
line: 'import Microsoft.Quantum.Math, Microsoft.Quantum.Diagnostics.*;',
tokens: [
{ startIndex: 0, type: 'keyword.import.qsharp' },
{ startIndex: 6, type: 'white.qsharp' },
{ startIndex: 7, type: 'namespace.qsharp' },
{ startIndex: 16, type: 'delimiter.qsharp' },
{ startIndex: 17, type: 'namespace.qsharp' },
{ startIndex: 24, type: 'delimiter.qsharp' },
{ startIndex: 25, type: 'identifier.qsharp' },
{ startIndex: 29, type: 'delimiter.qsharp' },
{ startIndex: 30, type: 'white.qsharp' },
{ startIndex: 31, type: 'namespace.qsharp' },
{ startIndex: 40, type: 'delimiter.qsharp' },
{ startIndex: 41, type: 'namespace.qsharp' },
{ startIndex: 48, type: 'delimiter.qsharp' },
{ startIndex: 49, type: 'namespace.qsharp' },
{ startIndex: 60, type: 'delimiter.qsharp' },
{ startIndex: 61, type: 'wildcard.qsharp' },
{ startIndex: 62, type: 'delimiter.qsharp' }
]
},
{
line: 'export A, B, C;',
tokens: [
{ startIndex: 0, type: 'keyword.qsharp' },
{ startIndex: 6, type: 'white.qsharp' },
{ startIndex: 7, type: 'identifier.qsharp' },
{ startIndex: 8, type: 'delimiter.qsharp' },
{ startIndex: 9, type: 'white.qsharp' },
{ startIndex: 10, type: 'identifier.qsharp' },
{ startIndex: 11, type: 'delimiter.qsharp' },
{ startIndex: 12, type: 'white.qsharp' },
{ startIndex: 13, type: 'identifier.qsharp' },
{ startIndex: 14, type: 'delimiter.qsharp' }
]
}
]
]);

View file

@ -33,12 +33,15 @@ export const language = <languages.IMonarchLanguage>{
keywords: [
'namespace',
'open',
'import',
'export',
'as',
'operation',
'function',
'body',
'adjoint',
'newtype',
'struct',
'controlled',
'if',
'elif',
@ -141,7 +144,6 @@ export const language = <languages.IMonarchLanguage>{
'stackalloc',
'static',
'string',
'struct',
'switch',
'this',
'throw',
@ -202,6 +204,7 @@ export const language = <languages.IMonarchLanguage>{
'^=',
':',
'::',
'.',
'..',
'==',
'...',
@ -241,6 +244,8 @@ export const language = <languages.IMonarchLanguage>{
namespaceFollows: ['namespace', 'open'],
importsFollows: ['import'],
symbols: /[=><!~?:&|+\-*\/\^%@._]+/,
escapes: /\\[\s\S]/,
@ -257,6 +262,10 @@ export const language = <languages.IMonarchLanguage>{
token: 'keyword.$0',
next: '@namespace'
},
'@importsFollows': {
token: 'keyword.$0',
next: '@imports'
},
'@typeKeywords': 'type',
'@keywords': 'keyword',
'@constants': 'constant',
@ -282,7 +291,7 @@ export const language = <languages.IMonarchLanguage>{
[/[;,.]/, 'delimiter'],
// strings
//[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-teminated string
//[/"([^"\\]|\\.)*$/, 'string.invalid' ], // non-terminated string
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }]
],
@ -295,7 +304,16 @@ export const language = <languages.IMonarchLanguage>{
namespace: [
{ include: '@whitespace' },
[/[A-Za-z]\w*/, 'namespace'],
[/[\.=]/, 'delimiter'],
[/[\.]/, 'delimiter'],
['', '', '@pop']
],
imports: [
{ include: '@whitespace' },
[/[A-Za-z]\w*(?=\.)/, 'namespace'],
[/[A-Za-z]\w*/, 'identifier'],
[/\*/, 'wildcard'],
[/[\.,]/, 'delimiter'],
['', '', '@pop']
],

39
src/nls-fix.js Normal file
View file

@ -0,0 +1,39 @@
/* This fix ensures that old nls-plugin configurations are still respected by the new localization solution. */
/* We should try to avoid this file and find a different solution. */
/* Warning: This file still has to work when replacing "\n" with " "! */
/**
* @type {typeof define}
*/
const globalDefine = globalThis.define;
globalDefine('vs/nls.messages-loader', [], function (...args) {
return {
load: (name, req, load, config) => {
const requestedLanguage = config['vs/nls']?.availableLanguages?.['*'];
if (!requestedLanguage || requestedLanguage === 'en') {
load({});
} else {
req([`vs/nls.messages.${requestedLanguage}`], () => {
load({});
});
}
}
};
});
globalDefine(
'vs/nls.messages',
['require', 'exports', 'vs/nls.messages-loader!'],
function (require, exports) {
Object.assign(exports, {
getNLSMessages: () => globalThis._VSCODE_NLS_MESSAGES,
getNLSLanguage: () => globalThis._VSCODE_NLS_LANGUAGE
});
}
);
define = function (...args) {
if (args.length > 0 && args[0] === 'vs/nls.messages') {
return;
}
return globalDefine(...args);
};
define.amd = true;

View file

@ -8,6 +8,7 @@
<script src="../../../out/monaco-editor/dev/vs/loader.js"></script>
<script>
require.config({
baseUrl: new URL('..', document.baseURI).toString(),
paths: {
vs: '../../../out/monaco-editor/dev/vs'
}

View file

@ -186,16 +186,22 @@ suite(`Smoke Test '${testInfo.packager}' on '${testInfo.browser}'`, () => {
await page.waitForSelector(`text=addEventListener`);
// find the TypeScript worker
const tsWorker = page.workers().find((worker) => {
const url = worker.url();
return /ts\.worker(\.[a-f0-9]+)?\.js$/.test(url) || /workerMain.js#typescript$/.test(url);
});
if (!tsWorker) {
assert.fail('Could not find TypeScript worker');
function findAsync(arr, fn) {
return Promise.all(arr.map(fn)).then((results) => {
return arr.find((_, i) => results[i]);
});
}
// check that the TypeScript worker exposes `ts` as a global
assert.strictEqual(await tsWorker.evaluate(`typeof ts`), 'object');
const tsWorker = await findAsync(
page.workers(),
async (page) => await page.evaluate(`typeof ts !== 'undefined'`)
);
if (!tsWorker) {
assert.fail('Could not find TypeScript worker');
}
// check that the TypeScript worker exposes the full `ts` as a global
assert.strictEqual(await tsWorker.evaluate(`typeof ts.optionDeclarations`), 'object');

View file

@ -35,7 +35,9 @@ global.window = {
matches: false,
addEventListener: function () {}
};
}
},
setInterval: function () {},
setTimeout: function () {}
};
requirejs(

View file

@ -21,6 +21,9 @@ define('vs/nls', [], {
localize: function () {
return 'NO_LOCALIZATION_FOR_YOU';
},
localize2: function (key, message) {
return { value: 'NO_LOCALIZATION_FOR_YOU', original: message };
},
load: function (name, req, load) {
load({});
}

View file

@ -62,6 +62,10 @@ async function _loadMonaco(setup: IMonacoSetup): Promise<typeof monaco> {
return new Promise((res) => {
// First load editor.main. If it inlines the plugins, we don't want to try to load them from the server.
req(["vs/editor/editor.main"], () => {
if ((setup as any).onlyCore) {
res(monaco);
return;
}
req(
[
"vs/basic-languages/monaco.contribution",

View file

@ -17,6 +17,10 @@ export class ControlledMonacoEditor extends React.Component<{
private lastSubscription: monaco.IDisposable | undefined;
componentDidMount(): void {
this.componentDidUpdate({ value: "" });
}
componentDidUpdate(lastProps: this["props"]) {
const newOnDidValueChange = this.props.onDidValueChange;
if (newOnDidValueChange !== lastProps.onDidValueChange) {

View file

@ -9,7 +9,6 @@
paths: { vs: "node_modules/monaco-editor/min/vs" },
};
require("script-loader!../../node_modules/monaco-editor/min/vs/loader");
require("script-loader!../../node_modules/monaco-editor/min/vs/editor/editor.main.nls.js");
require("script-loader!../../node_modules/monaco-editor/min/vs/editor/editor.main.js");
import { loadMonaco } from "../monaco-loader";

View file

@ -5338,7 +5338,6 @@ return {
};
</script>
<script src="./node_modules/monaco-editor/dev/vs/loader.js"></script>
<script src="./node_modules/monaco-editor/dev/vs/editor/editor.main.nls.js"></script>
<script src="./node_modules/monaco-editor/dev/vs/editor/editor.main.js"></script>
<script data-inline="yes-please" src="./monarch/monarch.js"></script>