hawkerm / monaco-editor-uwp

A Windows Runtime Component wrapper around the web-based Monaco Editor.
MIT License
153 stars 36 forks source link

Upgrade to C# 8.0 and disable NRT during type generation #47

Closed hez2010 closed 3 years ago

hez2010 commented 4 years ago
hez2010 commented 3 years ago

WebView isn't compatible with monaco 0.23+, I'm closing this PR. I think monaco-editor-uwp needs to switch to WinUI 3.0. I played with WinUI 3.0 preview 4 last week but it seems that AddHostObjectToScript doesn't work currently.

hawkerm commented 3 years ago

Hey @hez2010 sorry I've been quiet on this for so long, been heads down at work. My plan is to investigate splitting apart the main generated parts to .NET so we can shim on top of different WebView/2 projections for different frameworks.

Is there an issue open on the Monaco repo about the broken Edge support? They don't call it out in their readme, only IE.

I know there's an open issue about AddHostObjectToScript, so I'm hoping that'll come soon, though I'd still want to support UWP for another year, so I think we may have to stay back on the Monaco version.

hez2010 commented 3 years ago

I've generated full bindings for monaco editor using TypedocConverter and applied some modifications to it, also implemented relevant methods for Uri, Token and etc.

https://gist.github.com/hez2010/3d3e493f8e434f1dc758438c4a2c9dab

Still needs some minor modifications if you want to use them in monaco-editor-uwp.

I think it's better to decouple monaco type bindings from MonacoEditorComponent and publish the type bindings itself as a dedicated package, otherwise you cannot expose a non-selaed class which is really annoying.

hawkerm commented 3 years ago

Hey @hez2010 sorry for the delay in getting back to this. Was finally trying to take a stab at it.

I did see there were come conflicts with the new type definitions since they changed ResolveCompletionItem. I do plan after the next update to start looking at splitting the Monaco API parts out to a .NET standard library instead of being part of the component somehow.

I was trying to re-generate the typings myself with your updates, but was running into this:

Warning: No compiler options set. This likely means that TypeDoc did not find your tsconfig.json. Generated documentation will probably be empty.
Warning: Unable to locate entry point: I:/code/monaco-editor-uwp/GenerateMonacoTypings/.temp/monaco.ts

It was still generating a json file, but it was mostly empty, and then the C# files weren't being generated. Any thoughts on what I may be missing?

Thanks!

hawkerm commented 3 years ago

Also hit an issue with trying to run test app with 0.22.3 on Win 10 19042.

image

Points to this place in editor.main.js:

ae.replace(/(\p{Ll})(\p{Lu})/gmu,"$1_$2").replace(/([^\b_])(\p{Lu})(\p{Ll})/gmu,"$1_$2$3").toLocaleLowerCase()

Tried reverting back to 21.3 instead and that seems to be working great so far.

hawkerm commented 3 years ago

I've got this PR integrated into my local copy of my #46 PR along with the updates to bring us up to compatibility with 0.21.3 of Monaco tested out with all the examples in the Sample app.

Would be nice to at least fix the type-generation script though so it can be run locally. Feel like there's been updates to TypeScript and typedoc which aren't playing nice with the current script's configuration?

hez2010 commented 3 years ago

Feel like there's been updates to TypeScript and typedoc which aren't playing nice with the current script's configuration

A tsconfig.json is needed to generate json from TypeScript. Also .d.ts in filename should be renamed to .ts.

hawkerm commented 3 years ago

Thanks @hez2010, do you have the one that you've been using locally? It'd be great if we can commit it, so we can just run npm install again.

hez2010 commented 3 years ago

Typedoc introduced a bug (https://github.com/TypeStrong/typedoc/issues/1637) recently which mis-interprets property delegates as method signatures. To workaround, typedoc version should be fixed at 0.20.* (TypeScript 3.9~4.2).

I'm working on a PR to make it work again.

hez2010 commented 3 years ago

Done. #57