wip fix
This commit is contained in:
parent
07c55a63d6
commit
8065a51396
|
|
@ -85,13 +85,11 @@ export const syncHandler: WebSocketHandler<WSData> = {
|
|||
if (baseAction) {
|
||||
const action = baseAction.bind(conn);
|
||||
|
||||
ws.sendBinary(
|
||||
packr.pack({
|
||||
sendWS(ws, {
|
||||
type: SyncType.ActionResult,
|
||||
argid: msg.argid,
|
||||
val: await action(...msg.args),
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ export const ViewMetaScript: FC<{
|
|||
console.warn(`Available var:`, args, `\n\n`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return output.jsx;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { ReactNode } from "react";
|
||||
import { VG } from "../../../logic/global";
|
||||
import { modifyChildScopeIndex } from "./mod-scope-index";
|
||||
import hash_sum from "hash-sum";
|
||||
|
||||
export const createPassProp = (
|
||||
v: VG,
|
||||
|
|
@ -10,15 +11,25 @@ export const createPassProp = (
|
|||
return (arg: Record<string, any> & { children: ReactNode; idx?: any }) => {
|
||||
const meta = v.meta[id];
|
||||
|
||||
if (typeof arg.idx !== "undefined" && meta && meta.item && meta.item.id) {
|
||||
meta.indexed_scope[arg.idx] = {};
|
||||
if (meta && meta.item && meta.item.id) {
|
||||
let idx = arg.idx;
|
||||
if (!idx) {
|
||||
const narg: any = {};
|
||||
for (const [k, v] of Object.entries(arg)) {
|
||||
if (typeof v !== "object" && typeof v !== "function") {
|
||||
narg[k] = v;
|
||||
}
|
||||
}
|
||||
idx = hash_sum(narg);
|
||||
}
|
||||
meta.indexed_scope[idx] = {};
|
||||
|
||||
for (const [k, v] of Object.entries(arg)) {
|
||||
if (k === "children") continue;
|
||||
meta.indexed_scope[arg.idx][k] = v;
|
||||
meta.indexed_scope[idx][k] = v;
|
||||
}
|
||||
|
||||
const scopeIndex = { ...existingScopeIndex, [meta.item.id]: arg.idx };
|
||||
const scopeIndex = { ...existingScopeIndex, [meta.item.id]: idx };
|
||||
|
||||
if (!meta.scope) {
|
||||
meta.scope = {};
|
||||
|
|
@ -38,6 +49,7 @@ export const createPassProp = (
|
|||
if (k === "children") continue;
|
||||
meta.scope[k] = v;
|
||||
}
|
||||
|
||||
return arg.children;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export const mergeScopeUpwards = (
|
|||
|
||||
if (indexedScope || cur.scope || cur.propval) {
|
||||
scope = { ...cur.scope, ...indexedScope, ...cur.propval };
|
||||
|
||||
for (const [k, v] of Object.entries(scope)) {
|
||||
if (typeof finalScope[k] === "undefined") finalScope[k] = v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
import { ReactNode } from "react";
|
||||
|
||||
export const modifyChildScopeIndex = (
|
||||
child: ReactNode | ReactNode[],
|
||||
_scopeIndex: Record<string, any>
|
||||
) => {
|
||||
if (Array.isArray(child)) {
|
||||
const childs: any[] = [];
|
||||
for (const c of child) {
|
||||
childs.push(modifyChildScopeIndex(c, _scopeIndex));
|
||||
}
|
||||
return childs;
|
||||
}
|
||||
if (typeof child === "object" && child) {
|
||||
return { ...child, props: { ...(child as any).props, _scopeIndex } };
|
||||
}
|
||||
return child;
|
||||
};
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import { Fragment, ReactNode } from "react";
|
||||
|
||||
export const modifyChildScopeIndex = (
|
||||
child: ReactNode | ReactNode[],
|
||||
scopeIndex: Record<string, any>
|
||||
) => {
|
||||
if (Array.isArray(child)) {
|
||||
const childs: any[] = [];
|
||||
for (const c of child) {
|
||||
childs.push(modifyChildScopeIndex(c, scopeIndex));
|
||||
}
|
||||
return childs;
|
||||
}
|
||||
|
||||
if (typeof child === "object" && child) {
|
||||
const c = child as any;
|
||||
if (c.type === Fragment) {
|
||||
return (
|
||||
<Fragment key={c.key}>
|
||||
{modifyChildScopeIndex(c.props.children, scopeIndex)}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
return { ...child, props: { ...(child as any).props, scopeIndex } };
|
||||
}
|
||||
return child;
|
||||
};
|
||||
|
|
@ -32,7 +32,7 @@ export const createServer = async () => {
|
|||
maxPayloadLength: 9999999,
|
||||
closeOnBackpressureLimit: true,
|
||||
drain(ws) {
|
||||
console.log("Backpressure relieved...");
|
||||
// console.log("Backpressure relieved...");
|
||||
},
|
||||
close(ws, code, reason) {
|
||||
const pathname = ws.data.url.pathname;
|
||||
|
|
|
|||
Loading…
Reference in New Issue