From e803010fe28b849220f0dd5b35e16abb4584667e Mon Sep 17 00:00:00 2001
From: memdmp <memdmp@estrogen.zone>
Date: Mon, 24 Feb 2025 06:06:42 +0100
Subject: feat: at the expense of us carrying the entire ts base type defs in
 the repo, and hating the code, the ts shit all fits in <5MB .js files

---
 src/routes/Monaco.svelte | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

(limited to 'src/routes/Monaco.svelte')

diff --git a/src/routes/Monaco.svelte b/src/routes/Monaco.svelte
index cfe9767..295b432 100644
--- a/src/routes/Monaco.svelte
+++ b/src/routes/Monaco.svelte
@@ -1,11 +1,11 @@
 <script lang="ts">
   import type monaco from 'monaco-editor';
   import { onDestroy, onMount } from 'svelte';
-  // import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
+  import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
   // import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
   // import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
   // import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
-  // import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
+  import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
   // @ts-ignore
   import wrqTypes from '@types/webextension-polyfill/namespaces/webRequest.d.ts?raw';
   // @ts-ignore
@@ -52,14 +52,9 @@ declare global {
         //   return new htmlWorker();
         // }
         if (label === 'typescript' || label === 'javascript') {
-          return await (
-            await import('./ts-worker')
-          ).default;
+          return new tsWorker();
         }
-        // return new editorWorker();
-        return new (
-          await import('monaco-editor/esm/vs/editor/editor.worker?worker')
-        ).default();
+        return new editorWorker();
       },
     };
 
@@ -89,6 +84,14 @@ declare global {
       },
     });
     if (!divEl) while (!divEl) await new Promise((rs) => setTimeout(rs, 100));
+    for (const [_filename, contents] of Object.entries(
+      (await import('./filemap.js')).default
+    )) {
+      Monaco.languages.typescript.typescriptDefaults.addExtraLib(
+        contents
+        // ,_filename
+      );
+    }
     Monaco.languages.typescript.typescriptDefaults.addExtraLib(
       evTypes,
       'node_modules/@types/webextension-polyfill/namespaces/events.d.ts'
-- 
cgit v1.2.3

