Skip to content

Commit

Permalink
chore(deps-dev): bump monaco-editor from 0.49.0 to 0.50.0 (#171)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: yosuke ota <[email protected]>
  • Loading branch information
dependabot[bot] and ota-meshi authored Jun 23, 2024
1 parent ddc9f22 commit 87a91d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
32 changes: 29 additions & 3 deletions docs/.vitepress/theme/components/monaco/monaco-loader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,32 @@ async function setupMonaco() {
}
}

function appendMonacoEditorScript() {
return new Promise((resolve) => {
async function appendMonacoEditorScript() {
let error = new Error()
const urlList = [
`https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/${MONACO_EDITOR_VERSION}/min/vs/loader.min.js`,
`https://cdn.jsdelivr.net/npm/monaco-editor@${MONACO_EDITOR_VERSION}/dev/vs/loader.min.js`,
`https://unpkg.com/monaco-editor/${MONACO_EDITOR_VERSION}/min/vs/loader.min.js`,
"https://cdn.jsdelivr.net/npm/monaco-editor/dev/vs/loader.min.js",
"https://unpkg.com/monaco-editor@latest/min/vs/loader.js",
]
for (const url of urlList) {
try {
return await appendScript(url)
} catch (e) {
// eslint-disable-next-line no-console -- OK
console.warn(`Failed to retrieve resource from ${url}`)
error = e
}
}
throw error
}

/** Appends a script tag. */
function appendScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement("script")
script.src = `https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/${MONACO_EDITOR_VERSION}/min/vs/loader.min.js`
script.src = src
script.onload = () => {
script.onload = null

Expand All @@ -36,6 +58,10 @@ function appendMonacoEditorScript() {
setTimeout(watch, 200)
}
}
script.onerror = (e) => {
reject(e)
document.head.removeChild(script)
}
document.head.append(script)
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"globals": "^15.0.0",
"jsdom": "^24.0.0",
"mocha": "^10.0.0",
"monaco-editor": "^0.49.0",
"monaco-editor": "^0.50.0",
"npm-run-all": "^4.1.5",
"nyc": "^17.0.0",
"opener": "^1.5.1",
Expand Down

0 comments on commit 87a91d7

Please sign in to comment.