From 7d2065d55d45b6a590366f05347ba06c4e244847 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 5 May 2022 15:48:53 +0200 Subject: [PATCH 01/70] Add initial mdx language --- src/basic-languages/mdx/mdx.contribution.ts | 24 ++++++++ src/basic-languages/mdx/mdx.test.ts | 8 +++ src/basic-languages/mdx/mdx.ts | 65 +++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 src/basic-languages/mdx/mdx.contribution.ts create mode 100644 src/basic-languages/mdx/mdx.test.ts create mode 100644 src/basic-languages/mdx/mdx.ts diff --git a/src/basic-languages/mdx/mdx.contribution.ts b/src/basic-languages/mdx/mdx.contribution.ts new file mode 100644 index 0000000000..c435bfcf3d --- /dev/null +++ b/src/basic-languages/mdx/mdx.contribution.ts @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { registerLanguage } from '../_.contribution'; + +declare var AMD: any; +declare var require: any; + +registerLanguage({ + id: 'mdx', + extensions: ['.mdx'], + aliases: ['MDX', 'mdx'], + loader: () => { + if (AMD) { + return new Promise((resolve, reject) => { + require(['vs/basic-languages/mdx/mdx'], resolve, reject); + }); + } else { + return import('./mdx'); + } + } +}); diff --git a/src/basic-languages/mdx/mdx.test.ts b/src/basic-languages/mdx/mdx.test.ts new file mode 100644 index 0000000000..7e64f0a242 --- /dev/null +++ b/src/basic-languages/mdx/mdx.test.ts @@ -0,0 +1,8 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { testTokenization } from '../test/testRunner'; + +testTokenization('mdx', []); diff --git a/src/basic-languages/mdx/mdx.ts b/src/basic-languages/mdx/mdx.ts new file mode 100644 index 0000000000..d87e5244c4 --- /dev/null +++ b/src/basic-languages/mdx/mdx.ts @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import type { languages } from '../../fillers/monaco-editor-core'; + +export const conf: languages.LanguageConfiguration = { + comments: { + blockComment: ['{/*', '*/}'] + } +}; + +export const language = { + defaultToken: '', + tokenPostfix: '.mdx', + escapes: /\\(?:["'\\abfnrtv]|x[\dA-Fa-f]{1,4}|u[\dA-Fa-f]{4}|U[\dA-Fa-f]{8})/, + bracket_open: ['{'], + single_quote: ["'"], + double_quote: ['"'], + tokenizer: { + root: [ + [/^\s*import/, { token: 'keyword', next: '@import', nextEmbedded: 'js' }], + [/<\w+/, { token: 'keyword', next: '@jsx' }], + [/<\/?\w+>/, { token: 'keyword' }], + [/\*\*.+\*\*/, 'strong'], + [/{/, { token: 'delimiter.bracket', nextEmbedded: 'js' }], + { include: 'expression' } + ], + import: [[/'\s*(;|$)/, { token: 'string', next: '@pop', nextEmbedded: '@pop' }]], + expression: [[/}/, { token: 'delimiter.bracket', nextEmbedded: '@pop' }]], + jsx: [ + [/\w+=/, { token: 'delimiter.bracket', next: '@jsx_expression' }], + [/\/?>/, { token: 'keyword', next: '@pop' }] + ], + jsx_expression: [ + [ + /["'{]/, + { + cases: { + '@bracket_open': { + token: 'delimiter.bracket', + next: '@expression', + nextEmbedded: 'js' + }, + '@double_quote': { token: 'string', next: '@string_double' }, + '@single_quote': { token: 'string', next: '@string_single' } + } + } + ] + ], + string_double: [ + [/[^"\\]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, 'string', '@pop'] + ], + string_single: [ + [/[^'\\]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/'/, 'string', '@pop'] + ] + } +}; From e87ef8ef11b6df9f8c1b70db72cf52db65ca1859 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 6 May 2022 18:25:31 +0200 Subject: [PATCH 02/70] Update mdx language definition --- src/basic-languages/mdx/mdx.ts | 129 +++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 38 deletions(-) diff --git a/src/basic-languages/mdx/mdx.ts b/src/basic-languages/mdx/mdx.ts index d87e5244c4..d0c9ea70e5 100644 --- a/src/basic-languages/mdx/mdx.ts +++ b/src/basic-languages/mdx/mdx.ts @@ -8,58 +8,111 @@ import type { languages } from '../../fillers/monaco-editor-core'; export const conf: languages.LanguageConfiguration = { comments: { blockComment: ['{/*', '*/}'] - } + }, + brackets: [['{', '}']] }; export const language = { defaultToken: '', tokenPostfix: '.mdx', - escapes: /\\(?:["'\\abfnrtv]|x[\dA-Fa-f]{1,4}|u[\dA-Fa-f]{4}|U[\dA-Fa-f]{8})/, - bracket_open: ['{'], - single_quote: ["'"], - double_quote: ['"'], + control: /[!#()*+.[\\\]_`{}\-]/, + escapes: /\\@control/, + tokenizer: { root: [ + [/^---$/, { token: 'meta.content', next: '@frontmatter', nextEmbedded: 'yaml' }], + [/^\s{4}.*$/, { token: 'variable.source' }], [/^\s*import/, { token: 'keyword', next: '@import', nextEmbedded: 'js' }], - [/<\w+/, { token: 'keyword', next: '@jsx' }], - [/<\/?\w+>/, { token: 'keyword' }], - [/\*\*.+\*\*/, 'strong'], - [/{/, { token: 'delimiter.bracket', nextEmbedded: 'js' }], - { include: 'expression' } + [/^\s*export/, { token: 'keyword', next: '@export', nextEmbedded: 'js' }], + [/<\w+/, { token: 'type.identifier', next: '@jsx' }], + [/<\/?\w+>/, 'type.identifier'], + [ + /^(\s*)(>*\s*)(#{1,6}\s)/, + [{ token: 'white' }, { token: 'comment' }, { token: 'keyword', next: '@header' }] + ], + [/^(\s*)(>*\s*)([*+-])(\s+)/, ['white', 'comment', 'keyword', 'white']], + [/^(\s*)(>*\s*)(\d{1,9}\.)(\s+)/, ['white', 'comment', 'number', 'white']], + [/^(\s*)(>*\s*)(\d{1,9}\.)(\s+)/, ['white', 'comment', 'number', 'white']], + [/^(\s*)(>*\s*)(-{3,}|\*{3,}|_{3,})$/, ['white', 'comment', 'keyword']], + [/`{3,}(\s.*)?$/, { token: 'string', next: '@codeblock_backtick' }], + [/~{3,}(\s.*)?$/, { token: 'string', next: '@codeblock_tilde' }], + [ + /`{3,}(\S+).*$/, + { token: 'string', next: '@codeblock_highlight_backtick', nextEmbedded: '$1' } + ], + [ + /~{3,}(\S+).*$/, + { token: 'string', next: '@codeblock_highlight_tilde', nextEmbedded: '$1' } + ], + [/^(\s*)(-{4,})$/, ['white', 'comment']], + [/^(\s*)(>+)/, ['white', 'comment']], + { include: 'content' } + ], + content: [ + [ + /(\[)(.+)(]\()(.+)(\s+".*")(\))/, + ['', 'string.link', '', 'type.identifier', 'string.link', ''] + ], + [/(\[)(.+)(]\()(.+)(\))/, ['', 'type.identifier', '', 'string.link', '']], + [/(\[)(.+)(]\[)(.+)(])/, ['', 'type.identifier', '', 'type.identifier', '']], + [/(\[)(.+)(]:\s+)(\S*)/, ['', 'type.identifier', '', 'string.link']], + [/(\[)(.+)(])/, ['', 'type.identifier', '']], + [/`.*`/, 'variable.source'], + [/_/, { token: 'emphasis', next: '@emphasis_underscore' }], + [/\*(?!\*)/, { token: 'emphasis', next: '@emphasis_asterisk' }], + [/\*\*/, { token: 'strong', next: '@strong' }], + [/{/, { token: 'delimiter.bracket', next: '@expression', nextEmbedded: 'js' }] ], import: [[/'\s*(;|$)/, { token: 'string', next: '@pop', nextEmbedded: '@pop' }]], - expression: [[/}/, { token: 'delimiter.bracket', nextEmbedded: '@pop' }]], + expression: [ + [/{/, { token: 'delimiter.bracket', next: '@expression' }], + [/}/, { token: 'delimiter.bracket', next: '@pop', nextEmbedded: '@pop' }] + ], + export: [[/^\s*$/, { token: 'delimiter.bracket', next: '@pop', nextEmbedded: '@pop' }]], jsx: [ - [/\w+=/, { token: 'delimiter.bracket', next: '@jsx_expression' }], - [/\/?>/, { token: 'keyword', next: '@pop' }] + [/\s+/, ''], + [/(\w+)(=)("(?:[^"\\]|\\.)*")/, ['attribute.name', 'operator', 'string']], + [/(\w+)(=)('(?:[^'\\]|\\.)*')/, ['attribute.name', 'operator', 'string']], + [/(\w+(?=\s|>|={|$))/, ['attribute.name']], + [/={/, { token: 'delimiter.bracket', next: '@expression', nextEmbedded: 'js' }], + [/>/, { token: 'type.identifier', next: '@pop' }] ], - jsx_expression: [ - [ - /["'{]/, - { - cases: { - '@bracket_open': { - token: 'delimiter.bracket', - next: '@expression', - nextEmbedded: 'js' - }, - '@double_quote': { token: 'string', next: '@string_double' }, - '@single_quote': { token: 'string', next: '@string_single' } - } - } - ] + header: [ + [/.$/, { token: 'keyword', next: '@pop' }], + { include: 'content' }, + [/./, { token: 'keyword' }] + ], + strong: [ + [/\*\*/, { token: 'strong', next: '@pop' }], + { include: 'content' }, + [/./, { token: 'strong' }] + ], + emphasis_underscore: [ + [/_/, { token: 'emphasis', next: '@pop' }], + { include: 'content' }, + [/./, { token: 'emphasis' }] + ], + emphasis_asterisk: [ + [/\*(?!\*)/, { token: 'emphasis', next: '@pop' }], + { include: 'content' }, + [/./, { token: 'emphasis' }] + ], + frontmatter: [[/^---$/, { token: 'meta.content', nextEmbedded: '@pop', next: '@pop' }]], + codeblock_highlight_backtick: [ + [/\s*`{3,}\s*$/, { token: 'string', next: '@pop', nextEmbedded: '@pop' }], + [/.*$/, 'variable.source'] + ], + codeblock_highlight_tilde: [ + [/\s*~{3,}\s*$/, { token: 'string', next: '@pop', nextEmbedded: '@pop' }], + [/.*$/, 'variable.source'] ], - string_double: [ - [/[^"\\]+/, 'string'], - [/@escapes/, 'string.escape'], - [/\\./, 'string.escape.invalid'], - [/"/, 'string', '@pop'] + codeblock_backtick: [ + [/\s*`{3,}\s*$/, { token: 'string', next: '@pop' }], + [/.*$/, 'variable.source'] ], - string_single: [ - [/[^'\\]+/, 'string'], - [/@escapes/, 'string.escape'], - [/\\./, 'string.escape.invalid'], - [/'/, 'string', '@pop'] + codeblock_tilde: [ + [/\s*~{3,}\s*$/, { token: 'string', next: '@pop' }], + [/.*$/, 'variable.source'] ] } }; From 5e5600bd44e2bdc81c39c02f6ee13251745188bc Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 12 May 2022 10:47:28 +0200 Subject: [PATCH 03/70] Register mdx contribution --- src/basic-languages/monaco.contribution.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic-languages/monaco.contribution.ts b/src/basic-languages/monaco.contribution.ts index 56b078c1de..f27a3f0cd4 100644 --- a/src/basic-languages/monaco.contribution.ts +++ b/src/basic-languages/monaco.contribution.ts @@ -38,6 +38,7 @@ import './lua/lua.contribution'; import './liquid/liquid.contribution'; import './m3/m3.contribution'; import './markdown/markdown.contribution'; +import './mdx/mdx.contribution'; import './mips/mips.contribution'; import './msdax/msdax.contribution'; import './mysql/mysql.contribution'; From 9e1bd604de5f8a795561f28e335b5cfc2e81fa42 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 12 May 2022 10:57:05 +0200 Subject: [PATCH 04/70] Add website mdx sample --- website/index/samples/sample.mdx.txt | 92 ++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 website/index/samples/sample.mdx.txt diff --git a/website/index/samples/sample.mdx.txt b/website/index/samples/sample.mdx.txt new file mode 100644 index 0000000000..295a0c2821 --- /dev/null +++ b/website/index/samples/sample.mdx.txt @@ -0,0 +1,92 @@ +--- +frontmatter: data +yaml: true +--- + +[link](https://example.com) + +~~~ +aasd +asd +asd +~~~ + +# Hello MDX {1+2} + +import { MyComponent } from './MyComponent' + +This is **bold {'foo' + 1} text** + +This is _emphasis {'foo' + 1} text_ + +This is *emphasis {'foo' + 1} text too* + + This is an indented *code* block + +export function foo() { + console.log('asd', 1) + if(true) { + return 'yep' + } + return 'nope' +} + + +This is regular content + +- this is a list + +* this is also a list + ++ me too! + +1. pizza +2. fries +3. ice cream + +---- + +_________ + +***\ +~~~css +body { + color: red; +} +~~~ + +> - this is a list +> +> * this is also a list +> +> + me too! +> +> 1. pizza +> 2. fries +> 3. ice cream +> +> --- +> +> _________ +> +> *** +> +> ```css +> body { +> color: red; +> } +> ``` + +> This is a blockquote +> +>> This is a nested {'blockquote'} + +{'foo' + 1 + 2 + {} + 12} + +{/* this is a comment */} + + + + This is **also** markdown. + + From ce7f3259c1d4e001b82fbc74324872839a664c9f Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 12 May 2022 10:57:13 +0200 Subject: [PATCH 05/70] Document samples are needed when adding a language --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cb9019f2bd..8e49114b86 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,6 +19,7 @@ Please understand that we only bundle languages with the monaco editor that have - create `$/src/basic-languages/{myLang}/{myLang}.ts` - create `$/src/basic-languages/{myLang}/{myLang}.test.ts` - edit `$/src/basic-languages/monaco.contribution.ts` and register your new language +- create `$/website/index/samples/sample.{myLang}.txt` ```js import './{myLang}/{myLang}.contribution'; From 92a1dad12d5e76a661ebd0b3ea25201bb03f8546 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 13 May 2022 16:31:24 +0200 Subject: [PATCH 06/70] Remove mdx indented code blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They aren’t supported. --- src/basic-languages/mdx/mdx.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/basic-languages/mdx/mdx.ts b/src/basic-languages/mdx/mdx.ts index d0c9ea70e5..890befb795 100644 --- a/src/basic-languages/mdx/mdx.ts +++ b/src/basic-languages/mdx/mdx.ts @@ -21,7 +21,6 @@ export const language = { tokenizer: { root: [ [/^---$/, { token: 'meta.content', next: '@frontmatter', nextEmbedded: 'yaml' }], - [/^\s{4}.*$/, { token: 'variable.source' }], [/^\s*import/, { token: 'keyword', next: '@import', nextEmbedded: 'js' }], [/^\s*export/, { token: 'keyword', next: '@export', nextEmbedded: 'js' }], [/<\w+/, { token: 'type.identifier', next: '@jsx' }], From 7755d67b8baebab3da2524ddd90f2dd60589fce4 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 13 May 2022 16:32:48 +0200 Subject: [PATCH 07/70] Configure auto closing pairs and on enter rules --- src/basic-languages/mdx/mdx.ts | 48 ++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/basic-languages/mdx/mdx.ts b/src/basic-languages/mdx/mdx.ts index 890befb795..5d1d86b0bc 100644 --- a/src/basic-languages/mdx/mdx.ts +++ b/src/basic-languages/mdx/mdx.ts @@ -3,13 +3,57 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { languages } from '../../fillers/monaco-editor-core'; +import { languages } from '../../fillers/monaco-editor-core'; export const conf: languages.LanguageConfiguration = { comments: { blockComment: ['{/*', '*/}'] }, - brackets: [['{', '}']] + brackets: [['{', '}']], + autoClosingPairs: [ + { open: '"', close: '"' }, + { open: "'", close: "'" }, + { open: '“', close: '”' }, + { open: '‘', close: '’' }, + { open: '`', close: '`' }, + { open: '{', close: '}' }, + { open: '_', close: '_' }, + { open: '**', close: '**' } + ], + onEnterRules: [ + { + beforeText: /^\s*- .+/, + action: { indentAction: languages.IndentAction.None, appendText: '- ' } + }, + { + beforeText: /^\s*\+ .+/, + action: { indentAction: languages.IndentAction.None, appendText: '+ ' } + }, + { + beforeText: /^\s*\* .+/, + action: { indentAction: languages.IndentAction.None, appendText: '* ' } + }, + { + beforeText: /^> /, + action: { indentAction: languages.IndentAction.None, appendText: '> ' } + }, + { + beforeText: /<\w+/, + action: { indentAction: languages.IndentAction.Indent } + }, + { + beforeText: /\s+>\s*$/, + action: { indentAction: languages.IndentAction.Indent } + }, + { + beforeText: /<\/\w+>/, + action: { indentAction: languages.IndentAction.Outdent } + }, + ...Array.from({ length: 100 }, (_, index) => ({ + beforeText: new RegExp(`^${index}\\. .+`), + action: { indentAction: languages.IndentAction.None, appendText: `${index + 1}. ` } + })) + ] }; export const language = { From dbf74268d3524d8eacd675713db202e746265f0f Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 22 Jul 2022 11:06:21 +0200 Subject: [PATCH 08/70] Add < > to auto closing pairs They represent JSX elements. --- src/basic-languages/mdx/mdx.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic-languages/mdx/mdx.ts b/src/basic-languages/mdx/mdx.ts index 5d1d86b0bc..388ddc44e8 100644 --- a/src/basic-languages/mdx/mdx.ts +++ b/src/basic-languages/mdx/mdx.ts @@ -18,7 +18,8 @@ export const conf: languages.LanguageConfiguration = { { open: '`', close: '`' }, { open: '{', close: '}' }, { open: '_', close: '_' }, - { open: '**', close: '**' } + { open: '**', close: '**' }, + { open: '<', close: '>' } ], onEnterRules: [ { From d4ea5f53f1f5041c3009f0bce2fafc476572eb74 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 22 Jul 2022 11:07:26 +0200 Subject: [PATCH 09/70] Mark ( ) as auto closing pair in MDX This is nice for writing content. --- src/basic-languages/mdx/mdx.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic-languages/mdx/mdx.ts b/src/basic-languages/mdx/mdx.ts index 388ddc44e8..dfbc01e820 100644 --- a/src/basic-languages/mdx/mdx.ts +++ b/src/basic-languages/mdx/mdx.ts @@ -17,6 +17,7 @@ export const conf: languages.LanguageConfiguration = { { open: '‘', close: '’' }, { open: '`', close: '`' }, { open: '{', close: '}' }, + { open: '(', close: ')' }, { open: '_', close: '_' }, { open: '**', close: '**' }, { open: '<', close: '>' } From 68b964addf685716a3b3ee2374b30e432c5ccd27 Mon Sep 17 00:00:00 2001 From: "BECKHOFF\\PhilippLe" Date: Thu, 15 Sep 2022 15:49:35 +0200 Subject: [PATCH 10/70] add twincat file support for st --- src/basic-languages/st/st.contribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic-languages/st/st.contribution.ts b/src/basic-languages/st/st.contribution.ts index e94b9b6788..b6811c7a32 100644 --- a/src/basic-languages/st/st.contribution.ts +++ b/src/basic-languages/st/st.contribution.ts @@ -10,7 +10,7 @@ declare var require: any; registerLanguage({ id: 'st', - extensions: ['.st', '.iecst', '.iecplc', '.lc3lib'], + extensions: ['.st', '.iecst', '.iecplc', '.lc3lib', '.TcPOU', '.TcDUT', '.TcGVL', '.TcIO'], aliases: ['StructuredText', 'scl', 'stl'], loader: () => { if (AMD) { From b3883c13affc4de0e9bcd500c4ea3a8fa6e3b549 Mon Sep 17 00:00:00 2001 From: "BECKHOFF\\PhilippLe" Date: Thu, 15 Sep 2022 15:50:49 +0200 Subject: [PATCH 11/70] add implements keyword --- src/basic-languages/st/st.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic-languages/st/st.ts b/src/basic-languages/st/st.ts index fe76f2f193..4ddfdfb739 100644 --- a/src/basic-languages/st/st.ts +++ b/src/basic-languages/st/st.ts @@ -172,7 +172,8 @@ export const language = { 'vendor', 'common_source', 'from', - 'extends' + 'extends', + 'implements' ], constant: ['false', 'true', 'null'], From 681b38140f1a659b7c75a72ea1df65162a19a767 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Thu, 5 Jan 2023 16:46:14 +0100 Subject: [PATCH 12/70] Export custom TypeScript worker variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A custom TypeScript worker factory function gets passed `TypeScriptWorker`, `ts`, and `libFileMap`. It also exports `create` using ESM. However, this can’t be used, because the custom worker factory is only called if a custom worker path is defined. Exposing these members, means a worker can be defined using ESM. --- src/language/typescript/ts.worker.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/language/typescript/ts.worker.ts b/src/language/typescript/ts.worker.ts index f03e32d1b2..d654d679b6 100644 --- a/src/language/typescript/ts.worker.ts +++ b/src/language/typescript/ts.worker.ts @@ -3,15 +3,17 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as edworker from 'monaco-editor-core/esm/vs/editor/editor.worker'; -import { ICreateData, create } from './tsWorker'; +import { initialize } from 'monaco-editor-core/esm/vs/editor/editor.worker'; +import * as ts from './lib/typescriptServices'; +import { ICreateData, TypeScriptWorker, create } from './tsWorker'; import { worker } from '../../fillers/monaco-editor-core'; +import { libFileMap } from './lib/lib'; self.onmessage = () => { // ignore the first message - edworker.initialize((ctx: worker.IWorkerContext, createData: ICreateData) => { + initialize((ctx: worker.IWorkerContext, createData: ICreateData) => { return create(ctx, createData); }); }; -export { create } from './tsWorker'; +export { TypeScriptWorker, create, initialize, libFileMap, ts }; From fb47a0f545b1e28a739cdb37e8156f4b41ee1a76 Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 4 Apr 2023 10:13:10 -0400 Subject: [PATCH 13/70] Avoid a hack in the WGSL lexer This is a non-functioal change. The current rule for delimiters was silly: it should have been a character class range (e.g. [ ... ]). Move delimiter handling into the symbols matcher. --- src/basic-languages/wgsl/wgsl.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/basic-languages/wgsl/wgsl.ts b/src/basic-languages/wgsl/wgsl.ts index 1ed58809fa..ab3a48222b 100644 --- a/src/basic-languages/wgsl/wgsl.ts +++ b/src/basic-languages/wgsl/wgsl.ts @@ -377,7 +377,7 @@ export const language = { predeclared_intrinsics, operators, - symbols: /[!%&*+\-\.\/:;<=>^|_~]+/, + symbols: /[!%&*+\-\.\/:;<=>^|_~,]+/, tokenizer: { root: [ @@ -402,8 +402,6 @@ export const language = { { include: '@commentOrSpace' }, { include: '@numbers' }, - [/;:\./, 'delimiter'], - [/,/, 'delimiter'], // Hack: Should be in previous rule [/[{}()\[\]]/, '@brackets'], ['@', 'annotation', '@attribute'], [ From e3b1a47554b8ec6282f02d0d537cf7e1777e8983 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Thu, 6 Apr 2023 16:30:30 +0200 Subject: [PATCH 14/70] Playground improvements --- .../website/pages/playground/PlaygroundModel.ts | 2 +- .../pages/playground/PlaygroundPageContent.tsx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/website/src/website/pages/playground/PlaygroundModel.ts b/website/src/website/pages/playground/PlaygroundModel.ts index d94a99883a..7cb6cbf0d3 100644 --- a/website/src/website/pages/playground/PlaygroundModel.ts +++ b/website/src/website/pages/playground/PlaygroundModel.ts @@ -140,7 +140,7 @@ export class PlaygroundModel { } } - private readonly debouncer = new Debouncer(250); + private readonly debouncer = new Debouncer(700); @observable public isDirty = false; diff --git a/website/src/website/pages/playground/PlaygroundPageContent.tsx b/website/src/website/pages/playground/PlaygroundPageContent.tsx index e93c0d4a3b..3c1039d570 100644 --- a/website/src/website/pages/playground/PlaygroundPageContent.tsx +++ b/website/src/website/pages/playground/PlaygroundPageContent.tsx @@ -133,10 +133,16 @@ export class PlaygroundPageContent extends React.Component< checked={ model.settings.autoReload } - onChange={(e) => - (model.settings.autoReload = - e.target.checked) - } + onChange={(e) => { + model.settings.autoReload = + e.target.checked; + if ( + e.target.checked && + model.isDirty + ) { + model.reload(); + } + }} /> )}