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