Pārlūkot izejas kodu

Merge branch 'main' into mdx

Henning Dieterichs 2 gadi atpakaļ
vecāks
revīzija
c46883da4f

+ 27 - 11
.github/workflows/website.yml

@@ -7,17 +7,30 @@ on:
   # enable users to manually trigger with workflow_dispatch
   workflow_dispatch: {}
 
+# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
+permissions:
+  contents: read
+  pages: write
+  id-token: write
+
+# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
+# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
+concurrency:
+  group: 'pages'
+  cancel-in-progress: false
+
 jobs:
-  publish-website:
-    name: Publish Website
+  deploy:
+    environment:
+      name: github-pages
+      url: ${{ steps.deployment.outputs.page_url }}
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # pin@v2
-
+      - name: Checkout
+        uses: actions/checkout@v3
       - uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # pin@v2
         with:
           node-version: 16
-
       - name: Cache node modules
         id: cacheNodeModules
         uses: actions/cache@v2
@@ -25,11 +38,9 @@ jobs:
           path: '**/node_modules'
           key: ${{ runner.os }}-cacheNodeModules2-${{ hashFiles('**/package-lock.json') }}
           restore-keys: ${{ runner.os }}-cacheNodeModules2-
-
       - name: execute `npm ci` (1)
         if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
         run: npm ci
-
       - name: Build
         run: npm run build-monaco-editor
 
@@ -45,8 +56,13 @@ jobs:
         working-directory: website
         run: yarn run build
 
-      - name: Upload website to github pages
-        uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # pin@v3
+      - name: Setup Pages
+        uses: actions/configure-pages@v3
+      - name: Upload artifact
+        uses: actions/upload-pages-artifact@v1
         with:
-          github_token: ${{ secrets.GITHUB_TOKEN }}
-          publish_dir: ./website/dist
+          # Upload entire repository
+          path: './website/dist'
+      - name: Deploy to GitHub Pages
+        id: deployment
+        uses: actions/deploy-pages@v2

+ 8 - 0
CHANGELOG.md

@@ -1,5 +1,13 @@
 # Monaco Editor Changelog
 
+## [0.40.0]
+
+- Support for Glyph Margin Widgets
+- Removes `getDiffLineInformationForOriginal` and `getDiffLineInformationForModified` from `IDiffEditor`
+- `createTrustedTypesPolicy` is optional now
+- New option `IModelDecorationOptions.shouldFillLineOnLineBreak`
+- New option `EditorOptions.readOnlyMessage``
+
 ## [0.39.0]
 
 - New method `Environment.createTrustedTypesPolicy` to override trusted types handling.

+ 2 - 2
MAINTAINING.md

@@ -9,7 +9,7 @@ Make sure every unassigned issue is labeled properly:
 ## Publishing a stable build monaco-editor build
 
 - Make sure there exists a nightly build from the VS Code commit the stable build should be built from
-- [Compare Last Stable With Nightly](https://microsoft.github.io/monaco-editor/playground.html?source=v0.39.0-dev.20230606#XQAAAAKzBQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw9ajfg2SGxNmVfIdymzfNMmpU96miXJZvs8c7gcyo98bKVzbks7HoMVAZiOQjzsGSo4vYRPplxTKh4qJ5_s9m1RB0u1a8RPwJXtmqrYtToAekuwuDQ2im8_QvtfSt1HbJIiHVd2zPiTBSeoC03JVOCBfBsHUM0AOblitxr0yoEKp5yCNj9Xx68iP2xX6l7R-oQQP0QegyE5JU_S6OAtnV--nu4J_lwqYHYrlBXuqsqRU-cKhSqrbrcWCxKMEmQyZkUHmM75vxSD8qepWmGk7BA4eU4YQI7tZ6g74Y0LXfIckS_2A-xIQYChatES1wLXoLosL4FhDqugt7bJg6Lelf09SdwM_NgJuVqmU8jOyMkHaKZ4nkZt61mFhR3Wa4KUfFUTCro6cKL3tIHInvgOfg8gpWdNOKy19pICfKSDYlWkn6rPgZxR0b-KCbY8K3_B6h8_TU8JfXlva5OmzfgvNBQcN_UE95r5zuBUua8JDaVLTOUKDRsOj5DYNx9KGGgicA2qjH3IlyyuOfgPTmNssWQv496rVgpqm4Zpt3DGSDY-1vxbGQe7m135DxLbACD70fgH8-C-ou2umXUKDrJbZJI2EFFMvzvZVBZVEp7Fa2j7161WJ_oyFj1HvHtTMvvrE_0P2g-u--1zh_9OHJ_ybwLAA)
+- [Compare Last Stable With Nightly](https://microsoft.github.io/monaco-editor/playground.html?source=v0.40.0-dev.20230704#XQAAAAJWBgAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw_SM66BuzMt6m3zM8Thvb-XSMR_Da8IdBq3FOgly-7-xuaHSi_yUg58ZO9Mr-RKT7GyHzHoU8B9N7P-uTzmCdhT2Vv-4gNRbWSMQCUPrfmzFCkSH_WR2Vc8LGx2m0uRSFiJu82B1mS0RM-eriU9PTOqAgBrlPUMTU44VrHyVOqgs5BFrUuUHwGDzUHxeNuUk-kg2u70awQLQ83wD4o2EbSefqfIWkk2Yi0mnUS903tLA4V17MD_6OHIRArunMPL6E14ZCW0_Aql21F62Fmz--i_pNbqBIpSlBbZl6LzA1HzNsoDH7i2rn1qAw55L1MjwOU4QQMCJfffmJznAbGoZWkXK91OPYlOGNHNGG-MPUFsY5JSjLfvCWOvXypW9ZVkBZMo1qUbtE135CLqbaBiw52f3eOPBTru3IL_wT__ciAFI5NDiVOeN8V9zqkzbwiFNeQyZcjxmrDLjYTPJpao0dG61Um0w4FpVud8p77bjoAdEfG8JNO97W4cawj0HvMfvcZS81P7IsijZqA7KyVsdq79iCJQuMO31aS86cM4GTNT0TvdI7p62uiEmm9X6ZjF8oSLxW87Vt0oYAZ5wBePqdN6FwNO6BWACt2Ep9i5Q6h-mOy7_JWOiPTOH0Zz3v6SaNhjxJwZAqNG3FqvRTgLg-au-pfa8PD0No3U15UyWeqrVXSthGFghLJ16ppEwFCqFfQ6Vr0leZtSZXyk41-t5ZKMG-KQjzq1XE2PnuyOz60nV4GaYvGlMHrXz-XrEqb2kwNf_pBee0)
   - Update [package.json](./package.json)
     - set `version` to next stable
     - set `vscodeRef` to _vscodeCommitId_
@@ -17,7 +17,7 @@ Make sure every unassigned issue is labeled properly:
   - Run `npm install` to update lockfile
   - Update [CHANGELOG.md](./CHANGELOG.md)
     - API Changes / Breaking Changes / New and noteworthy
-    - Thank you ([use this tool](https://vscode-tools.azurewebsites.net/acknowledgement/))
+    - Thank you ([use this tool](https://tools.code.visualstudio.com/acknowledgement))
   - Commit
   - [Trigger build](https://dev.azure.com/monacotools/Monaco/_build?definitionId=416)
 

+ 5 - 0
build/importTypescript.ts

@@ -37,6 +37,11 @@ export const typescriptVersion = "${typeScriptDependencyVersion}";\n`
 
 	let tsServices = fs.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescript.js')).toString();
 
+	tsServices = tsServices.replace(
+		'const path = matchedStar ? subst.replace("*", matchedStar) : subst;',
+		'const path = matchedStar ? subst.replace("*", matchedStar) : subst; // CodeQL [SM02383] This is a false positive, the code is from the TypeScript compiler'
+	);
+
 	// The output from this build will only be accessible via ESM; rather than removing
 	// references to require/module, define them as dummy variables that bundlers will ignore.
 	// The TS code can figure out that it's not running under Node even with these defined.

+ 9 - 9
package-lock.json

@@ -1,12 +1,12 @@
 {
 	"name": "monaco-editor",
-	"version": "0.39.0",
+	"version": "0.40.0",
 	"lockfileVersion": 2,
 	"requires": true,
 	"packages": {
 		"": {
 			"name": "monaco-editor",
-			"version": "0.39.0",
+			"version": "0.40.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.39.0-dev.20230605",
+				"monaco-editor-core": "^0.40.0-dev.20230629",
 				"parcel": "^2.7.0",
 				"pin-github-action": "^1.8.0",
 				"playwright": "^1.32.2",
@@ -5326,9 +5326,9 @@
 			"dev": true
 		},
 		"node_modules/monaco-editor-core": {
-			"version": "0.39.0-rc2",
-			"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.39.0-rc2.tgz",
-			"integrity": "sha512-PVOMjeVt17EvLIa27CmtVIqUz500mHPmsMJpKbVjV1fHCaRHoK38Qrk+lYWXM4MAHFOeUb1GNlj8Z1TnqlOJSw==",
+			"version": "0.40.0-dev.20230707",
+			"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.40.0-dev.20230707.tgz",
+			"integrity": "sha512-aKvvZjZYww+5KbyYq5L3aUjdRmVVXZrCXGO0A0GTISpx2PuqThDpEv7r4ZQkhHQxHSGCRZdLr2JAdgFLkNcmxg==",
 			"dev": true
 		},
 		"node_modules/mri": {
@@ -11020,9 +11020,9 @@
 			}
 		},
 		"monaco-editor-core": {
-			"version": "0.39.0-rc2",
-			"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.39.0-rc2.tgz",
-			"integrity": "sha512-PVOMjeVt17EvLIa27CmtVIqUz500mHPmsMJpKbVjV1fHCaRHoK38Qrk+lYWXM4MAHFOeUb1GNlj8Z1TnqlOJSw==",
+			"version": "0.40.0-dev.20230707",
+			"resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.40.0-dev.20230707.tgz",
+			"integrity": "sha512-aKvvZjZYww+5KbyYq5L3aUjdRmVVXZrCXGO0A0GTISpx2PuqThDpEv7r4ZQkhHQxHSGCRZdLr2JAdgFLkNcmxg==",
 			"dev": true
 		},
 		"mri": {

+ 3 - 3
package.json

@@ -1,7 +1,7 @@
 {
 	"name": "monaco-editor",
-	"version": "0.39.0",
-	"vscodeRef": "78390793536f5f43e17ff7c97b260bd2a5d1060c",
+	"version": "0.40.0",
+	"vscodeRef": "660393deaaa6d1996740ff4880f1bad43768c814",
 	"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.39.0-dev.20230605",
+		"monaco-editor-core": "^0.40.0-dev.20230629",
 		"parcel": "^2.7.0",
 		"pin-github-action": "^1.8.0",
 		"playwright": "^1.32.2",

+ 33 - 0
src/basic-languages/elixir/elixir.test.ts

@@ -303,6 +303,17 @@ testTokenization('elixir', [
 			]
 		}
 	],
+	// Sigils (multi-letter uppercase)
+	[
+		{
+			line: '~DX/foo/',
+			tokens: [
+				{ startIndex: 0, type: 'sigil.delimiter.elixir' },
+				{ startIndex: 4, type: 'sigil.elixir' },
+				{ startIndex: 7, type: 'sigil.delimiter.elixir' }
+			]
+		}
+	],
 	// Sigils (no interpolation)
 	[
 		{
@@ -314,6 +325,17 @@ testTokenization('elixir', [
 			]
 		}
 	],
+	// Sigils (multi-letter uppercase no interpolation)
+	[
+		{
+			line: '~WW/foo#{1}/',
+			tokens: [
+				{ startIndex: 0, type: 'sigil.delimiter.elixir' },
+				{ startIndex: 4, type: 'sigil.elixir' },
+				{ startIndex: 11, type: 'sigil.delimiter.elixir' }
+			]
+		}
+	],
 	// Sigils (modifiers)
 	[
 		{
@@ -325,6 +347,17 @@ testTokenization('elixir', [
 			]
 		}
 	],
+	// Sigils (multi-letter uppercase with modifiers)
+	[
+		{
+			line: '~DX/custom/az09',
+			tokens: [
+				{ startIndex: 0, type: 'sigil.delimiter.elixir' },
+				{ startIndex: 4, type: 'sigil.elixir' },
+				{ startIndex: 10, type: 'sigil.delimiter.elixir' }
+			]
+		}
+	],
 	// Module attributes
 	[
 		{

+ 10 - 9
src/basic-languages/elixir/elixir.ts

@@ -333,7 +333,8 @@ export const language = <languages.IMonarchLanguage>{
 
 		// See https://elixir-lang.org/getting-started/sigils.html
 		// Sigils allow for typing values using their textual representation.
-		// All sigils start with ~ followed by a letter indicating sigil type
+		// All sigils start with ~ followed by a letter or
+		// multi-letter uppercase starting at Elixir v1.15.0, indicating sigil type
 		// and then a delimiter pair enclosing the textual representation.
 		// Optional modifiers are allowed after the closing delimiter.
 		// For instance a regular expressions can be written as:
@@ -353,16 +354,16 @@ export const language = <languages.IMonarchLanguage>{
 
 		sigils: [
 			[/~[a-z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.interpol' }],
-			[/~[A-Z]@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.noInterpol' }]
+			[/~([A-Z]+)@sigilStartDelimiter/, { token: '@rematch', next: '@sigil.noInterpol' }]
 		],
 
 		sigil: [
-			[/~([a-zA-Z])\{/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.{.}' }],
-			[/~([a-zA-Z])\[/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.[.]' }],
-			[/~([a-zA-Z])\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }],
-			[/~([a-zA-Z])\</, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.<.>' }],
+			[/~([a-z]|[A-Z]+)\{/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.{.}' }],
+			[/~([a-z]|[A-Z]+)\[/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.[.]' }],
+			[/~([a-z]|[A-Z]+)\(/, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.(.)' }],
+			[/~([a-z]|[A-Z]+)\</, { token: '@rematch', switchTo: '@sigilStart.$S2.$1.<.>' }],
 			[
-				/~([a-zA-Z])(@sigilSymmetricDelimiter)/,
+				/~([a-z]|[A-Z]+)(@sigilSymmetricDelimiter)/,
 				{ token: '@rematch', switchTo: '@sigilStart.$S2.$1.$2.$2' }
 			]
 		],
@@ -475,7 +476,7 @@ export const language = <languages.IMonarchLanguage>{
 		// Fallback to the generic sigil by default
 		'sigilStart.interpol': [
 			[
-				/~([a-zA-Z])@sigilStartDelimiter/,
+				/~([a-z]|[A-Z]+)@sigilStartDelimiter/,
 				{
 					token: 'sigil.delimiter',
 					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'
@@ -498,7 +499,7 @@ export const language = <languages.IMonarchLanguage>{
 
 		'sigilStart.noInterpol': [
 			[
-				/~([a-zA-Z])@sigilStartDelimiter/,
+				/~([a-z]|[A-Z]+)@sigilStartDelimiter/,
 				{
 					token: 'sigil.delimiter',
 					switchTo: '@sigilContinue.$S2.$S3.$S4.$S5'

+ 1 - 1
src/language/typescript/lib/typescriptServices.js

@@ -40937,7 +40937,7 @@ ${lanes.join("\n")}
         trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
       }
       const resolved = forEach(paths[matchedPatternText], (subst) => {
-        const path = matchedStar ? subst.replace("*", matchedStar) : subst;
+        const path = matchedStar ? subst.replace("*", matchedStar) : subst; // CodeQL [SM02383] This is a false positive, the code is from the TypeScript compiler
         const candidate = normalizePath(combinePaths(baseDirectory, path));
         if (state.traceEnabled) {
           trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);

+ 2 - 2
test/manual/dev-setup.js

@@ -39,7 +39,7 @@
 			'<ul><li>' +
 			renderLoadingOptions(true) +
 			(isRelease ? '' : `</li><li>${renderLoadingOptions(false)}`) +
-			'</li></ul>';
+			'</li></ul>'; // CodeQL [SM03712] This code is not deployed and serves as local test code. No risk of malicious input.
 
 		document.body.appendChild(div);
 
@@ -47,7 +47,7 @@
 		for (let i = 0; i < aElements.length; i++) {
 			let aElement = aElements[i];
 			if (aElement.className === 'loading-opts') {
-				aElement.href += window.location.search;
+				aElement.href += window.location.search; // CodeQL [SM01507] This code is not deployed and serves as local test code. No risk of malicious input.
 			}
 		}
 	})();

+ 1 - 1
website/src/monaco-loader.ts

@@ -84,7 +84,7 @@ function loadScript(path: string): Promise<void> {
 		script.onload = () => res();
 		script.async = true;
 		script.type = "text/javascript";
-		script.src = path;
+		script.src = path; // CodeQL [SM01507] This is safe because the runner (that allows for dynamic paths) runs in an isolated iframe. The hosting website uses a static path configuration. // CodeQL [SM03712] This is safe because the runner (that allows for dynamic paths) runs in an isolated iframe. The hosting website uses a static path configuration.
 		document.head.appendChild(script);
 	});
 }

+ 2 - 2
website/src/runner/index.ts

@@ -21,7 +21,7 @@ window.addEventListener("message", (event) => {
 		const style = document.getElementById(
 			"custom-style"
 		) as HTMLStyleElement;
-		style.innerHTML = e.css;
+		style.innerHTML = e.css; // CodeQL [SM03712] This is safe because the runner runs in an isolated iframe.
 	}
 });
 
@@ -54,7 +54,7 @@ async function initialize(state: IPreviewState) {
 	const js = massageJs(state.js);
 
 	try {
-		eval(js);
+		eval(js); // CodeQL [SM01632] This is safe because the runner runs in an isolated iframe. This feature is essential to the functionality of the playground. // CodeQL [SM02688] This is safe because the runner runs in an isolated iframe. This feature is essential to the functionality of the playground.
 	} catch (err) {
 		const pre = document.createElement("pre");
 		pre.appendChild(

+ 6 - 8
website/src/website/pages/home/Home.tsx

@@ -172,10 +172,9 @@ class EditorDemo extends React.Component {
 						<div>
 							<h2>IntelliSense, Validation</h2>
 							<p>
-								Paragraph of text beneath the heading to explain
-								the heading. We'll add onto it with another
-								sentence and probably just keep going until we
-								run out of words.
+								Get completions and errors directly in the
+								browser for supported languages. Or write your
+								own completion providers in JavaScript.
 							</p>
 						</div>
 					</div>
@@ -184,10 +183,9 @@ class EditorDemo extends React.Component {
 						<div>
 							<h2>Basic Syntax Colorization</h2>
 							<p>
-								Paragraph of text beneath the heading to explain
-								the heading. We'll add onto it with another
-								sentence and probably just keep going until we
-								run out of words.
+								Colorize code using our pre-built syntax
+								highlighting, or configure your own custom
+								colorization.
 							</p>
 						</div>
 					</div>

+ 14 - 12
website/src/website/pages/playground/PlaygroundPageContent.tsx

@@ -1,24 +1,24 @@
 import { autorun } from "mobx";
 import { observer } from "mobx-react";
 import * as React from "react";
+import { ButtonGroup, FormCheck } from "react-bootstrap";
 import { getLoadedMonaco } from "../../../monaco-loader";
-import { IPlaygroundProject, IPreviewState } from "../../../shared";
 import { Page } from "../../components/Page";
 import { Select } from "../../components/Select";
+import { Button, Col, Row, Stack } from "../../components/bootstrap";
 import {
 	MonacoEditor,
 	MonacoEditorHeight,
 } from "../../components/monaco/MonacoEditor";
 import { withLoadedMonaco } from "../../components/monaco/MonacoLoader";
+import { monacoEditorVersion } from "../../monacoEditorVersion";
 import { hotComponent } from "../../utils/hotComponent";
 import { IReference, ref } from "../../utils/ref";
-import { getNpmVersionsSync } from "./getNpmVersionsSync";
-import { getPlaygroundExamples, PlaygroundExample } from "./playgroundExamples";
 import { PlaygroundModel } from "./PlaygroundModel";
 import { Preview } from "./Preview";
 import { SettingsDialog } from "./SettingsDialog";
-import { Button, Col, Row, Stack } from "../../components/bootstrap";
-import { ButtonGroup, FormCheck } from "react-bootstrap";
+import { getNpmVersionsSync } from "./getNpmVersionsSync";
+import { PlaygroundExample, getPlaygroundExamples } from "./playgroundExamples";
 
 @hotComponent(module)
 @observer
@@ -258,13 +258,15 @@ export class VersionSelector extends React.Component<{
 				<Select
 					values={versions}
 					getLabel={(i) =>
-						`${i}${
-							{
-								["undefined"]: "",
-								["true"]: " ✓",
-								["false"]: " ✗",
-							}["" + model.bisectModel.getState(i)]
-						}`
+						i === latestValue
+							? `latest stable (${monacoEditorVersion})`
+							: `${i}${
+									{
+										["undefined"]: "",
+										["true"]: " ✓",
+										["false"]: " ✗",
+									}["" + model.bisectModel.getState(i)]
+							  }`
 					}
 					value={{
 						get() {

+ 1 - 1
website/static/monarch/monarch.js

@@ -58,7 +58,7 @@ function createLangModel(languageId, text) {
 	var update = function () {
 		var def = null;
 		try {
-			def = eval("(function(){ " + langModel.getValue() + "; })()");
+			def = eval("(function(){ " + langModel.getValue() + "; })()"); // CodeQL [SM01632] langModel.getValue() is a default value with volatile user modifications. This is an essential functionality for the monarch playground and safe, as no injection is possible.
 		} catch (err) {
 			setInnerText(outputPane, err + "\n");
 			return;