forked from bots-garden/ori
| ✨ Workspace panel, selectors, previews, desktop app, sandbox template, resizable file tree, light/dark theme | 1 | /** |
| 2 | * Bundles Monaco with the application instead of the default CDN loader, so | |
| 3 | * ori keeps working without internet access. Imported only by MonacoViewer, | |
| 4 | * which is itself lazy-loaded: none of this weight reaches the initial | |
| 5 | * bundle. | |
| 6 | */ | |
| 7 | ||
| 8 | import { loader } from "@monaco-editor/react"; | |
| 9 | import * as monaco from "monaco-editor"; | |
| 10 | import editorWorker from "monaco-editor/editor/editor.worker.js?worker"; | |
| 11 | import cssWorker from "monaco-editor/language/css/css.worker.js?worker"; | |
| 12 | import htmlWorker from "monaco-editor/language/html/html.worker.js?worker"; | |
| 13 | import jsonWorker from "monaco-editor/language/json/json.worker.js?worker"; | |
| 14 | import tsWorker from "monaco-editor/language/typescript/ts.worker.js?worker"; | |
| 15 | ||
| 16 | self.MonacoEnvironment = { | |
| 17 | getWorker(_workerId: string, label: string) { | |
| 18 | switch (label) { | |
| 19 | case "json": | |
| 20 | return new jsonWorker(); | |
| 21 | case "css": | |
| 22 | case "scss": | |
| 23 | case "less": | |
| 24 | return new cssWorker(); | |
| 25 | case "html": | |
| 26 | case "handlebars": | |
| 27 | case "razor": | |
| 28 | return new htmlWorker(); | |
| 29 | case "typescript": | |
| 30 | case "javascript": | |
| 31 | return new tsWorker(); | |
| 32 | default: | |
| 33 | return new editorWorker(); | |
| 34 | } | |
| 35 | }, | |
| 36 | }; | |
| 37 | ||
| 38 | loader.config({ monaco }); |