fix
This commit is contained in:
parent
537999cb64
commit
b6b849d902
File diff suppressed because one or more lines are too long
|
|
@ -83,9 +83,10 @@ declare global {
|
||||||
|
|
||||||
type SingleChange =
|
type SingleChange =
|
||||||
| { type: "set"; name: string; value: any }
|
| { type: "set"; name: string; value: any }
|
||||||
| ({ type: "prop"; name: string } & PropVal);
|
| ({ type: "prop"; name: string } & PropVal)
|
||||||
|
| { type: "child"; childs: SimpleItem[] };
|
||||||
|
|
||||||
type PropVal =
|
export type PropVal =
|
||||||
| { mode: "string"; value: string }
|
| { mode: "string"; value: string }
|
||||||
| { mode: "raw"; value: string; valueBuilt?: string }
|
| { mode: "raw"; value: string; valueBuilt?: string }
|
||||||
| { mode: "jsx"; value: null | (IItem & PrasiEdit) };
|
| { mode: "jsx"; value: null | (IItem & PrasiEdit) };
|
||||||
|
|
@ -96,12 +97,17 @@ declare global {
|
||||||
child_idx: number;
|
child_idx: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PrasiEdit = {
|
type SimpleItem = Partial<Omit<IItem, "component">> & {
|
||||||
|
component?: { id: string; props: Record<string, PropVal> };
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PrasiEdit = {
|
||||||
edit: {
|
edit: {
|
||||||
setValue: <T extends keyof IItem>(name: T, value: IItem[T]) => void;
|
setValue: <T extends keyof IItem>(name: T, value: IItem[T]) => void;
|
||||||
setProp: (name: string, value: PropVal | string) => void;
|
setProp: (name: string, value: PropVal | string) => void;
|
||||||
pending: SingleChange[];
|
pending: SingleChange[];
|
||||||
readonly childs: (IItem & PrasiEdit)[];
|
childs: (IItem & PrasiEdit)[];
|
||||||
|
setChilds: (childs: ((IItem & PrasiEdit) | SimpleItem)[]) => void;
|
||||||
readonly parent: null | ParentArg;
|
readonly parent: null | ParentArg;
|
||||||
commit: () => Promise<void>;
|
commit: () => Promise<void>;
|
||||||
readonly props?: Record<string, PropVal>;
|
readonly props?: Record<string, PropVal>;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useGlobal } from "web-utils";
|
import { useGlobal, useLocal } from "web-utils";
|
||||||
import { AutoHeightTextarea } from "../../../../../utils/ui/auto-textarea";
|
import { AutoHeightTextarea } from "../../../../../utils/ui/auto-textarea";
|
||||||
import { EDGlobal } from "../../../logic/ed-global";
|
import { EDGlobal } from "../../../logic/ed-global";
|
||||||
import { apiRef, apiUrl, server } from "./api-utils";
|
import { apiRef, apiUrl, server } from "./api-utils";
|
||||||
|
|
@ -13,15 +13,18 @@ export const EdApiDB = ({
|
||||||
update: () => void;
|
update: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const p = useGlobal(EDGlobal, "EDITOR");
|
const p = useGlobal(EDGlobal, "EDITOR");
|
||||||
|
const local = useLocal({ url: db.url });
|
||||||
const api = apiRef[apiUrl(p)];
|
const api = apiRef[apiUrl(p)];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex border-b py-2 px-2 border-slate-300 boxed flex flex-col items-stretch">
|
<div className="flex border-b py-2 px-2 border-slate-300 boxed flex-col items-stretch">
|
||||||
<AutoHeightTextarea
|
<AutoHeightTextarea
|
||||||
value={db.url}
|
value={local.url}
|
||||||
className="text-[13px] border p-2 mb-2 "
|
className="text-[13px] border p-2 mb-2 "
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
db.url = e.currentTarget.value;
|
local.url = e.currentTarget.value;
|
||||||
p.render();
|
db.url = local.url;
|
||||||
|
local.render();
|
||||||
}}
|
}}
|
||||||
onBlur={async () => {
|
onBlur={async () => {
|
||||||
update();
|
update();
|
||||||
|
|
@ -57,6 +60,7 @@ export const EdApiDB = ({
|
||||||
"api-ts-" + p.site.config.api_url,
|
"api-ts-" + p.site.config.api_url,
|
||||||
Date.now().toString()
|
Date.now().toString()
|
||||||
);
|
);
|
||||||
|
location.reload();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
DB Pull
|
DB Pull
|
||||||
|
|
@ -74,6 +78,7 @@ export const EdApiDB = ({
|
||||||
server.status = "ready";
|
server.status = "ready";
|
||||||
render();
|
render();
|
||||||
alert("RESTART: OK");
|
alert("RESTART: OK");
|
||||||
|
location.reload();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Restart Server
|
Restart Server
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,11 @@ export const initLoadComp = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const component of comps) {
|
for (const component of comps) {
|
||||||
for (const prop of Object.values(component.props)) {
|
if (component.props) {
|
||||||
if (prop.meta?.type === "content-element" && prop.content) {
|
for (const prop of Object.values(component.props)) {
|
||||||
await initLoadComp(p, prop.content, opt, loaded);
|
if (prop.meta?.type === "content-element" && prop.content) {
|
||||||
|
await initLoadComp(p, prop.content, opt, loaded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export const instantiate = (arg: {
|
||||||
newitem.hidden = item.hidden;
|
newitem.hidden = item.hidden;
|
||||||
|
|
||||||
if (newitem.component) {
|
if (newitem.component) {
|
||||||
if (newitem.component.props && item.component) {
|
if (newitem.component.props && item.component && item.component.props) {
|
||||||
for (const k of Object.keys(newitem.component.props)) {
|
for (const k of Object.keys(newitem.component.props)) {
|
||||||
const cprop = item.component.props[k];
|
const cprop = item.component.props[k];
|
||||||
const nprop = newitem.component.props[k];
|
const nprop = newitem.component.props[k];
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ const w = window as unknown as {
|
||||||
type SingleChange =
|
type SingleChange =
|
||||||
| { type: "set"; name: string; value: any }
|
| { type: "set"; name: string; value: any }
|
||||||
| ({ type: "prop"; name: string } & PropVal)
|
| ({ type: "prop"; name: string } & PropVal)
|
||||||
| { type: "child"; childs: SimpleItem[] };
|
| { type: "child"; childs: ((IItem & PrasiEdit) | SimpleItem)[] };
|
||||||
|
|
||||||
export type PropVal =
|
export type PropVal =
|
||||||
| { mode: "string"; value: string }
|
| { mode: "string"; value: string }
|
||||||
|
|
@ -32,7 +32,7 @@ export type PrasiEdit = {
|
||||||
setProp: (name: string, value: PropVal | string) => void;
|
setProp: (name: string, value: PropVal | string) => void;
|
||||||
pending: SingleChange[];
|
pending: SingleChange[];
|
||||||
childs: (IItem & PrasiEdit)[];
|
childs: (IItem & PrasiEdit)[];
|
||||||
setChilds: (childs: SimpleItem[]) => void;
|
setChilds: (childs: ((IItem & PrasiEdit) | SimpleItem)[]) => void;
|
||||||
readonly parent: null | ParentArg;
|
readonly parent: null | ParentArg;
|
||||||
commit: () => Promise<void>;
|
commit: () => Promise<void>;
|
||||||
readonly props?: Record<string, PropVal>;
|
readonly props?: Record<string, PropVal>;
|
||||||
|
|
@ -197,8 +197,9 @@ export const devItem = (
|
||||||
mitem.doc?.transact(() => {
|
mitem.doc?.transact(() => {
|
||||||
for (const [k, v] of Object.entries(result)) {
|
for (const [k, v] of Object.entries(result)) {
|
||||||
const m = metas[k];
|
const m = metas[k];
|
||||||
|
|
||||||
if (m.mitem) {
|
if (m.mitem) {
|
||||||
syncronize(m.mitem as any, v);
|
console.log(syncronize(m.mitem as any, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -306,7 +307,7 @@ export const devItem = (
|
||||||
} as IItem & PrasiEdit;
|
} as IItem & PrasiEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
const complexifyProps = async (
|
const complexifyProps = (
|
||||||
props: Record<string, PropVal>,
|
props: Record<string, PropVal>,
|
||||||
compileValueBuilt: Record<string, { value: string; valueBuilt?: string }>
|
compileValueBuilt: Record<string, { value: string; valueBuilt?: string }>
|
||||||
) => {
|
) => {
|
||||||
|
|
|
||||||
|
|
@ -68,41 +68,39 @@ export const baseTypings = `
|
||||||
};
|
};
|
||||||
childs: IItem[];
|
childs: IItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type SingleChange =
|
type SingleChange =
|
||||||
| { type: "set"; name: string; value: any }
|
| { type: "set"; name: string; value: any }
|
||||||
| ({ type: "prop"; name: string } & PropVal)
|
| ({ type: "prop"; name: string } & PropVal)
|
||||||
| { type: "child"; childs: SimpleItem[] };
|
| { type: "child"; childs: SimpleItem[] };
|
||||||
|
|
||||||
export type PropVal =
|
export type PropVal =
|
||||||
| { mode: "string"; value: string }
|
| { mode: "string"; value: string }
|
||||||
| { mode: "raw"; value: string; valueBuilt?: string }
|
| { mode: "raw"; value: string; valueBuilt?: string }
|
||||||
| { mode: "jsx"; value: null | (IItem & PrasiEdit) };
|
| { mode: "jsx"; value: null | (IItem & PrasiEdit) };
|
||||||
|
|
||||||
type ParentArg = {
|
type ParentArg = {
|
||||||
item: IItem & PrasiEdit;
|
item: IItem & PrasiEdit;
|
||||||
child_type: "jsx" | "child";
|
child_type: "jsx" | "child";
|
||||||
child_idx: number;
|
child_idx: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SimpleItem = Partial<Omit<IItem, "component">> & {
|
type SimpleItem = Partial<Omit<IItem, "component">> & {
|
||||||
component?: { id: string; props: Record<string, PropVal> };
|
component?: { id: string; props: Record<string, PropVal> };
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PrasiEdit = {
|
export type PrasiEdit = {
|
||||||
edit: {
|
edit: {
|
||||||
setValue: <T extends keyof IItem>(name: T, value: IItem[T]) => void;
|
setValue: <T extends keyof IItem>(name: T, value: IItem[T]) => void;
|
||||||
setProp: (name: string, value: PropVal | string) => void;
|
setProp: (name: string, value: PropVal | string) => void;
|
||||||
pending: SingleChange[];
|
pending: SingleChange[];
|
||||||
childs: (IItem & PrasiEdit)[];
|
childs: (IItem & PrasiEdit)[];
|
||||||
setChilds: (childs: SimpleItem[]) => void;
|
setChilds: (childs: ((IItem & PrasiEdit) | SimpleItem)[]) => void;
|
||||||
readonly parent: null | ParentArg;
|
readonly parent: null | ParentArg;
|
||||||
commit: () => Promise<void>;
|
commit: () => Promise<void>;
|
||||||
readonly props?: Record<string, PropVal>;
|
readonly props?: Record<string, PropVal>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
type PrasiItem = IItem & PrasiEdit;
|
|
||||||
|
|
||||||
const _item: undefined | PrasiItem;
|
const _item: undefined | PrasiItem;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --hot ./pkgs/core/index.ts dev",
|
"dev": "bun run --no-clear-screen --hot ./pkgs/core/index.ts dev",
|
||||||
"clean": "rm -rf data/lmdb && rm -rf app/static && rm -rf app/web/.parcel-cache",
|
"clean": "rm -rf data/lmdb && rm -rf app/static && rm -rf app/web/.parcel-cache",
|
||||||
"build": "bun run --silent ./pkgs/core/build.ts",
|
"build": "bun run --silent ./pkgs/core/build.ts",
|
||||||
"db-pull": "bun run ./pkgs/core/db-pull.ts",
|
"db-pull": "bun run ./pkgs/core/db-pull.ts",
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export const prepareApiRoutes = async () => {
|
||||||
const api = await import(importPath);
|
const api = await import(importPath);
|
||||||
let args: string[] = await parseArgs(importPath);
|
let args: string[] = await parseArgs(importPath);
|
||||||
const route = {
|
const route = {
|
||||||
url: api._.url,
|
url: api._.url,
|
||||||
args,
|
args,
|
||||||
raw: !!api._.raw,
|
raw: !!api._.raw,
|
||||||
fn: api._.api,
|
fn: api._.api,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue