fix
This commit is contained in:
parent
cbab64c5ac
commit
8484a6a930
|
|
@ -19,6 +19,7 @@ import { EdPopPage } from "./panel/popup/page/page-popup";
|
|||
import { EdPopScript } from "./panel/popup/script/pop-script";
|
||||
import { EdPopSite } from "./panel/popup/site/site-popup";
|
||||
import { iconVSCode } from "./panel/popup/code/icons";
|
||||
import { isLocalhost } from "../../utils/ui/is-localhost";
|
||||
|
||||
export const EdBase = () => {
|
||||
const p = useGlobal(EDGlobal, "EDITOR");
|
||||
|
|
@ -31,6 +32,10 @@ export const EdBase = () => {
|
|||
|
||||
edRoute(p);
|
||||
|
||||
const vscode_url = isLocalhost()
|
||||
? "http://localhost:8443?"
|
||||
: "https://prasi-vsc.avolut.com/?tkn=prasi&";
|
||||
|
||||
if (p.status === "load-site") {
|
||||
return (
|
||||
<Loading
|
||||
|
|
@ -41,7 +46,7 @@ export const EdBase = () => {
|
|||
{p.site.id && (
|
||||
<div className="absolute top-[50px]">
|
||||
<a
|
||||
href={`https://prasi-vsc.avolut.com/?tkn=prasi&folder=/site/${p.site.id}/site/src`}
|
||||
href={`${vscode_url}folder=/site/${p.site.id}/site/src`}
|
||||
target="_blank"
|
||||
className={cx(
|
||||
"flex space-x-1 border items-center rounded-md px-2 cursor-pointer pointer-events-auto",
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ export const EdScriptMonaco: FC<{}> = () => {
|
|||
break;
|
||||
case "prop-instance":
|
||||
{
|
||||
types._raw = declareScope(p, meta, monaco);
|
||||
declareScope(p, meta, monaco);
|
||||
const nmodel = monaco.editor.createModel(
|
||||
trim(val),
|
||||
"typescript",
|
||||
|
|
@ -172,7 +172,7 @@ export const EdScriptMonaco: FC<{}> = () => {
|
|||
break;
|
||||
case "item":
|
||||
{
|
||||
types._raw = declareScope(p, meta, monaco);
|
||||
declareScope(p, meta, monaco);
|
||||
const model = monaco.editor.createModel(
|
||||
trim(val),
|
||||
"typescript",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import type { OnMount } from "@monaco-editor/react";
|
|||
import { IContent } from "../../../../../../utils/types/general";
|
||||
import { IMeta, PG, active } from "../../../../logic/ed-global";
|
||||
import { TypedArray } from "yjs-types";
|
||||
import { register } from "../../../../../../utils/script/typings";
|
||||
|
||||
type Monaco = Parameters<OnMount>[1];
|
||||
export type MonacoEditor = Parameters<OnMount>[0];
|
||||
|
|
@ -144,29 +145,42 @@ return typings;
|
|||
m_prev = m;
|
||||
}
|
||||
|
||||
const raw_types: string[] = [];
|
||||
const tree_types: string[] = [];
|
||||
const tree_usage: string[] = [];
|
||||
for (const [k, v] of Object.entries(vars)) {
|
||||
if (v.mode === "local") {
|
||||
raw_types.push(`\
|
||||
const \$\$_${k} = ${v.val};
|
||||
const im = tree_types.length;
|
||||
tree_types.push(`\
|
||||
declare module "item-${im}" {
|
||||
export const \$\$_${k} = ${v.val};
|
||||
}
|
||||
`);
|
||||
tree_usage.push(`
|
||||
import { \$\$_${k} } from "item-${im}";
|
||||
const ${k} = null as unknown as (typeof \$\$_${k} & { render: ()=> void });
|
||||
`);
|
||||
} else if (v.mode === "prop") {
|
||||
raw_types.push(`\
|
||||
const \$\$_${k} = ${v.val};
|
||||
const ${k} = null as unknown as typeof \$\$_${k};`);
|
||||
const im = tree_types.length;
|
||||
tree_types.push(`\
|
||||
|
||||
declare module "item-${im}" {
|
||||
export const \$\$_${k} = ${v.val};
|
||||
}
|
||||
`);
|
||||
tree_usage.push(`
|
||||
import { \$\$_${k} } from "item-${im}";
|
||||
const ${k} = null as unknown as typeof \$\$_${k};
|
||||
`);
|
||||
} else if (v.mode === "type") {
|
||||
raw_types.push(`
|
||||
const ${k} = null as unknown as ${v.val};
|
||||
tree_types.push(`
|
||||
export const ${k} = null as unknown as ${v.val};
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [k, v] of Object.entries(comp_types)) {
|
||||
raw_types.push(v);
|
||||
}
|
||||
|
||||
return raw_types.join("\n");
|
||||
register(monaco, tree_usage.join("\n"), "ts:tree_usage.d.ts");
|
||||
register(monaco, tree_types.join("\n"), "ts:tree_types.d.ts");
|
||||
register(monaco, Object.values(comp_types).join("\n"), "ts:comp_types.d.ts");
|
||||
};
|
||||
|
||||
const map_childs = (
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export const extractProp = (prop: {
|
|||
|
||||
for (const [k, v] of Object.entries(props)) {
|
||||
if (v.type) {
|
||||
if (k === "_raw") {
|
||||
if (k.startsWith("_raw")) {
|
||||
propTypes.push(v.type);
|
||||
} else {
|
||||
let const_or_type = "const";
|
||||
|
|
|
|||
Loading…
Reference in New Issue