This commit is contained in:
Rizky 2024-05-10 14:29:02 +07:00
parent 2e243b9e45
commit e9907507a8
13 changed files with 84 additions and 67 deletions

File diff suppressed because one or more lines are too long

View File

@ -41,7 +41,7 @@ export const ensureLib = async (src_dir: string, id_site: string) => {
} }
} }
} catch (e) { } catch (e) {
console.error(e); // console.error(e);
} }
} }
}; };

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
import { IMeta } from "../../utils/types";
export const devItem = (meta: IMeta) => {
console.log(meta);
}

View File

@ -16,6 +16,7 @@ import { updatePropScope } from "./eval-prop";
import { extractNavigate } from "./extract-nav"; import { extractNavigate } from "./extract-nav";
import { createViLocal } from "./local"; import { createViLocal } from "./local";
import { createViPassProp } from "./passprop"; import { createViPassProp } from "./passprop";
import { devItem } from "./dev-item";
export const viEvalScript = ( export const viEvalScript = (
vi: { vi: {
page: VG["page"]; page: VG["page"];
@ -60,6 +61,7 @@ export const viEvalScript = (
PassProp: script?.PassProp, PassProp: script?.PassProp,
ErrorBox: ErrorBox, ErrorBox: ErrorBox,
newElement: () => {}, newElement: () => {},
_item: meta.mitem ? devItem(meta) : undefined,
render: (jsx: ReactNode) => { render: (jsx: ReactNode) => {
let result = jsx; let result = jsx;
if (isValidElement(jsx) && jsx.props.children) { if (isValidElement(jsx) && jsx.props.children) {
@ -134,9 +136,6 @@ export const viEvalScript = (
...viScriptArg(vi), ...viScriptArg(vi),
...exports, ...exports,
...passprop, ...passprop,
_meta: vi.meta,
_item: meta.item,
_syncm: typeof syncronize !== "undefined" ? syncronize : undefined,
}; };
if (typeof passprop === "object") { if (typeof passprop === "object") {

View File

@ -9,9 +9,6 @@ export const baseTypings = `
const useEffect: typeof React.useEffect; const useEffect: typeof React.useEffect;
const useState: typeof React.useState; const useState: typeof React.useState;
const _meta: Record<string, any>;
const _item: IContent;
const _syncm: (mitem:any, item:any) => void;
const pathname: string; const pathname: string;
const isEditor: boolean; const isEditor: boolean;
const isLayout: boolean; const isLayout: boolean;
@ -30,7 +27,6 @@ export const baseTypings = `
visit: (item: IContent) => void | Promise<void> visit: (item: IContent) => void | Promise<void>
) => void ) => void
) => void;}) => ReactNode; ) => void;}) => ReactNode;
const apiHeaders: Record<string, any>;
const navigate: (url: string) => void; const navigate: (url: string) => void;
const params: any; const params: any;
const cx: (...classNames: any[]) => string; const cx: (...classNames: any[]) => string;
@ -51,11 +47,7 @@ export const baseTypings = `
}; };
const children: RElement; const children: RElement;
const PassProp: FC<Record<string, any> & { children: React.ReactNode }>; type PrasiItemSingle = {
const Preload: FC<{ url: string[] }>;
const apiurl: string;
const pageid: string;
type ITEM = {
id: string; id: string;
name: string; name: string;
type: "item" | "text"; type: "item" | "text";
@ -65,22 +57,24 @@ export const baseTypings = `
css?: string; css?: string;
html?: string; html?: string;
}; };
text: string; text?: string;
html: string; html?: string;
component?: { component?: {
id: string; id: string;
props: Record< props: Record<
string, string,
{ { type: "string" | "raw"; value: string; valueBuilt?: string }
value: string;
valueBuilt: string;
meta: { type: string };
}
>; >;
}; };
childs: ITEM[]; childs: PrasiItemSingle[];
}; };
const newElement: (gen?: (item: ITEM) => ITEM | ITEM[]) => React.ReactNode; type PrasiItem = PrasiItemSingle & {
update: (fn: () => Promise<void> | void) => void;
};
const _item: undefined | PrasiItem;
const PassProp: FC<Record<string, any> & { children: React.ReactNode }>;
const mobile: { const mobile: {
notif: { notif: {
register: (user_id: string) => void; register: (user_id: string) => void;

View File

@ -0,0 +1,25 @@
type PrasiItemSingle = {
id: string;
name: string;
type: "item" | "text";
adv?: {
js?: string;
jsBuilt?: string;
css?: string;
html?: string;
};
text?: string;
html?: string;
component?: {
id: string;
props: Record<
string,
{ type: "string" | "raw"; value: string; valueBuilt?: string }
>;
};
childs: PrasiItemSingle[];
};
export type PrasiItem = PrasiItemSingle & {
update: (fn: () => Promise<void> | void) => void;
};