chore: upgrade monaco-editor@0.54.0#223
Open
liuxy0551 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
简介
依赖的 monaco-editor 版本从 0.52.2 升级到 0.54.0
按 commit 查看,chore commit 中的改动原因:
目的:解决 Monaco 0.54.0 模块加载顺序变化导致 self.monaco 未定义的问题。
0.52.2 时,这个文件直接返回 self.monaco,因为 Monaco 在所有语言插件加载前就已经挂载到全局。0.54.0 改变了内部模块拆分方式,语言插件可能在 Monaco 挂载到全局之前就加载了。改用 Proxy
后,属性访问会被延迟到实际使用时才解析,避开加载顺序问题。
目的:适配 Monaco 0.54.0 的导出格式变化。
0.52.2 中 editor.main 直接导出 Monaco API 对象,0.54.0 改为通过 exports.m 导出。api.m || api 这个兼容写法确保两种格式都能正确获取到 Monaco 实例并挂载到 global.monaco。
目的:为 Monaco 0.54.0 新增的浏览器 API 依赖提供 Node.js 环境下的 polyfill。
Monaco 0.54.0 内部开始使用更多浏览器原生 API,而测试运行在 Node.js 中没有这些 API,需要手动模拟:
crypto.randomUUID/getRandomValuesdocument.baseURIURL构造函数CSS.supports/CSS.escapewindow.addEventListenerContextKeyService监听 DOM 事件这些在 0.52.2 中都不需要,是 0.54.0 新引入的依赖。