diff --git a/app/srv/ws/sync/code/templates/typings/global_d_ts b/app/srv/ws/sync/code/templates/typings/global_d_ts index 12b5303a..d4ed029a 100644 --- a/app/srv/ws/sync/code/templates/typings/global_d_ts +++ b/app/srv/ws/sync/code/templates/typings/global_d_ts @@ -58,4 +58,55 @@ declare global { }) => Promise; init: (arg: { port?: number }) => Promise; }; + + type IItem = { + 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: IItem[]; + }; + + type SingleChange = + | { type: "set"; name: string; value: any } + | ({ type: "prop"; name: string } & PropVal); + + type PropVal = + | { mode: "string"; value: string } + | { mode: "raw"; value: string; valueBuilt?: string } + | { mode: "jsx"; value: null | (IItem & PrasiEdit) }; + + type ParentArg = { + item: IItem & PrasiEdit; + child_type: "jsx" | "child"; + child_idx: number; + }; + + type PrasiEdit = { + edit: { + setValue: (name: T, value: IItem[T]) => void; + setProp: (name: string, value: PropVal | string) => void; + pending: SingleChange[]; + readonly childs: (IItem & PrasiEdit)[]; + readonly parent: null | ParentArg; + commit: () => Promise; + readonly props?: Record; + }; + }; + + type PrasiItem = IItem & PrasiEdit; } diff --git a/app/web/src/utils/script/types/base.ts b/app/web/src/utils/script/types/base.ts index 0b56f4fc..711c183f 100644 --- a/app/web/src/utils/script/types/base.ts +++ b/app/web/src/utils/script/types/base.ts @@ -97,7 +97,6 @@ export const baseTypings = ` }; }; - type PrasiItem = IItem & PrasiEdit; const _item: undefined | PrasiItem;