wip fix
This commit is contained in:
parent
3dd306bc87
commit
220fbc2640
|
|
@ -80,6 +80,12 @@ export const parseJs = (meta: IMeta) => {
|
|||
value: code.substring(loc.start.index, loc.end.index),
|
||||
index: loc.start.index,
|
||||
};
|
||||
} else if (attr.value.loc) {
|
||||
const loc = attr.value.loc as any;
|
||||
passprop[attr.name.name] = {
|
||||
value: code.substring(loc.start.index, loc.end.index),
|
||||
index: loc.start.index,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,21 @@ import { loadApiProxyDef } from "./api-proxy-def";
|
|||
|
||||
export type ApiProxy<T extends Record<string, any> = {}> = any;
|
||||
|
||||
const apiProxyPending: Record<string, Promise<void>> = {};
|
||||
|
||||
export const apiProxy = (api_url: string) => {
|
||||
if (!w.prasiApi) {
|
||||
w.prasiApi = {};
|
||||
}
|
||||
|
||||
const base = new URL(api_url);
|
||||
const base_url = `${base.protocol}//${base.host}`;
|
||||
if (!w.prasiApi[base_url]) {
|
||||
if (!apiProxyPending[base_url]) {
|
||||
apiProxyPending[base_url] = loadApiProxyDef(base_url, false);
|
||||
}
|
||||
}
|
||||
|
||||
return new Proxy(
|
||||
{},
|
||||
{
|
||||
|
|
@ -16,20 +30,12 @@ export const apiProxy = (api_url: string) => {
|
|||
) {
|
||||
return new Promise<any>(async (resolve, reject) => {
|
||||
try {
|
||||
let base_url = api_url;
|
||||
if (typeof this?.api_url === "string") {
|
||||
base_url = this.api_url;
|
||||
let api_def = w.prasiApi[base_url];
|
||||
|
||||
if (!api_def) {
|
||||
await apiProxyPending[base_url];
|
||||
}
|
||||
|
||||
if (!w.prasiApi) {
|
||||
w.prasiApi = {};
|
||||
}
|
||||
|
||||
if (!w.prasiApi[base_url]) {
|
||||
await loadApiProxyDef(base_url, false);
|
||||
}
|
||||
|
||||
const api_def = w.prasiApi[base_url];
|
||||
if (api_def) {
|
||||
if (!api_def.apiEntry) api_def.apiEntry = {};
|
||||
if (api_def.apiEntry && !api_def.apiEntry[actionName]) {
|
||||
|
|
|
|||
|
|
@ -42,13 +42,35 @@ export const declareScope = async (
|
|||
if (def.local) {
|
||||
addScope({
|
||||
monaco,
|
||||
loc: { item_id: m.item.id, type: "item" },
|
||||
loc: {
|
||||
item_id: m.item.id,
|
||||
comp_id: m.parent?.comp_id,
|
||||
type: "item",
|
||||
},
|
||||
source: `\
|
||||
export const {};
|
||||
declare global {
|
||||
const ${def.local.name} = ${def.local.value};
|
||||
}`,
|
||||
});
|
||||
} else if (def.passprop) {
|
||||
Object.keys(def.passprop).map((e) => {
|
||||
if (e !== "idx" && e !== "key") {
|
||||
addScope({
|
||||
monaco,
|
||||
loc: {
|
||||
item_id: m.item.id,
|
||||
comp_id: m.parent?.comp_id,
|
||||
type: "item",
|
||||
},
|
||||
source: `\
|
||||
export const {};
|
||||
declare global {
|
||||
const ${e} = null as any;
|
||||
}`,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (def.props) {
|
||||
Object.keys(def.props).map((e) => {
|
||||
addScope({
|
||||
|
|
|
|||
|
|
@ -39,6 +39,26 @@ effect={async (local) => {
|
|||
}}
|
||||
>
|
||||
<Local/>
|
||||
</Button>{" "}
|
||||
<Button
|
||||
className={cx(css`
|
||||
width: auto !important;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
font-size: 12px;
|
||||
`)}
|
||||
onClick={() => {
|
||||
p.script.do_edit(
|
||||
`\
|
||||
<PassProp idx={0}>
|
||||
{children}
|
||||
</PassProp>
|
||||
`,
|
||||
false
|
||||
);
|
||||
}}
|
||||
>
|
||||
<Passprop/>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ export const EdTreeName = ({
|
|||
}}
|
||||
onBlur={() => {
|
||||
item.name = local.rename;
|
||||
|
||||
const mitem = node.data?.mitem;
|
||||
if (mitem) {
|
||||
mitem.set("name", item.name);
|
||||
}
|
||||
p.ui.tree.rename_id = "";
|
||||
p.render();
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export const ViScript: FC<{ meta: IMeta; children: ReactNode }> = ({
|
|||
const scope_meta = getScopeMeta({ meta: vi.meta }, meta);
|
||||
const scope = getScopeValue(scope_meta);
|
||||
|
||||
|
||||
if (meta.item.component?.id) {
|
||||
viEvalProps(vi, meta, scope);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,11 @@ export const createViPassProp = (
|
|||
}
|
||||
|
||||
for (const [k, v] of Object.entries(arg)) {
|
||||
if (k === "key" || k === "idx") continue;
|
||||
|
||||
if (k !== "children") {
|
||||
delete meta.scope.val[k];
|
||||
meta.scope.val = {
|
||||
...meta.scope.val,
|
||||
get [k]() {
|
||||
return v;
|
||||
},
|
||||
};
|
||||
meta.scope.val[k] = v;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,21 +21,22 @@ export const getScopeMeta = (
|
|||
}
|
||||
}
|
||||
|
||||
for (const meta of scopes_meta) {
|
||||
const def = meta.scope.def;
|
||||
for (const m of scopes_meta) {
|
||||
const def = m.scope.def;
|
||||
if (def) {
|
||||
if (def.passprop) {
|
||||
for (const p of Object.keys(def.passprop)) {
|
||||
scope_meta[p] = { type: "passprop", meta };
|
||||
console.log(meta.item.name, p, def.passprop)
|
||||
scope_meta[p] = { type: "passprop", meta: m };
|
||||
}
|
||||
}
|
||||
if (def.props) {
|
||||
for (const p of Object.keys(def.props)) {
|
||||
scope_meta[p] = { type: "jsxprop", meta };
|
||||
scope_meta[p] = { type: "jsxprop", meta: m };
|
||||
}
|
||||
}
|
||||
if (def.local) {
|
||||
scope_meta[def.local.name] = { type: "local", meta };
|
||||
scope_meta[def.local.name] = { type: "local", meta: m };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +55,3 @@ export const getScopeValue = (scope_meta: ReturnType<typeof getScopeMeta>) => {
|
|||
|
||||
return scope;
|
||||
};
|
||||
|
||||
// export const getScope = (vi: { meta: VG["meta"] }, meta: IMeta) => {
|
||||
|
||||
// };
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ export const SiteManager = () => {
|
|||
},
|
||||
});
|
||||
|
||||
console.log(orgs);
|
||||
if (orgs) {
|
||||
orgs.push({
|
||||
org: {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export const baseTypings = `
|
|||
name: string;
|
||||
idx?: any;
|
||||
value: T;
|
||||
children: (local: T & { render: () => void }) => any;
|
||||
children: ReactNode;
|
||||
deps?: any[];
|
||||
effect?: (
|
||||
local: T & { render: () => void }
|
||||
|
|
|
|||
|
|
@ -19,43 +19,48 @@ export const monacoTypings = async (
|
|||
if (!map.has(prop.values)) {
|
||||
map.set(prop.values, true);
|
||||
} else {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (w.prasiApi[p.site.api_url] && w.prasiApi[p.site.api_url].prismaTypes) {
|
||||
const prisma = w.prasiApi[p.site.api_url].prismaTypes;
|
||||
const prasi_api = w.prasiApi[p.site.api_url];
|
||||
if (prasi_api) {
|
||||
if (prasi_api && prasi_api.prismaTypes) {
|
||||
const prisma = prasi_api.prismaTypes;
|
||||
|
||||
register(
|
||||
monaco,
|
||||
`\
|
||||
if (prisma) {
|
||||
register(
|
||||
monaco,
|
||||
`\
|
||||
declare module "ts:runtime/index" {
|
||||
${prisma["runtime/index.d.ts"]}
|
||||
}`,
|
||||
`ts:runtime/index.d.ts`
|
||||
);
|
||||
`ts:runtime/index.d.ts`
|
||||
);
|
||||
|
||||
register(
|
||||
monaco,
|
||||
`\
|
||||
register(
|
||||
monaco,
|
||||
`\
|
||||
declare module "ts:runtime/library" {
|
||||
${prisma["runtime/library.d.ts"]}
|
||||
}`,
|
||||
`ts:runtime/library.d.ts`
|
||||
);
|
||||
`ts:runtime/library.d.ts`
|
||||
);
|
||||
|
||||
register(
|
||||
monaco,
|
||||
`\
|
||||
register(
|
||||
monaco,
|
||||
`\
|
||||
declare module "ts:prisma" {
|
||||
${prisma["prisma.d.ts"].replace(
|
||||
`import * as runtime from './runtime/library';`,
|
||||
`import * as runtime from 'ts:runtime/library';`
|
||||
)}
|
||||
}`,
|
||||
`ts:prisma.d.ts`
|
||||
);
|
||||
|
||||
register(monaco, w.prasiApi[p.site.api_url].apiTypes, "ts:api.d.ts");
|
||||
`ts:prisma.d.ts`
|
||||
);
|
||||
}
|
||||
const api_types = prasi_api.apiTypes;
|
||||
if (api_types) register(monaco, api_types, "ts:api.d.ts");
|
||||
}
|
||||
}
|
||||
|
||||
monaco.languages.typescript.typescriptDefaults.setExtraLibs([
|
||||
|
|
|
|||
Loading…
Reference in New Issue