This commit is contained in:
Rizky 2024-08-14 13:16:07 +07:00
parent 62efe7580f
commit 1ac457b38a
5 changed files with 10 additions and 7 deletions

View File

@ -28,7 +28,6 @@ const w = window as unknown as {
monaco_loaded: boolean; monaco_loaded: boolean;
}; };
const encode = new TextEncoder();
export type MonacoEditor = Parameters<OnMount>[0]; export type MonacoEditor = Parameters<OnMount>[0];
export const EdScriptMonaco: FC<{}> = () => { export const EdScriptMonaco: FC<{}> = () => {
const p = useGlobal(EDGlobal, "EDITOR"); const p = useGlobal(EDGlobal, "EDITOR");
@ -58,7 +57,6 @@ export const EdScriptMonaco: FC<{}> = () => {
useEffect(() => { useEffect(() => {
if (!w.monaco_loaded) { if (!w.monaco_loaded) {
w.monaco_loaded = true; w.monaco_loaded = true;
// setTimeout(console.clear, 500);
} }
return () => { return () => {
@ -345,7 +343,7 @@ export const EdScriptMonaco: FC<{}> = () => {
p.ui.popup.script.typings.status = "error"; p.ui.popup.script.typings.status = "error";
p.ui.popup.script.typings.err_msg = code_result; p.ui.popup.script.typings.err_msg = code_result;
} else if (typeof code_result === "object") { } else if (typeof code_result === "object") {
scope = code_result; scope = await code_result;
} }
} else { } else {
editorLocalValue[active.item_id] = null; 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.status = "error";
p.ui.popup.script.typings.err_msg = code_result; p.ui.popup.script.typings.err_msg = code_result;
} else if (typeof code_result === "object") { } else if (typeof code_result === "object") {
scope = code_result; scope = (await code_result) as any;
} }
} else { } else {
const meta = getMetaById(p, active.item_id); const meta = getMetaById(p, active.item_id);
@ -387,6 +385,8 @@ export const EdScriptMonaco: FC<{}> = () => {
scriptEdit.timeout = setTimeout(applyChanges, 1000); scriptEdit.timeout = setTimeout(applyChanges, 1000);
}} }}
onMount={async (editor, monaco) => { onMount={async (editor, monaco) => {
monaco.languages.register({ id: "typescript" });
local.monaco = monaco; local.monaco = monaco;
local.editor = editor; local.editor = editor;
local.render(); local.render();

View File

@ -40,7 +40,9 @@ export const jsMount = async (editor: MonacoEditor, monaco: Monaco, p?: PG) => {
} }
const compilerOptions: CompilerOptions = { const compilerOptions: CompilerOptions = {
jsx: monaco.languages.typescript.JsxEmit.ReactJSX, // note: ReactJSX ga bisa solve type buat <div> etc...
// yg bisa solve cmn JsxEmit.React
jsx: monaco.languages.typescript.JsxEmit.React,
target: monaco.languages.typescript.ScriptTarget.ES2015, target: monaco.languages.typescript.ScriptTarget.ES2015,
allowNonTsExtensions: true, allowNonTsExtensions: true,
lib: ["esnext", "dom"], lib: ["esnext", "dom"],

View File

@ -135,8 +135,8 @@ ${await loadText("https://cdn.jsdelivr.net/npm/@types/react@18.3.3/index.d.ts")}
{ {
filePath: "jsx-runtime.d.ts", filePath: "jsx-runtime.d.ts",
content: `declare module "react/jsx-runtime" { content: `declare module "react/jsx-runtime" {
import * as React from "react"; import * as React from "./";
export { Fragment } from "react"; export { Fragment } from "./";
export namespace JSX { export namespace JSX {
type ElementType = React.JSX.ElementType; type ElementType = React.JSX.ElementType;

BIN
bun.lockb

Binary file not shown.

View File

@ -19,6 +19,7 @@
"pkgs/*" "pkgs/*"
], ],
"dependencies": { "dependencies": {
"@shikijs/core": "^1.12.1",
"brotli-wasm": "^3.0.1", "brotli-wasm": "^3.0.1",
"fdir": "^6.1.0", "fdir": "^6.1.0",
"react-select": "^5.8.0", "react-select": "^5.8.0",