This was working until recently, don't think it is something I've done?
The following used to work to add some extra definitions to the function node:
window.monaco.languages.typescript.javascriptDefaults.addExtraLib(
typeDeclarations,
'file://types/uibuilder/uib-util.d.ts'
)
But as of v5.0.9, it no longer works.
It now looks as though it has moved to:
window.monaco.typescript.javascriptDefaults.addExtraLib
Can someone confirm if this is correct please?
If it is correct, it is really a Node-RED breaking change isn't it? At the very least, doing this now requires additional checks for the correct location.
The changelogs support your finding. Monaco lists the move from monaco.languages.typescript to monaco.typescript as a breaking change in 0.55.0. Node-RED's changelog records the update to Monaco 0.55.1 under 5.0.0-beta.3, rather than under 5.0.9. That points to the namespace change arriving during the 5.0 development cycle, not being newly introduced by the 5.0.9 maintenance release. Code using the old namespace needs to account for that upstream API change.
Yes, they removed the languages object.
Thanks both, I've had to add a test for which version is being used in order for it not to be broken in different versions of Node-RED.
For now though, anyone using v7 UIBUILDER with Node-RED v5.0.9 will not get the function node help for the uibuilder functions. The fix will be in v8.
Ooof! The type of thing you only come across when you're finally getting round to switching to nodered 5.x and updating your nodes to make them compatible.
Are there any other major changes that have been made to the Monaco implementation? One of the biggest workarounds I had to implement in an embedded code editor was a mechanism for instantiating a "Completely Clean" script editor that was untainted by Nodered (NodeRed specific library extensions) or browser functions (seeing as the intention is to run the script in a sandbox on the backend and not the ui). This could actually make a pretty good feature for context / library isolation that Nodered can support by default.
In the end this is what I came up with: EditorLanguageExtension
And then invoking it: CircuitBreakerFaultDetectorNode
It seems to be reasonably reliable, and allows building up contextual templates with targeted auto-completion based on context without tainting the global monaco javascript instance or vice versa.
This is more of a me too comment rather than I have a solution ...
I have the same issue trying to define a new language into the editor. I was using the MonacoAceTokenizer which now seems no longer to work or at least the steps I'm following no longer work. The reason for the Ace tokenizer is that the language I'm using is specified for ace editor (I assume).
Either way, that broken with the upgrade and I'm still investigating how to fix it but it's not prime time just yet. It doesn't help that the language I'm interested in is rather niche ...
The difficultly we have is that for us, monaco is a black box component we embed in the editor. As its is still pre-1.0 version, they ship breaking changes in minor releases - and, to be frank, unless it changes a behaviour in the core use of monaco, we're unlikely to spot a breaking change for users who are taking advantage of bits of monaco we don't use in core.
All that said, now it has been highlighted that there were breaking changes I was unaware of, we will be more careful in future updates to look for potential breaking changes. That will mean we won't be able to keep monaco as up to date if they introduce a change that is not appropriate for us to drop in a maintenance release of Node-RED.
/cc @Steve-Mcl