diff --git a/app/web/src/nova/ed/panel/popup/script/monaco.tsx b/app/web/src/nova/ed/panel/popup/script/monaco.tsx index 44de02af..253a57af 100644 --- a/app/web/src/nova/ed/panel/popup/script/monaco.tsx +++ b/app/web/src/nova/ed/panel/popup/script/monaco.tsx @@ -28,7 +28,6 @@ const w = window as unknown as { monaco_loaded: boolean; }; -const encode = new TextEncoder(); export type MonacoEditor = Parameters[0]; export const EdScriptMonaco: FC<{}> = () => { const p = useGlobal(EDGlobal, "EDITOR"); @@ -58,7 +57,6 @@ export const EdScriptMonaco: FC<{}> = () => { useEffect(() => { if (!w.monaco_loaded) { w.monaco_loaded = true; - // setTimeout(console.clear, 500); } return () => { @@ -345,7 +343,7 @@ export const EdScriptMonaco: FC<{}> = () => { p.ui.popup.script.typings.status = "error"; p.ui.popup.script.typings.err_msg = code_result; } else if (typeof code_result === "object") { - scope = code_result; + scope = await code_result; } } else { editorLocalValue[active.item_id] = null; @@ -356,7 +354,7 @@ export const EdScriptMonaco: FC<{}> = () => { p.ui.popup.script.typings.status = "error"; p.ui.popup.script.typings.err_msg = code_result; } else if (typeof code_result === "object") { - scope = code_result; + scope = (await code_result) as any; } } else { const meta = getMetaById(p, active.item_id); @@ -387,6 +385,8 @@ export const EdScriptMonaco: FC<{}> = () => { scriptEdit.timeout = setTimeout(applyChanges, 1000); }} onMount={async (editor, monaco) => { + monaco.languages.register({ id: "typescript" }); + local.monaco = monaco; local.editor = editor; local.render(); diff --git a/app/web/src/utils/script/mount.tsx b/app/web/src/utils/script/mount.tsx index 40567d1c..fe806d5c 100644 --- a/app/web/src/utils/script/mount.tsx +++ b/app/web/src/utils/script/mount.tsx @@ -40,7 +40,9 @@ export const jsMount = async (editor: MonacoEditor, monaco: Monaco, p?: PG) => { } const compilerOptions: CompilerOptions = { - jsx: monaco.languages.typescript.JsxEmit.ReactJSX, + // note: ReactJSX ga bisa solve type buat
etc... + // yg bisa solve cmn JsxEmit.React + jsx: monaco.languages.typescript.JsxEmit.React, target: monaco.languages.typescript.ScriptTarget.ES2015, allowNonTsExtensions: true, lib: ["esnext", "dom"], diff --git a/app/web/src/utils/script/typings.ts b/app/web/src/utils/script/typings.ts index 6fb25b78..80e8a549 100644 --- a/app/web/src/utils/script/typings.ts +++ b/app/web/src/utils/script/typings.ts @@ -135,8 +135,8 @@ ${await loadText("https://cdn.jsdelivr.net/npm/@types/react@18.3.3/index.d.ts")} { filePath: "jsx-runtime.d.ts", content: `declare module "react/jsx-runtime" { -import * as React from "react"; -export { Fragment } from "react"; +import * as React from "./"; +export { Fragment } from "./"; export namespace JSX { type ElementType = React.JSX.ElementType; diff --git a/bun.lockb b/bun.lockb index 11fb70a5..aba236dd 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index a72ab7ca..7ea04830 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "pkgs/*" ], "dependencies": { + "@shikijs/core": "^1.12.1", "brotli-wasm": "^3.0.1", "fdir": "^6.1.0", "react-select": "^5.8.0",