TypeFox / monaco-languageclient

Repo hosts npm packages for monaco-languageclient, vscode-ws-jsonrpc, monaco-editor-wrapper, @typefox/monaco-editor-react and monaco-languageclient-examples
https://www.npmjs.com/package/monaco-languageclient
MIT License
992 stars 170 forks source link

monaco-vscode-editor-api is missing some files #655

Open xueerli opened 1 month ago

xueerli commented 1 month ago

Description

I upgraded from version 7 to 8 and used monaco-vscode-editor-api to replace monaco-editor-treemended as per the docs. But monaco-vscode-editor-api miss some files. e.g. metadata.js which is used by monaco-editor-webpack-plugin.

Before:

"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.16 <1.84.0",
"monaco-languageclient": "~7.2.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.16 <1.84.0",

Now:

"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@4.3.2",
"monaco-languageclient": "8.3.1",
"vscode": "npm:@codingame/monaco-vscode-api@4.3.2",

Here is a list of files for monaco-vscode-editor-api1 Here is a list of files for monaco-editor-treemended: 2

Expectation

Upgrade to v8 with minimal changes.

Thanks.

CGNonofr commented 1 month ago

As stated in the readme, the webpack plugin can't be used anymore

kaisalmen commented 1 month ago

@xueerli see here: https://github.com/CodinGame/monaco-vscode-api#if-you-use-webpack

xueerli commented 1 month ago

@kaisalmen thank you for your response. In addition to monaco-editor-webpack-plugin, there is no setLocale method in monaco-editor/esm/vs/nls . There is also no monaco-editor/esm/vs/platform/actions/common/actions to handle context menus.

CGNonofr commented 1 month ago

There is even no vs/nls file in the editor api, why are you trying to access it directly?

Exposed modules are whitelisted, and vs/platform/actions/common/actions is currently not part of it, what do you need it for?

xueerli commented 4 weeks ago

@CGNonofr I use vs/nls setLocale to set locale language. I use vs/platform/actions/common/actions to delete some actions. In previous versions of treemended, it was possible to import from monaco-editor.

CGNonofr commented 4 weeks ago

I'm not sure why you would want to call setLocale by hands?

You should be able to import vscode/vscode/XXX instead of monaco-editor/esm/XXX though

kaisalmen commented 4 weeks ago

@xueerli we even have a utility for loading locales available: https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/wrapper_statemachine.html#L18-L22

It must be loaded before anything else. Usage is demonstrate here: https://github.com/TypeFox/monaco-languageclient/blob/main/index.html#L41

xueerli commented 2 weeks ago

@CGNonofr I use ESM. Shouldn't I set Locale manually? I couldn't find a better way. Here's a related issue https://github.com/microsoft/monaco-editor/issues/1514.

CGNonofr commented 2 weeks ago

We are using our own localization mechanism here, inspired by what is used in VSCode, adpated to work in ESM (VScode is built into commonjs/umd and they inject the localization at runtime, which is not possible with ESM)

setLocale is an internal api and you're not supposed to call it by hands. you would need to give the localization content as parameter

xueerli commented 2 weeks ago

@CGNonofr @kaisalmen Thank you so much. Referring to your implementation, I'll try registerLocalization in vscode/l10n.

CGNonofr commented 2 weeks ago

Why don't you use what @kaisalmen suggested?